The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(billing): prepaid credits in upcoming invoice (#45475)
Ignacio Dobronich27f31ef692b7
diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/BillingBreakdown.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/BillingBreakdown.tsxindex 9eeebc2b440..cf3b15f16db 100644--- a/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/BillingBreakdown.tsx+++ b/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/BillingBreakdown.tsx@@ -84,9 +84,8 @@ const BillingBreakdown = () => {</>) : (<>- Your upcoming invoice (excluding credits) will continue to update until the end of- your billing cycle on {billingCycleEnd.format('MMMM DD')}. For a more detailed- breakdown, visit the{' '}+ Your upcoming invoice will continue to update until the end of your billing cycle on{' '}+ {billingCycleEnd.format('MMMM DD')}. For a more detailed breakdown, visit the{' '}<InlineLink href={`/org/${orgSlug}/usage`}>usage page.</InlineLink></>)}diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/UpcomingInvoice.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/UpcomingInvoice.tsxindex 580cc1cbe61..0d75d521cd6 100644--- a/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/UpcomingInvoice.tsx+++ b/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/UpcomingInvoice.tsx@@ -60,8 +60,11 @@ export const UpcomingInvoice = ({ slug }: UpcomingInvoiceProps) => {// For non-platform customers, compute is broken down per project and contains a breakdown arrayconst computeItems =- upcomingInvoice?.lines?.filter((item) => item.description?.toLowerCase().includes('compute')) ||- []+ upcomingInvoice?.lines?.filter(+ (item) =>+ item.description?.toLowerCase().includes('compute') &&+ !item.description.startsWith('Compute Credits')+ ) || []const computeCreditsItem =upcomingInvoice?.lines?.find((item) => item.description.startsWith('Compute Credits')) ?? null@@ -90,6 +93,9 @@ export const UpcomingInvoice = ({ slug }: UpcomingInvoiceProps) => {).sort((a, b) => b.amount_before_discount - a.amount_before_discount) || []+ const prepaidCreditsItem =+ upcomingInvoice?.lines?.find((item) => item.item_name === 'Prepaid Credits') ?? null+const hasTax =upcomingInvoice?.tax_status === 'calculated' && (upcomingInvoice?.tax?.tax_amount ?? 0) > 0const taxFailed = upcomingInvoice?.tax_status === 'failed'@@ -283,6 +289,20 @@ export const UpcomingInvoice = ({ slug }: UpcomingInvoiceProps) => {</TableBody><TableFooter>+ {prepaidCreditsItem && (+ <TableRow>+ <TableCell className="py-2 px-0 flex items-center">+ <span className="mr-2">{prepaidCreditsItem.item_name}</span>+ <InfoTooltip className="max-w-xs">+ Prepaid credits purchased upfront, applied automatically against your+ invoice. Any remaining balance rolls over to the next billing cycle.+ </InfoTooltip>+ </TableCell>+ <TableCell className="text-right py-2 px-0" translate="no">+ {formatCurrency(prepaidCreditsItem.amount) ?? '-'}+ </TableCell>+ </TableRow>+ )}<TableRow><TableCell className="font-medium py-2 px-0 flex items-center"><span className="mr-2">Current Costs</span>@@ -299,75 +319,56 @@ export const UpcomingInvoice = ({ slug }: UpcomingInvoiceProps) => {<TableRow><TableCell className="font-medium py-2 px-0 flex items-center"><span className="mr-2">Projected Costs</span>- <InfoTooltip className="max-w-xs">- Projected costs at the end of the billing cycle. Includes predictable costs- for Compute Hours, IPv4, Custom Domain and Point-In-Time-Recovery, but no- costs for metrics like MAU, storage or function invocations. Final amounts- may vary depending on your usage.+ <InfoTooltip className="max-w-sm">+ <p className="mb-2">+ Projected costs at the end of the billing cycle. Includes predictable+ costs for Compute Hours, IPv4, Custom Domain and Point-In-Time-Recovery,+ but no costs for metrics like MAU, storage or function invocations. Final+ amounts may vary depending on your usage.+ </p>++ {hasTax && (+ <div className="mt-3 border-t border-muted pt-2 space-y-1">+ <div className="flex items-center justify-between gap-4 text-xs">+ <span>Subtotal</span>+ <span translate="no">+ {formatCurrency(upcomingInvoice.tax!.total_amount_excluding_tax)}+ </span>+ </div>+ <div className="flex items-center justify-between gap-4 text-xs">+ <span>+ Tax+ {upcomingInvoice.tax?.tax_rate_percentage != null &&+ ` (${upcomingInvoice.tax.tax_rate_percentage}%)`}+ </span>+ <span translate="no">+ {formatCurrency(upcomingInvoice.tax!.tax_amount)}+ </span>+ </div>+ <p className="text-foreground-lighter pt-1 text-xs">+ Estimated based on your organization's billing address. The final+ amount may be adjusted at the end of the billing cycle.+ </p>+ </div>+ )}++ {taxFailed && (+ <p className="mt-3 border-t border-muted pt-2 text-warning">+ We were unable to estimate tax for your organization. Please verify your+ billing address in your organization settings.+ </p>+ )}</InfoTooltip></TableCell><TableCell className="text-right font-medium py-2 px-0" translate="no">{formatCurrency(hasTax- ? upcomingInvoice.tax!.total_amount_excluding_tax+ ? upcomingInvoice.tax!.total_amount_including_tax: upcomingInvoice.amount_projected) ?? '-'}</TableCell></TableRow>)}-- {hasTax && (- <>- <TableRow>- <TableCell className="py-2 px-0">- <div className="flex items-center gap-1">- <span>Projected Tax</span>- <InfoTooltip>- Estimated tax- {upcomingInvoice?.tax?.tax_rate_percentage != null &&- ` at ${upcomingInvoice.tax.tax_rate_percentage}%`}{' '}- based on your organization's billing address. The final amount may be- adjusted at the end of the billing cycle.- </InfoTooltip>- </div>- </TableCell>- <TableCell className="text-right py-2 px-0" translate="no">- {formatCurrency(upcomingInvoice?.tax?.tax_amount) ?? '-'}- </TableCell>- </TableRow>- <TableRow>- <TableCell className="font-medium py-2 px-0 flex items-center">- <span className="mr-2">Projected Total</span>- <InfoTooltip>- Projected costs including applicable tax. The final amount may be adjusted- at the end of the billing cycle.- </InfoTooltip>- </TableCell>- <TableCell className="text-right font-medium py-2 px-0" translate="no">- {formatCurrency(upcomingInvoice?.tax!.total_amount_including_tax) ?? '-'}- </TableCell>- </TableRow>- </>- )}-- {taxFailed && (- <TableRow>- <TableCell className="py-2 px-0">- <div className="flex items-center gap-1">- <span>Projected Tax</span>- <InfoTooltip>- We were unable to estimate tax for your organization. Please verify your- billing address in your organization settings.- </InfoTooltip>- </div>- </TableCell>- <TableCell className="text-right py-2 px-0">- <div className="flex items-center justify-end gap-1">- <span className="text-warning">Could not be estimated</span>- </div>- </TableCell>- </TableRow>- )}</TableFooter></Table></div>