From 0dcc5c0ac0179f0e09033fb99a4c870b5641f9a8 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 20 Mar 2024 17:16:59 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=A5=E0=B8=B7=E0=B9=88=E0=B8=AD?= =?UTF-8?q?=E0=B8=99=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=B8=9B=E0=B8=B5=E0=B8=81=E0=B9=88?= =?UTF-8?q?=E0=B8=AD=E0=B8=99=E0=B8=AB=E0=B8=99=E0=B9=89=E0=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ReportController.ts | 83 ++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 2 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 6a9ebc0..61ef140 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -534,6 +534,77 @@ export class ReportController extends Controller { ], }); + //รอบปีก่อนๆ + const salaryPeriodIncrease1_APR = await this.salaryPeriodRepository.findOne({ + where: { + period: "APR", + year: salaryPeriod.year - 2, + isActive: true, + }, + }); + const salaryPeriodIncrease1_OCT = await this.salaryPeriodRepository.findOne({ + where: { + period: "OCT", + year: salaryPeriod.year - 2, + isActive: true, + }, + }); + const salaryOrg1_APR = await this.salaryOrgRepository.findOne({ + where: { + salaryPeriodId: salaryPeriodIncrease1_APR?.id, + rootId: rootId, + snapshot: "SNAP2", + } + }); + const salaryOrg1_OCT = await this.salaryOrgRepository.findOne({ + where: { + salaryPeriodId: salaryPeriodIncrease1_OCT?.id, + rootId: rootId, + snapshot: "SNAP2", + } + }); + const salaryProfile1 = await this.salaryProfileRepository.find({ + where: { + salaryOrgId: In([salaryOrg1_APR?.id, salaryOrg1_OCT?.id]), + type: "FULL", + } + }); + //รอบปีก่อนหน้า + const salaryPeriodIncrease2_APR = await this.salaryPeriodRepository.findOne({ + where: { + period: "APR", + year: salaryPeriod.year - 1, + isActive: true, + }, + }); + const salaryPeriodIncrease2_OCT = await this.salaryPeriodRepository.findOne({ + where: { + period: "OCT", + year: salaryPeriod.year - 1, + isActive: true, + }, + }); + const salaryOrg2_APR = await this.salaryOrgRepository.findOne({ + where: { + salaryPeriodId: salaryPeriodIncrease2_APR?.id, + rootId: rootId, + snapshot: "SNAP2", + } + }); + const salaryOrg2_OCT = await this.salaryOrgRepository.findOne({ + where: { + salaryPeriodId: salaryPeriodIncrease2_OCT?.id, + rootId: rootId, + snapshot: "SNAP2", + } + }); + const salaryProfile2 = await this.salaryProfileRepository.find({ + where: { + salaryOrgId: In([salaryOrg2_APR?.id, salaryOrg2_OCT?.id]), + type: "FULL", + } + }); + return new HttpSuccess({ template: "gov1-03", reportName: "gov1-03", @@ -555,8 +626,16 @@ export class ReportController extends Controller { item.amount == undefined || item.amount == null ? "๐" : Extension.ToThaiNumber(String(item.amount.toLocaleString())), - salaryIncrease1: null, //การเลื่อนเงินเดือนปีก่อนๆหน้า - salaryIncrease2: null, //การเลื่อนเงินเดือนปีก่อนหน้า + salaryIncrease1: salaryProfile1.length > 0 ? + salaryProfile1 + .filter(profile => profile.citizenId === item.citizenId) + .map(profile => profile.amount) + : "๐", //การเลื่อนเงินเดือนปีก่อนๆหน้า + salaryIncrease2: salaryProfile2.length > 0 ? + salaryProfile2 + .filter(profile => profile.citizenId === item.citizenId) + .map(profile => profile.amount) + : "๐", //การเลื่อนเงินเดือนปีก่อนหน้า score: null, //ผลการประเมินฯ remark: null, //หมายเหตุ }))