Processing Incoming Invoices with AI: From PDF and E-Invoice to Booking
Accounts payable teams now receive invoices in two very different shapes: structured e-invoices that are data from the start, and PDFs or paper that have to be read. An AI agent can handle both streams, but only if it treats them differently. This guide covers the options, the decision criteria and how the handover to accounting should work.
What does this guide cover, and who is it for?
It covers the path of a supplier invoice from the inbox to a booking proposal: capture, read, check, match against purchase order and goods receipt, suggest coding and hand over to the accounting or ERP system. It is written for finance, procurement and controlling leads who are deciding how much of that path an agent should own.
For the general picture of how agents work with scans, contracts and data sheets, see Making Documents, PDFs and Scans Usable for AI Agents. This article is narrower. Invoices are special because a growing share of them no longer needs OCR at all.
The regulatory direction across Europe points the same way. The European Commission's ViDA package was adopted on 11 March 2025; it lets member states introduce mandatory e-invoicing under specific conditions, and digital reporting based on e-invoicing will apply to cross-border B2B transactions from 1 July 2030. Germany already requires every business to be able to receive e-invoices since 1 January 2025, according to the German finance ministry's FAQ. For issuers, transition rules allow other invoice types until the end of 2026, and until the end of 2027 where the issuer's prior-year turnover was at most EUR 800,000. In practice, mixed inboxes will be normal for years. None of this is legal advice.
Which invoice formats does the agent need to tell apart?
Three: pure XML e-invoices, hybrid invoices that combine a PDF view with embedded XML, and everything else, meaning plain PDFs, scans and paper. The first two are parsed; only the third is extracted with OCR and a language model. Getting this routing right matters more than any model choice.
The common standard. According to the European Commission, EN 16931 was developed by CEN at the Commission's request. It consists of a semantic data model and two mandatory syntaxes: UBL 2.1 and UN/CEFACT Cross Industry Invoice (CII). A new version of EN 16931-1 was published in May 2026, replacing the 2017 edition.
XRechnung (pure XML). Germany's public-sector format is, per xeinkauf.de, an XML data set based on EN 16931 that can use either syntax. Version 3.0 has applied since 1 February 2024 and stays in force until at least 31 July 2027; a pre-release of specification 4.0 was published in September 2026 (as of November 2026). The practical lesson applies to any EN 16931 format: support both UBL and CII, and expect version changes.
ZUGFeRD (hybrid). As FeRD explains, ZUGFeRD embeds the structured invoice data as CII-based XML inside a PDF/A-3 file, with the PDF serving as the human-readable view. The current information package is ZUGFeRD 2.5.2, dated 4 August 2026. German tax guidance states that where the two parts differ, the structured data take precedence. An agent that runs OCR on the PDF of a hybrid invoice is reading the secondary copy.
Everything else. A plain PDF is not an e-invoice under German rules, even though it arrives electronically. For these, OCR plus a language model extracts the fields into a fixed schema, with the usual risks around tables, discount lines and multi-page documents.
How do you choose the right processing route?
Four questions decide it. What share of your invoices is already structured? Do purchase orders and goods receipts exist in a system the agent can query? Where do the results go, an ERP with its own invoice verification or a standalone accounting package? And how much automation will your finance team accept without sign-off?
- Structured share. Count one month of incoming invoices by format. If XML is already common, build the structured path first and keep extraction as a fallback.
- Purchase order coverage. Goods and materials invoices can be checked against orders and receipts. Invoices without an order, such as rent, utilities or advisory work, need different rules, for example comparison with the contract or the previous period.
- Target system. The handover format depends on whether data lands in an ERP or an accounting package. If your bookkeeping runs on DATEV, common in Germany, the article Finance Agent on DATEV Data covers what happens after booking; this guide covers the steps before it.
- Approval level. Decide which cases the agent only prepares and which it may pass on unreviewed. A sensible start: every invoice gets a proposal, a person approves.
- Validation. Ready-made validators exist. The KoSIT validator checks XML documents against XML Schema and Schematron rules and is licensed under Apache 2.0.
What does the process look like from inbox to booking?
Six stages: capture, detect the format, parse or extract, run business checks, match against order and receipt, and hand over. The language model is used only where fixed rules are not enough: reading unstructured documents, matching loosely worded line items and explaining a mismatch in plain language.
- Capture. One mailbox or portal that the agent polls. Store each attachment with sender, timestamp and message ID so every invoice can be traced back to where it came from.
- Detect the format. For an XML file, identify the syntax (UBL or CII). For a PDF, first check for an embedded XML attachment. Only if there is none does the document go to extraction.
- Parse or extract. Structured invoices are parsed field by field: invoice number, date, supplier, VAT ID, line items, tax rates, totals, bank details, order reference. In Java environments, the open-source Mustangproject library can read, write, validate and convert ZUGFeRD, Factur-X and XRechnung (Apache 2.0, version 2.26.0 released 25 August 2026). For PDFs and scans, a language model fills the same schema.
- Business checks. Do the lines add up to the totals? Are tax rate and tax amount consistent? Is the supplier known, the bank account unchanged, the invoice number not already booked? These are rules, not AI tasks.
- Match against order and receipt. This is the classic three-way match: do quantity and price agree with the purchase order, and was the invoiced quantity actually received? The model helps when the order reference is missing or the supplier's line text differs from your catalogue, and it writes a short reason for each mismatch.
- Handover. The agent produces a booking proposal with supplier account, GL account, cost centre and tax code, and attaches the original document. For e-invoices, keep the original XML untouched. According to the German finance ministry, the structured part must be kept for eight years in its original, unaltered form; check the retention rules in your own jurisdiction.
How invoice handling fits into the wider role of a finance agent, alongside dunning, cash forecasting and reporting, is covered in AI Agents for Accounting and Controlling in Mid-Sized Companies.
What typically goes wrong?
Most failures happen around the reading step rather than in it. Hybrid invoices get processed as images, duplicates slip through, changed bank details are accepted, and the original XML is lost on the way to accounting. Some limits cannot be solved by any agent.
- Reading the PDF instead of the XML. Treating hybrid invoices as plain PDFs means processing the copy that does not count.
- Duplicates. The same invoice arrives by email and by post, or twice with different file names. Check supplier, invoice number and amount, not files.
- Changed bank details. A new IBAN for a known supplier is a classic fraud pattern. The agent must never adopt it on its own; it flags it for review.
- Thin e-invoices. Not every XML carries an order reference or clean line items. German guidance even tolerates gross-price invoices issued until the end of 2027 that list only totals in the structured part, which makes line-level matching impossible.
- Standards keep moving. EN 16931-1 has a 2026 edition and XRechnung 4.0 is on its way. Parsers and validation rules need an owner and a maintenance routine.
- Extraction errors. On a poor scan, a language model may produce a plausible value instead of admitting a gap. Every extracted field needs a plausibility check and, when in doubt, a human.
When it is not worth it: with only a handful of invoices a month, the built-in features of your accounting software are usually enough. And where orders and goods receipts are not recorded reliably, matching becomes guesswork; the fix then belongs in procurement, not in accounts payable.
Conclusion: where should you start?
Start with the structured path: detect e-invoices, parse the XML, validate it, match it against orders and hand over proposals. It is rule-based, testable and covers a growing share of volume. Add AI extraction for PDFs and paper as a second stage, with clear thresholds for when a person takes over.
In our own operations, a shadow phase works well: the agent proposes a booking for every invoice while the team keeps working as before, and the comparison shows which cases it handles reliably. For an overview of other specialised agents beyond accounts payable, see AI agents for business processes.
Frequently asked questions
Do I still need OCR if suppliers send e-invoices?
Not for genuine e-invoices. Their content is already machine-readable XML, so a parser is more reliable than reading the PDF image. OCR and AI extraction remain necessary for plain PDFs, scans and paper.
What is EN 16931?
It is the European standard for electronic invoicing, published by CEN at the request of the European Commission. It defines a semantic data model and two mandatory syntaxes, UBL 2.1 and UN/CEFACT CII.
Which part of a hybrid invoice should the agent trust?
The embedded XML. German tax guidance states that if the structured part and the visual PDF differ, the structured data prevail, and the same logic applies to any process built on the data.
Should the agent post invoices automatically?
Start with proposals that a person approves. Automatic posting makes sense only for narrow cases, such as recurring invoices with no deviation from the order or contract.
Sources
- European Commission: The European standard on eInvoicing (EN 16931) ec.europa.eu
- European Commission: VAT in the Digital Age (ViDA) taxation-customs.ec.europa.eu
- German Federal Ministry of Finance: FAQ on the introduction of e-invoicing (German) bundesfinanzministerium.de
- KoSIT / xeinkauf.de: XRechnung xeinkauf.de
- FeRD: ZUGFeRD ferd-net.de
- Mustangproject: library for ZUGFeRD, Factur-X and XRechnung mustangproject.org
- KoSIT Validator (GitHub) github.com