Skip to content

πŸ› Billing: mid-week plan activation misses week-quota snapshot rotationΒ #3988

Description

@PierreBrisorgueil

Root cause (surfaced by a downstream consumer's audit β€” latent since inception, not a regression): forceRotateForPlanChange is wired only into handleSubscriptionUpdated's plan-change block. handleCheckoutCompleted and both branches of handleSubscriptionCreated never rotate the current-week quota snapshot after a mid-week plan activation β€” the org keeps the previous plan's weekly quota until the next weekly reset (money bug: an upgraded org does not get its new quota immediately).

Fix:

  • Wire the snapshot rotation into handleCheckoutCompleted and both handleSubscriptionCreated branches (preserveUsage semantics consistent with the existing plan-change call site; rotation failure logged non-fatal, mirroring existing patterns).
  • Usage attribution reads the LIVE quota rather than the stale snapshot where applicable (billing.usage.service.js).
  • Integration tests: checkout-completed and subscription-created lifecycle paths assert the rotated snapshot + immediate new-plan quota.

Reference: a proven equivalent patch runs in production on a downstream consumer; this issue ports it to the stack so every consumer gets it.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions