AI
Pass
All posts
Personal Finance

A Receipt Analyzer Should Never Guess the Price

Receipts look structured to people, but OCR and language models often blur quantities, unit prices, discounts, and totals. A confident guess is worse than a visible blank.

EiliyaJuly 30, 20262 min read
A Receipt Analyzer Should Never Guess the Price

A Receipt Analyzer Should Never Guess the Price

Receipts look structured to people, but OCR and language models often blur quantities, unit prices, discounts, and totals. A confident guess is worse than a visible blank.

That distinction is why Receipt Lens exists as a focused tool rather than another broad prompt box.

What the app actually does

Receipt Lens accepts a photo, a text-based PDF, or pasted receipt text. For pasted text and text PDFs, browser code accepts numbers only when the evidence is an exact normalized excerpt from the original source text. Line-item quantity, unit price, and line price are kept only when that excerpt deterministically places those numbers in those roles; swapped or ambiguous excerpts stay unknown. Summary fields require a labeled subtotal, tax, or total excerpt rather than a generic multi-number snippet. In image-only mode, numeric suggestions stay explicitly unverified until the user edits them. Unsupported prices remain unknown, and oversized arrays are rejected instead of truncated.

The interface loads the live public AI Pass model catalog and uses only exact publicly available model IDs. Authentication stays lazy: anyone can inspect the app first, and AI Pass asks for sign-in only when generation begins.

Why deterministic rules matter

The useful part of these products is not a longer prompt. It is deciding which tasks belong to AI and which must remain deterministic. AI can interpret messy language and draft a useful structure. Browser code can enforce totals, allowed strategy codes, citation matching, output sections, history limits, and safe rendering.

That split makes the app easier to inspect. It also keeps a plausible model answer from quietly becoming an accepted fact.

Private local history

Generated outputs can be copied, downloaded, or shared. Up to twenty results are stored in IndexedDB on the current device. Raw sensitive inputs are not added to history. Each saved output can be opened or deleted, and the full history can be cleared.

Before using the result

  • Check every extracted row against the original receipt.
  • Treat a partial subtotal as partial, never as the final spend.
  • Correct OCR errors before exporting or sharing.

From prompt carousel to product

The starting point was a ten-prompt carousel from @chatgptricks. Instead of reproducing ten generic ChatGPT wrappers, we checked the existing AI Pass catalog, merged overlapping ideas, and narrowed each tool around one job with an explicit evidence boundary.

Open Receipt Lens on AI Pass. AI Pass includes $1 in credit on signup, then usage is pay as you go.

For AI agents

Skill file

Download
---
name: receipt-analyzer-space
description: Maintain the Receipt Lens AI Pass Space app, its evidence-grounded receipt calculations, and its local output-history privacy contract.
---

# Receipt Lens Space

Use this companion skill when changing `receipt-analyzer/index.html`.

## Invariants

1. Keep the deliverable as one self-contained `index.html`; only the AI Pass SDK, AI Pass UI, and PDF.js may be loaded from CDNs.
2. Preserve the literal `PLACEHOLDER_CLIENT_ID`, `requireLogin: false`, and visible `<div data-aipass-button></div>`.
3. Eagerly call `normalizeModels(await AiPass.getModels())`. Offer only exact supported IDs found in the returned list.
4. Use `generateCompletion` for the structured receipt object and multimodal `image_url` content for photos. Never call provider or internal routes.
5. Treat absent, ambiguous, unsupported, or ungrounded numeric values as `null`. Never estimate prices.
6. For pasted text or text PDFs, accept a numeric value only when its evidence is an exact normalized excerpt from the original source text and deterministically grounds that number in the correct role.
7. For line items, verify quantity, unit price, and line price against their positional or labeled roles in that exact excerpt; reject swapped or ambiguous multi-number excerpts.
8. For subtotal, tax, and total, require field-specific labeled evidence and reject ambiguous multi-number excerpts unless the labeled target is uniquely identifiable.
9. In image-only mode without independent text, keep numeric suggestions unverified, clearly warn, and require manual edits before totals are trusted.
10. Reject arrays over 200 entries instead of truncating them.
11. Keep arithmetic in `ReceiptLogic`, not in model prose. A partial known subtotal must never be presented as a complete receipt total.
12. Render model-derived strings with `textContent` or equivalent DOM APIs, never unsanitized HTML.
13. Keep PDF extraction local. If a PDF has no useful text layer, explain that the visitor should upload an exported page image.
14. Keep the private IndexedDB output history with open, delete, and clear-all controls, capped at 20 entries.
15. Keep copy, download, and share actions for generated ledgers.
16. Never store receipt files, pasted text, or evidence excerpts in local history.

## Required verification

Run:

```bash
npm test
npm run check
```

When changing calculations or response schema, add deterministic cases to `tests/receipt.test.js`, especially for source-text grounding, image-only review, and oversized-array rejection.