From dee3b530debaabfebae519b517eff22894d2a7bb Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 15 Jan 2025 09:33:57 +0000 Subject: [PATCH] fix summary --- src/lib/sdk/billing.ts | 4 +++- .../billing/+page.svelte | 1 + .../billing/planSummary.svelte | 18 ++++++++---------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts index d3078688c..0d0824561 100644 --- a/src/lib/sdk/billing.ts +++ b/src/lib/sdk/billing.ts @@ -171,10 +171,12 @@ export type Aggregation = { * Total amount of the invoice. */ amount: number; + additionalMembers: number; + /** * Price for additional members */ - additionalMembers: number; + additionalMemberAmount: number; /** * Total storage usage. */ diff --git a/src/routes/(console)/organization-[organization]/billing/+page.svelte b/src/routes/(console)/organization-[organization]/billing/+page.svelte index 25b35dc32..cc0fb72d1 100644 --- a/src/routes/(console)/organization-[organization]/billing/+page.svelte +++ b/src/routes/(console)/organization-[organization]/billing/+page.svelte @@ -123,6 +123,7 @@ creditList={data?.creditList} members={data?.members} currentPlan={data?.aggregationBillingPlan} + currentAggregation={data?.billingAggregation} currentInvoice={data?.billingInvoice} /> diff --git a/src/routes/(console)/organization-[organization]/billing/planSummary.svelte b/src/routes/(console)/organization-[organization]/billing/planSummary.svelte index a2b3f05ce..3d8a89c6d 100644 --- a/src/routes/(console)/organization-[organization]/billing/planSummary.svelte +++ b/src/routes/(console)/organization-[organization]/billing/planSummary.svelte @@ -5,7 +5,7 @@ import { toLocaleDate } from '$lib/helpers/date'; import { plansInfo, tierToPlan, upgradeURL } from '$lib/stores/billing'; import { organization } from '$lib/stores/organization'; - import type { CreditList, Invoice, Plan } from '$lib/sdk/billing'; + import type { Aggregation, CreditList, Invoice, Plan } from '$lib/sdk/billing'; import { abbreviateNumber, formatCurrency, formatNumberWithCommas } from '$lib/helpers/numbers'; import { humanFileSize } from '$lib/helpers/sizeConvertion'; import { BillingPlan } from '$lib/constants'; @@ -18,17 +18,16 @@ export let currentPlan: Plan; export let creditList: CreditList; export let currentInvoice: Invoice | undefined = undefined; + export let currentAggregation: Aggregation | undefined = undefined let showCancel: boolean = false; - const extraMembers = members.total > 1 ? members.total - 1 : 0; const availableCredit = creditList.available; const today = new Date(); const isTrial = new Date($organization?.billingStartDate).getTime() - today.getTime() > 0 && $plansInfo.get($organization.billingPlan)?.trialDays; const extraUsage = currentInvoice ? currentInvoice.amount - currentPlan?.price : 0; - const extraAddons = currentInvoice ? currentInvoice.usage?.length : 0; {#if $organization} @@ -64,7 +63,7 @@ Add-ons{extraMembers ? extraAddons + 1 : extraAddons} + >{currentAggregation.additionalMembers > 0 ? currentInvoice.usage.length + 1 : currentInvoice.usage.length}
@@ -78,7 +77,7 @@
    - {#if extraMembers} + {#if currentAggregation.additionalMembers}
  • @@ -86,15 +85,14 @@
    {formatCurrency( - extraMembers * - (currentPlan?.addons?.seats?.price ?? 0) + currentAggregation.additionalMemberAmount )}
    - {extraMembers} + {currentAggregation.additionalMembers}
  • @@ -102,10 +100,10 @@ {#if currentInvoice?.usage} {#each currentInvoice.usage as excess, i}
  • 0 ? 'u-padding-block-8' : 'u-padding-block-start-8'}" - class:u-sep-block-start={i > 0 || extraMembers}> + class:u-sep-block-start={i > 0 || currentAggregation.additionalMembers > 0}> {#if ['storage', 'bandwidth'].includes(excess.name)} {@const excessValue = humanFileSize( excess.value