Prototypes Prototype docsP11 · Docs and assistant
Invoices read by AI (P20)
DocsPage 25 of 30

Invoices read by AI (P20)

Voucher reads invoices, credit notes and receipts for a bookkeeper, from a PDF, a scan, a phone photo or an e-invoice. Two AI models read each document, and a field is approved automatically only when both agree, the value is on the page and the checks pass. A person reviews every other field on the page itself.

Reading the words

Voucher reads the text of a PDF with pdf.js and keeps the position of each word on the page. A scan or a photo is scaled to at most 2,000 pixels wide. Tesseract.js then reads it in your browser in Danish, English and German, and each word keeps its OCR confidence score. An e-invoice in UBL, Peppol BIS 3.0 or OIOUBL is read field by field without an AI model.

Two AI models

Voucher numbers the words on the page and sends them to two models at the same time. For each field, a model returns the numbers of the words that contain it. Because a model never returns the value itself, it cannot return a value that is not on the page. Voucher then reads the value from those words. It reads amounts with the document's decimal separator and dates in all three languages. It also reads CVR and VAT numbers, IBANs and FIK payment codes. On Cloudflare Workers AI the two models are glm-5.3 and qwen3.8-27b, from two different model families that make different mistakes. When ANTHROPIC_API_KEY is set, Claude is used as the first model.

The checks

A field is approved automatically when at least two readings give the same value and no check fails. On a scan, the OCR confidence of each of its words must also be at least 70 out of 100. Voucher runs these checks:

  • The totals follow EN 16931, the European standard for e-invoices (rules BR-CO-10, 13, 14, 15 and 17).
  • The check digits of a CVR number (modulus 11), an IBAN (modulus 97) and a FIK payment code (modulus 10) are valid.
  • The dates are in the right order.
  • The supplier's CVR number differs from the buyer's CVR number.
  • The invoice number has not already been approved for the same supplier.

Learning each supplier's layout

When a person approves an invoice, Voucher saves the words that come before each value for that supplier. The next document from the same supplier is also read with those words, as a third reading without an AI model. The server runs the checks again on each approval and rejects an invoice number that was approved before. An approved invoice is exported as Peppol BIS Billing 3.0, as an invoice or a credit note.

Measured

The Quality page reads 30 test documents from 10 suppliers and compares each field with the correct answer. The set has 19 PDFs, 7 scans and 4 phone photos, including one credit note, one invoice whose total is 10.00 off, and one invoice sent twice. The page shows the share of fields read correctly, the fields approved automatically that were wrong, and the wrong fields that were sent to a person.

Previous: Admin from a spreadsheet (P19). Next: Zibaldone writing (P23).

How Prototype docs is built

The pages are written in Markdown and built into these pages and an index of 154 sections. The assistant answers from the index, and every answer names the sections it was taken from.