Proration calculator
Work out what to charge or credit for a mid-cycle upgrade, downgrade, seat change or co-termed add-on. You get every invoice line and the working behind it, including the edge cases: short months, leap years and billing on the 31st.
Using an AI assistant? Copy a prompt that gives it this calculator.
—
Invoice lines
| Line | Service period | Fraction | Amount |
|---|
How it's calculated
The same numbers under each method
Proration methods disagree most in February and in annual contracts that span a leap day.
Three ways to prorate
All three agree in a 30-day month. Take 10 days left in February 2026 on a $3,000/month plan and they give three different answers.
Price × days used ÷ days in that period
$1,071.43
$3,000 × 10/28
Every full month costs the same, so a day in February costs more than a day in March. The most common method, and the one Bunny Billing uses.
Annual price × days used ÷ 365
$986.30
$36,000 × 10/365
Every day of the year costs the same. Common in annual contracts and when finance thinks in daily rates.
Price × 30/360 days ÷ 30
$1,200.00
$3,000 × 12/30
Every month counts as 30 days, so February 19 to month end is 12 “days”. Half a month is always half the price. Shows up in contracts that define a month as 30 days.
The edge cases spreadsheets get wrong
Billing on the 29th, 30th or 31st
A subscription that started on January 31 bills on February 28, then March 31. Its periods run 28 to 31 days, and a formula that assumes “same day next month” breaks every February.
Leap years
An annual contract that spans February 29 has 366 days. Divide by 365 and the customer pays for a day that does not exist in the price.
Rounding per line
A credit and a charge each round to the cent, so the net can differ by a cent from prorating the difference. Going from 10 to 15 seats at $20 with 21 of 31 days left is $67.75 on the invoice, not $67.74.
Sub-cent prices and other currencies
$0.0045 per unit across a million units needs exact arithmetic until the last step. Yen has no minor unit and some dinars have three decimal places, so “round to 2 decimals” is wrong for them.
Use it in code, or give it to your AI agent
This calculator runs on billing-math, an open-source MIT library from Bunny. Language models are unreliable at date and money arithmetic, so give your agent the MCP server and it calls exact functions instead of guessing.
Give it to your AI in one paste
Copy this prompt into Claude Code, Cursor, Claude Desktop or any assistant that supports MCP. It installs the server, checks the answer against a known example, and switches to exact tools for billing questions.
See the prompt
Set up the billing-math MCP server for me so you can do SaaS billing math exactly instead of estimating it: proration, plan and seat changes, co-terming and ramped multi-year deals.
About it: an open-source (MIT) stdio MCP server from Bunny Billing, published on npm as @bunnyapp/billing-math. Source: https://github.com/bunnyapp/billing-math. It needs Node.js 20 or later and runs with: npx -y @bunnyapp/billing-math
1. Add the server to the MCP configuration of the app I'm using right now.
- Claude Code: run claude mcp add billing-math -- npx -y @bunnyapp/billing-math
- Cursor, Claude Desktop, Windsurf, VS Code or another MCP client: add this server to its MCP config file, adjusting the format if the app uses a different one:
{
"mcpServers": {
"billing-math": {
"command": "npx",
"args": ["-y", "@bunnyapp/billing-math"]
}
}
}
If you can't change the configuration yourself, give me exact step-by-step instructions for this app instead.
2. Tell me if I need to restart the app or reload its MCP servers.
3. Once it is connected, check it works: use calculate_plan_change for a $3,000/month plan upgraded to a $4,500/month plan on 2026-06-19, where the billing period started on 2026-06-01. The answer should be $600.00 due now.
From then on, use the billing-math tools (calculate_plan_change, calculate_coterm, prorate_charge, get_billing_period, model_ramp_deal) for any proration, upgrade, downgrade, seat change, co-term, billing-date or ramp deal (TCV, ACV, ARR, invoice schedule) question, and show me the explanation steps they return.
npm install @bunnyapp/billing-math
import { calculatePlanChange } from '@bunnyapp/billing-math';
calculatePlanChange({
anchorDate: '2026-06-01',
changeDate: '2026-06-19',
from: { price: 3000, name: 'Growth' },
to: { price: 4500, name: 'Scale' },
}).net; // 600
claude mcp add billing-math -- npx -y @bunnyapp/billing-math
{
"mcpServers": {
"billing-math": {
"command": "npx",
"args": ["-y", "@bunnyapp/billing-math"]
}
}
}
The terms behind the numbers
Definitions for everything this calculator touches.
Stop working this out by hand
In Bunny Billing, a mid-term change is a quote against the live subscription. The proration is worked out from the subscription's actual state on the change date, and the amount the customer signs is the amount on the invoice.