Implement expense interactors #2
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Overview
Implements the
expensefeature — 6 interactors covering read, write, search, and summary. Depends on #1 (DI foundation +categoryinteractor set).Prerequisites
Issue #1 must be merged first. This gives you:
AppDatabase+CategoryDao+ExpenseDaoalready wiredCategorydomain model +GetCategoriesinteractorExpense,DateRange,ExpenseWithCategory,ExpenseSummarydomain models already in placeWhat to do
1. Define signatures + TODOs
Create these 6 files under
domain/expense/interactor/:GetExpenses.kt—subscribeAll(),subscribeByDateRange(range),awaitOne(id),awaitAll(query, range?)UpsertExpense.kt—await(expense): LongInsertExpenses.kt—awaitAll(expenses: List<Expense>)DeleteExpense.kt—await(id)ReassignExpenseCategory.kt—await(fromCategoryId, toCategoryId)GetExpenseSummary.kt—await(range): ExpenseSummaryFor
GetExpenses.awaitOne(id): implement by callingexpenseDao.getById(id)+categoryDao.getById(expense.categoryId), returningnullif either is null, otherwiseExpenseWithCategory(expense.toModel(), category.toModel()). Add the appropriate TODO body.For
GetExpenses.awaitAll(query, range?): do the post-fetch filter in Kotlin. FetchcategoryDao.getAll()once, build aMap<Long, Category>, fetch expenses viaexpenseDao.search(range?.start?.toEpochDay(), range?.end?.toEpochDay()), filter byqueryagainstnote/amount.toString()/category.name, map toExpenseWithCategory.2. Implement all 6 interactors (replace TODOs)
Refer to
docs/03-function-todos.mdfor exact per-method behavior and edge cases. Highlights:InsertExpenses.awaitAll: bulk insert viadao.insertAll, allidmust be 0.ReassignExpenseCategory.await: single SQL update.GetExpenseSummary.await: fetch expenses in range, sum total, group by category, sort DESC.3. Add to
DomainModule4. Verify compilation
Run
./gradlew assembleDebug. Must succeed.Acceptance
DomainModulehas the 6 new factories./gradlew assembleDebugsucceedsImplementation rule
Per
AGENTS.md— do not start implementation without explicit user sign-off on this issue. When working, check for related issues in the remote repo first.