Repository navigation
fix(subscription): allow free plan currency mismatch - #4954
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan includes up to 8 reviews per rolling hour; 7 remain after this review. 📝 WalkthroughWalkthroughSubscription invoice currency resolution now prioritizes fiat plan currencies. Custom plans validate customer currencies. Priced subscriptions reject customer and plan currency mismatches, while unpriced subscriptions can use different currencies. ChangesSubscription currency handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This localized change allows free plans to use a different currency from the customer while preserving validation for priced subscriptions; no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
7513165 to
2e9ee7b
Compare
2e9ee7b to
1cec0c2
Compare
Summary
Root cause
The plan-start currency resolver enforced customer and fiat-plan currency equality before a subscription spec existed. That duplicated price-dependent validation at a layer that could not distinguish priced from unpriced contents.
The resolver now only selects the invoice currency: the plan currency for fiat plans, or the customer fiat for custom-currency plans. The subscription service remains the owning validation boundary and rejects customer/invoice currency mismatches when
spec.HasBillables()is true.Impact
Free subscriptions can start and be updated without spurious currency errors. Priced fiat-plan subscriptions retain the existing customer currency mismatch protection.
Validation
go test -tags=dynamic ./openmeter/subscription/workflow/service -run 'Test(ResolveSubscriptionInvoiceCurrency|CreateFromPlan)$' -count=1go test -tags=dynamic ./openmeter/subscription/... ./openmeter/productcatalog/subscription/... -count=1git diff --checkGreptile Summary
The PR moves fiat customer/plan mismatch handling from the early invoice-currency resolver to the subscription spec’s billability-aware validation.
Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains.
Important Files Changed
Sequence Diagram
sequenceDiagram participant W as Subscription workflow participant R as Currency resolver participant S as Subscription spec participant V as Core service validation participant DB as Persistence W->>R: Resolve invoice currency R-->>W: Fiat plan currency W->>S: Build spec from plan W->>V: Create subscription alt Spec has priced items V->>V: Compare customer and invoice currencies alt Currencies mismatch V-->>W: Validation error else Currencies match V->>DB: Persist subscription end else Spec has no priced items V->>DB: Persist subscription endReviews (3): Last reviewed commit: "fix(subscription): allow free plan curre..." | Re-trigger Greptile
Context used:
Summary by CodeRabbit
New Features
Bug Fixes