diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 40292ba..f5ba611 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -1173,6 +1173,19 @@ export class ReportController extends Controller { if (requestBody.type == "KPI9") { templateName = "KPI9"; reportName = "KPI9"; + const userEvaluations_ = data.kpiUserEvaluations.length > 0 + ? data.kpiUserEvaluations + .filter((x: any) => x.evaluationResults == "EXCELLENT" || x.evaluationResults == "VERY_GOOD") + .map((x: any, idx: number) => ({ + no: Extension.ToThaiNumber((idx + 1).toString()), + fullName: `${x.prefix}${x.firstName} ${x.lastName}`, + position: x.position ? x.position : "", + posLevelName: x.posLevelName ? x.posLevelName : "", + evaluationResults: x.evaluationResults + ? Extension.EvaluationResult(x.evaluationResults) + : "", + })) + : [{}] formattedData = { root: data?.kpiUserEvaluations != null && data?.kpiUserEvaluations.length > 0 @@ -1180,18 +1193,7 @@ export class ReportController extends Controller { : "-", period: data?.durationKPI == "APR" ? "๑" : data?.durationKPI == "OCT" ? "๒" : "-", year: data.year ? Extension.ToThaiNumber((data.year + 543).toString()) : "-", - userEvaluations: - data.kpiUserEvaluations.length > 0 - ? data.kpiUserEvaluations.map((x: any, idx: number) => ({ - no: Extension.ToThaiNumber((idx + 1).toString()), - fullName: `${x.prefix}${x.firstName} ${x.lastName}`, - position: x.position ? x.position : "", - posLevelName: x.posLevelName ? x.posLevelName : "", - evaluationResults: x.evaluationResults - ? Extension.EvaluationResult(x.evaluationResults) - : "", - })) - : [{}], + userEvaluations: userEvaluations_.length > 0 ? userEvaluations_ : [{}], }; }