Skip to content

Automation7 min read

AI document processing: how to extract invoices, delivery notes and contracts without losing control

OCR reads the page, a language model understands it, and validation rules decide what a person must check. A practical guide to building document extraction you can trust.

Ryze Labs engineering team

Key takeaways

  • Reliable document processing is a pipeline of OCR, model extraction, validation against your own data and human review, not a single AI call.
  • Validation rules that compare extracted values with purchase orders, master data and arithmetic catch most errors before they reach your ERP.
  • Structured e-invoices should be parsed directly; AI extraction is for the scanned, emailed and photographed documents that remain.

Most companies still retype data from documents. Supplier invoices arrive as PDFs, delivery notes come back as phone photos with a signature in the corner, and contracts sit in shared folders where nobody can find the renewal date. The work is repetitive, the errors are expensive, and the people doing it would rather do something else.

Why documents are harder than they look

A document looks structured to a person, but to software it is a picture of text. Every supplier has a different invoice layout, delivery notes are often crumpled or photographed at an angle, and contracts bury key terms in clause 14.3. Template-based OCR tools worked when you had five suppliers; they break when you have five hundred.

The other difficulty is that extraction is only half the job. Knowing that an invoice says 1,240.00 is useless unless you also know which purchase order it belongs to, whether the quantities match what was received, and whether the VAT is calculated correctly. That checking step is where most of the manual time actually goes. In a warehouse, supplier delivery notes at receiving are often the first documents worth automating; AI in warehousing shows where this fits next to stock control and picking.

How a document pipeline works

A production setup is a chain of small, testable steps. Each step does one thing and records what it did, so when something goes wrong you can see exactly where.

  1. Intake: documents arrive from a shared inbox, a scanner folder, a supplier portal or a mobile app, and each one gets an ID and a stored original.
  2. Classification: the system decides whether this is an invoice, a credit note, a delivery note, a contract or something else, and routes it accordingly.
  3. Text recognition: OCR turns scans and photos into text with positions on the page; born-digital PDFs skip this and use their embedded text.
  4. Extraction: a language model maps the text to your fields, such as supplier, document number, dates, line items, totals and tax.
  5. Validation: rules check the result against arithmetic, master data and open orders, and assign a confidence status.
  6. Review and posting: clean documents go straight to the ERP or accounting system; anything flagged goes to a person first.

This structure is the same whether you process supplier invoices in an accounts payable team or proof-of-delivery notes in warehousing. What changes is the field list and the validation rules.

OCR versus language-model extraction

OCR and language models solve different problems, and good systems use both. OCR answers the question of which characters are on the page. A language model answers the question of what those characters mean in context, for example that the date next to Due is the payment deadline and the other date is the delivery date.

Classic OCR with templatesOCR plus language model
New layoutsNeeds a new template per supplierUsually handles unseen layouts
Line items and tablesFragile when rows wrap or columns shiftBetter at reading irregular tables
Free-text documentsWeak; contracts need manual readingCan find clauses, parties and dates
PredictabilityDeterministic for known layoutsNeeds validation, since it can misread
Running costLow per pageHigher per page, depends on the model

Language models can also be wrong with confidence, which is why the extraction step should never be trusted on its own. Ask the model for structured output in a fixed schema, require it to point to where on the page each value came from, and let it return empty when a field is missing rather than guess. Our article on why models make things up explains the mechanics.

Validation: where trust comes from

Validation is the part that turns a demo into something your finance team will accept. The aim is that every document either passes checks you understand or is stopped with a clear reason.

  • Arithmetic: line totals add up to the net amount, tax is consistent with the rate, and net plus tax equals gross.
  • Master data: the supplier's tax ID and bank account match your vendor record; a changed IBAN is always flagged.
  • Order matching: quantities and prices are compared with the purchase order and the goods receipt, within tolerances you set.
  • Duplicates: the same supplier, number and amount have not been booked before.
  • Plausibility: dates are in a sensible range, currencies are expected, and the document type fits the sender.

Designing the human review step

Human review is not a sign that automation failed. It is how you keep control while the system handles the routine cases. The design question is which documents a person sees, what they see, and how fast they can confirm or correct it.

A good review screen shows the original document next to the extracted fields, highlights the values that failed validation, and lets the reviewer fix a field in one click. Every correction is logged, which gives you a record for audit and a dataset for improving the prompts and rules. Start with a high review rate and lower it only when your measurements justify it; our guide to human-in-the-loop design covers thresholds and escalation.

Example

Illustrative example: a 40-person distribution company

This is a fictional, illustrative calculation. Suppose an office handles 400 supplier invoices a month at about 3 minutes each for keying and checking, roughly 20 hours a month. If the pipeline posts clean, fully matched invoices automatically and a person reviews the rest at about 1 minute each, the saving depends entirely on how many invoices pass validation. Measure that pass rate in a pilot on your own documents before you plan around any number.

E-invoices change the picture

If a document already arrives as structured data, do not run it through AI at all. Parse it directly. In Romania, B2B invoices between Romanian taxpayers must go through RO e-Factura in the CIUS-RO profile of EN 16931 (UBL XML). In Germany, every business must be able to receive EN 16931 e-invoices such as XRechnung or ZUGFeRD since 1 January 2025, and issuing becomes mandatory in stages from 2027.

That means AI extraction is increasingly for what is left: foreign suppliers, receipts, delivery notes, customs documents, contracts and anything photographed in a yard. Our overview of e-invoicing in the EU explains what your ERP needs to handle. Rules and dates change, so check current ANAF or BMF guidance and your tax advisor.

How to start: a practical checklist

  • Pick one document type with real volume, such as supplier invoices or proof-of-delivery notes.
  • Collect a sample of a few hundred real documents, including bad scans and unusual layouts.
  • Write down the fields you need and where each one goes in your ERP or accounting system.
  • List your validation rules before you build anything; they matter more than the model choice.
  • Run a pilot in shadow mode, where the system extracts but people still key, and compare the results field by field.
  • Decide the review threshold from measured error rates, not from hope.
  • Agree on data handling with your DPO, including where documents are stored and which processors see them.

If you want help building the pipeline, the integrations and the review screen, that is the kind of work we do as AI automations.

General information, not legal, tax or investment advice.

FAQ

Questions people ask

Modern OCR and vision models can often read clear handwriting, such as quantities and signatures on a delivery note. Accuracy drops with poor photos and messy writing, so handwritten fields should usually go through validation and human review. Test on your own documents before relying on it.

For invoices that pass strict validation, such as matching a purchase order, goods receipt and known supplier data, automatic posting can be reasonable. Anything that fails a rule should be reviewed by a person. Set the threshold based on measured results from a pilot, not on vendor claims.

Structured e-invoices such as RO e-Factura XML, XRechnung or ZUGFeRD should be parsed directly, without AI. AI extraction is still useful for documents that arrive as PDFs, scans or photos, such as foreign invoices, receipts, delivery notes and contracts.

Documents often contain personal data, so you need a lawful basis, a data processing agreement with any AI vendor under Art. 28 GDPR, and a clear view of where data is processed. Check international transfer rules if the provider is outside the EU, and discuss the setup with your DPO.

How we can help

Services related to this article

  • AI Automations

    Workflows across email, documents, CRM, ERP and finance — without the copy-paste.

Read next

Want to apply this to your company?

Tell us which process slows you down. We reply within one business day with questions or a first idea of how we'd approach it.