From 063752f0021bf20d655bf0fc0e6749654d6370ad Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Mon, 17 Jun 2024 17:39:26 +0700 Subject: [PATCH] add pointSumTotal --- .../OrganizationUnauthorizeController.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/controllers/OrganizationUnauthorizeController.ts b/src/controllers/OrganizationUnauthorizeController.ts index 7086622a..eb1575c2 100644 --- a/src/controllers/OrganizationUnauthorizeController.ts +++ b/src/controllers/OrganizationUnauthorizeController.ts @@ -61,6 +61,7 @@ export class OrganizationUnauthorizeController extends Controller { .leftJoinAndSelect("positions.posExecutive", "posExecutive") .leftJoinAndSelect("current_holder.profileSalary", "profileSalary") .leftJoinAndSelect("current_holder.profileDisciplines", "profileDisciplines") + .leftJoinAndSelect("current_holder.profileAssessments", "profileAssessments") .leftJoinAndSelect("current_holder.posLevel", "posLevel") .leftJoinAndSelect("current_holder.posType", "posType") .where({ @@ -188,6 +189,13 @@ export class OrganizationUnauthorizeController extends Controller { (position) => position.positionIsSelected === true, ); const isSpecial = specialPosition ? specialPosition.isSpecial : null; + + const latestProfileAssessment = item.current_holder.profileAssessments + ? item.current_holder.profileAssessments.sort((a:any, b:any) => b.date - a.date)[0] + : null; + const pointSumtotal = latestProfileAssessment + ? latestProfileAssessment.pointSumTotal + : null; return { id: item.id, profileId: item.current_holder.id, @@ -216,7 +224,7 @@ export class OrganizationUnauthorizeController extends Controller { child3: item.orgChild3?.orgChild3Name ? item.orgChild3.orgChild3Name : null, child4Id: item.orgChild4Id, child4: item.orgChild4?.orgChild4Name ? item.orgChild4.orgChild4Name : null, - result: null, + result: pointSumtotal, duration: null, isPunish: item.current_holder.profileDisciplines.filter( @@ -279,6 +287,7 @@ export class OrganizationUnauthorizeController extends Controller { .leftJoinAndSelect("employeePosMaster.positions", "positions") .leftJoinAndSelect("current_holder.profileSalarys", "profileSalarys") .leftJoinAndSelect("current_holder.profileDisciplines", "profileDisciplines") + .leftJoinAndSelect("current_holder.profileAssessments", "profileAssessments") .leftJoinAndSelect("current_holder.posLevel", "posLevel") .leftJoinAndSelect("current_holder.posType", "posType") .where({ @@ -392,7 +401,10 @@ export class OrganizationUnauthorizeController extends Controller { datePeriodStart.getMonth() - 6, ), ); - + const latestProfileAssessment = item.current_holder.profileAssessments + ? item.current_holder.profileAssessments.sort((a: any, b: any) => b.date - a.date)[0] + : null; + const pointSumtotal = latestProfileAssessment ? latestProfileAssessment.pointSumTotal : null; return { profileId: item.current_holder.id, salaryLevel: item.current_holder.salaryLevel, @@ -423,7 +435,7 @@ export class OrganizationUnauthorizeController extends Controller { child3: item.orgChild3?.orgChild3Name ? item.orgChild3.orgChild3Name : null, child4Id: item.orgChild4Id, child4: item.orgChild4?.orgChild4Name ? item.orgChild4.orgChild4Name : null, - result: null, + result: pointSumtotal, duration: null, isPunish: item.current_holder.profileDisciplines.filter(