From 5cedece659a6ab2eff1ddea840cf039839fb8175 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Mon, 1 Sep 2025 15:38:32 +0000 Subject: [PATCH] fix when downgrade --- .../billing/planSummary.svelte | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/routes/(console)/organization-[organization]/billing/planSummary.svelte b/src/routes/(console)/organization-[organization]/billing/planSummary.svelte index dd2a0c734..51c39a931 100644 --- a/src/routes/(console)/organization-[organization]/billing/planSummary.svelte +++ b/src/routes/(console)/organization-[organization]/billing/planSummary.svelte @@ -146,9 +146,14 @@ id: 'base-plan', expandable: false, cells: { - item: currentPlan?.price === 0 ? 'Free plan' : 'Base plan', + item: 'Base plan', usage: '', - price: formatCurrency(currentPlan?.price || 0) + price: formatCurrency( + Math.max( + (currentAggregation?.amount ?? currentPlan?.price ?? 0) - availableCredit, + 0 + ) + ) }, children: [] }; @@ -300,12 +305,12 @@ $: billingData = getBillingData(currentPlan, currentAggregation, $isSmallViewport); $: totalAmount = Math.max( - (currentAggregation?.amount || currentPlan?.price || 0) - availableCredit, + (currentAggregation?.amount ?? currentPlan?.price ?? 0) - availableCredit, 0 ); $: creditsApplied = Math.min( - currentAggregation?.amount || currentPlan?.price || 0, + currentAggregation?.amount ?? currentPlan?.price ?? 0, availableCredit ); @@ -314,7 +319,7 @@ {currentPlan.name} plan - {#if currentPlan?.price > 0} + {#if totalAmount > 0} Next payment of {formatCurrency(totalAmount)}