You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 27, 2024. It is now read-only.
Now we have a basic UI for Stats screen, we need to prepare a data to be able to build the remaining part of the screen. Here is the sample screen:
You might notice that we have a PieChart to show the ratio of the expenses/incomes in a chart shape. Also below we have them as a list. That means both chart and list will be using the same data. Now, if we look at the data, we need to filter them by month and transaction type (e.g. give me expense transactions for November grouped by categories). Repository part has been implemented, so we have the following method for it:
override fun getTransactionsWithinDateByType(
from: Long,
to: Long,
categoryType: Int
): Flow<List<Transaction>> {
return database
.transactionDao()
.getTransactionsWithinDateByType(from, to, categoryType)
.map(TransactionDbMapper::mapTransactionListFromDb)
}
However, our transaction adding part is not done yet, that's why we have to mock that data for now. So, comment out the real implementation of getTransactionsWithinDateByType from TransactionRepositoryImpl, then add a hardcoded list of Flow. Let's say, mocked list will consist of expenses:
One transaction of any category
Two transactions with the same category id, but with different amounts and different days of the current month
Three transactions with the same category id, but with different amounts and different days of the current month
The reason to give these is, we need to verify that the logic for use case is working properly.
Now, our repository part is done, we will work on the original job of the task. We need to create a use case, which is a business logic for the app. Call it GetCategoriesWithAmountUseCase, and it needs to extend from UseCaseWithParam. You can refer to com.shagalalab.qarejet.domain.interactor.transaction.GetCategoriesWithAmountUseCase from old qarejet implementation. You will need to implement similar logic.
Task
Add mock implementation of repository method and implement use case to get categories with amount
branch: feature/stats-use-case
classes to be added: com.shagalalab.feature.stats.domain.GetCategoriesWithAmountUseCase
classes to be modified: TransactionRepositoryImpl#getTransactionsWithinDateByType
Acception criteria
TransactionRepositoryImpl#getTransactionsWithinDateByType has mocked list of transactions
GetCategoriesWithAmountUseCase has been created, and it sum up the amounts for the same category
The text was updated successfully, but these errors were encountered:
Now we have a basic UI for Stats screen, we need to prepare a data to be able to build the remaining part of the screen. Here is the sample screen:
![Screenshot_1605528793](https://user-images.githubusercontent.com/8268042/99251653-cd864680-2861-11eb-8123-5b443d665fb3.png)
You might notice that we have a
PieChart
to show the ratio of the expenses/incomes in a chart shape. Also below we have them as a list. That means both chart and list will be using the same data. Now, if we look at the data, we need to filter them by month and transaction type (e.g. give me expense transactions for November grouped by categories). Repository part has been implemented, so we have the following method for it:However, our transaction adding part is not done yet, that's why we have to mock that data for now. So, comment out the real implementation of
getTransactionsWithinDateByType
fromTransactionRepositoryImpl
, then add a hardcoded list ofFlow
. Let's say, mocked list will consist of expenses:The reason to give these is, we need to verify that the logic for use case is working properly.
Now, our repository part is done, we will work on the original job of the task. We need to create a use case, which is a business logic for the app. Call it
GetCategoriesWithAmountUseCase
, and it needs to extend fromUseCaseWithParam
. You can refer tocom.shagalalab.qarejet.domain.interactor.transaction.GetCategoriesWithAmountUseCase
from old qarejet implementation. You will need to implement similar logic.Task
Add mock implementation of repository method and implement use case to get categories with amount
feature/stats-use-case
com.shagalalab.feature.stats.domain.GetCategoriesWithAmountUseCase
TransactionRepositoryImpl#getTransactionsWithinDateByType
Acception criteria
TransactionRepositoryImpl#getTransactionsWithinDateByType
has mocked list of transactionsGetCategoriesWithAmountUseCase
has been created, and it sum up the amounts for the same categoryThe text was updated successfully, but these errors were encountered: