Deferred vs Unbilled Revenue With Claude
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?
| Column | What the script does with it |
|---|---|
billed_to_date | Total invoiced to 31 Oct 2026, net of credit notes |
fee, start_date, end_date | Give the revenue recognised by day |
contract_id | Row key. Each contract stands alone |
What plan does Claude give first?
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?
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.
| Contract | Fee and term | Billed and recognised | Deferred | Unbilled |
|---|---|---|---|---|
| D-01 | 9,450.00, 22 May 2026 to 30 Apr 2027 | Billed 9,450.00, recognised 4,477.76 | 4,972.24 | 0.00 |
| D-26 | 50,800.00, 15 Apr 2026 to 30 Apr 2029 | Billed 40,384.17, recognised 9,136.69 | 31,247.48 | 0.00 |
| D-33 | 27,700.00, 16 Dec 2025 to 30 Nov 2026 | Billed 26,512.86, recognised 25,325.71 | 1,187.15 | 0.00 |
| D-27 | 65,800.00, 27 Feb 2026 to 29 Feb 2028 | Billed 22,172.71, recognised 22,172.71 | 0.00 | 0.00 |
| D-10 | 63,750.00, 13 Mar 2026 to 28 Feb 2027 | Billed 21,039.31, recognised 42,078.61 | 0.00 | 21,039.30 |
| D-03 | 15,750.00, 24 Feb 2026 to 31 Jan 2027 | Billed 2,878.29, recognised 11,513.16 | 0.00 | 8,634.87 |
| D-08 | 43,500.00, 7 Jan to 31 Dec 2026 | Billed 36,108.63, recognised 36,108.64 | 0.00 | 0.01 |
| D-07 | 47,200.00, 29 Sep 2025 to 28 Sep 2026 | Billed 0.00, recognised 47,200.00 | 0.00 | 47,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.
| What we sent | What the script did |
|---|---|
| Billed one cent above recognised, and one cent below | Deferred 0.01 and unbilled 0.00, then the reverse. Both as the reference |
| Billed exactly the recognised amount | Both 0.00 |
| A contract that ends on 31 Oct, billed in full and billed half | Both 0.00, then half the fee unbilled |
| A contract that starts 1 Nov, with nothing billed and with 500.00 billed | Both 0.00, then deferred 500.00 |
| A one day term on 30 Oct and on 31 Oct | Recognised 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 elapsed | Recognised 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?
| What we sent | What happened |
|---|---|
| A negative billed amount, even on the second line | Stopped 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 amount | Stopped at the line |
| The same contract_id twice | Both scripts went on. The second printed a warning |
| A negative fee | The 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?
How well did Claude split deferred and unbilled revenue?
What happens when a contract is billed above its whole fee?
Book a demo
Use the message box to tell us your ERP and the process you want to start with.