Static demo: commenting, signing and verdicts are off. Run verifair to try them.
Customers who upgrade mid-month are charged the full new price today. Finance wants the charge prorated by remaining days, so an upgrade on day 20 of 30 costs one third of the difference.
Out of scope: downgrades (stay end-of-cycle), annual plans.
You will be asked: when the proration starts, and whether rounding once is fine for Finance.
A new pure function, prorate(), is called by the plan-change handler only when the new price is higher.
Before / after: upgrade from 10 EUR to 40 EUR on day 20 of a 30-day cycle.
Invoice line today
Before
30.00 EUR, the full difference
After
10.00 EUR, the difference for the 10 days left
flowchart LR
A[Plan change] --> B{New price higher?}
B -- yes --> C[Prorate by days left] --> D[Invoice line today]
B -- no --> E[Switch at the end of the cycle]
A higher price is prorated by the days left; a lower one waits for the next cycle.
praise nitpick suggestion issue question thought todo chore note
Non-blocking (suggestion)
Comment
Cancel
Case
Handled
Verified by
Change on the last day of the cycle
Charged 1/30, not zero
unit test
Change on the first day
Full difference, no proration
unit test
Leap year February
Uses real cycle length, 29 days
unit test
Two changes in one day
Second change prorates from the first
integration test
Currency rounding
Round half-even to cents, once, at the end
golden file
praise nitpick suggestion issue question thought todo chore note
Non-blocking (suggestion)
Comment
Cancel
Proves
Command
Result
Link
Fails on revert
Proration math for all edge cases
pytest tests/test_pricing.py
✅ 212 passed
CI job #8812
yes
Retried request does not prorate twice
pytest tests/test_plan_change.py::test_retry
✅ passed
CI job #8812
yes
40 real customers match the Finance sheet
notebook, run all cells
✅ 40/40 match
notebook
no, it reads past invoices
Upgrade works on staging
POST /accounts/771/plan on staging
✅ invoice line 10.00 EUR
staging
yes
No new errors after deploy
log query, last 2h
⚠️ 40 minutes only, staging was redeployed
log query
no
Upgrade works on staging: the plan-change call for test account #771 and the invoice line it wrote.
POST /accounts/771/plan
{"plan": "pro"}
{"invoice_line": {"description": "Pro upgrade, prorated", "amount": "10.00", "currency": "EUR"}}
40 real customers match the Finance sheet: first rows of the notebook output.
Customer
Ours
Finance
Match
10231
13.33
13.33
✅
10498
4.67
4.67
✅
11870
26.00
26.00
✅
37 more
✅ 40/40
praise nitpick suggestion issue question thought todo chore note
Non-blocking (suggestion)
Comment
Cancel
5 Not verified / assumptions comment
Annual plans were not tested. We assume they never reach the plan-change handler.
Not run against production data volumes. The function is pure, so we expect no change in speed.
Assumes the billing cycle dates in the database are always in the customer's local time zone.
praise nitpick suggestion issue question thought todo chore note
Non-blocking (suggestion)
Comment
Cancel
Revert the merge requests in Changes, newest first, and redeploy. No schema change and no data migration. Invoices already issued with a prorated line stay as they are.
praise nitpick suggestion issue question thought todo chore note
Non-blocking (suggestion)
Comment
Cancel
7 Security impact comment
None. The change only reads prices and dates that the handler already loads. It adds no input from users, no new endpoint and no new permission.
praise nitpick suggestion issue question thought todo chore note
Non-blocking (suggestion)
Comment
Cancel
8 Agent reviews comment
Round
Reviewers
Findings
Fixed
Dismissed
1
quant, Python, security
3
2
1
2
quant, Python, security
0
0
0
The dismissed finding is the second question in Judge this.
praise nitpick suggestion issue question thought todo chore note
Non-blocking (suggestion)
Comment
Cancel
Is "first day" the day the cycle starts, or the day after the previous invoice?
Is rounding once at the end acceptable to Finance, or should each line round? (The quant reviewer flagged this; we kept one rounding.)
praise nitpick suggestion issue question thought todo chore note
Non-blocking (suggestion)
Comment
Cancel
#
Repo
Merge request
What it changes
Status
1
billing-service
!231
prorate() and the plan-change handler
open
2
invoice-ui
!88
shows the prorated line on the invoice
open, merge after !231
praise nitpick suggestion issue question thought todo chore note
Non-blocking (suggestion)
Comment
Cancel