From 09fd606b86c52b9e76febcb3462ec98dc5b59aa9 Mon Sep 17 00:00:00 2001 From: Adisak Date: Fri, 8 May 2026 12:13:36 +0700 Subject: [PATCH] hotfix#2476 --- src/controllers/PositionController.ts | 55 ++++++++++++++------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index 38c841a8..96576db8 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -1475,6 +1475,9 @@ export class PositionController extends Controller { if (posMaster.orgRevision?.orgRevisionIsCurrent == true && !posMaster.isSit) { const _position = requestBody.positions.find((p) => p.positionIsSelected == true); if (_position) { + const _posExecutive = _position.posExecutiveId + ? await this.posExecutiveRepository.findOne({ where: { id: _position.posExecutiveId } }) + : null; const current_holderId: any = posMaster.current_holderId; const _profile = await this.profileRepository.findOne({ where: { id: current_holderId }, @@ -1484,7 +1487,7 @@ export class PositionController extends Controller { _profile.posTypeId = _position.posTypeId; _profile.posLevelId = _position.posLevelId; _profile.positionField = _position.posDictField ?? _null; - _profile.posExecutive = _position.posExecutiveId ?? _null; + _profile.posExecutive = _posExecutive?.posExecutiveName ?? _null; _profile.positionArea = _position.posDictArea ?? _null; _profile.positionExecutiveField = _position.posDictExecutiveField ?? _null; await this.profileRepository.save(_profile); @@ -2418,7 +2421,7 @@ export class PositionController extends Controller { ? _data.child1[0] != null ? "posMaster.orgChild1Id IN (:...child1)" : // : `posMaster.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}` - `posMaster.orgChild1Id is null` + `posMaster.orgChild1Id is null` : "1=1", { child1: _data.child1 }, ) @@ -2980,50 +2983,50 @@ export class PositionController extends Controller { const type0LastPosMasterNo = requestBody.type == 0 ? await this.posMasterRepository.find({ - where: { - orgRootId: requestBody.id, - orgChild1Id: IsNull(), - }, - }) + where: { + orgRootId: requestBody.id, + orgChild1Id: IsNull(), + }, + }) : []; const type1LastPosMasterNo = requestBody.type == 1 ? await this.posMasterRepository.find({ - where: { - orgChild1Id: requestBody.id, - orgChild2Id: IsNull(), - }, - }) + where: { + orgChild1Id: requestBody.id, + orgChild2Id: IsNull(), + }, + }) : []; const type2LastPosMasterNo = requestBody.type == 2 ? await this.posMasterRepository.find({ - where: { - orgChild2Id: requestBody.id, - orgChild3Id: IsNull(), - }, - }) + where: { + orgChild2Id: requestBody.id, + orgChild3Id: IsNull(), + }, + }) : []; const type3LastPosMasterNo = requestBody.type == 3 ? await this.posMasterRepository.find({ - where: { - orgChild3Id: requestBody.id, - orgChild4Id: IsNull(), - }, - }) + where: { + orgChild3Id: requestBody.id, + orgChild4Id: IsNull(), + }, + }) : []; const type4LastPosMasterNo = requestBody.type == 4 ? await this.posMasterRepository.find({ - where: { - orgChild4Id: requestBody.id, - }, - }) + where: { + orgChild4Id: requestBody.id, + }, + }) : []; const allLastPosMasterNo = [