Blog ·
The current account is a ledger, not a number
A balance shouldn't be a number you maintain: it should be a number you can reproduce. The ledger model, and why the stored balance is just a cache.

A customer account balance shouldn’t be a number you maintain. It should be a number you can reproduce.
The shortcut is a balance column updated on every operation. It’s fast and it works — until the day a customer disputes their balance. Then the question is no longer “what does it say” but “how did it get there”, and a single number has no answer.
The ledger model
Every operation writes an immutable movement: a date, an amount, a sign, a reference to what caused it, and the resulting running balance. The balance is the sum. Nothing overwrites anything.
What it gives you:
- An account statement is a query, not a report someone builds.
- Disputes get resolved by reading, not by reconstruction.
- Errors are fixed by posting a correcting movement — which is auditable — rather than by adjusting a number, which isn’t.
- And you can answer “what was the balance on the 15th?” — which someone will ask.
The stored balance is a cache
The pragmatic part: we do keep a stored balance, for speed. But it’s a cache, and treating it as one is the whole discipline: it’s recomputable, it’s protected under the same lock as the movements that change it, and there’s a way to rebuild it.
A cache you can’t rebuild isn’t a cache: it’s a second source of truth that will eventually disagree with the first.
The wider principle
Prefer storing events over storing state, wherever someone might ask how the state came to be. In money, someone always asks.
That’s how the receivables, cash and current-account flows in YSY Empresa are built: ledgers, not editable tables. When the owner — or an auditor — asks what happened, the system has the complete answer.