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, //หมายเหตุ }))