Engineering · Payments

The money balanced, and nobody had asked

A split bill should add up to the bill. We had the function that checks it, and for months nothing called it. Here is what happened when we finally ran it across every paid order on the live database.


A bill split four ways across two cards, a voucher and the rest in cash is four records of money and one record of what was owed. They should sum to the same number. If they ever do not, that is not a rounding curiosity — it is either money that came in and was not recorded, or a bill that was closed for less than it was.

We had a function that checks exactly that, sitting in our sale code under a comment describing when it gets called. It was a good comment. It was also fiction: nothing called it, not the audit, not the API, not anything. We found that by listing every function our code exports and never mentions again — and the comment was worse than no comment, because it was the reason nobody had ever gone looking.

Wired up is not the same as true

So we wired it into the order record and wrote tests for it. That proves the arithmetic. It does not prove anything about our actual rows, and those are two different claims — the second is the one an operator would care about.

This week we finally asked the live database. Every paid order, legs against total.

Thirty-four paid orders. Eighteen carry payment records, and every single one balances to the penny — not one out by so much as 1p, which is the standard the check holds itself to. Money here is whole pence, never fractions of a pound, precisely so that close enough never becomes a concept.

The ones without records, and why they are not a scandal

Sixteen orders have no payment records at all, and they split cleanly in two. Thirteen are from the first week of trading, before we recorded payment legs separately at all. The other three are zero-pound orders, which tendered nothing and therefore have nothing to record — and nought does equal nought, so those balance fine.

From the day we started writing them, every non-zero paid order has its payment records and every one of them adds up. The change-over is clean and there has been no drift since.

The check that flags old history is working, not broken

Those thirteen early orders are reported as not balancing, because they claim a total with no record of how it was paid. It is tempting to call that a false alarm and quieten it. It is not one. An order that says eighty-seven pounds with nothing explaining where eighty-seven pounds came from is exactly the thing that check exists to surface, and our own tests say so in as many words.

The honest gap

The number is available on the order record. Nothing watches it. If a future sale wrote payment records that did not sum, no screen would go red — somebody reading our API would be the first to know. That is worth saying plainly rather than implying a vigilance we have not built yet.

If you are buying a till, this is a fair question to ask of it: not do split payments work, which everybody says yes to, but does anything check that they added up, and where would I see it if they had not?


Try it on tonight’s service.

Nothing to install, no card. Not better by the weekend? Close the tab.