refactor: change condition for active only filter

This commit is contained in:
Methapon2001 2024-12-18 17:48:50 +07:00
parent 9426a6b3ba
commit a62d729ce6

View file

@ -273,13 +273,13 @@ export class EmployeeController extends Controller {
AND: { AND: {
...filterStatus(activeOnly ? Status.ACTIVE : status), ...filterStatus(activeOnly ? Status.ACTIVE : status),
customerBranch: { customerBranch: {
...filterStatus(activeOnly ? Status.ACTIVE : status), status: activeOnly ? { not: Status.INACTIVE } : undefined,
id: customerBranchId, id: customerBranchId,
customerId, customerId,
customer: isSystem(req.user) customer: isSystem(req.user)
? filterStatus(activeOnly ? Status.ACTIVE : status) ? { status: activeOnly ? { not: Status.INACTIVE } : undefined }
: { : {
...filterStatus(activeOnly ? Status.ACTIVE : status), status: activeOnly ? { not: Status.INACTIVE } : undefined,
registeredBranch: { registeredBranch: {
OR: permissionCond(req.user, { activeOnly: activeOnly }), OR: permissionCond(req.user, { activeOnly: activeOnly }),
}, },