From ccd544b8d523fd37b014f40bec83d94304fcd84c Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 5 Sep 2024 09:36:53 +0700 Subject: [PATCH] fix report kp7/kk1 --- src/controllers/ProfileController.ts | 5 ++++ src/controllers/ProfileEmployeeController.ts | 29 ++++++++++++++++---- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index c012435d..4792967e 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -126,6 +126,11 @@ export class ProfileController extends Controller { "current_holders.orgChild4", ], where: { id: id }, + order: { + profileSalary: { + date: "DESC" + } + } }); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 85e02cf5..f284d70e 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -131,6 +131,11 @@ export class ProfileEmployeeController extends Controller { "current_holders.orgChild4", ], where: { id: id }, + order: { + profileSalarys: { + date: "DESC" + } + } }); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profile.id); @@ -194,6 +199,20 @@ export class ProfileEmployeeController extends Controller { let _child3 = child3 == null || child3 == undefined ? "" : `${child3.orgChild3Name}/`; let _child4 = child4 == null || child4 == undefined ? "" : `${child4.orgChild4Name}/`; + const educations = await this.educationRepository.find({ + select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"], + where: { profileEmployeeId: id }, + order: { lastUpdatedAt: "DESC" }, + }); + const Education = educations.map((item) => ({ + Institute: item.institute, + Date: + item.startDate && item.endDate + ? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}` + : "", + Degree: item.degree && item.field ? `${item.degree} ${item.field}` : "", + })); + const mapData = { Id: profile.id, CitizenId: profile.citizenId != null ? Extension.ToThaiNumber(profile.citizenId) : "", @@ -213,11 +232,11 @@ export class ProfileEmployeeController extends Controller { profile.profileSalarys.length > 0 && profile.profileSalarys[0].amount != null ? Extension.ToThaiNumber(profile.profileSalarys[0].amount.toLocaleString()) : "", - Education: - profile.profileEducations.length > 0 && - profile.profileEducations[profile.profileEducations.length - 1].institute != null - ? profile.profileEducations[profile.profileEducations.length - 1].institute - : "", + Education: Education, + // profile.profileEducations.length > 0 && + // profile.profileEducations[profile.profileEducations.length - 1].institute != null + // ? profile.profileEducations[profile.profileEducations.length - 1].institute + // : "", AppointText: profile.dateAppoint != null ? profile.dateAppoint : "", SalaryDate: profile.profileSalarys.length > 0 && profile.profileSalarys[0].date != null