Skip to content

Feature/billing cycle fix 142#272

Open
Robinsonchiziterem wants to merge 2 commits intoCalebux:mainfrom
Robinsonchiziterem:feature/billing-cycle-fix-142
Open

Feature/billing cycle fix 142#272
Robinsonchiziterem wants to merge 2 commits intoCalebux:mainfrom
Robinsonchiziterem:feature/billing-cycle-fix-142

Conversation

@Robinsonchiziterem
Copy link
Copy Markdown

@Robinsonchiziterem Robinsonchiziterem commented Mar 30, 2026

PR #142 Billing cycle calculation uses fixed 30/90/365 day intervals — drifts for calendar month subscriptions

Description

This PR standardizes the billing cycle calculations across the SYNCRO backend and client library. Previously, the system used fixed-day arithmetic (30/90/365 days) which caused date drift over time (e.g., January 31st projecting to March 2nd/3rd instead of February 28th/29th).

The new implementation uses date-fns calendar-aware functions (addMonths, addQuarters, addYears) to ensure accurate renewal dates that respect varying month lengths and leap years.

Key Changes:

  • Simulation Service: Refactored calculateNextRenewal to use date-fns.
  • Renewal Executor: Standardized next billing date calculation during the renewal process.
  • Client Utils: Updated subscription-utils.ts to use addDays consistency.
  • Dependencies: Added date-fns to the backend.

Test Plan

  • Tested locally (verified with unit tests for Jan 31st and Feb 29th transitions)
  • Verified expected behavior (projections correctly align with calendar months)
  • No regressions introduced (all existing logic and mathematical averages in analytics remain consistent)

Screenshots (if applicable)


Checklist

  • Code builds successfully
  • Tests pass
  • Follows project conventions
  • No sensitive data exposed

Closes #142

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 30, 2026

@Robinsonchiziterem Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Billing cycle calculation uses fixed 30/90/365 day intervals — drifts for calendar month subscriptions

1 participant