How to build intercompany reconciliation using Claude

- You need
- Intercompany ledger entries and FX rates, as two CSV files
- Tested with
- Claude Sonnet 5.5, made-up data, 3 Nov 2026
- Result
- 22 of 22 intercompany references matched the answer key
Before you start
Before consolidation, someone has to prove that what one entity says it is owed matches what the other says it owes. Often that is a spreadsheet with a column per entity.
Writing a program for it used to be a project. On 3 Nov 2026 we gave Claude eight rules and two files, and it wrote the program in one session.
Three entities make three pairs of entities. Ten entities can make up to forty five. Each pair has its own currencies and its own habits, and each entity books on its own day.
Our test has 43 entries on 22 references in dollars, pounds and euros, and the rules already collide: what is a late entry that is also the wrong amount? Real groups add intercompany loans, dividends, netting and different rates for the balance sheet and the income statement.
At group scale we would not maintain this ourselves. Intercompany runs on exceptions, and the exceptions decide how the application changes: the charge booked to the wrong entity, the invoice booked twice, the entity that closes two days late.
Each is a rule that somebody has to write and keep consistent with the rest.
Building it took one session. We expect keeping it right to take longer: a new entity, a new currency, a change in the booking calendar, and the tests run again. We did not test the upkeep. For the build or buy trade-off, read Build vs Buy: Finance AI Agents in 2026.
What you need
An ERP connection
You need the intercompany entries from every entity's ledger, with a reference that both sides share, and the exchange rates.
If each entity is a separate ledger or a separate ERP, that is one connection per ledger, and the shared reference is something your team has to enforce when people book.
Our file had it. A real file may not, and the matching then rests on amounts and dates, which is risky when two refs carry the same amount, as DE-0012 and DE-0013 do in our file.
If your ERPs have mature, documented REST APIs for the ledger and for rates you can build the reads. Check each API's terms before you connect an AI tool to it.
ChatFin's build or buy page says ChatFin runs on the ERP and version you already have and reads through governed feeds. Our script used CSV files and posts nothing.
The data points
| File | Columns |
|---|---|
| Intercompany ledger | entity, doc_no, counterparty, doc_date, counterparty_ref, currency, amount, description |
| Exchange rates | currency, usd_per_unit, rate_date |
A receivable is a positive amount and a payable is negative. Every entry in the test file is converted at the closing rate for 31 Oct 2026, whatever day it was booked.
A plan, broken into steps
Attach ic_ledger.csv and fx_rates.csv and paste this.
I work in the group accounting team. I want a small tool that reconciles our intercompany entries before consolidation. I have two files: - ic_ledger.csv: the intercompany entries of three entities, US, UK and DE (entity, doc_no, counterparty, doc_date, counterparty_ref, currency, amount, description). A receivable is a positive amount and a payable is negative. - fx_rates.csv: the rates at 31 Oct 2026 (currency, usd_per_unit, rate_date). Our rules: 1. Two entries are a pair when they have the same counterparty_ref, each entry names the other's entity as its counterparty, and one is positive and the other negative. 2. Compare each pair in USD using fx_rates.csv. A pair agrees if the USD values differ by 1.00 or less. 3. A pair that differs by more than 1.00 is an amount break. Report the difference in USD. 4. An entry with no partner is a missing entry. Say which entity has not booked its side. 5. An entry dated after 31 Oct 2026 is a timing item, not a break, if its partner is dated on or before 31 Oct 2026. 6. Two entries with the same counterparty_ref whose entity and counterparty fields do not point at each other are a wrong entity. 7. Two entries on the same side with the same counterparty_ref are a duplicate. Two entries with the same sign are a sign error. 8. Eliminate only the pairs that agree, and report the elimination total in USD. 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.
Claude answered with eight steps, from reading the files to writing one row per reference, and said what could go wrong at each.
It saw that one reference can break several rules at once and that the order of the checks decides the label. It also saw that the file has the same amount on two different references, so matching on amount would pair the wrong entries.
It then listed ten places where the rules are silent. Three could change a result on other data:
- Rounding. It converted each entry to USD, rounded to the cent, and then compared.
- A late entry whose amount is also wrong. It called that an amount break and kept timing for pairs whose amounts agree.
- The order when rules overlap: duplicate first, then wrong entity, sign error, missing entry, timing, amount break and agree.
Open for your group controller. We did not answer them. We told Claude to use its plan and it applied its own reading of each. Your group controller settles them.
Ask Claude to build it
Good. Use that plan. Write one Python script, standard library only, that reads both files and writes ic_review.csv with one row per counterparty_ref: counterparty_ref, status (agree, amount break, missing entry, timing, wrong entity, duplicate, sign error), usd_difference, detail. Use exact decimal arithmetic for money. Never change my files. Run it, then show me how many refs are in each status, every ref that is not agree, and the elimination total in USD.
Claude Sonnet 5.5 (claude-sonnet-5-5) ran both prompts in Claude Code on 3 Nov 2026, in one session that held both messages and played the two turns in order. We did not run them in the chat app.
The script is 311 lines of Python, standard library only, with money in Decimal. It read 43 entries and 22 references. Thirteen references agreed, and the elimination total was USD 140,115.01. These are the nine that did not:
| Ref | Status | What the script said |
|---|---|---|
| IC-0014 | Amount break, USD 25.00 | UK booked GBP -4,961.09 (USD -6,375.00), US booked USD 6,400.00. |
| IC-0015 | Amount break, USD 25.00 | DE is higher by 25.00. |
| IC-0016 | Missing entry | UK has not booked its side. Only US-0016 exists. |
| IC-0017 | Missing entry | UK has not booked its side. Only DE-0017 exists. |
| IC-0018 | Timing | DE booked on 2 Nov, US on 21 Oct. The amounts agree, so it is not eliminated this period. |
| IC-0019 | Timing | US booked on 2 Nov, UK on 23 Oct. The amounts agree. |
| IC-0020 | Wrong entity | DE names UK as its counterparty and US names DE. The script says UK has not booked, which is probably wrong: DE entered the wrong counterparty. |
| IC-0021 | Duplicate | US booked the ref twice, US-0021 and US-0021B. With one reversed, the pair would agree. |
| IC-0022 | Sign error | Both entries are positive. One side needs the opposite sign. |
The elimination total is the receivable side of the 13 agreeing pairs. Two of Claude's assumptions set it: it totals the receivable side, and it does not eliminate the duplicate, wrong entity or sign error pairs.
The payable side comes to 140,112.89, so USD 2.12 is left over, which is the sum of the small differences inside the pairs. Three pairs are close to the limit: IC-0011 is 0.62 apart, IC-0012 0.74 and IC-0013 0.74.
Claude also pointed out that three of the nine already have matching amounts and need only a correction by the booking entity. Fixing them would add USD 10,900.00 to the total.
Where to run it
Intercompany usually takes more than one pass in a close: a draft, a round of chasing, a final. A script on a laptop can do the first run.
For the chasing you want a place where each entity sees its own open items, a log of who fixed what, and a rerun that only changes the items that moved. 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 writes back only drafts a person approves through the official API. We did not run this policy through ChatFin. ChatFin also has a page titled AI for Intercompany Transactions and Eliminations in Sage Intacct.
Test it before you trust it
1. Plant a break of every kind and keep the answer key
We built the 22 references with 13 that agree, 2 amount breaks, 2 missing entries, 2 timing items, 1 wrong entity, 1 duplicate and 1 sign error. Five of the agreeing pairs differ by 0.01 to 0.74 USD, and three of those come from a rate we shifted by 0.0001.
We did not give Claude the key. All 22 statuses matched it. We also added up the elimination total ourselves, from the answer key and the ledger, and got 140,115.01 on the receivable side and 140,112.89 on the payable side.
Made-up data. The data is made up and the breaks are ours. A match shows that the script follows the written rules on these entries. It says nothing about your ledger.
2. Try the edges
We ran 14 small ledgers, each with one or two references. The table groups them into nine rows.
| What we sent | What the script did |
|---|---|
| Two entries 1.00 apart in USD, and two entries 1.01 apart | Agree for 1.00, amount break for 1.01 |
| Both entries dated after 31 Oct | Agree, so both would be eliminated in October |
| One entry dated after 31 Oct and the amounts also differ by 40.00 | Amount break, with a note that part may be timing |
| Three entries from three entities share one ref | Wrong entity, none eliminated |
Entity code typed in lower case (us) | Read as US and agreed |
One side typed IC-0012, the other IC0012 | Two missing entries, each saying the other entity has not booked |
| An entry that names its own entity as the counterparty | Wrong entity |
| A currency with no rate (CAD) | Stopped, "no rate for currency CAD", no output file |
A blank counterparty_ref, an amount typed 1,000.00, or an amount of 0.00 | Stopped each time, naming the line, no output file |
Two rows are worth taking to your group controller. Entries that are both dated after the cut off were eliminated, because the rule only covers one late entry against one on time. And a reference typed two ways produces two missing entries, which look like two real breaks.
3. Take the gaps to your controller
The rules do not cover netting, loans, an entity that closes late on purpose, or one rate for the balance sheet and another for income.
Claude warned that using the closing rate for every entry means some differences are rate effects. Add what you want to the prompt and run the same files again.
Where ChatFin fits
The script finds the breaks. A close needs the rest: the connection to each entity's ledger, a screen where each entity clears its own items, an approval before eliminations are booked, and a record of who changed what.
ChatFin's own build or buy page lists the governed connection, the approval workflow and an audit trail as what you get when you buy (Build vs Buy: Finance AI Agents in 2026). ChatFin also has a page titled Best AI Agents for Intercompany Accounting in 2026.