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
|
* NOTE every non-archive list also excludes archived rows, so archiving a
|
||||||
* customer removes them from ALL type lists at once.
|
* customer removes them from ALL type lists at once.
|
||||||
*
|
*
|
||||||
* «در انتظار» vs «عمده» must not show the same rows. App self-registration
|
* «در انتظار» and «عمده» MAY show the same customer, exactly as in the
|
||||||
* creates APP_SHOPKEEPER + isActive=false + STEP_ONE_SUBMITTED, and step-one
|
* reference: getCustomer has no verification filter, so a customer awaiting
|
||||||
* accept sets isActive=true — so pending is inactive+pending-step only, and
|
* approval is in both lists.
|
||||||
* the main omde list excludes those same inactive pending rows.
|
|
||||||
*/
|
*/
|
||||||
scopeWhere(scope) {
|
scopeWhere(scope) {
|
||||||
const pendingVerification = {
|
const pendingVerification = {
|
||||||
@@ -97186,8 +97185,7 @@ var require_admin_customers_service = __commonJS({
|
|||||||
return {
|
return {
|
||||||
kind: client_1.CustomerKind.APP_SHOPKEEPER,
|
kind: client_1.CustomerKind.APP_SHOPKEEPER,
|
||||||
isArchived: false,
|
isArchived: false,
|
||||||
...notExpertTradingAccount,
|
...notExpertTradingAccount
|
||||||
NOT: pendingVerification
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,4 +99,15 @@ describe('AdminCustomersService', () => {
|
|||||||
expect(writes[0].passwordHash).toBe(OTP_ONLY_PASSWORD_HASH);
|
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
|
* NOTE every non-archive list also excludes archived rows, so archiving a
|
||||||
* customer removes them from ALL type lists at once.
|
* customer removes them from ALL type lists at once.
|
||||||
*
|
*
|
||||||
* «در انتظار» vs «عمده» must not show the same rows. App self-registration
|
* «در انتظار» and «عمده» MAY show the same customer, exactly as in the
|
||||||
* creates APP_SHOPKEEPER + isActive=false + STEP_ONE_SUBMITTED, and step-one
|
* reference: getCustomer has no verification filter, so a customer awaiting
|
||||||
* accept sets isActive=true — so pending is inactive+pending-step only, and
|
* approval is in both lists.
|
||||||
* the main omde list excludes those same inactive pending rows.
|
|
||||||
*/
|
*/
|
||||||
private scopeWhere(scope: OmdeScope): Prisma.CustomerWhereInput {
|
private scopeWhere(scope: OmdeScope): Prisma.CustomerWhereInput {
|
||||||
const pendingVerification: Prisma.CustomerWhereInput = {
|
const pendingVerification: Prisma.CustomerWhereInput = {
|
||||||
@@ -284,12 +283,15 @@ export class AdminCustomersService {
|
|||||||
return { isArchived: true, ...notExpertTradingAccount };
|
return { isArchived: true, ...notExpertTradingAccount };
|
||||||
case 'all':
|
case 'all':
|
||||||
default:
|
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 {
|
return {
|
||||||
kind: CustomerKind.APP_SHOPKEEPER,
|
kind: CustomerKind.APP_SHOPKEEPER,
|
||||||
isArchived: false,
|
isArchived: false,
|
||||||
...notExpertTradingAccount,
|
...notExpertTradingAccount,
|
||||||
NOT: pendingVerification,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user