fix(customers): show every non-archived wholesale customer in the main list
The reference (henza_server AdminController::getCustomer) lists type=2 AND
is_archive=0 with no verification or active filter. The develop-branch change
that hid inactive customers with a pending verification step from «عمده»
emptied the list for customers migrated in that state, while their numbers
stayed taken ("already exists"). Restore parity; the sales-expert trading
account exclusion is kept.
Includes the rebuilt release/app.js and a regression test.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
e2ec30f241
commit
0c52adcd26
@@ -97157,10 +97157,9 @@ var require_admin_customers_service = __commonJS({
|
||||
* NOTE every non-archive list also excludes archived rows, so archiving a
|
||||
* customer removes them from ALL type lists at once.
|
||||
*
|
||||
* «در انتظار» vs «عمده» must not show the same rows. App self-registration
|
||||
* creates APP_SHOPKEEPER + isActive=false + STEP_ONE_SUBMITTED, and step-one
|
||||
* accept sets isActive=true — so pending is inactive+pending-step only, and
|
||||
* the main omde list excludes those same inactive pending rows.
|
||||
* «در انتظار» and «عمده» MAY show the same customer, exactly as in the
|
||||
* reference: getCustomer has no verification filter, so a customer awaiting
|
||||
* approval is in both lists.
|
||||
*/
|
||||
scopeWhere(scope) {
|
||||
const pendingVerification = {
|
||||
@@ -97186,8 +97185,7 @@ var require_admin_customers_service = __commonJS({
|
||||
return {
|
||||
kind: client_1.CustomerKind.APP_SHOPKEEPER,
|
||||
isArchived: false,
|
||||
...notExpertTradingAccount,
|
||||
NOT: pendingVerification
|
||||
...notExpertTradingAccount
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,4 +99,15 @@ describe('AdminCustomersService', () => {
|
||||
expect(writes[0].passwordHash).toBe(OTP_ONLY_PASSWORD_HASH);
|
||||
});
|
||||
});
|
||||
describe('wholesale list scope (parity with AdminController::getCustomer)', () => {
|
||||
const scope = (name: 'all' | 'non_verified') =>
|
||||
(build().service as unknown as { scopeWhere(s: string): Record<string, unknown> }).scopeWhere(name);
|
||||
|
||||
it('«عمده» has no verification or active filter — pending customers stay listed', () => {
|
||||
const where = scope('all');
|
||||
expect(where).toEqual({ kind: 'APP_SHOPKEEPER', isArchived: false, salesExpertTradingFor: null });
|
||||
expect(JSON.stringify(where)).not.toContain('verificationStep');
|
||||
expect(JSON.stringify(where)).not.toContain('isActive');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -252,10 +252,9 @@ export class AdminCustomersService {
|
||||
* NOTE every non-archive list also excludes archived rows, so archiving a
|
||||
* customer removes them from ALL type lists at once.
|
||||
*
|
||||
* «در انتظار» vs «عمده» must not show the same rows. App self-registration
|
||||
* creates APP_SHOPKEEPER + isActive=false + STEP_ONE_SUBMITTED, and step-one
|
||||
* accept sets isActive=true — so pending is inactive+pending-step only, and
|
||||
* the main omde list excludes those same inactive pending rows.
|
||||
* «در انتظار» and «عمده» MAY show the same customer, exactly as in the
|
||||
* reference: getCustomer has no verification filter, so a customer awaiting
|
||||
* approval is in both lists.
|
||||
*/
|
||||
private scopeWhere(scope: OmdeScope): Prisma.CustomerWhereInput {
|
||||
const pendingVerification: Prisma.CustomerWhereInput = {
|
||||
@@ -284,12 +283,15 @@ export class AdminCustomersService {
|
||||
return { isArchived: true, ...notExpertTradingAccount };
|
||||
case 'all':
|
||||
default:
|
||||
// type=2 + not archived, not «در انتظار», not an expert's trading row.
|
||||
// type=2 + not archived (AdminController::getCustomer:166-168), minus an
|
||||
// expert's trading row. NO verification/active filter: the reference
|
||||
// lists every non-archived type-2 customer, pending ones included, and
|
||||
// only counts the inactive ones separately. Filtering them out here
|
||||
// emptied the list for customers migrated with a pending step.
|
||||
return {
|
||||
kind: CustomerKind.APP_SHOPKEEPER,
|
||||
isArchived: false,
|
||||
...notExpertTradingAccount,
|
||||
NOT: pendingVerification,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user