From 3d6ceb2229426f11ba97e92502852db594ae4651 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Wed, 20 Mar 2024 13:54:34 +0700 Subject: [PATCH] report gov01-07 --- src/controllers/ReportController.ts | 79 +++++++++++++++-------------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 332c7c9..6a9ebc0 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -768,8 +768,6 @@ export class ReportController extends Controller { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { id: salaryPeriodId, - period: "APR", - isActive: true, }, }); @@ -777,51 +775,39 @@ export class ReportController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน"); } - const salaryOrg = await this.salaryOrgRepository.findOne({ - where: { - salaryPeriodId: salaryPeriodId, - rootId: rootId, - snapshot: "SNAP2", - }, - order: { - group: "ASC", - }, - relations: ["salaryProfiles"], - }); - const salaryProfile = await this.salaryProfileRepository.find({ where: { - salaryOrgId: salaryOrg?.id, - amountSpecial: IsNull() || 0, - amountUse: MoreThan(1), + salaryOrg: { + snapshot: "SNAP2", + rootId: rootId, + salaryPeriodId: salaryPeriodId, + salaryPeriod: { + period: "APR", + }, + }, }, - select: [ - "id", - "prefix", - "firstName", - "lastName", - "root", - "position", - "posType", - "posLevel", - "orgShortName", - "posMasterNo", - "amount", - "amountUse", - "positionSalaryAmount", - ], order: { + type: "DESC", + orgShortName: "ASC", posMasterNo: "ASC", }, }); + const agency = salaryProfile[0] == null ? "" : salaryProfile[0].root; - const mapData = salaryProfile.map((item, index) => ({ + const formattedData = salaryProfile.map((item, index) => ({ no: Extension.ToThaiNumber(String(index + 1)), fullname: item.prefix + item.firstName + " " + item.lastName, - position: item.position, + position: + item.position + + "/" + + (item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") + + (item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") + + (item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") + + (item.child1 == undefined && item.child1 == null ? "" : item.child1 + "/") + + (item.root == undefined && item.root == null ? "" : item.root), posType: item.posType, posLevel: item.posLevel, - posMasterNo: Extension.ToThaiNumber(String(item.posMasterNo)), + posMasterNo: item.orgShortName + Extension.ToThaiNumber(String(item.posMasterNo)), amount: item.amount == undefined || item.amount == null ? "๐" @@ -829,11 +815,28 @@ export class ReportController extends Controller { positionSalaryAmount: item.positionSalaryAmount == undefined || item.positionSalaryAmount == null ? "๐" - : Extension.ToThaiNumber(String(item.positionSalaryAmount)), - remark: null, + : Extension.ToThaiNumber(String(item.positionSalaryAmount)) + + (item.amountSpecial > 0 + ? `(${Extension.ToThaiNumber(String(item.positionSalaryAmount))})` + : ""), + remark: + (item.type == "FULL" ? `หนึ่งขั้น ` : item.type == "FULLHAFT" ? `หนึ่งขั้นครึ่ง ` : "") + + (item.isNext == true ? "(ได้รับเงินเดือนสูงกว่าขั้นสูงฯ)" : ""), })); - return mapData; + return new HttpSuccess({ + template: "gov1-07", + reportName: "gov1-07", + data: { + year: Extension.ToThaiNumber((salaryPeriod.year + 543).toString()), + yearOld: Extension.ToThaiNumber((salaryPeriod.year + 542).toString()), + date: Extension.ToThaiNumber( + Extension.ToThaiFullDate(new Date(`${salaryPeriod.year}-04-01`)), + ), + agency: agency, + data: formattedData, + }, + }); } /**