From 3b3b6e605e1b834d18a1ff0064a373e4f4375ce5 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Thu, 7 Nov 2024 13:27:29 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=87=E0=B8=B4=E0=B8=99=E0=B9=80?= =?UTF-8?q?=E0=B8=94=E0=B8=B7=E0=B8=AD=E0=B8=99=E0=B8=A5=E0=B9=88=E0=B8=B2?= =?UTF-8?q?=E0=B8=AA=E0=B8=B8=E0=B8=94=E0=B8=94=E0=B8=B6=E0=B8=87=E0=B8=88?= =?UTF-8?q?=E0=B8=B2=E0=B8=81=20profile=20#760?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 197 +++++--- src/controllers/ProfileController.ts | 727 ++++++++++++++++++--------- 2 files changed, 636 insertions(+), 288 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 60e1075e..6f93e9a3 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -2313,7 +2313,7 @@ export class CommandController extends Controller { await Promise.all( body.data.map(async (item) => { const profile = await this.profileRepository.findOne({ - relations: ["profileSalary"], + relations: ["profileSalary","posLevel","posType","current_holders"], where: { id: item.profileId }, order: { profileSalary: { @@ -2324,7 +2324,38 @@ export class CommandController extends Controller { if (!profile) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้"); } - + const orgRevision = await this.orgRevisionRepo.findOne({ + where:{ + orgRevisionIsCurrent: true, + orgRevisionIsDraft: false + } + }) + const shortName = + !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.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : null; + let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null; // ประวัติตำแหน่ง const data = new ProfileSalary(); const meta = { @@ -2333,18 +2364,13 @@ export class CommandController extends Controller { date: item.date, refCommandNo: item.refCommandNo, templateDoc: item.salaryRef, - position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, - positionType: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, - positionLevel: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, - posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, - positionLine: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, - positionPathSide: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, - positionExecutive: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, + position: profile.position, + positionType: profile.posType.posTypeName, + positionLevel: profile.posLevel.posLevelName, + posNo: shortName?shortName:"-", + positionLine: position?.positionField ?? "-", + positionPathSide: position?.positionArea ?? "-", + positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", amount: item.amount ? item.amount : null, positionSalaryAmount: item.positionSalaryAmount ? item.positionSalaryAmount : null, mouthSalaryAmount: item.mouthSalaryAmount ? item.mouthSalaryAmount : null, @@ -2449,7 +2475,7 @@ export class CommandController extends Controller { await Promise.all( body.data.map(async (item) => { const profile = await this.profileRepository.findOne({ - relations: ["profileSalary"], + relations: ["profileSalary","posType","posLevel"], where: { id: item.profileId }, order: { profileSalary: { @@ -2461,6 +2487,39 @@ export class CommandController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้"); } + const orgRevision = await this.orgRevisionRepo.findOne({ + where:{ + orgRevisionIsCurrent: true, + orgRevisionIsDraft: false + } + }) + + const shortName = + !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.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : null; + let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null; // ประวัติตำแหน่ง const data = new ProfileSalary(); const meta = { @@ -2468,18 +2527,13 @@ export class CommandController extends Controller { date: item.date, refCommandNo: item.refCommandNo, templateDoc: item.salaryRef, - position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, - positionType: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, - positionLevel: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, - posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, - positionLine: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, - positionPathSide: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, - positionExecutive: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, + position: profile.position, + positionType: profile.posType.posTypeName, + positionLevel: profile.posLevel.posLevelName, + posNo: shortName?shortName:"-", + positionLine: position?.positionField ?? "-", + positionPathSide: position?.positionArea ?? "-", + positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", amount: item.amount ? item.amount : null, positionSalaryAmount: item.positionSalaryAmount ? item.positionSalaryAmount : null, mouthSalaryAmount: item.mouthSalaryAmount ? item.mouthSalaryAmount : null, @@ -2496,7 +2550,6 @@ export class CommandController extends Controller { createdAt: new Date(), lastUpdatedAt: new Date(), }; - Object.assign(data, meta); const history = new ProfileSalaryHistory(); Object.assign(history, { ...data, id: undefined }); @@ -2531,7 +2584,7 @@ export class CommandController extends Controller { await Promise.all( body.data.map(async (item) => { const profile = await this.profileRepository.findOne({ - relations: ["profileSalary"], + relations: ["profileSalary","posType","posLevel",'current_holders','current_holders.positions','current_holders.positions.posExecutive'], where: { id: item.profileId }, order: { profileSalary: { @@ -2549,7 +2602,6 @@ export class CommandController extends Controller { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์"); } let dateLeave_: any = item.date; - await removeProfileInOrganize(profile.id, "OFFICER"); _profile.isLeave = true; _profile.leaveReason = "คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด"; @@ -2557,24 +2609,52 @@ export class CommandController extends Controller { _profile.lastUpdateUserId = req.user.sub; _profile.lastUpdateFullName = req.user.name; _profile.lastUpdatedAt = new Date(); + + const orgRevision = await this.orgRevisionRepo.findOne({ + where:{ + orgRevisionIsCurrent: true, + orgRevisionIsDraft: false + } + }) + const shortName = + !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.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : null; + let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null; const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { profileId: item.profileId, date: item.date, refCommandNo: item.refCommandNo, templateDoc: item.salaryRef, commandId: item.commandId, - position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, - positionType: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, - positionLevel: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, - posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, - positionLine: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, - positionPathSide: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, - positionExecutive: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, + position: profile.position, + positionType: profile.posType.posTypeName, + positionLevel: profile.posLevel.posLevelName, + posNo: shortName, + positionLine: position?.positionField ?? "-", + positionPathSide: position?.positionArea ?? "-", + positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", amount: item.amount ? item.amount : null, positionSalaryAmount: item.positionSalaryAmount ? item.positionSalaryAmount : null, mouthSalaryAmount: item.mouthSalaryAmount ? item.mouthSalaryAmount : null, @@ -2593,25 +2673,26 @@ export class CommandController extends Controller { dateGovernment: new Date(), isGovernment: item.isGovernment, }); + await removeProfileInOrganize(profile.id, "OFFICER"); const clearProfile = await checkCommandType(String(item.commandId)); const _null: any = null; if (clearProfile) { - if (_profile.keycloak != null) { - const delUserKeycloak = await deleteUser(_profile.keycloak); - if (delUserKeycloak) _profile.keycloak = _null; - } - _profile.position = _null; - _profile.posTypeId = _null; - _profile.posLevelId = _null; - } - await Promise.all([ - this.profileRepository.save(_profile), - this.salaryRepo.save(profileSalary), - ]); - const history = new ProfileSalaryHistory(); - Object.assign(history, { ...profileSalary, id: undefined }); - history.profileSalaryId = profileSalary.id; - await this.salaryHistoryRepo.save(history); + if (_profile.keycloak != null) { + const delUserKeycloak = await deleteUser(_profile.keycloak); + if (delUserKeycloak) _profile.keycloak = _null; + } + _profile.position = _null; + _profile.posTypeId = _null; + _profile.posLevelId = _null; + } + await Promise.all([ + this.profileRepository.save(_profile), + this.salaryRepo.save(profileSalary), + ]); + const history = new ProfileSalaryHistory(); + Object.assign(history, { ...profileSalary, id: undefined }); + history.profileSalaryId = profileSalary.id; + await this.salaryHistoryRepo.save(history); }), ); diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index ba464a1f..073cd6a5 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -252,9 +252,8 @@ export class ProfileController extends Controller { profile.dateRetire != null ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.dateRetire)) : "-", - salaryAmount: - profile.profileSalary.length > 0 && profile.profileSalary[0].amount != null - ? Extension.ToThaiNumber(profile.profileSalary[0].amount.toLocaleString()) + salaryAmount: profile.amount != null + ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "-", registrationAddress: Extension.ToThaiNumber( `${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`, @@ -1905,7 +1904,38 @@ export class ProfileController extends Controller { } // const posType = await this.posTypeRepo.findOneBy({ id: String(profile.posTypeId) }) // const posLevel = await this.posLevelRepo.findOneBy({ id: String(profile.posLevelId) }) - + const orgRevision = await this.orgRevisionRepo.findOne({ + where:{ + orgRevisionIsCurrent: true, + orgRevisionIsDraft: false + } + }) + const shortName = + !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.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : null; + let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null; if (profile.isProbation != false) { profile.isProbation = false; profile.lastUpdateUserId = req.user.sub; @@ -1917,23 +1947,16 @@ export class ProfileController extends Controller { refCommandNo: body.refCommandNo, templateDoc: body.salaryRef, //profile.position, - position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, - positionType: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, - positionLevel: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, - posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, - positionLine: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, - positionPathSide: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, - positionExecutive: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, - amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, - positionSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, - mouthSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, + position: profile.position, + positionType: profile.posType.posTypeName, + positionLevel: profile.posLevel.posLevelName, + posNo: shortName?shortName:"-", + positionLine: position?.positionField ?? "-", + positionPathSide: position?.positionArea ?? "-", + positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", + amount: profile.amount, + positionSalaryAmount:profile.positionSalaryAmount, + mouthSalaryAmount: profile.mouthSalaryAmount, order: profile.profileSalary.length >= 0 ? profile.profileSalary.length > 0 @@ -1970,7 +1993,7 @@ export class ProfileController extends Controller { }, ) { const profile = await this.profileRepo.findOne({ - relations: ["profileSalary"], + relations: ["profileSalary","posType","posLevel"], where: { id: body.profileId }, order: { profileSalary: { @@ -1988,7 +2011,6 @@ export class ProfileController extends Controller { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์"); } let dateLeave_: any = body.date; - await removeProfileInOrganize(profile.id, "OFFICER"); _profile.isLeave = true; _profile.leaveReason = "คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด"; @@ -1996,26 +2018,54 @@ export class ProfileController extends Controller { _profile.lastUpdateUserId = req.user.sub; _profile.lastUpdateFullName = req.user.name; _profile.lastUpdatedAt = new Date(); + + const orgRevision = await this.orgRevisionRepo.findOne({ + where:{ + orgRevisionIsCurrent: true, + orgRevisionIsDraft: false + } + }) + const shortName = + !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.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : null; + let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null; const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { profileId: body.profileId, date: body.date, refCommandNo: body.refCommandNo, templateDoc: body.salaryRef, - position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, - positionType: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, - positionLevel: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, - posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, - positionLine: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, - positionPathSide: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, - positionExecutive: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, - amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, - positionSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, - mouthSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, + position: profile.position, + positionType: profile.posType.posTypeName, + positionLevel: profile.posLevel.posLevelName, + posNo: shortName?shortName:"-", + positionLine: position?.positionField ?? "-", + positionPathSide: position?.positionArea ?? "-", + positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", + amount: profile.amount, + positionSalaryAmount: profile.positionSalaryAmount, + mouthSalaryAmount: profile.mouthSalaryAmount, order: profile.profileSalary.length >= 0 ? profile.profileSalary.length > 0 @@ -2029,6 +2079,7 @@ export class ProfileController extends Controller { createdAt: new Date(), lastUpdatedAt: new Date(), }); + await removeProfileInOrganize(profile.id, "OFFICER"); await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]); return new HttpSuccess(); @@ -2052,7 +2103,7 @@ export class ProfileController extends Controller { }, ) { const profile = await this.profileRepo.findOne({ - relations: ["profileSalary"], + relations: ["profileSalary","posType","posLevel"], where: { id: body.profileId }, order: { profileSalary: { @@ -2070,33 +2121,60 @@ export class ProfileController extends Controller { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์"); } let dateLeave_: any = body.date; - await removeProfileInOrganize(profile.id, "OFFICER"); _profile.isLeave = true; _profile.leaveReason = "ได้รับโทษทางวินัย ปลดออกจากราชการ"; _profile.dateLeave = dateLeave_; _profile.lastUpdateUserId = req.user.sub; _profile.lastUpdateFullName = req.user.name; _profile.lastUpdatedAt = new Date(); + + const orgRevision = await this.orgRevisionRepo.findOne({ + where:{ + orgRevisionIsCurrent: true, + orgRevisionIsDraft: false + } + }) + const shortName = + !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.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : null; + let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null; const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { profileId: body.profileId, date: body.date, refCommandNo: body.refCommandNo, templateDoc: body.salaryRef, - position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, - positionType: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, - positionLevel: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, - posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, - positionLine: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, - positionPathSide: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, - positionExecutive: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, - amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, - positionSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, - mouthSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, + position: profile.position, + positionType: profile.posType.posTypeName, + positionLevel: profile.posLevel.posLevelName, + posNo: shortName?shortName:"-", + positionLine: position?.positionField ?? "-", + positionPathSide: position?.positionArea ?? "-", + positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", + amount: profile.amount, + positionSalaryAmount: profile.positionSalaryAmount, + mouthSalaryAmount: profile.mouthSalaryAmount, order: profile.profileSalary.length >= 0 ? profile.profileSalary.length > 0 @@ -2110,6 +2188,7 @@ export class ProfileController extends Controller { createdAt: new Date(), lastUpdatedAt: new Date(), }); + await removeProfileInOrganize(profile.id, "OFFICER"); await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]); return new HttpSuccess(); @@ -2133,7 +2212,7 @@ export class ProfileController extends Controller { }, ) { const profile = await this.profileRepo.findOne({ - relations: ["profileSalary"], + relations: ["profileSalary","posType","posLevel"], where: { id: body.profileId }, order: { profileSalary: { @@ -2151,33 +2230,60 @@ export class ProfileController extends Controller { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์"); } let dateLeave_: any = body.date; - await removeProfileInOrganize(profile.id, "OFFICER"); _profile.isLeave = true; _profile.leaveReason = "ได้รับโทษทางวินัย ไล่ออกจากราชการ"; _profile.dateLeave = dateLeave_; _profile.lastUpdateUserId = req.user.sub; _profile.lastUpdateFullName = req.user.name; _profile.lastUpdatedAt = new Date(); + + const orgRevision = await this.orgRevisionRepo.findOne({ + where:{ + orgRevisionIsCurrent: true, + orgRevisionIsDraft: false + } + }) + const shortName = + !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.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : null; + let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null; const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { profileId: body.profileId, date: body.date, refCommandNo: body.refCommandNo, templateDoc: body.salaryRef, - position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, - positionType: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, - positionLevel: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, - posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, - positionLine: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, - positionPathSide: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, - positionExecutive: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, - amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, - positionSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, - mouthSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, + position: profile.position, + positionType: profile.posType.posTypeName, + positionLevel: profile.posLevel.posLevelName, + posNo: shortName?shortName:"-", + positionLine: position?.positionField ?? "-", + positionPathSide: position?.positionArea ?? "-", + positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", + amount: profile.amount, + positionSalaryAmount: profile.positionSalaryAmount, + mouthSalaryAmount: profile.mouthSalaryAmount, order: profile.profileSalary.length >= 0 ? profile.profileSalary.length > 0 @@ -2203,6 +2309,7 @@ export class ProfileController extends Controller { // createdAt: new Date(), // lastUpdatedAt: new Date(), // }); + await removeProfileInOrganize(profile.id, "OFFICER"); await Promise.all([ this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary), @@ -2230,7 +2337,7 @@ export class ProfileController extends Controller { }, ) { const profile = await this.profileRepo.findOne({ - relations: ["profileSalary"], + relations: ["profileSalary","posType","posLevel"], where: { id: body.profileId }, order: { profileSalary: { @@ -2248,33 +2355,60 @@ export class ProfileController extends Controller { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์"); } let dateLeave_: any = body.date; - await removeProfileInOrganize(profile.id, "OFFICER"); _profile.isLeave = true; _profile.leaveReason = "ได้รับโทษทางวินัย พักจากราชการ"; _profile.dateLeave = dateLeave_; _profile.lastUpdateUserId = req.user.sub; _profile.lastUpdateFullName = req.user.name; _profile.lastUpdatedAt = new Date(); + + const orgRevision = await this.orgRevisionRepo.findOne({ + where:{ + orgRevisionIsCurrent: true, + orgRevisionIsDraft: false + } + }) + const shortName = + !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.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : null; + let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null; const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { profileId: body.profileId, date: body.date, refCommandNo: body.refCommandNo, templateDoc: body.salaryRef, - position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, - positionType: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, - positionLevel: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, - posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, - positionLine: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, - positionPathSide: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, - positionExecutive: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, - amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, - positionSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, - mouthSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, + position: profile.position, + positionType: profile.posType.posTypeName, + positionLevel: profile.posLevel.posLevelName, + posNo: shortName?shortName:"-", + positionLine: position?.positionField ?? "-", + positionPathSide: position?.positionArea ?? "-", + positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", + amount: profile.amount, + positionSalaryAmount: profile.positionSalaryAmount, + mouthSalaryAmount: profile.mouthSalaryAmount, order: profile.profileSalary.length >= 0 ? profile.profileSalary.length > 0 @@ -2288,6 +2422,7 @@ export class ProfileController extends Controller { createdAt: new Date(), lastUpdatedAt: new Date(), }); + await removeProfileInOrganize(profile.id, "OFFICER"); await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]); return new HttpSuccess(); @@ -2311,7 +2446,7 @@ export class ProfileController extends Controller { }, ) { const profile = await this.profileRepo.findOne({ - relations: ["profileSalary"], + relations: ["profileSalary","posType","posLevel"], where: { id: body.profileId }, order: { profileSalary: { @@ -2329,32 +2464,59 @@ export class ProfileController extends Controller { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์"); } let dateLeave_: any = body.date; - await removeProfileInOrganize(profile.id, "OFFICER"); _profile.isLeave = true; _profile.leaveReason = "ได้รับโทษทางวินัย ให้ออกจากราชการไว้ก่อน"; _profile.dateLeave = dateLeave_; _profile.lastUpdateUserId = req.user.sub; _profile.lastUpdateFullName = req.user.name; + + const orgRevision = await this.orgRevisionRepo.findOne({ + where:{ + orgRevisionIsCurrent: true, + orgRevisionIsDraft: false + } + }) + const shortName = + !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.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : null; + let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null; const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { profileId: body.profileId, date: body.date, refCommandNo: body.refCommandNo, templateDoc: body.salaryRef, - position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, - positionType: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, - positionLevel: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, - posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, - positionLine: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, - positionPathSide: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, - positionExecutive: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, - amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, - positionSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, - mouthSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, + position: profile.position, + positionType: profile.posType.posTypeName, + positionLevel: profile.posLevel.posLevelName, + posNo: shortName?shortName:"-", + positionLine: position?.positionField ?? "-", + positionPathSide: position?.positionArea ?? "-", + positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", + amount: profile.amount, + positionSalaryAmount: profile.positionSalaryAmount, + mouthSalaryAmount: profile.mouthSalaryAmount, order: profile.profileSalary.length >= 0 ? profile.profileSalary.length > 0 @@ -2368,6 +2530,7 @@ export class ProfileController extends Controller { createdAt: new Date(), lastUpdatedAt: new Date(), }); + await removeProfileInOrganize(profile.id, "OFFICER"); await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]); return new HttpSuccess(); @@ -2391,7 +2554,7 @@ export class ProfileController extends Controller { }, ) { const profile = await this.profileRepo.findOne({ - relations: ["profileSalary"], + relations: ["profileSalary","posType","posLevel"], where: { id: body.profileId }, order: { profileSalary: { @@ -2408,26 +2571,54 @@ export class ProfileController extends Controller { // profile.dateLeave = dateLeave_; // profile.lastUpdateUserId = req.user.sub; // profile.lastUpdateFullName = req.user.name; + + const orgRevision = await this.orgRevisionRepo.findOne({ + where:{ + orgRevisionIsCurrent: true, + orgRevisionIsDraft: false + } + }) + const shortName = + !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.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : null; + let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null; const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { profileId: body.profileId, date: body.date, refCommandNo: body.refCommandNo, templateDoc: body.salaryRef, - position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, - positionType: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, - positionLevel: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, - posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, - positionLine: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, - positionPathSide: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, - positionExecutive: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, - amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, - positionSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, - mouthSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, + position: profile.position, + positionType: profile.posType.posTypeName, + positionLevel: profile.posLevel.posLevelName, + posNo: shortName?shortName:"-", + positionLine: position?.positionField ?? "-", + positionPathSide: position?.positionArea ?? "-", + positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", + amount: profile.amount, + positionSalaryAmount: profile.positionSalaryAmount, + mouthSalaryAmount: profile.mouthSalaryAmount, order: profile.profileSalary.length >= 0 ? profile.profileSalary.length > 0 @@ -2464,7 +2655,7 @@ export class ProfileController extends Controller { }, ) { const profile = await this.profileRepo.findOne({ - relations: ["profileSalary"], + relations: ["profileSalary","posType","posLevel"], where: { id: body.profileId }, order: { profileSalary: { @@ -2481,26 +2672,54 @@ export class ProfileController extends Controller { // profile.dateLeave = dateLeave_; // profile.lastUpdateUserId = req.user.sub; // profile.lastUpdateFullName = req.user.name; + + const orgRevision = await this.orgRevisionRepo.findOne({ + where:{ + orgRevisionIsCurrent: true, + orgRevisionIsDraft: false + } + }) + const shortName = + !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.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : null; + let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null; const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { profileId: body.profileId, date: body.date, refCommandNo: body.refCommandNo, templateDoc: body.salaryRef, - position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, - positionType: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, - positionLevel: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, - posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, - positionLine: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, - positionPathSide: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, - positionExecutive: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, - amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, - positionSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, - mouthSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, + position: profile.position, + positionType: profile.posType.posTypeName, + positionLevel: profile.posLevel.posLevelName, + posNo: shortName?shortName:"-", + positionLine: position?.positionField ?? "-", + positionPathSide: position?.positionArea ?? "-", + positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", + amount: profile.amount, + positionSalaryAmount: profile.positionSalaryAmount, + mouthSalaryAmount: profile.mouthSalaryAmount, order: profile.profileSalary.length >= 0 ? profile.profileSalary.length > 0 @@ -2537,7 +2756,7 @@ export class ProfileController extends Controller { }, ) { const profile = await this.profileRepo.findOne({ - relations: ["profileSalary"], + relations: ["profileSalary","posType","posLevel"], where: { id: body.profileId }, order: { profileSalary: { @@ -2554,26 +2773,55 @@ export class ProfileController extends Controller { // profile.dateLeave = dateLeave_; // profile.lastUpdateUserId = req.user.sub; // profile.lastUpdateFullName = req.user.name; + + const orgRevision = await this.orgRevisionRepo.findOne({ + where:{ + orgRevisionIsCurrent: true, + orgRevisionIsDraft: false + } + }) + const shortName = + !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.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : null; + + let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null; const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { profileId: body.profileId, date: body.date, refCommandNo: body.refCommandNo, templateDoc: body.salaryRef, - position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, - positionType: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, - positionLevel: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, - posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, - positionLine: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, - positionPathSide: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, - positionExecutive: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, - amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, - positionSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, - mouthSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, + position: profile.position, + positionType: profile.posType.posTypeName, + positionLevel: profile.posLevel.posLevelName, + posNo: shortName?shortName:"-", + positionLine: position?.positionField ?? "-", + positionPathSide: position?.positionArea ?? "-", + positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", + amount: profile.amount, + positionSalaryAmount: profile.positionSalaryAmount, + mouthSalaryAmount: profile.mouthSalaryAmount, order: profile.profileSalary.length >= 0 ? profile.profileSalary.length > 0 @@ -2610,7 +2858,7 @@ export class ProfileController extends Controller { }, ) { const profile = await this.profileRepo.findOne({ - relations: ["profileSalary"], + relations: ["profileSalary","posType","posLevel"], where: { id: body.profileId }, order: { profileSalary: { @@ -2627,26 +2875,54 @@ export class ProfileController extends Controller { // profile.dateLeave = dateLeave_; // profile.lastUpdateUserId = req.user.sub; // profile.lastUpdateFullName = req.user.name; + + const orgRevision = await this.orgRevisionRepo.findOne({ + where:{ + orgRevisionIsCurrent: true, + orgRevisionIsDraft: false + } + }) + const shortName = + !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.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : null; + let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null; const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { profileId: body.profileId, date: body.date, refCommandNo: body.refCommandNo, templateDoc: body.salaryRef, - position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, - positionType: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, - positionLevel: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, - posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, - positionLine: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, - positionPathSide: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, - positionExecutive: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, - amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, - positionSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, - mouthSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, + position: profile.position, + positionType: profile.posType.posTypeName, + positionLevel: profile.posLevel.posLevelName, + posNo: shortName?shortName:"-", + positionLine: position?.positionField ?? "-", + positionPathSide: position?.positionArea ?? "-", + positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", + amount: profile.amount, + positionSalaryAmount: profile.positionSalaryAmount, + mouthSalaryAmount: profile.mouthSalaryAmount, order: profile.profileSalary.length >= 0 ? profile.profileSalary.length > 0 @@ -2683,7 +2959,7 @@ export class ProfileController extends Controller { }, ) { const profile = await this.profileRepo.findOne({ - relations: ["profileSalary"], + relations: ["profileSalary","posType","posLevel"], where: { id: body.profileId }, order: { profileSalary: { @@ -2700,26 +2976,55 @@ export class ProfileController extends Controller { // profile.dateLeave = dateLeave_; // profile.lastUpdateUserId = req.user.sub; // profile.lastUpdateFullName = req.user.name; + + const orgRevision = await this.orgRevisionRepo.findOne({ + where:{ + orgRevisionIsCurrent: true, + orgRevisionIsDraft: false + } + }) + const shortName = + !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.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : 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.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}` + : null; + + let position = profile.current_holders.filter((x) => x.orgRevisionId == orgRevision?.id)[0]?.positions?.filter((pos) => pos.positionIsSelected === true)[0]?? null; const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { profileId: body.profileId, date: body.date, refCommandNo: body.refCommandNo, templateDoc: body.salaryRef, - position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, - positionType: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, - positionLevel: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, - posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, - positionLine: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, - positionPathSide: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, - positionExecutive: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, - amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, - positionSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, - mouthSalaryAmount: - profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, + position: profile.position, + positionType: profile.posType.posTypeName, + positionLevel: profile.posLevel.posLevelName, + posNo: shortName?shortName:"-", + positionLine: position?.positionField ?? "-", + positionPathSide: position?.positionArea ?? "-", + positionExecutive: position?.posExecutive?.posExecutiveName ?? "-", + amount: profile.amount, + positionSalaryAmount: profile.positionSalaryAmount, + mouthSalaryAmount: profile.mouthSalaryAmount, order: profile.profileSalary.length >= 0 ? profile.profileSalary.length > 0 @@ -2774,39 +3079,7 @@ export class ProfileController extends Controller { profile.lastUpdateUserId = req.user.sub; profile.lastUpdateFullName = req.user.name; profile.lastUpdatedAt = new Date(); - // const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { - // profileId: body.profileId, - // date: body.date, - // refCommandNo: body.refCommandNo, - // templateDoc: body.salaryRef, - // position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, - // positionType: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, - // positionLevel: - // profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLevel : null, - // posNo: profile.profileSalary.length > 0 ? profile.profileSalary[0].posNo : null, - // positionLine: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionLine : null, - // positionPathSide: - // profile.profileSalary.length > 0 ? profile.profileSalary[0].positionPathSide : null, - // positionExecutive: - // profile.profileSalary.length > 0 ? profile.profileSalary[0].positionExecutive : null, - // amount: profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, - // positionSalaryAmount: - // profile.profileSalary.length > 0 ? profile.profileSalary[0].positionSalaryAmount : null, - // mouthSalaryAmount: - // profile.profileSalary.length > 0 ? profile.profileSalary[0].mouthSalaryAmount : null, - // order: - // profile.profileSalary.length >= 0 - // ? profile.profileSalary.length > 0 - // ? profile.profileSalary[0].order + 1 - // : 1 - // : null, - // createdUserId: req.user.sub, - // createdFullName: req.user.name, - // lastUpdateUserId: req.user.sub, - // lastUpdateFullName: req.user.name, - // createdAt: new Date(), - // lastUpdatedAt: new Date(), - // }); + await Promise.all([this.profileRepo.save(profile)]); return new HttpSuccess(); @@ -4242,7 +4515,7 @@ export class ProfileController extends Controller { child4ShortName: child4 == null ? null : child4.orgChild4ShortName, node: null, nodeId: null, - salary: profile && profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, + salary: profile ? profile.amount: null, }; if (_profile.child4Id != null) { @@ -4987,7 +5260,7 @@ export class ProfileController extends Controller { posNo: shortName, isPosmasterAct: data.length > 0, posmasterAct: data, - salary: profile && profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, + salary: profile ? profile.amount: null, }; if (_profile.child4Id != null) { @@ -5141,15 +5414,9 @@ export class ProfileController extends Controller { child4ShortName: child4 == null ? null : child4.orgChild4ShortName, node: null, nodeId: null, - amount: profile && profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, - positionSalaryAmount: - profile && profile.profileSalary.length > 0 - ? profile.profileSalary[0].positionSalaryAmount - : null, - mouthSalaryAmount: - profile && profile.profileSalary.length > 0 - ? profile.profileSalary[0].mouthSalaryAmount - : null, + amount: profile ? profile.amount : null, + positionSalaryAmount: profile ? profile.positionSalaryAmount : null, + mouthSalaryAmount: profile ? profile.mouthSalaryAmount : null, }; if (_profile.child4Id != null) {