diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 5911940e..579d791d 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -99,7 +99,7 @@ import { CreatePosMasterHistoryOfficer, } from "../services/PositionService"; import { PostRetireToExprofile } from "./ExRetirementController"; -import { LeaveType } from "../entities/LeaveType" +import { LeaveType } from "../entities/LeaveType"; @Route("api/v1/org/command") @Tags("Command") @Security("bearerAuth") @@ -219,8 +219,8 @@ export class CommandController extends Controller { _data.child1 != undefined && _data.child1 != null ? _data.child1[0] != null ? `current_holders.orgChild1Id IN (:...child1)` - // : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}` - : `current_holders.orgChild1Id is null` + : // : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}` + `current_holders.orgChild1Id is null` : "1=1", { child1: _data.child1, @@ -298,7 +298,7 @@ export class CommandController extends Controller { status == null || status == undefined || status == "" ? null : status.trim().toLocaleUpperCase() == "NEW" || - status.trim().toLocaleUpperCase() == "DRAFT" + status.trim().toLocaleUpperCase() == "DRAFT" ? ["NEW", "DRAFT"] : [status.trim().toLocaleUpperCase()], }, @@ -428,7 +428,7 @@ export class CommandController extends Controller { }); if (profile) { const currentHolder = profile!.current_holders?.find( - x => + (x) => x.orgRevision?.orgRevisionIsDraft === false && x.orgRevision?.orgRevisionIsCurrent === true, ); @@ -457,29 +457,26 @@ export class CommandController extends Controller { order: { createdAt: "DESC" }, relations: { posExecutive: true }, }); - const operator = Object.assign( - new CommandOperator(), - { - profileId: profile?.id, - prefix: profile?.prefix, - firstName: profile?.firstName, - lastName: profile?.lastName, - posNo: posNo, - posType: profile?.posType?.posTypeName ?? null, - posLevel: profile?.posLevel?.posLevelName ?? null, - position: position?.positionName ?? null, - positionExecutive: position?.posExecutive?.posExecutiveName ?? null, - roleName: "เจ้าหน้าที่ดำเนินการ", - orderNo: 1, - commandId: command.id, - createdUserId: request.user.sub, - createdFullName: request.user.name, - createdAt: now, - lastUpdateUserId: request.user.sub, - lastUpdateFullName: request.user.name, - lastUpdatedAt: now, - } - ); + const operator = Object.assign(new CommandOperator(), { + profileId: profile?.id, + prefix: profile?.prefix, + firstName: profile?.firstName, + lastName: profile?.lastName, + posNo: posNo, + posType: profile?.posType?.posTypeName ?? null, + posLevel: profile?.posLevel?.posLevelName ?? null, + position: position?.positionName ?? null, + positionExecutive: position?.posExecutive?.posExecutiveName ?? null, + roleName: "เจ้าหน้าที่ดำเนินการ", + orderNo: 1, + commandId: command.id, + createdUserId: request.user.sub, + createdFullName: request.user.name, + createdAt: now, + lastUpdateUserId: request.user.sub, + lastUpdateFullName: request.user.name, + lastUpdatedAt: now, + }); await this.commandOperatorRepository.save(operator); } } @@ -521,7 +518,7 @@ export class CommandController extends Controller { commandTypeName: command.commandType?.name || null, commandCode: command.commandType?.code || null, commandSysId: command.commandType?.commandSysId || null, - createdUserId: command.createdUserId + createdUserId: command.createdUserId, }; return new HttpSuccess(_command); } @@ -733,7 +730,7 @@ export class CommandController extends Controller { /** * API แก้ไขเงินเดือนทั้งกลุ่ม * - * @summary API แก้ไขเงินเดือนทั้งกลุ่ม + * @summary API แก้ไขเงินเดือนทั้งกลุ่ม * * @param {string} id Id คำสั่ง */ @@ -802,8 +799,8 @@ export class CommandController extends Controller { .PostData(request, path + "/delete", { refIds: [commandRecive.refId], }) - .then(async (res) => { }) - .catch(() => { }); + .then(async (res) => {}) + .catch(() => {}); const commandId = commandRecive.commandId; await this.commandReciveRepository.delete(commandRecive.id); @@ -846,8 +843,8 @@ export class CommandController extends Controller { .PostData(request, path + "/delete", { refIds: [commandRecive.refId], }) - .then(async (res) => { }) - .catch(() => { }); + .then(async (res) => {}) + .catch(() => {}); const commandId = commandRecive.commandId; await this.commandReciveRepository.delete(commandRecive.id); @@ -890,8 +887,8 @@ export class CommandController extends Controller { .PostData(request, path + "/delete", { refIds: [commandRecive.refId], }) - .then(async (res) => { }) - .catch(() => { }); + .then(async (res) => {}) + .catch(() => {}); const commandId = commandRecive.commandId; await this.commandReciveRepository.delete(commandRecive.id); @@ -1175,8 +1172,8 @@ export class CommandController extends Controller { .PostData(request, path + "/delete", { refIds: command.commandRecives.map((x) => x.refId), }) - .then(async (res) => { }) - .catch(() => { }); + .then(async (res) => {}) + .catch(() => {}); await this.commandReciveRepository.delete({ commandId: command.id }); command.status = "CANCEL"; @@ -1241,8 +1238,8 @@ export class CommandController extends Controller { .PostData(request, path + "/delete", { refIds: command.commandRecives.map((x) => x.refId), }) - .then(async (res) => { }) - .catch(() => { }); + .then(async (res) => {}) + .catch(() => {}); await this.commandSendCCRepository.delete({ commandSendId: In(commandSend.map((x) => x.id)) }); await this.commandReciveRepository.delete({ commandId: command.id }); @@ -1394,11 +1391,11 @@ export class CommandController extends Controller { let profiles = command && command.commandRecives.length > 0 ? command.commandRecives - .filter((x) => x.profileId != null) - .map((x) => ({ - receiverUserId: x.profileId, - notiLink: "", - })) + .filter((x) => x.profileId != null) + .map((x) => ({ + receiverUserId: x.profileId, + notiLink: "", + })) : []; const msgNoti = { @@ -1430,8 +1427,8 @@ export class CommandController extends Controller { refIds: command.commandRecives.filter((x) => x.refId != null).map((x) => x.refId), status: "WAITING", }) - .then(async (res) => { }) - .catch(() => { }); + .then(async (res) => {}) + .catch(() => {}); await this.commandRepository.save(command); } else { const path = commandTypePath(command.commandType.code); @@ -1568,7 +1565,7 @@ export class CommandController extends Controller { ); await this.profileRepository.save(profiles); } - } catch { } + } catch {} type = "EMPLOYEE"; try { @@ -1600,7 +1597,7 @@ export class CommandController extends Controller { ); await this.profileEmployeeRepository.save(profiles); } - } catch { } + } catch {} return new HttpSuccess(); } @@ -1664,7 +1661,7 @@ export class CommandController extends Controller { }), ); } - } catch { } + } catch {} type = "EMPLOYEE"; try { @@ -1719,7 +1716,7 @@ export class CommandController extends Controller { }), ); } - } catch { } + } catch {} return new HttpSuccess(); } @@ -1932,7 +1929,7 @@ export class CommandController extends Controller { .then((x) => { res = x; }) - .catch((x) => { }); + .catch((x) => {}); } let _command; @@ -2010,76 +2007,76 @@ export class CommandController extends Controller { profile?.current_holders.length == 0 ? null : profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) != - null && - profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) - ?.orgChild4 != null + null && + profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) + ?.orgChild4 != null ? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild4.orgChild4ShortName} ${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}` : profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) != - null && - profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) - ?.orgChild3 != null + null && + profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) + ?.orgChild3 != null ? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild3.orgChild3ShortName} ${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}` : profile?.current_holders.find( - (x) => x.orgRevisionId == orgRevisionActive?.id, - ) != null && - profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) - ?.orgChild2 != null - ? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild2.orgChild2ShortName} ${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}` - : profile?.current_holders.find( - (x) => x.orgRevisionId == orgRevisionActive?.id, - ) != null && - profile?.current_holders.find( - (x) => x.orgRevisionId == orgRevisionActive?.id, - )?.orgChild1 != null - ? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild1.orgChild1ShortName} ${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}` - : profile?.current_holders.find( (x) => x.orgRevisionId == orgRevisionActive?.id, ) != null && + profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) + ?.orgChild2 != null + ? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild2.orgChild2ShortName} ${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}` + : profile?.current_holders.find( + (x) => x.orgRevisionId == orgRevisionActive?.id, + ) != null && profile?.current_holders.find( (x) => x.orgRevisionId == orgRevisionActive?.id, - )?.orgRoot != null + )?.orgChild1 != null + ? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild1.orgChild1ShortName} ${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}` + : profile?.current_holders.find( + (x) => x.orgRevisionId == orgRevisionActive?.id, + ) != null && + profile?.current_holders.find( + (x) => x.orgRevisionId == orgRevisionActive?.id, + )?.orgRoot != null ? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot.orgRootShortName} ${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}` : null; const root = profile?.current_holders == null || - profile?.current_holders.length == 0 || - profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null + profile?.current_holders.length == 0 || + profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null ? null : profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) - ?.orgRoot; + ?.orgRoot; const child1 = profile?.current_holders == null || - profile?.current_holders.length == 0 || - profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null + profile?.current_holders.length == 0 || + profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null ? null : profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) - ?.orgChild1; + ?.orgChild1; const child2 = profile?.current_holders == null || - profile?.current_holders.length == 0 || - profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null + profile?.current_holders.length == 0 || + profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null ? null : profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) - ?.orgChild2; + ?.orgChild2; const child3 = profile?.current_holders == null || - profile?.current_holders.length == 0 || - profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null + profile?.current_holders.length == 0 || + profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null ? null : profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) - ?.orgChild3; + ?.orgChild3; const child4 = profile?.current_holders == null || - profile?.current_holders.length == 0 || - profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null + profile?.current_holders.length == 0 || + profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null ? null : profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) - ?.orgChild4; + ?.orgChild4; let _root = root?.orgRootName; let _child1 = child1?.orgChild1Name; @@ -2140,10 +2137,10 @@ export class CommandController extends Controller { commandCode != "C-PM-21" ? profile?.isLeave == false ? (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (_root == null ? "" : _root) + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root) : orgLeave : profileTemp.org, fullName: `${x.prefix}${x.firstName} ${x.lastName}`, @@ -2158,8 +2155,8 @@ export class CommandController extends Controller { commandCode != "C-PM-21" ? profile?.posType && profile?.posLevel ? Extension.ToThaiNumber( - `${profile?.posType.posTypeShortName} ${profile?.posLevel.posLevelName}`, - ) + `${profile?.posType.posTypeShortName} ${profile?.posLevel.posLevelName}`, + ) : "-" : Extension.ToThaiNumber(profileTemp.posLevel), posNo: @@ -2173,19 +2170,19 @@ export class CommandController extends Controller { ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile?.dateRetire)) : profile?.birthDate && commandCode == "C-PM-21" ? Extension.ToThaiNumber( - Extension.ToThaiShortDate_monthYear( - new Date( - profile.birthDate.getFullYear() + 60, - profile.birthDate.getMonth(), - profile.birthDate.getDate(), + Extension.ToThaiShortDate_monthYear( + new Date( + profile.birthDate.getFullYear() + 60, + profile.birthDate.getMonth(), + profile.birthDate.getDate(), + ), ), - ), - ) + ) : "-", dateExecute: command.commandExcecuteDate ? Extension.ToThaiNumber( - Extension.ToThaiShortDate_monthYear(command.commandExcecuteDate), - ) + Extension.ToThaiShortDate_monthYear(command.commandExcecuteDate), + ) : "-", remark: x.remarkVertical ? x.remarkVertical : "-", }; @@ -2286,7 +2283,7 @@ export class CommandController extends Controller { .then(async (res) => { _command = res; }) - .catch(() => { }); + .catch(() => {}); let issue = command.isBangkok == "OFFICE" @@ -2320,7 +2317,7 @@ export class CommandController extends Controller { firstName: true, lastName: true, roleName: true, - orderNo: true + orderNo: true, }, where: { commandId: command.id }, order: { orderNo: "ASC" }, @@ -2341,15 +2338,18 @@ export class CommandController extends Controller { command.commandExcecuteDate == null ? "" : Extension.ToThaiNumber(Extension.ToThaiFullDate2(command.commandExcecuteDate)), - operators: operators.length > 0 - ? operators.map(x => ({ - fullName: `${x.prefix ?? ""}${x.firstName ?? ""} ${x.lastName ?? ""}`, - roleName: x.roleName - })) - : [{ - fullName: "", - roleName: "เจ้าหน้าที่ดำเนินการ" - }] + operators: + operators.length > 0 + ? operators.map((x) => ({ + fullName: `${x.prefix ?? ""}${x.firstName ?? ""} ${x.lastName ?? ""}`, + roleName: x.roleName, + })) + : [ + { + fullName: "", + roleName: "เจ้าหน้าที่ดำเนินการ", + }, + ], }, }); } @@ -2594,7 +2594,7 @@ export class CommandController extends Controller { }); if (profile) { const currentHolder = profile!.current_holders?.find( - x => + (x) => x.orgRevision?.orgRevisionIsDraft === false && x.orgRevision?.orgRevisionIsCurrent === true, ); @@ -2623,29 +2623,26 @@ export class CommandController extends Controller { order: { createdAt: "DESC" }, relations: { posExecutive: true }, }); - const operator = Object.assign( - new CommandOperator(), - { - profileId: profile?.id, - prefix: profile?.prefix, - firstName: profile?.firstName, - lastName: profile?.lastName, - posNo: posNo, - posType: profile?.posType?.posTypeName ?? null, - posLevel: profile?.posLevel?.posLevelName ?? null, - position: position?.positionName ?? null, - positionExecutive: position?.posExecutive?.posExecutiveName ?? null, - roleName: "เจ้าหน้าที่ดำเนินการ", - orderNo: 1, - commandId: command.id, - createdUserId: request.user.sub, - createdFullName: request.user.name, - createdAt: now, - lastUpdateUserId: request.user.sub, - lastUpdateFullName: request.user.name, - lastUpdatedAt: now, - } - ); + const operator = Object.assign(new CommandOperator(), { + profileId: profile?.id, + prefix: profile?.prefix, + firstName: profile?.firstName, + lastName: profile?.lastName, + posNo: posNo, + posType: profile?.posType?.posTypeName ?? null, + posLevel: profile?.posLevel?.posLevelName ?? null, + position: position?.positionName ?? null, + positionExecutive: position?.posExecutive?.posExecutiveName ?? null, + roleName: "เจ้าหน้าที่ดำเนินการ", + orderNo: 1, + commandId: command.id, + createdUserId: request.user.sub, + createdFullName: request.user.name, + createdAt: now, + lastUpdateUserId: request.user.sub, + lastUpdateFullName: request.user.name, + lastUpdatedAt: now, + }); await this.commandOperatorRepository.save(operator); } } @@ -2657,8 +2654,8 @@ export class CommandController extends Controller { refIds: requestBody.persons.filter((x) => x.refId != null).map((x) => x.refId), status: "REPORT", }) - .then(async (res) => { }) - .catch(() => { }); + .then(async (res) => {}) + .catch(() => {}); let order = command.commandRecives == null || command.commandRecives.length <= 0 ? 0 @@ -3431,27 +3428,27 @@ export class CommandController extends Controller { ? x.orgChild1.orgChild1Name + "\n" + x.orgRoot.orgRootName : x.orgChild3 == null ? x.orgChild2.orgChild2Name + - "\n" + - x.orgChild1.orgChild1Name + - "\n" + - x.orgRoot.orgRootName - : x.orgChild4 == null - ? x.orgChild3.orgChild3Name + - "\n" + - x.orgChild2.orgChild2Name + "\n" + x.orgChild1.orgChild1Name + "\n" + x.orgRoot.orgRootName + : x.orgChild4 == null + ? x.orgChild3.orgChild3Name + + "\n" + + x.orgChild2.orgChild2Name + + "\n" + + x.orgChild1.orgChild1Name + + "\n" + + x.orgRoot.orgRootName : x.orgChild4.orgChild4Name + - "\n" + - x.orgChild3.orgChild3Name + - "\n" + - x.orgChild2.orgChild2Name + - "\n" + - x.orgChild1.orgChild1Name + - "\n" + - x.orgRoot.orgRootName, + "\n" + + x.orgChild3.orgChild3Name + + "\n" + + x.orgChild2.orgChild2Name + + "\n" + + x.orgChild1.orgChild1Name + + "\n" + + x.orgRoot.orgRootName, positionName: x?.current_holder.position ?? _null, profileId: x?.current_holder.id ?? _null, }); @@ -3980,8 +3977,8 @@ export class CommandController extends Controller { relations: { roleKeycloaks: true, posType: true, - posLevel: true - } + posLevel: true, + }, }); if (!profile) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้"); @@ -4066,7 +4063,7 @@ export class CommandController extends Controller { orgChild2: true, orgChild3: true, orgChild4: true, - } + }, }); orgRootRef = curPosMaster?.orgRoot ?? null; orgChild1Ref = curPosMaster?.orgChild1 ?? null; @@ -4258,28 +4255,17 @@ export class CommandController extends Controller { organizeName = names.join(" "); } await PostRetireToExprofile( - // profile.citizenId ?? "", - // profile.prefix ?? "", - // profile.firstName ?? "", - // profile.lastName ?? "", - // item.commandDateAffect?.getFullYear().toString() ?? "", - // profile.position, - // profile.posType?.posTypeName ?? "", - // profile.posLevel?.posLevelName ?? "", - // item.commandDateAffect ?? new Date(), - // organizeName, - // clearProfile.retireTypeName ?? "", - "310190004095X", - "จ.ส.อ.", - "dev", - "hrms", - "2026", - "เจ้าหน้าที่จัดเก็บรายได้", - "อื่นๆ", - "C 3", - new Date(2026, 0, 1), - "สำนักงานเขตบางกอกใหญ่", - "เกษียณ" + profile.citizenId ?? "", + profile.prefix ?? "", + profile.firstName ?? "", + profile.lastName ?? "", + item.commandDateAffect?.getFullYear().toString() ?? "", + profile.position, + profile.posType?.posTypeName ?? "", + profile.posLevel?.posLevelName ?? "", + item.commandDateAffect ?? new Date(), + organizeName, + clearProfile.retireTypeName ?? "", ); } }), @@ -4379,8 +4365,8 @@ export class CommandController extends Controller { relations: { roleKeycloaks: true, posType: true, - posLevel: true - } + posLevel: true, + }, }); if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); @@ -4466,7 +4452,7 @@ export class CommandController extends Controller { orgChild2: true, orgChild3: true, orgChild4: true, - } + }, }); orgRootRef = curPosMaster?.orgRoot ?? null; orgChild1Ref = curPosMaster?.orgChild1 ?? null; @@ -4509,28 +4495,17 @@ export class CommandController extends Controller { organizeName = names.join(" "); } await PostRetireToExprofile( - // profile.citizenId ?? "", - // profile.prefix ?? "", - // profile.firstName ?? "", - // profile.lastName ?? "", - // item.commandDateAffect?.getFullYear().toString() ?? "", - // profile.position, - // profile.posType?.posTypeName ?? "", - // `${profile.posType?.posTypeShortName} ${profile.posLevel?.posLevelName}`, - // item.commandDateAffect ?? new Date(), - // organizeName, - // clearProfile.retireTypeName ?? "", - "310190004095X", - "จ.ส.อ.", - "dev", - "hrms", - "2026", - "เจ้าหน้าที่จัดเก็บรายได้", - "อื่นๆ", - "C 3", - new Date(2026, 0, 1), - "สำนักงานเขตบางกอกใหญ่", - "เกษียณ" + profile.citizenId ?? "", + profile.prefix ?? "", + profile.firstName ?? "", + profile.lastName ?? "", + item.commandDateAffect?.getFullYear().toString() ?? "", + profile.position, + profile.posType?.posTypeName ?? "", + `${profile.posType?.posTypeShortName} ${profile.posLevel?.posLevelName}`, + item.commandDateAffect ?? new Date(), + organizeName, + clearProfile.retireTypeName ?? "", ); } }), @@ -4633,8 +4608,8 @@ export class CommandController extends Controller { relations: { roleKeycloaks: true, posType: true, - posLevel: true - } + posLevel: true, + }, }); if (!profile) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้"); @@ -4783,28 +4758,17 @@ export class CommandController extends Controller { organizeName = names.join(" "); } await PostRetireToExprofile( - // profile.citizenId ?? "", - // profile.prefix ?? "", - // profile.firstName ?? "", - // profile.lastName ?? "", - // item.commandDateAffect?.getFullYear().toString() ?? "", - // profile.position, - // profile.posType?.posTypeName ?? "", - // profile.posLevel?.posLevelName ?? "", - // item.commandDateAffect ?? new Date(), - // organizeName, - // clearProfile.retireTypeName ?? "", - "310190004095X", - "จ.ส.อ.", - "dev", - "hrms", - "2026", - "เจ้าหน้าที่จัดเก็บรายได้", - "อื่นๆ", - "C 3", - new Date(2026, 0, 1), - "สำนักงานเขตบางกอกใหญ่", - "เกษียณ" + profile.citizenId ?? "", + profile.prefix ?? "", + profile.firstName ?? "", + profile.lastName ?? "", + item.commandDateAffect?.getFullYear().toString() ?? "", + profile.position, + profile.posType?.posTypeName ?? "", + profile.posLevel?.posLevelName ?? "", + item.commandDateAffect ?? new Date(), + organizeName, + clearProfile.retireTypeName ?? "", ); } } @@ -5411,29 +5375,19 @@ export class CommandController extends Controller { let _posLevelName: string = !isEmployee ? `${profile.posLevel?.posLevelName}` : `${profile.posType?.posTypeName} ${profile.posLevel?.posLevelName}`; + await PostRetireToExprofile( - // profile.citizenId ?? "", - // profile.prefix ?? "", - // profile.firstName ?? "", - // profile.lastName ?? "", - // item.commandDateAffect?.getFullYear().toString() ?? "", - // profile.position, - // profile.posType?.posTypeName ?? "", - // _posLevelName, - // item.commandDateAffect ?? new Date(), - // organizeName, - // retireTypeName, - "310190004095X", - "จ.ส.อ.", - "dev", - "hrms", - "2026", - "เจ้าหน้าที่จัดเก็บรายได้", - "อื่นๆ", - "C 3", - new Date(2026, 0, 1), - "สำนักงานเขตบางกอกใหญ่", - "เกษียณ" + profile.citizenId ?? "", + profile.prefix ?? "", + profile.firstName ?? "", + profile.lastName ?? "", + item.commandDateAffect?.getFullYear().toString() ?? "", + profile.position, + profile.posType?.posTypeName ?? "", + _posLevelName, + item.commandDateAffect ?? new Date(), + organizeName, + retireTypeName, ); } }), @@ -5768,14 +5722,14 @@ export class CommandController extends Controller { ) { let _posNumCodeSit: string = ""; let _posNumCodeSitAbb: string = ""; - let commandType: any = "" + let commandType: any = ""; const _command = await this.commandRepository.findOne({ where: { id: body.data.find((x) => x.commandId)?.commandId ?? "" }, }); if (_command) { commandType = await this.commandTypeRepository.findOne({ select: { code: true }, - where: { id: _command.commandTypeId } + where: { id: _command.commandTypeId }, }); if (_command?.isBangkok?.toLocaleUpperCase() == "OFFICE") { const orgRootDeputy = await this.orgRootRepository.findOne({ @@ -5909,10 +5863,7 @@ export class CommandController extends Controller { if (commandType && String(commandType.code) == "C-PM-11") { const profileIds = body.data.map((x) => x.profileId); - await this.profileRepository.update( - { id: In(profileIds) }, - { isProbation: false } - ); + await this.profileRepository.update({ id: In(profileIds) }, { isProbation: false }); // // Task #2304 อัปเดตจำนวนสิทธิ์การลา เมื่อผ่านทดลองงานฯ // if (leaveType != null) { // await Promise.all( @@ -6071,26 +6022,26 @@ export class CommandController extends Controller { !profile.current_holders || profile.current_holders.length == 0 ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && - profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) - ?.orgChild4 != null + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) + ?.orgChild4 != null ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}` : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && - profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) - ?.orgChild3 != null + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) + ?.orgChild3 != null ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}` : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && - profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) - ?.orgChild2 != null + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) + ?.orgChild2 != null ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2.orgChild2ShortName}` : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != - null && - profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) - ?.orgChild1 != null + null && + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) + ?.orgChild1 != null ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}` : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != - null && - profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) - ?.orgRoot != null + null && + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) + ?.orgRoot != null ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}` : null; const posNo = `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`; @@ -6187,28 +6138,17 @@ export class CommandController extends Controller { organizeName = names.join(" "); } await PostRetireToExprofile( - // profile.citizenId ?? "", - // profile.prefix ?? "", - // profile.firstName ?? "", - // profile.lastName ?? "", - // item.commandDateAffect?.getFullYear().toString() ?? "", - // profile.position, - // profile.posType?.posTypeName ?? "", - // profile.posLevel?.posLevelName ?? "", - // item.commandDateAffect ?? new Date(), - // organizeName, - // clearProfile.retireTypeName ?? "", - "310190004095X", - "จ.ส.อ.", - "dev", - "hrms", - "2026", - "เจ้าหน้าที่จัดเก็บรายได้", - "อื่นๆ", - "C 3", - new Date(2026, 0, 1), - "สำนักงานเขตบางกอกใหญ่", - "เกษียณ" + profile.citizenId ?? "", + profile.prefix ?? "", + profile.firstName ?? "", + profile.lastName ?? "", + item.commandDateAffect?.getFullYear().toString() ?? "", + profile.position, + profile.posType?.posTypeName ?? "", + profile.posLevel?.posLevelName ?? "", + item.commandDateAffect ?? new Date(), + organizeName, + clearProfile.retireTypeName ?? "", ); }), ); @@ -6932,8 +6872,8 @@ export class CommandController extends Controller { prefix: avatar, fileName: fileName, }) - .then(() => { }) - .catch(() => { }); + .then(() => {}) + .catch(() => {}); } } }), @@ -7516,7 +7456,7 @@ export class CommandController extends Controller { where: { profileId: item.posMasterChild.current_holderId, status: true, - isDeleted: false + isDeleted: false, }, }); @@ -8044,7 +7984,7 @@ export class CommandController extends Controller { .then(async (res) => { _command = res; }) - .catch(() => { }); + .catch(() => {}); let issue = command.isBangkok == "OFFICE" diff --git a/src/controllers/ExRetirementController.ts b/src/controllers/ExRetirementController.ts index c8174e6f..c64ccdeb 100644 --- a/src/controllers/ExRetirementController.ts +++ b/src/controllers/ExRetirementController.ts @@ -183,6 +183,12 @@ export async function PostRetireToExprofile( organizeName: string, // child4Name child3Name child2Name child1Name rootName retireTypeName: string, // เช่น เกษียณ, ขอโอนออก, ลาออก, ปลดออก, ไล่ออก, ... ) { + // check NODE_ENV ถ้าเป็น production ถึงจะทำการส่งข้อมูลไปยัง exprofile + const NODE_ENV = process.env.NODE_ENV || "development"; + if (NODE_ENV !== "production") { + return; + } + let retryCount = 0; const maxRetries = 2; diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 8f428180..2fb7e085 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -322,7 +322,15 @@ export class ProfileController extends Controller { ]; const educations = await this.profileEducationRepo.find({ - select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute", "isDeleted"], + select: [ + "startDate", + "endDate", + "educationLevel", + "degree", + "field", + "institute", + "isDeleted", + ], where: { profileId: id, isDeleted: false }, order: { level: "ASC" }, }); @@ -655,7 +663,15 @@ export class ProfileController extends Controller { ]; const education_raw = await this.profileEducationRepo.find({ - select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute", "isDeleted"], + select: [ + "startDate", + "endDate", + "educationLevel", + "degree", + "field", + "institute", + "isDeleted", + ], where: { profileId: id, isDeleted: false }, // order: { lastUpdatedAt: "DESC" }, order: { level: "ASC" }, @@ -1052,7 +1068,14 @@ export class ProfileController extends Controller { let _child4 = child4?.orgChild4Name; const cert_raw = await this.certificateRepository.find({ - select: ["certificateType", "issuer", "certificateNo", "issueDate", "expireDate", "isDeleted"], + select: [ + "certificateType", + "issuer", + "certificateNo", + "issueDate", + "expireDate", + "isDeleted", + ], where: { profileId: id, isDeleted: false }, order: { createdAt: "ASC" }, }); @@ -1069,12 +1092,14 @@ export class ProfileController extends Controller { ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.expireDate)) : "", issueToExpireDate: item.issueDate - ? item.expireDate - ? Extension.ToThaiNumber(`${Extension.ToThaiFullDate2(item.issueDate)} - ${Extension.ToThaiFullDate2(item.expireDate)}`) + ? item.expireDate + ? Extension.ToThaiNumber( + `${Extension.ToThaiFullDate2(item.issueDate)} - ${Extension.ToThaiFullDate2(item.expireDate)}`, + ) : Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.issueDate)) : item.expireDate ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.expireDate)) - : "" + : "", })) : [ { @@ -1246,7 +1271,7 @@ export class ProfileController extends Controller { "page", "refCommandDate", "note", - "isDeleted" + "isDeleted", ], relations: { insignia: { @@ -1325,9 +1350,7 @@ export class ProfileController extends Controller { const totalLeaveDaysKey = `totalLeaveDaysLv${lvIndex}`; const leaveTypeNameKey = `leaveTypeNameLv${lvIndex}`; - const leaveDate = item.maxDateLeaveStart - ? new Date(item.maxDateLeaveStart) - : null; + const leaveDate = item.maxDateLeaveStart ? new Date(item.maxDateLeaveStart) : null; const year = leaveDate ? Extension.ToThaiNumber(Extension.ToThaiShortYear(leaveDate)) : ""; @@ -1525,7 +1548,9 @@ export class ProfileController extends Controller { ? actposition_raw.map((item) => ({ date: item.dateStart && item.dateEnd - ? Extension.ToThaiNumber(`${Extension.ToThaiFullDate2(item.dateStart)} - ${Extension.ToThaiFullDate2(item.dateEnd)}`) + ? Extension.ToThaiNumber( + `${Extension.ToThaiFullDate2(item.dateStart)} - ${Extension.ToThaiFullDate2(item.dateEnd)}`, + ) : item.dateStart ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateStart)) : item.dateEnd @@ -1550,7 +1575,9 @@ export class ProfileController extends Controller { ? assistance_raw.map((item) => ({ date: item.dateStart && item.dateEnd - ? Extension.ToThaiNumber(`${Extension.ToThaiFullDate2(item.dateStart)} - ${Extension.ToThaiFullDate2(item.dateEnd)}`) + ? Extension.ToThaiNumber( + `${Extension.ToThaiFullDate2(item.dateStart)} - ${Extension.ToThaiFullDate2(item.dateEnd)}`, + ) : item.dateStart ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateStart)) : item.dateEnd @@ -1580,7 +1607,9 @@ export class ProfileController extends Controller { ? duty_raw.map((item) => ({ date: item.dateStart && item.dateEnd - ? Extension.ToThaiNumber(`${Extension.ToThaiFullDate2(item.dateStart)} - ${Extension.ToThaiFullDate2(item.dateEnd)}`) + ? Extension.ToThaiNumber( + `${Extension.ToThaiFullDate2(item.dateStart)} - ${Extension.ToThaiFullDate2(item.dateEnd)}`, + ) : item.dateStart ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateStart)) : item.dateEnd @@ -1858,7 +1887,7 @@ export class ProfileController extends Controller { ? Extension.ToThaiNumber(profiles.registrationZipCode) : "", fullRegistrationAddress: fullRegistrationAddress, - updateAt: profiles.lastUpdatedAt + updateAt: profiles.lastUpdatedAt ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.lastUpdatedAt)) : "", telephone: profiles.phone != null ? Extension.ToThaiNumber(profiles.phone) : "", @@ -2267,8 +2296,8 @@ export class ProfileController extends Controller { _data.child1 != undefined && _data.child1 != null ? _data.child1[0] != null ? `current_holders.orgChild1Id IN (:...child1)` - // : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}` - : `current_holders.orgChild1Id is null` + : // : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}` + `current_holders.orgChild1Id is null` : "1=1", { child1: _data.child1, @@ -6244,8 +6273,8 @@ export class ProfileController extends Controller { _data.child1 != undefined && _data.child1 != null ? _data.child1[0] != null ? `current_holders.orgChild1Id IN (:...child1)` - // : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}` - : `current_holders.orgChild1Id is null` + : // : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}` + `current_holders.orgChild1Id is null` : "1=1", { child1: _data.child1 }, ) @@ -6632,8 +6661,8 @@ export class ProfileController extends Controller { _data.child1 != undefined && _data.child1 != null ? _data.child1[0] != null ? `current_holders.orgChild1Id IN (:...child1)` - // : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}` - : `current_holders.orgChild1Id is null` + : // : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}` + `current_holders.orgChild1Id is null` : "1=1", { child1: _data.child1 }, ) @@ -7718,7 +7747,7 @@ export class ProfileController extends Controller { child2Id: null, child3Id: null, child4Id: null, - rootDnaId: null + rootDnaId: null, }); } return new HttpSuccess({ @@ -7728,7 +7757,7 @@ export class ProfileController extends Controller { child2Id: posMasters?.orgChild2Id || null, child3Id: posMasters?.orgChild3Id || null, child4Id: posMasters?.orgChild4Id || null, - rootDnaId: posMasters?.orgRoot?.ancestorDNA || null + rootDnaId: posMasters?.orgRoot?.ancestorDNA || null, }); } @@ -8987,8 +9016,8 @@ export class ProfileController extends Controller { _data.child1 != undefined && _data.child1 != null ? _data.child1[0] != null ? `current_holders.orgChild1Id IN (:...child1)` - // : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}` - : `current_holders.orgChild1Id is null` + : // : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}` + `current_holders.orgChild1Id is null` : "1=1", { child1: _data.child1 }, ) @@ -9511,8 +9540,8 @@ export class ProfileController extends Controller { _data.child1 != undefined && _data.child1 != null ? _data.child1[0] != null ? `current_holders.orgChild1Id IN (:...child1)` - // : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}` - : `current_holders.orgChild1Id is null` + : // : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}` + `current_holders.orgChild1Id is null` : "1=1", { child1: _data.child1, @@ -10922,28 +10951,17 @@ export class ProfileController extends Controller { organizeName = names.join(" "); } await PostRetireToExprofile( - // profile.citizenId ?? "", - // profile.prefix ?? "", - // profile.firstName ?? "", - // profile.lastName ?? "", - // requestBody.dateLeave?.getFullYear().toString() ?? "", - // profile.position, - // profile.posType?.posTypeName ?? "", - // profile.posLevel?.posLevelName ?? "", - // requestBody.dateLeave ?? new Date(), - // organizeName, - // "ถึงแก่กรรม", - "310190004095X", - "จ.ส.อ.", - "dev", - "hrms", - "2026", - "เจ้าหน้าที่จัดเก็บรายได้", - "อื่นๆ", - "C 3", - new Date(2026, 0, 1), - "สำนักงานเขตบางกอกใหญ่", - "เกษียณ" + profile.citizenId ?? "", + profile.prefix ?? "", + profile.firstName ?? "", + profile.lastName ?? "", + requestBody.dateLeave?.getFullYear().toString() ?? "", + profile.position, + profile.posType?.posTypeName ?? "", + profile.posLevel?.posLevelName ?? "", + requestBody.dateLeave ?? new Date(), + organizeName, + "ถึงแก่กรรม", ); return new HttpSuccess(); } diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 0d01f7ab..5fa532ca 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -317,7 +317,15 @@ export class ProfileEmployeeController extends Controller { ]; const educations = await this.profileEducationRepo.find({ - select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute", "isDeleted"], + select: [ + "startDate", + "endDate", + "educationLevel", + "degree", + "field", + "institute", + "isDeleted", + ], where: { profileEmployeeId: id, isDeleted: false }, order: { level: "ASC" }, }); @@ -651,7 +659,15 @@ export class ProfileEmployeeController extends Controller { ]; const education_raw = await this.profileEducationRepo.find({ - select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute", "isDeleted"], + select: [ + "startDate", + "endDate", + "educationLevel", + "degree", + "field", + "institute", + "isDeleted", + ], where: { profileEmployeeId: id, isDeleted: false }, // order: { lastUpdatedAt: "DESC" }, order: { level: "ASC" }, @@ -1048,7 +1064,14 @@ export class ProfileEmployeeController extends Controller { let _child4 = child4?.orgChild4Name; const cert_raw = await this.certificateRepository.find({ - select: ["certificateType", "issuer", "certificateNo", "issueDate", "expireDate", "isDeleted"], + select: [ + "certificateType", + "issuer", + "certificateNo", + "issueDate", + "expireDate", + "isDeleted", + ], where: { profileEmployeeId: id, isDeleted: false }, order: { createdAt: "ASC" }, }); @@ -1065,12 +1088,14 @@ export class ProfileEmployeeController extends Controller { ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.expireDate)) : "", issueToExpireDate: item.issueDate - ? item.expireDate - ? Extension.ToThaiNumber(`${Extension.ToThaiFullDate2(item.issueDate)} - ${Extension.ToThaiFullDate2(item.expireDate)}`) + ? item.expireDate + ? Extension.ToThaiNumber( + `${Extension.ToThaiFullDate2(item.issueDate)} - ${Extension.ToThaiFullDate2(item.expireDate)}`, + ) : Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.issueDate)) : item.expireDate ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.expireDate)) - : "" + : "", })) : [ { @@ -1242,7 +1267,7 @@ export class ProfileEmployeeController extends Controller { "page", "refCommandDate", "note", - "isDeleted" + "isDeleted", ], relations: { insignia: { @@ -1321,9 +1346,7 @@ export class ProfileEmployeeController extends Controller { const totalLeaveDaysKey = `totalLeaveDaysLv${lvIndex}`; const leaveTypeNameKey = `leaveTypeNameLv${lvIndex}`; - const leaveDate = item.maxDateLeaveStart - ? new Date(item.maxDateLeaveStart) - : null; + const leaveDate = item.maxDateLeaveStart ? new Date(item.maxDateLeaveStart) : null; const year = leaveDate ? Extension.ToThaiNumber(Extension.ToThaiShortYear(leaveDate)) : ""; @@ -1521,7 +1544,9 @@ export class ProfileEmployeeController extends Controller { ? actposition_raw.map((item) => ({ date: item.dateStart && item.dateEnd - ? Extension.ToThaiNumber(`${Extension.ToThaiFullDate2(item.dateStart)} - ${Extension.ToThaiFullDate2(item.dateEnd)}`) + ? Extension.ToThaiNumber( + `${Extension.ToThaiFullDate2(item.dateStart)} - ${Extension.ToThaiFullDate2(item.dateEnd)}`, + ) : item.dateStart ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateStart)) : item.dateEnd @@ -1546,7 +1571,9 @@ export class ProfileEmployeeController extends Controller { ? assistance_raw.map((item) => ({ date: item.dateStart && item.dateEnd - ? Extension.ToThaiNumber(`${Extension.ToThaiFullDate2(item.dateStart)} - ${Extension.ToThaiFullDate2(item.dateEnd)}`) + ? Extension.ToThaiNumber( + `${Extension.ToThaiFullDate2(item.dateStart)} - ${Extension.ToThaiFullDate2(item.dateEnd)}`, + ) : item.dateStart ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateStart)) : item.dateEnd @@ -1576,7 +1603,9 @@ export class ProfileEmployeeController extends Controller { ? duty_raw.map((item) => ({ date: item.dateStart && item.dateEnd - ? Extension.ToThaiNumber(`${Extension.ToThaiFullDate2(item.dateStart)} - ${Extension.ToThaiFullDate2(item.dateEnd)}`) + ? Extension.ToThaiNumber( + `${Extension.ToThaiFullDate2(item.dateStart)} - ${Extension.ToThaiFullDate2(item.dateEnd)}`, + ) : item.dateStart ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateStart)) : item.dateEnd @@ -1836,7 +1865,7 @@ export class ProfileEmployeeController extends Controller { ? Extension.ToThaiNumber(profiles.registrationZipCode) : "", fullRegistrationAddress: fullRegistrationAddress, - updateAt: profiles.lastUpdatedAt + updateAt: profiles.lastUpdatedAt ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.lastUpdatedAt)) : "", telephone: profiles.phone != null ? Extension.ToThaiNumber(profiles.phone) : "", @@ -2888,8 +2917,8 @@ export class ProfileEmployeeController extends Controller { _data.child1 != undefined && _data.child1 != null ? _data.child1[0] != null ? `current_holders.orgChild1Id IN (:...child1)` - // : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}` - : `current_holders.orgChild1Id is null` + : // : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}` + `current_holders.orgChild1Id is null` : "1=1", { child1: _data.child1, @@ -3768,8 +3797,8 @@ export class ProfileEmployeeController extends Controller { _data.child1 != undefined && _data.child1 != null ? _data.child1[0] != null ? `current_holders.orgChild1Id IN (:...child1)` - // : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}` - : `current_holders.orgChild1Id is null` + : // : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}` + `current_holders.orgChild1Id is null` : "1=1", { child1: _data.child1 }, ) @@ -4327,8 +4356,8 @@ export class ProfileEmployeeController extends Controller { _data.child1 != undefined && _data.child1 != null ? _data.child1[0] != null ? `current_holders.orgChild1Id IN (:...child1)` - // : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}` - : `current_holders.orgChild1Id is null` + : // : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}` + `current_holders.orgChild1Id is null` : "1=1", { child1: _data.child1, @@ -5396,28 +5425,17 @@ export class ProfileEmployeeController extends Controller { organizeName = names.join(" "); } await PostRetireToExprofile( - // profile.citizenId ?? "", - // profile.prefix ?? "", - // profile.firstName ?? "", - // profile.lastName ?? "", - // requestBody.dateLeave?.getFullYear().toString() ?? "", - // profile.position, - // profile.posType?.posTypeName ?? "", - // `${profile.posType?.posTypeShortName} ${profile.posLevel?.posLevelName}`, - // requestBody.dateLeave ?? new Date(), - // organizeName, - // "ถึงแก่กรรม", - "310190004095X", - "จ.ส.อ.", - "dev", - "hrms", - "2026", - "เจ้าหน้าที่จัดเก็บรายได้", - "อื่นๆ", - "C 3", - new Date(2026, 0, 1), - "สำนักงานเขตบางกอกใหญ่", - "เกษียณ" + profile.citizenId ?? "", + profile.prefix ?? "", + profile.firstName ?? "", + profile.lastName ?? "", + requestBody.dateLeave?.getFullYear().toString() ?? "", + profile.position, + profile.posType?.posTypeName ?? "", + `${profile.posType?.posTypeShortName} ${profile.posLevel?.posLevelName}`, + requestBody.dateLeave ?? new Date(), + organizeName, + "ถึงแก่กรรม", ); return new HttpSuccess(); } diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index 99e0754d..66d66dd7 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -167,7 +167,7 @@ export class ProfileEmployeeTempController extends Controller { }, }); ImgUrl = response_.data.downloadUrl; - } catch { } + } catch {} } const province = await this.provinceRepository.findOneBy({ id: profile.registrationProvinceId, @@ -179,36 +179,36 @@ export class ProfileEmployeeTempController extends Controller { const root = profile.current_holders == null || - profile.current_holders.length == 0 || - profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null + profile.current_holders.length == 0 || + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot; const child1 = profile.current_holders == null || - profile.current_holders.length == 0 || - profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null + profile.current_holders.length == 0 || + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1; const child2 = profile.current_holders == null || - profile.current_holders.length == 0 || - profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null + profile.current_holders.length == 0 || + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2; const child3 = profile.current_holders == null || - profile.current_holders.length == 0 || - profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null + profile.current_holders.length == 0 || + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3; const child4 = profile.current_holders == null || - profile.current_holders.length == 0 || - profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null + profile.current_holders.length == 0 || + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4; @@ -256,60 +256,68 @@ export class ProfileEmployeeTempController extends Controller { const salarys = salary_raw.length > 1 ? salary_raw.slice(1).map((item) => ({ - date: item.commandDateAffect - ? Extension.ToThaiNumber(Extension.ToThaiShortDate(item.commandDateAffect)) - : null, - position: Extension.ToThaiNumber( - Extension.ToThaiNumber( - `${item.positionName != null ? item.positionName : "-"} ${item.positionType == null ? item.positionCee ?? "" : (item.positionType == "อำนวยการ" || item.positionType == "บริหาร" ? item.positionType : "") + item.positionLevel}`, + date: item.commandDateAffect + ? Extension.ToThaiNumber(Extension.ToThaiShortDate(item.commandDateAffect)) + : null, + position: Extension.ToThaiNumber( + Extension.ToThaiNumber( + `${item.positionName != null ? item.positionName : "-"} ${item.positionType == null ? item.positionCee ?? "" : (item.positionType == "อำนวยการ" || item.positionType == "บริหาร" ? item.positionType : "") + item.positionLevel}`, + ), ), - ), - posNo: item.posNo != null ? Extension.ToThaiNumber(item.posNo) : "", - orgRoot: item.orgRoot != null ? Extension.ToThaiNumber(item.orgRoot) : "", - orgChild1: item.orgChild1 != null ? Extension.ToThaiNumber(item.orgChild1) : "", - orgChild2: item.orgChild2 != null ? Extension.ToThaiNumber(item.orgChild2) : "", - orgChild3: item.orgChild3 != null ? Extension.ToThaiNumber(item.orgChild3) : "", - orgChild4: item.orgChild4 != null ? Extension.ToThaiNumber(item.orgChild4) : "", - positionCee: item.positionCee != null ? Extension.ToThaiNumber(item.positionCee) : "", - positionExecutive: - item.positionExecutive != null ? Extension.ToThaiNumber(item.positionExecutive) : "", - })) + posNo: item.posNo != null ? Extension.ToThaiNumber(item.posNo) : "", + orgRoot: item.orgRoot != null ? Extension.ToThaiNumber(item.orgRoot) : "", + orgChild1: item.orgChild1 != null ? Extension.ToThaiNumber(item.orgChild1) : "", + orgChild2: item.orgChild2 != null ? Extension.ToThaiNumber(item.orgChild2) : "", + orgChild3: item.orgChild3 != null ? Extension.ToThaiNumber(item.orgChild3) : "", + orgChild4: item.orgChild4 != null ? Extension.ToThaiNumber(item.orgChild4) : "", + positionCee: item.positionCee != null ? Extension.ToThaiNumber(item.positionCee) : "", + positionExecutive: + item.positionExecutive != null ? Extension.ToThaiNumber(item.positionExecutive) : "", + })) : [ - { - date: "-", - position: "-", - posNo: "-", - orgRoot: null, - orgChild1: null, - orgChild2: null, - orgChild3: null, - orgChild4: null, - positionCee: null, - positionExecutive: null, - }, - ]; + { + date: "-", + position: "-", + posNo: "-", + orgRoot: null, + orgChild1: null, + orgChild2: null, + orgChild3: null, + orgChild4: null, + positionCee: null, + positionExecutive: null, + }, + ]; const educations = await this.profileEducationRepo.find({ - select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute", "isDeleted"], + select: [ + "startDate", + "endDate", + "educationLevel", + "degree", + "field", + "institute", + "isDeleted", + ], where: { profileEmployeeId: id, isDeleted: false }, order: { level: "ASC" }, }); const Education = educations && educations.length > 0 ? educations.map((item) => ({ - institute: item.institute ? item.institute : "-", - date: - item.startDate && item.endDate - ? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}` - : "-", - degree: item.degree && item.field ? `${item.degree} ${item.field}` : "-", - })) + institute: item.institute ? item.institute : "-", + date: + item.startDate && item.endDate + ? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}` + : "-", + degree: item.degree && item.field ? `${item.degree} ${item.field}` : "-", + })) : [ - { - institute: "-", - date: "-", - degree: "-", - }, - ]; + { + institute: "-", + date: "-", + degree: "-", + }, + ]; const mapData = { // Id: profile.id, @@ -347,10 +355,10 @@ export class ProfileEmployeeTempController extends Controller { position: salary_raw.length > 0 && salary_raw[0].positionName != null ? Extension.ToThaiNumber( - Extension.ToThaiNumber( - `${salary_raw[0].positionName != null ? salary_raw[0].positionName : "-"} ${salary_raw[0].positionType == null ? salary_raw[0].positionCee ?? "" : (salary_raw[0].positionType == "อำนวยการ" || salary_raw[0].positionType == "บริหาร" ? salary_raw[0].positionType : "") + salary_raw[0].positionLevel}`, - ), - ) + Extension.ToThaiNumber( + `${salary_raw[0].positionName != null ? salary_raw[0].positionName : "-"} ${salary_raw[0].positionType == null ? salary_raw[0].positionCee ?? "" : (salary_raw[0].positionType == "อำนวยการ" || salary_raw[0].positionType == "บริหาร" ? salary_raw[0].positionType : "") + salary_raw[0].positionLevel}`, + ), + ) : "", positionCee: salary_raw.length > 0 && salary_raw[0].positionCee != null @@ -360,22 +368,27 @@ export class ProfileEmployeeTempController extends Controller { salary_raw.length > 0 && salary_raw[0].positionExecutive != null ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].positionExecutive)) : "", - org: `${salary_raw.length > 0 && salary_raw[0].orgChild4 && salary_raw[0].orgChild4 != "-" - ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].orgChild4)) + " " - : "" - }${salary_raw.length > 0 && salary_raw[0].orgChild3 && salary_raw[0].orgChild3 != "-" + org: `${ + salary_raw.length > 0 && salary_raw[0].orgChild4 && salary_raw[0].orgChild4 != "-" + ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].orgChild4)) + " " + : "" + }${ + salary_raw.length > 0 && salary_raw[0].orgChild3 && salary_raw[0].orgChild3 != "-" ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].orgChild3)) + " " : "" - }${salary_raw.length > 0 && salary_raw[0].orgChild2 && salary_raw[0].orgChild2 != "-" + }${ + salary_raw.length > 0 && salary_raw[0].orgChild2 && salary_raw[0].orgChild2 != "-" ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].orgChild2)) + " " : "" - }${salary_raw.length > 0 && salary_raw[0].orgChild1 && salary_raw[0].orgChild1 != "-" + }${ + salary_raw.length > 0 && salary_raw[0].orgChild1 && salary_raw[0].orgChild1 != "-" ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].orgChild1)) + " " : "" - }${salary_raw.length > 0 && salary_raw[0].orgRoot && salary_raw[0].orgRoot != "-" + }${ + salary_raw.length > 0 && salary_raw[0].orgRoot && salary_raw[0].orgRoot != "-" ? Extension.ToThaiNumber(Extension.ToThaiNumber(salary_raw[0].orgRoot)) : "" - }`, + }`, ocFullPath: (_child4 == null ? "" : _child4 + "\n") + (_child3 == null ? "" : _child3 + "\n") + @@ -448,7 +461,7 @@ export class ProfileEmployeeTempController extends Controller { }, }); _ImgUrl[i] = response_.data.downloadUrl; - } catch { } + } catch {} } }), ); @@ -462,7 +475,7 @@ export class ProfileEmployeeTempController extends Controller { }, }); ImgUrl = response_.data.downloadUrl; - } catch { } + } catch {} } const profileOc = await this.profileRepo.findOne({ relations: [ @@ -501,36 +514,36 @@ export class ProfileEmployeeTempController extends Controller { const root = profileOc.current_holders == null || - profileOc.current_holders.length == 0 || - profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null + profileOc.current_holders.length == 0 || + profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null ? null : profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot; const child1 = profileOc.current_holders == null || - profileOc.current_holders.length == 0 || - profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null + profileOc.current_holders.length == 0 || + profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null ? null : profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1; const child2 = profileOc.current_holders == null || - profileOc.current_holders.length == 0 || - profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null + profileOc.current_holders.length == 0 || + profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null ? null : profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2; const child3 = profileOc.current_holders == null || - profileOc.current_holders.length == 0 || - profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null + profileOc.current_holders.length == 0 || + profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null ? null : profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3; const child4 = profileOc.current_holders == null || - profileOc.current_holders.length == 0 || - profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null + profileOc.current_holders.length == 0 || + profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null ? null : profileOc.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4; @@ -549,19 +562,19 @@ export class ProfileEmployeeTempController extends Controller { const certs = cert_raw.length > 0 ? cert_raw.slice(-2).map((item) => ({ - CertificateType: item.certificateType ?? null, - Issuer: item.issuer ?? null, - CertificateNo: Extension.ToThaiNumber(item.certificateNo) ?? null, - IssueDate: Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.issueDate)) ?? null, - })) + CertificateType: item.certificateType ?? null, + Issuer: item.issuer ?? null, + CertificateNo: Extension.ToThaiNumber(item.certificateNo) ?? null, + IssueDate: Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.issueDate)) ?? null, + })) : [ - { - CertificateType: "-", - Issuer: "-", - CertificateNo: "-", - IssueDate: "-", - }, - ]; + { + CertificateType: "-", + Issuer: "-", + CertificateNo: "-", + IssueDate: "-", + }, + ]; const training_raw = await this.trainingRepository.find({ select: ["startDate", "endDate", "place", "department"], where: { profileEmployeeId: id }, @@ -570,34 +583,34 @@ export class ProfileEmployeeTempController extends Controller { const trainings = training_raw.length > 0 ? training_raw.slice(-2).map((item) => ({ - Institute: item.department ?? "", - Start: - item.startDate == null - ? "" - : Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate)), - End: - item.endDate == null - ? "" - : Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate)), - Date: - item.startDate && item.endDate - ? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}` - : "", - Level: "", - Degree: item.name, - Field: "", - })) + Institute: item.department ?? "", + Start: + item.startDate == null + ? "" + : Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate)), + End: + item.endDate == null + ? "" + : Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate)), + Date: + item.startDate && item.endDate + ? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}` + : "", + Level: "", + Degree: item.name, + Field: "", + })) : [ - { - Institute: "-", - Start: "-", - End: "-", - Date: "-", - Level: "-", - Degree: "-", - Field: "-", - }, - ]; + { + Institute: "-", + Start: "-", + End: "-", + Date: "-", + Level: "-", + Degree: "-", + Field: "-", + }, + ]; const discipline_raw = await this.disciplineRepository.find({ select: ["refCommandDate", "refCommandNo", "detail"], @@ -607,22 +620,30 @@ export class ProfileEmployeeTempController extends Controller { const disciplines = discipline_raw.length > 0 ? discipline_raw.slice(-2).map((item) => ({ - DisciplineYear: - Extension.ToThaiNumber(new Date(item.refCommandDate).getFullYear().toString()) ?? - null, - DisciplineDetail: item.detail ?? null, - RefNo: Extension.ToThaiNumber(item.refCommandNo) ?? null, - })) + DisciplineYear: + Extension.ToThaiNumber(new Date(item.refCommandDate).getFullYear().toString()) ?? + null, + DisciplineDetail: item.detail ?? null, + RefNo: Extension.ToThaiNumber(item.refCommandNo) ?? null, + })) : [ - { - DisciplineYear: "-", - DisciplineDetail: "-", - RefNo: "-", - }, - ]; + { + DisciplineYear: "-", + DisciplineDetail: "-", + RefNo: "-", + }, + ]; const education_raw = await this.profileEducationRepo.find({ - select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute", "isDeleted"], + select: [ + "startDate", + "endDate", + "educationLevel", + "degree", + "field", + "institute", + "isDeleted", + ], where: { profileEmployeeId: id, isDeleted: false }, // order: { lastUpdatedAt: "DESC" }, order: { level: "ASC" }, @@ -630,34 +651,34 @@ export class ProfileEmployeeTempController extends Controller { const educations = education_raw.length > 0 ? education_raw.slice(-2).map((item) => ({ - Institute: item.institute, - Start: - item.startDate == null - ? "" - : Extension.ToThaiNumber(new Date(item.startDate).getFullYear().toString()), - End: - item.endDate == null - ? "" - : Extension.ToThaiNumber(new Date(item.endDate).getFullYear().toString()), - Date: - item.startDate && item.endDate - ? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}` - : "", - Level: item.educationLevel ?? "", - Degree: item.degree ? `${item.degree} ${item.field ? item.field : ""}` : "", - Field: item.field ?? "-", - })) + Institute: item.institute, + Start: + item.startDate == null + ? "" + : Extension.ToThaiNumber(new Date(item.startDate).getFullYear().toString()), + End: + item.endDate == null + ? "" + : Extension.ToThaiNumber(new Date(item.endDate).getFullYear().toString()), + Date: + item.startDate && item.endDate + ? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}` + : "", + Level: item.educationLevel ?? "", + Degree: item.degree ? `${item.degree} ${item.field ? item.field : ""}` : "", + Field: item.field ?? "-", + })) : [ - { - Institute: "-", - Start: "-", - End: "-", - Date: "-", - Level: "-", - Degree: "-", - Field: "-", - }, - ]; + { + Institute: "-", + Start: "-", + End: "-", + Date: "-", + Level: "-", + Degree: "-", + Field: "-", + }, + ]; const salary_raw = await this.salaryRepo.find({ select: [ "commandDateAffect", @@ -678,50 +699,50 @@ export class ProfileEmployeeTempController extends Controller { const salarys = salary_raw.length > 0 ? salary_raw.map((item) => ({ - SalaryDate: item.commandDateAffect - ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateAffect)) - : null, - Position: item.positionName != null ? Extension.ToThaiNumber(item.positionName) : null, - PosNo: item.posNo != null ? Extension.ToThaiNumber(item.posNo) : null, - Salary: - item.amount != null ? Extension.ToThaiNumber(item.amount.toLocaleString()) : null, - Special: - item.amountSpecial != null - ? Extension.ToThaiNumber(item.amountSpecial.toLocaleString()) + SalaryDate: item.commandDateAffect + ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateAffect)) : null, - Rank: item.positionLevel != null ? Extension.ToThaiNumber(item.positionLevel) : null, - RefAll: item.remark ? Extension.ToThaiNumber(item.remark) : null, - PositionLevel: - item.positionLevel != null ? Extension.ToThaiNumber(item.positionLevel) : null, - PositionType: item.positionType ?? null, - PositionAmount: - item.positionSalaryAmount == null - ? null - : Extension.ToThaiNumber(item.positionSalaryAmount.toLocaleString()), - FullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`, - OcFullPath: - (_child4 == null ? "" : _child4 + "\n") + - (_child3 == null ? "" : _child3 + "\n") + - (_child2 == null ? "" : _child2 + "\n") + - (_child1 == null ? "" : _child1 + "\n") + - (_root == null ? "" : _root), - })) + Position: item.positionName != null ? Extension.ToThaiNumber(item.positionName) : null, + PosNo: item.posNo != null ? Extension.ToThaiNumber(item.posNo) : null, + Salary: + item.amount != null ? Extension.ToThaiNumber(item.amount.toLocaleString()) : null, + Special: + item.amountSpecial != null + ? Extension.ToThaiNumber(item.amountSpecial.toLocaleString()) + : null, + Rank: item.positionLevel != null ? Extension.ToThaiNumber(item.positionLevel) : null, + RefAll: item.remark ? Extension.ToThaiNumber(item.remark) : null, + PositionLevel: + item.positionLevel != null ? Extension.ToThaiNumber(item.positionLevel) : null, + PositionType: item.positionType ?? null, + PositionAmount: + item.positionSalaryAmount == null + ? null + : Extension.ToThaiNumber(item.positionSalaryAmount.toLocaleString()), + FullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`, + OcFullPath: + (_child4 == null ? "" : _child4 + "\n") + + (_child3 == null ? "" : _child3 + "\n") + + (_child2 == null ? "" : _child2 + "\n") + + (_child1 == null ? "" : _child1 + "\n") + + (_root == null ? "" : _root), + })) : [ - { - SalaryDate: "-", - Position: "-", - PosNo: "-", - Salary: "-", - Special: "-", - Rank: "-", - RefAll: "-", - PositionLevel: "-", - PositionType: "-", - PositionAmount: "-", - FullName: "-", - OcFullPath: "-", - }, - ]; + { + SalaryDate: "-", + Position: "-", + PosNo: "-", + Salary: "-", + Special: "-", + Rank: "-", + RefAll: "-", + PositionLevel: "-", + PositionType: "-", + PositionAmount: "-", + FullName: "-", + OcFullPath: "-", + }, + ]; const insignia_raw = await this.profileInsigniaRepo.find({ relations: { @@ -735,37 +756,37 @@ export class ProfileEmployeeTempController extends Controller { const insignias = insignia_raw.length > 0 ? insignia_raw.map((item) => ({ - ReceiveDate: item.receiveDate - ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.receiveDate)) - : "", - InsigniaName: item.insignia.name, - InsigniaShortName: item.insignia.shortName, - InsigniaTypeName: item.insignia.insigniaType.name, - No: item.no ? Extension.ToThaiNumber(item.no) : "", - Issue: item.issue ? item.issue : "", - VolumeNo: item.volumeNo ? Extension.ToThaiNumber(item.volumeNo) : "", - Volume: item.volume ? Extension.ToThaiNumber(item.volume) : "", - Section: item.section ? Extension.ToThaiNumber(item.section) : "", - Page: item.page ? Extension.ToThaiNumber(item.page) : "", - RefCommandDate: item.refCommandDate - ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.refCommandDate)) - : "", - })) + ReceiveDate: item.receiveDate + ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.receiveDate)) + : "", + InsigniaName: item.insignia.name, + InsigniaShortName: item.insignia.shortName, + InsigniaTypeName: item.insignia.insigniaType.name, + No: item.no ? Extension.ToThaiNumber(item.no) : "", + Issue: item.issue ? item.issue : "", + VolumeNo: item.volumeNo ? Extension.ToThaiNumber(item.volumeNo) : "", + Volume: item.volume ? Extension.ToThaiNumber(item.volume) : "", + Section: item.section ? Extension.ToThaiNumber(item.section) : "", + Page: item.page ? Extension.ToThaiNumber(item.page) : "", + RefCommandDate: item.refCommandDate + ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.refCommandDate)) + : "", + })) : [ - { - ReceiveDate: "-", - InsigniaName: "-", - InsigniaShortName: "-", - InsigniaTypeName: "-", - No: "-", - Issue: "-", - VolumeNo: "-", - Volume: "-", - Section: "-", - Page: "-", - RefCommandDate: "-", - }, - ]; + { + ReceiveDate: "-", + InsigniaName: "-", + InsigniaShortName: "-", + InsigniaTypeName: "-", + No: "-", + Issue: "-", + VolumeNo: "-", + Volume: "-", + Section: "-", + Page: "-", + RefCommandDate: "-", + }, + ]; const leave_raw = await this.profileLeaveRepository.find({ relations: { leaveType: true }, @@ -775,19 +796,19 @@ export class ProfileEmployeeTempController extends Controller { const leaves = leave_raw.length > 0 ? leave_raw.map((item) => ({ - LeaveTypeName: item.leaveType.name, - DateLeaveStart: item.dateLeaveStart - ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateLeaveStart)) - : "", - LeaveDays: item.leaveDays ? Extension.ToThaiNumber(item.leaveDays.toString()) : "", - })) + LeaveTypeName: item.leaveType.name, + DateLeaveStart: item.dateLeaveStart + ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateLeaveStart)) + : "", + LeaveDays: item.leaveDays ? Extension.ToThaiNumber(item.leaveDays.toString()) : "", + })) : [ - { - LeaveTypeName: "-", - DateLeaveStart: "-", - LeaveDays: "-", - }, - ]; + { + LeaveTypeName: "-", + DateLeaveStart: "-", + LeaveDays: "-", + }, + ]; const data = { fullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`, @@ -814,20 +835,20 @@ export class ProfileEmployeeTempController extends Controller { profiles.citizenId != null ? Extension.ToThaiNumber(profiles.citizenId.toString()) : "", fatherFullName: profileFamilyFather?.fatherPrefix || - profileFamilyFather?.fatherFirstName || - profileFamilyFather?.fatherLastName + profileFamilyFather?.fatherFirstName || + profileFamilyFather?.fatherLastName ? `${profileFamilyFather?.fatherPrefix ?? ""}${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim() : null, motherFullName: profileFamilyMother?.motherPrefix || - profileFamilyMother?.motherFirstName || - profileFamilyMother?.motherLastName + profileFamilyMother?.motherFirstName || + profileFamilyMother?.motherLastName ? `${profileFamilyMother?.motherPrefix ?? ""}${profileFamilyMother?.motherFirstName ?? ""} ${profileFamilyMother?.motherLastName ?? ""}`.trim() : null, coupleFullName: profileFamilyCouple?.couplePrefix || - profileFamilyCouple?.coupleFirstName || - profileFamilyCouple?.coupleLastNameOld + profileFamilyCouple?.coupleFirstName || + profileFamilyCouple?.coupleLastNameOld ? `${profileFamilyCouple?.couplePrefix ?? ""}${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastName ?? ""}`.trim() : null, coupleLastNameOld: profileFamilyCouple?.coupleLastNameOld ?? null, @@ -1105,8 +1126,8 @@ export class ProfileEmployeeTempController extends Controller { _dataOrg.child1 != undefined && _dataOrg.child1 != null ? _dataOrg.child1[0] != null ? `current_holderTemps.orgChild1Id IN (:...child1)` - // : `current_holderTemps.orgChild1Id is ${_dataOrg.privilege == "PARENT" ? "not null" : "null"}` - : `current_holders.orgChild1Id is null` + : // : `current_holderTemps.orgChild1Id is ${_dataOrg.privilege == "PARENT" ? "not null" : "null"}` + `current_holders.orgChild1Id is null` : "1=1", { child1: _dataOrg.child1, @@ -1176,8 +1197,8 @@ export class ProfileEmployeeTempController extends Controller { _data.profileEmployeeEmployment.length == 0 ? null : _data.profileEmployeeEmployment.reduce((latest, current) => { - return latest.date > current.date ? latest : current; - }).date; + return latest.date > current.date ? latest : current; + }).date; return { id: _data.id, prefix: _data.prefix, @@ -1327,32 +1348,32 @@ export class ProfileEmployeeTempController extends Controller { profile.current_holders.length == 0 ? null : profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && - profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 != - null + profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 != + null ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && - profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) - ?.orgChild3 != null + profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) + ?.orgChild3 != null ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && - profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) - ?.orgChild2 != null + profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) + ?.orgChild2 != null ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && - profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) - ?.orgChild1 != null + profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) + ?.orgChild1 != null ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) != - null && - profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) - ?.orgRoot != null + null && + profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) + ?.orgRoot != null ? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; const root = profile.current_holders.length == 0 || - (profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && - profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null) + (profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && + profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null) ? null : profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot; @@ -1561,8 +1582,8 @@ export class ProfileEmployeeTempController extends Controller { _data.child1 != undefined && _data.child1 != null ? _data.child1[0] != null ? `current_holderTemps.orgChild1Id IN (:...child1)` - // : `current_holderTemps.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}` - : `current_holders.orgChild1Id is null` + : // : `current_holderTemps.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}` + `current_holders.orgChild1Id is null` : "1=1", { child1: _data.child1, @@ -1673,35 +1694,35 @@ export class ProfileEmployeeTempController extends Controller { _data.current_holderTemps.length == 0 ? null : _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null && - _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) - ?.orgChild4 != null + _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) + ?.orgChild4 != null ? `${_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null && - _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) - ?.orgChild3 != null + _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) + ?.orgChild3 != null ? `${_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != - null && - _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) - ?.orgChild2 != null + null && + _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) + ?.orgChild2 != null ? `${_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != - null && - _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) - ?.orgChild1 != null + null && + _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) + ?.orgChild1 != null ? `${_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != - null && - _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) - ?.orgRoot != null + null && + _data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) + ?.orgRoot != null ? `${_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${_data.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; const dateEmployment = _data.profileEmployeeEmployment.length == 0 ? null : _data.profileEmployeeEmployment.reduce((latest, current) => { - return latest.date > current.date ? latest : current; - }).date; + return latest.date > current.date ? latest : current; + }).date; return { id: _data.id, prefix: _data.prefix, @@ -1952,8 +1973,8 @@ export class ProfileEmployeeTempController extends Controller { .map((x) => x.current_holderId).length == 0 ? ["zxc"] : orgRevision.employeeTempPosMasters - .filter((x) => x.current_holderId != null) - .map((x) => x.current_holderId), + .filter((x) => x.current_holderId != null) + .map((x) => x.current_holderId), }); }), ) @@ -2122,74 +2143,74 @@ export class ProfileEmployeeTempController extends Controller { posTypeId: profile.posType == null ? null : profile.posType.id, rootId: profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot == + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) - ?.orgRootId, + ?.orgRootId, root: profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot == + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot - .orgRootName, + .orgRootName, child1Id: profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1 == + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) - ?.orgChild1Id, + ?.orgChild1Id, child1: profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1 == + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1 - .orgChild1Name, + .orgChild1Name, child2Id: profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2 == + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) - ?.orgChild2Id, + ?.orgChild2Id, child2: profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2 == + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2 - .orgChild2Name, + .orgChild2Name, child3Id: profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3 == + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) - ?.orgChild3Id, + ?.orgChild3Id, child3: profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3 == + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3 - .orgChild3Name, + .orgChild3Name, child4Id: profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4 == + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) - ?.orgChild4Id, + ?.orgChild4Id, child4: profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4 == + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4 - .orgChild4Name, + .orgChild4Name, salary: profile ? profile.amount : null, amountSpecial: profile ? profile.amountSpecial : null, }; @@ -2273,8 +2294,8 @@ export class ProfileEmployeeTempController extends Controller { _data.child1 != undefined && _data.child1 != null ? _data.child1[0] != null ? `current_holderTemps.orgChild1Id IN (:...child1)` - // : `current_holderTemps.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}` - : `current_holders.orgChild1Id is null` + : // : `current_holderTemps.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}` + `current_holders.orgChild1Id is null` : "1=1", { child1: _data.child1 }, ) @@ -2318,34 +2339,34 @@ export class ProfileEmployeeTempController extends Controller { item.current_holderTemps.length == 0 ? null : item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null && - item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) - ?.orgChild4 != null + item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) + ?.orgChild4 != null ? `${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null && - item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) - ?.orgChild3 != null + item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) + ?.orgChild3 != null ? `${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != - null && - item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) - ?.orgChild2 != null + null && + item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) + ?.orgChild2 != null ? `${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != - null && - item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) - ?.orgChild1 != null + null && + item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) + ?.orgChild1 != null ? `${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != - null && - item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) - ?.orgRoot != null + null && + item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) + ?.orgRoot != null ? `${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; const root = item.current_holderTemps.length == 0 || - (item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null && - item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == + (item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null && + item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null) ? null : item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot; @@ -2831,54 +2852,54 @@ export class ProfileEmployeeTempController extends Controller { isProbation: item.isProbation, orgRootName: item.current_holders == null || - item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null || - item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot == + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null || + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot == null || - item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot - ?.orgRootName == null + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot + ?.orgRootName == null ? null : item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot - ?.orgRootName, + ?.orgRootName, orgChild1Name: item.current_holders == null || - item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null || - item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild1 == + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null || + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild1 == null || - item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild1 - ?.orgChild1Name == null + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild1 + ?.orgChild1Name == null ? null : item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) - ?.orgChild1?.orgChild1Name, + ?.orgChild1?.orgChild1Name, orgChild2Name: item.current_holders == null || - item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null || - item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild2 == + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null || + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild2 == null || - item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild2 - ?.orgChild2Name == null + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild2 + ?.orgChild2Name == null ? null : item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) - ?.orgChild2?.orgChild2Name, + ?.orgChild2?.orgChild2Name, orgChild3Name: item.current_holders == null || - item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null || - item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild3 == + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null || + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild3 == null || - item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild3 - ?.orgChild3Name == null + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild3 + ?.orgChild3Name == null ? null : item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) - ?.orgChild3?.orgChild3Name, + ?.orgChild3?.orgChild3Name, orgChild4Name: item.current_holders == null || - item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null || - item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild4 == + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null || + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild4 == null || - item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild4 - ?.orgChild4Name == null + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild4 + ?.orgChild4Name == null ? null : item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) - ?.orgChild4?.orgChild4Name, + ?.orgChild4?.orgChild4Name, }; }), ); @@ -3097,7 +3118,7 @@ export class ProfileEmployeeTempController extends Controller { isLeave: false, isRetired: item.current_holder.birthDate == null || - calculateRetireDate(item.current_holder.birthDate).getFullYear() != body.year + calculateRetireDate(item.current_holder.birthDate).getFullYear() != body.year ? false : true, isSpecial: false, @@ -3153,68 +3174,68 @@ export class ProfileEmployeeTempController extends Controller { posTypeId: profile.posType == null ? null : profile.posType.id, rootId: profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || - profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot == null + profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot == null ? null : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRootId, root: profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || - profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot == null + profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot == null ? null : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot.orgRootName, child1Id: profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || - profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1 == null + profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1Id, child1: profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || - profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1 == null + profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1 - .orgChild1Name, + .orgChild1Name, child2Id: profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || - profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2 == null + profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2Id, child2: profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || - profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2 == null + profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2 - .orgChild2Name, + .orgChild2Name, child3Id: profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || - profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3 == null + profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3Id, child3: profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || - profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3 == null + profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3 - .orgChild3Name, + .orgChild3Name, child4Id: profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || - profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4 == null + profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4Id, child4: profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || - profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4 == null + profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4 - .orgChild4Name, + .orgChild4Name, }; return new HttpSuccess(_profile); } @@ -3267,8 +3288,8 @@ export class ProfileEmployeeTempController extends Controller { const formattedData = profiles.map((item) => { const posMaster = item.current_holders == null || - item.current_holders.length == 0 || - item.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null + item.current_holders.length == 0 || + item.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null ? null : item.current_holders.find((x) => x.orgRevisionId == findRevision.id); // const posExecutive = @@ -3293,49 +3314,49 @@ export class ProfileEmployeeTempController extends Controller { item.current_holders.length == 0 ? null : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 != - null + item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 != + null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 != - null + item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 != + null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2 != - null + item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2 != + null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision.id) - ?.orgChild1 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision.id) + ?.orgChild1 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision.id) - ?.orgRoot != null + item.current_holders.find((x) => x.orgRevisionId == findRevision.id) + ?.orgRoot != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; const root = item.current_holders == null || - item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null + item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null ? null : item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot; const child1 = item.current_holders == null || - item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1 == null + item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1 == null ? null : item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1; const child2 = item.current_holders == null || - item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2 == null + item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2 == null ? null : item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2; const child3 = item.current_holders == null || - item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 == null + item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 == null ? null : item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3; const child4 = item.current_holders == null || - item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 == null + item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 == null ? null : item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4; @@ -3459,24 +3480,24 @@ export class ProfileEmployeeTempController extends Controller { !profile.current_holders || profile.current_holders.length == 0 ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && - profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 != - null + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4 != + null ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}` : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && - profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3 != - null + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3 != + null ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}` : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && - profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) - ?.orgChild2 != null + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) + ?.orgChild2 != null ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2.orgChild2ShortName}` : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && - profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) - ?.orgChild1 != null + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) + ?.orgChild1 != null ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}` : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && - profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) - ?.orgRoot != null + profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) + ?.orgRoot != null ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}` : null; const dest_item = await this.salaryRepo.findOne({ @@ -3560,28 +3581,17 @@ export class ProfileEmployeeTempController extends Controller { organizeName = names.join(" "); } await PostRetireToExprofile( - // profile.citizenId ?? "", - // profile.prefix ?? "", - // profile.firstName ?? "", - // profile.lastName ?? "", - // requestBody.dateLeave?.getFullYear().toString() ?? "", - // profile.position, - // profile.posType?.posTypeName ?? "", - // `${profile.posType?.posTypeShortName} ${profile.posLevel?.posLevelName}`, - // requestBody.dateLeave ?? new Date(), - // organizeName, - // "ถึงแก่กรรม", - "310190004095X", - "จ.ส.อ.", - "dev", - "hrms", - "2026", - "เจ้าหน้าที่จัดเก็บรายได้", - "อื่นๆ", - "C 3", - new Date(2026, 0, 1), - "สำนักงานเขตบางกอกใหญ่", - "เกษียณ" + profile.citizenId ?? "", + profile.prefix ?? "", + profile.firstName ?? "", + profile.lastName ?? "", + requestBody.dateLeave?.getFullYear().toString() ?? "", + profile.position, + profile.posType?.posTypeName ?? "", + `${profile.posType?.posTypeShortName} ${profile.posLevel?.posLevelName}`, + requestBody.dateLeave ?? new Date(), + organizeName, + "ถึงแก่กรรม", ); return new HttpSuccess(); } @@ -3918,7 +3928,7 @@ export class ProfileEmployeeTempController extends Controller { positionId: profile.positionIdTemp, profileId: profile.id, }) - .then(async () => { }); + .then(async () => {}); } }), ); @@ -4009,32 +4019,32 @@ export class ProfileEmployeeTempController extends Controller { item.current_holders.length == 0 ? null : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 != - null + item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 != + null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 != - null + item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 != + null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision.id) - ?.orgChild2 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision.id) + ?.orgChild2 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision.id) - ?.orgChild1 != null + item.current_holders.find((x) => x.orgRevisionId == findRevision.id) + ?.orgChild1 != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != - null && - item.current_holders.find((x) => x.orgRevisionId == findRevision.id) - ?.orgRoot != null + null && + item.current_holders.find((x) => x.orgRevisionId == findRevision.id) + ?.orgRoot != null ? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}` : null; const root = item.current_holders.length == 0 || - (item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && - item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null) + (item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && + item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null) ? null : item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot; @@ -4127,36 +4137,36 @@ export class ProfileEmployeeTempController extends Controller { const posMaster = profile.current_holders == null || - profile.current_holders.length == 0 || - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) == null + profile.current_holders.length == 0 || + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id); const root = profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot == null + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot; const child1 = profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1 == + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1; const child2 = profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2 == + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2; const child3 = profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3 == + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3; const child4 = profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4 == + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4; @@ -4170,27 +4180,27 @@ export class ProfileEmployeeTempController extends Controller { profile.current_holders.length == 0 ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) != null && - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) - ?.orgChild4 != null + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) + ?.orgChild4 != null ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4.orgChild4ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) != null && - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) - ?.orgChild3 != null + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) + ?.orgChild3 != null ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3.orgChild3ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) != - null && - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) - ?.orgChild2 != null + null && + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) + ?.orgChild2 != null ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2.orgChild2ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) != - null && - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) - ?.orgChild1 != null + null && + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) + ?.orgChild1 != null ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1.orgChild1ShortName} ${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) != - null && - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) - ?.orgRoot != null + null && + profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) + ?.orgRoot != null ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot.orgRootShortName} ${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` : null; const _profile: any = {