Stack. Python, Claude API with structured outputs, Gmail API, Google Sheets API, SQLite, FastAPI for the review screen, openpyxl for Excel. 51 automated tests run on every push.
The model reads, rules judge. The model fills a fixed schema with the values printed on the page and is told never to fix the arithmetic. Line totals, subtotal, tax rate (Chilean IVA 19 %), dates and currency are checked by plain rules.
Duplicates across batches. The same invoice sent twice, even as a new scan or photo, and the same charge under a new invoice number.
Safe approval emails. The email carries the original and a link to the review screen, never approve or reject links of its own: mail scanners open links, and a scanner must never approve a payment.
Idempotent everywhere. A file is read once (content hash), an approval email is sent once, a row reaches the sheet once.
Never fails silently. Unreadable files go to their own tab and an alert goes out by email.
Limits today. Up to two pages per invoice, one invoice per file. In production the review screen sits behind the client's login.