From e30e07b6b4c270b1ead38947dc84d254a0d8ae3a Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 2 Jul 2024 15:25:34 +0700 Subject: [PATCH] fix --- src/controllers/ReportController.ts | 431 ++++++++++++++-------------- 1 file changed, 218 insertions(+), 213 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index fabf443..33e328d 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -1083,7 +1083,7 @@ export class ReportController extends Controller { group: "GROUP2", }, }); - + if (salaryPeriod.period === "APR") { let salaryProfileGroup1: any; let salaryProfileGroup2: any; @@ -1092,8 +1092,8 @@ export class ReportController extends Controller { where: { salaryOrgId: salaryOrg_Group1?.id, type: "FULL", //หนึ่งขั้น - }, - }); + }, + }); } if (salaryOrg_Group2) { salaryProfileGroup2 = await this.salaryProfileRepository.find({ @@ -1102,7 +1102,7 @@ export class ReportController extends Controller { type: "FULL", //หนึ่งขั้น }, }); - } + } //รอบปีก่อนๆ const salaryPeriodIncrease1_APR = await this.salaryPeriodRepository.findOne({ where: { @@ -1311,61 +1311,63 @@ export class ReportController extends Controller { remark: null, //หมายเหตุ })) : null, - profileGroup2: salaryProfileGroup2?salaryProfileGroup2.map((item: any, index: any) => ({ - no: Extension.ToThaiNumber(String(index + 1)), - fullname: - (item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") + - (item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") + - (item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") + - (item.child1 == undefined && item.child1 == null ? "" : item.child1 + "/") + - (item.root == undefined && item.root == null ? "" : item.root) + - "/" + - item.prefix + - item.firstName + - " " + - item.lastName, // สังกัด/ชื่อ-นามสกุล - posLevel: item.posLevel, - posMasterNo: - Extension.ToThaiNumber(item.orgShortName) + - Extension.ToThaiNumber(String(item.posMasterNo.toLocaleString())), - amount: - item.amount == undefined || item.amount == null - ? "๐" - : Extension.ToThaiNumber(String(item.amount.toLocaleString())), - salaryIncrease1: - salaryProfile1_Group2.length > 0 - ? (() => { - const filteredType = salaryProfile1_Group2 - .filter((profile) => profile.citizenId === item.citizenId) - .map((profile) => profile.type); - const Type = filteredType[0]; - return Type === "HAFT" - ? "ครึ่งขั้น" - : Type === "FULL" - ? "หนึ่งขั้น" - : "ไม่ได้เลื่อนขั้น"; - })() - : null, //การเลื่อนเงินเดือนปีก่อนๆหน้า - salaryIncrease2: - salaryProfile2_Group2.length > 0 - ? (() => { - const filteredType = salaryProfile2_Group2 - .filter((profile) => profile.citizenId === item.citizenId) - .map((profile) => profile.type); - const Type = filteredType[0]; - return Type === "HAFT" - ? "ครึ่งขั้น" - : Type === "FULL" - ? "หนึ่งขั้น" - : "ไม่ได้เลื่อนขั้น"; - })() - : null, //การเลื่อนเงินเดือนปีก่อนหน้า - score: null, //ผลการประเมินฯ - remark: null, //หมายเหตุ - })) :null, + profileGroup2: salaryProfileGroup2 + ? salaryProfileGroup2.map((item: any, index: any) => ({ + no: Extension.ToThaiNumber(String(index + 1)), + fullname: + (item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") + + (item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") + + (item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") + + (item.child1 == undefined && item.child1 == null ? "" : item.child1 + "/") + + (item.root == undefined && item.root == null ? "" : item.root) + + "/" + + item.prefix + + item.firstName + + " " + + item.lastName, // สังกัด/ชื่อ-นามสกุล + posLevel: item.posLevel, + posMasterNo: + Extension.ToThaiNumber(item.orgShortName) + + Extension.ToThaiNumber(String(item.posMasterNo.toLocaleString())), + amount: + item.amount == undefined || item.amount == null + ? "๐" + : Extension.ToThaiNumber(String(item.amount.toLocaleString())), + salaryIncrease1: + salaryProfile1_Group2.length > 0 + ? (() => { + const filteredType = salaryProfile1_Group2 + .filter((profile) => profile.citizenId === item.citizenId) + .map((profile) => profile.type); + const Type = filteredType[0]; + return Type === "HAFT" + ? "ครึ่งขั้น" + : Type === "FULL" + ? "หนึ่งขั้น" + : "ไม่ได้เลื่อนขั้น"; + })() + : null, //การเลื่อนเงินเดือนปีก่อนๆหน้า + salaryIncrease2: + salaryProfile2_Group2.length > 0 + ? (() => { + const filteredType = salaryProfile2_Group2 + .filter((profile) => profile.citizenId === item.citizenId) + .map((profile) => profile.type); + const Type = filteredType[0]; + return Type === "HAFT" + ? "ครึ่งขั้น" + : Type === "FULL" + ? "หนึ่งขั้น" + : "ไม่ได้เลื่อนขั้น"; + })() + : null, //การเลื่อนเงินเดือนปีก่อนหน้า + score: null, //ผลการประเมินฯ + remark: null, //หมายเหตุ + })) + : null, }, }); - } else if (salaryOrg_Group1 &&salaryPeriod.period === "OCT") { + } else if (salaryOrg_Group1 && salaryPeriod.period === "OCT") { // find period APR const salaryPeriod_APR = await this.salaryPeriodRepository.findOne({ where: { @@ -1573,161 +1575,164 @@ export class ReportController extends Controller { root: salaryOrg_Group1?.root, profile: salaryProfileGroup1 ? salaryProfileGroup1.map((item: any, index: any) => ({ - no: Extension.ToThaiNumber(String(index + 1)), - fullname: - (item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") + - (item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") + - (item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") + - (item.child1 == undefined && item.child1 == null ? "" : item.child1 + "/") + - (item.root == undefined && item.root == null ? "" : item.root) + - "/" + - item.prefix + - item.firstName + - " " + - item.lastName, // สังกัด/ชื่อ-นามสกุล - posLevel: item.posLevel, - posMasterNo: - Extension.ToThaiNumber(item.orgShortName) + - Extension.ToThaiNumber(String(item.posMasterNo.toLocaleString())), - amount: - item.amount == undefined || item.amount == null - ? "๐" - : Extension.ToThaiNumber(String(item.amount.toLocaleString())), - salaryIncrease1: - salaryProfile1_Group1.length > 0 - ? (() => { - const filteredType = salaryProfile1_Group1 - .filter((profile) => profile.citizenId === item.citizenId) - .map((profile) => profile.type); - const Type = filteredType[0]; - return Type === "HAFT" - ? "ครึ่งขั้น" - : Type === "FULL" - ? "หนึ่งขั้น" - : Type === "FULLHAFT" - ? "หนึ่งขั้นครึ่ง" - : "ไม่ได้เลื่อนขั้น"; - })() - : null, //การเลื่อนเงินเดือนปีก่อนๆหน้า - salaryIncrease2: - salaryProfile2_Group1.length > 0 - ? (() => { - const filteredType = salaryProfile2_Group1 - .filter((profile) => profile.citizenId === item.citizenId) - .map((profile) => profile.type); - const Type = filteredType[0]; - return Type === "HAFT" - ? "ครึ่งขั้น" - : Type === "FULL" - ? "หนึ่งขั้น" - : Type === "FULLHAFT" - ? "หนึ่งขั้นครึ่ง" - : "ไม่ได้เลื่อนขั้น"; - })() - : null, //การเลื่อนเงินเดือนปีก่อนหน้า - salaryIncreaseAPR: - salaryProfile_APR_Group1.length > 0 - ? (() => { - const filteredType = salaryProfile_APR_Group1 - .filter((profile) => profile.citizenId === item.citizenId) - .map((profile) => profile.type); - const Type = filteredType[0]; - return Type === "HAFT" - ? "ครึ่งขั้น" - : Type === "FULL" - ? "หนึ่งขั้น" - : Type === "FULLHAFT" - ? "หนึ่งขั้นครึ่ง" - : "ไม่ได้เลื่อนขั้น"; - })() - : null, //การเลื่อนเงินเดือนรอบเมษา - Type: - item.type === "FULL" - ? "หนึ่งขั้น" - : item.type === "FULLHAFT" - ? "หนึ่งขั้นครึ่ง" - : null, - score1: null, //ผลการประเมินฯ ครั้งที่ 1 - score2: null, //ผลการประเมินฯ ครั้งที่ 2 - })):null, - profileGroup2: salaryProfileGroup2?salaryProfileGroup2.map((item, index) => ({ - no: Extension.ToThaiNumber(String(index + 1)), - fullname: - (item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") + - (item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") + - (item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") + - (item.child1 == undefined && item.child1 == null ? "" : item.child1 + "/") + - (item.root == undefined && item.root == null ? "" : item.root) + - "/" + - item.prefix + - item.firstName + - " " + - item.lastName, // สังกัด/ชื่อ-นามสกุล - posLevel: item.posLevel, - posMasterNo: - Extension.ToThaiNumber(item.orgShortName) + - Extension.ToThaiNumber(String(item.posMasterNo.toLocaleString())), - amount: - item.amount == undefined || item.amount == null - ? "๐" - : Extension.ToThaiNumber(String(item.amount.toLocaleString())), - salaryIncrease1: - salaryProfile1_Group2.length > 0 - ? (() => { - const filteredType = salaryProfile1_Group2 - .filter((profile) => profile.citizenId === item.citizenId) - .map((profile) => profile.type); - const Type = filteredType[0]; - return Type === "HAFT" - ? "ครึ่งขั้น" - : Type === "FULL" - ? "หนึ่งขั้น" - : Type === "FULLHAFT" - ? "หนึ่งขั้นครึ่ง" - : "ไม่ได้เลื่อนขั้น"; - })() - : null, //การเลื่อนเงินเดือนปีก่อนๆหน้า - salaryIncrease2: - salaryProfile2_Group2.length > 0 - ? (() => { - const filteredType = salaryProfile2_Group2 - .filter((profile) => profile.citizenId === item.citizenId) - .map((profile) => profile.type); - const Type = filteredType[0]; - return Type === "HAFT" - ? "ครึ่งขั้น" - : Type === "FULL" - ? "หนึ่งขั้น" - : Type === "FULLHAFT" - ? "หนึ่งขั้นครึ่ง" - : "ไม่ได้เลื่อนขั้น"; - })() - : null, //การเลื่อนเงินเดือนปีก่อนหน้า - salaryIncreaseAPR: - salaryProfile_APR_Group2.length > 0 - ? (() => { - const filteredType = salaryProfile_APR_Group2 - .filter((profile) => profile.citizenId === item.citizenId) - .map((profile) => profile.type); - const Type = filteredType[0]; - return Type === "HAFT" - ? "ครึ่งขั้น" - : Type === "FULL" - ? "หนึ่งขั้น" - : Type === "FULLHAFT" - ? "หนึ่งขั้นครึ่ง" - : "ไม่ได้เลื่อนขั้น"; - })() - : null, //การเลื่อนเงินเดือนรอบเมษา - Type: - item.type === "FULL" - ? "หนึ่งขั้น" - : item.type === "FULLHAFT" - ? "หนึ่งขั้นครึ่ง" - : null, - score1: null, //ผลการประเมินฯ ครั้งที่ 1 - score2: null, //ผลการประเมินฯ ครั้งที่ 2 - })):null, + no: Extension.ToThaiNumber(String(index + 1)), + fullname: + (item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") + + (item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") + + (item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") + + (item.child1 == undefined && item.child1 == null ? "" : item.child1 + "/") + + (item.root == undefined && item.root == null ? "" : item.root) + + "/" + + item.prefix + + item.firstName + + " " + + item.lastName, // สังกัด/ชื่อ-นามสกุล + posLevel: item.posLevel, + posMasterNo: + Extension.ToThaiNumber(item.orgShortName) + + Extension.ToThaiNumber(String(item.posMasterNo.toLocaleString())), + amount: + item.amount == undefined || item.amount == null + ? "๐" + : Extension.ToThaiNumber(String(item.amount.toLocaleString())), + salaryIncrease1: + salaryProfile1_Group1.length > 0 + ? (() => { + const filteredType = salaryProfile1_Group1 + .filter((profile) => profile.citizenId === item.citizenId) + .map((profile) => profile.type); + const Type = filteredType[0]; + return Type === "HAFT" + ? "ครึ่งขั้น" + : Type === "FULL" + ? "หนึ่งขั้น" + : Type === "FULLHAFT" + ? "หนึ่งขั้นครึ่ง" + : "ไม่ได้เลื่อนขั้น"; + })() + : null, //การเลื่อนเงินเดือนปีก่อนๆหน้า + salaryIncrease2: + salaryProfile2_Group1.length > 0 + ? (() => { + const filteredType = salaryProfile2_Group1 + .filter((profile) => profile.citizenId === item.citizenId) + .map((profile) => profile.type); + const Type = filteredType[0]; + return Type === "HAFT" + ? "ครึ่งขั้น" + : Type === "FULL" + ? "หนึ่งขั้น" + : Type === "FULLHAFT" + ? "หนึ่งขั้นครึ่ง" + : "ไม่ได้เลื่อนขั้น"; + })() + : null, //การเลื่อนเงินเดือนปีก่อนหน้า + salaryIncreaseAPR: + salaryProfile_APR_Group1.length > 0 + ? (() => { + const filteredType = salaryProfile_APR_Group1 + .filter((profile) => profile.citizenId === item.citizenId) + .map((profile) => profile.type); + const Type = filteredType[0]; + return Type === "HAFT" + ? "ครึ่งขั้น" + : Type === "FULL" + ? "หนึ่งขั้น" + : Type === "FULLHAFT" + ? "หนึ่งขั้นครึ่ง" + : "ไม่ได้เลื่อนขั้น"; + })() + : null, //การเลื่อนเงินเดือนรอบเมษา + Type: + item.type === "FULL" + ? "หนึ่งขั้น" + : item.type === "FULLHAFT" + ? "หนึ่งขั้นครึ่ง" + : null, + score1: null, //ผลการประเมินฯ ครั้งที่ 1 + score2: null, //ผลการประเมินฯ ครั้งที่ 2 + })) + : null, + profileGroup2: salaryProfileGroup2 + ? salaryProfileGroup2.map((item, index) => ({ + no: Extension.ToThaiNumber(String(index + 1)), + fullname: + (item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") + + (item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") + + (item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") + + (item.child1 == undefined && item.child1 == null ? "" : item.child1 + "/") + + (item.root == undefined && item.root == null ? "" : item.root) + + "/" + + item.prefix + + item.firstName + + " " + + item.lastName, // สังกัด/ชื่อ-นามสกุล + posLevel: item.posLevel, + posMasterNo: + Extension.ToThaiNumber(item.orgShortName) + + Extension.ToThaiNumber(String(item.posMasterNo.toLocaleString())), + amount: + item.amount == undefined || item.amount == null + ? "๐" + : Extension.ToThaiNumber(String(item.amount.toLocaleString())), + salaryIncrease1: + salaryProfile1_Group2.length > 0 + ? (() => { + const filteredType = salaryProfile1_Group2 + .filter((profile) => profile.citizenId === item.citizenId) + .map((profile) => profile.type); + const Type = filteredType[0]; + return Type === "HAFT" + ? "ครึ่งขั้น" + : Type === "FULL" + ? "หนึ่งขั้น" + : Type === "FULLHAFT" + ? "หนึ่งขั้นครึ่ง" + : "ไม่ได้เลื่อนขั้น"; + })() + : null, //การเลื่อนเงินเดือนปีก่อนๆหน้า + salaryIncrease2: + salaryProfile2_Group2.length > 0 + ? (() => { + const filteredType = salaryProfile2_Group2 + .filter((profile) => profile.citizenId === item.citizenId) + .map((profile) => profile.type); + const Type = filteredType[0]; + return Type === "HAFT" + ? "ครึ่งขั้น" + : Type === "FULL" + ? "หนึ่งขั้น" + : Type === "FULLHAFT" + ? "หนึ่งขั้นครึ่ง" + : "ไม่ได้เลื่อนขั้น"; + })() + : null, //การเลื่อนเงินเดือนปีก่อนหน้า + salaryIncreaseAPR: + salaryProfile_APR_Group2.length > 0 + ? (() => { + const filteredType = salaryProfile_APR_Group2 + .filter((profile) => profile.citizenId === item.citizenId) + .map((profile) => profile.type); + const Type = filteredType[0]; + return Type === "HAFT" + ? "ครึ่งขั้น" + : Type === "FULL" + ? "หนึ่งขั้น" + : Type === "FULLHAFT" + ? "หนึ่งขั้นครึ่ง" + : "ไม่ได้เลื่อนขั้น"; + })() + : null, //การเลื่อนเงินเดือนรอบเมษา + Type: + item.type === "FULL" + ? "หนึ่งขั้น" + : item.type === "FULLHAFT" + ? "หนึ่งขั้นครึ่ง" + : null, + score1: null, //ผลการประเมินฯ ครั้งที่ 1 + score2: null, //ผลการประเมินฯ ครั้งที่ 2 + })) + : null, }, }); } @@ -1866,7 +1871,7 @@ export class ReportController extends Controller { salaryPeriodId: salaryPeriodId, }, type: In(["HAFT", "FULL", "FULLHAFT"]), - isRetired: true, //กรองเฉพาะคนที่เกษียณ + // isRetired: true, //กรองเฉพาะคนที่เกษียณ }, order: { salaryOrg: {