From c2b7df91468763527dbf910084f49ac78ccb845d Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 10 Apr 2024 11:44:38 +0700 Subject: [PATCH] fix --- src/controllers/ReportController.ts | 53 +++++++++++++++-------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 6e1a6af..759c54d 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -5915,33 +5915,36 @@ export class ReportController extends Controller { }); //ปีก่อนหน้า - salaryProfilePerviousAPR = await this.salaryProfileEmployeeRepository.find({ - relations: ["salaryOrg", "salaryOrg.salaryPeriod"], - where: { - salaryOrg: { - snapshot: "SNAP2", - salaryPeriodId: perviousYearAPR.id, + if(perviousYearAPR){ + salaryProfilePerviousAPR = await this.salaryProfileEmployeeRepository.find({ + relations: ["salaryOrg", "salaryOrg.salaryPeriod"], + where: { + salaryOrg: { + snapshot: "SNAP2", + salaryPeriodId: perviousYearAPR.id, + }, }, - }, - order: { - orgShortName: "ASC", - posMasterNo: "ASC", - }, - }); - - salaryProfilePerviousOCT = await this.salaryProfileEmployeeRepository.find({ - relations: ["salaryOrg", "salaryOrg.salaryPeriod"], - where: { - salaryOrg: { - snapshot: "SNAP2", - salaryPeriodId: perviousYearOCT.id, + order: { + orgShortName: "ASC", + posMasterNo: "ASC", }, - }, - order: { - orgShortName: "ASC", - posMasterNo: "ASC", - }, - }); + }); + } + if(perviousYearOCT){ + salaryProfilePerviousOCT = await this.salaryProfileEmployeeRepository.find({ + relations: ["salaryOrg", "salaryOrg.salaryPeriod"], + where: { + salaryOrg: { + snapshot: "SNAP2", + salaryPeriodId: perviousYearOCT.id, + }, + }, + order: { + orgShortName: "ASC", + posMasterNo: "ASC", + }, + }); + } //ปีปัจุบัน const salaryProfileCurrentAPR = await this.salaryProfileEmployeeRepository.find({