Document Invoice Processing
An invoice-processing pipeline that reads invoices with OCR, extracts the fields with an LLM, and checks the numbers before anything is posted. It is tested against 16 fictional invoices designed to break it: scans, skewed phone photos, handwritten amendments, broken arithmetic, unknown vendors, changed bank details and a corrupt file.
- 16
- test invoices, each with an expected outcome
- 3
- invoice layouts
- Exact
- money checks in integer minor units
What I built
- A fixture generator renders 16 fictional invoices across three layouts, with a machine-readable manifest of the expected result for each, such as AUTO_POST.
- The edge cases are deliberate: a clean native PDF, a scan, a skewed photo, a handwritten amendment, broken arithmetic, an unknown vendor, a bank-detail change, a corrupt file and a signature-image decoy.
- Money is validated in integer minor units, so totals are checked exactly instead of with floating-point rounding.
- An OCR benchmark (Tesseract.js) proves the invoice number and total can be recovered before the workflow is allowed to depend on them.
- Fields are extracted by an LLM inside an n8n workflow, and an invoice that fails validation is held back instead of posted.
Stack
- n8n
- Node.js
- Tesseract.js
- LLM field extraction
- Headless Chrome
