From 37245744c9ee6dff9bade70423a11d33df88916b Mon Sep 17 00:00:00 2001 From: Adisak Date: Mon, 5 Jan 2026 11:35:49 +0700 Subject: [PATCH] #2153 --- src/services/PositionService.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/services/PositionService.ts b/src/services/PositionService.ts index 9d0d5c3b..0562f458 100644 --- a/src/services/PositionService.ts +++ b/src/services/PositionService.ts @@ -41,7 +41,7 @@ export async function CreatePosMasterHistoryOfficer( if (!pm.ancestorDNA) return false; const checkCurrentRevision = await repoOrgRevision.findOne({ - where:{ + where: { id: pm.orgRevisionId, orgRevisionIsCurrent: true, orgRevisionIsDraft: false @@ -54,12 +54,18 @@ export async function CreatePosMasterHistoryOfficer( ? pm.positions.find((p) => p.positionIsSelected === true) ?? null : null; h.ancestorDNA = pm.ancestorDNA ? pm.ancestorDNA : _null; - if(!type || type != "DELETE"){ - if(checkCurrentRevision){ + if (!type || type != "DELETE") { + if (checkCurrentRevision) { h.prefix = pm.current_holder?.prefix || _null; h.firstName = pm.current_holder?.firstName || _null; h.lastName = pm.current_holder?.lastName || _null; - }else{ + h.profileId = pm.current_holder?.id || _null; + h.rootDnaId = pm.orgRoot.ancestorDNA || _null; + h.child1DnaId = pm.orgChild1.ancestorDNA || _null; + h.child2DnaId = pm.orgChild2.ancestorDNA || _null; + h.child3DnaId = pm.orgChild3.ancestorDNA || _null; + h.child4DnaId = pm.orgChild4.ancestorDNA || _null; + } else { h.prefix = pm.next_holder?.prefix || _null; h.firstName = pm.next_holder?.firstName || _null; h.lastName = pm.next_holder?.lastName || _null;