Business records tool / 2026 / In progress · Anonymized work
Operations Ledger.
A purchase ledger that saves a purchase and all its records together, or saves nothing
- The hard part
- Stopping one purchase from being recorded twice when a request is sent again, or the same invoice arrives under a new key.
- Works today
- The ledger records purchases from invoices, checks every total in whole numbers and saves each purchase with all its records, or nothing.
- Role
- Software engineering
- Built with
- TypeScript · Node.js · SQLite · MCP · Zod · JavaScript · HTML · CSS · Lucide
01What I built
The problem.
Recording a purchase from an invoice can go wrong in two ways that are easy to miss. Rounding can make the lines add up to a slightly different total from the invoice. And if a request is sent again, or the same invoice arrives twice, the purchase can be recorded twice.
What I built.
Operations Ledger records purchases from invoices. Each invoice arrives already split across its lines, and that split has been checked. First the ledger reads the request and turns money and amounts into whole numbers, so nothing is lost to rounding. Then a calculator works out the discounts, the invoice's separate amounts and the split again. If anything is off by even a little, nothing is saved. Last, the ledger saves the purchase and its lines. With them it saves the stock records, a history entry and the answer a repeated request will get. All of these are saved in one SQLite A technical worddatabase transactionA group of database changes saved together, so either all of them are saved or none are., so either all of it is saved or none of it is.
The ledger
TypeScript, Node.js, SQLite, MCP, Zod
- Request reader
- Checks the input, then turns money and amounts into whole numbers of the smallest unit.
- Purchase calculator
- Works out the discounts, the invoice's separate amounts and the split again. It stops if anything is off at all.
- Retry check
- Matches the key, the action's name and a short code made from the request. An exact repeat gets the first answer back, and a changed one is refused.The storySaving a purchase and its retry answer together
- Invoice check
- Finds a purchase that is already saved, even when it comes with a new request key.
- Purchase write
- Locks the database, then saves the purchase, its lines and its stock records. The history entry and the retry answer are saved with them, all or nothing.The storySaving a purchase and its retry answer together
The dashboard
TypeScript, Node.js, MCP, HTML, CSS, JavaScript
Operations Snapshot Dashboard- Request guard
- Checks each request before fetching anything. The request must name the right site and only ask to read. Its web address must be short enough, and its report options must make sense.
- Source connections
- One connection per system starts and refreshes on its own, so one failure doesn't throw away the other's data.
- Snapshot checks
- Picks the newest record first. Then it checks the format version and the features the system says it has. Last, it checks that the content matches its fingerprint code and that the times make sense.The storyChecking the newest snapshot so a broken update stays visible
- Combined view
- Keeps each system's status, the data it accepted and the reason for any error. Expired data gets an out-of-date label.The storyChecking the newest snapshot so a broken update stays visible
- Background service
- A background service for my user account starts the server when I sign in, and restarts it if it stops by surprise.
Confidential work. Names and identifying business details have been changed.
02The journey
What broke, and what changed.
Broke, then fixedA decisionA milestone
- 01 of 08DecidedOperations Snapshot Dashboard
Pick the newest snapshot first, then check it
The questionEach system sends copies of its data, called snapshotsOperations Ledger · Operations Snapshot Dashboard · The dashboardSnapshot checksPicks the newest record first. Then it checks the format version and the features the system says it has. Last, it checks that the content matches its fingerprint code and that the times make sense.See it in the map above. When the newest snapshot fails a check, the dashboard could look back for an older one that passes. That would hide a failure in the system behind old data.
What I choseThe newest record is chosen first and checked second. A broken update stays on screen as broken.
- 02 of 08DecidedOperations Snapshot Dashboard
Out of date and broken are shown differently
The questionExpired data and data that fails a check are both problems, but not the same problem.
What I choseExpired data can stay on screen with an out-of-date labelOperations Ledger · Operations Snapshot Dashboard · The dashboardCombined viewKeeps each system's status, the data it accepted and the reason for any error. Expired data gets an out-of-date label.See it in the map above. A snapshot with the wrong format shows no data at all. So does a snapshot whose content no longer matches its fingerprint, a short code sent with it.
- 03 of 08DecidedOperations Snapshot Dashboard
Read the copies each system shares, not its private tables
The questionReading the systems' databases directly would tie the page to how they lay out their private tables. Letting the page change records would make it a third place to keep the same records up to date.
What I choseThe dashboard reads only the copies each system shares through its tools. Each copy has a version number. The dashboard has no database and cannot change records. So the systems can change how they work inside freely. A new copy version needs a planned update to the dashboard.
- 04 of 08DecidedOperations Snapshot Dashboard
Keep the view up after the terminal closes
The questionI started the dashboard's server by hand in a terminal window, so closing the window stopped it. I wanted the dashboard to stay up without a terminal left open. I also didn't want a browser window to pop up every time I signed in.
What I choseThe same server now runs as a background serviceOperations Ledger · Operations Snapshot Dashboard · The dashboardBackground serviceA background service for my user account starts the server when I sign in, and restarts it if it stops by surprise.See it in the map above for my user account. It starts when I sign in, and restarts if it stops by surprise. It still only reads, opens no browser and saves no snapshotsOperations Ledger · Operations Snapshot Dashboard · The dashboardSnapshot checksPicks the newest record first. Then it checks the format version and the features the system says it has. Last, it checks that the content matches its fingerprint code and that the times make sense.See it in the map above. It still only answers this computer.
ProofThe tests check the service's settings. They also check that it holds no browser data and no passwords or keys.
- 05 of 08DecidedOperations Ledger
Count money as whole numbers, not decimals
The questionThe discounts and the split across lines have to add back up to the invoice total exactly.
What I choseComputers store decimals in a way that can round them slightly. So money is kept as a whole number of its smallest unitOperations Ledger · The ledgerRequest readerChecks the input, then turns money and amounts into whole numbers of the smallest unit.See it in the map above, like pence. The split rulesOperations Ledger · The ledgerPurchase calculatorWorks out the discounts, the invoice's separate amounts and the split again. It stops if anything is off at all.See it in the map above work the invoice total out again. If rounding or the split is off, the purchase stops before anything is saved.
- 06 of 08DecidedOperations Ledger
Save the retry answer with the purchase it describes
The questionThe ledger keeps the answer a repeated request will get, called the retry answerOperations Ledger · The ledgerPurchase writeLocks the database, then saves the purchase, its lines and its stock records. The history entry and the retry answer are saved with them, all or nothing.See it in the map above. If that answer is saved on its own, it can be lost after the purchase is saved. Or it can stay behind after the purchase was undone.
What I choseThe retry answer is saved in one A technical worddatabase transactionA group of database changes saved together, so either all of them are saved or none are. with the purchase and its history entry, so all of it is saved or none is. If an error happens, all of it is undone.
- 07 of 08DecidedOperations Ledger
Two checks for two kinds of repeat
The questionEach request carries a request keyOperations Ledger · The ledgerRetry checkMatches the key, the action's name and a short code made from the request. An exact repeat gets the first answer back, and a changed one is refused.See it in the map above, a label the caller sends with it. The key spots an exact retry, which is the same request sent again. It misses the same invoice sent under a new key.
What I choseThe key check gives back the first answer for an exact retry. It refuses a request that uses an old key with changed content. A separate invoice checkOperations Ledger · The ledgerInvoice checkFinds a purchase that is already saved, even when it comes with a new request key.See it in the map above finds a purchase that is already saved.
- 08 of 08DecidedOperations Ledger
Saving here doesn't mean another system was updated
The questionA purchase saved in the ledger could be mistaken for a sign that the accounting system was updated too.
What I choseCorrections get their own records, and so do confirmations from other systems. The ledger's own history stays in view. What happened in another system is confirmed on its own.
03Today
Where it stands.
Work done in another system still needs its own check, to make sure the two records match. Some kinds of correction are not supported yet.