Finance & Accounting

Pre-processinvoices.Identifypotentialduplicates.Flagproblemswiththerelevantcontractclauses.

The agent matches every invoice against the purchase order, service agreement, and expense policy before it reaches an approver. Clean matches auto-approve. Exceptions are routed to the finance system with the exact reason: not “flagged for review” — the specific policy clause and what it prohibits. The team opens a queue of decisions, not a pile of documents.

Key Takeaways

Overpayments eliminated

Every invoice is matched against the purchase order and contract terms before approval. Duplicate invoices and overbillings are caught automatically.

Straight-through processing

Clean invoices — those that match PO amount, vendor terms, and policy thresholds — are approved and queued for payment without touching an AP desk.

Exact clause citations

When an invoice is flagged, the review note cites the specific contract clause or policy section that triggered the exception — not a generic alert.

Three-way match automated

PO number, received goods confirmation, and invoice are reconciled in a single pass. Discrepancies surface before payment runs.

Audit trail built in

Every approval and every exception is logged with the source documents, matching criteria, and timestamp. Finance audit ready.

The approval bottleneck is in the matching, not the decision.

AP teams spend most of their time doing one thing: verifying that an invoice matches what was agreed. PO number, line items, rates, quantities, payment terms, applicable discounts. For high-volume invoice processing, this matching work consumes the bulk of the team's capacity before a single approval decision is made.

The automation performs the three-way match on every invoice — reconciling the invoice against the purchase order and the goods receipt confirmation. It then checks the result against the contract terms: rate schedules, approved vendor lists, early payment discount windows, and the applicable spend policy thresholds. Clean invoices are approved straight-through. Exceptions are flagged with the specific PO line, contract clause, or policy section that triggered the discrepancy.

The AP team's queue shrinks to exceptions only. Every item in it has a specific, actionable reason attached.

One call per invoice

Pass the invoice, the matching PO, the goods receipt, and the relevant contract. The automation performs the three-way match, validates against contract terms and spend policy, and returns an approval decision with a full audit trail.

python
import dspy
from predict_rlm import File, PredictRLM


class ProcessInvoiceForApproval(dspy.Signature):
    """Perform a three-way match between an invoice, its purchase order,
    and the goods receipt. Validate against contract terms and spend policy.
    Approve clean invoices; flag exceptions with specific clause citations."""

    invoice: File          = dspy.InputField(desc="Vendor invoice (PDF)")
    purchase_order: File   = dspy.InputField(desc="Original purchase order")
    goods_receipt: File    = dspy.InputField(desc="Goods or services receipt confirmation")
    contract: File         = dspy.InputField(desc="Vendor contract with rate schedule and terms")
    spend_policy: File     = dspy.InputField(desc="Internal spend policy and approval thresholds")
    approval_decision: str = dspy.OutputField(desc="Approved, or flagged with specific exception and clause citation")
    audit_record: File     = dspy.OutputField(desc="Matching log with source references — Excel")


agent = PredictRLM(ProcessInvoiceForApproval, lm="openai/gpt-5.1", max_iterations=8)

result = agent(
    invoice=File(path="invoices/INV-2026-04721.pdf"),
    purchase_order=File(path="pos/PO-2026-03814.pdf"),
    goods_receipt=File(path="receipts/GR-2026-03814.pdf"),
    contract=File(path="contracts/acme-services-2025.pdf"),
    spend_policy=File(path="policy/ap-spend-policy-v4.pdf"),
)
# result.approval_decision → queued for payment or routed to AP for review
# result.audit_record → archived to ERP

Built on predict-rlm — open source. github.com/Trampoline-AI/predict-rlm

What the AP team sees

Two queues. The first is a straight-through approval queue: invoices that passed the three-way match and policy check, ready to release for payment with a full matching log attached. The second is an exception queue: invoices flagged with a specific reason — the PO line that doesn't reconcile, the contract clause being violated, the spend threshold being exceeded. Every exception cites the source document and the specific passage. The AP team's job is to resolve exceptions, not to match invoices.