FinancePrototypeEN
Invoice data extraction
Demo prototype: reads synthetic PDF invoices and fills an accounting import file.
Esempi BestIAPublished on 24 November 2026
- Maturity
- Prototype
- Category
- Finance
- Entry language
- English
- Published
- 24 November 2026
01The problem
In this fictional company, invoice data is typed by hand into the accounting software, with frequent mistakes in VAT numbers and totals.
02The solution
PDFs are converted to text, key fields are extracted and validated against simple rules, and a CSV is produced for the accounting import.
03Role of AI
A language model extracts structured fields; totals and VAT checksums are verified by code before anything is exported.
04Technical architecture
README.md
InvoiceLens — invoice data extraction
Demo prototype on synthetic PDF invoices.
Overview
Batch tool that turns PDF invoices into an accounting import CSV. The model extracts fields; code verifies totals and VAT numbers.
Pipeline
inbox/*.pdf
|
v
[pdfplumber] text + tables --(no text layer)--> [OCR]
|
v
[LLM API] -> InvoiceSchema (JSON)
|
v
[Validators] VAT checksum, sum(lines) == total, dates, currency
| |
ok fail -> review.csv (with reason)
v
export/accounting.csv + audit.jsonl (field -> page, bbox, text span)Stack
| Part | Technology |
|---|---|
| Runtime | Python 3.12, Typer CLI |
| pdfplumber | |
| Schema | Pydantic v2 |
| AI | LLM via API |
Schema
class Line(BaseModel):
description: str
quantity: Decimal
unit_price: Decimal
vat_rate: Decimal
class Invoice(BaseModel):
supplier_name: str
supplier_vat: str # validated with checksum
number: str
issue_date: date
currency: Literal["EUR"]
lines: list[Line]
total: DecimalChecks
abs(sum(line.quantity * line.unit_price * (1 + line.vat_rate)) - total) <= 0.01- VAT number checksum per country.
- Duplicate detection on (supplier_vat, number).
Run
uv run invoicelens extract inbox/ --out export/05Results and lessons
Results verified by the authorFields correct on 47 of 50 synthetic invoices in the author's test.