Exclude sales-expert trading accounts from wholesale customer lists.

Expert trading rows are APP_SHOPKEEPER for orders/ledger and were showing next to real omde customers.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
s.esmaeili
2026-10-25 23:16:13 +03:30
co-authored by Cursor
parent 066bfd2818
commit 4679e2498c
2 changed files with 16 additions and 5 deletions
@@ -264,6 +264,12 @@ export class AdminCustomersService {
in: [VerificationStep.STEP_ONE_SUBMITTED, VerificationStep.STEP_TWO_SUBMITTED],
},
};
// A sales expert is an AdminUser; their trading Customer row exists only so
// the app can hold orders/ledger for them (D21). It must not appear next to
// real wholesale customers in «عمده» / «در انتظار».
const notExpertTradingAccount: Prisma.CustomerWhereInput = {
salesExpertTradingFor: null,
};
switch (scope) {
case 'banker':
@@ -273,15 +279,16 @@ export class AdminCustomersService {
// the main omde list, not this one.
return { kind: CustomerKind.WALK_IN_SHOPKEEPER, isArchived: false };
case 'non_verified':
return { isArchived: false, ...pendingVerification };
return { isArchived: false, ...pendingVerification, ...notExpertTradingAccount };
case 'archived':
return { isArchived: true };
return { isArchived: true, ...notExpertTradingAccount };
case 'all':
default:
// type=2 + not archived, and not sitting in «در انتظار».
// type=2 + not archived, not «در انتظار», not an expert's trading row.
return {
kind: CustomerKind.APP_SHOPKEEPER,
isArchived: false,
...notExpertTradingAccount,
NOT: pendingVerification,
};
}