Warehouse ledger pattern
Stock is never stored as a figure. It is derived from an append-only movement ledger, so a balance can always be traced to its transactions.
- Seven rules enforced by the database: append-only, who and when on every row, corrections as contra rows
- Sixteen assertions, each rule proven by removing it and watching the tests fail