diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index 02d4d290..f9683365 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -752,6 +752,50 @@ export class OrganizationController extends Controller { next_holderId: IsNull() || "", }, }), + totalRootPosition: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : IsNull() || "", orgChild2Id : IsNull() || "", + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + }, + }), + totalRootPositionCurrentUse: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : IsNull() || "", orgChild2Id : IsNull() || "", + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + current_holderId: Not(IsNull()) || Not(""), + }, + }), + totalRootPositionCurrentVacant: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : IsNull() || "", orgChild2Id : IsNull() || "", + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + current_holderId: IsNull() || "", + }, + }), + totalRootPositionNextUse: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : IsNull() || "", orgChild2Id : IsNull() || "", + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + next_holderId: Not(IsNull()) || Not(""), + }, + }), + totalRootPositionNextVacant: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : IsNull() || "", orgChild2Id : IsNull() || "", + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + next_holderId: IsNull() || "", + }, + }), children: await Promise.all( orgChild1Data @@ -804,6 +848,51 @@ export class OrganizationController extends Controller { next_holderId: IsNull() || "", }, }), + totalRootPosition: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : IsNull() || "", + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + }, + }), + totalRootPositionCurrentUse: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : IsNull() || "", + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + current_holderId: Not(IsNull()) || Not(""), + }, + }), + totalRootPositionCurrentVacant: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : IsNull() || "", + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + current_holderId: IsNull() || "", + }, + }), + totalRootPositionNextUse: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : IsNull() || "", + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + next_holderId: Not(IsNull()) || Not(""), + }, + }), + totalRootPositionNextVacant: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : IsNull() || "", + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + next_holderId: IsNull() || "", + }, + }), + children: await Promise.all( orgChild2Data .filter((orgChild2) => orgChild2.orgChild1Id === orgChild1.id) @@ -858,6 +947,51 @@ export class OrganizationController extends Controller { next_holderId: IsNull() || "", }, }), + totalRootPosition: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + }, + }), + totalRootPositionCurrentUse: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + current_holderId: Not(IsNull()) || Not(""), + }, + }), + totalRootPositionCurrentVacant: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + current_holderId: IsNull() || "", + }, + }), + totalRootPositionNextUse: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + next_holderId: Not(IsNull()) || Not(""), + }, + }), + totalRootPositionNextVacant: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + next_holderId: IsNull() || "", + }, + }), + children: await Promise.all( orgChild3Data .filter((orgChild3) => orgChild3.orgChild2Id === orgChild2.id) @@ -912,6 +1046,51 @@ export class OrganizationController extends Controller { next_holderId: IsNull() || "", }, }), + totalRootPosition: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : orgChild3.id, orgChild4Id : IsNull() || "", + }, + }), + totalRootPositionCurrentUse: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : orgChild3.id, orgChild4Id : IsNull() || "", + current_holderId: Not(IsNull()) || Not(""), + }, + }), + totalRootPositionCurrentVacant: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : orgChild3.id, orgChild4Id : IsNull() || "", + current_holderId: IsNull() || "", + }, + }), + totalRootPositionNextUse: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : orgChild3.id, orgChild4Id : IsNull() || "", + next_holderId: Not(IsNull()) || Not(""), + }, + }), + totalRootPositionNextVacant: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : orgChild3.id, orgChild4Id : IsNull() || "", + next_holderId: IsNull() || "", + }, + }), + children: await Promise.all( orgChild4Data .filter((orgChild4) => orgChild4.orgChild3Id === orgChild3.id) @@ -967,6 +1146,50 @@ export class OrganizationController extends Controller { next_holderId: IsNull() || "", }, }), + totalRootPosition: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : orgChild3.id, orgChild4Id : orgChild4.id, + }, + }), + totalRootPositionCurrentUse: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : orgChild3.id, orgChild4Id : orgChild4.id, + current_holderId: Not(IsNull()) || Not(""), + }, + }), + totalRootPositionCurrentVacant: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : orgChild3.id, orgChild4Id : orgChild4.id, + current_holderId: IsNull() || "", + }, + }), + totalRootPositionNextUse: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : orgChild3.id, orgChild4Id : orgChild4.id, + next_holderId: Not(IsNull()) || Not(""), + }, + }), + totalRootPositionNextVacant: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : orgChild3.id, orgChild4Id : orgChild4.id, + next_holderId: IsNull() || "", + }, + }), })), ), })),