Every transfer is two entries that sum to zero
transcript
Subtract from one balance. Add to the other. A thread stops between the two lines. Money vanishes. And afterwards, there is nothing to audit. No trail at all.
Store entries instead. A signed amount on one account. A transfer is two entries. Minus fifty, plus fifty. Sum zero. There is no way to add to one side only.
A top-up has the same shape. Minus three hundred on the cash account. Plus three hundred on Ann. The money came from outside the system. Sum zero. Only the cash account may go negative.
The balance is just a cached sum of the entries. Verify checks every entry in the system sums to zero. And that every balance equals its entries. Run it after every test. If it ever says false, you find the bug before a customer does.
Store entries. Check that they sum to zero.
Full breakdown in the lecture.