Deferred vs Unbilled Revenue With Claude

Summary
You need Contracts with billed to date, as CSV
Tested with Claude Sonnet 5.5, made-up data, 5 Nov 2026, two separate runs
Result 200 of 200 cells matched, both runs
Contracts inD-10 fee 63,750.00billed 21,039.31D-07 fee 47,200.00billed 0.00, term endedClaudeBalances outD-10 recognised 42,078.61D-10 unbilled 21,039.30D-07 recognised 47,200.00D-07 unbilled 47,200.00

How do you split deferred and unbilled revenue?

On 5 Nov 2026 we gave Claude four written rules and one file of 50 contracts, and it wrote a script that splits billed less recognised into deferred or unbilled revenue.

Which CSV columns does it use?

Columns the deferred and unbilled rule uses
ColumnWhat the script does with it
billed_to_dateTotal invoiced to 31 Oct 2026, net of credit notes
fee, start_date, end_dateGive the revenue recognised by day
contract_idRow key. Each contract stands alone

What plan does Claude give first?

Prompt 1: plan
I work in the accounting team of a software company. I want a small tool that tells me, for every contract at 31 Oct 2026, whether we owe the customer service (deferred revenue) or the customer owes us an invoice (unbilled revenue).

I have one file, contracts.csv (contract_id, customer, start_date, end_date, fee, billed_to_date). fee is the subscription fee for the whole term. billed_to_date is the total we have invoiced on the contract up to 31 Oct 2026, net of credit notes.

Our policy:
1. Revenue is recognised by day over the term. The term runs from start_date to end_date, both days included. Recognised to a date = fee times the days from start_date to that date, divided by the days in the term, rounded to the cent. Nothing is recognised before start_date, and a date after end_date counts as end_date.
2. For each contract compare billed_to_date with the revenue recognised to 31 Oct 2026. If billed is more, the difference is deferred revenue and unbilled revenue is zero. If billed is less, the difference is unbilled revenue and deferred revenue is zero. If they are equal, both are zero.
3. Do not net one contract against another. Report each contract on its own.
4. Stop, say which line is wrong, and write no output file if billed_to_date is negative, if end_date is before start_date, or if a date or an amount cannot be read.

Do not write code yet. Break the job into numbered steps. For each step say what could go wrong. Then list anything in the policy that is unclear.

Claude noticed that four contracts, D-07, D-18, D-34 and D-40, ended before 31 Oct with nothing billed, so each would show its whole fee as unbilled, and asked us to confirm.

It also flagged what to do when billed is above the whole fee, since the policy does not say. A second run, started with no memory of the first, raised both. We answered neither.

What script does Claude write?

Prompt 2: build and run
Good. Use that plan. Write one Python script, standard library only, that reads the file and writes deferred_unbilled.csv with one row per contract: contract_id, recognised_to_date, billed_to_date, deferred_revenue, unbilled_revenue. Use exact decimal arithmetic for money. Never change my file. Run it, then show me the totals of each money column, and the row for every contract that has unbilled revenue.

Claude Sonnet 5.5 (claude-sonnet-5-5) answered the plan prompt and then the build prompt, in two turns of one session in Claude Code on 5 Nov 2026.

It wrote a 160 line script, ran it on 50 contracts and reported four totals: recognised 951,755.84, billed 1,152,254.75, deferred 486,758.96 and unbilled 286,260.05.

The second run wrote a 171 line script and reported the same four. Our key agreed with all 200 cells from both runs.

Claude checked that billed minus recognised, 200,498.91, equals deferred minus unbilled, and said that net is for reading only, since the policy does not net contracts. A laptop ran every test here, on files of up to 3,000 contracts.

How does the sign rule work on real contracts?

The rule as we wrote it: If billed is more, the difference is deferred revenue and unbilled revenue is zero. If billed is less, the difference is unbilled revenue and deferred revenue is zero.

If they are equal, both are zero. The file holds 18 contracts billed in full in advance, 12 others billed more than recognised, 12 billed less, 4 exactly equal and 4 ended with nothing billed.

