ChatFin/Build Payment Reconciliation with Claude

How to build payment reconciliation using Claude

By Ashok ManthenaPublished 5 Nov 202611 min read
Three rows of ap_payments.csv (PAY-7701, PAY-7723, PAY-7727) go into Claude. The same three payments come out in rec_status.csv: PAY-7701 cleared, PAY-7723 stale, PAY-7727 amount mismatch. A note reads 37 of 37 graded items matched our reference answers.
You need
AP payments and the bank statement as two CSV files, plus two balances typed into the prompt
Tested with
Claude Sonnet 5.5, made-up data, 5 Nov 2026
Result
37 of 37 graded items matched our reference answers

Before you start

The bank statement says one thing and the cash book says another, and the gap is made of checks still in the post, a bank fee nobody booked, a payment that bounced and one that went out twice.

Finding which is which is a matching job with a few rules. It is the kind of job that ends up in a spreadsheet or on a developer's list. On 5 Nov 2026 we wrote the nine rules in plain English and Claude wrote the script in one sitting.

Our file is one account for one month: 31 payments and 29 bank lines. The rules in the prompt cover one account in one currency and one description format.

One bank line paying several invoices, a check that clears months late and many accounts in many currencies would each be another rule to teach the program.

Our view is that mid size and large companies should not build and maintain this.

The two balances are typed into the script, the matching depends on how the bank words its descriptions, and when the difference does not tie, someone has to find out why. For the trade-off, read Build vs Buy: Finance AI Agents in 2026.

What you need

An ERP connection

You need the payments you issued with their IDs, methods, check numbers, amounts and dates, plus the bank statement lines, plus two balances: the statement closing balance and your cash book balance on the same date.

Check how your bank and ERP export these, and what their API terms allow before you pull them live.

Our script reads two CSV files and writes one. It posts nothing.

The data points

Columns in ap_payments.csv and bank_statement.csv
ColumnUsed for
payment_id, method, check_noThe match to a bank line. Keep check numbers as text
amount, issue_dateThe comparison with the bank, the 31 Oct cut-off and the 90 day test
line_id, date, descriptionWhat the match is made on. The amount is never used to find the match
amount on the bank fileNegative for money leaving the bank
Closing balance and cash book balanceTyped into the prompt. Not in the files

A plan, broken into steps

Attach ap_payments.csv and bank_statement.csv and paste this.

Prompt 1: plan
I work in the accounting team. I want a small tool that reconciles the vendor payments we issued in October to our bank statement.

I have two files:
- ap_payments.csv: one row per payment we issued (payment_id, vendor, method, check_no, amount, issue_date). Amounts are positive. method is CHECK, ACH or WIRE. check_no is filled only for checks.
- bank_statement.csv: the October bank statement (line_id, date, description, amount). Money leaving the bank is negative.

The statement closing balance is 205,432.18. Our cash book balance for this account is 173,838.42. The statement date is 31 Oct 2026. Our policy:
1. A bank debit matches a payment when the payment_id, or the words "CHECK" and the check_no, appear in its description. Match on that and not on the amount.
2. A payment issued after 31 Oct 2026 is ignored.
3. A payment whose matching debit has the same amount is "cleared".
4. A payment whose matching debit has a different amount is an "amount mismatch".
5. A payment with no matching debit is "outstanding", or "stale" if it was issued more than 90 days before 31 Oct 2026.
6. A bank credit whose description starts with RETURN and names a payment_id marks that payment as "returned". The credit line is a "returned payment". The payment is then "returned" and not "cleared".
7. If a payment has more than one matching debit, the first by date is its clearing and every later one is a "duplicate clearing".
8. A bank debit whose description starts with FEE is a "bank charge". Any other debit that matches no payment is "unidentified".
9. Adjusted bank balance = statement closing balance minus the outstanding and stale payments. Adjusted book balance = cash book balance minus bank charges plus returned payments. Mismatches, duplicate clearings and unidentified debits are not adjusted. They stay as the unreconciled difference, which is the adjusted bank balance minus the adjusted book balance.
Apply the rules in the order above, and give each payment and each bank line one status.

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

