ChatFin/Intercompany FX Differences With Claude

Intercompany FX Differences With Claude

By Ashok ManthenaPublished 5 Nov 20267 min read
You need
A ledger and a closing rate per currency, as CSV
Tested with
Claude Sonnet 5.5, made-up data, 5 Nov 2026
Result
176 of 176 cells match the key, both runs

30 pairs agree, 14 differ

The limit is 1.00 USD. Each entry is translated at the closing rate, rounded to the cent, and compared. On 5 Nov 2026 we gave Claude six rules for that comparison and a ledger of 44 pairs, and checked every cell of its answer.

The test used four entities and three currencies, one rate per currency and one rate date.

Rules 2 to 4 of our prompt: one limit, applied after rounding

Translate each entry to USD with its currency's usd_per_unit from fx_rates.csv, then round each translated amount to the cent, halves up. The difference is the gap between the two USD amounts, as a positive number. A pair agrees if the difference is 1.00 or less. Any other pair is a difference.

The rates in the test are made up: GBP at 1.2736 and EUR at 1.0912 on 31 Oct 2026. The 44 pairs:

  • 20 pairs with a USD gap of 0.99 (7 pairs), 1.00 (7 pairs) or 1.01 (6 pairs).
  • 8 pairs where the payable side was booked at a rate 0.0001 away from the file rate. Four are 8,489.00 USD or less and four are 42,000.00 USD or more.
  • 12 pairs that tie, and 4 clear differences of 8.75, 25.00, 340.50 and 1,250.00.

ic_ledger.csv, fx_rates.csv and fx_review.csv

The script Claude wrote reads ic_ledger.csv and fx_rates.csv and writes fx_review.csv.

Columns in ic_ledger.csv and fx_rates.csv
ColumnUsed for
counterparty_refTies the two entries of a pair. Each ref appears twice
entity, currency, amountWho booked it, in what currency. A receivable is positive, a payable negative
currency, usd_per_unit, rate_dateOne closing rate per currency

Both runs planned eight steps and raised four unclear points

Attach ic_ledger.csv and fx_rates.csv and paste this. We do not publish the data, so your numbers will differ from ours.

Prompt 1: plan
I work in the group accounting team. Before consolidation I want a small tool that checks the currency differences on our intercompany charges.

I have two files:
- ic_ledger.csv: the intercompany entries of four entities, US (USD), UK (GBP), DE (EUR) and NL (EUR). The columns are entity, doc_no, counterparty, doc_date, counterparty_ref, currency, amount and description. The entity that is owed money books a positive amount, the entity that owes it books a negative amount.
- fx_rates.csv: the rates at 31 Oct 2026 (currency, usd_per_unit, rate_date).

Our rules:
1. Every counterparty_ref has exactly two entries, one positive and one negative, booked by different entities.
2. Translate each entry to USD with its currency's usd_per_unit from fx_rates.csv, then round each translated amount to the cent, halves up.
3. The difference is the gap between the two USD amounts, as a positive number.
4. A pair agrees if the difference is 1.00 or less. Any other pair is a difference.
5. For every pair also give larger_entity (the entity whose USD amount is larger, blank if they are equal) and implied_rate: the positive entry's USD amount divided by the negative entry's local amount, to four decimals, halves up. That is the rate the payable side would need to match exactly.
6. If an entry has a currency that is not in fx_rates.csv, stop, write nothing and say which entry.

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.

Run 1 was the first attempt. Run 2 repeated the prompts in a new session.

  • Negative amounts. "Halves up" can mean toward plus infinity or away from zero, and the two differ on a negative half cent. Both runs said they would round the size of the amount, so the two sides of a pair behave alike.
  • Whether the gap and "larger" compare signed or absolute amounts. Both took absolute amounts.
  • Which USD figure feeds implied_rate: the rounded one or the unrounded one. Both chose the rounded one. Run 2 asked us to confirm; run 1 stated its reading and carried on.
  • What to do with a ref that does not have two entries. Rule 6 covers only a missing rate. Run 1 planned to stop and asked us to confirm. Run 2 asked whether to stop or list the ref as an exception.

