From 7104ce4f347c0cd31595a7bfc24ed49914e135d7 Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Fri, 8 May 2026 14:47:58 +0700 Subject: [PATCH] fixed condition check --- src/services/RetirementService.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/services/RetirementService.ts b/src/services/RetirementService.ts index 7ebfcb17..3e8a1923 100644 --- a/src/services/RetirementService.ts +++ b/src/services/RetirementService.ts @@ -31,7 +31,6 @@ export class RetirementService { }; try { - // หาวันที่ 1 ตุลาคมของปีปัจจุบัน const now = new Date(); const currentYear = now.getFullYear(); @@ -50,7 +49,7 @@ export class RetirementService { }); // Filter เอาเฉพาะวันที่ 1 ตุลาคมเท่านั้น - const filteredProfiles = profiles.filter(p => { + const filteredProfiles = profiles.filter((p) => { if (!p.leaveDate) return false; const leaveDate = new Date(p.leaveDate); return ( @@ -87,11 +86,10 @@ export class RetirementService { }; result.failedProfiles.push(errorInfo); } - }) + }), ); } } - } catch (error: any) { // Log error but don't throw - allow cronjob to complete with partial results console.error("[cronjobPostRetireToExprofile] Error:", error); @@ -118,7 +116,7 @@ export class RetirementService { const retireYear = retireDate.getFullYear(); // Validate date is valid - if (isNaN(retireYear) || retireYear < 2000 || retireYear > 2100) { + if (isNaN(retireYear) || retireYear < 2000) { throw new Error(`Invalid leaveDate for profile ${profile.id}: ${profile.leaveDate}`); } @@ -135,7 +133,7 @@ export class RetirementService { profile.posLevel?.posLevelName || "", retireDate, profile.org || "", - profile.leaveReason || "เกษียณอายุราชการ" + profile.leaveReason || "เกษียณอายุราชการ", ); } }