diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 49fa8c3..e7121c2 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -12,6 +12,7 @@ import { KpiCapacity } from "../entities/kpiCapacity"; import { KpiPlan } from "../entities/kpiPlan"; import { KpiRole } from "../entities/kpiRole"; import CallAPI from "../interfaces/call-api"; +import { throws } from "assert"; @Route("api/v1/kpi/report") @Tags("Report") @Security("bearerAuth") @@ -775,6 +776,9 @@ export class ReportController extends Controller { relations: ["kpiPeriod"], where: { id: In(profileEvaluationIds.map((evaluation) => evaluation.id)) }, }); + if(!profileEvaluation || profileEvaluation.length === 0){ + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรายงานการประเมินผลฯ ระดับบุคคลของบุคคลนี้"); + } const combinedData: KPIData = profileEvaluation.reduce( (acc: KPIData, x) => {