diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 51bffd8..6b272d3 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -1557,7 +1557,7 @@ export class ReportController extends Controller { salaryPeriodId: salaryPeriodId, }, type: "NONE", //ไม่ได้เลื่อน - isReserve: false //กรองเฉพาะคนที่ไม่เกษียณ + isReserve: false, //กรองเฉพาะคนที่ไม่เกษียณ }, order: { salaryOrg: { @@ -1653,7 +1653,7 @@ export class ReportController extends Controller { salaryPeriodId: salaryPeriodId, }, type: "NONE", //ไม่ได้เลื่อน - isReserve: true //กรองเฉพาะคนที่เกษียณ + isReserve: true, //กรองเฉพาะคนที่เกษียณ }, order: { salaryOrg: { @@ -1749,7 +1749,7 @@ export class ReportController extends Controller { salaryPeriodId: salaryPeriodId, }, type: "NONE", //ไม่ได้เลื่อน - isReserve: false //กรองเฉพาะคนที่ไม่เกษียณ + isReserve: false, //กรองเฉพาะคนที่ไม่เกษียณ }, order: { salaryOrg: { @@ -1829,7 +1829,7 @@ export class ReportController extends Controller { salaryPeriodId: salaryPeriodId, }, type: "NONE", //ไม่ได้เลื่อน - isReserve: true //กรองเฉพาะคนที่เกษียณ + isReserve: true, //กรองเฉพาะคนที่เกษียณ }, order: { salaryOrg: { @@ -2557,6 +2557,7 @@ export class ReportController extends Controller { positionSalaryAmount: profile.positionSalaryAmount ? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString()) : null, + reasonSign: null, score: null, //สรุปผลการประเมินฯ ระดับและคะแนน reason: null, //เหตุผลที่ไม่สมควรหรือไม่อาจเลื่อนขั้นค่าจ้าง }; @@ -2634,6 +2635,7 @@ export class ReportController extends Controller { positionSalaryAmount: profile.positionSalaryAmount ? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString()) : null, + reasonSign: null, score: null, //สรุปผลการประเมินฯ ระดับและคะแนน reason: null, //เหตุผลที่ไม่สมควรหรือไม่อาจเลื่อนขั้นค่าจ้าง }; @@ -2857,7 +2859,7 @@ export class ReportController extends Controller { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { id: salaryPeriodId, - isActive: true + isActive: true, }, }); if (!salaryPeriod) { @@ -2901,7 +2903,7 @@ export class ReportController extends Controller { fullName: fullName, position: profile.position, posLevel: profile.posLevel, - } + }; }); return new HttpSuccess({ @@ -3733,33 +3735,33 @@ export class ReportController extends Controller { year: salaryPeriod?.year - 2, }, }); - - let octPreviousYearProfile: SalaryProfileEmployee[] = []; + + let octPreviousYearProfile: SalaryProfileEmployee[] = []; if (octPreviousYear) { - octPreviousYearProfile = await this.salaryProfileEmployeeRepository.find({ - relations: ["salaryOrg"], - where: { - salaryOrg: { - snapshot: "SNAP2", - rootId: rootId, - salaryPeriodId: octPreviousYear?.id, - }, - }, - }); + octPreviousYearProfile = await this.salaryProfileEmployeeRepository.find({ + relations: ["salaryOrg"], + where: { + salaryOrg: { + snapshot: "SNAP2", + rootId: rootId, + salaryPeriodId: octPreviousYear?.id, + }, + }, + }); } - - let octPreviousYearProfile2: SalaryProfileEmployee[] = []; + + let octPreviousYearProfile2: SalaryProfileEmployee[] = []; if (octPreviousYear2) { - octPreviousYearProfile2 = await this.salaryProfileEmployeeRepository.find({ - relations: ["salaryOrg"], - where: { - salaryOrg: { - snapshot: "SNAP2", - salaryPeriodId: octPreviousYear2?.id, - rootId: rootId, - }, - }, - }); + octPreviousYearProfile2 = await this.salaryProfileEmployeeRepository.find({ + relations: ["salaryOrg"], + where: { + salaryOrg: { + snapshot: "SNAP2", + salaryPeriodId: octPreviousYear2?.id, + rootId: rootId, + }, + }, + }); } const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({ @@ -3785,7 +3787,7 @@ export class ReportController extends Controller { const formattedData = _salaryPeriod.map((profile: any, index: number) => { if (!profile) { - return null; + return null; } const fullNameParts = [ profile.child4, @@ -3807,39 +3809,47 @@ export class ReportController extends Controller { posNumber: profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, - yearOld2: octPreviousYear2 == null ? null : Extension.ToThaiNumber(octPreviousYear2.year.toString()), + yearOld2: + octPreviousYear2 == null + ? null + : Extension.ToThaiNumber(octPreviousYear2.year.toString()), typeOld2: - octPreviousYear2 && octPreviousYearProfile2.length > 0 ? (() => { - const _profile = octPreviousYearProfile2 - .filter((profileOCT2) => profileOCT2.citizenId === profile.citizenId); + octPreviousYear2 && octPreviousYearProfile2.length > 0 + ? (() => { + const _profile = octPreviousYearProfile2.filter( + (profileOCT2) => profileOCT2.citizenId === profile.citizenId, + ); if (_profile.length > 0) { return _profile[0]?.type === "HAFT" - ? "๐.๕ ขั้น" - : _profile[0]?.type === "FULL" + ? "๐.๕ ขั้น" + : _profile[0]?.type === "FULL" ? "๑ ขั้น" : profile?.type === "FULLHAFT" - ? "๑.๕ ขั้น" - : "ไม่ได้เลื่อนขั้นฯ"; - } - return null; - })() - : null, - yearOld: octPreviousYear == null ? null : Extension.ToThaiNumber(octPreviousYear.year.toString()), - typeOld1: - octPreviousYear && octPreviousYearProfile.length > 0 ? (() => { - const _profile = octPreviousYearProfile - .filter((profileOCT) => profileOCT.citizenId === profile.citizenId); - if (_profile.length > 0) { - return _profile[0]?.type === "HAFT" - ? "๐.๕ ขั้น" - : _profile[0]?.type === "FULL" - ? "๑ ขั้น" - : profile?.type === "FULLHAFT" ? "๑.๕ ขั้น" : "ไม่ได้เลื่อนขั้นฯ"; } return null; - })() + })() + : null, + yearOld: + octPreviousYear == null ? null : Extension.ToThaiNumber(octPreviousYear.year.toString()), + typeOld1: + octPreviousYear && octPreviousYearProfile.length > 0 + ? (() => { + const _profile = octPreviousYearProfile.filter( + (profileOCT) => profileOCT.citizenId === profile.citizenId, + ); + if (_profile.length > 0) { + return _profile[0]?.type === "HAFT" + ? "๐.๕ ขั้น" + : _profile[0]?.type === "FULL" + ? "๑ ขั้น" + : profile?.type === "FULLHAFT" + ? "๑.๕ ขั้น" + : "ไม่ได้เลื่อนขั้นฯ"; + } + return null; + })() : null, typeOld: salaryPeriodAPRProfile.length > 0 @@ -3849,13 +3859,13 @@ export class ReportController extends Controller { .map((profile) => ({ type: profile.type, })); - return _profile[0]?.type === "HAFT" + return _profile[0]?.type === "HAFT" ? "๐.๕ ขั้น" : _profile[0]?.type === "FULL" - ? "๑ ขั้น" - : profile?.type === "FULLHAFT" - ? "๑.๕ ขั้น" - : "ไม่ได้เลื่อนขั้นฯ"; + ? "๑ ขั้น" + : profile?.type === "FULLHAFT" + ? "๑.๕ ขั้น" + : "ไม่ได้เลื่อนขั้นฯ"; })() : null, //เมษา ปีเดียวกัน type: @@ -3891,18 +3901,18 @@ export class ReportController extends Controller { where: { id: salaryPeriodId, period: "OCT", - isActive: true + isActive: true, }, }); if (!salaryPeriod) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน"); } const fifteenPoint = await this.salaryOrgEmployeeRepository.findOne({ - where:{ + where: { salaryPeriodId: salaryPeriodId, rootId: rootId, snapshot: "SNAP2", - } + }, }); const fifteenPercentData = fifteenPoint?.fifteenPercent == undefined || fifteenPoint?.fifteenPercent == null @@ -3913,39 +3923,39 @@ export class ReportController extends Controller { fifteenPoint?.fifteenPoint == undefined || fifteenPoint?.fifteenPoint == null ? ".๐๐" : "." + Extension.ToThaiNumber(String(fifteenPoint?.fifteenPoint)); - + const _salaryProfileEmployee = await this.salaryProfileEmployeeRepository.find({ - relations: ["salaryOrg"], - where: { - type: Not("NONE"), - salaryOrg: { - snapshot: "SNAP2", - rootId: rootId, - salaryPeriodId: salaryPeriodId, - }, + relations: ["salaryOrg"], + where: { + type: Not("NONE"), + salaryOrg: { + snapshot: "SNAP2", + rootId: rootId, + salaryPeriodId: salaryPeriodId, }, - order: { - orgShortName: "ASC", - posMasterNo: "ASC", - }, - }); + }, + order: { + orgShortName: "ASC", + posMasterNo: "ASC", + }, + }); if (!_salaryProfileEmployee) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } - + const aprSalaryPeriodCurrent = await this.salaryPeriodRepository.findOne({ where: { period: "APR", year: salaryPeriod.year, - isActive: true + isActive: true, }, }); const octPreviousYear = await this.salaryPeriodRepository.findOne({ where: { period: "OCT", year: salaryPeriod?.year - 1, - isActive: true + isActive: true, }, }); @@ -3953,7 +3963,7 @@ export class ReportController extends Controller { where: { period: "APR", year: salaryPeriod?.year - 1, - isActive: true + isActive: true, }, }); @@ -4024,41 +4034,47 @@ export class ReportController extends Controller { position: profile.position, posLevel: profile.posLevel, posNumber: - profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), + profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, - typeOld2: //เมษา ปีก่อนหน้า - aprPreviousYear2 && aprPreviousYearProfile2.length > 0 ? (() => { - const _profile = aprPreviousYearProfile2 - .filter((profileAPR2) => profileAPR2.citizenId === profile.citizenId); - if (_profile.length > 0) { - return _profile[0]?.type === "HAFT" + //เมษา ปีก่อนหน้า + typeOld2: + aprPreviousYear2 && aprPreviousYearProfile2.length > 0 + ? (() => { + const _profile = aprPreviousYearProfile2.filter( + (profileAPR2) => profileAPR2.citizenId === profile.citizenId, + ); + if (_profile.length > 0) { + return _profile[0]?.type === "HAFT" ? "๐.๕ ขั้น" : _profile[0]?.type === "FULL" - ? "๑ ขั้น" - : profile?.type === "FULLHAFT" - ? "๑.๕ ขั้น" - : "ไม่ได้เลื่อนขั้นฯ"; - } - return null; - })() - : null, - yearOld: - octPreviousYear == null ? null : Extension.ToThaiNumber(octPreviousYear.year.toString()), - typeOld1: //ตุลา ปีก่อนหน้า - octPreviousYear && octPreviousYearProfile.length > 0 ? (() => { - const _profile = octPreviousYearProfile - .filter((profileOCT) => profileOCT.citizenId === profile.citizenId); - if (_profile.length > 0) { - return _profile[0]?.type === "HAFT" - ? "๐.๕ ขั้น" - : _profile[0]?.type === "FULL" - ? "๑ ขั้น" - : profile?.type === "FULLHAFT" + ? "๑ ขั้น" + : profile?.type === "FULLHAFT" ? "๑.๕ ขั้น" : "ไม่ได้เลื่อนขั้นฯ"; } return null; - })() + })() + : null, + yearOld: + octPreviousYear == null ? null : Extension.ToThaiNumber(octPreviousYear.year.toString()), + //ตุลา ปีก่อนหน้า + typeOld1: + octPreviousYear && octPreviousYearProfile.length > 0 + ? (() => { + const _profile = octPreviousYearProfile.filter( + (profileOCT) => profileOCT.citizenId === profile.citizenId, + ); + if (_profile.length > 0) { + return _profile[0]?.type === "HAFT" + ? "๐.๕ ขั้น" + : _profile[0]?.type === "FULL" + ? "๑ ขั้น" + : profile?.type === "FULLHAFT" + ? "๑.๕ ขั้น" + : "ไม่ได้เลื่อนขั้นฯ"; + } + return null; + })() : null, typeOld: aprPreviousYearProfileCurrent.length > 0 @@ -4068,15 +4084,15 @@ export class ReportController extends Controller { .map((profile) => ({ type: profile.type, })); - return _profile[0]?.type === "HAFT" + return _profile[0]?.type === "HAFT" ? "๐.๕ ขั้น" : _profile[0]?.type === "FULL" - ? "๑ ขั้น" - : profile?.type === "FULLHAFT" - ? "๑.๕ ขั้น" - : "ไม่ได้เลื่อนขั้นฯ"; + ? "๑ ขั้น" + : profile?.type === "FULLHAFT" + ? "๑.๕ ขั้น" + : "ไม่ได้เลื่อนขั้นฯ"; })() - : null, //เมษา + : null, //เมษา type: profile.type === "HAFT" ? "๐.๕ ขั้น" @@ -4084,27 +4100,31 @@ export class ReportController extends Controller { ? "๑ ขั้น" : profile.type === "FULLHAFT" ? "๑.๕ ขั้น" - : "ไม่ได้เลื่อนขั้นฯ", + : "ไม่ได้เลื่อนขั้นฯ", score1: null, score2: null, - }; + }; }); return new HttpSuccess({ template: "emp2-03", - reportName: "emp2-03", + reportName: "emp2-03", data: { year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))), - yearOld: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year-1))), - yearShort: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))).slice(-2), - yearShortOld: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year-1))).slice(-2), + yearOld: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year - 1))), + yearShort: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))).slice( + -2, + ), + yearShortOld: Extension.ToThaiNumber( + String(Extension.ToThaiYear(salaryPeriod.year - 1)), + ).slice(-2), fifteenPercent: fifteenPercentData + fifteenPointData, agency: agency, data: formattedData, }, }); } - + /** * API 04-บัญชีรายชื่อลูกจ้างประจำกรุงเทพมหานครผู้สมควรได้เลื่อนขั้นค่าจ้าง (แบบ ลจ.กทม.1) * @@ -4117,7 +4137,7 @@ export class ReportController extends Controller { where: { id: salaryPeriodId, period: "OCT", - isActive: true + isActive: true, }, }); if (!salaryPeriod) { @@ -4131,7 +4151,7 @@ export class ReportController extends Controller { rootId: rootId, salaryPeriodId: salaryPeriodId, }, - type: Not("NONE") + type: Not("NONE"), }, order: { orgShortName: "ASC", @@ -4210,22 +4230,22 @@ export class ReportController extends Controller { } const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({ - relations: ["salaryOrg", "salaryOrg.salaryPeriod"], - where: { - amountSpecial: Not(IsNull()), - type: Not("NONE"), - salaryOrg: { - snapshot: "SNAP2", - rootId: rootId, - salaryPeriodId: salaryPeriodId, - }, + relations: ["salaryOrg", "salaryOrg.salaryPeriod"], + where: { + amountSpecial: Not(IsNull()), + type: Not("NONE"), + salaryOrg: { + snapshot: "SNAP2", + rootId: rootId, + salaryPeriodId: salaryPeriodId, }, - order: { - orgShortName: "ASC", - posMasterNo: "ASC", - }, - }); - + }, + order: { + orgShortName: "ASC", + posMasterNo: "ASC", + }, + }); + if (!_salaryPeriod) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } @@ -4252,16 +4272,20 @@ export class ReportController extends Controller { position: profile.position, posLevel: profile.posLevel, posNumber: - profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), - positionSalaryAmount: profile.positionSalaryAmount ? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString()) : null, - amountSpecial: profile.amountSpecial ? Extension.ToThaiNumber(profile.amountSpecial.toLocaleString()) : null, + profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), + positionSalaryAmount: profile.positionSalaryAmount + ? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString()) + : null, + amountSpecial: profile.amountSpecial + ? Extension.ToThaiNumber(profile.amountSpecial.toLocaleString()) + : null, reason: null, }; }); return new HttpSuccess({ template: "emp2-05", - reportName: "emp2-05", + reportName: "emp2-05", data: { year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))), agency: agency, @@ -4281,7 +4305,7 @@ export class ReportController extends Controller { where: { id: salaryPeriodId, period: "OCT", - isActive: true + isActive: true, }, }); if (!salaryPeriod) { @@ -4295,7 +4319,7 @@ export class ReportController extends Controller { rootId: rootId, salaryPeriodId: salaryPeriodId, }, - type: "NONE" + type: "NONE", }, order: { orgShortName: "ASC", @@ -4374,21 +4398,21 @@ export class ReportController extends Controller { } const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({ - relations: ["salaryOrg", "salaryOrg.salaryPeriod"], - where: { - type: "NONE", - salaryOrg: { - snapshot: "SNAP2", - rootId: rootId, - salaryPeriodId: salaryPeriodId, - }, + relations: ["salaryOrg", "salaryOrg.salaryPeriod"], + where: { + type: "NONE", + salaryOrg: { + snapshot: "SNAP2", + rootId: rootId, + salaryPeriodId: salaryPeriodId, }, - order: { - orgShortName: "ASC", - posMasterNo: "ASC", - }, - }); - + }, + order: { + orgShortName: "ASC", + posMasterNo: "ASC", + }, + }); + if (!_salaryPeriod) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } @@ -4415,7 +4439,7 @@ export class ReportController extends Controller { position: profile.position, posLevel: profile.posLevel, posNumber: - profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), + profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, reason: null, score: null, @@ -4425,7 +4449,7 @@ export class ReportController extends Controller { return new HttpSuccess({ template: "emp2-07", - reportName: "emp2-07", + reportName: "emp2-07", data: { year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))), agency: agency, @@ -4521,23 +4545,23 @@ export class ReportController extends Controller { if (!salaryPeriod) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน"); } - + const _salaryPeriodTarget = await this.salaryProfileEmployeeRepository.find({ - relations: ["salaryOrg", "salaryOrg.salaryPeriod"], - where: { - isRetired: true, - salaryOrg: { - snapshot: "SNAP2", - rootId: rootId, - salaryPeriodId: salaryPeriodId, - }, + relations: ["salaryOrg", "salaryOrg.salaryPeriod"], + where: { + isRetired: true, + salaryOrg: { + snapshot: "SNAP2", + rootId: rootId, + salaryPeriodId: salaryPeriodId, }, - order: { - orgShortName: "ASC", - posMasterNo: "ASC", - }, - }); - + }, + order: { + orgShortName: "ASC", + posMasterNo: "ASC", + }, + }); + if (!_salaryPeriodTarget) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } @@ -4586,7 +4610,6 @@ export class ReportController extends Controller { }); } - const agency = _salaryPeriodTarget[0] == null ? "" : _salaryPeriodTarget[0].root; const formattedData = _salaryPeriodTarget.map((profile, index) => { @@ -4609,79 +4632,88 @@ export class ReportController extends Controller { position: profile.position, posLevel: profile.posLevel, posNumber: - profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), + profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, typeOld2: - octPreviousYear2 && octPreviousYearProfile2.length > 0 ? (() => { - const _profile = octPreviousYearProfile2 - .filter((profileOCT2) => profileOCT2.citizenId === profile.citizenId); - if (_profile.length > 0) { - return _profile[0]?.type === "HAFT" - ? "๐.๕ ขั้น" - : _profile[0]?.type === "FULL" - ? "๑ ขั้น" - : profile?.type === "FULLHAFT" - ? "๑.๕ ขั้น" - : "ไม่ได้เลื่อนขั้นฯ"; - } - return null; - })() - : null, - yearOld: octPreviousYear == null ? null : Extension.ToThaiNumber(octPreviousYear.year.toString()), - typeOld1: - octPreviousYear && octPreviousYearProfile.length > 0 ? (() => { - const _profile = octPreviousYearProfile - .filter((profileOCT) => profileOCT.citizenId === profile.citizenId); - if (_profile.length > 0) { - return _profile[0]?.type === "HAFT" + octPreviousYear2 && octPreviousYearProfile2.length > 0 + ? (() => { + const _profile = octPreviousYearProfile2.filter( + (profileOCT2) => profileOCT2.citizenId === profile.citizenId, + ); + if (_profile.length > 0) { + return _profile[0]?.type === "HAFT" ? "๐.๕ ขั้น" : _profile[0]?.type === "FULL" + ? "๑ ขั้น" + : profile?.type === "FULLHAFT" + ? "๑.๕ ขั้น" + : "ไม่ได้เลื่อนขั้นฯ"; + } + return null; + })() + : null, + yearOld: + octPreviousYear == null ? null : Extension.ToThaiNumber(octPreviousYear.year.toString()), + typeOld1: + octPreviousYear && octPreviousYearProfile.length > 0 + ? (() => { + const _profile = octPreviousYearProfile.filter( + (profileOCT) => profileOCT.citizenId === profile.citizenId, + ); + if (_profile.length > 0) { + return _profile[0]?.type === "HAFT" + ? "๐.๕ ขั้น" + : _profile[0]?.type === "FULL" + ? "๑ ขั้น" + : profile?.type === "FULLHAFT" + ? "๑.๕ ขั้น" + : "ไม่ได้เลื่อนขั้นฯ"; + } + return null; + })() + : null, + typeOld: + _salaryPeriodTarget.length > 0 + ? (() => { + const _profile = _salaryPeriodTarget + .filter((profileAPR) => profileAPR.citizenId === profile.citizenId) + .map((profile) => ({ + type: profile.type, + })); + return _profile[0]?.type === "HAFT" + ? "๐.๕ ขั้น" + : _profile[0]?.type === "FULL" ? "๑ ขั้น" : profile?.type === "FULLHAFT" - ? "๑.๕ ขั้น" - : "ไม่ได้เลื่อนขั้นฯ"; - } - return null; - })() - : null, - typeOld: - _salaryPeriodTarget.length > 0 - ? (() => { - const _profile = _salaryPeriodTarget - .filter((profileAPR) => profileAPR.citizenId === profile.citizenId) - .map((profile) => ({ - type: profile.type, - })); - return _profile[0]?.type === "HAFT" - ? "๐.๕ ขั้น" - : _profile[0]?.type === "FULL" + ? "๑.๕ ขั้น" + : "ไม่ได้เลื่อนขั้นฯ"; + })() + : null, //เมษา ปีเดียวกัน + type: + profile.type === "HAFT" + ? "๐.๕ ขั้น" + : profile.type === "FULL" ? "๑ ขั้น" - : profile?.type === "FULLHAFT" - ? "๑.๕ ขั้น" - : "ไม่ได้เลื่อนขั้นฯ"; - })() - : null, //เมษา ปีเดียวกัน - type: - profile.type === "HAFT" - ? "๐.๕ ขั้น" - : profile.type === "FULL" - ? "๑ ขั้น" - : profile.type === "FULLHAFT" - ? "๑.๕ ขั้น" - : "ไม่ได้เลื่อนขั้นฯ", - score1: null, - score2: null, - reason: null, + : profile.type === "FULLHAFT" + ? "๑.๕ ขั้น" + : "ไม่ได้เลื่อนขั้นฯ", + score1: null, + score2: null, + reason: null, }; }); return new HttpSuccess({ template: "emp2-09", - reportName: "emp2-09", + reportName: "emp2-09", data: { year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))), - yearShort: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))).slice(-2,), - yearShortOld: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year-1))).slice(-2,), + yearShort: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))).slice( + -2, + ), + yearShortOld: Extension.ToThaiNumber( + String(Extension.ToThaiYear(salaryPeriod.year - 1)), + ).slice(-2), agency: agency, data: formattedData, }, @@ -4699,7 +4731,7 @@ export class ReportController extends Controller { where: { id: salaryPeriodId, period: "OCT", - isActive: true + isActive: true, }, }); if (!salaryPeriod) { @@ -4713,7 +4745,7 @@ export class ReportController extends Controller { rootId: rootId, salaryPeriodId: salaryPeriodId, }, - type: "NONE" + type: "NONE", }, order: { orgShortName: "ASC", @@ -4767,7 +4799,7 @@ export class ReportController extends Controller { }; }); const year = Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))); - const yearOld = Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year-1))); + const yearOld = Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year - 1))); return new HttpSuccess({ template: "emp2-10", reportName: "emp2-10", @@ -4799,21 +4831,21 @@ export class ReportController extends Controller { } const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({ - relations: ["salaryOrg", "salaryOrg.salaryPeriod"], - where: { - type: Not("NONE"), - salaryOrg: { - snapshot: "SNAP2", - rootId: rootId, - salaryPeriodId: salaryPeriodId, - }, + relations: ["salaryOrg", "salaryOrg.salaryPeriod"], + where: { + type: Not("NONE"), + salaryOrg: { + snapshot: "SNAP2", + rootId: rootId, + salaryPeriodId: salaryPeriodId, }, - order: { - orgShortName: "ASC", - posMasterNo: "ASC", - }, - }); - + }, + order: { + orgShortName: "ASC", + posMasterNo: "ASC", + }, + }); + if (!_salaryPeriod) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } @@ -4865,7 +4897,7 @@ export class ReportController extends Controller { where: { id: salaryPeriodId, period: "OCT", - isActive: true + isActive: true, }, }); if (!salaryPeriod) { @@ -4876,18 +4908,18 @@ export class ReportController extends Controller { snapshot: "SNAP2", rootId: rootId, salaryPeriodId: salaryPeriodId, - } + }, }); if (!salaryOrg) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } return new HttpSuccess({ - template: "emp2-12", + template: "emp2-12", reportName: "emp2-12", }); } - + /** * API 13-บัญชีรายละเอียดแสดงการเลื่อนขั้นค่าจ้างและให้ลูกจ้างประจำกรุงเทพมหานครได้รับอัตราค่าจ้างสูงกว่าอัตราค่าจ้างขั้นสูงของตำแหน่งที่ได้รับแต่งตั้งในแต่ละระดับ ที่เกษียณอายุราชการ * @@ -4906,22 +4938,22 @@ export class ReportController extends Controller { } const salaryProfile = await this.salaryProfileEmployeeRepository.find({ - relations: ["salaryOrg", "salaryOrg.salaryPeriod"], - where: { - isRetired: true, - isNext: true, - salaryOrg: { - snapshot: "SNAP2", - rootId: rootId, - salaryPeriodId: salaryPeriodId, - }, + relations: ["salaryOrg", "salaryOrg.salaryPeriod"], + where: { + isRetired: true, + isNext: true, + salaryOrg: { + snapshot: "SNAP2", + rootId: rootId, + salaryPeriodId: salaryPeriodId, }, - order: { - orgShortName: "ASC", - posMasterNo: "ASC", - }, - }); - + }, + order: { + orgShortName: "ASC", + posMasterNo: "ASC", + }, + }); + if (!salaryProfile) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } @@ -4948,13 +4980,15 @@ export class ReportController extends Controller { position: profile.position, posLevel: profile.posLevel, posNumber: - profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), + profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, - positionSalaryAmount: profile.positionSalaryAmount ? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString()) : null, + positionSalaryAmount: profile.positionSalaryAmount + ? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString()) + : null, reason: null, }; }); - + return new HttpSuccess({ template: "emp2-13", reportName: "emp2-13", @@ -4978,7 +5012,7 @@ export class ReportController extends Controller { where: { id: salaryPeriodId, period: "OCT", - isActive: true + isActive: true, }, }); if (!salaryPeriod) { @@ -4993,7 +5027,7 @@ export class ReportController extends Controller { salaryPeriodId: salaryPeriodId, }, type: "NONE", - isRetired: true + isRetired: true, }, order: { orgShortName: "ASC", @@ -5071,22 +5105,22 @@ export class ReportController extends Controller { } const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({ - relations: ["salaryOrg", "salaryOrg.salaryPeriod"], - where: { - isRetired: true, - type: "NONE", - salaryOrg: { - snapshot: "SNAP2", - rootId: rootId, - salaryPeriodId: salaryPeriodId, - }, + relations: ["salaryOrg", "salaryOrg.salaryPeriod"], + where: { + isRetired: true, + type: "NONE", + salaryOrg: { + snapshot: "SNAP2", + rootId: rootId, + salaryPeriodId: salaryPeriodId, }, - order: { - orgShortName: "ASC", - posMasterNo: "ASC", - }, - }); - + }, + order: { + orgShortName: "ASC", + posMasterNo: "ASC", + }, + }); + if (!_salaryPeriod) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } @@ -5113,7 +5147,7 @@ export class ReportController extends Controller { position: profile.position, posLevel: profile.posLevel, posNumber: - profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), + profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, reason: null, }; @@ -5121,7 +5155,7 @@ export class ReportController extends Controller { return new HttpSuccess({ template: "emp2-15", - reportName: "emp2-15", + reportName: "emp2-15", data: { year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))), agency: agency, @@ -5141,7 +5175,7 @@ export class ReportController extends Controller { where: { id: salaryPeriodId, period: "OCT", - isActive: true + isActive: true, }, }); if (!salaryPeriod) { @@ -5152,14 +5186,14 @@ export class ReportController extends Controller { snapshot: "SNAP2", rootId: rootId, salaryPeriodId: salaryPeriodId, - } + }, }); if (!salaryOrg) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } return new HttpSuccess({ - template: "emp2-16", + template: "emp2-16", reportName: "emp2-16", }); } @@ -5182,21 +5216,21 @@ export class ReportController extends Controller { } const salaryProfile = await this.salaryProfileEmployeeRepository.find({ - relations: ["salaryOrg", "salaryOrg.salaryPeriod"], - where: { - isNext: true, - salaryOrg: { - snapshot: "SNAP2", - rootId: rootId, - salaryPeriodId: salaryPeriodId, - }, + relations: ["salaryOrg", "salaryOrg.salaryPeriod"], + where: { + isNext: true, + salaryOrg: { + snapshot: "SNAP2", + rootId: rootId, + salaryPeriodId: salaryPeriodId, }, - order: { - orgShortName: "ASC", - posMasterNo: "ASC", - }, - }); - + }, + order: { + orgShortName: "ASC", + posMasterNo: "ASC", + }, + }); + if (!salaryProfile) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } @@ -5223,13 +5257,15 @@ export class ReportController extends Controller { position: profile.position, posLevel: profile.posLevel, posNumber: - profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), + profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, - positionSalaryAmount: profile.positionSalaryAmount ? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString()) : null, + positionSalaryAmount: profile.positionSalaryAmount + ? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString()) + : null, reason: null, }; }); - + return new HttpSuccess({ template: "emp2-17", reportName: "emp2-17", @@ -5253,7 +5289,7 @@ export class ReportController extends Controller { where: { id: salaryPeriodId, period: "OCT", - isActive: true + isActive: true, }, }); if (!salaryPeriod) { @@ -5268,7 +5304,7 @@ export class ReportController extends Controller { salaryPeriodId: salaryPeriodId, }, type: "NONE", - isRetired: false + isRetired: false, }, order: { orgShortName: "ASC", @@ -5341,7 +5377,7 @@ export class ReportController extends Controller { where: { id: salaryPeriodId, period: "OCT", - isActive: true + isActive: true, }, }); if (!salaryPeriod) { @@ -5409,8 +5445,8 @@ export class ReportController extends Controller { : null, //ร้อยละ 4 precentSix: profile.positionSalaryAmount == 0.06 - ? Extension.ToThaiNumber(profile.amountSpecial.toLocaleString()) - : null, //ร้อยละ 6 + ? Extension.ToThaiNumber(profile.amountSpecial.toLocaleString()) + : null, //ร้อยละ 6 reason: null, }; }); @@ -5444,21 +5480,21 @@ export class ReportController extends Controller { } const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({ - relations: ["salaryOrg", "salaryOrg.salaryPeriod"], - where: { - type: "NONE", - salaryOrg: { - snapshot: "SNAP2", - rootId: rootId, - salaryPeriodId: salaryPeriodId, - }, + relations: ["salaryOrg", "salaryOrg.salaryPeriod"], + where: { + type: "NONE", + salaryOrg: { + snapshot: "SNAP2", + rootId: rootId, + salaryPeriodId: salaryPeriodId, }, - order: { - orgShortName: "ASC", - posMasterNo: "ASC", - }, - }); - + }, + order: { + orgShortName: "ASC", + posMasterNo: "ASC", + }, + }); + if (!_salaryPeriod) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } @@ -5485,7 +5521,7 @@ export class ReportController extends Controller { position: profile.position, posLevel: profile.posLevel, posNumber: - profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), + profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, reason: null, }; @@ -5493,7 +5529,7 @@ export class ReportController extends Controller { return new HttpSuccess({ template: "emp2-21", - reportName: "emp2-21", + reportName: "emp2-21", data: { year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))), agency: agency, @@ -5513,7 +5549,7 @@ export class ReportController extends Controller { where: { id: salaryPeriodId, period: "OCT", - isActive: true + isActive: true, }, }); if (!salaryPeriod) { @@ -5524,14 +5560,14 @@ export class ReportController extends Controller { snapshot: "SNAP2", rootId: rootId, salaryPeriodId: salaryPeriodId, - } + }, }); if (!salaryOrg) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } return new HttpSuccess({ - template: "emp2-22", + template: "emp2-22", reportName: "emp2-22", }); } @@ -5619,7 +5655,7 @@ export class ReportController extends Controller { where: { id: salaryPeriodId, period: "OCT", - isActive: true + isActive: true, }, }); if (!salaryPeriod) { @@ -5630,14 +5666,14 @@ export class ReportController extends Controller { snapshot: "SNAP2", rootId: rootId, salaryPeriodId: salaryPeriodId, - } + }, }); if (!salaryOrg) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } return new HttpSuccess({ - template: "blank", + template: "blank", reportName: "emp2-24", }); } @@ -5672,20 +5708,20 @@ export class ReportController extends Controller { //งวดปีก่อนหน้า const perviousYearAPR = await this.salaryPeriodRepository.findOne({ - where:{ - period: "APR", - year: salaryPeriodOCT.year-1, - }, + where: { + period: "APR", + year: salaryPeriodOCT.year - 1, + }, }); if (!perviousYearAPR) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือนก่อนหน้า"); } const perviousYearOCT = await this.salaryPeriodRepository.findOne({ - where:{ - period: "OCT", - year: salaryPeriodOCT.year-1, - }, + where: { + period: "OCT", + year: salaryPeriodOCT.year - 1, + }, }); if (!perviousYearOCT) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือนก่อนหน้า"); @@ -5693,37 +5729,37 @@ export class ReportController extends Controller { //ปีก่อนหน้า const salaryProfilePerviousAPR = await this.salaryProfileEmployeeRepository.find({ - relations: ["salaryOrg", "salaryOrg.salaryPeriod"], - where: { - salaryOrg: { - snapshot: "SNAP2", - salaryPeriodId: perviousYearAPR.id, - }, + relations: ["salaryOrg", "salaryOrg.salaryPeriod"], + where: { + salaryOrg: { + snapshot: "SNAP2", + salaryPeriodId: perviousYearAPR.id, }, - order: { - orgShortName: "ASC", - posMasterNo: "ASC", - }, - }); - + }, + order: { + orgShortName: "ASC", + posMasterNo: "ASC", + }, + }); + if (!salaryProfilePerviousAPR) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } const salaryProfilePerviousOCT = await this.salaryProfileEmployeeRepository.find({ - relations: ["salaryOrg", "salaryOrg.salaryPeriod"], - where: { - salaryOrg: { - snapshot: "SNAP2", - salaryPeriodId: perviousYearOCT.id, - }, + relations: ["salaryOrg", "salaryOrg.salaryPeriod"], + where: { + salaryOrg: { + snapshot: "SNAP2", + salaryPeriodId: perviousYearOCT.id, }, - order: { - orgShortName: "ASC", - posMasterNo: "ASC", - }, - }); - + }, + order: { + orgShortName: "ASC", + posMasterNo: "ASC", + }, + }); + if (!salaryProfilePerviousOCT) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } @@ -5732,7 +5768,7 @@ export class ReportController extends Controller { const salaryProfileCurrentAPR = await this.salaryProfileEmployeeRepository.find({ relations: ["salaryOrg", "salaryOrg.salaryPeriod"], where: { - salaryOrg: { + salaryOrg: { snapshot: "SNAP2", salaryPeriodId: salaryPeriodId, }, @@ -5748,40 +5784,47 @@ export class ReportController extends Controller { } const salaryProfileCurrentOCT = await this.salaryProfileEmployeeRepository.find({ - relations: ["salaryOrg", "salaryOrg.salaryPeriod"], - where: { - salaryOrg: { - snapshot: "SNAP2", - salaryPeriodId: salaryPeriodId, - }, + relations: ["salaryOrg", "salaryOrg.salaryPeriod"], + where: { + salaryOrg: { + snapshot: "SNAP2", + salaryPeriodId: salaryPeriodId, }, - order: { - orgShortName: "ASC", - posMasterNo: "ASC", - }, - }); - + }, + order: { + orgShortName: "ASC", + posMasterNo: "ASC", + }, + }); + if (!salaryProfileCurrentOCT) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } const agency = salaryProfileCurrentOCT[0] == null ? "" : salaryProfileCurrentOCT[0].root; - + const formattedData = salaryProfileCurrentOCT.map((profile, index) => { //งวดปีก่อนหน้า - const matchedAPRProfileOld = salaryProfilePerviousAPR.find(aprProfile_old => aprProfile_old.citizenId === profile.citizenId); - const matchedOCTProfileOld = salaryProfilePerviousOCT.find(octProfile_old => octProfile_old.citizenId === profile.citizenId); + const matchedAPRProfileOld = salaryProfilePerviousAPR.find( + (aprProfile_old) => aprProfile_old.citizenId === profile.citizenId, + ); + const matchedOCTProfileOld = salaryProfilePerviousOCT.find( + (octProfile_old) => octProfile_old.citizenId === profile.citizenId, + ); const amountUseAPR_Old = matchedAPRProfileOld ? matchedAPRProfileOld.amountUse : 0; const amountUseOCT_Old = matchedOCTProfileOld ? matchedOCTProfileOld.amountUse : 0; const amountUseOld = amountUseAPR_Old + amountUseOCT_Old; - + //งวดปีปัจจุบัน - const matchedAPRProfile = salaryProfileCurrentAPR.find(aprProfile => aprProfile.citizenId === profile.citizenId); - const matchedOCTProfile = salaryProfileCurrentOCT.find(octProfile => octProfile.citizenId === profile.citizenId); + const matchedAPRProfile = salaryProfileCurrentAPR.find( + (aprProfile) => aprProfile.citizenId === profile.citizenId, + ); + const matchedOCTProfile = salaryProfileCurrentOCT.find( + (octProfile) => octProfile.citizenId === profile.citizenId, + ); const amountUseAPR = matchedAPRProfile ? matchedAPRProfile.amountUse : 0; const amountUseOCT = matchedOCTProfile ? matchedOCTProfile.amountUse : 0; const amountUse = amountUseAPR + amountUseOCT; - const fullNameParts = [ profile.child4, @@ -5802,15 +5845,17 @@ export class ReportController extends Controller { position: profile.position, posLevel: profile.posLevel, posNumber: - profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), + profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, - positionSalaryAmount: profile.positionSalaryAmount ? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString()) : null, + positionSalaryAmount: profile.positionSalaryAmount + ? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString()) + : null, amountUseOld: amountUseOld ? Extension.ToThaiNumber(amountUseOld.toLocaleString()) : null, amountUse: amountUse ? Extension.ToThaiNumber(amountUse.toLocaleString()) : null, reason: null, }; }); - + return new HttpSuccess({ template: "emp2-25", reportName: "emp2-25", @@ -5819,6 +5864,6 @@ export class ReportController extends Controller { agency: agency, data: formattedData, }, - }); + }); } }