Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"path": "C:\\Program Files\\Eclipse Adoptium\\jdk-21.0.9.10-hotspot",
"default": true
}
]
],
"java.configuration.updateBuildConfiguration": "disabled"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.pledgerio.app.reports.domain.usecase

import com.pledgerio.app.shared.Resource
import com.pledgerio.app.accounts.domain.model.Account
import com.pledgerio.app.accounts.domain.model.AccountType
import com.pledgerio.app.transactions.domain.model.Transaction
import com.pledgerio.app.accounts.domain.repository.AccountRepository
import com.pledgerio.app.transactions.domain.repository.TransactionRepository
Expand Down Expand Up @@ -37,7 +38,12 @@ class GetDashboardDataUseCase @Inject constructor(
DashboardData(
accounts = accounts,
recentTransactions = transactions,
netWorth = accounts.sumOf { it.balance },
netWorth = accounts.filter { account ->
when (account.type) {
AccountType.CHECKING, AccountType.SAVINGS, AccountType.CREDIT_CARD -> true
else -> false
}
}.sumOf { it.balance },
monthlyIncome = transactions
.filter { it.type == com.pledgerio.app.transactions.domain.model.TransactionType.DEBIT }
.sumOf { it.amount },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,27 @@ class GetDashboardDataUseCaseTest {
assertEquals(2, data.recentTransactions.size)
}

@Test
fun `net worth only includes checking savings and credit cards`() = runTest {
val accounts = listOf(
Account(id = 1, name = "Checking", balance = 1000.0, typeCode = "default"),
Account(id = 2, name = "Joint checking", balance = 500.0, typeCode = "joined"),
Account(id = 3, name = "Joint savings", balance = 5000.0, typeCode = "joined_savings"),
Account(id = 4, name = "Credit card", balance = -200.0, typeCode = "credit_card"),
Account(id = 5, name = "Loan", balance = -3000.0, typeCode = "loan"),
Account(id = 6, name = "Mortgage", balance = -9000.0, typeCode = "mortgage"),
Account(id = 7, name = "Investments", balance = 700.0, typeCode = "investment"),
Account(id = 8, name = "Cash", balance = 100.0, typeCode = "cash"),
)
every { accountRepository.getAccounts() } returns flowOf(Resource.Success(accounts))
every { transactionRepository.getRecentTransactions(5) } returns flowOf(Resource.Success(emptyList()))

val result = useCase().first() as Resource.Success

assertEquals(6300.0, result.data.netWorth, 0.01)
assertEquals(accounts, result.data.accounts)
}

@Test
fun `returns account error when accounts fail`() = runTest {
every { accountRepository.getAccounts() } returns flowOf(Resource.Error("Network down"))
Expand Down
2 changes: 1 addition & 1 deletion docs/FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This describes the checked-in implementation. Server-backed features depend on t
| Capability | Behavior and entry point | Implementation |
|---|---|---|
| Setup and login | Configure/validate server, password login with TOTP verification when required, refresh session, change server, log out | `ui/onboarding`, `AuthRepository`, `SessionManager` |
| Dashboard | Accounts, income/expense summary, recent transactions, spending insights, add actions | `ui/dashboard`, `GetDashboardDataUseCase` |
| Dashboard | Accounts, net worth from checking, savings, and credit cards, income/expense summary, recent transactions, spending insights, add actions | `ui/dashboard`, `GetDashboardDataUseCase` |
| Transactions | Month navigation, paging, filters, detail, create/edit/delete | `ui/transactions`, `TransactionRepository` |
| Transaction entry | Income/expense/transfer, category, expense group, contract, tags, templates, splits, classification suggestions | `TransactionFormViewModel`, `ui/transactions/form` |
| Invoice scan | Camera or image picker, local OCR, backend text interpretation, review/edit prefilled form before saving | `ui/transactions/scan`, `ProcessInvoiceScanUseCase` |
Expand Down
Loading