The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Improve support for custom commissions in payouts cron
Steven Teyf31b84c69d17
diff --git a/apps/web/app/(ee)/api/cron/payouts/create-payout.ts b/apps/web/app/(ee)/api/cron/payouts/create-payout.tsindex 61e8f4f85f..42db0fcc64 100644--- a/apps/web/app/(ee)/api/cron/payouts/create-payout.ts+++ b/apps/web/app/(ee)/api/cron/payouts/create-payout.ts@@ -62,18 +62,31 @@ export const createPayout = async ({const [commissions, clawbacks] = await Promise.all([// Find all pending commissions- // We only process commissions that were created before the holding periodprisma.commission.findMany({where: {earnings: {gt: 0,},...commonWhere,- ...(holdingPeriodDays > 0 && {- createdAt: {- lt: new Date(Date.now() - holdingPeriodDays * 24 * 60 * 60 * 1000),- },- }),+ // If there is a holding period set:+ // we only process commissions that were created before the holding period+ // but custom commissions are always included+ ...(holdingPeriodDays > 0+ ? {+ OR: [+ {+ type: "custom",+ },+ {+ createdAt: {+ lt: new Date(+ Date.now() - holdingPeriodDays * 24 * 60 * 60 * 1000,+ ),+ },+ },+ ],+ }+ : {}),},select: {id: true,