ChatFin/Build Subscription Revenue Recognition with Claude

How to build subscription revenue recognition using Claude

By Ashok ManthenaPublished 5 Nov 202610 min read
Three rows of contracts.csv (S01, S03, S10) go into Claude. The same three contracts come out in revenue_schedule.csv: S01 with 13400.00 deferred, S03 with 9782.14 deferred, S10 with 2049.32 unbilled. A note reads 65 of 65 cells matched our key, after we fixed 3 cells on contract S06.
You need
Contracts, as one CSV file
Tested with
Claude Sonnet 5.5, made-up data, 5 Nov 2026
Result
65 of 65 cells matched our key, after we fixed 3 cells on contract S06

Before you start

A customer pays 36,500 for a year of software on 15 March. By 31 October you have earned about seven and a half months of it, and the rest sits on the balance sheet as deferred revenue.

Spreading one contract over its days is easy. Doing it for every contract, with an amendment in August, a cancellation in October and a setup fee, and being able to show how the total was built, is a program.

It used to wait for a developer. On 5 Nov 2026 we wrote six rules in plain English and Claude wrote the program.

Our file has 13 contracts. Even that raised a question the rules did not answer: when a customer cancels on 10 October, do you recognise the full fee over the shorter term, or stop at the old daily rate and keep the rest as a liability?

Our rules cover a flat fee in one currency and one amendment per contract. They say nothing about usage fees or several currencies.

Our view is that mid size and large companies should not build and maintain this.

Every new contract type is a new rule to write, test and keep, and our 13 contracts already needed an answer on cancellations that the rules did not give. For the trade-off, read Build vs Buy: Finance AI Agents in 2026.

What you need

An ERP connection

You need one row per contract with its term, fee, setup fee, the total billed to date, and any amendment or cancellation. Check how your billing system and ERP export it, and what their API terms allow before you read it live.

The result then needs to feed the revenue journal and the deferred revenue account, and an accountant needs to tie the total to the ledger.

Our script reads one CSV file and writes one. It posts nothing and it does not compare the total with a ledger balance.

The data points

Columns in contracts.csv
ColumnUsed for
start_date, end_dateThe term. Both days count, so a full 2026 is 365
fee, setup_feeThe total to recognise. The setup fee is spread over the term too
billed_to_dateInvoiced to 31 Oct, net of credit notes. Decides deferred or unbilled
amend_date, amend_remaining_feeThe new rate from the amendment date. Both filled or both blank
cancel_dateEnds the term on that day

A plan, broken into steps

Attach contracts.csv and paste this.

Prompt 1: plan
I work in the accounting team of a software company. I want a small tool that works out our subscription revenue and deferred revenue for October 2026.

