Skip to content

fix(licenses): show currency edits in plan previews - #2301

Open
charlietlamb wants to merge 2 commits into
mainfrom
charlie/licnese-limitation-fix
Open

fix(licenses): show currency edits in plan previews#2301
charlietlamb wants to merge 2 commits into
mainfrom
charlie/licnese-limitation-fix

Conversation

@charlietlamb

@charlietlamb charlietlamb commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • show added or removed catalog currencies in license save previews
  • preserve migration-compatible comparisons for existing subscriber snapshots
  • serialize currency-only license customizations through the dashboard and API

Verification

  • server and dashboard type checks
  • 28 focused unit/frontend tests
  • React Doctor: 100/100

The integration regression is included; its local run is blocked during setup by an invalid test secret before reaching the assertion.


Summary by cubic

Show currency changes in license plan previews and in the dashboard diff, and allow currency-only customizations to flow through the dashboard and API. Fixes missing visibility for added/removed additional_currencies on prices and item tiers.

  • Bug Fixes
    • Detect and include additional_currencies changes in diffPlanV1 (base price and item tiers) via includeCurrencyListChanges.
    • Thread currency diffs through preview/build/response and customize paths; dashboard plan diff now shows added/removed currency details.
    • Keep migration-safe comparisons for existing subscriber snapshots by opting into currency diffs only where needed.
    • Add focused unit and integration tests for currency previews and license customize utils.

Written for commit f69c2f0. Summary will update on new commits.

Review in cubic

Greptile Summary

This PR fixes the plan preview system to surface catalog currency additions and removals as visible changes, in addition to price-amount edits it already tracked. The core mechanism is a new includeCurrencyListChanges flag on diffPlanV1 that layers a strict additionalCurrencyListsEqual check on top of the existing migration-compatible additionalCurrenciesCompatible comparison, so callers that need a full diff can opt in without affecting snapshot-comparison paths used for migrations.

  • Bug fixes: Introduce additionalCurrencyListsEqual and itemCurrencyListsEqual helpers and wire them into all preview/diff call sites (diffPlanV1PreviewFields, getPlanResponse, buildPlanUpdatePreview, diffLicensePlanCustomize, productToLicenseCustomize) via the new opt-in flag.
  • Bug fixes: Update customizePlanV1DiffsEqual (used in variantCustomizeChanged) to also require full currency-list equality, so a currency-only change on a variant's customize no longer silently passes as "unchanged".
  • Improvements: Add focused unit and integration tests covering the added-currency case for both the base price and per-item currency lists.

Confidence Score: 5/5

Safe to merge. The change is additive — a new opt-in flag threads through all preview and customize-diff call sites, leaving migration-snapshot comparisons untouched.

All changed paths opt in to the stricter additionalCurrencyListsEqual check, and the pre-existing additionalCurrenciesCompatible logic used by migration snapshot comparisons is left intact. The customizePlanV1DiffsEqual update correctly expands variant-change detection. Unit tests cover the new currency-detection paths end-to-end; the integration test addition is structurally sound even though its local run is gated by a test-secret issue unrelated to the logic.

No files require special attention. The integration test in preview-parent-license-update.test.ts cannot yet run locally due to a test-secret setup issue noted in the PR, so its assertion remains unverified in CI.

Important Files Changed

Filename Overview
shared/utils/planV1Utils/diff/diffPlanV1.ts Core diff engine: adds additionalCurrencyListsEqual, itemCurrencyListsEqual, and the includeCurrencyListChanges flag; existing additionalCurrenciesCompatible (used in pricesEqual/tiersEqual) is left intact for migration-safe comparisons. customizePlanV1DiffsEqual gains an explicit currency-list equality check.
shared/utils/planV1Utils/diff/diffPlanV1PreviewFields.ts Both diffPlanV1ItemChanges and diffPlanV1PreviewFields now pass includeCurrencyListChanges: true, so currency-only changes appear in preview customize and price_change.
server/src/internal/licenses/actions/customize/toApiPlanLicenseWithCustomize.ts diffLicensePlanCustomize now passes includeCurrencyListChanges: true; license API response will include currency-only customizations.
vite/src/views/products/plan/components/plan-licenses/licenseCustomizeUtils.ts productToLicenseCustomize now detects currency-only edits and serializes them into the outgoing LicenseCustomize patch.
server/tests/integration/crud/plans/licenses/catalog-update/parent-plan/preview-parent-license-update.test.ts Integration test expanded with a currency-only preview assertion; PR notes the test is locally blocked by an invalid test secret before reaching the assertion, so it cannot be validated in CI.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[diffPlanV1 called] --> B{includeCurrencyListChanges?}
    B -- false --> C[pricesEqual uses additionalCurrenciesCompatible\nonly changed amounts on shared currencies trigger diff]
    B -- true --> D[pricesEqual AND additionalCurrencyListsEqual\nany add/remove/change triggers diff]
    C --> E[itemsEqual uses itemPricesEqual\nwhich uses additionalCurrenciesCompatible]
    D --> F[itemsEqual OR itemCurrencyListsEqual\ndetects currency-list changes on items too]
    E --> G[Returns DiffedCustomizePlanV1]
    F --> G
    G --> H{Caller}
    H -- migration snapshot compare --> I[pricesEqual / additionalCurrenciesCompatible\nno flag needed]
    H -- preview / customize diff --> J[includeCurrencyListChanges: true\ndiffPlanV1PreviewFields\ngetApiPlanDiff\ndiffLicensePlanCustomize\nproductToLicenseCustomize\ngetPlanResponse]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[diffPlanV1 called] --> B{includeCurrencyListChanges?}
    B -- false --> C[pricesEqual uses additionalCurrenciesCompatible\nonly changed amounts on shared currencies trigger diff]
    B -- true --> D[pricesEqual AND additionalCurrencyListsEqual\nany add/remove/change triggers diff]
    C --> E[itemsEqual uses itemPricesEqual\nwhich uses additionalCurrenciesCompatible]
    D --> F[itemsEqual OR itemCurrencyListsEqual\ndetects currency-list changes on items too]
    E --> G[Returns DiffedCustomizePlanV1]
    F --> G
    G --> H{Caller}
    H -- migration snapshot compare --> I[pricesEqual / additionalCurrenciesCompatible\nno flag needed]
    H -- preview / customize diff --> J[includeCurrencyListChanges: true\ndiffPlanV1PreviewFields\ngetApiPlanDiff\ndiffLicensePlanCustomize\nproductToLicenseCustomize\ngetPlanResponse]
Loading

Reviews (1): Last reviewed commit: "fix(licenses): 🐛 show currency edits in..." | Re-trigger Greptile

@capy-ai

capy-ai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Capy auto-review is paused for this organization because the usage-cycle auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews.

@vercel

vercel Bot commented Jul 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
checkout Ignored Ignored Jul 20, 2026 10:19am
landing-page Ignored Ignored Jul 20, 2026 10:19am

Request Review

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.

1 participant