Accrue Recurring Vendor Invoices With Claude

Summary
You need Vendor invoice history as one CSV file
Tested with Claude Sonnet 5.5, made-up data, 5 Nov 2026
Result 40 of 40 vendors matched the answer key
Three invoice rows for vendor V35 (July 1,500.01, August 1,000.00, September 1,200.00) go into Claude. The accrual comes out in accruals.csv as accrue 1233.34 with a review flag. A note reads 40 of 40 vendors matched the answer key.

What rule did we test?

Eastgate Uniforms billed 1,000.00, 1,250.00 and 1,500.00: the largest is exactly 1.5 times the smallest, so it is not flagged. Tanglewood Translation billed 1,500.01, 1,000.00 and 1,200.00, one cent over, so it goes to review.

Floating point misjudges an exact 1.5: in Python 1.5 times 1.20 comes out as 1.7999999999999998, so a script that compares 1.80 against it flags a vendor billing 1.20 and 1.80.

The rule that flags a vendor for review: the largest of its last three invoices is more than 1.5 times the smallest. On 5 Nov 2026 we wrote five rules as a short list and Claude Sonnet 5.5 returned a script on the second turn.

What files does it need?

Our run used a six-column CSV and was not connected to anything.

Columns the accrual rules read
ColumnWhat it does here
invoice_monthThe month the service belongs to. The three-of-four test counts distinct months in it
amountThe last three amounts are averaged and compared for the 1.5 test
one_timeY removes a vendor from the accrual. The stop rule still reads its rows, so a zero amount on a one-time vendor stops the whole run
vendor_idGroups the invoices and is printed when the stop rule fires
vendor, expense_accountRead by none of the five rules, and not copied to the output

How do you ask Claude for a plan first?

Attach invoice_history.csv and paste this. Our data is not public, so your numbers will differ from ours.

Prompt 1: plan
It is the end of October 2026 and I have to book accruals for the vendors we pay every month whose October invoice has not arrived. I have one file, invoice_history.csv, with the invoices we hold: vendor_id, vendor, expense_account, one_time, invoice_month (the month the service belongs to) and amount. It covers May to September 2026. None of these vendors has sent an October invoice yet.

My rules.
1. Accrue for October only if the vendor sent an invoice in at least 3 of the 4 months June, July, August and September 2026.
2. Never accrue for a vendor with one_time = Y.
3. The accrual is the average of the vendor's last three invoices, rounded to the cent.
4. If the largest of those three invoices is more than 1.5 times the smallest, still accrue the average, but flag the vendor for review.
5. If any invoice amount is zero or negative, stop, print the vendor_id and invoice_month, and write nothing.

Do not write code yet. Give me numbered steps, say what could go wrong in each, and list anything in my rules that is unclear.

Claude wrote nine steps and found the file's two odd vendors before it wrote any code. V39 and V40 each have two invoices in August, and the plan asked whether those are separate charges, a split, or a duplicate.

It said to compare the 1.5 limit in whole cents, as twice the largest against three times the smallest, so that exactly 1.5 and one cent over land on the right sides.

It also noted that a sum of cents divided by three can never end on exactly half a cent, so the rounding mode does not matter here. Its counts were off: it said 29 vendors qualify and 7 fail, which adds to 36 for a 40-vendor file, and the script read all 40.

The open points that change the result: does "last three invoices" mean three invoices or three months? Should V16 (no September invoice) be accrued as if nothing were missing? Are V27 and V30 (a one-time flag on a vendor that bills every month) mistakes in the data?

We answered none of these. Claude took the last three as three invoices and counted a month once toward the three-of-four test, and said so.

How do you ask Claude to build it?

Prompt 2: build and run
Good, use that plan. Write one Python script, standard library only, that reads the file and writes accruals.csv with one row per vendor: vendor_id, decision (accrue or no accrual), accrual_amount (blank when there is no accrual), flag (review or blank), reason. Use Decimal for money and do not change my file. Run it, then show me the total accrual, the vendors flagged for review, and the vendors that got no accrual with the reason.

Claude Sonnet 5.5 (claude-sonnet-5-5) worked through both prompts in two turns on 5 Nov 2026. The script is 159 lines of standard library Python and works in Decimal. It accrued 29 vendors for 78,046.86, flagged 5 of them for review and gave no accrual to 11.

Rule 5, the stop on a zero or negative amount, did not fire on this file. It matched our key on all 40 vendors, amount and flag. A second session, with the same two prompts, wrote a 107-line script and reached the same 78,046.86 and the same 40 matches.

