Description
A user requested the ability to see a wallet's balance at the end of any selected month (e.g., balance on May 31st), not just the all-time/today balance. This is needed to compare Oinkoin data with monthly bank statements.
Current behavior:
- The "Accounts" row on the homescreen shows the all-time balance of selected wallets (SQL:
SUM(r.value) across ALL records + initial_amount + transfers).
- This balance does not change when the user navigates to a past month — it always reflects today's total.
- The Income/Expenses row below IS correctly scoped to the selected time period, but the Accounts row is not.
Requested behavior:
- When viewing a past month (e.g., May 2026), the Accounts row should show the balance at the end of that month (May 31st), not the current balance.
- The user wants this per-wallet (not just combined), so they can cross-check individual accounts against bank statements.
Proposed Solution
- Scope the Accounts row balance to the selected time period: Instead of showing the all-time wallet balance, calculate the balance as of the end of the selected time interval (e.g.,
endOfMonth for monthly view, endOfYear for yearly, etc.).
- Tapping the Accounts row opens a per-wallet breakdown: Currently tapping the row opens the WalletPickerPage (multi-select filter). Change this to show a per-wallet split at the selected time period, so the user can see each wallet's individual end-of-period balance.
- Current month behavior: Keep showing the current balance when the current month is selected (end-of-current-month balance, which matches today).
Technical Context
- Wallet balance is computed in
lib/services/database/sqlite-database.dart:648-662 via _walletBalanceQuery(), which has no date filter.
- A new SQL query or in-memory filtering is needed to add
WHERE r.datetime <= :endDate to both the main JOIN and the transfer subquery.
- The balance is exposed via
_controller.selectedWalletsBalance / selectedWalletsBalanceString in lib/records/controllers/tab_records_controller.dart:774-784.
- The Accounts row UI is in
lib/records/components/days-summary-box-card.dart:104-130.
Files Likely Affected
lib/services/database/sqlite-database.dart — Add a point-in-time balance query
lib/records/controllers/tab_records_controller.dart — Use period-scoped balance instead of all-time
lib/records/components/days-summary-box-card.dart — UI adjustments (optional)
lib/wallets/wallet-picker-page.dart or new page — Per-wallet breakdown view
Notes
- The balance must account for: outgoing records (
r.value where r.wallet_id = w.id), incoming transfers (ABS(t.value) where t.transfer_wallet_id = w.id), and w.initial_amount.
- Future/planned records (from recurring patterns) should be excluded when calculating past end-of-period balances.
Description
A user requested the ability to see a wallet's balance at the end of any selected month (e.g., balance on May 31st), not just the all-time/today balance. This is needed to compare Oinkoin data with monthly bank statements.
Current behavior:
SUM(r.value)across ALL records + initial_amount + transfers).Requested behavior:
Proposed Solution
endOfMonthfor monthly view,endOfYearfor yearly, etc.).Technical Context
lib/services/database/sqlite-database.dart:648-662via_walletBalanceQuery(), which has no date filter.WHERE r.datetime <= :endDateto both the main JOIN and the transfer subquery._controller.selectedWalletsBalance/selectedWalletsBalanceStringinlib/records/controllers/tab_records_controller.dart:774-784.lib/records/components/days-summary-box-card.dart:104-130.Files Likely Affected
lib/services/database/sqlite-database.dart— Add a point-in-time balance querylib/records/controllers/tab_records_controller.dart— Use period-scoped balance instead of all-timelib/records/components/days-summary-box-card.dart— UI adjustments (optional)lib/wallets/wallet-picker-page.dartor new page — Per-wallet breakdown viewNotes
r.valuewherer.wallet_id = w.id), incoming transfers (ABS(t.value)wheret.transfer_wallet_id = w.id), andw.initial_amount.