feat: budgets / envelopes (#7) #17
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/issue-7-budgets"
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?
Budgets / envelopes
Fourth item of the P1 double-entry tier (#7): budgets (hledger
--budget/ Ledger virtualpostings). Assign a target
amountto a category over a period (date range), then compare it to theactual summed activity in that category over the period.
Surfaces (server-depth, mirroring the payees/attachments features)
budgetstable (category_idFKON DELETE CASCADE,period_start,period_end,amount) + index + changelog trigger (entity_kind = 'budget').Commands.budgetAdd/budgetList/budgetRemove/budgetStatus+LedgerStoreSQL +categoryActivity(categoryId, from, to).AddBudget/RemoveBudget(writes) +ListBudgets/GetBudgetStatus(reads)(+ proto
Budget/BudgetStatusmessages).addBudget/listBudgets/removeBudget/budgetStatus+BudgetInfo/BudgetStatusInfo.add_budget/remove_budget(destructiveHint) /list_budgets/get_budget_statustools (no money moves → no propose/commit).BudgetTests), gRPC (BudgetRPCTests), MCP.make testgreen.Sign convention (documented in code)
categoryActivityreturns the raw signed sum of the categorized splits' amounts over the period— positive = debit-side (spending) activity, negative = credit-side (income) activity — matching the
ledger's normal signs (
Report/Statements.swift: expense accounts are debit-normal, incomecredit-normal). Money is folded exactly in Swift (not lossy SQL
SUM), likecurrentBalance.Period bounds are inclusive (
t.date BETWEEN period_start AND period_end).⚠️ Migration version — cross-branch coordination
Numbered version 11 (main is at 8; 9 = attachments/#15, 10 = effective-date/#16 on their
still-open branches). The migrator applies per-recorded-version, so the gap is safe. When merging the
migration-adding PRs, order the
Schema.migrationsarray by version and set the migration-countassertion in
CommonsStoreTeststo the final count.Scope
One P1 item (does not close #7). Remaining item: pending/cleared two-phase. Report/UI integration of
budgets is a follow-up (#4).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.