Rule 6's last sentence is there because rules 3 and 6 conflict without it: a payment that bounced has already been called cleared. Claude's plan still raised it as its first open point.

Claude gave steps for loading, matching, duplicates, comparing amounts, stale payments, returns, other bank lines and the balances, and said what could go wrong in each.

Three warnings were specific to this data. The file repeats amounts (2,290.00 four times, 15,400.00 three times), so matching on amount would pair the wrong lines.

A check number such as 10481 could sit inside a longer number, so the match has to be on whole numbers. And a returned payment also has a debit of the right amount, which is why rule 3 alone would call it cleared.

It worked the October data through by hand before writing code and got a difference of -9,056.64, then showed that this equals the sum of the items rule 9 leaves unadjusted.

That tie-out was also the check on the finished script. It then listed ten open points. The ones that matter most:

  • What a normal matched debit is called, and the debit of a returned payment. The policy has no word for either.
  • Whether a stale payment should only be labelled or also voided. Rule 9 deducts it like any outstanding item.
  • What to do with a credit that is not a RETURN, or a RETURN that names no payment.

Settle before relying on it. We did not answer them. We told Claude to use its plan, and it used its own default for each. Your controller decides all ten.

Ask Claude to build it

Prompt 2: build and run
Good. Use that plan. Write one Python script, standard library only, that reads both files and writes rec_status.csv with one row per payment and one row per bank line: item (payment_id or line_id), kind (payment or bank line), status. Use exact decimal arithmetic for money. Never change my files. Run it, then show me how many items are in each status, every item that is not "cleared", and the two adjusted balances with the unreconciled difference.

Claude Sonnet 5.5 (claude-sonnet-5-5) ran both prompts on 5 Nov 2026. The first run took the prompts one at a time, as two turns. The script is 234 lines of Python, standard library only, with money as Decimal.

It wrote 60 rows, one for each of the 31 payments and the 29 bank lines. Nineteen payments cleared. Here are the other 12, plus the bank lines that are not a plain clear:

Items that did not clear
ItemsStatusWhat the script saw
PAY-7719 to PAY-7722, PAY-7725OutstandingFour payments issued 27 to 31 Oct and PAY-7725, issued 2 Aug, exactly 90 days before the statement date.
PAY-7723, PAY-7724StaleIssued 20 Jul and 1 Aug, 103 and 91 days before 31 Oct.
PAY-7726IgnoredIssued 2 Nov, after the statement date.
PAY-7727, PAY-7728Amount mismatchThe bank paid 1,209.00 against 1,290.00 issued, and 2,775.00 against 2,750.00.
PAY-7730, PAY-7731ReturnedBoth cleared, then the bank credited them back (NSF, account closed).
BK-025Duplicate clearingCheck 10492 was debited twice, 8,800.00 each time.
BK-018UnidentifiedA point-of-sale debit of 312.64 that names no payment.
BK-028, BK-029Bank chargeFees of 45.00 and 35.00.

The balances came out as follows. The difference is made of the two amount mismatches (net +56.00), the duplicate clearing (-8,800.00) and the unidentified debit (-312.64), and the script printed that check on screen.

Adjusted balances
LineAmount
Statement closing balance205,432.18
Less outstanding and stale payments (7)38,240.40
Adjusted bank balance167,191.78
Cash book balance173,838.42
Less bank charges80.00
Plus returned payments2,490.00
Adjusted book balance176,248.42
Unreconciled difference (bank minus book)-9,056.64

The closing balance and the cash book balance are typed into the script as constants, so next month someone changes them. The script cannot check the closing balance against the lines, because the statement file has no opening balance.

Where to run it

The people who need the result are whoever chases the open items and whoever signs off. They need to see the open items carry forward, tick off what cleared, and keep the signed result. A hosting service such as Vercel is one option. Nothing here was hosted.

