Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

fix(billing): enforce en-US locale for billing money formatting (#7487) (#7498)

Vivek Maddheshiyafb0bffaa3198
diff --git a/frontend/editor/src/portal/billing/sharedBillingFormat.test.ts b/frontend/editor/src/portal/billing/sharedBillingFormat.test.ts
index d7ccd22df7..03c0998e34 100644
--- a/frontend/editor/src/portal/billing/sharedBillingFormat.test.ts
+++ b/frontend/editor/src/portal/billing/sharedBillingFormat.test.ts
@@ -3,6 +3,7 @@ import {
currencySymbol,
docCapForMoney,
formatMinor,
+ formatMoneyMajor,
formatPeriodDate,
meterState,
} from "@app/billing";
@@ -86,6 +87,13 @@ describe("formatMinor", () => {
});
});
+describe("formatMoneyMajor", () => {
+ it("formats major units with standard thousand separators and symbol", () => {
+ expect(formatMoneyMajor(1000, "usd")).toBe("$1,000");
+ expect(formatMoneyMajor(500, "eur")).toBe("€500");
+ });
+});
+
describe("formatPeriodDate", () => {
it("returns an empty string for null", () => {
expect(formatPeriodDate(null)).toBe("");
diff --git a/frontend/editor/src/proprietary/billing/format.ts b/frontend/editor/src/proprietary/billing/format.ts
index ff44e69882..3d6372ab6f 100644
--- a/frontend/editor/src/proprietary/billing/format.ts
+++ b/frontend/editor/src/proprietary/billing/format.ts
@@ -33,7 +33,7 @@ export function formatMinor(
minor: number,
currency: string | null | undefined,
): string {
- const num = new Intl.NumberFormat(undefined, {
+ const num = new Intl.NumberFormat("en-US", {
minimumFractionDigits: 2,
maximumFractionDigits: 3,
}).format(minor / 100);
@@ -45,7 +45,7 @@ export function formatMoneyMajor(
major: number,
currency: string | null | undefined,
): string {
- return `${currencySymbol(currency)}${major.toLocaleString()}`;
+ return `${currencySymbol(currency)}${major.toLocaleString("en-US")}`;
}
/**