ChatFin/Credit Holds and Disputed Invoices With Claude

Credit Holds and Disputed Invoices With Claude

By Ashok ManthenaPublished 5 Nov 20269 min read
Two open invoices for customer C12 from open_invoices.csv, 19000.00 disputed and 22000.00 not, go into a box labelled Claude Sonnet 5.5. collections.csv comes out with C12: past due 41000.00, action call, credit hold Y. The caption reads 20 of 20 customers match the answer key.
You need
Open invoices, credit limits and payment history as CSV
Tested with
Claude Sonnet 5.5, made-up data, 5 Nov 2026, two runs
Result
80 of 80 fields match our answer key in each of two runs

The rule we tested

A customer owes 41,000.00 past due against a limit of 40,000.00, and 19,000.00 of that sits in an invoice under dispute.

Our prompt treats disputed invoices two ways: the action comes from "its oldest past due invoice that is not disputed", while the hold counts "all its past due open amounts, disputed or not".

We also asked for a slow payer flag, which looks at a customer's six most recent payments.

Four rules in plain English and three CSV files produced a script after a plan turn and a build turn. Our file has 20 customers, one credit limit for all of them and 100 open invoices.

What you need

Three CSV files

You need three things: open invoices with a due date, an amount and a dispute flag, the credit limit for each customer, and the history of paid invoices with their due and paid dates. We used three CSV files we generated and did not try an API.

Columns in open_invoices.csv, customers.csv and payment_history.csv
ColumnUsed for
due_date and disputedThe action. A disputed invoice is skipped when picking the oldest one
open_amountThe past due total for the hold. Disputed amounts are included
credit_limitThe hold test. A total equal to the limit is not a hold
due_date and paid_date in the historyThe slow payer test, on the six most recent payments

Prompt 1: ask for a plan

Use Claude with file access and code execution, as we did, and keep both prompts in one conversation. Give it your open invoices, customer limits and payment history (we attached open_invoices.csv, customers.csv and payment_history.csv) and paste this.

Replace the file names, the column names and the report date with yours. If your export has no dispute column, add one first.

Prompt 1: plan
I work in the accounts receivable team. I want a small tool that tells our collectors, at month end, what to do about each customer: which action to take, whether to put the customer on credit hold, and whether it is a slow payer.

I have three files:
- open_invoices.csv: invoice_no, customer_id, customer, invoice_date, due_date, open_amount, disputed (Y or N).
- customers.csv: customer_id, customer, credit_limit.
- payment_history.csv: customer_id, invoice_no, due_date, paid_date for invoices already paid.

The report date is 31 Oct 2026. Our rules:
1. An invoice is past due when the report date minus its due_date is more than 0 days.
2. The collection action for a customer comes from its oldest past due invoice that is not disputed: 1 to 15 days past due is "email", 16 to 45 is "call", 46 to 90 is "letter", over 90 is "legal review". A customer with no such invoice gets "none".
3. A customer is on credit hold when the total of all its past due open amounts, disputed or not, is more than its credit_limit.
4. A customer is a slow payer when at least 3 of its six most recent payments (by paid_date) were paid more than 15 days after the due date. A customer with fewer than six payments is judged on the ones it has.

Do not write code yet. Break the job into numbered steps. For each step say what could go wrong. Then list anything in the rules that is unclear.

The first run gave nine steps and the rerun seven. Both opened the three files before they wrote the plan, and both caught the customers our data puts on the edge: C09 at exactly 40,000.00 past due, C10 at 40,000.01, C13 at 39,999.99.

C07's only past due invoice is disputed and 120 days old, so the action is "none". C08 gets "email" while a disputed invoice of 130 days sits beside it. Is that intended, or should a disputed invoice raise its own flag?

  • The rerun noted that an invoice of 12 dollars at 100 days sends the whole customer to "legal review". Is there a minimum amount?
  • The hold counts past due amounts only, so a customer with 80,000.00 open and 30,000.00 past due is not held on a limit of 40,000.00. Is that meant?
  • Our payment history ends on 22 Jul, so for some customers "most recent" means payments from months ago. The rerun asked whether old payments should age out.
  • A customer with fewer than six payments needs the same three late ones. The first run asked whether a share would be fairer, and whether a customer with no payments (C19) is "not slow" or "no history".
  • Every customer in our file has the same limit of 40,000.00. The first run asked whether that is real or a placeholder. It is a placeholder.

We did not answer these in the run. The bands (1 to 15, 16 to 45, 46 to 90, over 90 days), the 15 days and the 3 of 6 are our test values.

Ask Claude to build it

Prompt 2: build and run
Good. Use that plan. Write one Python script, standard library only, that reads the three files and writes collections.csv with one row per customer: customer_id, past_due_total, action, credit_hold (Y or N), slow_payer (Y or N). Use exact decimal arithmetic for money. Never change my files. Run it, then show me every customer whose action is not "none", or who is on credit hold, or who is a slow payer.

