Find Duplicate Expense Claims With Claude

Summary
You need One CSV of expense lines
Tested with Claude Sonnet 5.5, made-up data, 5 Nov 2026
Result 100 of 100 lines matched the answer key
Three rows of expense_lines.csv (EX-7094, EX-7096 and EX-7100, each 63.25 from Fern Books) go into Claude. The same three claims come out in decisions.csv: EX-7094 approved, EX-7096 and EX-7100 rejected under rule 1. A note reads 100 of 100 lines matched the answer key.

What rule did we test?

Our prompt has four rules: reject a line that repeats an earlier line (same employee, merchant, amount and expense date), return a line whose currency is not USD, return a line over 25.00 that has no receipt, otherwise approve.

Rule 1 sits above rule 2, so the second copy of a euro claim filed twice is rejected as a repeat (the second copies are EX-7057 and EX-7058 in our file).

We ran the rules in the order given and did not run the swapped order. The key rejects 13 lines as repeats. Two claims in the file were re-filed after a return (EX-7010 and EX-7019 is one of them). Different employees at the same merchant count as separate claims.

What files does it need?

Our script compares lines inside one file, so a claim paid last month and filed again today would go through. Closing that gap takes the paid history from your expense tool or ERP.

Columns the repeat rule reads
ColumnWhere the rules use it
employee_id, merchant, amount, expense_dateAll four must agree for rule 1 to fire
claim_idThe lower number is the earlier line
currency, receiptRules 2 and 3
descriptionLeft out of the match on purpose

How do you ask Claude for a plan first?

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

Prompt 1: plan
Our expense team keeps paying the same claim twice. I have a file, expense_lines.csv, with one row per expense line: claim_id, employee_id, employee, expense_date, merchant, description, amount, currency and receipt (Y or N). I want a tool that finds the repeats before we pay.

Rules. A line gets the first rule it breaks.
1. Reject a line that repeats an earlier line: same employee, same merchant, same amount and same expense_date. Claim ids go up in the order claims were filed, so the lower claim_id is the earlier line.
2. Return a line if its currency is not USD.
3. Return a line over 25.00 that has no receipt.
4. Otherwise approve.

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

Before any code, Claude named 13 lines it expected to be rejected as repeats, by claim id.

Our key has the same 13. It noticed that the file is not in claim order (EX-7068 sits above EX-7028, and EX-7067 above EX-7045), so reading top to bottom would reject the wrong member of each pair.

It found two merchants typed with a different case, one of them with a trailing space. Its list of ten open points includes two claims that went through a return and a refile. Take EX-7010, a 62.00 line with no receipt, so rule 3 returns it.

EX-7019 is the same claim filed again with the receipt. Read literally, rule 1 rejects the corrected line and leaves the original stuck in "returned". Claude asked whether a returned line should still count as the earlier line.

We did not answer whether a returned line counts as the earlier line. The rule says "an earlier line", and Claude kept it literal. Claude also said it would put currency in the match. We replied "go with that plan", and the script left currency out.

How do you ask Claude to build it?

Prompt 2: build and run
Good, go with that plan. Write one Python script, standard library only, that reads the file and writes decisions.csv with one row per line: claim_id, decision (approve, return or reject), rule (the number, 0 for approve), reason. Use Decimal for amounts and do not change my file. Run it, then show me how many lines got each decision and every line that was not approved.

On 5 Nov 2026 Claude Sonnet 5.5 (claude-sonnet-5-5) answered the plan prompt and then the build prompt. The script is 121 lines of standard library Python with Decimal amounts.

It approved 75 lines, returned 12 and rejected 13, and matched our key on all 100. A second session with the same prompts wrote a different script and also matched on all 100.

