From 8721fcaf302f91d2041d4b913aa0c5965f67cc54 Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 27 Jun 2025 13:51:38 +0700 Subject: [PATCH] =?UTF-8?q?Fix=20=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=8A?= =?UTF-8?q?=E0=B8=B7=E0=B9=88=E0=B8=AD=E0=B8=82=E0=B9=89=E0=B8=B2=E0=B8=A3?= =?UTF-8?q?=E0=B8=B2=E0=B8=8A=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=9C=E0=B8=B9?= =?UTF-8?q?=E0=B9=89=E0=B8=97=E0=B8=B5=E0=B9=88=E0=B9=84=E0=B8=94=E0=B9=89?= =?UTF-8?q?=E0=B8=A3=E0=B8=B1=E0=B8=9A=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B9=80?= =?UTF-8?q?=E0=B8=AA=E0=B8=99=E0=B8=AD=E0=B8=82=E0=B8=AD=E0=B9=80=E0=B8=A5?= =?UTF-8?q?=E0=B8=B7=E0=B9=88=E0=B8=AD=E0=B8=99=E0=B9=80=E0=B8=87=E0=B8=B4?= =?UTF-8?q?=E0=B8=99=E0=B9=80=E0=B8=94=E0=B8=B7=E0=B8=AD=E0=B8=99=E0=B8=97?= =?UTF-8?q?=E0=B8=B1=E0=B9=89=E0=B8=87=E0=B8=9B=E0=B8=B5=E0=B8=AA=E0=B8=AD?= =?UTF-8?q?=E0=B8=87=E0=B8=82=E0=B8=B1=E0=B9=89=E0=B8=99=20=20#1391?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ReportController.ts | 277 ++++++++++++++-------------- 1 file changed, 142 insertions(+), 135 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 6b139c6..051b3ea 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -1091,7 +1091,7 @@ export class ReportController extends Controller { group: convertGroup, }, }); - + //รอบเมษา if (salaryPeriod.period === "APR") { let salaryProfileGroup1: any; let salaryProfileGroup2: any; @@ -1297,60 +1297,61 @@ export class ReportController extends Controller { remark: item.remark, //หมายเหตุ })) : null, - profileGroup2: salaryProfileGroup2 - ? salaryProfileGroup2.map((item: any, index: any) => ({ - no: Extension.ToThaiNumber(String(index + 1)), - affiliation: - (item.child4 == undefined && item.child4 == null ? "" : item.child4 + "\n") + - (item.child3 == undefined && item.child3 == null ? "" : item.child3 + "\n") + - (item.child2 == undefined && item.child2 == null ? "" : item.child2 + "\n") + - (item.child1 == undefined && item.child1 == null ? "" : item.child1 + "\n") + - (item.root == undefined && item.root == null ? "" : item.root), - // สังกัด/ชื่อ-นามสกุล - fullName: 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.length > 0 - ? (() => { - const filteredType = salaryProfile1 - .filter((profile) => profile.citizenId === item.citizenId) - .map((profile) => profile.type); - const Type = filteredType[0]; - return Type === "HAFT" - ? "ครึ่งขั้น" - : Type === "FULL" - ? "หนึ่งขั้น" - : "ไม่ได้เลื่อนขั้น"; - })() - : "-", //การเลื่อนเงินเดือนปีก่อนๆหน้า - salaryIncrease2: - salaryProfile2.length > 0 - ? (() => { - const filteredType = salaryProfile2 - .filter((profile) => profile.citizenId === item.citizenId) - .map((profile) => profile.type); - const Type = filteredType[0]; - return Type === "HAFT" - ? "ครึ่งขั้น" - : Type === "FULL" - ? "หนึ่งขั้น" - : "ไม่ได้เลื่อนขั้น"; - })() - : "-", //การเลื่อนเงินเดือนปีก่อนหน้า - score: item.result, //ผลการประเมินฯ - remark: item.remark, //หมายเหตุ - })) - : null, + // profileGroup2: salaryProfileGroup2 + // ? salaryProfileGroup2.map((item: any, index: any) => ({ + // no: Extension.ToThaiNumber(String(index + 1)), + // affiliation: + // (item.child4 == undefined && item.child4 == null ? "" : item.child4 + "\n") + + // (item.child3 == undefined && item.child3 == null ? "" : item.child3 + "\n") + + // (item.child2 == undefined && item.child2 == null ? "" : item.child2 + "\n") + + // (item.child1 == undefined && item.child1 == null ? "" : item.child1 + "\n") + + // (item.root == undefined && item.root == null ? "" : item.root), + // // สังกัด/ชื่อ-นามสกุล + // fullName: 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.length > 0 + // ? (() => { + // const filteredType = salaryProfile1 + // .filter((profile) => profile.citizenId === item.citizenId) + // .map((profile) => profile.type); + // const Type = filteredType[0]; + // return Type === "HAFT" + // ? "ครึ่งขั้น" + // : Type === "FULL" + // ? "หนึ่งขั้น" + // : "ไม่ได้เลื่อนขั้น"; + // })() + // : "-", //การเลื่อนเงินเดือนปีก่อนๆหน้า + // salaryIncrease2: + // salaryProfile2.length > 0 + // ? (() => { + // const filteredType = salaryProfile2 + // .filter((profile) => profile.citizenId === item.citizenId) + // .map((profile) => profile.type); + // const Type = filteredType[0]; + // return Type === "HAFT" + // ? "ครึ่งขั้น" + // : Type === "FULL" + // ? "หนึ่งขั้น" + // : "ไม่ได้เลื่อนขั้น"; + // })() + // : "-", //การเลื่อนเงินเดือนปีก่อนหน้า + // score: item.result, //ผลการประเมินฯ + // remark: item.remark, //หมายเหตุ + // })) + // : null, }, }); + //รอบตุลา } else if (salaryOrg && salaryPeriod.period === "OCT") { // find period APR const salaryPeriod_APR = await this.salaryPeriodRepository.findOne({ @@ -1524,90 +1525,15 @@ export class ReportController extends Controller { pointGroup2: fifteenPercent_Group2 + fifteenPoint_Group2, root: salaryOrg?.root, profile: salaryProfile_current - ? salaryProfile_current - .filter( - (item: any) => salaryProfile_APR.some((x: any) => x.citizenId === item.citizenId), // ตรวจสอบว่า citizenId ของ item มีอยู่ใน salaryProfile_APR หรือไม่ - ) - .map((item: any, index: any) => ({ - no: Extension.ToThaiNumber(String(index + 1)), - affiliation: - (item.child4 == undefined && item.child4 == null ? "" : item.child4 + "\n") + - (item.child3 == undefined && item.child3 == null ? "" : item.child3 + "\n") + - (item.child2 == undefined && item.child2 == null ? "" : item.child2 + "\n") + - (item.child1 == undefined && item.child1 == null ? "" : item.child1 + "\n") + - (item.root == undefined && item.root == null ? "" : item.root), - fullName: 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.length > 0 - ? (() => { - const filteredType = salaryProfile1 - .filter((profile) => profile.citizenId === item.citizenId) - .map((profile) => profile.type); - const Type = filteredType[0]; - return Type === "HAFT" - ? "ครึ่งขั้น" - : Type === "FULL" - ? "หนึ่งขั้น" - : Type === "FULLHAFT" - ? "หนึ่งขั้นครึ่ง" - : "ไม่ได้เลื่อนขั้น"; - })() - : "-", //การเลื่อนเงินเดือนปีก่อนๆหน้า - salaryIncrease2: - salaryProfile2.length > 0 - ? (() => { - const filteredType = salaryProfile2 - .filter((profile) => profile.citizenId === item.citizenId) - .map((profile) => profile.type); - const Type = filteredType[0]; - return Type === "HAFT" - ? "ครึ่งขั้น" - : Type === "FULL" - ? "หนึ่งขั้น" - : Type === "FULLHAFT" - ? "หนึ่งขั้นครึ่ง" - : "ไม่ได้เลื่อนขั้น"; - })() - : "-", //การเลื่อนเงินเดือนปีก่อนหน้า - salaryIncreaseAPR: - salaryProfile_APR.length > 0 - ? (() => { - const filteredType = salaryProfile_APR - .filter((profile) => profile.citizenId === item.citizenId) - .map((profile) => profile.type); - const Type = filteredType[0]; - return Type === "HAFT" - ? "ครึ่งขั้น" - : Type === "FULL" - ? "หนึ่งขั้น" - : Type === "FULLHAFT" - ? "หนึ่งขั้นครึ่ง" - : "ไม่ได้เลื่อนขั้น"; - })() - : "-", //การเลื่อนเงินเดือนรอบเมษา - Type: - item.type === "FULL" - ? "หนึ่งขั้น" - : item.type === "FULLHAFT" - ? "หนึ่งขั้นครึ่ง" - : "-", - score1: item.result ?? "-", //ผลการประเมินฯ ครั้งที่ 1 - score2: "-", //ผลการประเมินฯ ครั้งที่ 2 - })) - : null, - profileGroup2: salaryProfile_current ? salaryProfile_current .filter((item: any) => - salaryProfile_APR.some((x: any) => x.citizenId === item.citizenId), + salaryProfile_APR.some((x: any) => + x.citizenId === item.citizenId && + ( + x.type === "HAFT" && ["FULLHAFT"].includes(item.type) || + x.type === "FULL" && ["FULL", "FULLHAFT"].includes(item.type) + ) + ) ) .map((item: any, index: any) => ({ no: Extension.ToThaiNumber(String(index + 1)), @@ -1685,6 +1611,87 @@ export class ReportController extends Controller { score2: "-", //ผลการประเมินฯ ครั้งที่ 2 })) : null, + // profileGroup2: salaryProfile_current + // ? salaryProfile_current + // .filter((item: any) => + // salaryProfile_APR.some((x: any) => x.citizenId === item.citizenId), + // ) + // .map((item: any, index: any) => ({ + // no: Extension.ToThaiNumber(String(index + 1)), + // affiliation: + // (item.child4 == undefined && item.child4 == null ? "" : item.child4 + "\n") + + // (item.child3 == undefined && item.child3 == null ? "" : item.child3 + "\n") + + // (item.child2 == undefined && item.child2 == null ? "" : item.child2 + "\n") + + // (item.child1 == undefined && item.child1 == null ? "" : item.child1 + "\n") + + // (item.root == undefined && item.root == null ? "" : item.root), + // fullName: 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.length > 0 + // ? (() => { + // const filteredType = salaryProfile1 + // .filter((profile) => profile.citizenId === item.citizenId) + // .map((profile) => profile.type); + // const Type = filteredType[0]; + // return Type === "HAFT" + // ? "ครึ่งขั้น" + // : Type === "FULL" + // ? "หนึ่งขั้น" + // : Type === "FULLHAFT" + // ? "หนึ่งขั้นครึ่ง" + // : "ไม่ได้เลื่อนขั้น"; + // })() + // : "-", //การเลื่อนเงินเดือนปีก่อนๆหน้า + // salaryIncrease2: + // salaryProfile2.length > 0 + // ? (() => { + // const filteredType = salaryProfile2 + // .filter((profile) => profile.citizenId === item.citizenId) + // .map((profile) => profile.type); + // const Type = filteredType[0]; + // return Type === "HAFT" + // ? "ครึ่งขั้น" + // : Type === "FULL" + // ? "หนึ่งขั้น" + // : Type === "FULLHAFT" + // ? "หนึ่งขั้นครึ่ง" + // : "ไม่ได้เลื่อนขั้น"; + // })() + // : "-", //การเลื่อนเงินเดือนปีก่อนหน้า + // salaryIncreaseAPR: + // salaryProfile_APR.length > 0 + // ? (() => { + // const filteredType = salaryProfile_APR + // .filter((profile) => profile.citizenId === item.citizenId) + // .map((profile) => profile.type); + // const Type = filteredType[0]; + // return Type === "HAFT" + // ? "ครึ่งขั้น" + // : Type === "FULL" + // ? "หนึ่งขั้น" + // : Type === "FULLHAFT" + // ? "หนึ่งขั้นครึ่ง" + // : "ไม่ได้เลื่อนขั้น"; + // })() + // : "-", //การเลื่อนเงินเดือนรอบเมษา + // Type: + // item.type === "FULL" + // ? "หนึ่งขั้น" + // : item.type === "FULLHAFT" + // ? "หนึ่งขั้นครึ่ง" + // : "-", + // score1: item.result ?? "-", //ผลการประเมินฯ ครั้งที่ 1 + // score2: "-", //ผลการประเมินฯ ครั้งที่ 2 + // })) + // : null, }, }); }