The challenge
A 9-person AP team processed 30,000 invoices a month from 40+ vendors with inconsistent formats. The legacy OCR performed well on structured invoices but failed on free-form PDFs, forcing manual rework on 40% of the volume. Finance leadership needed to scale AP throughput without adding headcount as the business grew.
The approach
Instead of upgrading the OCR, we designed an AP agent: an LLM-powered agent with tool access to SAP, the vendor master, the general ledger, and the purchase-order system. The agent extracts line items, applies PO-matching and GL-coding rules, posts the invoice to SAP, and escalates to a person only when confidence falls below threshold. We paired it with UiPath for the deterministic parts (SAP posting, PDF routing, the ERP inbox) and built a review UI for exceptions.
The solution
Claude Sonnet as the reasoning engine with function calling into internal tools. UiPath bots for deterministic SAP posting and PDF handling. A Next.js review UI for exceptions with keyboard-first UX. An evaluation pipeline with 500 golden invoices. Observability in Power BI.
Illustrative example. An invoice arrives by email, the agent reads the vendor, PO number, total and GL account, checks the PO, the vendor master and the tolerance, and automation posts it in SAP with no human touch.
| Description | Qty | Unit price | Amount |
|---|---|---|---|
| Hydraulic fittings | 40 | 12.50 | 500.00 |
| Steel brackets | 25 | 18.00 | 450.00 |
| Freight | 1 | 85.00 | 85.00 |
- 1
Received
The invoice arrives as a PDF in the AP mailbox.
EX-2041.pdf
- 2
Read by the agent
Claude reads the free-form PDF and extracts the fields.
- Vendor
- PO number
- Total
- GL account
- 3
Checked
The agent checks it against the systems of record.
- PO match: PO EX-7731 open, lines found
- Vendor master: Vendor active, record matches
- Tolerance: Quantities and prices within limits
- PO match: PO EX-7731 open, lines found
- Vendor master: Vendor active, record matches
- Tolerance: Line 1 quantity: 60 invoiced, 40 on PO
- 4
Posted in SAP
Deterministic automation (UiPath) creates the document.
SAP 5100001234 (example)
Held. Automation does not post this one.
- 5
Done: straight-through
No human touch. Posted, logged and closed. In the published case, 8% of invoices go to a person instead.
Exception: routed to a person
Sent to the review UI with the agent's reasoning.
Agent's reasoning, example
Line 1 bills 60 units but PO EX-7731 allows 40. That is outside the tolerance, so a person needs to decide.
Audit trail Illustrative entries
Prompt and model versions pinned quarterly
- 09:14:02SystemInvoice received (email PDF)
- 09:14:04Agent4 fields read by the agent
- 09:14:05AgentPO found and matched
- 09:14:05AgentVendor master: match
- 09:14:06AgentWithin tolerance
- 09:14:09AutomationPosted in SAP (automation)
- 09:14:09SystemClosed, straight-through
Illustrative walkthrough; figures from the published case
In production: 92% straight-through by month 2, 3× throughput with the same team, under $0.40 per invoice.
The outcome
Straight-through processing reached 92% in month 2 and stabilized at 95% by month 6. AP throughput tripled with the same headcount. Cost per invoice fell below $0.40. The exceptions that do reach people are resolved in under a minute thanks to the review UI.
“It's not just faster, it's more accurate than we are.”
Lessons
The review UI mattered more than we expected: AP teams are fast when the tool is fast too. We also learned to pin prompt and model versions quarterly for auditability.