Vendors that exercise the accrual rules
VendorInvoicesResult
V31 Eastgate UniformsJul 1,000.00, Aug 1,250.00, Sep 1,500.00Accrue 1,250.00, no flag: the largest is exactly 1.5 times the smallest
V35 Tanglewood TranslationJul 1,500.01, Aug 1,000.00, Sep 1,200.00Accrue 1,233.34, review: one cent over 1.5 times
V01 Harbor Light CleaningMay 8,101.38, Jun 2,730.31, Jul 6,905.05, Aug 7,895.31, Sep 7,647.51Accrue 7,482.62, no flag: the small June invoice is not one of the last three
V16 Moorside Cloud HostingJun 4,886.84, Jul 5,528.65, Aug 5,201.70Accrue 5,205.73. There is no September invoice at all
V25 Larkfield PrintingMay 2,013.70, Jun 1,795.06, Sep 1,743.94No accrual: three invoices, but only two months inside June to September
V27 Pinecroft ArchiveJun to Sep, 4,598.44 to 5,619.65, one_time = YNo accrual, although it invoices every month
V39 Northcote Security PatrolJul 1,400.00, Aug 1,380.00, Aug 620.00, Sep 1,415.00Accrue 1,138.33, review: two invoices in August
V40 Westmere Records StorageAug 905.00, Aug 910.00, Sep 888.00No accrual: three invoices, two months

Claude flagged V39 and gave an alternative: add the two August invoices into one month and the accrual becomes 1,605.00 with no flag. The second session priced one more: drop the 620.00 as a mistake and it becomes 1,398.33.

V40 would accrue 901.00 if invoices were counted instead of months. Both scripts took three separate invoices and one August. The output is a list of vendors and amounts, and nothing in it posts or reverses. The 29 accrual lines include the 5 flagged for review.

Should you build this or buy it?

ChatFin's agents run on the ERP and version you already have, with no database credentials and no migration, and the vendor takes on the upkeep of connectors, models and controls (Build vs Buy: Finance AI Agents in 2026). ChatFin was not part of this run.

How do you check Claude's output against a key?

The 40 vendors and 137 invoices are made up. The list holds 12 plain vendors, 8 with invoices in exactly 3 of the 4 months, 6 with only 2 (two of those with a May invoice that must not count).

It also holds 4 marked one-time, 4 whose largest invoice is exactly 1.5 times the smallest, 4 that are one cent over, and 2 with two invoices in one month.

Two plain vendors carry a small June invoice that is not among their last three, to catch a script that tests the 1.5 limit on everything. The key was written before the first session started and sat outside Claude's working folder.

The key is our reading of the five rules. A match shows only that the script follows that reading on these vendors.

What happens at the edges of the rule?

We ran 21 small files through each script, each holding one vendor. Two of them test the stop rule, so a stop never sits inside the graded file.

Edge cases for the accrual rules
What we sentFirst scriptSecond script
Jun, Aug and Sep invoices of 100.00 (3 of 4 months)Accrue 100.00Accrue 100.00
Last three invoices of 100.00, 125.00, 150.00; then 150.01No flag; reviewNo flag; review
Last three of 100.00, 100.00, 100.01 (average 100.0033); 100.00, 100.01, 100.01 (100.0067)100.00; 100.01100.00; 100.01
Rows of one vendor out of month order in the fileMonths sorted, average 200.00Months sorted, average 200.00
An October invoice already in the file, with Jul to SepAccrues anyway; October counts as one of the last threeAccrues anyway; October counts as one of the last three
A zero amount, or a credit note of -20.00, as the middle of three invoicesStops, prints vendor and month, writes nothingStops, prints vendor and month, writes nothing
one_time typed yStops, names the lineTreats it as Y, no accrual
Month typed Sep-2026Stops, names the lineLeaves it out of the month count but averages it, no warning

The scripts differ on bad input, and neither checks that the vendor really has no October invoice: with one in the file, both accrue anyway.

How does it compare with our own version of the rules?

We generated 399 random vendors, with up to two invoices a month, May to September, amounts around the 1.5 limit and one-time flags, and compared both scripts with the reference code that built the key.

They agreed on every vendor, amount and flag. The random set has no zero amounts and no bad months, so it says nothing about the stop rule or about bad input.

What does a controller still review?

  • Two invoices in one month: two charges, or one? V39's accrual moves from 1,138.33 to 1,605.00 on that answer.
  • A vendor that stopped billing in September, like V16: accrue it, or find out why September is missing first?
  • One-time vendors that bill every month, like V27 and V30: is the flag right?
  • Credit notes stop the run. Should one stop everything, or only its own vendor?

Questions about accruing recurring vendor invoices

What do you need to accrue recurring vendor invoices with Claude?
Vendor invoice history as one CSV file. Ours covered 40 vendors.
How well did Claude do on accruing recurring vendor invoices?
40 of 40 vendors matched the answer key. A second session wrote a 107-line script and reached the same 78,046.86 and the same 40 matches.
Which Claude model did we test?
Claude Sonnet 5.5 (claude-sonnet-5-5), on made-up data, on 5 Nov 2026.

Book a demo

Use the message box to tell us your ERP and the process you want to start with.

Request a demo