Intercompany Reference Matching With Claude

Summary
You need Two ledger extracts as CSV
Tested with Claude Sonnet 5.5, made-up data, 5 Nov 2026
Result 80 of 80 entries match our key
Three rows of ledger_a.csv go into Claude: A005 with the reference IC0121, A002 with IC0336 and A001 with IC/0321. In matches.csv A005 is paired with B010, while A002 and A001 need review. A note reads 80 of 80 entries match our key.

How does Claude match intercompany references?

The two ledger extracts hold 80 entries, and one entity writes IC-0336 where its counterparty writes IC0336.

Our rule said a pair has the same reference, and Claude read "same" as the same number without being told to. On references of a different kind, the first session paired IC-0012 with PO-0012 because it keeps only the digits.

What files does it need?

Files for the intercompany reference test
FileWhat it holds
ledger_a.csv (41 entries)Entries where the entity booked a receivable
ledger_b.csv (39 entries)The matching payables
Columnsentry_id, entity, counterparty, counterparty_ref, posting_date, amount, currency. Four invented entities, all USD

What plan does Claude give first?

Prompt 1: plan
I work in group accounting. Our four entities book intercompany entries in two ledger extracts. Before we eliminate anything I need to know which entries are two halves of the same transaction.

I have two files:
- ledger_a.csv: entries where the entity booked a receivable (entry_id, entity, counterparty, counterparty_ref, posting_date, amount, currency)
- ledger_b.csv: entries where the entity booked the matching payable (same columns)

My rules:
1. Two entries are a pair when they have the same counterparty_ref.
2. A pair must also be mirrored: the entity of one entry is the counterparty of the other, and the amounts are equal to the cent.
3. If one reference is on three or more entries, do not pair any of them. They all go to a person.
4. An entry booked to its own entity goes to a person. So does an entry with no partner.

Do not write code yet. Break the job into numbered steps. For each step say what it checks, and what the tool does with an entry it cannot decide. Then list anything in my rules that is unclear.

In the first session Claude gave seven steps. Step 2 turns each reference into its digits, so I.C. 0122 and IC/0321 become keys. Its first open question was whether we meant that: "Rule 1 says same counterparty_ref, but the refs differ in punctuation and case."

It also counted by hand before writing code: 30 pairs, 20 entries for a person. In all four three-entry groups, two entries mirror each other and the third does not.

Rule 3 sends all three to a person, and Claude asked whether the reviewer should be told a clean pair exists. We answered none of the nine questions.

What script does Claude write?

Prompt 2: build and run
Good. Use that plan. Write one Python script, standard library only, that reads both files and writes matches.csv with one row per entry and these columns: entry_id, status, paired_with, reason.
- status is one of: paired, needs_review
- paired_with: the entry_id of the other half, empty when the status is needs_review
- reason: one short sentence a controller can read
Never change my input files. Run it, then show me the count of entries per status and every entry that is needs_review.

Claude Sonnet 5.5 (claude-sonnet-5-5) ran both prompts as two turns on 5 Nov 2026. (The test harness also made one call to Claude Opus 5.5 per session.) The script is 149 lines of standard library Python.

It paired 30 pairs, 60 entries, and sent 20 to a person. All 80 matched our key. A second session with the same prompts wrote a different script and also scored 80 of 80.

Eight of the 80 ledger entries and the first script result
EntryEntityReferenceAmountResult
A007Corvane DE to Bramhall UKIC-037551837.21paired with B026
B026Bramhall UK to Corvane DEIC-037551837.21paired with A007
A005Corvane DE to Dunmore SGIC012159105.49paired with B010
B010Dunmore SG to Corvane DEIC-012159105.49paired with A005
A002Bramhall UK to Dunmore SGIC033631686.86needs review
A004Bramhall UK to Corvane DEIC-033631686.86needs review
B035Corvane DE to Bramhall UKic 033631686.86needs review
A012Corvane DE to Corvane DEI.C. 012261669.90needs review

The first two rows are a pair typed alike. The next two are a pair typed IC0121 and IC-0121. The three that follow share one number across three entities, and the last is booked to its own entity.

In the data, 44 of the 60 paired entries are typed differently from their partner, so a script that compared the text as typed would have found only the 16 typed alike.

How is the answer key built?

We built 30 pairs, four groups of three entries, five entries with no partner and three booked to their own entity.

The key says which entries pair and which go to a person. A script compares each output row with it. The entities and references are invented, and the key follows the four rules in the prompts.

What happens with other kinds of reference?

We ran 16 small ledgers through three scripts: the first session's, the second session's, and the first session's after a change we asked for:

Reference edge cases across two sessions and one change
What we sentFirst sessionSecond sessionFirst script, after the change
IC-0012 against IC0012 or ic 0012PairedPairedPaired
IC-0012 against PO-0012PairedSent to a personSent to a person
IC-0012 against IC-12Sent to a personPairedSent to a person
Amounts equal, one side typed "1,000.00"Sent to a personSent to a personSent to a person
Same amount, one side in EURSent to a personSent to a personSent to a person
Both entries in the same ledgerSent to a personSent to a personSent to a person
Two references in one field, IC-0012 / IC-0013Sent to a personSent to a personSent to a person
Amounts 0.30 and 0.300PairedPairedPaired

The second session sends IC-0012 against PO-0012 to a person but pairs IC-0012 with IC-12. Its script only recognises references that start with IC, and only the four entity names we gave, so a PO reference or any other entity goes to a person.

We told the first session that the letters in front must also match and the number must be the same. It wrote a 180 line version. The PO pair went to a person.

It sent IC-0012 and IC-12 to a person as well, and said it read "the same number" as the digits written the same, because a missed pair costs a person a quick look and a wrong pair is eliminated unseen. All 80 entries on our data stayed as they were.

What does a controller still review?

  • Do 0012 and 12 count as the same number?
  • Does a different prefix mean a different document? Write the prefixes your entities use into the rule.
  • When a reference is on three entries and two mirror cleanly, should the reviewer be told?
  • What should happen to an amount typed with a thousands comma? Both sessions sent it to a person.

Questions about matching intercompany references

What do you need to match intercompany entries with Claude?
Two ledger extracts as CSV. In our test, ledger_a.csv held 41 receivable entries and ledger_b.csv held 39 matching payables.
How well did Claude pair intercompany entries?
All 80 entries matched our key. Claude paired 30 pairs, 60 entries, and sent 20 entries to a person. A second session with the same prompts also scored 80 of 80.
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