Why LLM 3-Way Invoice Matching Double-Counts Short Deliveries (And the Excel Formula That Fixes It) A developer built a deterministic 3-way invoice matching method that fixes two common LLM arithmetic failures: price variance computed on invoiced quantity instead of received quantity, which double-counts short deliveries, and parsers treating unsigned vendor packing slips as accepted inventory. On a synthetic case (PO-7416, GRN 9906, Invoice BX-118, $1,224.00 billed), the corrected split reconciles to $0.00 across supported, short-delivery, price-variance and freight-cap buckets. The developer published a four-sheet Excel workbook with a Buyer-Signed? SUMIFS gate and a generator script on GitHub. 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. Suppose a line item has: Q p at PO unit price P p Q r 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. 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. 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 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 | 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 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.