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 splitPayouts

Steven Tey559766d39f6d
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 275049bee5..cebc718111 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
@@ -79,6 +79,11 @@ export async function processPayouts({
? { id: { notIn: excludedPayoutIds } }
: {}),
...getPayoutEligibilityFilter(program),
+ ...(cutoffPeriodValue && {
+ periodEnd: {
+ lte: cutoffPeriodValue,
+ },
+ }),
},
data: {
invoiceId: invoice.id,
diff --git a/apps/web/app/(ee)/api/cron/payouts/process/split-payouts.ts b/apps/web/app/(ee)/api/cron/payouts/process/split-payouts.ts
index c3ecc9a04f..7148af8d26 100644
--- a/apps/web/app/(ee)/api/cron/payouts/process/split-payouts.ts
+++ b/apps/web/app/(ee)/api/cron/payouts/process/split-payouts.ts
@@ -87,9 +87,8 @@ export async function splitPayouts({
programId: program.id,
partnerId: payout.partnerId,
periodStart: currentCommissions[0].createdAt,
- periodEnd: endOfMonth(
+ periodEnd:
currentCommissions[currentCommissions.length - 1].createdAt,
- ),
amount: currentCommissions.reduce(
(total, commission) => total + commission.earnings,
0,