Only run 1 flagged, before writing any code, that three pairs, IC-0007, IC-0008 and IC-0020, are exactly 1.00 apart after rounding and about 1.004 apart before it. We checked the three before rounding: 1.0039, 1.0039 and 1.0035, so each would be a difference.

We told Claude to use its plan, and it used the defaults above.

Both runs wrote a Python script, 149 and 143 lines

Prompt 2: build and run
Good. Use that plan. Write one Python script, standard library only, that reads both files and writes fx_review.csv with one row per counterparty_ref: counterparty_ref, status (agree or difference), usd_difference, larger_entity, implied_rate. Use exact decimal arithmetic for money and rates. Never change my files. Run it, then show me how many refs agree, every ref that is a difference, and the total of the differences in USD.

Claude Sonnet 5.5 (claude-sonnet-5-5) took both prompts on 5 Nov 2026 as two turns of one Claude Code session with the files in a working folder.

The first script is 149 lines of Python, standard library only, and the second is 143. Both use Decimal for money and rates, and both check the ledger before they write anything.

The 14 differences add up to 1,661.40 USD, and 1,590.50 of that is two pairs, IC-0042 (340.50) and IC-0043 (1,250.00). The 30 pairs that agree carry 16.20 USD of gap between them.

A 0.0001 rate gap passes on 7,307.00 and fails on 150,000.00

The implied_rate column is the rate that would make the payable side tie exactly, and in every row it sits 0.0001 from the file rate.

Eight pairs booked 0.0001 away from the file rate
RefPair in USDImplied rateGap in USDResult
IC-00217,307.001.09130.67Agree
IC-00223,463.001.27350.28Agree
IC-00237,249.001.09130.66Agree
IC-00248,489.001.27350.66Agree
IC-002542,000.001.09133.85Difference
IC-0026150,000.001.091113.75Difference
IC-002796,000.001.27377.53Difference
IC-002865,000.001.09115.96Difference

Checks: a key, 25 edge ledgers, 2,000 random pairs

1. A key kept out of the working folder

Our own code worked out the result for each of the 44 refs, and we kept the key out of the folder we told Claude to work in.

We compared four fields per ref: status, USD gap, larger entity and implied rate. That is 176 cells. Run 1 had 0 differences and run 2 had 0, and the two output files are identical.

2. Edge cases

We ran 25 small ledgers through both scripts.

Edge case results
What we sentWhat happened
USD gap of 1.00, then 1.01Agree at 1.00, difference at 1.01. Both runs
EUR 1,000.01 against USD 1,090.21Agree. The gap is 1.00 after rounding and 1.0009 before it. Both runs round first
EUR 10.00 at a test rate of 1.0925, which is 10.925 before rounding, against USD 10.93Gap 0.00, so the half cent rounds up on the positive and on the negative entry
The payable booked at 1.0913 on USD 5,000, then on USD 150,000Agree with a gap of 0.46, then a difference of 13.74
A CAD entry with no rateBoth stop and write nothing. Both name the entry, its entity and its ref. Only run 1 gives the file line
A ref with one entry, with three entries, with two positives, or with both entries from one entityStopped each time, with the ref named
Zero amounts; an amount typed 1,000.00Both stop. Run 1 names the file line. Run 2 names the entity and document number, and for zero says the ref lacks one positive and one negative entry
IC-0012 on one side and IC0012 on the otherStopped. Each ref has one entry
Currency typed eurRun 1 reads it as EUR. Run 2 stops
A blank counterparty_ref on both entriesRun 1 stops. Run 2 pairs them and writes a row with a blank ref
Rates dated 30 SepRun 1 stops. Run 2 does not look at the date

3. 2,000 random pairs against our own version

We wrote our own version of the six rules and made 2,000 random pairs across all four entities, with amounts up to 1 million, payables booked up to 0.0003 off the file rate, and about one pair in seven given an extra gap.

Of those pairs, 676 agree and 1,324 are differences, and 21 sit between 0.99 and 1.01. Both scripts matched our version on every field of every pair. Our version is the same function that made the key, so a misreading of the six rules would pass in both.