0020. The Lynx Ledger page
- Status: Accepted
- Date: 2026-12-03
Context
The Lynx Ledger is the day-by-day page: checking today, the days that go under the cushion, every transaction by day, and "Add a transaction". Its view model is already in packages/core (ADR 0016). The page has to work on a phone and a wide screen, for people with large text, and the server has no ledger endpoint yet.
Decision
- Layout by CSS, in rem. Every day is in the page. Below
60remonly the focused day shows; from60remfive columns show, with a subgrid so the balances and entries line up across days. The width is in rem (the same breakpoint as the shared envelope widget), so a person whose text is large falls back to one day instead of five cramped ones. Navigation has both sets of buttons in the page and CSS shows one, so a screen reader meets one. - Always dark. The whole app already is (ADR 0010); the ledger adds no theme toggle and no Smart Invert rule of its own. Status is never colour alone: outline shape, icon and a word.
- Columns fold. A weekend or a bank holiday is folded into the next bank day, because the bank posts it then; the column says what it holds. That is core's rule (MR-107), not the page's.
- Mock first. The page reads and writes only through
DataSource:ledgerSnapshot,addTransactionandundoTransaction. The mock implements them on the same in-memory store as the other pages; the API source rejects with "The ledger isn't connected to the server yet." and the page shows that with Try again. The server work is a separate change, so this one ships and can be tested without it. - Undo is its own call. Partner's Recently added Undo archives. A transaction just added on the ledger is deleted for good in the mock, so
undoTransactionis separate from the archive Undo, uses the samecanUndorule for who may and when, and its words say "deleted for good". A retry reuses its request id; an id used for an add is refused for an Undo. - Entries are plain text until editing lands. An entry becomes one native button only when the page passes an open handler (
onOpen); until then a button that does nothing would only mislead. The editing change turns it on. - A controller, not state in components.
ledger-controller.tsholds loading, the focused day, the Danger zone jump, the form and Undo as signals, and the components only show them. Focus moves and announcements are signals too, so tests see them without a screen reader.
Consequences
- The page has no money math; its tests are about states, focus and words. Every state is on
/gallery. - Until the server has a ledger endpoint the live app shows the not-connected message. When it does, only the API source changes.
- The phone shows one day, so a person cannot compare days side by side there; the Danger zone list is the way to see what is ahead.
- Two Undo meanings (archive and delete for good) exist side by side; the words keep them apart.
Addendum, 2026-12-03: edit, make Private and remove
This does not change the decisions above. It records what the editing change added and the one place it overrides them.
- Entries are buttons now. The page passes the open handler, so every entry is one native button (
aria-expanded). Its form shares the Add form's spot above the days; opening one closes the other, and an Add that is on its way keeps the spot. The entry that is open gets a brand outline. - The status rule changed (MR-030, MR-032). A person can move an unconfirmed entry to any status, both ways, by hand; the bank keeps its own moves. Only a bank-confirmed Posted entry is locked. A Posted a person sets is stored unconfirmed and shows "Awaiting the bank".
changeStatus(entry, to, by)took over from the oldTRANSITIONStable; reconcile is its only other caller and behaves as before (only the wording of a skipped move changed). - Rules in core.
ledger-edit.tsholds the form's values, fields and words, the three checks (edit, Private, remove) and the write that applies them (MR-115, MR-116, MR-117). It reuses the Add form's field checks (checkLedgerFields), so a charge is judged the same way whichever form it came from. - Three more calls, and an Undo for them.
DataSourcegainseditTransaction,setPrivate,removeTransaction, each with a request id, andundoLedgerChange. The mock holds what an Undo needs on the source side (a token per change, valid only until that entry is written to again), not in the page. Remove is a real delete, not an archive. - The audit says that, not what. The audit note is fixed words ("Edited on the Lynx Ledger.", "Private changed on the Lynx Ledger.", "Deleted on the Lynx Ledger.", "Put back with Undo on the Lynx Ledger."): no amount, note or name.
- Words. The ledger says "deleted for good". Partner's Recently added and Help keep "archived" for their own Undo.
- Posted-day note. A bank entry that sits on a different day than the bank posted it (older or imported data, a line moved by hand) shows "Posted Wed Dec 2" and, in its read-only facts, "Bank posted it: Wed Dec 2". Words only: balances, locks and placement do not change, and it stays on another person's Private entry (it is only a date). Reconcile itself now places on the posted day.
- Still true. The Worker applies the same rules and the same content-free audit.
Addendum, 2026-12-05: the server
The Worker now serves the ledger (GET /api/snapshot/ledger, POST /api/ledger/transactions, PATCH .../:id, PATCH .../:id/private, POST .../:id/remove, POST .../:id/undo-add, POST /api/ledger/undo/:id), and the API data source calls them. Core still decides every check; the Worker persists only a plan that passed.
- Private is stored (
entries.private_by) and withheld by the server in every read that shows entries (Privacy.entryNote), not only in the ledger's snapshot. - Remove is a real delete. The
entriesDELETE guard now lets through a Planned or Charged entry that is not bank-confirmed, and nothing else. The audit line is fixed words only. - Undo needs a copy, so there is one, briefly.
ledger_workholds the entry as it was (and the answer a request id got) for 30 minutes, for the person who made the change only; it is wiped on the next ledger write after that. This is the one place "no copy kept" is softened, and it is the only way an Undo of a delete can work. It is in the nightly backup like any table, so a copy can outlive its window there until the backup's own retention ends. - Undo is stale when the entry's audit lines changed since the change was saved (anything else wrote to it), not by clock.