Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Handle zero-decimal currencies in currencyFormatter (#3090)

Steven Teya3a21c86e73b
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/commissions/client.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/commissions/client.tsx
index d07dd70c6c..5e10c36c1f 100644
--- a/apps/web/app/(ee)/admin.dub.co/(dashboard)/commissions/client.tsx
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/commissions/client.tsx
@@ -131,13 +131,13 @@ export default function CommissionsPageClient() {
id: "commissions",
header: "Commissions",
accessorKey: "commissions",
- cell: ({ row }) => currencyFormatter(row.original.commissions / 100),
+ cell: ({ row }) => currencyFormatter(row.original.commissions),
},
{
id: "fees",
header: "Fees",
accessorKey: "fees",
- cell: ({ row }) => currencyFormatter(row.original.fees / 100),
+ cell: ({ row }) => currencyFormatter(row.original.fees),
},
],
pagination,
@@ -244,7 +244,7 @@ export default function CommissionsPageClient() {
</p>
</div>
<p className="text-right font-medium text-neutral-900">
- {currencyFormatter(d.values[tab.id] / 100)}
+ {currencyFormatter(d.values[tab.id])}
</p>
</Fragment>
</div>
@@ -265,7 +265,7 @@ export default function CommissionsPageClient() {
/>
<YAxis
showGridLines
- tickFormat={(value) => currencyFormatter(value / 100)}
+ tickFormat={(value) => currencyFormatter(value)}
/>
</TimeSeriesChart>
) : (
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/components/user-info.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/components/user-info.tsx
index dbbe82ee60..9bb9830b8c 100644
--- a/apps/web/app/(ee)/admin.dub.co/(dashboard)/components/user-info.tsx
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/components/user-info.tsx
@@ -140,7 +140,7 @@ export default function UserInfo({ data }: { data: UserInfoProps }) {
</span>
<span className="text-neutral-500">
{item.isCurrency
- ? currencyFormatter(program[item.id] / 100)
+ ? currencyFormatter(program[item.id])
: nFormatter(program[item.id], { full: true })}
</span>
</div>
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/payouts/client.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/payouts/client.tsx
index 0ac500373b..fa885c1cc5 100644
--- a/apps/web/app/(ee)/admin.dub.co/(dashboard)/payouts/client.tsx
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/payouts/client.tsx
@@ -151,19 +151,19 @@ export default function PayoutsPageClient() {
id: "amount",
header: "Amount",
accessorKey: "amount",
- cell: ({ row }) => currencyFormatter(row.original.amount / 100),
+ cell: ({ row }) => currencyFormatter(row.original.amount),
},
{
id: "fee",
header: "Fee",
accessorKey: "fee",
- cell: ({ row }) => currencyFormatter(row.original.fee / 100),
+ cell: ({ row }) => currencyFormatter(row.original.fee),
},
{
id: "total",
header: "Total",
accessorKey: "total",
- cell: ({ row }) => currencyFormatter(row.original.total / 100),
+ cell: ({ row }) => currencyFormatter(row.original.total),
},
],
pagination,
@@ -269,7 +269,7 @@ export default function PayoutsPageClient() {
</p>
</div>
<p className="text-right font-medium text-neutral-900">
- {currencyFormatter(d.values.value / 100)}
+ {currencyFormatter(d.values.value)}
</p>
</Fragment>
</div>
@@ -280,7 +280,7 @@ export default function PayoutsPageClient() {
<XAxis maxTicks={5} tickFormat={dateFormatter} />
<YAxis
showGridLines
- tickFormat={(value) => currencyFormatter(value / 100)}
+ tickFormat={(value) => currencyFormatter(value)}
/>
</TimeSeriesChart>
) : (
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/revenue/client.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/revenue/client.tsx
index 7a287ed443..401d62e2f8 100644
--- a/apps/web/app/(ee)/admin.dub.co/(dashboard)/revenue/client.tsx
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/revenue/client.tsx
@@ -89,7 +89,7 @@ export default function RevenuePageClient() {
id: "revenue",
header: "Affiliate Revenue",
accessorKey: "revenue",
- cell: ({ row }) => currencyFormatter(row.original.saleAmount / 100),
+ cell: ({ row }) => currencyFormatter(row.original.saleAmount),
},
],
pagination,
diff --git a/apps/web/app/(ee)/api/cron/payouts/balance-available/route.ts b/apps/web/app/(ee)/api/cron/payouts/balance-available/route.ts
index 7b196408ca..4ac3bb996f 100644
--- a/apps/web/app/(ee)/api/cron/payouts/balance-available/route.ts
+++ b/apps/web/app/(ee)/api/cron/payouts/balance-available/route.ts
@@ -80,7 +80,7 @@ export async function POST(req: Request) {
);
return logAndRespond(
- `Pending balance found for partner ${partner.email} (${stripeAccount}): ${currencyFormatter(pendingBalance / 100, { currency })}. Scheduling another check in 1 hour...`,
+ `Pending balance found for partner ${partner.email} (${stripeAccount}): ${currencyFormatter(pendingBalance, { currency })}. Scheduling another check in 1 hour...`,
);
}
@@ -109,7 +109,7 @@ export async function POST(req: Request) {
);
console.log(
- `Stripe payout created for partner ${partner.email} (${stripeAccount}): ${stripePayout.id} (${currencyFormatter(stripePayout.amount / 100, { currency: stripePayout.currency })})`,
+ `Stripe payout created for partner ${partner.email} (${stripeAccount}): ${stripePayout.id} (${currencyFormatter(stripePayout.amount, { currency: stripePayout.currency })})`,
);
const transfers = await stripe.transfers.list({
diff --git a/apps/web/app/(ee)/api/cron/payouts/process/process-payouts.ts b/apps/web/app/(ee)/api/cron/payouts/process/process-payouts.ts
index 641ad00c76..ee74563c52 100644
--- a/apps/web/app/(ee)/api/cron/payouts/process/process-payouts.ts
+++ b/apps/web/app/(ee)/api/cron/payouts/process/process-payouts.ts
@@ -317,7 +317,7 @@ export async function processPayouts({
});
await log({
- message: `*${program.name}* just sent a payout of *${currencyFormatter(totalPayoutAmount / 100)}* :money_with_wings: \n\n Fees earned: *${currencyFormatter(totalFee / 100)} (${payoutFee * 100}%)* :money_mouth_face:`,
+ message: `*${program.name}* just sent a payout of *${currencyFormatter(totalPayoutAmount)}* :money_with_wings: \n\n Fees earned: *${currencyFormatter(totalFee)} (${payoutFee * 100}%)* :money_mouth_face:`,
type: "payouts",
});
diff --git a/apps/web/app/(ee)/api/cron/trigger-withdrawal/route.ts b/apps/web/app/(ee)/api/cron/trigger-withdrawal/route.ts
index 5362ea113a..7aff7868ff 100644
--- a/apps/web/app/(ee)/api/cron/trigger-withdrawal/route.ts
+++ b/apps/web/app/(ee)/api/cron/trigger-withdrawal/route.ts
@@ -43,11 +43,11 @@ export async function GET(req: Request) {
currentNetBalance - payoutsToBeSent - reservedBalance;
console.log({
- currentAvailableBalance: `${currencyFormatter(currentAvailableBalance / 100)}`,
- currentPendingBalance: `${currencyFormatter(currentPendingBalance / 100)}`,
- currentNetBalance: `${currencyFormatter(currentNetBalance / 100)}`,
- payoutsToBeSent: `${currencyFormatter(payoutsToBeSent / 100)}`,
- balanceToWithdraw: `${currencyFormatter(balanceToWithdraw / 100)}`,
+ currentAvailableBalance: `${currencyFormatter(currentAvailableBalance)}`,
+ currentPendingBalance: `${currencyFormatter(currentPendingBalance)}`,
+ currentNetBalance: `${currencyFormatter(currentNetBalance)}`,
+ payoutsToBeSent: `${currencyFormatter(payoutsToBeSent)}`,
+ balanceToWithdraw: `${currencyFormatter(balanceToWithdraw)}`,
});
if (balanceToWithdraw <= 0) {
@@ -62,7 +62,7 @@ export async function GET(req: Request) {
});
return logAndRespond(
- `Created payout: ${createdPayout.id} (${currencyFormatter(createdPayout.amount / 100)})`,
+ `Created payout: ${createdPayout.id} (${currencyFormatter(createdPayout.amount)})`,
);
} catch (error) {
return handleAndReturnErrorResponse(error);
diff --git a/apps/web/app/(ee)/app.dub.co/embed/referrals/activity.tsx b/apps/web/app/(ee)/app.dub.co/embed/referrals/activity.tsx
index 5637b06bb5..c628d29c8e 100644
--- a/apps/web/app/(ee)/app.dub.co/embed/referrals/activity.tsx
+++ b/apps/web/app/(ee)/app.dub.co/embed/referrals/activity.tsx
@@ -73,7 +73,7 @@ export function ReferralsEmbedActivity({
{nFormatter(value, { full: true })}{" "}
{subValue || subValue === 0 ? (
<span className="text-content-subtle text-xs">
- ({currencyFormatter(subValue / 100)})
+ ({currencyFormatter(subValue)})
</span>
) : null}
</span>
diff --git a/apps/web/app/(ee)/app.dub.co/embed/referrals/earnings-summary.tsx b/apps/web/app/(ee)/app.dub.co/embed/referrals/earnings-summary.tsx
index 8f28a33944..e59524eeb3 100644
--- a/apps/web/app/(ee)/app.dub.co/embed/referrals/earnings-summary.tsx
+++ b/apps/web/app/(ee)/app.dub.co/embed/referrals/earnings-summary.tsx
@@ -44,7 +44,7 @@ export function ReferralsEmbedEarningsSummary({
<div key={label} className="flex justify-between text-sm">
<span className="text-content-subtle font-medium">{label}</span>
<span className="text-content-default font-semibold">
- {currencyFormatter(value / 100)}
+ {currencyFormatter(value)}
</span>
</div>
))}
diff --git a/apps/web/app/(ee)/app.dub.co/embed/referrals/earnings.tsx b/apps/web/app/(ee)/app.dub.co/embed/referrals/earnings.tsx
index dd14e0a2f7..b452acc17e 100644
--- a/apps/web/app/(ee)/app.dub.co/embed/referrals/earnings.tsx
+++ b/apps/web/app/(ee)/app.dub.co/embed/referrals/earnings.tsx
@@ -62,7 +62,7 @@ export function ReferralsEmbedEarnings({ salesCount }: { salesCount: number }) {
id: "amount",
header: "Amount",
cell: ({ row }) => {
- return currencyFormatter(row.original.amount / 100);
+ return currencyFormatter(row.original.amount);
},
},
{
@@ -70,7 +70,7 @@ export function ReferralsEmbedEarnings({ salesCount }: { salesCount: number }) {
header: "Earnings",
accessorKey: "earnings",
cell: ({ row }) => {
- return currencyFormatter(row.original.earnings / 100);
+ return currencyFormatter(row.original.earnings);
},
},
{
diff --git a/apps/web/app/(ee)/app.dub.co/embed/referrals/leaderboard.tsx b/apps/web/app/(ee)/app.dub.co/embed/referrals/leaderboard.tsx
index 42b001fb22..8d76acdd11 100644
--- a/apps/web/app/(ee)/app.dub.co/embed/referrals/leaderboard.tsx
+++ b/apps/web/app/(ee)/app.dub.co/embed/referrals/leaderboard.tsx
@@ -83,7 +83,7 @@ export function ReferralsEmbedLeaderboard() {
id: "totalCommissions",
header: "Earnings",
cell: ({ row }) => {
- return currencyFormatter(row.original.totalCommissions / 100);
+ return currencyFormatter(row.original.totalCommissions);
},
},
],
diff --git a/apps/web/app/(ee)/app.dub.co/embed/referrals/links-list.tsx b/apps/web/app/(ee)/app.dub.co/embed/referrals/links-list.tsx
index 5a817798d1..eed56e0725 100644
--- a/apps/web/app/(ee)/app.dub.co/embed/referrals/links-list.tsx
+++ b/apps/web/app/(ee)/app.dub.co/embed/referrals/links-list.tsx
@@ -100,7 +100,7 @@ export function ReferralsEmbedLinksList({
header: "Sales",
minSize: 80,
maxSize: 100,
- cell: ({ row }) => currencyFormatter(row.original.saleAmount / 100),
+ cell: ({ row }) => currencyFormatter(row.original.saleAmount),
},
{
id: "actions",
diff --git a/apps/web/app/(ee)/app.dub.co/invoices/[invoiceId]/domain-renewal-invoice.tsx b/apps/web/app/(ee)/app.dub.co/invoices/[invoiceId]/domain-renewal-invoice.tsx
index 085dc8bd26..2dc1717cbc 100644
--- a/apps/web/app/(ee)/app.dub.co/invoices/[invoiceId]/domain-renewal-invoice.tsx
+++ b/apps/web/app/(ee)/app.dub.co/invoices/[invoiceId]/domain-renewal-invoice.tsx
@@ -73,15 +73,15 @@ export async function DomainRenewalInvoice({
const invoiceSummaryDetails = [
{
label: "Invoice amount",
- value: currencyFormatter(invoice.amount / 100),
+ value: currencyFormatter(invoice.amount),
},
{
label: `Platform fees (${Math.round((invoice.fee / invoice.amount) * 100)}%)`,
- value: `${currencyFormatter(invoice.fee / 100)}`,
+ value: `${currencyFormatter(invoice.fee)}`,
},
{
label: "Invoice total",
- value: currencyFormatter(invoice.total / 100),
+ value: currencyFormatter(invoice.total),
},
];
@@ -203,7 +203,7 @@ export async function DomainRenewalInvoice({
Total
</Text>
<Text style={tw("text-neutral-800 font-medium text-[16px]")}>
- {currencyFormatter(invoice.total / 100)}
+ {currencyFormatter(invoice.total)}
</Text>
</View>
</View>
@@ -232,7 +232,7 @@ export async function DomainRenewalInvoice({
>
<Text style={tw("w-[70%] p-2.5")}>{domain.slug}</Text>
<Text style={tw("w-[30%] p-2.5")}>
- {currencyFormatter(domain.renewalFee / 100)}
+ {currencyFormatter(domain.renewalFee)}
</Text>
</View>
))}
diff --git a/apps/web/app/(ee)/app.dub.co/invoices/[invoiceId]/partner-payout-invoice.tsx b/apps/web/app/(ee)/app.dub.co/invoices/[invoiceId]/partner-payout-invoice.tsx
index 1eeff7d803..b403c5579c 100644
--- a/apps/web/app/(ee)/app.dub.co/invoices/[invoiceId]/partner-payout-invoice.tsx
+++ b/apps/web/app/(ee)/app.dub.co/invoices/[invoiceId]/partner-payout-invoice.tsx
@@ -144,7 +144,7 @@ export async function PartnerPayoutInvoice({
const nonUsdTransactionDisplay =
chargeAmount && chargeCurrency && chargeCurrency !== "usd"
- ? ` (${currencyFormatter(chargeAmount / 100, {
+ ? ` (${currencyFormatter(chargeAmount, {
currency: chargeCurrency.toUpperCase(),
})})`
: "";
@@ -163,23 +163,23 @@ export async function PartnerPayoutInvoice({
const invoiceSummaryDetails = [
{
label: "Invoice amount",
- value: currencyFormatter(invoice.amount / 100),
+ value: currencyFormatter(invoice.amount),
},
{
label: `Platform fees (${Math.round(((invoice.fee - fastAchFee) / invoice.amount) * 100)}%)`,
- value: `${currencyFormatter((invoice.fee - fastAchFee) / 100)}`,
+ value: `${currencyFormatter(invoice.fee - fastAchFee)}`,
},
...(fastAchFee > 0
? [
{
label: "Fast ACH fees",
- value: currencyFormatter(fastAchFee / 100),
+ value: currencyFormatter(fastAchFee),
},
]
: []),
{
label: "Invoice total",
- value: `${currencyFormatter(invoice.total / 100)}${nonUsdTransactionDisplay}`,
+ value: `${currencyFormatter(invoice.total)}${nonUsdTransactionDisplay}`,
},
// if customer is in EU or AU, add VAT/GST reverse charge note
...(EU_CUSTOMER || AU_CUSTOMER
@@ -310,7 +310,7 @@ export async function PartnerPayoutInvoice({
Total
</Text>
<Text style={tw("text-neutral-800 font-medium text-[16px]")}>
- {currencyFormatter(invoice.total / 100)}
+ {currencyFormatter(invoice.total)}
</Text>
</View>
</View>
@@ -370,7 +370,7 @@ export async function PartnerPayoutInvoice({
)}
</Text>
<Text style={tw("w-1/6 p-3.5")}>
- {currencyFormatter(payout.amount / 100)}
+ {currencyFormatter(payout.amount)}
</Text>
</View>
))}
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/messages/[programSlug]/page-client.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/messages/[programSlug]/page-client.tsx
index 6290203616..af134b9c2f 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/messages/[programSlug]/page-client.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/messages/[programSlug]/page-client.tsx
@@ -425,7 +425,7 @@ function ProgramInfoPanel({
</span>
{value !== undefined ? (
<span className="text-content-emphasis text-sm font-medium">
- {currencyFormatter(value / 100)}
+ {currencyFormatter(value)}
</span>
) : (
<div className="h-5 w-12 animate-pulse rounded-md bg-neutral-200" />
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/partner-payout-details-sheet.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/partner-payout-details-sheet.tsx
index 6531fcc1a1..15db41e9dc 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/partner-payout-details-sheet.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/partner-payout-details-sheet.tsx
@@ -84,7 +84,7 @@ function PayoutDetailsSheetContent({ payout }: PayoutDetailsSheetProps) {
Amount: (
<div className="flex items-center gap-2">
- <strong>{currencyFormatter(payout.amount / 100)}</strong>
+ <strong>{currencyFormatter(payout.amount)}</strong>
{payout.mode === "external" && (
<Tooltip
@@ -166,7 +166,7 @@ function PayoutDetailsSheetContent({ payout }: PayoutDetailsSheetProps) {
{
id: "earnings",
header: "Earnings",
- cell: ({ row }) => currencyFormatter(row.original.earnings / 100),
+ cell: ({ row }) => currencyFormatter(row.original.earnings),
},
{
id: "type",
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-stats.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-stats.tsx
index dbe1b5a08d..188c5069eb 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-stats.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-stats.tsx
@@ -89,7 +89,7 @@ function PayoutStatsCard({
{error ? (
"-"
) : (
- <>{amount > 0 ? currencyFormatter(amount / 100) : "$0.00"}</>
+ <>{amount > 0 ? currencyFormatter(amount) : "$0.00"}</>
)}
</span>
{label === "Processed" && amount > 0 && (
@@ -203,7 +203,7 @@ export function PayoutStats() {
);
const processedPayoutAmountInUsd = currencyFormatter(
- payoutStatusMap?.processed?.amount / 100,
+ payoutStatusMap?.processed?.amount,
{
trailingZeroDisplay: "stripIfInteger",
},
@@ -220,20 +220,19 @@ export function PayoutStats() {
<strong className="text-black">{processedPayoutAmountInUsd}</strong>)
are below the minimum requirement of{" "}
<strong className="text-black">
- {currencyFormatter(MIN_WITHDRAWAL_AMOUNT_CENTS / 100, {
+ {currencyFormatter(MIN_WITHDRAWAL_AMOUNT_CENTS, {
trailingZeroDisplay: "stripIfInteger",
})}
</strong>
, you will be charged a fee of{" "}
<strong className="text-black">
- {currencyFormatter(BELOW_MIN_WITHDRAWAL_FEE_CENTS / 100)}
+ {currencyFormatter(BELOW_MIN_WITHDRAWAL_FEE_CENTS)}
</strong>{" "}
for this payout, which means you will receive{" "}
<strong className="text-black">
{currencyFormatter(
(payoutStatusMap?.processed?.amount -
- BELOW_MIN_WITHDRAWAL_FEE_CENTS) /
- 100,
+ BELOW_MIN_WITHDRAWAL_FEE_CENTS),
{ trailingZeroDisplay: "stripIfInteger" },
)}
</strong>
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-table.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-table.tsx
index d3b5588e04..b36c9a5ef3 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-table.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-table.tsx
@@ -221,7 +221,7 @@ export function PayoutTable() {
}
function AmountRowItem({ payout }: { payout: PartnerPayoutResponse }) {
- const display = currencyFormatter(payout.amount / 100);
+ const display = currencyFormatter(payout.amount);
if (
payout.status === PayoutStatus.pending &&
@@ -230,7 +230,7 @@ function AmountRowItem({ payout }: { payout: PartnerPayoutResponse }) {
return (
<Tooltip
content={`This program's minimum payout amount is ${currencyFormatter(
- payout.program.minPayoutAmount / 100,
+ payout.program.minPayoutAmount,
)}. This payout will be accrued and processed during the next payout period. [Learn more.](https://dub.co/help/article/receiving-payouts)`}
>
<span className="cursor-help truncate text-neutral-400 underline decoration-dotted underline-offset-2">
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-composite-chart.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-composite-chart.tsx
index 78de9361cb..efde71c407 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-composite-chart.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-composite-chart.tsx
@@ -179,7 +179,7 @@ export function EarningsCompositeChart() {
})}
</p>
<p className="text-right leading-none text-neutral-500">
- {currencyFormatter((d.values.total || 0) / 100)}
+ {currencyFormatter((d.values.total || 0))}
</p>
</div>
<div className="grid max-w-64 grid-cols-[minmax(0,1fr),min-content] gap-x-6 gap-y-2 px-4 py-3 text-xs">
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-table.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-table.tsx
index 02609e0899..d72e999bdb 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-table.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-table.tsx
@@ -165,7 +165,7 @@ export function EarningsTablePartner({ limit }: { limit?: number }) {
accessorKey: "amount",
cell: ({ row }) =>
row.original.amount
- ? currencyFormatter(row.original.amount / 100)
+ ? currencyFormatter(row.original.amount)
: "-",
},
]
@@ -202,7 +202,7 @@ export function EarningsTablePartner({ limit }: { limit?: number }) {
cell: ({ row }) => {
const commission = row.original;
- const earnings = currencyFormatter(commission.earnings / 100);
+ const earnings = currencyFormatter(commission.earnings);
if (commission.description) {
const reason =
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsx
index 4009780693..d5c6e213fe 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsx
@@ -252,7 +252,7 @@ const StatsBadge = memo(({ link }: { link: PartnerProfileLinkProps }) => {
/>
<span>
{tab === "sales"
- ? currencyFormatter(value / 100, {
+ ? currencyFormatter(value, {
trailingZeroDisplay: "stripIfInteger",
})
: nFormatter(value)}
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/payouts-card.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/payouts-card.tsx
index 5905d0eead..cee893dacc 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/payouts-card.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/payouts-card.tsx
@@ -64,7 +64,7 @@ export function PayoutsCard({ programId }: { programId?: string }) {
>
<div className="flex flex-col">
<span className="text-xs font-medium text-neutral-800">
- {currencyFormatter(payout.amount / 100)}
+ {currencyFormatter(payout.amount)}
</span>
<span className="text-[0.7rem] text-neutral-500">
{formatPeriod(payout)}
diff --git a/apps/web/app/(ee)/partners.dub.co/invoices/[payoutId]/route.tsx b/apps/web/app/(ee)/partners.dub.co/invoices/[payoutId]/route.tsx
index 8b2abb82dc..95eadb2264 100644
--- a/apps/web/app/(ee)/partners.dub.co/invoices/[payoutId]/route.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/invoices/[payoutId]/route.tsx
@@ -116,7 +116,7 @@ export const GET = withPartnerProfile(async ({ partner, params }) => {
label: "Payout amount",
value: (
<Text style={tw("text-neutral-800 w-2/3")}>
- {currencyFormatter(payout.amount / 100)}
+ {currencyFormatter(payout.amount)}
</Text>
),
},
diff --git a/apps/web/app/api/callback/plain/partner/route.ts b/apps/web/app/api/callback/plain/partner/route.ts
index 2e37e37213..3e1428015d 100644
--- a/apps/web/app/api/callback/plain/partner/route.ts
+++ b/apps/web/app/api/callback/plain/partner/route.ts
@@ -219,7 +219,7 @@ export async function POST(req: NextRequest) {
...partnerProfile.programs.flatMap(
({ program, createdAt, totalCommissions }) => [
plainUsageSection({
- usage: currencyFormatter(totalCommissions / 100),
+ usage: currencyFormatter(totalCommissions),
label: program.name,
sublabel: `Partner since ${formatDate(createdAt)}`,
color: "GREEN",
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/analytics-partners-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/analytics-partners-table.tsx
index 0a52f83562..cf34e188d8 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/analytics-partners-table.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/analytics-partners-table.tsx
@@ -101,7 +101,7 @@ export function AnalyticsPartnersTable() {
{
id: "saleAmount",
header: "Revenue",
- accessorFn: (d) => currencyFormatter(d.saleAmount / 100),
+ accessorFn: (d) => currencyFormatter(d.saleAmount),
},
]
: [
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx
index f5136d958d..ab0f47e58f 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx
@@ -243,13 +243,13 @@ export function BountySubmissionsTable() {
const target = performanceCondition.value;
const formattedValue = isCurrencyAttribute(attribute)
- ? currencyFormatter(value / 100, {
+ ? currencyFormatter(value, {
trailingZeroDisplay: "stripIfInteger",
})
: nFormatter(value, { full: true });
const formattedTarget = isCurrencyAttribute(attribute)
- ? currencyFormatter(target / 100, {
+ ? currencyFormatter(target, {
trailingZeroDisplay: "stripIfInteger",
})
: nFormatter(target, { full: true });
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/campaigns/[campaignId]/transactional-campaign-logic.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/campaigns/[campaignId]/transactional-campaign-logic.tsx
index 73af656ce6..a2fbd0b19f 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/campaigns/[campaignId]/transactional-campaign-logic.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/campaigns/[campaignId]/transactional-campaign-logic.tsx
@@ -148,7 +148,7 @@ function ValueInput({
return (
<InlineBadgePopover
text={
- value ? (isCurrency ? currencyFormatter(value / 100) : value) : "amount"
+ value ? (isCurrency ? currencyFormatter(value) : value) : "amount"
}
invalid={!value}
>
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/commission-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/commission-table.tsx
index e25e104695..088cdf04c5 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/commission-table.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/commission-table.tsx
@@ -151,7 +151,7 @@ const CommissionTableInner = memo(
header: "Amount",
accessorFn: (d) =>
d.type === "sale"
- ? currencyFormatter(d.amount / 100)
+ ? currencyFormatter(d.amount)
: nFormatter(d.quantity),
},
{
@@ -160,7 +160,7 @@ const CommissionTableInner = memo(
cell: ({ row }) => {
const commission = row.original;
- const earnings = currencyFormatter(commission.earnings / 100);
+ const earnings = currencyFormatter(commission.earnings);
if (commission.description) {
const reason =
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/create-commission-sheet.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/create-commission-sheet.tsx
index 8f78902d95..7e3df03b74 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/create-commission-sheet.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/create-commission-sheet.tsx
@@ -240,7 +240,7 @@ function CreateCommissionSheetContent({
cell: ({ row }) => (
<span className="text-sm text-neutral-700">
{row.original.sale?.amount
- ? currencyFormatter(row.original.sale.amount / 100)
+ ? currencyFormatter(row.original.sale.amount)
: "-"}
</span>
),
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/groups-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/groups-table.tsx
index 73f1967aec..7fee23cbe0 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/groups-table.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/groups-table.tsx
@@ -136,17 +136,17 @@ export function GroupsTable() {
{
id: "totalSaleAmount",
header: "Revenue",
- accessorFn: (d) => currencyFormatter(d.totalSaleAmount / 100),
+ accessorFn: (d) => currencyFormatter(d.totalSaleAmount),
},
{
id: "totalCommissions",
header: "Commissions",
- accessorFn: (d) => currencyFormatter(d.totalCommissions / 100),
+ accessorFn: (d) => currencyFormatter(d.totalCommissions),
},
{
id: "netRevenue",
header: "Net Revenue",
- accessorFn: (d) => currencyFormatter(d.netRevenue / 100),
+ accessorFn: (d) => currencyFormatter(d.netRevenue),
},
{
id: "menu",
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/[partnerId]/links/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/[partnerId]/links/page-client.tsx
index b2a0fe0b1c..a1c03043ff 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/[partnerId]/links/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/[partnerId]/links/page-client.tsx
@@ -117,7 +117,7 @@ const PartnerLinks = ({ partner }: { partner: EnrolledPartnerProps }) => {
{
header: "Revenue",
accessorFn: (d) =>
- currencyFormatter(d.saleAmount / 100, {
+ currencyFormatter(d.saleAmount, {
trailingZeroDisplay: "stripIfInteger",
}),
size: 1,
@@ -128,7 +128,7 @@ const PartnerLinks = ({ partner }: { partner: EnrolledPartnerProps }) => {
target="_blank"
className="block w-full cursor-alias decoration-dotted hover:underline"
>
- {currencyFormatter(row.original.saleAmount / 100, {
+ {currencyFormatter(row.original.saleAmount, {
trailingZeroDisplay: "stripIfInteger",
})}
</Link>
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/[partnerId]/partner-stats.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/[partnerId]/partner-stats.tsx
index 63f193c99c..8e8d533f3a 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/[partnerId]/partner-stats.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/[partnerId]/partner-stats.tsx
@@ -64,7 +64,7 @@ export function PartnerStats({
value: partner
? Number.isNaN(partner.totalSaleAmount)
? "-"
- : currencyFormatter((partner.totalSaleAmount ?? 0) / 100, {
+ : currencyFormatter((partner.totalSaleAmount ?? 0), {
trailingZeroDisplay: "stripIfInteger",
})
: error
@@ -79,7 +79,7 @@ export function PartnerStats({
value: partner
? Number.isNaN(partner.totalCommissions)
? "-"
- : currencyFormatter((partner.totalCommissions ?? 0) / 100)
+ : currencyFormatter((partner.totalCommissions ?? 0))
: error
? "-"
: undefined,
@@ -92,7 +92,7 @@ export function PartnerStats({
value: partner
? Number.isNaN(partner.netRevenue)
? "-"
- : currencyFormatter((partner.netRevenue ?? 0) / 100)
+ : currencyFormatter((partner.netRevenue ?? 0))
: error
? "-"
: undefined,
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/[partnerId]/payouts/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/[partnerId]/payouts/page-client.tsx
index a935f44cca..14abbd1834 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/[partnerId]/payouts/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/[partnerId]/payouts/page-client.tsx
@@ -75,7 +75,7 @@ function PartnerPayouts({ partner }: { partner: EnrolledPartnerProps }) {
cell: ({ row }) => {
return (
<div className="flex items-center gap-1.5">
- {currencyFormatter(row.original.amount / 100)}
+ {currencyFormatter(row.original.amount)}
{row.original.mode === "external" && (
<CircleArrowRight className="size-3.5 shrink-0" />
)}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/partners-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/partners-table.tsx
index c3a40276e6..1aee1a41c0 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/partners-table.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/partners-table.tsx
@@ -271,17 +271,17 @@ export function PartnersTable() {
{
id: "totalSaleAmount",
header: "Revenue",
- accessorFn: (d) => currencyFormatter(d.totalSaleAmount / 100),
+ accessorFn: (d) => currencyFormatter(d.totalSaleAmount),
},
{
id: "totalCommissions",
header: "Commissions",
- accessorFn: (d) => currencyFormatter(d.totalCommissions / 100),
+ accessorFn: (d) => currencyFormatter(d.totalCommissions),
},
{
id: "netRevenue",
header: "Net Revenue",
- accessorFn: (d) => currencyFormatter(d.netRevenue / 100),
+ accessorFn: (d) => currencyFormatter(d.netRevenue),
},
// Menu
{
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-details-sheet.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-details-sheet.tsx
index ccba54741a..e0a94cf886 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-details-sheet.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-details-sheet.tsx
@@ -83,7 +83,7 @@ function PayoutDetailsSheetContent({ payout }: PayoutDetailsSheetProps) {
</StatusBadge>
),
- Total: currencyFormatter(payout.amount / 100),
+ Total: currencyFormatter(payout.amount),
...(payout.invoiceId && {
Invoice: (
@@ -162,7 +162,7 @@ function PayoutDetailsSheetContent({ payout }: PayoutDetailsSheetProps) {
minSize: 100,
size: 120,
maxSize: 150,
- cell: ({ row }) => currencyFormatter(row.original.earnings / 100),
+ cell: ({ row }) => currencyFormatter(row.original.earnings),
},
// Menu
{
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-stats.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-stats.tsx
index fe0a953df7..adf99c72f9 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-stats.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-stats.tsx
@@ -128,7 +128,7 @@ export function PayoutStats() {
{display}
</div>
<div className="text-sm text-neutral-500">
- {currencyFormatter(amount / 100, {})}
+ {currencyFormatter(amount, {})}
</div>
</div>
))}
@@ -138,9 +138,7 @@ export function PayoutStats() {
>
<span className="underline decoration-dotted underline-offset-2">
{currencyFormatter(
- eligiblePendingPayouts?.amount
- ? eligiblePendingPayouts.amount / 100
- : 0,
+ eligiblePendingPayouts?.amount ?? 0,
{},
) + " USD"}
</span>
@@ -190,7 +188,7 @@ export function PayoutStats() {
{display}
</div>
<div className="text-sm text-neutral-500">
- {currencyFormatter(amount / 100, {})}
+ {currencyFormatter(amount, {})}
</div>
</div>
))}
@@ -199,7 +197,7 @@ export function PayoutStats() {
}
>
<span className="underline decoration-dotted underline-offset-2">
- {currencyFormatter(totalPaid / 100, {}) + " USD"}
+ {currencyFormatter(totalPaid, {}) + " USD"}
</span>
</Tooltip>
)}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-table.tsx
index 15f428bc96..e9ceed9461 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-table.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-table.tsx
@@ -304,7 +304,7 @@ function AmountRowItem({
const { program } = useProgram();
const minPayoutAmount = program?.minPayoutAmount || 0;
- const display = currencyFormatter(payout.amount / 100);
+ const display = currencyFormatter(payout.amount);
if (payout.status === PayoutStatus.pending) {
if (payout.amount < minPayoutAmount) {
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/success/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/success/page-client.tsx
index 6c828b88db..b1ad68f8a2 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/success/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/success/page-client.tsx
@@ -84,7 +84,7 @@ export function PayoutsSuccessPageClient() {
}
// Convert total from cents to dollars
- const amountPaid = currencyFormatter(invoice.amount / 100);
+ const amountPaid = currencyFormatter(invoice.amount);
// this can be zero in the beginning, so maybe we can add a loading state for the partner count,
// while we keep calling mutate() for the invoice SWR above?
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/page-client.tsx
index 727c169cad..31af6587c7 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/page-client.tsx
@@ -158,7 +158,7 @@ const InvoiceCard = ({
<div className="font-medium">Total</div>
<div className="flex items-center gap-1.5 text-neutral-500">
<span className="text-sm font-medium">
- {currencyFormatter(invoice.total / 100)}
+ {currencyFormatter(invoice.total)}
</span>
{invoice.status &&
(() => {
@@ -217,7 +217,7 @@ const InvoiceCard = ({
<div className="font-medium">Total</div>
<div className="flex items-center gap-1.5 text-neutral-500">
<span className="text-sm font-medium">
- {currencyFormatter(invoice.total / 100)}
+ {currencyFormatter(invoice.total)}
</span>
{invoice.status &&
(() => {
diff --git a/apps/web/lib/analytics/convert-currency.ts b/apps/web/lib/analytics/convert-currency.ts
index 1404c8a7e4..f738e5fdcf 100644
--- a/apps/web/lib/analytics/convert-currency.ts
+++ b/apps/web/lib/analytics/convert-currency.ts
@@ -1,24 +1,6 @@
+import { isZeroDecimalCurrency } from "@dub/utils";
import { redis } from "../upstash/redis";
-export const ZERO_DECIMAL_CURRENCIES = [
- "BIF",
- "CLP",
- "DJF",
- "GNF",
- "JPY",
- "KMF",
- "KRW",
- "MGA",
- "PYG",
- "RWF",
- "UGX",
- "VND",
- "VUV",
- "XAF",
- "XOF",
- "XPF",
-];
-
export const convertCurrency = async ({
currency,
amount,
@@ -27,8 +9,6 @@ export const convertCurrency = async ({
amount: number;
}) => {
const currencyCode = currency.toUpperCase();
- const isZeroDecimalCurrency = ZERO_DECIMAL_CURRENCIES.includes(currencyCode);
-
const fxRate = await redis.hget("fxRates:usd", currencyCode); // e.g. for MYR it'll be around 4.4
// if the FX rate is not found, we return the original amount
@@ -43,7 +23,7 @@ export const convertCurrency = async ({
let convertedAmount = amount / Number(fxRate);
// if the currency is a zero decimal currency, we need to multiply the converted amount by 100
- if (isZeroDecimalCurrency) {
+ if (isZeroDecimalCurrency(currencyCode)) {
convertedAmount = convertedAmount * 100;
}
@@ -64,8 +44,6 @@ export const convertCurrencyWithFxRates = ({
fxRates: Record<string, string>;
}) => {
const currencyCode = currency.toUpperCase();
- const isZeroDecimalCurrency = ZERO_DECIMAL_CURRENCIES.includes(currencyCode);
-
const fxRate = fxRates[currencyCode];
// if the FX rate is not found, we return the original amount
@@ -80,7 +58,7 @@ export const convertCurrencyWithFxRates = ({
let convertedAmount = amount / Number(fxRate);
// if the currency is a zero decimal currency, we need to multiply the converted amount by 100
- if (isZeroDecimalCurrency) {
+ if (isZeroDecimalCurrency(currencyCode)) {
convertedAmount = convertedAmount * 100;
}
diff --git a/apps/web/lib/api/bounties/generate-performance-bounty-name.ts b/apps/web/lib/api/bounties/generate-performance-bounty-name.ts
index f334ce8190..35ddaac95a 100644
--- a/apps/web/lib/api/bounties/generate-performance-bounty-name.ts
+++ b/apps/web/lib/api/bounties/generate-performance-bounty-name.ts
@@ -14,8 +14,8 @@ export const generatePerformanceBountyName = ({
const attributeLabel =
PERFORMANCE_BOUNTY_SCOPE_ATTRIBUTES[condition.attribute];
const valueFormatted = isCurrency
- ? `${currencyFormatter(condition.value / 100, { trailingZeroDisplay: "stripIfInteger" })} in`
+ ? `${currencyFormatter(condition.value, { trailingZeroDisplay: "stripIfInteger" })} in`
: `${nFormatter(condition.value, { full: true })}`;
- return `Earn ${currencyFormatter(rewardAmount / 100, { trailingZeroDisplay: "stripIfInteger" })} after generating ${valueFormatted} ${attributeLabel.toLowerCase()}`;
+ return `Earn ${currencyFormatter(rewardAmount, { trailingZeroDisplay: "stripIfInteger" })} after generating ${valueFormatted} ${attributeLabel.toLowerCase()}`;
};
diff --git a/apps/web/lib/api/errors.ts b/apps/web/lib/api/errors.ts
index 408dec5c9e..b20ab70ca9 100644
--- a/apps/web/lib/api/errors.ts
+++ b/apps/web/lib/api/errors.ts
@@ -245,7 +245,7 @@ export const exceededLimitError = ({
["links", "AI", "payouts"].includes(type) ? "monthly" : ""
} limit of ${
type === "payouts"
- ? currencyFormatter(limit / 100)
+ ? currencyFormatter(limit)
: `${limit} ${limit === 1 ? type.slice(0, -1) : type}`
} on the ${capitalize(plan)} plan. Please upgrade for higher limits.`;
};
diff --git a/apps/web/lib/api/sales/construct-discount-amount.ts b/apps/web/lib/api/sales/construct-discount-amount.ts
index 7d5c64a34f..997defecdc 100644
--- a/apps/web/lib/api/sales/construct-discount-amount.ts
+++ b/apps/web/lib/api/sales/construct-discount-amount.ts
@@ -6,7 +6,7 @@ export const constructDiscountAmount = (
) => {
return discount.type === "percentage"
? `${discount.amount}%`
- : currencyFormatter(discount.amount / 100, {
+ : currencyFormatter(discount.amount, {
trailingZeroDisplay: "stripIfInteger",
});
};
diff --git a/apps/web/lib/api/sales/construct-reward-amount.ts b/apps/web/lib/api/sales/construct-reward-amount.ts
index 5c16cd0031..438cbbe771 100644
--- a/apps/web/lib/api/sales/construct-reward-amount.ts
+++ b/apps/web/lib/api/sales/construct-reward-amount.ts
@@ -59,7 +59,7 @@ export const constructRewardAmount = (
return `Up to ${
reward.type === "percentage"
? `${max}%`
- : currencyFormatter(max / 100, {
+ : currencyFormatter(max, {
trailingZeroDisplay: "stripIfInteger",
})
}`;
@@ -73,7 +73,7 @@ export const constructRewardAmount = (
// 2. type AND timelines doesn't match the primary reward
return reward.type === "percentage"
? `${reward.amountInPercentage}%`
- : currencyFormatter((reward.amountInCents ?? 0) / 100, {
+ : currencyFormatter((reward.amountInCents ?? 0), {
trailingZeroDisplay: "stripIfInteger",
});
};
diff --git a/apps/web/lib/integrations/slack/transform.ts b/apps/web/lib/integrations/slack/transform.ts
index 852d709a5b..05dae1a6ee 100644
--- a/apps/web/lib/integrations/slack/transform.ts
+++ b/apps/web/lib/integrations/slack/transform.ts
@@ -314,8 +314,8 @@ const commissionCreatedTemplate = ({
}) => {
const { id, amount, earnings, currency, partner, customer } = data;
- const formattedAmount = currencyFormatter(amount / 100, { currency });
- const formattedEarnings = currencyFormatter(earnings / 100, { currency });
+ const formattedAmount = currencyFormatter(amount, { currency });
+ const formattedEarnings = currencyFormatter(earnings, { currency });
const linkToCommissions = `${APP_DOMAIN}/program/commissions`;
return {
@@ -478,7 +478,7 @@ const payoutConfirmedTemplate = ({
data: PayoutEventWebhookPayload;
}) => {
const { id, amount, currency, partner, invoiceId } = data;
- const formattedAmount = currencyFormatter(amount / 100, { currency });
+ const formattedAmount = currencyFormatter(amount, { currency });
const linkToPayout = `${APP_DOMAIN}/program/payouts?payoutId=${id}`;
return {
diff --git a/apps/web/lib/partners/create-partner-commission.ts b/apps/web/lib/partners/create-partner-commission.ts
index 9c8b2d63b8..d35c3bb184 100644
--- a/apps/web/lib/partners/create-partner-commission.ts
+++ b/apps/web/lib/partners/create-partner-commission.ts
@@ -264,7 +264,7 @@ export const createPartnerCommission = async ({
});
console.log(
- `Created a ${event} commission ${commission.id} (${currencyFormatter(commission.earnings / 100, { currency: commission.currency })}) for ${partnerId}: ${JSON.stringify(commission)}`,
+ `Created a ${event} commission ${commission.id} (${currencyFormatter(commission.earnings, { currency: commission.currency })}) for ${partnerId}: ${JSON.stringify(commission)}`,
);
const webhookPartner = constructWebhookPartner(programEnrollment, {
diff --git a/apps/web/lib/partners/create-stripe-transfer.ts b/apps/web/lib/partners/create-stripe-transfer.ts
index adf2dfc178..7bef1df4ae 100644
--- a/apps/web/lib/partners/create-stripe-transfer.ts
+++ b/apps/web/lib/partners/create-stripe-transfer.ts
@@ -73,7 +73,7 @@ export const createStripeTransfer = async ({
}
console.log(
- `Total processed payouts (${currencyFormatter(totalTransferableAmount / 100)}) for partner ${partner.id} are below ${currencyFormatter(MIN_WITHDRAWAL_AMOUNT_CENTS / 100)}, skipping...`,
+ `Total processed payouts (${currencyFormatter(totalTransferableAmount)}) for partner ${partner.id} are below ${currencyFormatter(MIN_WITHDRAWAL_AMOUNT_CENTS)}, skipping...`,
);
// skip creating a transfer
@@ -89,7 +89,7 @@ export const createStripeTransfer = async ({
if (finalTransferableAmount <= 0) {
console.log(
- `Final transferable amount after deducting withdrawal fee (${currencyFormatter(finalTransferableAmount / 100)}) is less than or equal to 0, skipping...`,
+ `Final transferable amount after deducting withdrawal fee (${currencyFormatter(finalTransferableAmount)}) is less than or equal to 0, skipping...`,
);
return;
@@ -122,7 +122,7 @@ export const createStripeTransfer = async ({
);
console.log(
- `Transfer of ${currencyFormatter(finalTransferableAmount / 100)} (${transfer.id}) created for partner ${partner.id} for ${pluralize(
+ `Transfer of ${currencyFormatter(finalTransferableAmount)} (${transfer.id}) created for partner ${partner.id} for ${pluralize(
"payout",
allPayouts.length,
)} ${allPayouts.map((p) => p.id).join(", ")}`,
diff --git a/apps/web/lib/partners/get-bounty-reward-description.ts b/apps/web/lib/partners/get-bounty-reward-description.ts
index 211700aa2b..772ebebb18 100644
--- a/apps/web/lib/partners/get-bounty-reward-description.ts
+++ b/apps/web/lib/partners/get-bounty-reward-description.ts
@@ -5,7 +5,7 @@ export function getBountyRewardDescription(
bounty: Pick<BountyProps, "rewardAmount" | "rewardDescription">,
) {
if (bounty.rewardAmount) {
- const formattedAmount = currencyFormatter(bounty.rewardAmount / 100, {
+ const formattedAmount = currencyFormatter(bounty.rewardAmount, {
trailingZeroDisplay: "stripIfInteger",
});
diff --git a/apps/web/lib/partners/get-discoverability-requirements.ts b/apps/web/lib/partners/get-discoverability-requirements.ts
index 4f812e46e9..de7e89a070 100644
--- a/apps/web/lib/partners/get-discoverability-requirements.ts
+++ b/apps/web/lib/partners/get-discoverability-requirements.ts
@@ -58,7 +58,7 @@ export function getDiscoverabilityRequirements({
completed: Boolean(partner.salesChannels?.length),
},
{
- label: `Earn ${currencyFormatter(PARTNER_DISCOVERY_MIN_COMMISSIONS / 100, { trailingZeroDisplay: "stripIfInteger" })} in commissions`,
+ label: `Earn ${currencyFormatter(PARTNER_DISCOVERY_MIN_COMMISSIONS, { trailingZeroDisplay: "stripIfInteger" })} in commissions`,
completed:
programEnrollments.filter(
(pe) =>
diff --git a/apps/web/lib/stripe/create-payment-intent.ts b/apps/web/lib/stripe/create-payment-intent.ts
index 6e97f1afa6..35c0b75ed2 100644
--- a/apps/web/lib/stripe/create-payment-intent.ts
+++ b/apps/web/lib/stripe/create-payment-intent.ts
@@ -58,7 +58,7 @@ export const createPaymentIntent = async ({
);
console.log(
- `Payment intent ${paymentIntent.id} created ${invoiceId ? `for invoice ${invoiceId} ` : ""}with amount ${currencyFormatter(paymentIntent.amount / 100)}`,
+ `Payment intent ${paymentIntent.id} created ${invoiceId ? `for invoice ${invoiceId} ` : ""}with amount ${currencyFormatter(paymentIntent.amount)}`,
);
return { paymentIntent, paymentMethod };
diff --git a/apps/web/lib/webhook/sample-events/partner-enrolled.json b/apps/web/lib/webhook/sample-events/partner-enrolled.json
index 9cea417709..97d5c62021 100644
--- a/apps/web/lib/webhook/sample-events/partner-enrolled.json
+++ b/apps/web/lib/webhook/sample-events/partner-enrolled.json
@@ -13,6 +13,7 @@
"paypalEmail": null,
"stripeConnectId": null,
"payoutsEnabledAt": null,
+ "trustedAt": null,
"createdAt": "2025-02-07T17:58:18.793Z",
"clicks": 0,
"leads": 0,
diff --git a/apps/web/scripts/stripe/fix-processed-payouts.ts b/apps/web/scripts/stripe/fix-processed-payouts.ts
index 3b2ab77fef..92c168d25a 100644
--- a/apps/web/scripts/stripe/fix-processed-payouts.ts
+++ b/apps/web/scripts/stripe/fix-processed-payouts.ts
@@ -34,7 +34,7 @@ async function main() {
`Found ${partnersWithProcessedPayouts.length} partners with processed payouts`,
);
console.log(
- `Total amount: ${currencyFormatter(partnersWithProcessedPayouts.reduce((acc, partner) => acc + (partner._sum.amount ?? 0), 0) / 100)}`,
+ `Total amount: ${currencyFormatter(partnersWithProcessedPayouts.reduce((acc, partner) => acc + (partner._sum.amount ?? 0), 0))}`,
);
console.table(partnersWithProcessedPayouts.slice(0, 10));
@@ -74,7 +74,7 @@ async function main() {
continue;
}
console.log(
- `Creating stripe transfer for partner ${previouslyProcessedPayouts[0].partner.email} with ${previouslyProcessedPayouts.length} payouts (total amount: ${currencyFormatter(previouslyProcessedPayouts.reduce((acc, p) => acc + p.amount, 0) / 100)})`,
+ `Creating stripe transfer for partner ${previouslyProcessedPayouts[0].partner.email} with ${previouslyProcessedPayouts.length} payouts (total amount: ${currencyFormatter(previouslyProcessedPayouts.reduce((acc, p) => acc + p.amount, 0))})`,
);
await createStripeTransfer({
partner: previouslyProcessedPayouts[0].partner,
diff --git a/apps/web/ui/analytics/events/events-table.tsx b/apps/web/ui/analytics/events/events-table.tsx
index bcfdd58f62..507e21cfa0 100644
--- a/apps/web/ui/analytics/events/events-table.tsx
+++ b/apps/web/ui/analytics/events/events-table.tsx
@@ -205,7 +205,7 @@ export default function EventsTable({
cell: ({ getValue }) => (
<div className="flex items-center gap-2">
<span>
- {currencyFormatter(getValue() / 100, {
+ {currencyFormatter(getValue(), {
trailingZeroDisplay: "stripIfInteger",
})}
</span>
diff --git a/apps/web/ui/analytics/use-analytics-filters.tsx b/apps/web/ui/analytics/use-analytics-filters.tsx
index 6cc628e975..69a8cbc9e2 100644
--- a/apps/web/ui/analytics/use-analytics-filters.tsx
+++ b/apps/web/ui/analytics/use-analytics-filters.tsx
@@ -313,7 +313,7 @@ export function useAnalyticsFilters({
const getFilterOptionTotal = useCallback(
({ count, saleAmount }: { count?: number; saleAmount?: number }) => {
return selectedTab === "sales" && saleUnit === "saleAmount" && saleAmount
- ? currencyFormatter(saleAmount / 100)
+ ? currencyFormatter(saleAmount)
: nFormatter(count, { full: true });
},
[selectedTab, saleUnit],
diff --git a/apps/web/ui/customers/customer-details-column.tsx b/apps/web/ui/customers/customer-details-column.tsx
index 9f6546d5fd..01270361ef 100644
--- a/apps/web/ui/customers/customer-details-column.tsx
+++ b/apps/web/ui/customers/customer-details-column.tsx
@@ -165,7 +165,7 @@ export function CustomerDetailsColumn({
) : (
<span>
{customerActivity?.ltv !== undefined
- ? currencyFormatter(customerActivity.ltv / 100, {
+ ? currencyFormatter(customerActivity.ltv, {
trailingZeroDisplay: "stripIfInteger",
})
: "-"}
diff --git a/apps/web/ui/customers/customer-partner-earnings-table.tsx b/apps/web/ui/customers/customer-partner-earnings-table.tsx
index 0c31688b28..550faf82ac 100644
--- a/apps/web/ui/customers/customer-partner-earnings-table.tsx
+++ b/apps/web/ui/customers/customer-partner-earnings-table.tsx
@@ -34,14 +34,14 @@ export function CustomerPartnerEarningsTable({
header: "Sale Amount",
accessorKey: "amount",
cell: ({ getValue }) => (
- <span>{currencyFormatter(getValue() / 100)}</span>
+ <span>{currencyFormatter(getValue())}</span>
),
},
{
header: "Commission",
accessorKey: "earnings",
cell: ({ getValue }) => (
- <span>{currencyFormatter(getValue() / 100)}</span>
+ <span>{currencyFormatter(getValue())}</span>
),
},
{
diff --git a/apps/web/ui/customers/customer-sales-table.tsx b/apps/web/ui/customers/customer-sales-table.tsx
index 438220e644..b6b4a658ff 100644
--- a/apps/web/ui/customers/customer-sales-table.tsx
+++ b/apps/web/ui/customers/customer-sales-table.tsx
@@ -59,7 +59,7 @@ export function CustomerSalesTable({
header: "Amount",
accessorFn: (d) => ("saleAmount" in d ? d.saleAmount : d.amount),
cell: ({ getValue }) => (
- <span>{currencyFormatter(getValue() / 100)}</span>
+ <span>{currencyFormatter(getValue())}</span>
),
},
...(sales?.length && "earnings" in sales?.[0]
@@ -68,7 +68,7 @@ export function CustomerSalesTable({
header: "Earnings",
accessorKey: "earnings",
cell: ({ getValue }) => (
- <span>{currencyFormatter(getValue() / 100)}</span>
+ <span>{currencyFormatter(getValue())}</span>
),
},
{
diff --git a/apps/web/ui/customers/customer-table/customer-table.tsx b/apps/web/ui/customers/customer-table/customer-table.tsx
index a0954713ec..fdbe801ce8 100644
--- a/apps/web/ui/customers/customer-table/customer-table.tsx
+++ b/apps/web/ui/customers/customer-table/customer-table.tsx
@@ -161,7 +161,7 @@ export function CustomerTable() {
cell: ({ getValue }) => (
<div className="flex items-center gap-2">
<span>
- {currencyFormatter(getValue() / 100, {
+ {currencyFormatter(getValue(), {
trailingZeroDisplay: "stripIfInteger",
})}
</span>
diff --git a/apps/web/ui/links/link-analytics-badge.tsx b/apps/web/ui/links/link-analytics-badge.tsx
index baf2159c57..e4f2604406 100644
--- a/apps/web/ui/links/link-analytics-badge.tsx
+++ b/apps/web/ui/links/link-analytics-badge.tsx
@@ -105,7 +105,7 @@ export function LinkAnalyticsBadge({
<div key={tab} className="text-sm leading-none">
<span className="font-medium text-neutral-950">
{tab === "sales"
- ? currencyFormatter(value / 100, {
+ ? currencyFormatter(value, {
trailingZeroDisplay: "stripIfInteger",
})
: nFormatter(value, { full: value < INFINITY_NUMBER })}
@@ -169,7 +169,7 @@ export function LinkAnalyticsBadge({
/>
<span>
{tab === "sales"
- ? currencyFormatter(value / 100, {
+ ? currencyFormatter(value, {
// @ts-ignore – trailingZeroDisplay is a valid option but TS is outdated
trailingZeroDisplay: "stripIfInteger",
})
diff --git a/apps/web/ui/links/link-builder/link-partner-details.tsx b/apps/web/ui/links/link-builder/link-partner-details.tsx
index f5e0a56c08..6817a4b6df 100644
--- a/apps/web/ui/links/link-builder/link-partner-details.tsx
+++ b/apps/web/ui/links/link-builder/link-partner-details.tsx
@@ -61,18 +61,18 @@ export function LinkPartnerDetails({
[
"Revenue",
partner
- ? currencyFormatter(partner.totalSaleAmount / 100)
+ ? currencyFormatter(partner.totalSaleAmount)
: undefined,
],
[
"Commissions",
partner
- ? currencyFormatter(partner.totalCommissions / 100)
+ ? currencyFormatter(partner.totalCommissions)
: undefined,
],
[
"Net revenue",
- partner ? currencyFormatter(partner.netRevenue / 100) : undefined,
+ partner ? currencyFormatter(partner.netRevenue) : undefined,
],
].map(([label, value]) => (
<div key={label} className="flex flex-col gap-1 px-4 py-3">
diff --git a/apps/web/ui/modals/domain-auto-renewal-modal.tsx b/apps/web/ui/modals/domain-auto-renewal-modal.tsx
index 2df374c51b..94e81b6b1a 100644
--- a/apps/web/ui/modals/domain-auto-renewal-modal.tsx
+++ b/apps/web/ui/modals/domain-auto-renewal-modal.tsx
@@ -88,12 +88,12 @@ function DomainAutoRenewalModal({
Your domain is currently set to expire on{" "}
<strong>{formatDate(expiresAt)}</strong>. By enabling
auto-renewal, Dub will automatically renew your domain for{" "}
- <strong>{currencyFormatter(renewalFee / 100)}</strong>.
+ <strong>{currencyFormatter(renewalFee)}</strong>.
</>
) : (
<>
Dub will automatically renew your domain for{" "}
- <strong>{currencyFormatter(renewalFee / 100)}</strong>. By
+ <strong>{currencyFormatter(renewalFee)}</strong>. By
disabling auto-renewal, your domain <strong>{domain.slug}</strong>{" "}
will expire on <strong>{formatDate(expiresAt)}</strong>.
<br />
diff --git a/apps/web/ui/modals/import-rewardful-modal.tsx b/apps/web/ui/modals/import-rewardful-modal.tsx
index 3f1f379fab..f3734deb69 100644
--- a/apps/web/ui/modals/import-rewardful-modal.tsx
+++ b/apps/web/ui/modals/import-rewardful-modal.tsx
@@ -16,7 +16,7 @@ import {
useMediaQuery,
useRouterStuff,
} from "@dub/ui";
-import { cn, fetcher } from "@dub/utils";
+import { cn, currencyFormatter, fetcher } from "@dub/utils";
import { Command } from "cmdk";
import { ArrowRight, ServerOff, Users } from "lucide-react";
import { useAction } from "next-safe-action/hooks";
@@ -328,7 +328,7 @@ function CampaignsStep({
const formatCommission = useCallback((campaign: RewardfulCampaign) => {
return campaign.reward_type === "percent"
? `${campaign.commission_percent}%`
- : `$${(campaign.commission_amount_cents / 100).toFixed(2)}`;
+ : `${currencyFormatter(campaign.commission_amount_cents)}`;
}, []);
const sortCampaigns = useCallback(
diff --git a/apps/web/ui/partners/bounties/bounty-performance.tsx b/apps/web/ui/partners/bounties/bounty-performance.tsx
index e398ae734e..ee34485c40 100644
--- a/apps/web/ui/partners/bounties/bounty-performance.tsx
+++ b/apps/web/ui/partners/bounties/bounty-performance.tsx
@@ -18,11 +18,11 @@ export function BountyPerformance({ bounty }: { bounty: PartnerBountyProps }) {
value === undefined
? "-"
: isCurrencyAttribute(attribute)
- ? currencyFormatter(value / 100)
+ ? currencyFormatter(value)
: nFormatter(value, { full: true });
const formattedTarget = isCurrencyAttribute(attribute)
- ? currencyFormatter(target / 100)
+ ? currencyFormatter(target)
: nFormatter(target, { full: true });
const metricLabel =
diff --git a/apps/web/ui/partners/commission-status-badges.tsx b/apps/web/ui/partners/commission-status-badges.tsx
index 3e4e68c7e2..7759c6d8be 100644
--- a/apps/web/ui/partners/commission-status-badges.tsx
+++ b/apps/web/ui/partners/commission-status-badges.tsx
@@ -34,7 +34,7 @@ export const CommissionStatusBadges = {
className: "text-blue-600 bg-blue-100",
icon: CircleHalfDottedClock,
tooltip: (data: CommissionTooltipDataProps) => {
- const title = `This commission has been processed and ${data.variant === "partner" && data.program?.minPayoutAmount ? `will be paid out once your payout total reaches the program's minimum payout amount of ${currencyFormatter(data.program?.minPayoutAmount / 100)}` : "is now eligible for payout"}.`;
+ const title = `This commission has been processed and ${data.variant === "partner" && data.program?.minPayoutAmount ? `will be paid out once your payout total reaches the program's minimum payout amount of ${currencyFormatter(data.program?.minPayoutAmount)}` : "is now eligible for payout"}.`;
const cta =
data.variant === "partner" ? "Learn more." : "View pending payouts.";
const href =
diff --git a/apps/web/ui/partners/confirm-payouts-sheet.tsx b/apps/web/ui/partners/confirm-payouts-sheet.tsx
index b3c757c44c..71ea5d817f 100644
--- a/apps/web/ui/partners/confirm-payouts-sheet.tsx
+++ b/apps/web/ui/partners/confirm-payouts-sheet.tsx
@@ -215,7 +215,7 @@ function ConfirmPayoutsSheetContent() {
label: method.title,
icon: method.icon,
...(method.fastSettlement && {
- meta: `+ ${currencyFormatter(FAST_ACH_FEE_CENTS / 100, { trailingZeroDisplay: "stripIfInteger" })}`,
+ meta: `+ ${currencyFormatter(FAST_ACH_FEE_CENTS, { trailingZeroDisplay: "stripIfInteger" })}`,
}),
}));
}, [finalPaymentMethods]);
@@ -418,7 +418,7 @@ function ConfirmPayoutsSheetContent() {
amount === undefined ? (
<div className="h-4 w-24 animate-pulse rounded-md bg-neutral-200" />
) : (
- currencyFormatter(amount / 100)
+ currencyFormatter(amount)
),
},
...(finalEligiblePayouts && finalEligiblePayouts.some(isExternalPayout)
@@ -430,7 +430,7 @@ function ConfirmPayoutsSheetContent() {
<div className="h-4 w-24 animate-pulse rounded-md bg-neutral-200" />
) : (
<div className="flex items-center gap-1.5">
- {currencyFormatter(externalAmount / 100)}
+ {currencyFormatter(externalAmount)}
<CircleArrowRight className="size-3.5 text-neutral-500" />
</div>
),
@@ -442,12 +442,12 @@ function ConfirmPayoutsSheetContent() {
key: "Fee",
value:
selectedPaymentMethod && fee !== undefined ? (
- currencyFormatter(fee / 100)
+ currencyFormatter(fee)
) : (
<div className="h-4 w-24 animate-pulse rounded-md bg-neutral-200" />
),
tooltipContent: selectedPaymentMethod
- ? `${selectedPaymentMethod.fee * 100}% processing fee${(fastAchFee ?? 0) > 0 ? ` + ${currencyFormatter((fastAchFee ?? 0) / 100)} Fast ACH fee` : ""}. ${!DIRECT_DEBIT_PAYMENT_METHOD_TYPES.includes(selectedPaymentMethod.type as Stripe.PaymentMethod.Type) ? " Switch to Direct Debit for a reduced fee." : ""} [Learn more](https://d.to/payouts)`
+ ? `${selectedPaymentMethod.fee * 100}% processing fee${(fastAchFee ?? 0) > 0 ? ` + ${currencyFormatter(fastAchFee ?? 0)} Fast ACH fee` : ""}. ${!DIRECT_DEBIT_PAYMENT_METHOD_TYPES.includes(selectedPaymentMethod.type as Stripe.PaymentMethod.Type) ? " Switch to Direct Debit for a reduced fee." : ""} [Learn more](https://d.to/payouts)`
: undefined,
},
{
@@ -464,7 +464,7 @@ function ConfirmPayoutsSheetContent() {
total === undefined ? (
<div className="h-4 w-24 animate-pulse rounded-md bg-neutral-200" />
) : (
- currencyFormatter(total / 100)
+ currencyFormatter(total)
),
},
];
@@ -511,7 +511,7 @@ function ConfirmPayoutsSheetContent() {
excludedPayoutIds.includes(row.original.id) && "line-through",
)}
>
- {currencyFormatter(row.original.amount / 100)}
+ {currencyFormatter(row.original.amount)}
</span>
{!selectedPayoutId && (
@@ -667,7 +667,7 @@ function ConfirmPayoutsSheetContent() {
}}
text={
amount && amount > 0
- ? `Hold to confirm ${currencyFormatter(amount / 100)} payout`
+ ? `Hold to confirm ${currencyFormatter(amount)} payout`
: "Hold to confirm payout"
}
disabled={
diff --git a/apps/web/ui/partners/mark-commission-duplicate-modal.tsx b/apps/web/ui/partners/mark-commission-duplicate-modal.tsx
index 542d3711dc..21761d9517 100644
--- a/apps/web/ui/partners/mark-commission-duplicate-modal.tsx
+++ b/apps/web/ui/partners/mark-commission-duplicate-modal.tsx
@@ -79,10 +79,10 @@ function ModalInner({
Amount:
commission.type === "sale"
- ? currencyFormatter(commission.amount / 100)
+ ? currencyFormatter(commission.amount)
: nFormatter(commission.quantity),
- Commission: currencyFormatter(commission.earnings / 100),
+ Commission: currencyFormatter(commission.earnings),
Status: (
<StatusBadge icon={null} variant={badge.variant}>
diff --git a/apps/web/ui/partners/mark-commission-fraud-or-canceled-modal.tsx b/apps/web/ui/partners/mark-commission-fraud-or-canceled-modal.tsx
index cab7a6ab52..4e27fa1f34 100644
--- a/apps/web/ui/partners/mark-commission-fraud-or-canceled-modal.tsx
+++ b/apps/web/ui/partners/mark-commission-fraud-or-canceled-modal.tsx
@@ -86,10 +86,10 @@ function ModalInner({
Amount:
commission.type === "sale"
- ? currencyFormatter(commission.amount / 100)
+ ? currencyFormatter(commission.amount)
: nFormatter(commission.quantity),
- Commission: currencyFormatter(commission.earnings / 100),
+ Commission: currencyFormatter(commission.earnings),
Status: (
<StatusBadge icon={null} variant={badge.variant}>
diff --git a/apps/web/ui/partners/overview/blocks/commissions-block.tsx b/apps/web/ui/partners/overview/blocks/commissions-block.tsx
index ca171f8e9b..0a1e2474ac 100644
--- a/apps/web/ui/partners/overview/blocks/commissions-block.tsx
+++ b/apps/web/ui/partners/overview/blocks/commissions-block.tsx
@@ -67,7 +67,7 @@ export function CommissionsBlock() {
</StatusBadge>
<span className="min-w-12 text-right">
- {currencyFormatter(earnings / 100)}
+ {currencyFormatter(earnings)}
</span>
</div>
</div>
diff --git a/apps/web/ui/partners/overview/blocks/countries-block.tsx b/apps/web/ui/partners/overview/blocks/countries-block.tsx
index 1d1a005b47..4792d6b0f3 100644
--- a/apps/web/ui/partners/overview/blocks/countries-block.tsx
+++ b/apps/web/ui/partners/overview/blocks/countries-block.tsx
@@ -86,7 +86,7 @@ export function CountriesBlock() {
<span>
{program?.primaryRewardEvent === "lead"
? nFormatter(leads, { full: true })
- : currencyFormatter(saleAmount / 100)}
+ : currencyFormatter(saleAmount)}
</span>
</Link>
))
diff --git a/apps/web/ui/partners/overview/blocks/links-block.tsx b/apps/web/ui/partners/overview/blocks/links-block.tsx
index ae90450918..1c0ff10a9e 100644
--- a/apps/web/ui/partners/overview/blocks/links-block.tsx
+++ b/apps/web/ui/partners/overview/blocks/links-block.tsx
@@ -92,7 +92,7 @@ export function LinksBlock() {
<span>
{program?.primaryRewardEvent === "lead"
? nFormatter(leads, { full: true })
- : currencyFormatter(saleAmount / 100)}
+ : currencyFormatter(saleAmount)}
</span>
</Link>
))
diff --git a/apps/web/ui/partners/overview/blocks/partners-block.tsx b/apps/web/ui/partners/overview/blocks/partners-block.tsx
index 61f4c01593..8f9f640dea 100644
--- a/apps/web/ui/partners/overview/blocks/partners-block.tsx
+++ b/apps/web/ui/partners/overview/blocks/partners-block.tsx
@@ -78,7 +78,7 @@ export function PartnersBlock() {
<span>
{program?.primaryRewardEvent === "lead"
? nFormatter(partner.leads, { full: true })
- : currencyFormatter(partner.saleAmount / 100)}
+ : currencyFormatter(partner.saleAmount)}
</span>
</Link>
))
diff --git a/apps/web/ui/partners/overview/blocks/traffic-sources-block.tsx b/apps/web/ui/partners/overview/blocks/traffic-sources-block.tsx
index db05f7c72f..35eec654bb 100644
--- a/apps/web/ui/partners/overview/blocks/traffic-sources-block.tsx
+++ b/apps/web/ui/partners/overview/blocks/traffic-sources-block.tsx
@@ -99,7 +99,7 @@ export function TrafficSourcesBlock() {
<span>
{program?.primaryRewardEvent === "lead"
? nFormatter(leads, { full: true })
- : currencyFormatter(saleAmount / 100)}
+ : currencyFormatter(saleAmount)}
</span>
</Link>
))
diff --git a/apps/web/ui/partners/partner-info-stats.tsx b/apps/web/ui/partners/partner-info-stats.tsx
index c9bb0376fa..aad2e16405 100644
--- a/apps/web/ui/partners/partner-info-stats.tsx
+++ b/apps/web/ui/partners/partner-info-stats.tsx
@@ -44,7 +44,7 @@ export function PartnerInfoStats({
label: "Revenue",
value: Number.isNaN(partner.totalSaleAmount)
? "-"
- : currencyFormatter(partner.totalSaleAmount / 100, {
+ : currencyFormatter(partner.totalSaleAmount, {
trailingZeroDisplay: "stripIfInteger",
}),
href: `/${slug}/events?event=sales&partnerId=${partner.id}&interval=1y`,
@@ -53,14 +53,14 @@ export function PartnerInfoStats({
label: "Commissions",
value: Number.isNaN(partner.totalCommissions)
? "-"
- : currencyFormatter(partner.totalCommissions / 100),
+ : currencyFormatter(partner.totalCommissions),
href: `/${slug}/program/commissions?partnerId=${partner.id}`,
},
{
label: "Net revenue",
value: Number.isNaN(partner.netRevenue)
? "-"
- : currencyFormatter(partner.netRevenue / 100),
+ : currencyFormatter(partner.netRevenue),
href: `/${slug}/events?event=sales&partnerId=${partner.id}&interval=1y`,
},
].map(({ label, value, href }) => (
diff --git a/apps/web/ui/partners/payout-status-descriptions.ts b/apps/web/ui/partners/payout-status-descriptions.ts
index 222cc99eea..61f44c3d2f 100644
--- a/apps/web/ui/partners/payout-status-descriptions.ts
+++ b/apps/web/ui/partners/payout-status-descriptions.ts
@@ -7,7 +7,7 @@ export const PAYOUT_STATUS_DESCRIPTIONS = {
"Payouts that have passed the program's holding period and are awaiting payment from the program.",
processing:
"Payouts that are being processed by the program – this can take up to 5 business days.",
- processed: `Payouts that have been processed by the program and will be paid out to your connected bank account once they reach the minimum withdrawal amount of ${currencyFormatter(MIN_WITHDRAWAL_AMOUNT_CENTS / 100, { trailingZeroDisplay: "stripIfInteger" })}.`,
+ processed: `Payouts that have been processed by the program and will be paid out to your connected bank account once they reach the minimum withdrawal amount of ${currencyFormatter(MIN_WITHDRAWAL_AMOUNT_CENTS, { trailingZeroDisplay: "stripIfInteger" })}.`,
sent: "Payouts that are on their way to your connected bank account – this can take anywhere from 1 to 14 business days depending on your bank location.",
completed:
"Payouts that have been paid out to your connected bank account.",
diff --git a/apps/web/ui/partners/program-reward-modifiers-tooltip.tsx b/apps/web/ui/partners/program-reward-modifiers-tooltip.tsx
index 3b327f9979..b4e21f2a61 100644
--- a/apps/web/ui/partners/program-reward-modifiers-tooltip.tsx
+++ b/apps/web/ui/partners/program-reward-modifiers-tooltip.tsx
@@ -165,7 +165,7 @@ const RewardItem = ({
condition.attribute
] === "currency"
? // Currency value
- currencyFormatter(Number(condition.value) / 100)
+ currencyFormatter(Number(condition.value))
: // Everything else
condition.value.toString())}
</span>
diff --git a/apps/web/ui/partners/program-stats-filter.tsx b/apps/web/ui/partners/program-stats-filter.tsx
index d33f61fdee..adf692f9ca 100644
--- a/apps/web/ui/partners/program-stats-filter.tsx
+++ b/apps/web/ui/partners/program-stats-filter.tsx
@@ -73,7 +73,7 @@ export function ProgramStatsFilter({
{nFormatter(count, { full: true })}
</span>
<span className="text-xs font-medium text-neutral-500">
- {amount !== undefined && currencyFormatter(amount / 100)}
+ {amount !== undefined && currencyFormatter(amount)}
</span>
</>
)
diff --git a/packages/email/src/templates/connect-payout-reminder.tsx b/packages/email/src/templates/connect-payout-reminder.tsx
index 318c558c12..cdef3795af 100644
--- a/packages/email/src/templates/connect-payout-reminder.tsx
+++ b/packages/email/src/templates/connect-payout-reminder.tsx
@@ -96,7 +96,7 @@ export default function ConnectPayoutReminder({
</Row>
</Column>
<Column className="text-right text-sm">
- {currencyFormatter(program.amount / 100)}
+ {currencyFormatter(program.amount)}
</Column>
</Row>
))}
diff --git a/packages/email/src/templates/domain-renewal-reminder.tsx b/packages/email/src/templates/domain-renewal-reminder.tsx
index f36fe19a3f..0ec3a1aefa 100644
--- a/packages/email/src/templates/domain-renewal-reminder.tsx
+++ b/packages/email/src/templates/domain-renewal-reminder.tsx
@@ -69,7 +69,7 @@ export default function DomainRenewalReminder({
{formatDate(domain.expiresAt)}
</span>
. We will attempt to charge your card on file{" "}
- {currencyFormatter(domain.renewalFee / 100)} in{" "}
+ {currencyFormatter(domain.renewalFee)} in{" "}
{domain.chargeAtInText} on {formatDate(domain.chargeAt)}.
</Text>
diff --git a/packages/email/src/templates/new-commission-alert-partner.tsx b/packages/email/src/templates/new-commission-alert-partner.tsx
index b78f2954d3..05f63e77c8 100644
--- a/packages/email/src/templates/new-commission-alert-partner.tsx
+++ b/packages/email/src/templates/new-commission-alert-partner.tsx
@@ -43,7 +43,7 @@ export default function NewCommissionAlertPartner({
};
shortLink?: string | null;
}) {
- const earningsInDollars = currencyFormatter(commission.earnings / 100);
+ const earningsInDollars = currencyFormatter(commission.earnings);
const linkToEarnings = `https://partners.dub.co/programs/${program.slug}/earnings`;
return (
@@ -79,7 +79,7 @@ export default function NewCommissionAlertPartner({
<>
made a{" "}
<strong className="text-black">
- {currencyFormatter(commission.amount / 100)}
+ {currencyFormatter(commission.amount)}
</strong>{" "}
purchase
</>
diff --git a/packages/email/src/templates/new-sale-alert-program-owner.tsx b/packages/email/src/templates/new-sale-alert-program-owner.tsx
index db4bf3a3a2..74624441c7 100644
--- a/packages/email/src/templates/new-sale-alert-program-owner.tsx
+++ b/packages/email/src/templates/new-sale-alert-program-owner.tsx
@@ -66,12 +66,12 @@ export default function NewSaleAlertProgramOwner({
const salesLink = `https://app.dub.co/${workspace.slug}/program/commissions?partnerId=${partner.id}`;
const notificationPreferencesLink = `https://app.dub.co/${workspace.slug}/settings/notifications`;
- const saleAmountInDollars = currencyFormatter(commission.amount / 100);
+ const saleAmountInDollars = currencyFormatter(commission.amount);
- const earningsInDollars = currencyFormatter(commission.earnings / 100);
+ const earningsInDollars = currencyFormatter(commission.earnings);
const profitInDollars = currencyFormatter(
- (commission.amount - commission.earnings) / 100,
+ (commission.amount - commission.earnings),
);
let formattedDueDate = "";
diff --git a/packages/email/src/templates/partner-payout-confirmed.tsx b/packages/email/src/templates/partner-payout-confirmed.tsx
index e38b6c5a60..907fe27509 100644
--- a/packages/email/src/templates/partner-payout-confirmed.tsx
+++ b/packages/email/src/templates/partner-payout-confirmed.tsx
@@ -46,7 +46,7 @@ export default function PartnerPayoutConfirmed({
mode: "internal" | "external" | null;
};
}) {
- const saleAmountInDollars = currencyFormatter(payout.amount / 100);
+ const saleAmountInDollars = currencyFormatter(payout.amount);
const startDate = payout.startDate
? formatDate(payout.startDate, {
diff --git a/packages/email/src/templates/partner-payout-failed.tsx b/packages/email/src/templates/partner-payout-failed.tsx
index ba35d0a717..0b994413eb 100644
--- a/packages/email/src/templates/partner-payout-failed.tsx
+++ b/packages/email/src/templates/partner-payout-failed.tsx
@@ -46,7 +46,7 @@ export default function PartnerPayoutFailed({
};
email: string;
}) {
- const payoutAmount = currencyFormatter(payout.amount / 100);
+ const payoutAmount = currencyFormatter(payout.amount);
const payoutMethod = payout.method.replace("_", " ");
return (
@@ -91,7 +91,7 @@ export default function PartnerPayoutFailed({
<Text className="text-sm leading-6 text-neutral-600">
To cover the cost of the failed payout, we've charged a{" "}
<span className="font-semibold text-neutral-800">
- ${payout.failureFee / 100} payment failure fee
+ {currencyFormatter(payout.failureFee)} payment failure fee
</span>
{payout.cardLast4 && (
<>
diff --git a/packages/email/src/templates/partner-payout-processed.tsx b/packages/email/src/templates/partner-payout-processed.tsx
index b8e9344772..c6ee2d078a 100644
--- a/packages/email/src/templates/partner-payout-processed.tsx
+++ b/packages/email/src/templates/partner-payout-processed.tsx
@@ -41,7 +41,7 @@ export default function PartnerPayoutProcessed({
};
variant: "stripe" | "paypal";
}) {
- const saleAmountInDollars = currencyFormatter(payout.amount / 100, {
+ const saleAmountInDollars = currencyFormatter(payout.amount, {
trailingZeroDisplay: "stripIfInteger",
});
diff --git a/packages/email/src/templates/partner-payout-withdrawal-completed.tsx b/packages/email/src/templates/partner-payout-withdrawal-completed.tsx
index 9ef8fc2ecf..6d9c8e2cf7 100644
--- a/packages/email/src/templates/partner-payout-withdrawal-completed.tsx
+++ b/packages/email/src/templates/partner-payout-withdrawal-completed.tsx
@@ -32,7 +32,7 @@ export default function PartnerPayoutWithdrawalCompleted({
traceId: string | null;
};
}) {
- const amountInDollars = currencyFormatter(payout.amount / 100, {
+ const amountInDollars = currencyFormatter(payout.amount, {
currency: payout.currency,
});
diff --git a/packages/email/src/templates/partner-payout-withdrawal-initiated.tsx b/packages/email/src/templates/partner-payout-withdrawal-initiated.tsx
index 81fb208f85..158110f655 100644
--- a/packages/email/src/templates/partner-payout-withdrawal-initiated.tsx
+++ b/packages/email/src/templates/partner-payout-withdrawal-initiated.tsx
@@ -18,8 +18,8 @@ import { Footer } from "../components/footer";
export default function PartnerPayoutWithdrawalInitiated({
email = "[email protected]",
payout = {
- amount: 45590,
- currency: "usd",
+ amount: 260689,
+ currency: "vnd",
arrivalDate: 1722163200,
},
}: {
@@ -30,7 +30,7 @@ export default function PartnerPayoutWithdrawalInitiated({
arrivalDate: number;
};
}) {
- const amountInDollars = currencyFormatter(payout.amount / 100, {
+ const finalPayoutAmount = currencyFormatter(payout.amount, {
currency: payout.currency,
});
@@ -52,7 +52,7 @@ export default function PartnerPayoutWithdrawalInitiated({
<Text className="text-sm leading-6 text-neutral-600">
Good news!{" "}
<span className="font-semibold text-neutral-800">
- {amountInDollars}
+ {finalPayoutAmount}
</span>{" "}
is being transferred from your Stripe Express account to your
connected bank account.
diff --git a/packages/email/src/templates/partner-paypal-payout-failed.tsx b/packages/email/src/templates/partner-paypal-payout-failed.tsx
index a2cdb63cfc..4091d7630f 100644
--- a/packages/email/src/templates/partner-paypal-payout-failed.tsx
+++ b/packages/email/src/templates/partner-paypal-payout-failed.tsx
@@ -40,7 +40,7 @@ export default function PartnerPaypalPayoutFailed({
};
email: string;
}) {
- const amountFormatted = currencyFormatter(payout.amount / 100);
+ const amountFormatted = currencyFormatter(payout.amount);
return (
<Html>
diff --git a/packages/email/src/templates/partner-program-summary.tsx b/packages/email/src/templates/partner-program-summary.tsx
index 30e51d5e9d..66b044fee3 100644
--- a/packages/email/src/templates/partner-program-summary.tsx
+++ b/packages/email/src/templates/partner-program-summary.tsx
@@ -156,7 +156,7 @@ export default function PartnerProgramSummary({
},
{
title: "Earnings",
- value: currencyFormatter(currentMonth.earnings / 100),
+ value: currencyFormatter(currentMonth.earnings),
percent: getPercentChange(currentMonth.earnings, previousMonth.earnings),
},
];
@@ -176,7 +176,7 @@ export default function PartnerProgramSummary({
},
{
title: "Earnings",
- value: currencyFormatter(lifetime.earnings / 100),
+ value: currencyFormatter(lifetime.earnings),
},
];
diff --git a/packages/email/src/templates/program-payout-reminder.tsx b/packages/email/src/templates/program-payout-reminder.tsx
index c0f3f807e0..125a66f4fa 100644
--- a/packages/email/src/templates/program-payout-reminder.tsx
+++ b/packages/email/src/templates/program-payout-reminder.tsx
@@ -74,7 +74,7 @@ export default function ProgramPayoutReminder({
<Stats
title="Total payout amount"
icon="https://assets.dub.co/misc/icons/nucleo/money-bills.png"
- value={currencyFormatter(payout.amount / 100)}
+ value={currencyFormatter(payout.amount)}
/>
</Column>
diff --git a/packages/utils/src/functions/currency-formatter.ts b/packages/utils/src/functions/currency-formatter.ts
index df0a2580f2..894d1f0ba6 100644
--- a/packages/utils/src/functions/currency-formatter.ts
+++ b/packages/utils/src/functions/currency-formatter.ts
@@ -1,16 +1,22 @@
+import { isZeroDecimalCurrency } from "./currency-zero-decimal";
+
interface CurrencyFormatterOptions extends Intl.NumberFormatOptions {
trailingZeroDisplay?: "auto" | "stripIfInteger";
}
export const currencyFormatter = (
- value: number,
+ valueInCents: number,
options?: CurrencyFormatterOptions,
-) =>
- Intl.NumberFormat("en-US", {
+) => {
+ const currency = options?.currency || "USD";
+ return Intl.NumberFormat("en-US", {
style: "currency",
- currency: "USD",
- minimumFractionDigits: 2,
- maximumFractionDigits: 2,
- trailingZeroDisplay: "auto",
+ currency,
+ trailingZeroDisplay: isZeroDecimalCurrency(currency)
+ ? "stripIfInteger"
+ : "auto",
...options,
- } as CurrencyFormatterOptions).format(value);
+ } as CurrencyFormatterOptions).format(
+ isZeroDecimalCurrency(currency) ? valueInCents : valueInCents / 100,
+ );
+};
diff --git a/packages/utils/src/functions/currency-zero-decimal.ts b/packages/utils/src/functions/currency-zero-decimal.ts
new file mode 100644
index 0000000000..0dac3c783a
--- /dev/null
+++ b/packages/utils/src/functions/currency-zero-decimal.ts
@@ -0,0 +1,19 @@
+export const isZeroDecimalCurrency = (currency: string) =>
+ [
+ "BIF",
+ "CLP",
+ "DJF",
+ "GNF",
+ "JPY",
+ "KMF",
+ "KRW",
+ "MGA",
+ "PYG",
+ "RWF",
+ "UGX",
+ "VND",
+ "VUV",
+ "XAF",
+ "XOF",
+ "XPF",
+ ].includes(currency.toUpperCase());
diff --git a/packages/utils/src/functions/index.ts b/packages/utils/src/functions/index.ts
index 5ea4ca5f59..5eed2ad7df 100644
--- a/packages/utils/src/functions/index.ts
+++ b/packages/utils/src/functions/index.ts
@@ -6,6 +6,7 @@ export * from "./cn";
export * from "./combine-words";
export * from "./construct-metadata";
export * from "./currency-formatter";
+export * from "./currency-zero-decimal";
export * from "./datetime";
export * from "./deep-equal";
export * from "./domains";