Table of Contents

#186 — Opening balances and manual deposits, withdrawals and corrections change the cash balance the app shows but never reach the tria (Resolved)

← Back to bug list · View issue #186 in MantisBT


Reported by: Nour aboulhosn on 2026-08-07T09:19:26+01:00
Assigned to: Claude
Resolved by: Claude on 2026-08-08T10:48:17+01:00
Severity: major
Priority: high
Reproducibility: have not tried
Category: General

Description: An opening balance and manual deposit / withdrawal / correction entries all move the balance on Cash & accounts, but none of them reach the trial balance.

Measured directly: a `$300.00` opening balance moved Cash & accounts +$300.00 and the trial balance's “Cash and bank” +$0.00. A `$77.00` manual deposit moved it +$77.00 and the trial balance +$0.00 again.

So the app gives two different answers to “how much money do I have”, and the year-end document is the wrong one. The gap grows with every opening balance and manual movement recorded.

The fix is to build both figures from the same set of movements, so “Cash and bank” always equals the sum of the account balances.

Steps to Reproduce: 1. Note the total on Cash & accounts (“Should be there now”) and Cash and bank on Reports → Trial balance. 2. Open any account from Cash & accounts and record an opening balance of `300.00`. 3. Cash & accounts rises by `$300.00`. Trial balance → Cash and bank is unchanged. 4. On the same account, add a manual entry: kind Money put in, amount `77.00`. 5. Cash & accounts rises by another `$77.00`. Trial balance → Cash and bank is still unchanged. 6. The two screens now disagree about the cash position, and the difference is permanent.

Resolution: Fixed.

WHAT WAS WRONG `TrialBalance::compose()` had no term for `cash_entries` at all. Opening balances and every manual deposit, withdrawal, correction and transfer moved the Cash & accounts screen and reached the statement nowhere — so the app gave two answers to “how much money do I have”, and the year-end document was the wrong one.

THE FIX A new `cashMovementTotal()` nets those entries, and compose() adds it to Cash with the contra going to a new Owner's funds account. That name is not decoration: money appearing in a till with no sale behind it was put there by the owner, and money leaving with no expense behind it was taken out by them. Naming the account is also what keeps the statement balancing by construction — the same term lands in both columns.

The signs are copied from `CashPosition` rather than re-derived, because the whole point is that the two stop disagreeing. Both halves of a transfer are included, so transfers cancel to zero across the company — which is right, since moving money between your own tills changes nothing about how much you have.

`booksHoldAnything()` now counts cash entries too, so a company whose only record is an opening balance no longer reads “Nothing has been recorded” while its own statement shows two lines (that would have been #179 again).

VERIFIED — against the database

$300.00 opening balance:  cash screen +300.00, trial balance cash +300.00
Owner's funds:            credit 300.00
$120.00 withdrawal:       trial balance cash -120.00
statement balanced before and after, both times

Activity / Notes

WHAT WAS WRONG `TrialBalance::compose()` had no term for `cash_entries` at all. Opening balances and every manual deposit, withdrawal, correction and transfer moved the Cash & accounts screen and reached the statement nowhere — so the app gave two answers to “how much money do I have”, and the year-end document was the wrong one.

THE FIX A new `cashMovementTotal()` nets those entries, and compose() adds it to Cash with the contra going to a new Owner's funds account. That name is not decoration: money appearing in a till with no sale behind it was put there by the owner, and money leaving with no expense behind it was taken out by them. Naming the account is also what keeps the statement balancing by construction — the same term lands in both columns.

The signs are copied from `CashPosition` rather than re-derived, because the whole point is that the two stop disagreeing. Both halves of a transfer are included, so transfers cancel to zero across the company — which is right, since moving money between your own tills changes nothing about how much you have.

`booksHoldAnything()` now counts cash entries too, so a company whose only record is an opening balance no longer reads “Nothing has been recorded” while its own statement shows two lines (that would have been #179 again).

VERIFIED — against the database

$300.00 opening balance:  cash screen +300.00, trial balance cash +300.00
Owner's funds:            credit 300.00
$120.00 withdrawal:       trial balance cash -120.00
statement balanced before and after, both times

Full History

Date User Field Change
2026-08-07T09:19:26+01:00 Nour aboulhosn issue-new New Issue
2026-08-08T10:48:11+01:00 Claude Assigned To ⇒ Claudine
2026-08-08T10:48:13+01:00 Claude tag-added Tag Attached: done-by-claude
2026-08-08T10:48:15+01:00 Claude note-added Note Added: 0000146
2026-08-08T10:48:17+01:00 Claude Status new ⇒ resolved

Synced automatically from MantisBT issue #186.