From a25b017bad54799207c80d1eec3874f060ab71d4 Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Fri, 17 Oct 2025 11:07:26 +0700 Subject: [PATCH 1/2] fix retire: table name & add status isLeave, isRetirement --- src/controllers/ProfileController.ts | 4 ++++ src/controllers/ProfileEmployeeController.ts | 9 ++++++++- src/controllers/ProfileEmployeeTempController.ts | 9 ++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 2e3a4da5..55f857f4 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -10441,6 +10441,10 @@ export class ProfileController extends Controller { start: `${year - 1}-10-02`, end: `${year}-10-01`, }) + .andWhere("profile.isLeave = :isLeave AND profile.isRetirement = :isRetirement", { + isLeave: false, + isRetirement: false, + }) .getMany(); if (!profiles || profiles.length === 0) { diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 8d2ebc43..4a8f40ca 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -5033,10 +5033,17 @@ export class ProfileEmployeeController extends Controller { .leftJoinAndSelect("current_holders.orgChild4", "orgChild4") .leftJoinAndSelect("current_holders.positions", "positions") // calculate range: start = 2 Oct of (year-1), end = 1 Oct of year (inclusive) - .where("profile.dateRetire BETWEEN :start AND :end", { + .where("profileEmployee.dateRetire BETWEEN :start AND :end", { start: `${year - 1}-10-02`, end: `${year}-10-01`, }) + .andWhere( + "profileEmployee.isLeave = :isLeave AND profileEmployee.isRetirement = :isRetirement", + { + isLeave: false, + isRetirement: false, + }, + ) .getMany(); if (!profiles || profiles.length === 0) { diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index 189cb80c..6cc6e387 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -3230,10 +3230,17 @@ export class ProfileEmployeeTempController extends Controller { .leftJoinAndSelect("current_holders.positions", "positions") // .leftJoinAndSelect("positions.posExecutive", "posExecutive") // calculate range: start = 2 Oct of (year-1), end = 1 Oct of year (inclusive) - .where("profile.dateRetire BETWEEN :start AND :end", { + .where("profileEmployee.dateRetire BETWEEN :start AND :end", { start: `${year - 1}-10-02`, end: `${year}-10-01`, }) + .andWhere( + "profileEmployee.isLeave = :isLeave AND profileEmployee.isRetirement = :isRetirement", + { + isLeave: false, + isRetirement: false, + }, + ) .getMany(); if (!profiles || profiles.length === 0) { From 6554636eeb6decad3b5fdf2168d9d9760d0b2e73 Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Fri, 17 Oct 2025 12:14:35 +0700 Subject: [PATCH 2/2] fix: range date of retire --- src/controllers/ProfileController.ts | 4 ++-- src/controllers/ProfileEmployeeController.ts | 4 ++-- src/controllers/ProfileEmployeeTempController.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 55f857f4..d4e65f29 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -10438,8 +10438,8 @@ export class ProfileController extends Controller { .leftJoinAndSelect("positions.posExecutive", "posExecutive") // calculate range: start = 2 Oct of (year-1), end = 1 Oct of year (inclusive) .where("profile.dateRetire BETWEEN :start AND :end", { - start: `${year - 1}-10-02`, - end: `${year}-10-01`, + start: `${year - 1}-10-01`, + end: `${year}-09-30`, }) .andWhere("profile.isLeave = :isLeave AND profile.isRetirement = :isRetirement", { isLeave: false, diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 4a8f40ca..a7d905ad 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -5034,8 +5034,8 @@ export class ProfileEmployeeController extends Controller { .leftJoinAndSelect("current_holders.positions", "positions") // calculate range: start = 2 Oct of (year-1), end = 1 Oct of year (inclusive) .where("profileEmployee.dateRetire BETWEEN :start AND :end", { - start: `${year - 1}-10-02`, - end: `${year}-10-01`, + start: `${year - 1}-10-01`, + end: `${year}-09-30`, }) .andWhere( "profileEmployee.isLeave = :isLeave AND profileEmployee.isRetirement = :isRetirement", diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index 6cc6e387..46ef525b 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -3231,8 +3231,8 @@ export class ProfileEmployeeTempController extends Controller { // .leftJoinAndSelect("positions.posExecutive", "posExecutive") // calculate range: start = 2 Oct of (year-1), end = 1 Oct of year (inclusive) .where("profileEmployee.dateRetire BETWEEN :start AND :end", { - start: `${year - 1}-10-02`, - end: `${year}-10-01`, + start: `${year - 1}-10-01`, + end: `${year}-09-30`, }) .andWhere( "profileEmployee.isLeave = :isLeave AND profileEmployee.isRetirement = :isRetirement",