From 342f95302d6597551ab129d3bd85669938f7bdf5 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 21 Mar 2024 09:51:42 +0700 Subject: [PATCH] report 04 --- src/controllers/ReportController.ts | 172 +++++++++++++++------------- 1 file changed, 90 insertions(+), 82 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index af0c378..ea0d37c 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -904,7 +904,7 @@ export class ReportController extends Controller { * @param {string} rootId Guid, *Id Root * @param {string} salaryPeriodId Guid, *Id Period */ - @Get("gov1-03/{rootId}/{salaryPeriodId}") + @Get("gov-03/{rootId}/{salaryPeriodId}") async SalaryReport3(@Path() rootId: string, @Path() salaryPeriodId: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { @@ -1066,7 +1066,7 @@ export class ReportController extends Controller { }); } - /** + /** * API แบบ 1 กท บัญชีรายชื่อผู้สมควรได้เลื่อนเงินเดือน รอบเมษายน * * @summary แบบ 1 กท บัญชีรายชื่อผู้สมควรได้เลื่อนเงินเดือน รอบเมษายน @@ -1074,85 +1074,93 @@ export class ReportController extends Controller { * @param {string} rootId Guid, *Id Root * @param {string} salaryPeriodId Guid, *Id Period */ - @Get("gov1-04/{rootId}/{salaryPeriodId}") - async SalaryReport4(@Path() rootId: string, @Path() salaryPeriodId: string) { - const salaryPeriod = await this.salaryPeriodRepository.findOne({ - where: { - id: salaryPeriodId, - // period: "APR", - isActive: true, - }, - }); - - if (!salaryPeriod) { - 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({ - relations: ["salaryOrg"], - where: { - salaryOrgId: salaryOrg?.id, - }, - order: { - salaryOrg: { - group: "ASC", - }, - type: "DESC", - posMasterNo: "ASC", - }, - }); - - return new HttpSuccess({ + @Get("gov-04/{rootId}/{salaryPeriodId}") + async SalaryReport4(@Path() rootId: string, @Path() salaryPeriodId: string) { + const salaryPeriod = await this.salaryPeriodRepository.findOne({ + where: { + id: salaryPeriodId, + // period: "APR", + isActive: true, + }, + }); + + if (!salaryPeriod) { + 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({ + relations: ["salaryOrg"], + where: { + salaryOrgId: salaryOrg?.id, + }, + order: { + salaryOrg: { + group: "ASC", + }, + type: "DESC", + posMasterNo: "ASC", + }, + }); + + return new HttpSuccess({ template: salaryPeriod.period === "APR" ? "gov1-04" : "gov2-04", reportName: salaryPeriod.period === "APR" ? "gov1-04" : "gov2-04", - data: { - year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod?.year))), - effectiveDate: salaryPeriod?.effectiveDate, - root: salaryProfile[0]?.root, - profile: salaryProfile.map((item, index) => ({ - no: Extension.ToThaiNumber(String(index + 1)), - fullname: item.prefix + item.firstName + " " + item.lastName, - log_group: item.salaryOrg.group, - log_type: item.type, - log_isNext: item.isNext, - 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), - posLevel: item.posLevel, - orgShortName: item.orgShortName + Extension.ToThaiNumber(String(item.posMasterNo)), - amount: - item.amount == undefined || item.amount == null - ? "๐" - : Extension.ToThaiNumber(String(item.amount)), + data: { + year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod?.year))), + effectiveDate: salaryPeriod?.effectiveDate, + root: salaryProfile[0]?.root, + profile: salaryProfile.map((item, index) => ({ + no: Extension.ToThaiNumber(String(index + 1)), + fullname: item.prefix + item.firstName + " " + item.lastName, + log_group: item.salaryOrg.group, + log_type: item.type, + log_isNext: item.isNext, + 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), + posLevel: item.posLevel, + orgShortName: item.orgShortName + Extension.ToThaiNumber(String(item.posMasterNo)), + amount: + item.amount == undefined || item.amount == null || item.amount == 0 + ? "" + : Extension.ToThaiNumber(String(item.amount)), amountSpecial: - (item.positionSalaryAmount == undefined || item.positionSalaryAmount == null ? "๐" : Extension.ToThaiNumber(String(item.positionSalaryAmount))) + - (item.amountSpecial == undefined || item.amountSpecial == null ? "๐" : `(${Extension.ToThaiNumber(String(item.amountSpecial))})`), - score: null, //สรุปผลการประเมินฯ ระดับและคะแนน - remark: - `${item.type === "FULL" ? "หนึ่งขั้น" : ""}\n` + - `${(item.type === "FULL" && item.amountSpecial == 0 && item.amountSpecial == null && item.amountSpecial == undefined) ? "ได้รับค่าตอบแทนพิเศษ\n" : ""}` + - `${(item.type === "FULL" && item.isNext === true) ? "(ได้รับเงินเดือนสูงกว่าขั้นสูงฯ)" : ""}`, // หมายเหตุ - })), - }, - }); - } + (item.positionSalaryAmount == undefined || + item.positionSalaryAmount == null || + item.positionSalaryAmount == 0 + ? "" + : Extension.ToThaiNumber(String(item.positionSalaryAmount))) + + (item.amountSpecial == undefined || + item.amountSpecial == null || + item.amountSpecial == 0 + ? "" + : `(${Extension.ToThaiNumber(String(item.amountSpecial))})`), + score: null, //สรุปผลการประเมินฯ ระดับและคะแนน + remark: + `${item.type === "FULL" ? "หนึ่งขั้น" : ""}\n` + + `${item.amountSpecial > 0 ? "ได้รับค่าตอบแทนพิเศษ\n" : ""}` + + `${item.isNext === true ? "(ได้รับเงินเดือนสูงกว่าขั้นสูงฯ)" : ""}`, // หมายเหตุ + })), + }, + }); + } /** * API แบบ 2 กท บัญชีรายชื่อผู้ไม่สมควรได้เลื่อนเงินเดือน รอบเมษายน @@ -1162,7 +1170,7 @@ export class ReportController extends Controller { * @param {string} rootId Guid, *Id Root * @param {string} salaryPeriodId Guid, *Id Period */ - @Get("gov1-05/{rootId}/{salaryPeriodId}") + @Get("gov-05/{rootId}/{salaryPeriodId}") async SalaryReport5(@Path() rootId: string, @Path() salaryPeriodId: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { @@ -1247,7 +1255,7 @@ export class ReportController extends Controller { // * @param {string} rootId Guid, *Id Root // * @param {string} salaryPeriodId Guid, *Id Period // */ - // @Get("gov1-06/{rootId}/{salaryPeriodId}") + // @Get("gov-06/{rootId}/{salaryPeriodId}") // async SalaryReport6(){ // } @@ -1260,7 +1268,7 @@ export class ReportController extends Controller { * @param {string} rootId Guid, *Id Root * @param {string} salaryPeriodId Guid, *Id Period */ - @Get("gov1-07/{rootId}/{salaryPeriodId}") + @Get("gov-07/{rootId}/{salaryPeriodId}") async SalaryReport7(@Path() rootId: string, @Path() salaryPeriodId: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { @@ -1344,7 +1352,7 @@ export class ReportController extends Controller { * @param {string} rootId Guid, *Id Root * @param {string} salaryPeriodId Guid, *Id Period */ - @Get("gov1-08/{rootId}/{salaryPeriodId}") + @Get("gov-08/{rootId}/{salaryPeriodId}") async SalaryReport8(@Path() rootId: string, @Path() salaryPeriodId: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: {