fixed condition check
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m6s

This commit is contained in:
Warunee Tamkoo 2026-05-08 14:47:58 +07:00
parent 1c5faecf04
commit 7104ce4f34

View file

@ -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 || "เกษียณอายุราชการ",
);
}
}