From dba2e154036ae6a9cba5a946b972f8e6e9c218d3 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Tue, 19 Mar 2024 09:46:52 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=A3=E0=B8=AD?= =?UTF-8?q?=E0=B8=9A=E0=B9=80=E0=B8=87=E0=B8=B4=E0=B8=99=E0=B9=80=E0=B8=94?= =?UTF-8?q?=E0=B8=B7=E0=B8=AD=E0=B8=99=E0=B9=80=E0=B8=94=E0=B8=B7=E0=B8=AD?= =?UTF-8?q?=E0=B8=99=E0=B8=A5=E0=B8=B9=E0=B8=81=E0=B8=88=E0=B9=89=E0=B8=B2?= =?UTF-8?q?=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/SalaryPeriodController.ts | 10 ++++- .../SalaryPeriodEmployeeController.ts | 40 +++++++++++-------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/controllers/SalaryPeriodController.ts b/src/controllers/SalaryPeriodController.ts index 2649496..d414d3b 100644 --- a/src/controllers/SalaryPeriodController.ts +++ b/src/controllers/SalaryPeriodController.ts @@ -762,7 +762,7 @@ export class SalaryPeriodController extends Controller { pageSize: number; keyword?: string; type?: any; - isRetire?: boolean | null; + isRetire?: string | null; }, ) { const salaryOrg = await this.salaryOrgRepository.findOne({ @@ -780,7 +780,13 @@ export class SalaryPeriodController extends Controller { qb.andWhere(body.type != null && body.type != "" ? `profile.type LIKE :type` : "1=1", { type: body.type == null ? "" : `${body.type.toUpperCase()}`, }) - .andWhere(body.isRetire != null ? `profile.isRetired = ${body.isRetire}` : "1=1") + .andWhere( + body.isRetire != null + ? body.isRetire == "1" + ? `profile.isRetired = true` + : `profile.isRetired = false` + : "1=1", + ) .andWhere({ salaryOrgId: salaryOrg.id, }) diff --git a/src/controllers/SalaryPeriodEmployeeController.ts b/src/controllers/SalaryPeriodEmployeeController.ts index 3116797..1d2174c 100644 --- a/src/controllers/SalaryPeriodEmployeeController.ts +++ b/src/controllers/SalaryPeriodEmployeeController.ts @@ -58,7 +58,7 @@ export class SalaryPeriodEmployeeController extends Controller { isActive: true, }, order: { effectiveDate: "DESC" }, - relations: ["salaryOrgs"], + relations: ["salaryOrgEmployees"], }); if (!salaryPeriod) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน"); @@ -66,28 +66,28 @@ export class SalaryPeriodEmployeeController extends Controller { const data = { group1id: - salaryPeriod.salaryOrgs.find( + salaryPeriod.salaryOrgEmployees.find( (x) => x.group == "GROUP1" && x.rootId == body.rootId && x.snapshot == body.snapshot.toLocaleUpperCase(), ) == null ? null - : salaryPeriod.salaryOrgs.find( + : salaryPeriod.salaryOrgEmployees.find( (x) => x.group == "GROUP1" && x.rootId == body.rootId && x.snapshot == body.snapshot.toLocaleUpperCase(), )?.id, group2id: - salaryPeriod.salaryOrgs.find( + salaryPeriod.salaryOrgEmployees.find( (x) => x.group == "GROUP2" && x.rootId == body.rootId && x.snapshot == body.snapshot.toLocaleUpperCase(), ) == null ? null - : salaryPeriod.salaryOrgs.find( + : salaryPeriod.salaryOrgEmployees.find( (x) => x.group == "GROUP2" && x.rootId == body.rootId && @@ -765,7 +765,7 @@ export class SalaryPeriodEmployeeController extends Controller { pageSize: number; keyword?: string; type?: any; - isRetire?: boolean | null; + isRetire?: string | null; }, ) { const salaryOrg = await this.salaryOrgRepository.findOne({ @@ -783,7 +783,13 @@ export class SalaryPeriodEmployeeController extends Controller { qb.andWhere(body.type != null && body.type != "" ? `profile.type LIKE :type` : "1=1", { type: body.type == null ? "" : `${body.type.toUpperCase()}`, }) - .andWhere(body.isRetire != null ? `profile.isRetired = ${body.isRetire}` : "1=1") + .andWhere( + body.isRetire != null + ? body.isRetire == "1" + ? `profile.isRetired = true` + : `profile.isRetired = false` + : "1=1", + ) .andWhere({ salaryOrgId: salaryOrg.id, }) @@ -1461,12 +1467,12 @@ export class SalaryPeriodEmployeeController extends Controller { async OfficerApprove(@Path() periodId: string, rootId: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { id: periodId }, - relations: ["salaryOrgs"], + relations: ["salaryOrgEmployees"], }); if (!salaryPeriod) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบผังเงินเดือนนี้"); await Promise.all( - salaryPeriod.salaryOrgs + salaryPeriod.salaryOrgEmployees .filter((x) => x.rootId == rootId) .map(async (x: any) => { x.status = "WAITHEAD1"; @@ -1487,13 +1493,13 @@ export class SalaryPeriodEmployeeController extends Controller { async HeadApprove(@Path() periodId: string, rootId: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { id: periodId }, - relations: ["salaryOrgs"], + relations: ["salaryOrgEmployees"], }); if (!salaryPeriod) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบผังเงินเดือนนี้"); await Promise.all( - salaryPeriod.salaryOrgs + salaryPeriod.salaryOrgEmployees .filter((x) => x.rootId == rootId) .map(async (x: any) => { x.status = "WAITOWNER1"; @@ -1514,13 +1520,13 @@ export class SalaryPeriodEmployeeController extends Controller { async OwnerApprove(@Path() periodId: string, rootId: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { id: periodId }, - relations: ["salaryOrgs"], + relations: ["salaryOrgEmployees"], }); if (!salaryPeriod) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบผังเงินเดือนนี้"); await Promise.all( - salaryPeriod.salaryOrgs + salaryPeriod.salaryOrgEmployees .filter((x) => x.rootId == rootId) .map(async (x: any) => { x.status = "REPORT"; @@ -1548,13 +1554,13 @@ export class SalaryPeriodEmployeeController extends Controller { ) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { id: periodId }, - relations: ["salaryOrgs"], + relations: ["salaryOrgEmployees"], }); if (!salaryPeriod) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบผังเงินเดือนนี้"); await Promise.all( - salaryPeriod.salaryOrgs + salaryPeriod.salaryOrgEmployees .filter((x) => x.rootId == rootId) .map(async (x: any) => { x.status = "WAITHEAD2"; @@ -1583,13 +1589,13 @@ export class SalaryPeriodEmployeeController extends Controller { ) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { id: periodId }, - relations: ["salaryOrgs"], + relations: ["salaryOrgEmployees"], }); if (!salaryPeriod) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบผังเงินเดือนนี้"); await Promise.all( - salaryPeriod.salaryOrgs + salaryPeriod.salaryOrgEmployees .filter((x) => x.rootId == rootId) .map(async (x: any) => { x.status = "REPORT";