From d0747b8d45c865ec9da70f93c94dff1c7fe769ca Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 30 Jan 2025 07:50:08 +0545 Subject: [PATCH] fix information on downgrade --- src/lib/components/billing/planExcess.svelte | 26 +++++++++---------- src/lib/stores/billing.ts | 15 +++++------ .../change-plan/+page.svelte | 9 +++++-- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/lib/components/billing/planExcess.svelte b/src/lib/components/billing/planExcess.svelte index 352f0b29b..35303bbde 100644 --- a/src/lib/components/billing/planExcess.svelte +++ b/src/lib/components/billing/planExcess.svelte @@ -17,7 +17,7 @@ import { abbreviateNumber } from '$lib/helpers/numbers'; import { formatNum } from '$lib/helpers/string'; import { onMount } from 'svelte'; - import type { OrganizationUsage } from '$lib/sdk/billing'; + import type { Aggregation } from '$lib/sdk/billing'; import { sdk } from '$lib/stores/sdk'; import { BillingPlan } from '$lib/constants'; import { tooltip } from '$lib/actions/tooltip'; @@ -33,16 +33,15 @@ executions?: number; members?: number; } = null; - let usage: OrganizationUsage = null; + let aggregation: Aggregation = null; let showExcess = false; onMount(async () => { - usage = await sdk.forConsole.billing.listUsage( + aggregation = await sdk.forConsole.billing.getAggregation( $organization.$id, - $organization.billingCurrentInvoiceDate, - new Date().toISOString() + $organization.billingAggregationId ); - excess = calculateExcess(usage, plan, members); + excess = calculateExcess(aggregation, plan); showExcess = Object.values(excess).some((value) => value > 0); }); @@ -50,14 +49,12 @@ {#if showExcess} - Your {tierToPlan($organization.billingPlan).name} plan subscription will end on {toLocaleDate( - $organization.billingNextInvoiceDate - )} + Your organization will switch to {tierToPlan(BillingPlan.FREE).name} plan. You will continue + to have access to {tierToPlan($organization.billingPlan).name} plan features until your billing + period ends on {toLocaleDate($organization.billingNextInvoiceDate)} - Following payment of your final invoice, your organization will switch to the {tierToPlan( - BillingPlan.FREE - ).name} plan. {#if excess?.members > 0}All team members except the owner will be removed on - that date.{/if} Service disruptions may occur unless resource usage is reduced. + {#if excess?.members > 0}All team members except the owner will be removed on that date.{/if} + Service disruptions may occur unless resource usage is reduced.