Claude Sonnet 5.5 (claude-sonnet-5-5) ran both prompts on 5 Nov 2026, one turn at a time, and every reply in both runs came from that model. The first script is 97 lines and the rerun's is 176.

Both use the standard library and Decimal, and both named the script collections_report.py. The rerun explained why: a file called collections.py would shadow a Python module.

Both gave the same answer: 17 of 20 customers have an action, a hold or a slow payer flag, three are on credit hold (C10, C11, C12) and one is a slow payer (C18).

Eight customers from the collections run
CustomerPast dueLimitActionHoldSlowWhy it is here
C074,602.0640,000.00noneNNIts only past due invoice, 120 days, is disputed
C085,590.1340,000.00emailNNA disputed invoice at 130 days, an undisputed one at 10 days
C0940,000.0040,000.00callNNPast due is exactly the limit
C1040,000.0140,000.00callYNPast due is the limit plus 0.01
C1241,000.0040,000.00callYNA disputed 19,000.00 pushes 22,000.00 over the limit
C143,964.2740,000.00emailNNThree payments exactly 15 days late
C162,534.2940,000.00emailNNThree payments 20 days late, one of them in its last six
C186,289.9340,000.00emailNYThree late payments out of the four it has

C12's undisputed past due invoices total 22,000.00, which is under the limit. The disputed 19,000.00 takes it to 41,000.00. C16 has three payments 20 days late and is not a slow payer, because only one of the three falls in its last six.

Our file has no reason column for a hold, so ask for one in the prompt.

How we checked it

1. Plant the answer and keep the key

We built 100 invoices for 20 customers (C01 to C20 in our sample files), 15 of them disputed, and 150 paid invoices. Three customers sit on the limit or a cent either side of it, one is far over it and one goes over only because of a dispute.

We built five customers to test the slow payer window. Three did what we planned: C14 has three payments exactly 15 days late and is not slow, C17 has two late in the last six with a third just outside it, and C18 has only four payments, three of them late.

C15 and C16 missed their plan because of the order of the paid dates.

C15 has two 16-day payments in its last six, so it is not slow, and C16 has one of its three 20-day payments in its last six. The key is right for both under the rule, and the 16 day boundary is one of the 29 single-customer cases in section 2.

Our own code wrote the answer key, and the folder Claude worked in held only the three input files. Both runs matched all 80 fields: the past due total, the action, the hold and the slow payer flag for each of the 20 customers.

We do not publish the files or the scripts here.

2. Try the edges of each rule

We ran 29 single-customer cases through both scripts, shown below in eleven rows.

Edge case results
What we sentWhat the scripts did
An undisputed invoice 0, 1, 15, 16, 45, 46, 90 and 91 days past due"none", "email", "email", "call", "call", "letter", "letter", "legal review"
A disputed invoice at 120 days alone; the same at 130 days beside an undisputed one at 10 days"none"; "email"
Past due of exactly the limit (10,000.00); the limit plus 0.01No hold; hold
A disputed invoice that carries past due over the limit; not-yet-due invoices that alone exceed itHold; no hold
A credit memo (-500.00) as the oldest past due lineIt sets the action: "letter". The rule says nothing about credit memos
Three of six payments 16 days late; exactly 15; three late but all older than the last sixSlow; not slow; not slow
Two payments, both 40 days late; three payments in all, all 16 days late; no paymentsNot slow; slow; not slow
Two payments with the same paid date at the edge of the last six, one late and one on timeThe first run said slow or not slow depending on the order of the rows. Our own reference changed with the order too. The rerun said not slow in both orders, because on a tie it keeps the payment that was paid less late
disputed typed yesFirst run treated it as not disputed and set an action. The rerun stopped with a message
An amount typed 1,000.00; a blank credit limit; a due date typed 01/10/2026First run stopped with a Python error. The rerun stopped with a message naming the line
An invoice for a customer not in the customer file; the same invoice number twiceBoth stopped on the first. On the second the first run added both lines and the rerun stopped

3. Compare it with our own version of the rules

We made 20 random sets of 250 customers, 2,500 open invoices and about 4,000 paid invoices each, with 12 percent of the invoices disputed and none sharing a paid date.

Both scripts agreed with it on the action, the hold and the slow payer flag for all 5,000 customer rows. The past due totals were not compared in this test.

4. Take the gaps to your head of credit

  1. Which payment counts when two share a paid date at the edge of the last six?
  2. Does a credit memo count as the oldest past due line for the action?

What ChatFin's build or buy page says

ChatFin's agents read through feeds and write back only drafts a person approves, and the buy side lists an approval workflow (Build vs Buy: Finance AI Agents in 2026, read on 3 Nov 2026). We did not run this policy through ChatFin.