Why receipts
When I wrote about why I built RPMBase, the first decision on the list was that typing is the enemy. A car log only works if people keep it, and nobody keeps a log that feels like homework. Most of what goes into the log already exists on paper: the fuel ticket, the workshop invoice, the parking receipt.
So the goal was simple to state: take a photo, get a filled-in form. Not a silent save. A form the owner glances at and confirms.
A vision model reads a receipt surprisingly well. The trouble is that when it is wrong, it is wrong with total confidence. A total of 1.250,50 can come back as 1.25. A pump number can come back as liters. A phone number printed under the station's name can come back as 84,200 km. The rest of this post is about the layers around the model that catch those mistakes.
For the owner's side of the same feature, the RPMBase guide on how to store car service receipts shows where a scanned receipt ends up.
The pipeline at a glance
- Check the photo before anything costs money. JPEG, PNG or WebP only, with limits on file size and pixel count. The owner must have agreed to the AI features, and the monthly AI allowance is checked before the model is called, not after.
- One read with a strict schema. The model fills a fixed JSON shape, including the printed line each value came from.
- Parse and normalize in code. Numbers, dates and currencies are re-read by plain functions, not trusted as given.
- Validate against the evidence and the car. Every suspicious field gets a reason.
- A second read, only when it matters. Serious problems earn one more attempt on a stronger model.
- Return a draft. Nothing is saved. The app shows the form with the doubtful fields marked, and the owner confirms.
A strict schema with evidence fields
The response format is a strict JSON schema: every key is required, no extra keys are allowed, and a value that is not printed comes back as null. Maintenance types, expense categories and currencies are enums, so the model cannot invent a category the app does not have. Each important value also carries the model's own confidence: high, medium or low.
The part that made the biggest difference is the evidence fields. For the date, the amount paid, the fuel volume and the odometer, the model must first copy the line it read exactly as printed, separators and labels included, and only then fill in the value. A typical fuel ticket comes back with something like costEvidence: "TOPLAM *1.250,50" next to cost: 1250.5.
The prompt is mostly a list of things that look like the answer but are not. The total is TOPLAM, GENEL TOPLAM or TOTAL, never the VAT line, the subtotal, the unit price or the change. Turkish receipts print the day first. The odometer is never a phone, plate, card, pump or receipt number. And the last line: never invent a value.
The model also gets a little context about the car: make, model, year and the current odometer reading in the app. Knowing the car is at about 84,000 km makes a ten-digit phone number a much less attractive candidate.
Parse the numbers yourself
Receipts in Turkey and in English-speaking countries swap the meaning of the comma and the dot. 1.250,50 and 1,250.50 are the same amount; 84.200 on an odometer line is eighty-four thousand, not eighty-four. So the value the model returns is not taken as final. A small parser turns a printed token into every reading it could plausibly mean, then keeps only those inside the range that makes sense for the field:
- When a token has both a comma and a dot, whichever comes last is the decimal mark.
- Groups of exactly three digits after the separator read as thousands; one or two digits read as decimals.
- For money and kilometres the larger plausible reading wins; for liters the smaller one does, because a 4,520-liter fill-up is not a car.
Dates get the same treatment: ISO dates, day-first dates with dots or slashes, and month names in Turkish and English, with Turkish letters folded so Şubat and subat match. A date that does not exist, like 31 February, is rejected rather than rolled over into March.
Checks that catch a confident wrong answer
After parsing, each field is checked against its own evidence and against what the app already knows about the car. None of these checks rejects the receipt. Each one attaches a reason to a field.
| Check | What it catches |
|---|---|
| The value must appear in its evidence line | A total read from the wrong line, or a number the model made up |
| Liters × unit price within 4% of the total | A misread fuel volume or total (4% leaves room for rounding and small discounts) |
| A receipt from the last 30 days showing over 500 km less than the car's current reading | An odometer taken from some other number on the paper |
| An odometer more than 30,000 km above the current reading | Same, in the other direction |
| A date in the future | A misread year, or a due date taken for the transaction date |
| A date more than three years old | Nothing wrong, usually: someone is digitizing an old service book. Still worth a second look |
| The model's own low confidence | Blurry or partly hidden values |
The evidence check is the one I would keep if I could only keep one. It costs nothing, it needs no knowledge of the car, and it turns "the model said so" into "the model said so, and here is the line it read".
A second read, only when it matters
Most receipts pass on the first read with a fast, inexpensive model. Some problems are serious enough to justify more: a total that does not match its evidence, a record type the model could not decide, an odometer that does not match its own line, or a date in the future. When those come up and a fallback model is configured, the server reads the same photo once more with a stronger model.
The two results are scored by counting their issues, and the cleaner one wins. If the second read fails outright, the first one is still returned. The owner's allowance is charged once either way. The validation decides when to spend more, so the expensive model only sees the receipts that need it.
Behind the per-month allowance there is one more guard: every model call is metered in real cost against a hard monthly budget per account. A model without a known price is refused outright, because a model you cannot price is a model you cannot hold to a budget.
The owner has the last word
The server never writes a receipt into the garage. It returns a flat, form-ready draft: record type, date, cost, currency, liters, odometer, service type or category, and a short note built from the merchant and the billed lines. Alongside it comes a list of fields to check: every field with low or missing confidence and every field that failed a validation.
A few small decisions matter here. If no date is printed, the date field is left empty instead of quietly becoming today. If no currency is printed, the currency is left for the owner instead of guessed. And on a workshop invoice with several lines, the most expensive service line decides the maintenance type, so an oil change with a cabin filter is logged as an oil change.
What I learned
Ask for evidence, not only answers. Making the model copy the line before giving the value improves the reading itself, and it gives the code something concrete to check.
Let the model read and let code do the arithmetic. Models are good readers and unreliable bookkeepers. Parsing separators, checking that liters times price matches the total and comparing against the odometer are jobs for plain, tested functions.
Flag instead of blocking. An old invoice or a big odometer jump is sometimes exactly right. Marking a field for a second look keeps the scan fast for the common case and honest for the strange one.
Spend by need. A cheap first read plus a stronger read only on failure gives most of the accuracy of the expensive model at a fraction of the cost, and that is what makes it affordable to include a few scans a month on the free plan.