The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Update confirm-payouts.ts
Kiran Kf01924eb5450
diff --git a/apps/web/lib/actions/partners/confirm-payouts.ts b/apps/web/lib/actions/partners/confirm-payouts.tsindex c5d2265a2e..15659bf3bd 100644--- a/apps/web/lib/actions/partners/confirm-payouts.ts+++ b/apps/web/lib/actions/partners/confirm-payouts.ts@@ -34,16 +34,6 @@ export const confirmPayoutsAction = authActionClientprogramId,});- // TODO:- // Move this down- if (excludeCurrentMonth) {- await splitPayouts({- programId,- minPayoutAmount,- });- return; // Remove this, just for testing- }-if (!workspace.stripeId) {throw new Error("Workspace does not have a valid Stripe ID.");}@@ -61,6 +51,21 @@ export const confirmPayoutsAction = authActionClient);}+ // If the user wants to exclude the current month, we need to split the payouts+ // 1 - one for everything up until the end of the previous month+ // 2 - everything else in the current month will be left as pending (and excluded from the payout)+ if (excludeCurrentMonth) {+ await splitPayouts({+ programId,+ minPayoutAmount,+ });+ }++ const now = new Date();+ const currentMonthStart = new Date(+ Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1),+ );+const payouts = await prisma.payout.findMany({where: {programId,@@ -74,6 +79,19 @@ export const confirmPayoutsAction = authActionClientnot: null,},},+ ...(excludeCurrentMonth && {+ OR: [+ {+ periodStart: null,+ periodEnd: null,+ },+ {+ periodEnd: {+ lte: currentMonthStart,+ },+ },+ ],+ }),},select: {id: true,