From 19ffc8f084a0e1a470ec10576194d675394b3099 Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 14 Nov 2024 11:41:52 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=20=E0=B8=AA?= =?UTF-8?q?=E0=B8=B4=E0=B8=97=E0=B8=98=E0=B8=B4=E0=B9=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/WorkflowController.ts | 35 +++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/controllers/WorkflowController.ts b/src/controllers/WorkflowController.ts index cf7cbd36..e48bb86a 100644 --- a/src/controllers/WorkflowController.ts +++ b/src/controllers/WorkflowController.ts @@ -922,13 +922,24 @@ export class WorkflowController extends Controller { }, relations: ["orgChild1"], }); + const profileDirector = await this.posMasterRepo.findOne({ + where: { + orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, + current_holderId: profile.id, + }, + select: ["isDirector"], + }); if (!profileOfficer) - return new HttpSuccess({ isOfficer: false, isStaff: false, isDirector: false }); + return new HttpSuccess({ + isOfficer: false, + isStaff: false, + isDirector: profileDirector?.isDirector ?? false, + }); let isOfficer = profileOfficer.orgChild1 == null ? false : profileOfficer.orgChild1.isOfficer; return new HttpSuccess({ isOfficer: isOfficer, isStaff: !isOfficer, - isDirector: profileOfficer.isDirector, + isDirector: profileDirector?.isDirector ?? false, }); } @@ -955,14 +966,28 @@ export class WorkflowController extends Controller { }, relations: ["orgChild1"], }); + const profileDirector = await this.posMasterRepo.findOne({ + where: { + orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, + current_holderId: profile.id, + }, + select: ["isDirector"], + }); if (!profileOfficer) - return new HttpSuccess({ isOfficer: false, isStaff: false, isDirector: false }); + return new HttpSuccess({ + isOfficer: false, + isStaff: false, + isDirector: profileDirector?.isDirector ?? false, + }); let isOfficer = profileOfficer.orgChild1 == null ? false : profileOfficer.orgChild1.isOfficer; return new HttpSuccess({ isOfficer: isOfficer, isStaff: !isOfficer, - isDirector: - !profileOfficer.orgChild1Id && profileOfficer.orgRootId ? profileOfficer.isDirector : false, + isDirector: profileDirector + ? !profileDirector.orgChild1Id && profileDirector.orgRootId + ? profileDirector.isDirector + : false + : false, }); }