From 7a6cf119bd8590eefd6d5384a4af669c98f9b8bd Mon Sep 17 00:00:00 2001 From: Adisak Date: Mon, 11 May 2026 13:25:26 +0700 Subject: [PATCH] update 2473 --- src/controllers/CommandController.ts | 4 ++-- src/controllers/ProfileEmployeeController.ts | 2 +- src/services/PositionService.ts | 15 +++++++++------ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 69262992..ca82faa3 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -4565,7 +4565,7 @@ export class CommandController extends Controller { orgChild3Ref = curPosMaster?.orgChild3 ?? null; orgChild4Ref = curPosMaster?.orgChild4 ?? null; if (curPosMaster) { - await CreatePosMasterHistoryEmployee(curPosMaster.id, req); + await CreatePosMasterHistoryEmployee(curPosMaster.id, req, "DELETE"); } } @@ -5792,7 +5792,7 @@ export class CommandController extends Controller { }, }); if (curPosMaster) { - await CreatePosMasterHistoryEmployee(curPosMaster.id, req); + await CreatePosMasterHistoryEmployee(curPosMaster.id, req, "DELETE"); } } await removeProfileInOrganize(_profile.id, "EMPLOYEE"); diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index a57fd209..bbf8d14a 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -5784,7 +5784,7 @@ export class ProfileEmployeeController extends Controller { await this.profileRepo.save(profile); if (requestBody.isLeave == true) { if (orgRevisionRef) { - await CreatePosMasterHistoryEmployee(orgRevisionRef.id, request); + await CreatePosMasterHistoryEmployee(orgRevisionRef.id, request, "DELETE"); } await removeProfileInOrganize(profile.id, "EMPLOYEE"); } diff --git a/src/services/PositionService.ts b/src/services/PositionService.ts index 357ec2af..7b104e15 100644 --- a/src/services/PositionService.ts +++ b/src/services/PositionService.ts @@ -137,6 +137,7 @@ export async function CreatePosMasterHistoryOfficer( export async function CreatePosMasterHistoryEmployee( posMasterId: string, request: RequestWithUser | null, + type?: string | null, ): Promise { try { await AppDataSource.transaction(async (manager) => { @@ -167,15 +168,17 @@ export async function CreatePosMasterHistoryEmployee( ? pm.positions.find((p) => p.positionIsSelected === true) ?? null : null; h.ancestorDNA = pm.ancestorDNA; - h.prefix = pm.current_holder?.prefix || _null; - h.firstName = pm.current_holder?.firstName || _null; - h.lastName = pm.current_holder?.lastName || _null; + if (!type || type != "DELETE") { + h.prefix = pm.current_holder?.prefix || _null; + h.firstName = pm.current_holder?.firstName || _null; + h.lastName = pm.current_holder?.lastName || _null; + h.position = selectedPosition?.positionName ?? _null; + h.posType = selectedPosition?.posType?.posTypeName ?? _null; + h.posLevel = selectedPosition?.posLevel?.posLevelName ?? _null; + } h.posMasterNoPrefix = pm.posMasterNoPrefix ?? _null; h.posMasterNo = pm.posMasterNo ?? _null; h.posMasterNoSuffix = pm.posMasterNoSuffix ?? _null; - h.position = selectedPosition?.positionName ?? _null; - h.posType = selectedPosition?.posType?.posTypeName ?? _null; - h.posLevel = selectedPosition?.posLevel?.posLevelName ?? _null; h.shortName = [ pm.orgChild4?.orgChild4ShortName,