From 5d28e1ce55706421bb7964e72e966f47ae3be131 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Mon, 8 Jul 2024 16:32:02 +0700 Subject: [PATCH] no message --- src/controllers/EmployeePositionController.ts | 7 +++ src/controllers/PositionController.ts | 8 +-- src/controllers/ProfileController.ts | 58 +++++++++---------- src/controllers/ProfileEmployeeController.ts | 42 +++++++++----- 4 files changed, 68 insertions(+), 47 deletions(-) diff --git a/src/controllers/EmployeePositionController.ts b/src/controllers/EmployeePositionController.ts index 7b73970d..420eb12d 100644 --- a/src/controllers/EmployeePositionController.ts +++ b/src/controllers/EmployeePositionController.ts @@ -1354,6 +1354,7 @@ export class EmployeePositionController extends Controller { "orgChild2", "orgChild3", "orgChild4", + "current_holder", "positions", "positions.posLevel", "positions.posType", @@ -1381,6 +1382,12 @@ export class EmployeePositionController extends Controller { position: item.positions.map((x) => x.positionName).join("/"), posLevel: item.positions.map((x) => x.posLevel.posLevelName).join("/"), posType: item.positions.map((x) => x.posType.posTypeName).join("/"), + fullname: + (item?.current_holder?.prefix ?? "") + + "" + + (item?.current_holder?.firstName ?? "") + + " " + + (item?.current_holder?.lastName ?? ""), })); return new HttpSuccess(_data); } diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index 1e1928e2..f5d45f3d 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -1605,11 +1605,11 @@ export class PositionController extends Controller { posLevel: item.positions.map((x) => x.posLevel.posLevelName).join("/"), posType: item.positions.map((x) => x.posType.posTypeName).join("/"), fullname: - item.current_holder.prefix + + (item?.current_holder?.prefix ?? "") + + "" + + (item?.current_holder?.firstName ?? "") + " " + - item.current_holder.firstName + - " " + - item.current_holder.lastName, + (item?.current_holder?.lastName ?? ""), })); return new HttpSuccess(_data); } diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 77cfbe61..d8b07e92 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -339,9 +339,7 @@ export class ProfileController extends Controller { : null, BirthDayText: profiles.birthDate != null - ? Extension.ToThaiNumber( - Extension.ToThaiFullDate2(profiles.birthDate).toString(), - ) + ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate).toString()) : "", BirthMonth: profiles?.birthDate ? Extension.ToThaiNumber(new Date(profiles.birthDate).getMonth() + (1).toString()) @@ -351,9 +349,7 @@ export class ProfileController extends Controller { : null, BirthYearText: profiles.birthDate != null - ? Extension.ToThaiNumber( - Extension.ToThaiFullDate2(profiles.birthDate).toString(), - ) + ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate).toString()) : "", Address: "", District: "", @@ -418,9 +414,7 @@ export class ProfileController extends Controller { ? "" : Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate)), End: - item.endDate == null - ? "" - : Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate)), + 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))}` @@ -480,9 +474,7 @@ export class ProfileController extends Controller { }); const Salary = salarys.map((item) => ({ - SalaryDate: item.date - ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.date)) - : null, + SalaryDate: item.date ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.date)) : null, Position: item.position != null ? Extension.ToThaiNumber(item.position) : null, PosNo: item.posNo != null ? Extension.ToThaiNumber(item.posNo) : null, Salary: item.amount != null ? Extension.ToThaiNumber(item.amount.toLocaleString()) : null, @@ -3064,6 +3056,30 @@ export class ProfileController extends Controller { posMasterId: posMaster?.id, }, }); + const shortName = + 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.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.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 + ? `${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 + ? `${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 + ? `${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 = { profileId: profile.id, prefix: profile.prefix, @@ -3103,6 +3119,7 @@ export class ProfileController extends Controller { child4ShortName: child4 == null ? null : child4.orgChild4ShortName, node: null, nodeId: null, + posNo: shortName, }; if (_profile.child4Id != null) { @@ -4803,23 +4820,6 @@ export class ProfileController extends Controller { order: { createdAt: "DESC" }, }); - await new CallAPI().PostData(request, "org/profile/salary", { - profileId: profile.id, - date: requestBody.dateLeave, - amount: profileSalary?.amount ?? null, - positionSalaryAmount: profileSalary?.positionSalaryAmount ?? null, - mouthSalaryAmount: profileSalary?.mouthSalaryAmount ?? null, - posNo: profileSalary?.posNo ?? null, - position: profileSalary?.position ?? null, - positionLine: profileSalary?.positionLine ?? null, - positionPathSide: profileSalary?.positionPathSide ?? null, - positionExecutive: profileSalary?.positionExecutive ?? null, - positionType: profileSalary?.positionType ?? null, - positionLevel: profileSalary?.positionLevel ?? null, - refCommandNo: null, - templateDoc: requestBody.leaveReason, - }); - return new HttpSuccess(); } diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 32d53169..89e77159 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -2694,20 +2694,6 @@ export class ProfileEmployeeController extends Controller { order: { createdAt: "DESC" }, }); - await new CallAPI().PostData(request, "org/profile-employee/salary", { - profileEmployeeId: profile.id, - date: requestBody.dateLeave, - amount: profileSalary?.amount ?? null, - positionSalaryAmount: profileSalary?.positionSalaryAmount ?? null, - mouthSalaryAmount: profileSalary?.mouthSalaryAmount ?? null, - posNo: profileSalary?.posNo ?? null, - position: profileSalary?.position ?? null, - positionType: profileSalary?.positionType ?? null, - positionLevel: profileSalary?.positionLevel ?? null, - refCommandNo: null, - templateDoc: requestBody.leaveReason, - }); - return new HttpSuccess(); } @@ -3281,6 +3267,33 @@ export class ProfileEmployeeController extends Controller { // posMasterId: posMaster?.id, // }, // }); + const shortName = + 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.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.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 + ? `${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 + ? `${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 + ? `${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 = { profileId: profile.id, prefix: profile.prefix, @@ -3317,6 +3330,7 @@ export class ProfileEmployeeController extends Controller { child4ShortName: child4 == null ? null : child4.orgChild4ShortName, node: null, nodeId: null, + posNo: shortName, }; if (_profile.child4Id != null) {