diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 888635e..05c5370 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -6015,33 +6015,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({