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.

fix formatValue in RewardsLogic

Steven Teyf2912000aaa4
diff --git a/apps/web/scripts/processed-payouts.ts b/apps/web/scripts/processed-payouts.ts
new file mode 100644
index 0000000000..34f7426e79
--- /dev/null
+++ b/apps/web/scripts/processed-payouts.ts
@@ -0,0 +1,27 @@
+import { prisma } from "@dub/prisma";
+import { currencyFormatter } from "@dub/utils";
+import "dotenv-flow/config";
+
+async function main() {
+ const processedPayouts = await prisma.payout.aggregate({
+ where: {
+ status: "processed",
+ partner: {
+ paypalEmail: null,
+ },
+ },
+ _count: {
+ id: true,
+ },
+ _sum: {
+ amount: true,
+ },
+ });
+
+ console.log({
+ count: processedPayouts._count.id,
+ amount: currencyFormatter(processedPayouts._sum.amount ?? 0),
+ });
+}
+
+main();
diff --git a/apps/web/ui/partners/rewards/rewards-logic.tsx b/apps/web/ui/partners/rewards/rewards-logic.tsx
index 75eb3fba2f..50994979fa 100644
--- a/apps/web/ui/partners/rewards/rewards-logic.tsx
+++ b/apps/web/ui/partners/rewards/rewards-logic.tsx
@@ -261,7 +261,8 @@ const formatValue = (
if (["number", "currency"].includes(type)) {
return type === "number"
? value!.toString()
- : currencyFormatter(Number(value), {
+ : // value is represented in dollars, so need to convert to cents (because currencyFormatter expects cents)
+ currencyFormatter(Number(value) * 100, {
trailingZeroDisplay: "stripIfInteger",
});
}