From 1126df613cd0672db91e08c606a7edc624df1011 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 8 Apr 2025 10:46:44 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=80=E0=B8=AA?= =?UTF-8?q?=E0=B9=89=E0=B8=99=20post=20latest=20find=20=E0=B9=84=E0=B8=A1?= =?UTF-8?q?=E0=B9=88=E0=B9=84=E0=B8=94=E0=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/SalaryPeriodController.ts | 16 ++++++++-------- .../SalaryPeriodEmployeeController.ts | 19 ++++++++++--------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/controllers/SalaryPeriodController.ts b/src/controllers/SalaryPeriodController.ts index 720075f..28badc8 100644 --- a/src/controllers/SalaryPeriodController.ts +++ b/src/controllers/SalaryPeriodController.ts @@ -70,56 +70,56 @@ export class SalaryPeriodController extends Controller { const data = { group1id: - salaryPeriod.salaryOrgs.find( + salaryPeriod.salaryOrgs && salaryPeriod.salaryOrgs.find( (x) => x.group == "GROUP1" && x.rootId == body.rootId && x.snapshot == body.snapshot.toLocaleUpperCase(), ) == null ? null - : salaryPeriod.salaryOrgs.find( + : salaryPeriod.salaryOrgs && salaryPeriod.salaryOrgs.find( (x) => x.group == "GROUP1" && x.rootId == body.rootId && x.snapshot == body.snapshot.toLocaleUpperCase(), )?.id, group1IsClose: - salaryPeriod.salaryOrgs.find( + salaryPeriod.salaryOrgs && salaryPeriod.salaryOrgs.find( (x) => x.group == "GROUP1" && x.rootId == body.rootId && x.snapshot == body.snapshot.toLocaleUpperCase(), ) == null ? null - : salaryPeriod.salaryOrgs.find( + : salaryPeriod.salaryOrgs && salaryPeriod.salaryOrgs.find( (x) => x.group == "GROUP1" && x.rootId == body.rootId && x.snapshot == body.snapshot.toLocaleUpperCase(), )?.isClose, group2id: - salaryPeriod.salaryOrgs.find( + salaryPeriod.salaryOrgs && salaryPeriod.salaryOrgs.find( (x) => x.group == "GROUP2" && x.rootId == body.rootId && x.snapshot == body.snapshot.toLocaleUpperCase(), ) == null ? null - : salaryPeriod.salaryOrgs.find( + : salaryPeriod.salaryOrgs && salaryPeriod.salaryOrgs.find( (x) => x.group == "GROUP2" && x.rootId == body.rootId && x.snapshot == body.snapshot.toLocaleUpperCase(), )?.id, group2IsClose: - salaryPeriod.salaryOrgs.find( + salaryPeriod.salaryOrgs && salaryPeriod.salaryOrgs.find( (x) => x.group == "GROUP2" && x.rootId == body.rootId && x.snapshot == body.snapshot.toLocaleUpperCase(), ) == null ? null - : salaryPeriod.salaryOrgs.find( + : salaryPeriod.salaryOrgs && salaryPeriod.salaryOrgs.find( (x) => x.group == "GROUP2" && x.rootId == body.rootId && diff --git a/src/controllers/SalaryPeriodEmployeeController.ts b/src/controllers/SalaryPeriodEmployeeController.ts index 6860b13..68f7a70 100644 --- a/src/controllers/SalaryPeriodEmployeeController.ts +++ b/src/controllers/SalaryPeriodEmployeeController.ts @@ -67,59 +67,58 @@ export class SalaryPeriodEmployeeController extends Controller { if (!salaryPeriod) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน"); } - const data = { group1id: - salaryPeriod.salaryOrgEmployees.find( + salaryPeriod.salaryOrgEmployees && salaryPeriod.salaryOrgEmployees.find( (x) => x.group == "GROUP1" && x.rootId == body.rootId && x.snapshot == body.snapshot.toLocaleUpperCase(), ) == null ? null - : salaryPeriod.salaryOrgEmployees.find( + : salaryPeriod.salaryOrgEmployees && salaryPeriod.salaryOrgEmployees.find( (x) => x.group == "GROUP1" && x.rootId == body.rootId && x.snapshot == body.snapshot.toLocaleUpperCase(), )?.id, group1IsClose: - salaryPeriod.salaryOrgs.find( + salaryPeriod.salaryOrgs && salaryPeriod.salaryOrgs.find( (x) => x.group == "GROUP1" && x.rootId == body.rootId && x.snapshot == body.snapshot.toLocaleUpperCase(), ) == null ? null - : salaryPeriod.salaryOrgs.find( + : salaryPeriod.salaryOrgs && salaryPeriod.salaryOrgs.find( (x) => x.group == "GROUP1" && x.rootId == body.rootId && x.snapshot == body.snapshot.toLocaleUpperCase(), )?.isClose, group2id: - salaryPeriod.salaryOrgEmployees.find( + salaryPeriod.salaryOrgEmployees && salaryPeriod.salaryOrgEmployees.find( (x) => x.group == "GROUP2" && x.rootId == body.rootId && x.snapshot == body.snapshot.toLocaleUpperCase(), ) == null ? null - : salaryPeriod.salaryOrgEmployees.find( + : salaryPeriod.salaryOrgEmployees && salaryPeriod.salaryOrgEmployees.find( (x) => x.group == "GROUP2" && x.rootId == body.rootId && x.snapshot == body.snapshot.toLocaleUpperCase(), )?.id, group2IsClose: - salaryPeriod.salaryOrgs.find( + salaryPeriod.salaryOrgs &&salaryPeriod.salaryOrgs.find( (x) => x.group == "GROUP2" && x.rootId == body.rootId && x.snapshot == body.snapshot.toLocaleUpperCase(), ) == null ? null - : salaryPeriod.salaryOrgs.find( + : salaryPeriod.salaryOrgs && salaryPeriod.salaryOrgs.find( (x) => x.group == "GROUP2" && x.rootId == body.rootId && @@ -128,6 +127,8 @@ export class SalaryPeriodEmployeeController extends Controller { effectiveDate: salaryPeriod.effectiveDate, period: salaryPeriod.period, }; + + return new HttpSuccess(data); }