Intercompany Reference Matching With Claude

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?
| File | What it holds |
|---|---|
ledger_a.csv (41 entries) | Entries where the entity booked a receivable |
ledger_b.csv (39 entries) | The matching payables |
| Columns | entry_id, entity, counterparty, counterparty_ref, posting_date, amount, currency. Four invented entities, all USD |
What plan does Claude give first?
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?
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.
| Entry | Entity | Reference | Amount | Result |
|---|---|---|---|---|
| A007 | Corvane DE to Bramhall UK | IC-0375 | 51837.21 | paired with B026 |
| B026 | Bramhall UK to Corvane DE | IC-0375 | 51837.21 | paired with A007 |
| A005 | Corvane DE to Dunmore SG | IC0121 | 59105.49 | paired with B010 |
| B010 | Dunmore SG to Corvane DE | IC-0121 | 59105.49 | paired with A005 |
| A002 | Bramhall UK to Dunmore SG | IC0336 | 31686.86 | needs review |
| A004 | Bramhall UK to Corvane DE | IC-0336 | 31686.86 | needs review |
| B035 | Corvane DE to Bramhall UK | ic 0336 | 31686.86 | needs review |
| A012 | Corvane DE to Corvane DE | I.C. 0122 | 61669.90 | needs 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:
| What we sent | First session | Second session | First script, after the change |
|---|---|---|---|
IC-0012 against IC0012 or ic 0012 | Paired | Paired | Paired |
IC-0012 against PO-0012 | Paired | Sent to a person | Sent to a person |
IC-0012 against IC-12 | Sent to a person | Paired | Sent to a person |
Amounts equal, one side typed "1,000.00" | Sent to a person | Sent to a person | Sent to a person |
| Same amount, one side in EUR | Sent to a person | Sent to a person | Sent to a person |
| Both entries in the same ledger | Sent to a person | Sent to a person | Sent to a person |
Two references in one field, IC-0012 / IC-0013 | Sent to a person | Sent to a person | Sent to a person |
Amounts 0.30 and 0.300 | Paired | Paired | Paired |
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
0012and12count 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?
How well did Claude pair intercompany entries?
Which Claude model did we test?
Book a demo
Use the message box to tell us your ERP and the process you want to start with.