diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 3c91dd85..20f7b230 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -1771,18 +1771,31 @@ export class CommandController extends Controller { .catch(() => {}); if (requestBody.persons != undefined && requestBody.persons.length > 0) { - const posMaster = await this.posMasterRepository.find({ - where: { - current_holderId: In(requestBody.persons.map((x) => x.profileId)), - orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, - }, - select: ["orgRootId"], - }); + let posMaster: any; + if (["C-PM-36", "C-PM-37"].includes(commandCode)) { + posMaster = await this.employeePosMasterRepository.find({ + where: { + current_holderId: In(requestBody.persons.map((x) => x.profileId)), + orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, + }, + select: ["orgRootId"], + }); + } + else { + posMaster = await this.posMasterRepository.find({ + where: { + current_holderId: In(requestBody.persons.map((x) => x.profileId)), + orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, + }, + select: ["orgRootId"], + }); + } + let _posMaster: any; if (["C-PM-38", "C-PM-40"].includes(commandCode)) { _posMaster = await this.posMasterRepository.find({ where: { - orgRootId: In(posMaster.map((x) => x.orgRootId)), + orgRootId: In(posMaster.map((x:any) => x.orgRootId)), orgChild1: IsNull(), orgChild2: IsNull(), orgChild3: IsNull(), @@ -1796,7 +1809,7 @@ export class CommandController extends Controller { } else { _posMaster = await this.posMasterRepository.find({ where: { - orgRootId: In(posMaster.map((x) => x.orgRootId)), + orgRootId: In(posMaster.map((x:any) => x.orgRootId)), orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, isDirector: true, current_holderId: Not(IsNull()),