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.

update

Kiran K6ee4c77492b5
diff --git a/apps/web/app/(ee)/api/programs/[programId]/payouts/count/route.ts b/apps/web/app/(ee)/api/programs/[programId]/payouts/count/route.ts
index b9d80287b5..38263ce867 100644
--- a/apps/web/app/(ee)/api/programs/[programId]/payouts/count/route.ts
+++ b/apps/web/app/(ee)/api/programs/[programId]/payouts/count/route.ts
@@ -102,6 +102,7 @@ export const GET = withWorkspace(
},
}),
+ // custom payouts
prisma.payout.aggregate({
where: {
programId,
@@ -116,9 +117,6 @@ export const GET = withWorkspace(
status: "pending",
periodStart: null,
periodEnd: null,
- // createdAt: {
- // lt: currentMonthStart,
- // },
},
_sum: {
amount: true,
diff --git a/apps/web/lib/actions/partners/confirm-payouts.ts b/apps/web/lib/actions/partners/confirm-payouts.ts
index 8d68f940ca..c5d2265a2e 100644
--- a/apps/web/lib/actions/partners/confirm-payouts.ts
+++ b/apps/web/lib/actions/partners/confirm-payouts.ts
@@ -200,7 +200,7 @@ export const confirmPayoutsAction = authActionClient
});
// TODO:
-// Move this to a background job before merging this PR
+// Move this to a background job
const splitPayouts = async ({
programId,
minPayoutAmount,
@@ -208,12 +208,6 @@ const splitPayouts = async ({
programId: string;
minPayoutAmount: number;
}) => {
- const now = new Date();
-
- const currentMonthStart = new Date(
- Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1),
- );
-
const payouts = await prisma.payout.findMany({
where: {
programId,
@@ -237,6 +231,15 @@ const splitPayouts = async ({
},
});
+ if (payouts.length === 0) {
+ return;
+ }
+
+ const now = new Date();
+ const currentMonthStart = new Date(
+ Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1),
+ );
+
for (const payout of payouts) {
const previousCommissions = payout.commissions
.filter((commission) => {