Why LLM 3-Way Invoice Matching Double-Counts Short Deliveries (And the Excel Formula That Fixes It)

2026-11-29来源 dev.toEnglish

When you drop a purchase order, a receiving log, and a supplier invoice into a general-purpose LLM and ask "how much should we hold back?", the output usually looks reasonable until you add the columns up.

In our testing on a synthetic 3-way match case (PO-7416, GRN 9906, Invoice BX-118, total billed $1,224.00), the most common failure was not OCR. It was arithmetic. Specifically, two bugs showed up over and over again when a single invoice combined a short delivery, a unit price increase, and excess freight.

Bug 1: Double-counting price variance on undelivered units

Suppose a line item has:

  • PO quantity Q_p at PO unit price P_p
  • Buyer-signed received quantity Q_r
  • Invoiced quantity Q_i at invoiced unit price P_i

When Q_i > Q_r (short delivery) and P_i > P_p (price increase) happen on the same line, a naive calculation does this:

Short Delivery = (Q_i - Q_r) * P_i Price Variance = Q_i * (P_i - P_p) <-- wrong: uses Q_i instead of Q_r 

If you sum Supported + Short Delivery + Price Variance, you overshoot the invoice total by (Q_i - Q_r) * (P_i - P_p). You charged the supplier for a price increase on units you already excluded for not being delivered.

The clean algebraic split that reconciles to $0.00 is:

Supported Amount = Q_r * P_p Short Delivery = (Q_i - Q_r) * P_i Price Variance = Q_r * (P_i - P_p) 

Check the sum:

Q_r * P_p + (Q_i - Q_r) * P_i + Q_r * (P_i - P_p) = Q_i * P_i 

Every dollar of the billed line lands in exactly one bucket.

Bug 2: Treating an unsigned vendor packing slip as proof of receipt

The second failure happens before the math even starts. Suppliers often attach their own packing slip or shipping confirmation to an invoice PDF. If a parser reads every quantity document indiscriminately, it treats an unsigned vendor slip as accepted inventory.

In a spreadsheet, you can block this structurally by adding a Buyer-Signed? column (Yes / No) to the receiving log and wiring it directly into SUMIFS:

=SUMIFS('Receiving Log'!$E$2:$E$100, 'Receiving Log'!$B$2:$B$100, A2, 'Receiving Log'!$G$2:$G$100, "Yes") 

Any row marked No contributes 0 to accepted received quantity, so unverified packing slips never silently clear a short-delivery hold.

Bug 3: Freight billed over a written PO cap

Freight lines rarely have a quantity variance, so they get skipped in basic SKU-matching scripts. A simple line-level cap check catches it:

=MAX(0, Billed_Freight - PO_Freight_Cap) 

Full reconciliation on the synthetic test case

Running all three checks on the synthetic PO-7416 / GRN 9906 / Invoice BX-118 pack splits the $1,224.00 invoice cleanly with a $0.00 reconciliation check (=ROUND(Invoice_Total - Supported - Disputed, 2)):

Bucket Amount Rule
Supported by current records $914.00 Q_r * P_p + freight within PO cap
Short delivery (unreceived / unsigned) $216.00 (Q_i - Q_r) * P_i
Price increase on received units only $64.00 Q_r * (P_i - P_p)
Freight above written cap $30.00 MAX(0, Billed - Cap)
Invoice Total $1,224.00 Variance check: $0.00

Open Excel template and workflow

I put the 4-sheet workbook (PO, Receiving Log, Vendor Invoice, and 3-Way Variance Audit, with formulas and the Buyer-Signed? SUMIFS gate) plus its generator script on GitHub so you can inspect the formulas or adapt them for your own AP reviews:

If you need to pull the line items and page-level quotes out of scanned PDFs before running the math, I also built a small web tool around this exact deterministic audit split: https://apdispute.com/invoice-dispute-evidence-audit (uses the same synthetic case as a no-login sample).

If your team handles partial shipments with prior invoices already paid against the same PO, I would be curious how you track cumulative prior billing in Excel without turning the sheet into a maintenance headache.

原文:https://www.a8q9.cn/en/article/why-llm-3-way-invoice-matching-double-counts-short-deliveries-and-the-excel-form-0ed25f.html

相关文章