From 0f76e8d3d94916d488259c5726fe3a6582da2b44 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Fri, 1 Mar 2024 11:02:45 +0700 Subject: [PATCH] fix bug --- src/controllers/SalaryPeriodController.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/controllers/SalaryPeriodController.ts b/src/controllers/SalaryPeriodController.ts index c749880..a695513 100644 --- a/src/controllers/SalaryPeriodController.ts +++ b/src/controllers/SalaryPeriodController.ts @@ -150,7 +150,7 @@ export class SalaryPeriodController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขอเงินเดือนผู้ใช้งานนี้ในระบบ"); } - // await this.salaryProfileRepository.remove(salaryProfile); + await this.salaryProfileRepository.remove(salaryProfile); // หาจำนวน Quota คงเหลือ if (salaryProfile.salaryOrg.snapshot == "SNAP1") { @@ -195,7 +195,7 @@ export class SalaryPeriodController extends Controller { @Post("change/amount") async changeAmount(@Body() body: { profileId: string; amount: number }) { const salaryProfile = await this.salaryProfileRepository.findOne({ - relations: ["salaryOrg"], + relations: ["salaryOrg","salaryOrg.salaryPeriod"], where: { id: body.profileId }, }); if (!salaryProfile) { @@ -285,7 +285,7 @@ export class SalaryPeriodController extends Controller { } await this.salaryProfileRepository.save(salaryProfile); - + // หาจำนวน Quota คงเหลือ if (salaryProfile.salaryOrg.snapshot == "SNAP1") { if(salaryProfile.salaryOrg.salaryPeriod.period == "APR"){ @@ -334,6 +334,7 @@ export class SalaryPeriodController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขอเงินเดือนผู้ใช้งานนี้ในระบบ"); } const salaryOrg = await this.salaryOrgRepository.findOne({ + relations: ["salaryPeriod"], where: { id: body.groupId }, }); if (!salaryOrg) {