Case note · Accounts payable
The invoice pipeline, from day one
TL;DR — A 40-person trading company's AP inbox ate about 9.5 hours a week. The baseline said so in receipts and a stopwatch, not in a workshop. The fix was mostly plain code: rules for the two standard formats, one model call for the handwritten scans, a human check by design. Week 6: 2.8 hours a week, zero mis-posted invoices, and the AP specialist got her afternoons back.
Names and identifying details withheld; numbers come from the measurement log kept during the project. [[CASE: verify all figures against the real client log and confirm the disclosure approach before publication]]
What "automate the invoices" actually meant
The request arrived as one sentence: "We want AI to read our invoices." The audit week found something narrower and more boring — which is exactly why it was fixable.
- The inbox: ~140 supplier emails a week; 60 carried a PDF invoice. 80% followed three formats — two were clean system exports, the third was a partner's handwritten-style scan. The remaining 20% were edge cases: multi-invoice attachments, currency mismatches, one monthly PDF statement that mixed orders and payments together.
- The work: for each invoice, the AP specialist opened the ERP, matched supplier and PO, typed totals and dates, and replied to the supplier with a confirmation. 6.5 minutes average — measured over 40 invoices she processed while we watched, not self-reported.
- The cost: ~9.5 hours a week of a salaried specialist, plus the errors: ~2 mis-posted invoices a month, each taking half a day to unwind. That was the floor every later claim had to beat. [[CASE: monthly CNY cost figure]]
What we ruled out, and why
- A full document-AI platform. The 20% of variety would still hit a human, and the platform's monthly fee was close to the hours it saved. Paying a subscription to move the same bottleneck. [[CASE: vendor cost comparison detail]]
- A "company brain" for AP. Under 50 staff, and the entire corpus was three PDF format specs. A naming convention and a one-page checklist beat it — and cost nothing a month.
- An LLM reading raw PDFs end to end. Quality was fine on the two clean formats and unacceptable on the scan, and "fine" is not the bar when money is moving. It also made every invoice depend on a model call — meaning the next price or quota change upstream becomes your outage.
What we built instead (three lines, roughly)
- Rules first. Parse the two clean system-export formats with plain code. No model involved: fast, free, deterministic. That's ~80% of volume handled before any AI enters the picture.
- One model step for the remainder. The handwritten-style scans go to a Qwen vision model with a strict JSON schema and per-field confidence. Below threshold → straight to the human queue. No drama, no retries at 3 a.m.
- Human check by design. Every automated post writes a one-line summary into the ERP comment field; every Friday the AP specialist clears the exceptions list in one pass. The check is part of the pipeline, not an apology for it.
Total custom code: ~300 lines of Python and one scheduled job, running inside the client's own machine room on a box with no internet connection. [[CASE: infrastructure detail]]
What the numbers say
Same measurement method as the baseline, six weeks after go-live:
- Time: 9.5 h/week → 2.8 h/week. The remaining time is the Friday exceptions pass plus confirmations on the model-handled scans. The other ~6.7 hours went back to the supplier-relations work she'd been doing after hours.
- Quality: mis-posted invoices: ~2/month → 0 in six weeks. Not because the system is magic — because a human still sees every non-routine invoice, and the routine ones now carry a written summary.
- Latency: confirmation to supplier: same day → same morning for the standard formats. Suppliers noticed before the CFO did.
- Running cost: the model step processes ~120 invoices a month — [[CASE: API cost/month]] — less than a category-2 taxi ride per month, against [[CASE: hours × rate]] of saved labour. The honest math held.
What broke, and what we'd do differently
- The monthly PDF statement (orders and payments mixed) still goes straight to the human. We decided a custom parser for one edge case wasn't worth the maintenance. If the supplier ever changes their format, the answer stays "no".
- One supplier changed a field name in month 2 without telling anyone. The pipeline failed loudly, the exceptions queue caught it, and the fix took 20 minutes. This is the maintenance retainer earning its keep.
- What I'd change: the confirmations to suppliers should have been bilingual from day one — the Chinese supplier copy got translated a week later than it should have been.
[[CASE: client quote slot — 2–3 sentences from the AP specialist or finance lead, with explicit written permission. Placeholder until real approval exists; no invented quotes.]]
The system is documented, owned by the client's finance lead, and ships with a runbook. The quarterly re-check of the model choice is on the calendar. Six months in, I'm the boring part of the stack.