I have one file, contracts.csv (contract_id, customer, start_date, end_date, fee, setup_fee, billed_to_date, amend_date, amend_remaining_fee, cancel_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. amend_date, amend_remaining_fee and cancel_date are filled only where they apply.

Our policy:
1. Revenue is recognised by day over the term. The term runs from start_date to end_date, both days included. The total to recognise is fee plus setup_fee, so the setup fee is spread over the term too.
2. Recognised to a date = total times the days from start_date to that date, divided by the days in the term, rounded to the cent. October revenue is recognised to 31 Oct minus recognised to 30 Sep.
3. An amendment changes the rate from amend_date. Before amend_date the contract keeps its original rate. From amend_date to end_date, amend_remaining_fee is what is left to recognise, spread by day over those days, both days included. Recognised to a date after amend_date = recognised to the day before amend_date plus the amended amount for the days from amend_date to that date.
4. A cancellation ends the term on cancel_date, both days included. Nothing is recognised after it.
5. Nothing is recognised before start_date or after end_date.
6. Deferred revenue at 31 Oct 2026 = billed_to_date minus recognised to 31 Oct, if that is above zero. If it is below zero, the absolute amount is unbilled revenue and deferred revenue is zero.

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 gave eight steps and said what could go wrong in each. It hand-calculated several contracts before writing code, such as S10 at about 2,049.32 unbilled, and the script later matched them. It caught that a term containing 29 Feb 2028 has 1,096 days.

It warned that totals built from rounded rows can differ by a cent from a rounded total, and that the file has no 30 Sep billing and no ledger balance, so it can produce the number to compare but not the proof.

It then raised the question that decided the page. For contract S06, cancelled on 10 Oct, rule 4 shortens the term and rule 2 divides by the days in the term.

Read that way, October revenue is 945.60. Read as "keep the old daily rate and stop", October revenue is 500.00 and 8,600.00 stays deferred.

Claude pointed out that earlier months were probably booked at the old rate, so under the first reading the ledger needs a 9,100.00 catch-up in October, and asked which reading is policy.

It listed six open points in all: the cancellation, how days are counted, rounding, how amendments work (setup fee, S12, a second amendment), billing before the term starts, and currency.

Settle before relying on it. We did not answer. We told Claude to use its plan, and it took rule 4 literally. It built a switch into the script for the other reading. Your controller decides this, the other five points and the unrecognised 4,350.00 on S12.

Ask Claude to build it

Prompt 2: build and run
Good. Use that plan. Write one Python script, standard library only, that reads the file and writes revenue_schedule.csv with one row per contract: contract_id, october_revenue, 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 an amendment or a cancellation, starts or ends in October 2026, starts after 31 Oct 2026, or has unbilled revenue.

Claude Sonnet 5.5 (claude-sonnet-5-5) ran both prompts on 5 Nov 2026. The first run took the prompts one at a time, as two turns.

The script is 174 lines of Python, standard library only, with money as Decimal. It checked the input file was unchanged, and it showed that recognised minus billed equals unbilled minus deferred.

October revenue came to 21,691.46, recognised to date 220,875.34, billed 345,960.00, deferred revenue 127,153.16 and unbilled revenue 2,068.50. These are the nine contracts it listed, plus the totals:

Contracts that need a closer look, and the totals
ContractWhy it is listedOctober revenueBilledDeferredUnbilled
S03Starts 15 Oct477.8610,260.009,782.140.00
S05Amended 1 Sep3,525.4930,000.009,123.020.00
S06Cancelled 10 Oct945.6018,250.000.000.00
S08Ends 15 Oct3,000.0073,000.000.000.00
S09Starts 1 Nov0.006,000.006,000.000.00
S10Billed too little2,038.364,000.000.002,049.32
S11Starts 31 Oct10.003,650.003,640.000.00
S12Amended 16 Aug2,218.6236,500.009,789.220.00
S13Starts 1 Oct1,019.181,000.000.0019.18
All 1321,691.46345,960.00127,153.162,068.50

Two lines deserve a second look. S12 was downgraded, so the policy recognises 32,150.00 over its life against 36,500.00 billed, and 4,350.00 stays in deferred revenue until someone raises a credit note.

S09 starts 1 Nov but was billed by 31 Oct, so rule 6 puts all 6,000.00 in deferred revenue.

Where to run it

A revenue schedule has to run again each month. The accountant who posts the entry needs to see each contract's number and tie the total to the ledger, and an old month has to be reproducible.

That means a stored copy of the input and the output of every run. A hosting service such as Vercel is one option. Nothing here was hosted.

If you would rather buy it

ChatFin's build or buy page says maintenance of connectors, models and controls is the vendor's job, not your backlog. We did not run this policy through ChatFin.

ChatFin also has pages titled AI Agents for Deferred Revenue Waterfalls, Deferred Revenue Waterfall: How to Build One and Best AI Agents for Revenue Recognition in 2026: What to Look For.

Test it before you trust it

1. Plant the answer and keep the key

We built the 13 contracts so that each rule is tested, with contracts that start on each side of the month, two amendments, one cancellation and two contracts billed less than recognised, and our reference code produced the expected answers.

The key was not in Claude's folder. Our first key did not match: three cells for S06 differed. Our key had kept the old daily rate after the cancellation, and rule 4 as written shortens the term. Claude followed the rule as written.

We fixed our key to match the prompt, and kept the old one in the folder. After that all 65 cells matched. A second run, in a fresh session with the same two prompts answered in order, wrote a 226-line script that matched too.

Made-up data. The key comes from our own reading of the prompt, and we built the contracts to hit its edges. A match shows the script follows the written rules on these contracts. It says nothing about your contracts.

2. Try the edges of each rule

We ran 32 small files through each script. The table groups them into twelve rows. The two scripts agree on all of them except four, which are shown in the table: Claude made different choices where the prompt was silent.

Edge case results
What we sentWhat the script did
A contract that starts 31 Oct; starts 1 Nov; ends 30 Sep; ends 31 Oct; runs 1 to 31 OctOne day of October (10.00); nothing; nothing in October; the last 310.00 in October; the full 3,100.00
A one-day contract on 15 OctThe full 80.00 in October
A term that contains 29 Feb 2028Day count is 517, not 516. October is 310.00 of 5,170.00
0.04 over 8 days, one day recognised; 0.05 over 10 days0.01 each. A half cent rounds up
A setup fee of 100.00 on a 3,000.00 contract that runs only in OctoberAll 3,100.00 recognised in October
Billed more than recognised; billed less; billed exactly equal; an ended contract never billedDeferred; unbilled; both zero; unbilled for the full 1,810.00
An amendment mid October; on the last day; dated after 31 OctOctober split in two rates; accepted; no effect on October
A cancellation on the start date; on 31 Oct; on 30 SepAll 3,650.00 in one day; 372.20 in October; nothing in October
An amendment dated on the start dateFirst script: stopped. Second script: accepted
An amendment and a cancellation on the same contractFirst script: calculated it. Second script: stopped
A negative billed amount; a blank setup feeFirst script: stopped for both. Second script: accepted both
End before start; a repeated contract_id; a date typed 01/10/2026; a fee typed 1,000.00; an amendment date with no amount or an amount with no date; a cancellation before the start or after the endStopped with a message naming the contract. No output

Both scripts treat the cancellation as the prompt wrote it. They differ on the four cases above, and a different chat could differ again.

Pick the behaviour you want for an amendment on the start date, an amendment with a cancellation, and a negative billed amount, and put it in the prompt.

3. Compare it with a second implementation

We wrote our own version of the rules and made 3,000 random contracts: terms from one day to two years, setup fees, 492 amendments and 445 cancellations, 72 with both. The first script matched our figures on all 15,000 cells.

The second script stops on a contract with both, so we tested it on 3,000 contracts without that combination, and it matched all 15,000 cells too. Our version is ours. The match shows the two readings agree, and both could be wrong.

4. Take the gaps to your controller

The cancellation reading, day counting, the rounding rule, how amendments work, and billing before the term starts. Add your answers to the prompt and run the same file again.

Where ChatFin fits

The script shows how far one file and six rules get you in a sitting. Around it you still need the feed from the billing system, a tie-out to the ledger, a review step for contracts the rules cannot handle, and a person to change the rules when the accounting policy changes.

ChatFin's build or buy page lists the approval workflow and a full audit trail as part of what you buy (Build vs Buy: Finance AI Agents in 2026).