One contract of each kind and the one cent case
ContractFee and termBilled and recognisedDeferredUnbilled
D-019,450.00, 22 May 2026 to 30 Apr 2027Billed 9,450.00, recognised 4,477.764,972.240.00
D-2650,800.00, 15 Apr 2026 to 30 Apr 2029Billed 40,384.17, recognised 9,136.6931,247.480.00
D-3327,700.00, 16 Dec 2025 to 30 Nov 2026Billed 26,512.86, recognised 25,325.711,187.150.00
D-2765,800.00, 27 Feb 2026 to 29 Feb 2028Billed 22,172.71, recognised 22,172.710.000.00
D-1063,750.00, 13 Mar 2026 to 28 Feb 2027Billed 21,039.31, recognised 42,078.610.0021,039.30
D-0315,750.00, 24 Feb 2026 to 31 Jan 2027Billed 2,878.29, recognised 11,513.160.008,634.87
D-0843,500.00, 7 Jan to 31 Dec 2026Billed 36,108.63, recognised 36,108.640.000.01
D-0747,200.00, 29 Sep 2025 to 28 Sep 2026Billed 0.00, recognised 47,200.000.0047,200.00

Sixteen contracts carry unbilled revenue. Four of them, the ones that ended with nothing billed, account for 183,450.00 of the 286,260.05.

Claude never netted deferred against unbilled, as rule 3 says. The script produces the amount and does not classify it as a receivable or a contract asset.

What did Claude do with a one cent gap?

D-08 and D-28 are billed one cent below what is recognised, so each shows 0.01 unbilled. In the first run Claude said the billed amounts looked cut off at the cent.

In the second it said the gap looked like a billing rounding difference. We planted those rows ourselves as a one cent shortfall. The second run's plan also called D-04 a contract that ends on 31 Oct 2026, when the file has 31 Oct 2027.

Neither script stops when billed is above the whole fee: both take it and report billed minus recognised as deferred, 4,945.21 in our test case and 0.50 on a contract that ended in May.

The second script printed a warning for it and stops on a negative fee, which the first takes.

What happens at the boundaries?

Boundary contracts went through the first script one at a time, next to a reference written from the same rules.

Boundaries of the sign rule
What we sentWhat the script did
Billed one cent above recognised, and one cent belowDeferred 0.01 and unbilled 0.00, then the reverse. Both as the reference
Billed exactly the recognised amountBoth 0.00
A contract that ends on 31 Oct, billed in full and billed halfBoth 0.00, then half the fee unbilled
A contract that starts 1 Nov, with nothing billed and with 500.00 billedBoth 0.00, then deferred 500.00
A one day term on 30 Oct and on 31 OctRecognised in full either way. Billed 100.00 gives zero, billed 0.00 gives unbilled 100.00
A half cent: 1.00 over 200 days, one day elapsedRecognised 0.01, so unbilled 0.01 with nothing billed. Rounded up

The first script matched the reference in all 19 single contract cases, including a zero fee, a negative fee and billed above the whole fee, none of which the policy mentions.

The second script matched 18 and stopped on the negative fee. Then 3,000 random contracts with billed amounts at zero, at the recognised figure, one cent either side, a quarter, half and all of the fee: 12,000 cells and no differences for either script.

What happens with bad data?

Bad data and the stop rule
What we sentWhat happened
A negative billed amount, even on the second lineStopped at the line, no file, in both scripts
End before start, a date typed 31/10/2026, 30 Feb, text in the fee, a blank or comma amountStopped at the line
The same contract_id twiceBoth scripts went on. The second printed a warning
A negative feeThe first script took it. The second stopped

Rule 4 named a negative billed amount, an end before the start and unreadable values. Every bad file we tried for those stopped the run with no output. Repeated ids went through in both scripts.

What does a controller still review?

  • D-07, D-18, D-34 and D-40 ended with nothing billed and show 183,450.00 as unbilled: is that revenue to chase or a contract to close?
  • What is billed above the whole fee: a refund owed, a billing error or something else? Our rule would call it deferred.

Questions about deferred and unbilled revenue

What do you need to split deferred and unbilled revenue with Claude?
Contracts with billed to date, as CSV. Ours had 50 contracts, and billed_to_date was the total invoiced to 31 Oct 2026, net of credit notes.
How well did Claude split deferred and unbilled revenue?
All 200 cells matched our key, in both runs.
What happens when a contract is billed above its whole fee?
Neither script stops. Both take it and report billed minus recognised as deferred, 4,945.21 in our test case and 0.50 on a contract that ended in May.

Book a demo

Use the message box to tell us your ERP and the process you want to start with.

Request a demo