diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 759c54d..6fb708e 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -2175,6 +2175,101 @@ export class ReportController extends Controller { }); } + /** + * API คำสั่งเลื่อนเงินเดือนข้าราชการเกษียณ รอบตุลาคม + * + * @summary คำสั่งเลื่อนเงินเดือนข้าราชการเกษียณ รอบตุลาคม + * + * @param {string} rootId Guid, *Id Root + * @param {string} salaryPeriodId Guid, *Id Period + */ + @Get("gov-07-01/{rootId}/{salaryPeriodId}") + async SalaryReport7retire(@Path() rootId: string, @Path() salaryPeriodId: string) { + const salaryPeriod = await this.salaryPeriodRepository.findOne({ + where: { + id: salaryPeriodId, + period: "OCT", + isActive: true, + }, + }); + + if (!salaryPeriod) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน"); + } + + const salaryProfile = await this.salaryProfileRepository.find({ + where: { + salaryOrg: { + snapshot: "SNAP2", + rootId: rootId, + salaryPeriodId: salaryPeriodId, + salaryPeriod: { + period: salaryPeriod.period + }, + }, + isRetired: true // เฉพาะคนที่เกษียณ + }, + order: { + type: "DESC", + orgShortName: "ASC", + posMasterNo: "ASC", + }, + }); + const _root = await this.salaryOrgRepository.findOne({ + where: { + rootId: rootId, + salaryPeriodId: salaryPeriodId, + }, + }); + const root = _root?.root == null ? "" : _root.root; + + const formattedData = salaryProfile.map((item, index) => ({ + no: Extension.ToThaiNumber(String(index + 1)), + fullname: item.prefix + item.firstName + " " + item.lastName, + 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(item.orgShortName) + + Extension.ToThaiNumber(String(item.posMasterNo.toLocaleString())), + amount: + item.amount == undefined || item.amount == null + ? "๐" + : Extension.ToThaiNumber(String(item.amount.toLocaleString())), + positionSalaryAmount: + item.positionSalaryAmount == undefined || item.positionSalaryAmount == null + ? "๐" + : Extension.ToThaiNumber(String(item.positionSalaryAmount.toLocaleString())) + + (item.amountSpecial > 0 + ? `(${Extension.ToThaiNumber(String(item.positionSalaryAmount))})` + : ""), + remark: + `${item.type === "FULL" ? "หนึ่งขั้น" : ""}\n` + + `${item.type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : ""}\n` + + `${item.amountSpecial > 0 ? "ได้รับค่าตอบแทนพิเศษ\n" : ""}` + + `${item.isNext === true ? "(ได้รับเงินเดือนสูงกว่าขั้นสูงฯ)" : ""}`, + })); + + return new HttpSuccess({ + template: "gov2-07", + reportName: "gov2-07", + data: { + year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))), + yearOld: Extension.ToThaiNumber((salaryPeriod.year + 542).toString()), + date: Extension.ToThaiNumber(Extension.ToThaiFullDate(new Date(`${salaryPeriod.year}-10-01`))), + agency: root, + data: formattedData, + }, + }); + } + /** * APIคำสั่งค่าตอบแทนพิเศษ และผู้ไม่ได้เลื่อน รอบเมษายน *