Benrnz/BudgetAnalyser

When budget increases new reconciliation ledger balance still equals previous month balance.

Closed this issue · 2 comments

If a budgeted amount changes during a month (existing ledger book and existing budget), and the ledger is being tracked in the ledger book, the balance isn't correct after the next reconciliation.
The balance will remain the same as the previous month's balance even though the budgeted amount has increased. The correct balance should be the new budgeted amount.
If budgetAmount > balance then add new Transaction to top up to budgeted amount from surplus.

Applies to SpentMonthlyBuckets only

Surrounded the Ledger behaviour during reconciliation with tests and rewrote with more efficient and clearer logic. Fixed SpentMonthlyLedger behaviour so that closing balances supplement and remove excess correctly.
SpentMonthlyLedger new behaviour:

If no budget-amount then a compensating transaction will be added to close the ledger at $0.
If closing-balance > opening-balance and budget-amount then a compensating transaction is added as follows: a) If opening-balance > budget-amount then closing balance will result in a balance equal to opening balance. b) Otherwise the closing balance will result in a balance equal to budget-amount.
If closing-balance < opening-balance and budget-amount then a compensating transaction is added that will result in a balance equal to the budget-amount.