AI (artificial intelligence) Learning · 02 / 08

End-to-End Walkthrough

One invoice followed from email to payment: extraction, three-way match, an exception resolved with a cited clause, approval, posting and audit.

The invoice

An illustrative run, following one real-shaped invoice through the system. Amounts are net of tax to keep the arithmetic clear.

Supplier: Example Supplies Ltd (vendor V-10442). Invoice INV-2026-04417, dated 14 October 2026, terms net 45. Purchase order PO-88213 for $12,480.00. The invoice arrives by email on 15 October 2026.

LineItemInvoicedPO (Purchase Order) valueReceived / accepted
1Widget A10 × $310.00 = $3,100.0010 × $310.0010
2Bracket B40 × $180.00 = $7,200.0040 × $180.0036 (goods receipt GRN-70211)
3Calibration service2 × $1,090.00 = $2,180.002 × $1,090.002 (service entry SES-5531 accepted)
Total$12,480.00$12,480.00Quantity short on line 2: 4 units

Stage by stage

Timeline of one invoice from receipt to archive Seven events from ingest at 09.14 to archive at 11.04. Matching fails at 09.17, the agent drafts a fix at 09.18, and the approver is asked at 09.44 and approves at 11.02.09.14Ingest09.17Match fails09.18Agent fix09.44Approval asked11.02Approved11.03Posted11.04ArchivedINV-2026-04417, 15 October 2026
Seven events from ingest to archive. Most of the time after the match failed was spent waiting for the approver.
  1. 09:14 · Ingest

    The mailbox connector stores the PDF (Portable Document Format) unchanged in immutable storage and records the sender, received time and SHA-256 (Secure Hash Algorithm, 256-bit) hash.

  2. 09:15 · Normalize

    The PDF is converted to page images and text. The hash is checked against earlier documents; no duplicate is found.

  3. 09:15 · Classify

    The LLM (Large Language Model) labels the document as an invoice with confidence 0.98. Non-invoices would route to a review queue here.

  4. 09:16 · Extract

    Document AI returns header and line fields as JSON (JavaScript Object Notation) that must match the invoice schema. Each field carries a confidence score.

  5. 09:16 · Validate

    Schema passes. Line amounts sum to the stated total, and the currency and tax fields are present.

  6. 09:17 · Enrich

    Vendor V-10442 is active, its bank details are unchanged since 2025, and it is approved for direct posting.

  7. 09:17 · Match

    Header total matches PO-88213. Line 2 is invoiced for 40 units, but only 36 were received, so the excess 4 units ($720.00) fail the zero-tolerance quantity rule. The DAG (Directed Acyclic Graph) routes the invoice to the exception agent.

  8. 09:18 · Resolve

    The agent calls grn.search and po.get through the MCP (Model Context Protocol) gateway, retrieves clause 7.3 of the supplier contract, and drafts a resolution: approve $11,760.00 for accepted quantities and open a dispute for $720.00.

  9. 09:44 · Approve

    The rules place $11,760.00 in the $5,000–$25,000 band, so the AP (Accounts Payable) Manager is asked to approve. The reviewer sees the draft, the clause and the match table, then approves the partial amount.

  10. 11:03 · Post

    The DAG posts AP invoice AP-2026-0091287 for $11,760.00 with an idempotency key. The $720.00 dispute is recorded as an open query against the vendor.

  11. 11:03 · Schedule

    Payment is scheduled for the 27 November 2026 payment run, one day before the net-45 due date of 28 November 2026.

  12. 11:04 · Archive

    The trace, the extraction, the match result, the clause citation, the approval and the ERP (Enterprise Resource Planning) document ID (identifier) are written to the audit store under one trace ID.

What the extraction looked like

The model returns data, never free text, and the orchestrator rejects anything that does not validate against the schema. Excerpt:

extraction · validated against invoice.v3 schema
{
  "document_type": "invoice",
  "invoice_number": "INV-2026-04417",
  "vendor_id": "V-10442",
  "invoice_date": "2026-10-14",
  "payment_terms_days": 45,
  "currency": "USD",
  "po_number": "PO-88213",
  "total_net": 12480.00,
  "lines": [
    { "line": 1, "item": "Widget A", "qty": 10, "unit_price": 310.00, "amount": 3100.00, "confidence": 0.99 },
    { "line": 2, "item": "Bracket B", "qty": 40, "unit_price": 180.00, "amount": 7200.00, "confidence": 0.97 },
    { "line": 3, "item": "Calibration service", "qty": 2, "unit_price": 1090.00, "amount": 2180.00, "confidence": 0.95 }
  ],
  "extraction_confidence": 0.97
}

Outcome and time

Elapsed time from receipt to posting was about two hours, of which roughly 75 minutes was waiting for the approver. Without the exception path, a clean invoice of the same shape goes straight to posting once the approval band clears. The dispute stays open in the ERP, so the vendor sees one clear question instead of an unexplained short payment.

Build this for your business

This example uses a generic invoicing system, but the same pattern — orchestrated steps, governed tools, grounded knowledge and a documented lifecycle — fits most back-office processes. We can scope a pilot on your own documents and systems.

Book a discovery call