Outstanding and Stale Payments With Claude

- You need
- Payments and bank statement lines as CSV, plus two balances
- Tested with
- Claude Sonnet 5.5, made-up data, 5 Nov 2026, two runs
- Result
- 70 of 70 payments and 6 of 6 balances match our answer key
The rule we tested
Rule 4 of our prompt sets the adjusted bank balance: "Adjusted bank balance = statement closing balance minus the total of the outstanding payments.
Stale payments are treated as void and are not deducted." Rule 5 writes the stale payments back into the book balance.
In our rules a payment is outstanding for 90 days and stale after that. A payment issued on 2 Aug 2026 is 90 days before 31 Oct and is outstanding, and one issued on 1 Aug is stale.
How to match a bank line to a payment is a separate job, and the first rule of the main build is on the payment reconciliation page.
We gave Claude six rules in plain English and two CSV files, with two balances typed into the prompt. Our file has one account, 70 payments and 60 statement lines.
What you need
Two CSV files
You need the list of payments you issued, with the issue date, the amount and the payment ID, and the bank statement lines with the same ID somewhere in the description.
You also need two balances at the close date, from the statement and from the cash book. We used CSV files we generated and did not try the API route.
| Column | Used for |
|---|---|
payment_id | Found in a debit line of the statement. A match means the payment has cleared |
issue_date | Days before 31 Oct. Up to 90 is outstanding, more is stale, after 31 Oct is ignored, or goes to review if the statement already shows the debit |
amount | The totals that move the two balances |
description and amount in the statement | Only debit lines (negative amounts) can clear a payment |
| Two balances | Typed into the prompt |
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 payment register and your bank statement export (we attached ap_payments.csv and bank_statement.csv) and paste this.
Replace the file names, the column names, the close date, the 90 days and both balances with yours. The two balances in our prompt are made up, so type your own. If your export has separate debit and credit columns, say so.
I work in the accounting team. I want a small tool that lists our outstanding and stale payments at month end and works out the adjusted bank and book balances. I have two files: - ap_payments.csv: the payments we issued (payment_id, vendor, issue_date, amount, method). Amounts are positive. - bank_statement.csv: the bank statement lines (line_id, bank_date, description, amount). A debit is negative and a credit is positive. The bank statement closing balance on 31 Oct 2026 is 1,184,620.37. The cash book balance on 31 Oct 2026 is 754,280.71. Our rules: 1. A payment has cleared when a debit line on the statement has its payment_id in the description. Credit lines are ignored. 2. A payment issued on or before 31 Oct 2026 that has not cleared is "outstanding" when it was issued 90 days or fewer before 31 Oct 2026, and "stale" when it was issued more than 90 days before. 3. A payment issued after 31 Oct 2026 is "ignored", because it belongs to November. If it already appears on the statement it is "review" instead. 4. Adjusted bank balance = statement closing balance minus the total of the outstanding payments. Stale payments are treated as void and are not deducted. 5. Adjusted book balance = cash book balance plus the total of the stale payments, because a void payment is written back. 6. Report the difference between the adjusted bank balance and the adjusted book balance. 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.
Both runs read the files first. Both found the three payments that our data dates 1 Nov but that already appear as debits on 30 and 31 Oct, and added up the amount: 51,053.25.
Rules 4 and 5 do not touch them. The statement balance already includes them, so the two adjusted balances do not agree. Should those payments be listed only, or should the book balance be reduced by them?
The first run also found that twelve unpaid payments were issued within a day or two of the 90-day line, so that an off-by-one would move six payments between outstanding and stale.
- The statement has deposits and three interest lines. Rule 1 ignores credits, but if the cash book has not booked them they will sit inside the difference too.
- The rerun saw that all six stale payments are transfers (wire or ACH). Is writing them back right, or are they failed transfers to chase?
- If a debit has the ID but a different amount, is the payment cleared, and which amount goes into the totals?
- A debit dated after the statement date: does it count as cleared at 31 Oct?
- Does the difference run bank minus book or the other way round?
We did not answer these in the run. Both scripts took the plain reading and reported what they chose, for example that a debit of 990.00 against 1,000.00 counts as cleared and that a debit dated 3 Nov counts as cleared.
The first run warned that nothing stops a stale payment clearing in November.
Ask Claude to build it
Good. Use that plan. Write one Python script, standard library only, that reads both files and writes two files. payment_status.csv has one row per payment: payment_id, status (cleared, outstanding, stale, ignored or review), amount. balances.csv has one row per figure: item, amount, with these items in this order: outstanding_total, stale_total, review_total, adjusted_bank_balance, adjusted_book_balance, difference. Use exact decimal arithmetic for money. Never change my files. Run it, then show me every payment that is not "cleared", and the six figures.
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 118 lines and the rerun's is 127. Both use the standard library and Decimal, and both read the whole number after PAY-, so PAY-2001 cannot match inside PAY-20010.
They differ on a lower case ID, an ID inside a longer word and a bad issue date, as the edge table shows. Both gave the same split of the 70 payments: 44 cleared, 13 outstanding, 6 stale, 3 review and 4 ignored.
| Payment | Issued | Days before 31 Oct | Amount | Status |
|---|---|---|---|---|
| PAY-20018 | 2026-08-03 | 89 | 43,812.94 | outstanding |
| PAY-20004 | 2026-08-02 | 90 | 25,506.94 | outstanding |
| PAY-20010 | 2026-08-01 | 91 | 37,824.63 | stale |
| PAY-20019 | 2026-07-31 | 92 | 10,294.84 | stale |
| PAY-20017 | 2026-10-31 | 0 | 33,477.72 | outstanding |
| PAY-20001 | 2026-11-01 | -1 | 25,536.50 | ignored |
| PAY-20024 | 2026-11-01 | -1 | 250.27 | review |
| PAY-20038 | 2026-11-01 | -1 | 22,718.27 | review |
| Step | Amount |
|---|---|
| Statement closing balance, stated in the prompt | 1,184,620.37 |
| Outstanding payments, 13 | minus 333,715.42 |
| Adjusted bank balance | 850,904.95 |
| Cash book balance, stated in the prompt | 754,280.71 |
| Stale payments written back, 6 | plus 147,677.49 |
| Adjusted book balance | 901,958.20 |
| Difference, bank minus book | -51,053.25 |
| Three payments dated 1 Nov already on the statement | 51,053.25 |
The difference is -51,053.25, and the three review payments add up to exactly 51,053.25. Reducing the cash book by those three payments would make the two adjusted balances agree.
We set the cash book balance that way. Neither run adjusted a balance, since our rules did not ask for it.
The script writes two CSV files, payment_status.csv and balances.csv, and the outstanding and stale lists are a filter on payment_status.csv.
How we checked it
1. Plant the answer and keep the key
We built 70 payments and 60 statement lines (47 debits and 13 credits). Three unpaid payments were issued on each of the days 88, 89, 90, 91 and 92 before 31 Oct, four on 31 Oct, four on 1 Nov and three more on 1 Nov that already appear on the statement.
We set the cash book balance so the two adjusted balances differ by exactly those three payments. Our own code wrote the answer key, and the folder Claude worked in held only the two input files. Both runs matched all 70 statuses and all six balance figures.
Made-up data. The vendors, amounts, statement lines and both balances are invented. A match shows the script follows the rules as written.
We do not publish the files or the scripts here, so the figures describe our run and cannot be rebuilt from this page.
2. Try the edges of each rule
We ran 18 small cases through both scripts, each a payments file and a statement file.
| What we sent | What the scripts did |
|---|---|
| Unpaid payments issued 89, 90, 91 and 92 days before 31 Oct | Outstanding, outstanding, stale, stale. Both scripts and ours agree |
| Unpaid, issued 31 Oct; unpaid, issued 1 Nov; issued 1 Nov and already debited | Outstanding; ignored; review |
| A credit line that carries the payment ID; a statement exported with debits as positive numbers | The payment stays outstanding in both. Only a debit clears a payment |
| A debit of 990.00 against a payment of 1,000.00; two debit lines for one payment | Cleared both times. Both scripts print a warning on the mismatch |
| A debit dated 3 Nov, after the statement date, that names a payment | Cleared in both. The rules have no date test on the statement line |
The ID typed in lower case on the statement, pay-20001 | First run: still outstanding. Rerun: cleared |
| A debit that names a payment not in the file; a statement with no lines; a file with no payments | The unknown ID is ignored with a warning. An empty statement leaves every payment outstanding or stale. No payments give two balances unchanged |
The ID inside a longer word on the statement, NOTPAY-20001 | First run: still outstanding. Rerun: cleared, as our own version does |
A negative payment amount (-300.00); an amount typed "1,000.00" in quotes | Both took the negative amount as outstanding and added 300.00 to the adjusted bank balance. Both read the quoted amount as 1,000.00 |
The same payment ID twice; an issue date typed 10/10/2026 | Both stopped on the duplicate ID with a message, while our own version did not stop. On the bad date the first run printed a message and the rerun crashed with a Python error |
Neither says anything about a negative payment amount that raised the adjusted bank balance, although the rerun's plan said a minus sign should stop the run.
3. Compare it with our own version of the rules
We made 20 random sets of 400 payments with a matching statement, issue dates from 130 days before the close to 5 days after it, and 80 credit lines in each.
Both scripts matched it on all 8,000 statuses and all 120 balance figures. The random sets hold no lower case IDs, no duplicates and no IDs inside longer words.
What ChatFin's build or buy page says
ChatFin's agents keep an audit trail from prompt to prepared payload on every action, 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 rule through ChatFin.