Continue where you left off ×
A Book You Never Erase, the append-only ledger, reversals and derived balances
The Ledger Everyone Reads · Open board
The log: append-only, ordered, kept, with “state = fold over the log” in its event-sourcing box. That board is about events in software. This lesson shows the same shape is what a money ledger has to be, and what you do when a line in it is wrong.
Education, not financial advice.
Before you start. From Every Litre Leaves One Tank and Enters Another, double-entry, normal balances and the trial balance : a ledger is accounts and entries, every transaction sums to zero, and the trial balance adds the book up as an alarm. From The Ledger Everyone Reads (event-driven & the log) (or Kafka 02: The Log if you came from From Scratch): a log is a list you only add to, and many readers read it at their own pace. This lesson needs nothing else.
The idea in 30 seconds
A money ledger is append-only: a posted entry is never changed or deleted, because people and systems have already acted on it.
A mistake is fixed with a reversal, an entry that cancels the wrong one, followed by the right one. Both stay, so the history is honest.
Fowler names three fixes: replacement loses history, reversal keeps it with more lines, difference keeps it with fewer lines and less clarity.
A balance is derived: the sum of the account’s entries. That gives a balance as of any date, and a way to check any claimed number.
For speed, a cached balance sits next to the entries with a version number. The version says which entries it covers and stops two writers overwriting each other.
Read the story
Lesson 44 of 58 in Finance
The rest of this lesson is part of a plan.
A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year .
See plans Already a member? Sign in
Or start free : a free account opens lessons 2 and 3 of every track.
In this lesson 16 October 2019: Square writes up Books The meter you never wind back: append-only The three ways to fix a wrong line, and the one ledgers use A balance is worked out, not stored: the derived balance Fast and still honest: the cached balance and its version Terms it explains: append-only, reversal, derived balance, cached balance, version.
Review Finance
Connects to
Charged Twice (idempotency & exactly-once) System Design The Ledger Everyone Reads (event-driven & the log) System Design Stripe, the case study System Design Kafka 02: The Log From Scratch Every Litre Leaves One Tank and Enters Another, double-entry, normal balances and the trial balance Finance Half a Point a Day, Gone, integer minor units, rounding and currency exponents Finance The Hold That Is Not Money Yet: authorisation, capture, clearing, settlement and chargebacks Finance The Ledger That Cannot Lie, build a small money ledger in Go and hold it to four promises Finance Mark as read Saved in this browser, and to your account when you sign in.