Process Automation | Artificial Intelligence
Invoice Automation: From Receipt to ERP Integration
· 6 min
Invoice automation is usually sold as a reading problem: get an AI to read PDFs. In practice, reading is the easy part. What decides whether the project works is everything around it — where the document comes from, how it is validated, and how it reaches the ERP without duplicates or wrong postings.
This article walks through the full flow, stage by stage, including the details specific to Portugal: the tax authority's QR code, the ATCUD, and the deadline that falls on 31 December 2026.
The six stages of supplier invoice automation
An invoice processing flow that survives production has six stages:
- Document capture
- Classification
- Data extraction
- Validation
- ERP integration
- Exceptions and archiving
Teams that jump from stage 1 to stage 5 end up with something that works in the demo and breaks in month two.
1. Capture: one way in
Invoices arrive by email, through supplier portals, on paper and, increasingly, as XML. The first job is to funnel all of it through a single door.
The simplest answer is a dedicated mailbox, something like invoices@company.com, shared with every supplier. The flow reads that mailbox, separates the attachments and stores the original before doing anything else.
Paper gets scanned into the same mailbox. Supplier portals are the awkward case: many send nothing and expect you to log in and download. Those go on their own list, with a scheduled collection.
2. Classification: not everything that arrives is an invoice
The invoice mailbox also collects credit notes, receipts, account statements, quotes and marketing. Treat everything as an invoice and the ERP fills up with noise.
Classification decides the document type and catches duplicates on arrival. The same PDF sent twice — once by the sales rep, once by the supplier's accounts team — happens more often than you would think.
A language model earns its place here, because it tells a receipt from an invoice-receipt by context, not just by the heading.
3. Extraction: start with what is already structured
Invoice data extraction is where most projects spend all their attention. There is an order that saves work and errors.
XML first. If the supplier sends a structured e-invoice (CIUS-PT in Portugal, mandatory for invoices to the State), the data is already there, field by field. There is nothing to "read".
Then the QR code. This is the detail most international tools miss. Under Ordinance 195/2020, invoices issued by certified software in Portugal carry a QR code with structured data: issuer and buyer tax numbers, date, document number, ATCUD, taxable amounts and VAT per rate, and the total.
Reading that QR code gives you the header fields deterministically, with no OCR and no AI. Render the page as an image and decode it.
AI only after that. The QR code does not include line items, the purchase order reference or the bank details. That is where an extraction model comes in — a dedicated service such as the Azure Document Intelligence invoice model, which supports Portuguese, or a language model with its own instructions.
And it comes in with a narrower job. In an earlier article we showed that extraction accuracy drops on line items and VAT breakdowns. That is exactly where the QR code helps: if the AI's total does not match the QR total, the system knows it got something wrong.
4. Validation: where the flow earns trust
A correctly read invoice can still be wrong. Validation catches what reading cannot:
- Known supplier. Does the issuer's tax number exist in the ERP supplier master? If not, no supplier is created automatically. It goes to review.
- Duplicate. Issuer tax number plus ATCUD identifies a document uniquely. If that pair has already been posted, the invoice stops.
- Totals add up. Taxable amounts plus VAT must equal the total. Obvious, but it is the rule that catches the most extraction errors.
- Order and receipt. For purchase-order spend, the invoice is matched against the order and the goods receipt — the classic three-way match. Quantities and prices outside the agreed tolerance go to review.
- Changed bank details. If the IBAN on the invoice differs from the supplier record, the invoice never goes through on its own. This is the textbook pattern of fraud via a compromised email account.
None of these rules needs AI. They are business rules, and they are what makes the output trustworthy.
5. ERP integration: the ERP decides the method
ERP invoice integration is the most variable stage. PHC, Primavera, Sage or SAP Business One — each installation exposes different things depending on version and licensing.
In order of preference:
- ERP API. The most robust option: the flow creates the purchase document directly and gets a confirmation back.
- Import file. Many ERPs accept documents from a fixed-format file. It works, but errors only surface when someone runs the import.
- RPA. A bot that fills in the screens like a user would. A last resort, because it breaks whenever the screen changes.
We covered when API, RPA or AI automation makes sense in more detail, including why RPA should be the exception.
One principle applies to all three: the invoice lands in the ERP as a pending document, not an approved posting. The flow prepares; accounting confirms. Responsibility stays where it belongs.
6. Exceptions, approval and archiving
Anything that fails earlier goes to a review queue — with the document, the extracted data and the reason it was stopped all in view. The reviewer should not need to open three systems to understand the problem.
The original is archived with a link to the ERP document. Once a month, it pays to compare what was posted against the invoices suppliers reported to the Portuguese tax authority under your tax number on the e-Fatura portal. An invoice that is there and not in the ERP is one that got lost at capture.
Worked example: 300 invoices a month
A hypothetical example, using our own estimates, to show where the exceptions end up.
An SME receives 300 invoices a month: 240 from Portuguese suppliers, 60 from abroad.
- The 240 Portuguese invoices carry a QR code. The header is read without interpretation errors. AI only extracts line items and the order reference.
- The 60 foreign invoices have no QR code. Assuming 90% real-world extraction accuracy, about 6 go to review.
- Matching against orders and receipts stops roughly another 15 — say 5% with price or quantity differences.
Result: around 20 invoices a month reach a person, instead of 300. And they arrive with the reason already identified.
To turn this into euros and payback time, we ran the numbers on a similar case in our piece on how much process automation costs for an SME.
What invoice automation does not fix
Three limits worth knowing before you start:
- Messy master data. Duplicate suppliers in the ERP, missing tax numbers, items without codes. The flow exposes these problems; it does not fix them.
- Invoices without an order. Services, retainers, one-off expenses. With no reference document, validation is weaker and human review carries more weight.
- Poor scans. Crumpled paper, skewed photos, unreadable QR codes. Input quality still matters.
The 31 December 2026 deadline
Portugal's 2026 State Budget Law sets out, in Article 95(3) of Law 73-A/2025, that until 31 December 2026 PDF invoices are accepted as electronic invoices for all tax purposes.
The requirement for a qualified electronic signature on PDFs has been postponed several times, and industry sources now point to 2027. Check the rules in force with your accountant before deciding. The direction is clear, though: more invoices will arrive signed or as XML, and a flow that already starts from structured data gets simpler over time, not harder.
The question before you start
Invoice automation pays off when volume is high enough and master data is in reasonable shape. Before picking a tool, answer this: of the invoices you receive each month, how many carry the tax authority's QR code, and how many have an order in the ERP they can be matched against?