Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
fix(billing): show credit invoices as Credit and format negative amounts as -$X.XX (#8603)
Andrew Huangd26715d517c6
diff --git a/frontend/src/pages/organization/BillingV2Page/billing-v2-format.ts b/frontend/src/pages/organization/BillingV2Page/billing-v2-format.tsindex 0f5aa55465..03ef22d32f 100644--- a/frontend/src/pages/organization/BillingV2Page/billing-v2-format.ts+++ b/frontend/src/pages/organization/BillingV2Page/billing-v2-format.ts@@ -27,14 +27,16 @@ export const billingV2ErrorCode = (error: unknown): string | undefined =>? error.response?.data?.details?.code: undefined;-export const fmtMoney = (n: number, maximumFractionDigits = 0): string =>- `$${Number(n).toLocaleString("en-US", { maximumFractionDigits })}`;--// Whole dollars stay whole ("$408"); any fractional amount always shows cents ("$22.20", "$0.60").+// Negative amounts put the sign before the currency symbol ("-$8.70", not "$-8.70").+export const fmtMoney = (n: number, maximumFractionDigits = 0, minimumFractionDigits = 0): string =>+ `${n < 0 ? "-" : ""}$${Math.abs(Number(n)).toLocaleString("en-US", {+ minimumFractionDigits,+ maximumFractionDigits+ })}`;++// Whole dollars stay whole ("$408"); any fractional amount always shows cents ("$22.20", "-$8.70").export const fmtMoneyCents = (n: number): string =>- Number.isInteger(n)- ? fmtMoney(n)- : `$${Number(n).toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;+ Number.isInteger(n) ? fmtMoney(n) : fmtMoney(n, 2, 2);// Pluralize a singular dimension noun (the catalog's "noun" field) for display beside a count, since// a limit meter always reads as a plural quantity ("0 / 100 certificates"). Conservative: a noun thatdiff --git a/frontend/src/pages/organization/BillingV2Page/components/BillingSheets.tsx b/frontend/src/pages/organization/BillingV2Page/components/BillingSheets.tsxindex f463341f6d..5e4d4c8fc8 100644--- a/frontend/src/pages/organization/BillingV2Page/components/BillingSheets.tsx+++ b/frontend/src/pages/organization/BillingV2Page/components/BillingSheets.tsx@@ -184,11 +184,13 @@ export const InvoicesSheet = ({ overview, isOpen, onOpenChange }: SheetProps) =><TableCell>{inv.date}</TableCell><TableCell className="tabular-nums">{fmtMoneyCents(inv.amount)}</TableCell><TableCell>- {inv.paid ? (- <Badge variant="success">Paid</Badge>- ) : (- <Badge variant="danger">Unpaid</Badge>- )}+ {inv.amount < 0 && <Badge variant="neutral">Credit</Badge>}+ {inv.amount >= 0 &&+ (inv.paid ? (+ <Badge variant="success">Paid</Badge>+ ) : (+ <Badge variant="danger">Unpaid</Badge>+ ))}</TableCell><TableCell className="text-right">{inv.pdfUrl ? (diff --git a/frontend/src/pages/organization/BillingV2Page/components/TabbedOverview.tsx b/frontend/src/pages/organization/BillingV2Page/components/TabbedOverview.tsxindex eea9651288..4c710f734f 100644--- a/frontend/src/pages/organization/BillingV2Page/components/TabbedOverview.tsx+++ b/frontend/src/pages/organization/BillingV2Page/components/TabbedOverview.tsx@@ -342,10 +342,14 @@ export const TabbedOverview = ({<spanclassName={cn("truncate text-xs",- latestInvoice.paid ? "text-muted" : "text-danger"+ latestInvoice.paid || latestInvoice.amount < 0+ ? "text-muted"+ : "text-danger")}>- {latestInvoice.paid ? latestInvoice.date : "Unpaid"}+ {latestInvoice.paid || latestInvoice.amount < 0+ ? latestInvoice.date+ : "Unpaid"}</span></>) : (