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 `getPayoutEligibilityFilter` logic (#4674)

Steven Teyd0b51a74b57f
diff --git a/apps/web/lib/api/payouts/payout-eligibility-filter.ts b/apps/web/lib/api/payouts/payout-eligibility-filter.ts
index 525b18e951..5c6dcf9c5e 100644
--- a/apps/web/lib/api/payouts/payout-eligibility-filter.ts
+++ b/apps/web/lib/api/payouts/payout-eligibility-filter.ts
@@ -13,23 +13,13 @@ export function getPayoutEligibilityFilter({
"id" | "minPayoutAmount" | "payoutMode" | "environment"
>;
}): Prisma.PayoutWhereInput {
- const commonWhere: Prisma.PayoutWhereInput = {
+ let commonWhere: Prisma.PayoutWhereInput = {
programId: program.id,
status: "pending",
invoiceId: null,
amount: {
gte: program.minPayoutAmount,
},
- // Gift card payouts must be within the Tremendous allowed range
- NOT: {
- partner: {
- defaultPayoutMethod: "tremendous",
- },
- OR: [
- { amount: { lt: TREMENDOUS_MIN_PAYOUT_AMOUNT_CENTS } },
- { amount: { gt: TREMENDOUS_MAX_PAYOUT_AMOUNT_CENTS } },
- ],
- },
};
// Non-production internal and hybrid payouts are simulated, so a missing
@@ -46,6 +36,20 @@ export function getPayoutEligibilityFilter({
return commonWhere;
}
+ commonWhere = {
+ ...commonWhere,
+ // Gift card payouts must be within the Tremendous allowed range
+ NOT: {
+ partner: {
+ defaultPayoutMethod: "tremendous",
+ },
+ OR: [
+ { amount: { lt: TREMENDOUS_MIN_PAYOUT_AMOUNT_CENTS } },
+ { amount: { gt: TREMENDOUS_MAX_PAYOUT_AMOUNT_CENTS } },
+ ],
+ },
+ };
+
switch (program.payoutMode) {
// Internal mode: all payouts are internal, require payoutsEnabledAt !== null
case "internal":
diff --git a/apps/web/lib/constants/program.ts b/apps/web/lib/constants/program.ts
index 15c18a88e2..eef66c9197 100644
--- a/apps/web/lib/constants/program.ts
+++ b/apps/web/lib/constants/program.ts
@@ -1,4 +1,4 @@
-import { ACME_PROGRAM_ID, DEMO_PROGRAM_ID } from "@dub/utils";
+import { ACME_PROGRAM_ID } from "@dub/utils";
export const PROGRAM_ONBOARDING_PARTNERS_LIMIT = 5;
export const MAX_PARTNERS_INVITES_PER_REQUEST = 50;
@@ -57,6 +57,5 @@ export const PROGRAM_APPLICATION_IMAGE_ALLOWED_TYPES_LABEL = "JPG, PNG, WebP";
export const EXTERNAL_PAYOUTS_PROGRAM_IDS = [
ACME_PROGRAM_ID, // Acme
- DEMO_PROGRAM_ID, // Demo
"prog_1M1EYH84K0ZGRA70CEGB4VC72",
];