[PM-40440] fix: Source upgrade cart total from server invoice preview#21902
[PM-40440] fix: Source upgrade cart total from server invoice preview#21902amorask-bitwarden wants to merge 6 commits into
Conversation
The change-plan dialog computed the cart total client-side and reapplied the org's customerDiscount to the target plan. When an org has an active price-migration schedule, the server surfaces the schedule's Phase 2 migration coupon as customerDiscount, so the dialog under-quoted the upgrade by the coupon percentage and rendered a bogus provider-discount line — even though confirming the upgrade releases the schedule and charges the full price. Render the invoice-preview Total the server already returns instead of recomputing it on the client, and remove the client-side discount rows. The server applies genuine customer-level discounts but not the schedule coupon, so the displayed total matches the actual charge in both the migration and real-discount cases.
…n's total Clears the server total synchronously when a new plan is selected so the summary falls back to the client estimate during the preview request, instead of briefly rendering the previously selected plan's total.
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE Reviewed the change-plan (upgrade) dialog fix that sources the cart total from the server invoice-preview Code Review DetailsNo findings. Notes from the review (no action required):
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #21902 +/- ##
==========================================
+ Coverage 52.03% 52.04% +0.01%
==========================================
Files 4098 4098
Lines 129737 129740 +3
Branches 20350 20350
==========================================
+ Hits 67514 67529 +15
+ Misses 57234 57206 -28
- Partials 4989 5005 +16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🎟️ Tracking
Resolves PM-40440
📔 Objective
The organization change-plan (upgrade) dialog computed the cart total on the client and re-applied the org's
customerDiscountpercentage to the newly selected plan. When an organization has an active price-migration schedule, the server surfaces the schedule's Phase 2 migration coupon ascustomerDiscount, so the dialog under-quoted the upgrade total by the coupon percentage (~20%) and rendered a misleading "provider discount" line. On confirm, the upgrade releases the schedule and drops the coupon, so the customer is charged the full price — the preview under-quoted them. (Display-only; no one was mischarged.)This change stops computing the total on the client for this dialog and instead renders the Stripe invoice-preview
Totalthe server already returns from the plan-change tax preview (estimatedTotal), falling back to the existing clienttotalgetter on error/first paint. The five client-side provider-discount rows and the now-deaddiscountPercentageFromSubfield andcalculateTotalAppliedDiscount()helper are removed. The server total applies genuine customer-level discounts but not the schedule coupon, so the quote is correct in both the migration and legitimate-discount cases.Depends on a companion
serverfix — should not merge alone. The server plan-change tax preview (PreviewOrganizationTaxCommand) drops Secrets Manager line items across a tier change (it looks up SM seat/service-account prices by the new plan's IDs against the current subscription). Until that lands, sourcing the total from the server would under-quote SM-enabled Teams→Enterprise upgrades. Being handled separately inserver.📸 Screenshots
serverPR: bitwarden/server#7995