Default billing to EUR, preserve USD for active subscribers#702
Conversation
Removes the USD/EUR currency selector from Plans & Billing. New subscriptions, MSP tenants, and distributor customers now default to EUR; any existing active USD subscription keeps its real currency so its price stays accurate. Also fixes a latent bug where MSP/distributor per-tenant pricing was computed off the admin's own account currency instead of each tenant's, pins AWS Marketplace checkout to USD since it's a separate billing rail, and removes an unused dead TotalCost stub from the MSP Tenants table.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughBilling currency is now derived from active subscription data through ChangesSubscription-derived currency
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Consumer as Hook or UI component
participant BillingProvider
participant resolveActiveCurrency
participant Subscription
Consumer->>BillingProvider: useBilling()
BillingProvider->>resolveActiveCurrency: resolveActiveCurrency(subscription)
resolveActiveCurrency-->>BillingProvider: currency
BillingProvider-->>Consumer: currency, plans, helpers
Consumer->>BillingProvider: subscribe/changeSubscription
BillingProvider->>BillingProvider: choose priceID using effectiveCurrency
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
e2e/tests/setup-keys.spec.tsOops! Something went wrong! :( ESLint: 9.39.3 TypeError: Converting circular structure to JSON 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/cloud/aws/AWSChoosePlan.tsx`:
- Line 180: AWSChoosePlan is still resolving the price ID from the ambient
currency state even though this path is explicitly pinned to USD, which can make
the displayed plan and the looked-up price diverge. Update the AWS subscription
flow in AWSChoosePlan so the same explicit Currency.USD value is passed through
to the subscribe and changeSubscription calls, ensuring priceID lookup uses USD
instead of the default currency state.
In `@src/contexts/BillingProvider.tsx`:
- Around line 173-178: `currency` is derived entirely from `subscription` via
`resolveActiveCurrency`, so the current `useState` plus `useEffect` pattern in
`BillingProvider` can render a stale default before the effect runs. Replace the
`currency` state/effect logic with a `useMemo` computed from `subscription` (and
any relevant loading guard if needed), and update the places that read
`currency`/`estimatedPrice` to rely on the memoized value so legacy USD
subscribers never flash EUR pricing.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: afcd4133-82cd-4e92-806d-866a1031ac02
📒 Files selected for processing (7)
src/cloud/aws/AWSChoosePlan.tsxsrc/cloud/distributor/hooks/useCustomerPlan.tssrc/cloud/msp/MSPTenantsTable.tsxsrc/cloud/msp/hooks/useTenantPlan.tssrc/cloud/msp/table/TenantPlanCostCell.tsxsrc/contexts/BillingProvider.tsxsrc/modules/billing/PlansAndBillingTab.tsx
Summary
Removes the USD/EUR currency selector from Settings → Plans & Billing and makes EUR the default currency across the dashboard, while keeping pricing accurate for customers already billed in USD.
$pricing until they change plans.resolveActiveCurrency()(src/utils/billing.ts) encodes this rule once and is used by all three resolution sites.Bug fixes included
useTenantPlananduseCustomerPlanpreviously derived currency from the logged-in admin's account. They now resolve it from each tenant/customer's own subscription, so the MSP Tenants cost column and the assign-a-plan modals show what that tenant is actually billed in.TenantPlanCostCellnow reuses the hook'sestimatedPriceinstead of duplicating the calculation with the wrong currency source.AWSChoosePlan.tsx) is pinned to USD — AWS bills in USD regardless of the dashboard default, so showing EUR list prices there would be misleading.TotalCostcomponent inMSPTenantsTable.tsx(hardcoded$5,260, never rendered).setCurrencyis dropped fromBillingContext(nothing calls it once the selector is gone), along with theinitialCurrencyref that only existed to protect manual selections. TheCurrencyenum keeps both values — it's the backend contract and legacy subscriptions still carrycurrency: "usd".Issue ticket number and link
N/A — internal request to move dashboard billing display to EUR.
Documentation
Select exactly one:
UI-only change to currency display/defaults; no user-facing docs describe the currency selector.
E2E tests
Optional: override the image tags used by the Playwright e2e workflow.
Defaults to
mainwhen omitted.management-cloud-tag: main
reverse-proxy-tag: main
Summary by CodeRabbit
New Features
Bug Fixes
UI Changes
Tests