diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index d9b07c4b..d0c83267 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -1656,18 +1656,35 @@ export class CommandController extends Controller { }, select: ["orgRootId"], }); - - const _posMaster = await this.posMasterRepository.find({ - where: { - orgRootId: In(posMaster.map((x) => x.orgRootId)), - orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, - isDirector: true, - current_holderId: Not(IsNull()), - }, - relations: ["current_holder", "orgRoot"], - }); + 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)), + orgChild1: IsNull(), + orgChild2: IsNull(), + orgChild3: IsNull(), + orgChild4: IsNull(), + orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, + isDirector: true, + current_holderId: Not(IsNull()), + }, + relations: ["current_holder", "orgRoot"], + }); + } + else { + _posMaster = await this.posMasterRepository.find({ + where: { + orgRootId: In(posMaster.map((x) => x.orgRootId)), + orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, + isDirector: true, + current_holderId: Not(IsNull()), + }, + relations: ["current_holder", "orgRoot"], + }); + } await Promise.all( - _posMaster.map(async (item) => { + _posMaster.map(async (item:any) => { const _commandSend = await this.commandSendRepository.findOne({ where: { commandId: command.id,