From 8888d2f27cff13c9a6163ff79e9b0e91ad78e504 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 9 Sep 2025 11:00:15 +0700 Subject: [PATCH] =?UTF-8?q?update=20=E0=B9=80=E0=B8=A1=E0=B8=B7=E0=B9=88?= =?UTF-8?q?=E0=B8=AD=E0=B8=A5=E0=B8=9A=E0=B8=84=E0=B8=99=E0=B8=84=E0=B8=A3?= =?UTF-8?q?=E0=B8=AD=E0=B8=87=E0=B8=95=E0=B9=89=E0=B8=AD=E0=B8=87=E0=B9=84?= =?UTF-8?q?=E0=B8=A1=E0=B9=88=E0=B8=9B=E0=B8=B1=E0=B9=89=E0=B8=A1=E0=B8=8A?= =?UTF-8?q?=E0=B8=B7=E0=B9=88=E0=B8=AD=E0=B8=A5=E0=B8=87=E0=B8=9B=E0=B8=A3?= =?UTF-8?q?=E0=B8=B0=E0=B8=A7=E0=B8=B1=E0=B8=95=E0=B8=B4=E0=B8=84=E0=B8=99?= =?UTF-8?q?=E0=B8=84=E0=B8=A3=E0=B8=AD=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/PositionController.ts | 4 +++- src/services/PositionService.ts | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index 5279876a..2961ae9e 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -3696,7 +3696,7 @@ export class PositionController extends Controller { } if (dataMaster.orgRevision.orgRevisionIsCurrent) { - await CreatePosMasterHistoryOfficer(dataMaster.id, request); + await CreatePosMasterHistoryOfficer(dataMaster.id, request, "DELETE"); } let _profileId: string = ""; @@ -3715,6 +3715,8 @@ export class PositionController extends Controller { positionIsSelected: false, }); }); + + // //เช็คถ้า revision ปัจจุบันให้ปั๊มที่ profile // const chkRevision = await this.orgRevisionRepository.findOne({ // where: { id: dataMaster.orgRevisionId }, diff --git a/src/services/PositionService.ts b/src/services/PositionService.ts index d09953df..1b73e648 100644 --- a/src/services/PositionService.ts +++ b/src/services/PositionService.ts @@ -11,6 +11,7 @@ import { RequestWithUser } from "../middlewares/user"; export async function CreatePosMasterHistoryOfficer( posMasterId: string, request: RequestWithUser | null, + type?: string | null, ): Promise { try { await AppDataSource.transaction(async (manager) => { @@ -42,9 +43,11 @@ export async function CreatePosMasterHistoryOfficer( ? pm.positions.find((p) => p.positionIsSelected === true) ?? null : null; h.ancestorDNA = pm.ancestorDNA ? pm.ancestorDNA : _null; - 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.posMasterNoPrefix = pm.posMasterNoPrefix ?? _null; h.posMasterNo = pm.posMasterNo ?? _null; h.posMasterNoSuffix = pm.posMasterNoSuffix ?? _null;