Skip to content

Default billing to EUR, preserve USD for active subscribers#702

Merged
heisbrot merged 4 commits into
mainfrom
feature/eur-only-billing
Jul 7, 2026
Merged

Default billing to EUR, preserve USD for active subscribers#702
heisbrot merged 4 commits into
mainfrom
feature/eur-only-billing

Conversation

@SunsetDrifter

@SunsetDrifter SunsetDrifter commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

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.

  • No active subscription (new signup, free tier, expired trial): currency resolves to EUR everywhere. No currency choice is offered.
  • Active subscription: the subscription's real currency is used, so existing USD subscribers keep seeing correct $ pricing until they change plans.
  • New shared helper resolveActiveCurrency() (src/utils/billing.ts) encodes this rule once and is used by all three resolution sites.

Bug fixes included

  • MSP / Distributor per-tenant currency: useTenantPlan and useCustomerPlan previously 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.
  • TenantPlanCostCell now reuses the hook's estimatedPrice instead of duplicating the calculation with the wrong currency source.
  • AWS Marketplace plan selection (AWSChoosePlan.tsx) is pinned to USD — AWS bills in USD regardless of the dashboard default, so showing EUR list prices there would be misleading.
  • Removed the dead TotalCost component in MSPTenantsTable.tsx (hardcoded $5,260, never rendered).

setCurrency is dropped from BillingContext (nothing calls it once the selector is gone), along with the initialCurrency ref that only existed to protect manual selections. The Currency enum keeps both values — it's the backend contract and legacy subscriptions still carry currency: "usd".

Issue ticket number and link

N/A — internal request to move dashboard billing display to EUR.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

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 main when omitted.

management-cloud-tag: main
reverse-proxy-tag: main

Summary by CodeRabbit

  • New Features

    • AWS plan selection now shows pricing in USD.
    • Billing currency is now determined automatically from the active subscription.
  • Bug Fixes

    • Tenant and plan pricing now stays consistent with the customer’s active subscription currency.
    • Tenant plan cost display is simplified and only shows the estimated price when the tenant is Active.
  • UI Changes

    • Removed the currency selector from the billing plans screen.
    • Simplified tenant cost and billing header displays.
  • Tests

    • Updated setup-keys end-to-end assertions around confirmation dialog visibility.

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.
@CLAassistant

CLAassistant commented Jul 7, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 546f0fa4-4d1a-4f99-990e-28081aeb8f72

📥 Commits

Reviewing files that changed from the base of the PR and between 529c4f9 and 56d40ac.

📒 Files selected for processing (1)
  • e2e/tests/setup-keys.spec.ts

📝 Walkthrough

Walkthrough

Billing currency is now derived from active subscription data through resolveActiveCurrency, with setCurrency removed from the billing context. AWS pricing uses USD directly, billing screens drop the currency selector, tenant plan cost display is simplified, and setup-key e2e tests add dialog-visibility checks.

Changes

Subscription-derived currency

Layer / File(s) Summary
BillingProvider currency resolution helper and context changes
src/contexts/BillingProvider.tsx
Adds exported resolveActiveCurrency(subscription?), replaces stateful currency initialization with a memoized subscription-derived value, removes setCurrency from context type and value, and uses effectiveCurrency (USD for AWS) in subscribe and changeSubscription.
Customer and tenant plan hooks
src/cloud/distributor/hooks/useCustomerPlan.ts, src/cloud/msp/hooks/useTenantPlan.ts
Both hooks stop pulling currency from useBilling() and instead compute it via memoized resolveActiveCurrency(subscription).
Tenant plan cost display
src/cloud/msp/table/TenantPlanCostCell.tsx
Drops useMemo/useBilling usage, sources estimatedPrice from useTenantPlan, and displays 0.00 for non-active tenants instead of the computed price.
Removal of currency selector and hardcoded UI elements
src/cloud/aws/AWSChoosePlan.tsx, src/modules/billing/PlansAndBillingTab.tsx, src/cloud/msp/MSPTenantsTable.tsx
AWSChoosePlan hardcodes Currency.USD for PlanCard; PlansAndBillingTab removes the currency Select dropdown and setCurrency usage; MSPTenantsTable removes the hardcoded TotalCost component and its CreditCardIcon import.
Setup-key dialog assertions
e2e/tests/setup-keys.spec.ts
After revoke and delete confirmations, the test now asserts the dialog is no longer visible before verifying the table result.

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
Loading

Suggested reviewers: mlsmaycon

Poem

A rabbit hopped through billing code,
And down the subscription burrow strode.
No dropdowns now, just USD,
For AWS and pricing clarity. 🐇
The dialog fades, the tests agree,
Hop, hop—clean paths for you and me.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main billing default change and the USD exception for active subscribers.
Description check ✅ Passed The description matches the template and includes the required issue, documentation choice, and e2e settings sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/eur-only-billing

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

e2e/tests/setup-keys.spec.ts

Oops! Something went wrong! :(

ESLint: 9.39.3

TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Object'
| property 'configs' -> object with constructor 'Object'
| property 'flat' -> object with constructor 'Object'
| ...
| property 'plugins' -> object with constructor 'Object'
--- property 'react' closes the circle
Referenced from: /.eslintrc.json
at JSON.stringify ()
at /node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2255:45
at Array.map ()
at ConfigValidator.formatErrors (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2246:23)
at ConfigValidator.validateConfigSchema (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2277:84)
at ConfigArrayFactory._normalizeConfigData (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3123:19)
at ConfigArrayFactory._loadConfigData (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3088:21)
at ConfigArrayFactory._loadExtendedShareableConfig (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3393:21)
at ConfigArrayFactory._loadExtends (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3261:25)
at ConfigArrayFactory._normalizeObjectConfigDataBody (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3199:25)
(node:2) ESLintRCWarning: You are using an eslintrc configuration file, which is deprecated and support will be removed in v10.0.0. Please migrate to an eslint.config.js file. See https://eslint.org/docs/latest/use/configure/migration-guide for details. An eslintrc configuration file is used because you have the ESLINT_USE_FLAT_CONFIG environment variable set to false. If you want to use an eslint.config.js file, remove the environment variable. If you want to find the location of the eslintrc configuration file, use the --debug flag.
(Use node --trace-warnings ... to show where the warning was created)


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@heisbrot heisbrot marked this pull request as ready for review July 7, 2026 12:47

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between ac7d578 and 8abd8a8.

📒 Files selected for processing (7)
  • src/cloud/aws/AWSChoosePlan.tsx
  • src/cloud/distributor/hooks/useCustomerPlan.ts
  • src/cloud/msp/MSPTenantsTable.tsx
  • src/cloud/msp/hooks/useTenantPlan.ts
  • src/cloud/msp/table/TenantPlanCostCell.tsx
  • src/contexts/BillingProvider.tsx
  • src/modules/billing/PlansAndBillingTab.tsx

Comment thread src/cloud/aws/AWSChoosePlan.tsx
Comment thread src/contexts/BillingProvider.tsx Outdated
@heisbrot heisbrot merged commit 1f219c4 into main Jul 7, 2026
8 checks passed
@heisbrot heisbrot deleted the feature/eur-only-billing branch July 7, 2026 14:45
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.

3 participants