From 32cd7d03176fabef9aa4484a25ce7435ab2c5b63 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Thu, 7 May 2026 14:07:37 +0530 Subject: [PATCH] fix: address billing estimation review feedback --- .../components/billing/estimatedTotalBox.svelte | 3 +++ .../components/organizationUsageLimits.svelte | 2 +- .../change-plan/+page.svelte | 16 +++++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/lib/components/billing/estimatedTotalBox.svelte b/src/lib/components/billing/estimatedTotalBox.svelte index bd02d4427..57f4b2f4c 100644 --- a/src/lib/components/billing/estimatedTotalBox.svelte +++ b/src/lib/components/billing/estimatedTotalBox.svelte @@ -17,6 +17,7 @@ export let isDowngrade = false; export let organizationId: string | undefined = undefined; export let estimationOverride: PlanChangeEstimate | null = null; + export let preferExternalEstimate = false; let budgetEnabled = false; let estimation: Models.Estimation | PlanChangeEstimate; @@ -103,6 +104,8 @@ $: if (estimationOverride) { estimation = estimationOverride; + } else if (preferExternalEstimate) { + estimation = undefined; } else if (organizationId) { getUpdatePlanEstimate(organizationId, billingPlan.$id, collaborators, couponData?.code); } else { diff --git a/src/lib/components/organizationUsageLimits.svelte b/src/lib/components/organizationUsageLimits.svelte index ca0b774e7..d4cec7abd 100644 --- a/src/lib/components/organizationUsageLimits.svelte +++ b/src/lib/components/organizationUsageLimits.svelte @@ -64,7 +64,7 @@ ]; } - return project.resources + return (project.resources ?? []) .filter((resource) => resource.status !== 'compliant' || resource.excess > 0) .map((resource) => ({ id: `${project.$id}-${resource.type}`, diff --git a/src/routes/(console)/organization-[organization]/change-plan/+page.svelte b/src/routes/(console)/organization-[organization]/change-plan/+page.svelte index 50ea81a19..9e3483e7f 100644 --- a/src/routes/(console)/organization-[organization]/change-plan/+page.svelte +++ b/src/routes/(console)/organization-[organization]/change-plan/+page.svelte @@ -211,6 +211,10 @@ } } + const additionalInviteEmails = $derived(getAdditionalInvites()); + const additionalInviteSignature = $derived(additionalInviteEmails.join(',')); + const selectedCouponCode = $derived(selectedCoupon?.code ?? null); + async function handleSubmit() { if (isDowngrade) { await downgrade(); @@ -375,7 +379,12 @@ $: isUpgrade = selectedPlan.order > $currentPlan?.order; $: isDowngrade = selectedPlan.order < $currentPlan?.order; - $: if (data?.organization?.$id && selectedPlan?.$id) { + $: if ( + data?.organization?.$id && + selectedPlan?.$id && + additionalInviteSignature !== undefined && + selectedCouponCode !== undefined + ) { loadPlanChangeEstimate(); } @@ -383,7 +392,7 @@ if ($organization?.billingPlanId === selectedPlan.$id) return true; if (isDowngrade && selectedPlan.group === BillingPlanGroup.Starter && data.hasFreeOrgs) return true; - if (isDowngrade && selectedPlan.$id !== $organization?.billingPlanId) { + if (isDowngrade) { if (isLoadingPlanEstimate) return true; const limits = getPlanChangeLimits(); @@ -561,7 +570,8 @@ bind:couponData={selectedCoupon} bind:billingBudget organizationId={data.organization.$id} - estimationOverride={planChangeEstimate} /> + estimationOverride={planChangeEstimate} + preferExternalEstimate /> {:else if isSelfService} {/if}