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.

code improvements

Pedro Ladeiraf7ba44352ab0
diff --git a/apps/web/lib/api/customers/reattribute-customer.ts b/apps/web/lib/api/customers/reattribute-customer.ts
index 135322ccc0..8854f75f3e 100644
--- a/apps/web/lib/api/customers/reattribute-customer.ts
+++ b/apps/web/lib/api/customers/reattribute-customer.ts
@@ -568,10 +568,24 @@ export async function transferUnpaidCommissions({
return;
}
+ const stillTransferable = {
+ OR: [
+ { payoutId: null },
+ {
+ payout: {
+ status: {
+ in: MUTABLE_PAYOUT_STATUSES,
+ },
+ },
+ },
+ ],
+ };
+
if (transferablePendingOrHoldIds.length > 0) {
await prisma.commission.updateMany({
where: {
id: { in: transferablePendingOrHoldIds },
+ ...stillTransferable,
},
data: {
customerId: newCustomerId,
@@ -586,6 +600,7 @@ export async function transferUnpaidCommissions({
await prisma.commission.updateMany({
where: {
id: { in: transferableProcessedIds },
+ ...stillTransferable,
},
data: {
customerId: newCustomerId,