diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 438cbf37..f4208e5d 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -4707,7 +4707,40 @@ export class CommandController extends Controller { if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } - + const orgRevision = await this.orgRevisionRepository.findOne({ + where: { + orgRevisionIsCurrent: true, + orgRevisionIsDraft: false + } + }); + const _posMaster = await this.employeePosMasterRepository.findOne({ + where: { + orgRevisionId: orgRevision?.id, + id: profile.posmasterIdTemp + // current_holderId: profile.id + }, + relations: { + orgRoot: true, + orgChild1: true, + orgChild2: true, + orgChild3: true, + orgChild4: true, + }, + }); + let orgShortName = ""; + if (_posMaster != null) { + if (_posMaster.orgChild1Id === null) { + orgShortName = _posMaster.orgRoot?.orgRootShortName; + } else if (_posMaster.orgChild2Id === null) { + orgShortName = _posMaster.orgChild1?.orgChild1ShortName; + } else if (_posMaster.orgChild3Id === null) { + orgShortName = _posMaster.orgChild2?.orgChild2ShortName; + } else if (_posMaster.orgChild4Id === null) { + orgShortName = _posMaster.orgChild3?.orgChild3ShortName; + } else { + orgShortName = _posMaster.orgChild4?.orgChild4ShortName; + } + } const dest_item = await this.salaryRepo.findOne({ where: { profileEmployeeId: item.refId }, order: { order: "DESC" }, @@ -4723,7 +4756,7 @@ export class CommandController extends Controller { commandId: item.commandId, positionSalaryAmount: item.positionSalaryAmount, mouthSalaryAmount: item.mouthSalaryAmount, - posNo: profile.posMasterNoTemp, + posNo: `${orgShortName ?? ""} ${profile.posMasterNoTemp ?? ""}`, position: profile.positionTemp, positionType: profile.posTypeNameTemp, positionLevel: profile.posLevelNameTemp, diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index 913f00bc..1b1976ca 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -4383,7 +4383,9 @@ export class PositionController extends Controller { posTypeId: position.posTypeId, posTypeName: position.posType == null ? null : position.posType.posTypeName, posLevelId: position.posLevelId, - posLevelName: position.posLevel == null ? null : position.posLevel.posLevelName, + posLevelName: position.posType == null && position.posLevel == null + ? null + : `${position.posType.posTypeShortName} ${position.posLevel.posLevelName}`, // posExecutiveId: position.posExecutiveId, // posExecutiveName: // position.posExecutive == null ? null : position.posExecutive.posExecutiveName, diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 0fa1829a..fca3c91b 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -6641,7 +6641,9 @@ export class ProfileController extends Controller { position: profile.position, leaveDate: profile.dateLeave, posMasterNo: posMaster == null ? null : posMaster.posMasterNo, - posLevelName: profile.posLevel == null ? null : profile.posLevel.posLevelName, + posLevelName: profile.posType == null && profile.posLevel == null + ? null + : `${profile.posType.posTypeShortName} ${profile.posLevel.posLevelName}`, posLevelRank: profile.posLevel == null ? null : profile.posLevel.posLevelRank, posLevelId: profile.posLevel == null ? null : profile.posLevel.id, posTypeName: profile.posType == null ? null : profile.posType.posTypeName,