Recording money correctly.
WHAT A LEDGER IS
An append-only record of movements between accounts.
WHY APPEND-ONLY
History must not change, and corrections must be visible.
WHAT DOUBLE-ENTRY MEANS
Every movement recorded twice: a debit and a matching credit.
WHY THAT MATTERS
It makes imbalance detectable, and the total of all entries must be zero.
WHAT THAT PROVIDES
A structural check that nothing was lost or created.
WHAT AN ACCOUNT IS HERE
Any place value can sit: a customer balance, a fee account, a settlement account, a suspense account.
WHAT A SUSPENSE ACCOUNT IS FOR
Value whose destination is not yet determined.
WHY IT IS NECESSARY
Unmatched receipts must go somewhere, visibly.
WHAT TO NEVER DO
Store a balance as a single mutable number.
WHY
It cannot be audited, and a concurrency error corrupts it invisibly.
WHAT TO DO INSTEAD
Derive balances from entries, and cache if performance requires.
WHAT TO ENFORCE
That entries are immutable That every transaction balances That corrections are new entries, not edits
WHAT TO STORE PER ENTRY
Amount, currency, accounts, timestamp, reference, and what caused it.