Invoice Price Tolerance Check With Claude

What rule did we test?
Two percent of a 14.25 PO price is 0.285, so the limit is 14.535, a figure that falls between two prices in cents. 14.53 is under it and 14.54 is over.
On 5 Nov 2026 we wrote five rules in plain English and Claude Sonnet 5.5 returned a script on its second turn. The 2 percent is our own test policy.
What files does it need?
The check needs the PO lines with their unit prices and the vendor invoices. We also supplied the receipts, and no rule uses them: the first script never opens that file and the second opens it only to print a warning.
| File and column | What the price check does with it |
|---|---|
vendor_invoices.csv: inv_price, inv_qty | The price is read as text first. A negative quantity marks a credit note |
purchase_orders.csv: po_price | The limit is this price times 1.02 |
item, uom on both files | Compared exactly, before the price is looked at |
goods_receipts.csv | Supplied, and not read by any of the five rules |
How do you ask Claude for a plan first?
Attach the three files and paste this. Our data is not public, so your numbers will differ from ours.
I work in accounts payable. Before an invoice is paid I want to check its price, unit and item against the purchase order. I have three files: - purchase_orders.csv (po_no, po_line, vendor_id, vendor, item, description, uom, po_qty, po_price) - goods_receipts.csv (gr_no, po_no, po_line, item, received_qty, gr_date) - vendor_invoices.csv (invoice_no, vendor_id, po_no, po_line, item, inv_qty, inv_price, uom, inv_date) Every line in these files has been received in full and none is invoiced twice, so quantity and duplicates are not part of this job. A credit note has a negative inv_qty. My rules, in order. An invoice gets the first one that fits. 1. Hold an invoice whose item is not the item on its PO line. 2. Hold an invoice whose uom is not the uom on its PO line. 3. Hold an invoice whose inv_price is not a plain number such as 14.20 (for example 14,20). 4. Hold an invoice whose price is more than 2 percent above the PO price. A price of exactly 2 percent above is fine, and so is any lower price. Credit notes skip this rule. 5. Otherwise approve. Do not write code yet. Number the steps, say what could go wrong in each one, and list anything in my rules that is unclear.
Claude wrote nine steps. In the first session it made one point about the price test in step 7: use exact decimals and compare in whole units, because 24 invoices in the file sit at 1.99, 2.00 or 2.01 percent over the PO price and eight are exactly on the limit.
It read the file to find them, with examples such as 510.00 against 500.00. It also said to look at the price as text before turning it into a number, since once 100,00 is converted it cannot be told from a good price.
Its open points, eight in the first session and nine in the second, include what counts as a plain number (is 1500 one?), whether credit notes still go through rules 1 to 3, and what to do with an invoice that has no PO line.
Both sessions asked whether the limit should be rounded to the cent first.
We answered none of them. The first session wrote down its position on each point. The second wrote down two, and did not mention that its script approves a price of zero.
How do you ask Claude to build it?
Good, use that plan. Write one Python script, standard library only, that reads the three files and writes decisions.csv with one row per invoice: invoice_no, po_no, decision (approve or hold), rule (the number, 0 for approve), reason. The reason is one short sentence with the numbers. Use Decimal for prices and do not change my files. Run it, then show me how many invoices were approved and held, with every hold and its reason.
Claude Sonnet 5.5 (claude-sonnet-5-5) ran both prompts on 5 Nov 2026 as two turns. The script is 85 lines of standard library Python with Decimal prices.
It approved 74 invoices and held 26: 6 for item, 6 for unit, 6 for a comma price and 8 for price. It matched our key on all 100, rule number included. A second session wrote a 99-line script and matched all 100. Eight invoices from the file:
| Invoice | PO price | Invoice | Result |
|---|---|---|---|
| VI-6014 | 200.00 | 203.98 (1.99 percent over) | Approve |
| VI-6017 | 200.00 | 204.00 (exactly 2 percent over) | Approve |
| VI-6009 | 1500.00 | 1530.15 (2.01 percent over) | Hold, rule 4 |
| VI-6100 | 500.00 | 510.05 (2.01 percent over) | Hold, rule 4 |
| CN-6029 | 100.00 | 100.00 on a credit note of 2 units | Approve: credit notes skip rule 4 |
| VI-6045 | 100.00 | 100,00 | Hold, rule 3 |
| VI-6006 | 400.00 per EA | Billed per RL | Hold, rule 2 |
| VI-6001 | Item CL-815 | Billed as item PK-220 | Hold, rule 1 |
The first session chose "a plain number" for itself and said so: digits with an optional dot, so 1500 passes and a comma, a currency symbol, a blank or a zero is held.
The second session also limited the decimals to two. Both sessions let credit notes through rules 1 to 3 and skip only rule 4, as the prompt says, and recorded one reason per hold.
Should you build this or buy it?
Build vs Buy: Finance AI Agents in 2026 lists an approval workflow and an audit trail among what you get when you buy. This check was not run through ChatFin.
How do you check Claude's output against a key?
The 100 invoices are made up. Eight sit at 1.99 percent over, eight at exactly 2.00 and eight at 2.01. Eight are cheaper than the PO. Six are credit notes, six carry a comma price, six a different unit and six a different item.
Forty-four are plain: 30 at the PO price and 14 at 1 percent over. PO prices are multiples of 100.00, chosen so that each cutoff lands on a whole number of cents. Claude had three files in its own folder. The key was somewhere else, and neither session opened it.
The key is our reading of the five rules. A match shows the script follows that reading on these invoices.
What happens at the edges of the rule?
We ran 31 small files through each script, 30 with one invoice and one with none. Eight of them:
| What we sent | First script | Second script |
|---|---|---|
| PO price 100.00; invoice 102.00, then 102.01 | Approve; hold | Approve; hold |
| PO price 14.25 (limit 14.535); invoice 14.53, then 14.54 | Approve; hold | Approve; hold |
PO price 0.05; invoice 0.051 (exactly 2 percent) | Approve | Hold under rule 3 |
Invoice price 100.0000 against 100.00 | Approve | Hold under rule 3 |
Invoice price 100.00 with a space at the end | Approve | Hold under rule 3 |
Invoice price 0.00 | Hold under rule 3 | Approve |
| A credit note priced at 150.00 against a PO price of 100.00 | Approve | Approve |
| An invoice for a PO that is not in the file | Hold under rule 1 | Stops, no output |
How does it compare with our own version of the rules?
We generated 3,000 random invoices: six price levels from 90 to 150 percent of the PO, one in nine with a wrong item, one in nine with a wrong unit, about 6 percent with a comma price and one in seven a credit note.
Neither script differed from the reference code that built the key. That code reads rule 3 loosely (it would approve 1e2 or -100.00), and the random prices have two decimals, so the test says nothing about the zero, three-decimal and trailing-space cases in section 2.
What does a policy owner still review?
- How many decimals can a price carry? The second script holds any price that is not one or two decimals, and held a legitimate 0.051.
- Should a credit note priced above the PO still be approved? Both scripts say yes.
- Is a zero price a hold? One script holds it, the other approves it.
- What happens to an invoice with no PO line? No rule says, and the scripts disagree.
- Do you round the limit, or compare the exact figure? Both scripts compared exactly.
Questions about the invoice price tolerance check
What do you need to check invoice prices against a tolerance with Claude?
How well did Claude do on the invoice price tolerance check?
Which Claude model did we test?
Book a demo
Use the message box to tell us your ERP and the process you want to start with.