From 2fc4fd3121ec69b80ba209ff7bac9ef05c772bee Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 25 Jun 2025 17:31:26 +0700 Subject: [PATCH] #1390 --- src/controllers/ReportController.ts | 39 +++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 83b975a..6b139c6 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -1698,11 +1698,12 @@ export class ReportController extends Controller { * @param {string} rootId Guid, *Id Root * @param {string} salaryPeriodId Guid, *Id Period */ - @Get("gov-04/{rootId}/{salaryPeriodId}/{group}") + @Get("gov-04/{rootId}/{salaryPeriodId}/{group}/{type}") async SalaryReport4( @Path() rootId: string, @Path() salaryPeriodId: string, @Path() group: string, + @Path() type: string = 'ALL' ) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { @@ -1714,18 +1715,34 @@ export class ReportController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน"); } const convertGroup = group.toUpperCase(); + let condition: any = { + salaryOrg: { + snapshot: "SNAP2", + rootId: rootId, + group: convertGroup, + salaryPeriodId: salaryPeriodId, + }, + }; + // condition.type = In(["HAFT", "FULL", "FULLHAFT"]); + condition.isRetired = salaryPeriod.period === "APR" ? In([true, false]) : false; //กรองเฉพาะคนที่ไม่เกษียณเฉพาะรอบตุลา + if(salaryPeriod.period == "APR"){ + if(type == "HAFT"){ + condition.type = "HAFT"; + }else if(type == "FULL"){ + condition.type = "FULL"; + } + }else{ + if(type == "HAFT"){ + condition.type = "HAFT"; + }else if(type == "FULL"){ + condition.type = "FULL"; + }else if(type == "FULLHAFT"){ + condition.type = "FULLHAFT"; + } + } const _salaryPeriod = await this.salaryProfileRepository.find({ relations: ["salaryOrg", "salaryOrg.salaryPeriod"], - where: { - salaryOrg: { - snapshot: "SNAP2", - rootId: rootId, - group: convertGroup, - salaryPeriodId: salaryPeriodId, - }, - type: In(["HAFT", "FULL", "FULLHAFT"]), - isRetired: salaryPeriod.period === "APR" ? In([true, false]) : false, //กรองเฉพาะคนที่ไม่เกษียณเฉพาะรอบตุลา - }, + where: condition, order: { salaryOrg: { group: "ASC",