diff --git a/src/controllers/KpiPlanController.ts b/src/controllers/KpiPlanController.ts index d2f558c..69cf6c8 100644 --- a/src/controllers/KpiPlanController.ts +++ b/src/controllers/KpiPlanController.ts @@ -48,14 +48,15 @@ export class kpiPlanController extends Controller { @Request() request: { user: Record }, ) { const kpiPlan = Object.assign(new KpiPlan(), requestBody); - if (requestBody.year != null) { + if (requestBody.year != null && requestBody.period != null) { const kpiPeriod = await this.kpiPeriodRepository .createQueryBuilder("kpiPeriod") .where("kpiPeriod.year = :year", { year: requestBody.year }) .andWhere("kpiPeriod.durationKPI = :durationKPI", { durationKPI: requestBody.period }) .getOne(); if (!kpiPeriod) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัดตามตำแหน่งนี้"); + // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัดตามตำแหน่งนี้"); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบการประเมินนี้ในปีงบประมาณ "+requestBody.year); } } await new CallAPI() diff --git a/src/controllers/KpiRoleController.ts b/src/controllers/KpiRoleController.ts index 98a3d55..04b80d8 100644 --- a/src/controllers/KpiRoleController.ts +++ b/src/controllers/KpiRoleController.ts @@ -48,14 +48,15 @@ export class kpiRoleController extends Controller { @Request() request: { user: Record }, ) { const kpiRole = Object.assign(new KpiRole(), requestBody); - if (requestBody.year != null) { + if (requestBody.year != null && requestBody.period != null) { const kpiPeriod = await this.kpiPeriodRepository .createQueryBuilder("kpiPeriod") .where("kpiPeriod.year = :year", { year: requestBody.year }) .andWhere("kpiPeriod.durationKPI = :durationKPI", { durationKPI: requestBody.period }) .getOne(); if (!kpiPeriod) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัดตามตำแหน่งนี้"); + // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัดตามตำแหน่งนี้"); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบการประเมินนี้ในปีงบประมาณ "+requestBody.year); } } await new CallAPI()