Vai al contenuto

FinancePrototipoEN

Invoice data extraction

Demo prototype: reads synthetic PDF invoices and fills an accounting import file.

Esempi BestIAPubblicata il 24 novembre 2026
Maturità
Prototipo
Categoria
Finance
Lingua della scheda
English
Pubblicata
24 novembre 2026

01Il problema

In this fictional company, invoice data is typed by hand into the accounting software, with frequent mistakes in VAT numbers and totals.

02La soluzione

PDFs are converted to text, key fields are extracted and validated against simple rules, and a CSV is produced for the accounting import.

Il cuore AI del progetto

03Ruolo dell'AI

A language model extracts structured fields; totals and VAT checksums are verified by code before anything is exported.

04Architettura tecnica

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

text
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

PartTechnology
RuntimePython 3.12, Typer CLI
PDFpdfplumber
SchemaPydantic v2
AILLM via API

Schema

python
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: Decimal

Checks

  • 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

bash
uv run invoicelens extract inbox/ --out export/

05Risultati e lezioni

Risultati verificati dall'autore

Fields correct on 47 of 50 synthetic invoices in the author's test.

—Immagini

  • Illustration: a PDF invoice whose fields are extracted into a structured table