Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Add mock data for stats #38

Open
atabekm opened this issue Nov 16, 2020 · 0 comments
Open

Add mock data for stats #38

atabekm opened this issue Nov 16, 2020 · 0 comments
Assignees
Labels

Comments

@atabekm
Copy link
Member

atabekm commented Nov 16, 2020

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
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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants