From 6f4d6d14b71bd3e881048b2c087682af97f38374 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Fri, 6 Dec 2024 09:18:26 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=20api=20=E0=B8=97?= =?UTF-8?q?=E0=B8=B5=E0=B9=88=E0=B8=94=E0=B8=B6=E0=B8=87=20amount=20?= =?UTF-8?q?=E0=B8=88=E0=B8=B2=E0=B8=81=20profile=20salary=20=E0=B9=80?= =?UTF-8?q?=E0=B8=9B=E0=B9=87=E0=B8=99=E0=B8=88=E0=B8=B2=E0=B8=81=20profil?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OrganizationUnauthorizeController.ts | 18 ++++++++++-------- src/controllers/ProfileController.ts | 9 +++++---- src/controllers/ProfileEmployeeController.ts | 9 +++++---- .../ProfileEmployeeTempController.ts | 9 +++++---- src/controllers/ProfileSalaryController.ts | 7 ++++++- .../ProfileSalaryEmployeeController.ts | 7 ++++++- 6 files changed, 37 insertions(+), 22 deletions(-) diff --git a/src/controllers/OrganizationUnauthorizeController.ts b/src/controllers/OrganizationUnauthorizeController.ts index 35b28e48..a637fdea 100644 --- a/src/controllers/OrganizationUnauthorizeController.ts +++ b/src/controllers/OrganizationUnauthorizeController.ts @@ -163,10 +163,11 @@ export class OrganizationUnauthorizeController extends Controller { : item.positions?.find((position) => position.positionIsSelected == true)?.posExecutive .posExecutiveName; - const amount = - item.current_holder == null || item.current_holder.profileSalary.length == 0 - ? null - : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount; + // const amount = + // item.current_holder == null || item.current_holder.profileSalary.length == 0 + // ? null + // : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount; + const amount = item.current_holder?item.current_holder.amount:null; let datePeriodStart = new Date( `${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`, ); @@ -380,10 +381,11 @@ export class OrganizationUnauthorizeController extends Controller { orgShortName = item.orgChild4?.orgChild4ShortName; } - const amount = - item.current_holder == null || item.current_holder.profileSalary.length == 0 - ? null - : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount; + // const amount = + // item.current_holder == null || item.current_holder.profileSalary.length == 0 + // ? null + // : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount; + const amount = item.current_holder?item.current_holder.amount:null; let datePeriodStart = new Date( `${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`, ); diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index f284fb11..527f7d06 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -7247,10 +7247,11 @@ export class ProfileController extends Controller { : item.positions?.find((position) => position.positionIsSelected == true)?.posExecutive .posExecutiveName; - const amount = - item.current_holder == null || item.current_holder.profileSalary.length == 0 - ? null - : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount; + // const amount = + // item.current_holder == null || item.current_holder.profileSalary.length == 0 + // ? null + // : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount; + const amount = item.current_holder?item.current_holder.amount:null; let datePeriodStart = new Date( `${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`, ); diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index b742dfd3..006eb088 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -2950,10 +2950,11 @@ export class ProfileEmployeeController extends Controller { orgShortName = item.orgChild4?.orgChild4ShortName; } - const amount = - item.current_holder == null || item.current_holder.profileSalary.length == 0 - ? null - : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount; + // const amount = + // item.current_holder == null || item.current_holder.profileSalary.length == 0 + // ? null + // : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount; + const amount = item.current_holder?item.current_holder.amount:null; let datePeriodStart = new Date( `${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`, ); diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index 22e1a1f2..d608d753 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -2699,10 +2699,11 @@ export class ProfileEmployeeTempController extends Controller { orgShortName = item.orgChild4?.orgChild4ShortName; } - const amount = - item.current_holder == null || item.current_holder.profileSalary.length == 0 - ? null - : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount; + // const amount = + // item.current_holder == null || item.current_holder.profileSalary.length == 0 + // ? null + // : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount; + const amount = item.current_holder?item.current_holder.amount:null; let datePeriodStart = new Date( `${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`, ); diff --git a/src/controllers/ProfileSalaryController.ts b/src/controllers/ProfileSalaryController.ts index b5b0d8a5..970ff8a9 100644 --- a/src/controllers/ProfileSalaryController.ts +++ b/src/controllers/ProfileSalaryController.ts @@ -122,7 +122,7 @@ export class ProfileSalaryController extends Controller { createdAt: new Date(), lastUpdatedAt: new Date(), }; - + const _null:any = null; Object.assign(data, { ...body, ...meta }); const history = new ProfileSalaryHistory(); Object.assign(history, { ...data, id: undefined }); @@ -131,6 +131,11 @@ export class ProfileSalaryController extends Controller { history.profileSalaryId = data.id; await this.salaryHistoryRepo.save(history, { data: req }); + profile.amount = body?.amount??_null; + profile.positionSalaryAmount = body?.positionSalaryAmount??_null; + profile.mouthSalaryAmount = body.mouthSalaryAmount??_null; + await this.profileRepo.save(profile, { data: req }); + return new HttpSuccess(); } diff --git a/src/controllers/ProfileSalaryEmployeeController.ts b/src/controllers/ProfileSalaryEmployeeController.ts index 0ebc07d3..1c3c89ce 100644 --- a/src/controllers/ProfileSalaryEmployeeController.ts +++ b/src/controllers/ProfileSalaryEmployeeController.ts @@ -137,12 +137,17 @@ export class ProfileSalaryEmployeeController extends Controller { Object.assign(data, { ...body, ...meta }); const history = new ProfileSalaryHistory(); Object.assign(history, { ...data, id: undefined }); - + const _null:any = null; await this.salaryRepo.save(data, { data: req }); setLogDataDiff(req, { before, after: data }); history.profileSalaryId = data.id; await this.salaryHistoryRepo.save(history, { data: req }); + profile.amount = body?.amount??_null; + profile.positionSalaryAmount = body?.positionSalaryAmount??_null; + profile.mouthSalaryAmount = body.mouthSalaryAmount??_null; + await this.profileRepo.save(profile, { data: req }); + return new HttpSuccess(); }