# Agent design: supplier invoice processing

## Summary

Invoices arriving in the shared mailbox are read by a document-extraction model, checked against the purchase order and goods receipt in the ERP (three-way matching), and prepared for payment. Clean matches go to a two-person approval step; mismatches go to an exception queue with the reason explained. No payment is ever released without two human approvals, and every step is logged for audit. Targets: reduce manual keying, cut the 12% mismatch-handling time and remove most of the 1,400 a month in late-payment fees.

## Workflow

| Step | Actor | Tool | Output |
| --- | --- | --- | --- |
| 1 | Mailbox | Shared invoice mailbox | New email with PDF attachment |
| 2 | Agent | Document-extraction model | Supplier, invoice number, date, PO number, lines, totals, tax |
| 3 | Agent | ERP API | Supplier record, PO and goods-receipt lines |
| 4 | Agent | Rules + LLM | Three-way match result and a plain-English explanation of any difference |
| 5 | Agent | ERP API | Draft invoice record (status: pending approval) |
| 6 | Clerk | Approval tool | Approver 1 reviews match and approves or rejects |
| 7 | Finance manager | Approval tool | Approver 2 approves payment |
| 8 | ERP | ERP payment run | Payment scheduled; audit log closed |

## Decision rules

- **Extraction confidence below 0.9 on any key field:** send to the exception queue for a clerk to check the PDF.
- **Supplier not found or bank details differ from the supplier record:** stop, flag as **possible fraud**, and send to the finance manager. The agent never updates bank details.
- **Price or quantity differs from the PO by more than 2% or 50:** exception queue, with the difference explained.
- **Duplicate invoice number for the same supplier:** block and flag.
- **Due within 5 days:** mark as priority in the approval queue to avoid late fees.

## Approval gates

| Action | Gate |
| --- | --- |
| Creating a draft invoice record | Automatic (status stays "pending") |
| Approving a matched invoice | Approver 1 (accounts clerk) |
| Releasing payment | Approver 2 (finance manager), who must be a different person from Approver 1 |
| Changing supplier bank details | Outside this workflow; existing verification process only |

Segregation of duties is enforced in the approval tool: the same user cannot approve both steps.

## Failure handling

- **Extraction fails or the PDF is unreadable:** exception queue, tagged "manual entry".
- **ERP API unavailable:** hold the invoice in the queue and retry every 30 minutes; alert the team after 4 hours.
- **Email has several invoices in one PDF:** split by page if the model detects separate invoice numbers; otherwise send to the exception queue.
- **Weekly reconciliation:** compare mailbox count with ERP records to catch anything missed.

## Security, privacy and audit

- The agent has read access to POs, receipts and supplier records, and write access only to draft invoices.
- Every step records who or what acted, when, and the result; logs are kept for 7 years.
- Supplier bank details are masked in logs and never sent to the LLM.
- Invoice data stays within approved systems [confirm: data-processing terms of the extraction model].

## Metrics

| Metric | Baseline | Target |
| --- | --- | --- |
| Invoices keyed by hand | ~900 a month | Under 20% |
| Invoices with mismatches | 12% | Same rate, but resolved in under 2 working days [measure current time] |
| Late-payment fees | ~1,400 a month | Under 300 a month |
| Payments released without two approvals | 0 | 0 |
| Extraction accuracy on key fields | [measure] | 98% |

## Rollout plan

1. **Weeks 1–2:** run in parallel with manual keying on 100 invoices; compare extracted fields.
2. **Weeks 3–4:** use agent drafts for suppliers with clean matches only.
3. **Then:** extend to all suppliers once accuracy and exception rates hit target.

---

**Next:** a 2-week pilot plan and a risk register. Constraints respected: segregation of duties, two human approvals for every payment and a 7-year audit trail.
