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 split-payouts.ts

Kiran Kb2213c2de37a
diff --git a/apps/web/app/(ee)/api/cron/payouts/confirm/split-payouts.ts b/apps/web/app/(ee)/api/cron/payouts/confirm/split-payouts.ts
index f7475c9766..906657f33f 100644
--- a/apps/web/app/(ee)/api/cron/payouts/confirm/split-payouts.ts
+++ b/apps/web/app/(ee)/api/cron/payouts/confirm/split-payouts.ts
@@ -80,40 +80,40 @@ export async function splitPayouts({
),
},
});
- }
- if (previousCommissionsCount > 0 && currentCommissionsCount > 0) {
- const periodEnd =
- currentCommissions[currentCommissions.length - 1].createdAt;
+ if (currentCommissionsCount > 0) {
+ const periodEnd =
+ currentCommissions[currentCommissions.length - 1].createdAt;
- const currentMonthPayout = await prisma.payout.create({
- data: {
- id: createId({ prefix: "po_" }),
- programId: program.id,
- partnerId: payout.partnerId,
- periodStart: currentCommissions[0].createdAt,
- periodEnd: new Date(
- periodEnd.getFullYear(),
- periodEnd.getMonth() + 1,
- ),
- amount: currentCommissions.reduce(
- (total, commission) => total + commission.earnings,
- 0,
- ),
- description: "Dub Partners payout",
- },
- });
+ const currentMonthPayout = await prisma.payout.create({
+ data: {
+ id: createId({ prefix: "po_" }),
+ programId: program.id,
+ partnerId: payout.partnerId,
+ periodStart: currentCommissions[0].createdAt,
+ periodEnd: new Date(
+ periodEnd.getFullYear(),
+ periodEnd.getMonth() + 1,
+ ),
+ amount: currentCommissions.reduce(
+ (total, commission) => total + commission.earnings,
+ 0,
+ ),
+ description: "Dub Partners payout",
+ },
+ });
- await prisma.commission.updateMany({
- where: {
- id: {
- in: currentCommissions.map((commission) => commission.id),
+ await prisma.commission.updateMany({
+ where: {
+ id: {
+ in: currentCommissions.map((commission) => commission.id),
+ },
},
- },
- data: {
- payoutId: currentMonthPayout.id,
- },
- });
+ data: {
+ payoutId: currentMonthPayout.id,
+ },
+ });
+ }
}
}
}