Invoice and purchase order match

Compare the items on an invoice with the purchase order it cites. Totals are compared in code.

F@f

Problem

Line descriptions on invoices rarely match purchase orders word for word, so exact matching fails and people compare them by hand.

Goal

Pass invoices whose items correspond to the order, and send partial or missing matches to a person.

Input / state

Invoice lines and PO lines from your parser and ERP, with totals already compared in code.

invoice_lines
Line descriptions and quantities extracted from the invoice.
po_lines
Line descriptions and quantities on the purchase order.
code_checks
Results of total and quantity comparisons done in code.

Decision question

ChoiceQuestion key po_match

Do the items on the invoice correspond to the items on the purchase order?

Options

  • matchesEvery invoice line corresponds to a PO line, even if worded differently.
  • partial_matchSome lines correspond, others are extra, missing or different.
  • no_matchThe items don't correspond, or the cited PO is for something else.

Allowed outcomes

Decided in your code from the answer and its confidence. Thresholds are yours to set and test.

  • MatchedChoice is matches and confidence meets your threshold.
  • Partial matchChoice is partial_match and confidence meets your threshold.
  • No matchChoice is no_match and confidence meets your threshold.
  • AP specialistConfidence is below your threshold: probability is spread across options.

Example scenarios

Predefined demonstrations. No model is called; the outcome shown is an illustrative judgment.

Example state

{
  "po_lines": [
    "Toner cartridge, black, LaserJet (26A) qty 4"
  ],
  "code_checks": "totals equal",
  "invoice_lines": [
    "HP 26A black toner x4"
  ]
}

Outcome

Illustrative
Matched

Choice is matches and confidence meets your threshold.

Why

Same item and quantity, worded differently.

Using it well

  • Compare totals, tax and quantities in code. Arithmetic is a known weak spot for language models.
  • A match on items doesn't approve payment; it moves the invoice to the next check.

Request definition

POST https://api.typesafe.ai/v1/systemone
{
  "model": "jev-latest",
  "state": {
    "invoice_lines": "<invoice_lines>",
    "po_lines": "<po_lines>",
    "code_checks": "<code_checks>"
  },
  "questions": {
    "po_match": {
      "type": "choice",
      "instructions": "Do the items on the invoice correspond to the items on the purchase order?",
      "criteria": {
        "matches": "Every invoice line corresponds to a PO line, even if worded differently.",
        "partial_match": "Some lines correspond, others are extra, missing or different.",
        "no_match": "The items don't correspond, or the cited PO is for something else."
      }
    }
  }
}

Request shape from the System One API reference; a Kev server accepts the same body. Replace the placeholder state with your data. Requests need your own API key or server.

Version History

v1Current Versionabout 8 hours ago@f

Initial version

Comments (0)