Darkroom NotesSeason 4STIL.RECEIPTPart 3 of 6
The total never lies — fixing tax mix-ups with math
The "10% taxable" field would end up holding the tax amount instead of the taxable amount. AI and rules alike mix it up when similar numbers sit nearby. And worse, the wrong number really does exist somewhere on the receipt. What rescued it wasn't a clever reader, but one unmoving fact — the total.

Last time, I wrote about getting a receipt's "table" readable. But even with the table readable, the numbers still had a pitfall. Today, the story of fixing tax-rate and tax-amount mix-ups with math.
The tax amount lands in "10% taxable"
Near the bottom of a receipt, there's a breakdown by tax rate. Something like "10% taxable ¥◯◯," "consumption tax ¥△△."
Testing on a real device, I kept finding that "10% taxable" field holding not the taxable amount, but the tax amount. When similar numbers sit close together, AI and rules alike mix up which one is the "taxable amount" and which is the "tax." In tallying expenses, a slip here quietly adds up.
Existing isn't enough
What made it tricky was that the wrong number really does exist somewhere on the receipt.
For every number the AI read, I was running a check: "is this number actually written on the receipt?" It was there to prevent fabrication. But the tax amount is printed on the paper. So even putting the tax amount into the "taxable" field passes that check. It exists, but it's in the wrong place. Checking only whether something exists wasn't enough.
The total never lies
So I put the final judgment somewhere else. The total.
On a single-rate receipt, one equation always holds: the taxable amount is a fixed share of the total, set by the rate. At 10%, the pre-tax taxable amount is 100/110 of the total. If the sorted numbers don't satisfy that equation, something is wrong.
Whether the AI is wrong, the rules are wrong, or I'm wrong — the "total" printed on the receipt is the one unmoving fact. It's already settled the moment you receive it. So I made it the measuring stick. If the sorted breakdown doesn't square with the total, fix it until it does. I chose to trust one unmoving number over the judgment of a clever reader.
Three layers of defense
So the sorting settled into three layers. First the AI reads. Where the AI is weak, the rules cover. And last, the equation against the total confirms it all adds up.
The three are good at different things. AI is strong at reading context. Rules are strong at position — where it sits on the paper. And the equation is strong at catching a lie. Where any single layer is shaky, three layers together hold up well. In the world of receipts, the most trustworthy partner turned out to be not the clever AI, but one number: the total.
Next time
Fixing things one by one like this, you naturally trip over plenty of receipts. Next, the story of a way of building where every stumble on a real device becomes a test, so it never happens again.
STIL.RECEIPT is out on the App Store.