If you would rather buy it

ChatFin's build or buy page says it runs on the ERP and version you already have and writes back only drafts a person approves through the official API.

We did not run this policy through ChatFin. ChatFin also has pages titled AI Payment Reconciliation: POS, PSP, Bank to ERP and Build an AI Agent for Bank Reconciliation.

Test it before you trust it

1. Plant the answer and keep the key

We built the data so every status appears, with a payment at exactly 90 days, a payment on 31 Oct, a check cleared twice one transposed amount and one keying error.

Our reference code produced the expected status for each of the 31 payments and for the six bank lines the policy names, and the key was not in Claude's folder.

All 37 matched. A second run, in a fresh session with the same two prompts answered in order, wrote a 232-line script that matched too.

The two scripts called the debit of a returned payment by different names ("cleared, payment later returned" and "returned"), because the policy has no word for it.

Made-up data. The key comes from our own reading of the policy, and we built the data to hit its edges. A match shows the script follows the written rules on these lines. It says nothing about your bank.

2. Try the edges of each rule

We ran 28 small files through the first script. The eleven rows show 23 of them. The other five are a plain match by payment ID, a debit that matches nothing, an empty statement, a credit that names a payment, and a 1 Nov payment with a debit of a different amount.

Edge case results
What we sentWhat the script did
A payment issued 90 days, then 91 days, before 31 Oct, with no bank lineOutstanding; stale
Issued 31 Oct; issued 1 NovOutstanding; ignored. A 1 Nov payment that already has a debit is ignored and its bank line is labelled "review"
A check matched by CHECK 20001; by CHQ 20001Cleared; not matched. The payment stays outstanding and the debit is unidentified
PAY-1 and PAY-10, with a debit that names PAY-10Only PAY-10 clears. The match is on whole IDs
A debit one cent off the paymentAmount mismatch on both the payment and the line
Two debits for one payment, in either order in the file, or on the same dateThe earliest clears. The later one is a duplicate clearing
A RETURN credit for a cleared payment; the word typed in lower casePayment returned, original debit labelled "cleared, payment later returned", credit labelled "returned payment"
A RETURN credit with no original debit; one naming a payment that does not exist; a credit that is not a RETURNThe credit is labelled "review" for the first two and "unclassified credit" for the third. The credit is not added back to the book balance
A FEE debit, typed in upper or lower case; a FEE line that also names a payment IDBank charge; for the second the payment match wins and it shows as an amount mismatch
A repeated payment_id; a check with no check numberStopped with a message. No output file
An amount typed 1,000.00Accepted. The script strips the comma

Every boundary the policy states came out as written. The behaviour to take to your controller is the rule order: a FEE line that names a payment is matched to the payment first, because rule 1 comes before rule 8.

3. Compare it with a second implementation

We wrote our own version of the rules and made 2,000 random payments with 2,027 bank lines: clean clears, amounts off by 1 cent, 10.00 or 25.00, double debits, returns, fees and stray card debits, and checks whose bank text carries extra words after the number.

Claude's script gave the same status on every payment and every line the policy names. The mix was 1,181 cleared, 213 amount mismatches, 292 outstanding, 102 stale, 49 ignored and 163 returned.

The generator and seed are in the edge folder. Our version is ours, and it is also what produced the key in test 1, so the two tests share one reading. The match shows the readings agree, and both could be wrong.

4. Take the gaps to your controller

What to call a cleared debit of a returned payment, what to do with stale checks in the books, how to treat other credits, and where the two balances come from each month. Add your answers to the prompt and run the same files again.

Where ChatFin fits

The script shows how far two files and nine rules get you in a sitting. Around it you still need the bank feed and the ERP feed, a screen where the accountant clears items, and a person to change the rules when a bank changes how it writes descriptions.

ChatFin's build or buy page says the vendor, not your backlog, keeps connectors, models and controls working (Build vs Buy: Finance AI Agents in 2026).