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;