The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
filter out INVOICE_MIN_PAYOUT_AMOUNT_CENTS
Steven Tey066a7beddd0c
diff --git a/apps/web/app/(ee)/api/cron/payouts/reminders/program-owners/route.ts b/apps/web/app/(ee)/api/cron/payouts/reminders/program-owners/route.tsindex b577e114b7..91cf63cb26 100644--- a/apps/web/app/(ee)/api/cron/payouts/reminders/program-owners/route.ts+++ b/apps/web/app/(ee)/api/cron/payouts/reminders/program-owners/route.ts@@ -1,4 +1,5 @@import { handleAndReturnErrorResponse } from "@/lib/api/errors";+import { INVOICE_MIN_PAYOUT_AMOUNT_CENTS } from "@/lib/constants/payouts";import { verifyVercelSignature } from "@/lib/cron/verify-vercel";import { sendBatchEmail } from "@dub/email";import ProgramPayoutReminder from "@dub/email/templates/program-payout-reminder";@@ -112,12 +113,18 @@ export async function GET(req: Request) {},});- // only send notifications for programs that have not paid out any invoices in the last week+ // only send notifications for programs that:+ // - have a total payout amount greater than or equal to $10 (INVOICE_MIN_PAYOUT_AMOUNT_CENTS)+ // - have not paid out any invoices in the last 2 weeksconst payoutsToNotify = pendingPayouts.filter((p) => {+ const invoiceTotal = p._sum?.amount ?? 0;const recentPaidInvoicesForProgram = recentPaidInvoices.filter((i) => i.programId === p.programId,);- return recentPaidInvoicesForProgram.length === 0;+ return (+ invoiceTotal >= INVOICE_MIN_PAYOUT_AMOUNT_CENTS ||+ recentPaidInvoicesForProgram.length === 0+ );});const programs = await prisma.program.findMany({