Repeat rule rows from the 100-line file
LinesWhat they areDecision
EX-7094, EX-7096, EX-7100Zoe Adeyemi, Fern Books, 63.25, 9 Oct, filed three timesFirst approved, the other two rejected under rule 1
EX-7053, EX-7083Pavel Novak and Sana Qureshi, each with a 21.00 coffee at Blue Kettle on 12 OctBoth approved: two people
EX-7042, EX-7043Merchant typed Blue Kettle and BLUE KETTLE, 29.90Second rejected
EX-7025, EX-7075Merchant typed Metro Cab and metro cab with a trailing space, 52.10Second rejected
EX-7001, EX-7082Pavel Novak, the same cab at 44.00 on 19 Oct and 20 OctBoth approved: the dates differ
EX-7063, EX-7081Eli Brandt, Taxi to client and Cab to client site, 38.60Second rejected: description is not in the rule
EX-7013, EX-7058Lucas Meyer, a 40.00 EUR train ticket filed twiceFirst returned under rule 2, second rejected under rule 1
EX-7010, EX-7019Maya Costa, a 62.00 training manual, first without a receipt, then with oneFirst returned under rule 3, second rejected under rule 1

Claude's script rejected EX-7019, and it said so in its reply: the corrected claim is rejected and the original stays returned, and the repeat check "should skip originals that were returned" if you want the other outcome.

What if only an approved line counts as the earlier one?

We worked out the other reading with a short script of our own, not with Claude: a line counts as the earlier line only if it was approved.

EX-7019 and EX-7026, the two corrected claims with receipts, become approved. EX-7057 and EX-7058, the second copies of the euro claims, stop being rejected and are returned for their currency, so the employee gets two returns for what is one claim.

The reason column in both scripts names the earlier claim ("Repeats EX-7010" in one, "Repeats earlier line EX-7010" in the other).

Should you build this or buy it?

ChatFin's agents read through feeds and write back only drafts a person approves through the official API, and the vendor takes on the upkeep of connectors, models and controls (Build vs Buy: Finance AI Agents in 2026). ChatFin did not run this rule.

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

The 100 lines hold 16 planted groups, from eight made-up employees. They include exact repeats (one filed three times), different employees at the same merchant, merchant names typed in another case, euro claims filed twice and dates one day apart.

The rest are a changed description, claims returned and then re-filed with a receipt, and two pairs where the later claim id comes first in the file.

The key was kept outside Claude's folder. A repeat counts whatever happened to the earlier line, and merchants match without regard to capitals or end spaces.

The prompt says only "same merchant". Read literally, EX-7043 and EX-7075 would be different merchants and both would be approved. The counts would then be 77 approved, 12 returned and 11 rejected.

What happens at the edges of the rule?

We ran 23 one-case files through each script.

Edge cases for the repeat rule
What we sentFirst scriptSecond script
Claim ids EX-9 and EX-10, same lineEX-10 rejectedEX-10 rejected
EX-0002 first in the file, EX-0001 secondEX-0002 rejected, EX-0001 approvedEX-0002 rejected, EX-0001 approved
Merchant Shop and Shop LtdBoth approvedBoth approved
The same line in EUR, then in USDFirst returned, second rejectedFirst returned, second rejected
Currency typed usdStops, names the rowApproves it
Receipt typed YesStops, names the rowApproves it
Amount typed 1,000.00Stops, names the rowStops with a Python traceback
The same claim id on two linesStops, names the rowIdentical lines: approves the first, rejects the second. Different lines: approves both

Both scripts agree on every repeat case with distinct claim ids. On bad input one script stops and names the row, and the other approves a lower-case currency, a receipt flag typed Yes and a date in day-first order, and it crashes on a comma in an amount.

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

We generated 3,000 random lines from ten employees, four merchants (one of them typed in three ways), three days, four amounts, two currencies and a random receipt flag, and compared both scripts with the reference code that built the key.

They agreed on every line, case and spacing differences included. This adds volume and odd combinations, and it shares the key's reading of the rules.

What does a policy owner still review?

  • Does a returned line count as the earlier line? The answer changes four decisions in this file.
  • Is currency part of the match? Neither script includes it, so 36.00 in EUR and 36.00 in USD from one person on one day are a repeat.
  • Pavel Novak's cab at 44.00 on 19 Oct and 20 Oct, and Sana Qureshi's 16.20 coffee on 20 and 21 Oct, both pass. Do you want lines one day apart on a review list?

Questions about duplicate expense claims

What do you need to find duplicate expense claims with Claude?
One CSV of expense lines. Our script compares lines inside one file, so a claim paid last month and filed again today would go through.
How well did Claude do on duplicate expense claims?
100 of 100 lines matched the answer key.
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