From 20bf1114423cecd81c80e4ce6ee3c4bd82aaa4cb Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 10 Apr 2024 14:54:52 +0700 Subject: [PATCH] emp2 (01-10) --- src/controllers/ReportController.ts | 132 ++++++++++++++++++---------- 1 file changed, 86 insertions(+), 46 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 05c5370..ceb39a2 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -3912,7 +3912,7 @@ export class ReportController extends Controller { } const totalEmp2step = emp2step.size ?? 0; - const agency = octSnap1.salaryProfiles[0] == null ? "" : octSnap1.salaryProfiles[0].root; + // const agency = octSnap1.salaryProfiles[0] == null ? "" : octSnap1.salaryProfiles[0].root; return new HttpSuccess({ template: "emp2-01", reportName: "emp2-01", @@ -3921,35 +3921,35 @@ export class ReportController extends Controller { yearShort: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))).slice( -2, ), - agency: agency, - totalUser: octSnap1 == null ? "" : Extension.ToThaiNumber(octSnap1.total.toString()), + agency: octSnap1.root == null ? "" : octSnap1.root, + totalUser: octSnap1 == null ? "" : Extension.ToThaiNumber(octSnap1.total.toLocaleString()), totalSalary: - octSnap1 == null ? "" : Extension.ToThaiNumber(octSnap1.currentAmount.toString()), + octSnap1 == null ? "" : Extension.ToThaiNumber(octSnap1.currentAmount.toLocaleString()), sixPercent: - octSnap1 == null ? "" : Extension.ToThaiNumber(octSnap1.sixPercentAmount.toString()), + octSnap1 == null ? "" : Extension.ToThaiNumber(octSnap1.sixPercentAmount.toLocaleString()), remainingAmountApr: - aprSnap2 == null ? "" : Extension.ToThaiNumber(aprSnap2.useAmount.toString()), //จำนวนเงินที่ใช้เลื่อนขั้นค่าจ้างไปแล้วในวันที่ 1 เม.ย. + aprSnap2 == null ? "" : Extension.ToThaiNumber(aprSnap2.useAmount.toLocaleString()), //จำนวนเงินที่ใช้เลื่อนขั้นค่าจ้างไปแล้วในวันที่ 1 เม.ย. remainingAmountOct: - octSnap2 == null ? "" : Extension.ToThaiNumber(octSnap2.spentAmount.toString()), //เหลือเงินใช้เลื่อนขั้นค่าจ้างในวันที่ 1 ต.ค. - totalOld: aprSnap2 == null ? "" : Extension.ToThaiNumber(aprSnap2.total.toString()), //จำนวน(คน)(โควตาเลื่อนขั้นค่าจ้าง) + octSnap2 == null ? "" : Extension.ToThaiNumber(octSnap2.spentAmount.toLocaleString()), //เหลือเงินใช้เลื่อนขั้นค่าจ้างในวันที่ 1 ต.ค. + totalOld: aprSnap2 == null ? "" : Extension.ToThaiNumber(aprSnap2.total.toLocaleString()), //จำนวน(คน)(โควตาเลื่อนขั้นค่าจ้าง) fifteenPercentOld: - aprSnap2 == null ? "" : Extension.ToThaiNumber(aprSnap2.fifteenPercent.toString()), + aprSnap2 == null ? "" : Extension.ToThaiNumber(aprSnap2.fifteenPercent.toLocaleString()), totalUseOld: - aprSnap2 == null ? "" : Extension.ToThaiNumber(aprSnap2.quantityUsed.toString()), //พิจารณาให้(คน)(โควตาเลื่อนขั้นค่าจ้าง) - full2: totalEmp2step == null ? "" : Extension.ToThaiNumber(totalEmp2step.toString()), //เลื่อนขั้นค่าจ้างรวมทั้งปีสองขั้นจำนวน(คน) - fullHaft: fullHaftCount == null ? "" : Extension.ToThaiNumber(fullHaftCount.toString()), //จำนวน(คน)(หนึ่งขั้นครึ่ง) + aprSnap2 == null ? "" : Extension.ToThaiNumber(aprSnap2.quantityUsed.toLocaleString()), //พิจารณาให้(คน)(โควตาเลื่อนขั้นค่าจ้าง) + full2: totalEmp2step == null ? "" : Extension.ToThaiNumber(totalEmp2step.toLocaleString()), //เลื่อนขั้นค่าจ้างรวมทั้งปีสองขั้นจำนวน(คน) + fullHaft: fullHaftCount == null ? "" : Extension.ToThaiNumber(fullHaftCount.toLocaleString()), //จำนวน(คน)(หนึ่งขั้นครึ่ง) fullHaftSalary: - fullHaftTotalAmount == null ? "" : Extension.ToThaiNumber(fullHaftTotalAmount.toString()), //ใช้เงิน(หนึ่งขั้นครึ่ง) - full: fullCount == null ? "" : Extension.ToThaiNumber(fullCount.toString()), //จำนวน(คน)(หนึ่งขั้น) + fullHaftTotalAmount == null ? "" : Extension.ToThaiNumber(fullHaftTotalAmount.toLocaleString()), //ใช้เงิน(หนึ่งขั้นครึ่ง) + full: fullCount == null ? "" : Extension.ToThaiNumber(fullCount.toLocaleString()), //จำนวน(คน)(หนึ่งขั้น) fullSalary: - fullTotalAmount == null ? "" : Extension.ToThaiNumber(fullTotalAmount.toString()), //ใช้เงิน(หนึ่งขั้น) - haft: haftCount == null ? "" : Extension.ToThaiNumber(haftCount.toString()), //จำนวน(คน)(ครึ่งขั้น) + fullTotalAmount == null ? "" : Extension.ToThaiNumber(fullTotalAmount.toLocaleString()), //ใช้เงิน(หนึ่งขั้น) + haft: haftCount == null ? "" : Extension.ToThaiNumber(haftCount.toLocaleString()), //จำนวน(คน)(ครึ่งขั้น) haftSalary: - haftTotalAmount == null ? "" : Extension.ToThaiNumber(haftTotalAmount.toString()), //ใช้เงิน(ครึ่งขั้น) - notPromoted: noneCount == null ? "" : Extension.ToThaiNumber(noneCount.toString()), //ไม่ได้เลื่อนขั้นค่าจ้างจำนวน(คน) - total: octSnap2 == null ? "" : Extension.ToThaiNumber(octSnap2.useAmount.toString()), //รวมใช้เงิน + haftTotalAmount == null ? "" : Extension.ToThaiNumber(haftTotalAmount.toLocaleString()), //ใช้เงิน(ครึ่งขั้น) + notPromoted: noneCount == null ? "" : Extension.ToThaiNumber(noneCount.toLocaleString()), //ไม่ได้เลื่อนขั้นค่าจ้างจำนวน(คน) + total: octSnap2 == null ? "" : Extension.ToThaiNumber(octSnap2.useAmount.toLocaleString()), //รวมใช้เงิน summary: - octSnap2 == null ? "" : Extension.ToThaiNumber(octSnap2.remainingAmount.toString()), //เหลือเงิน + octSnap2 == null ? "" : Extension.ToThaiNumber(octSnap2.remainingAmount.toLocaleString()), //เหลือเงิน }, }); } @@ -4052,8 +4052,13 @@ export class ReportController extends Controller { if (!_salaryPeriod) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } - - const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root; + const _root = await this.salaryOrgEmployeeRepository.findOne({ + where: { + rootId: rootId, + salaryPeriodId: salaryPeriodId, + }, + }); + // const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root; const formattedData = _salaryPeriod.map((profile: any, index: number) => { if (!profile) { @@ -4155,7 +4160,7 @@ export class ReportController extends Controller { reportName: "emp2-02", data: { year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))), - agency: agency, + agency: _root?.root == null ? "" : _root?.root, data: formattedData, }, }); @@ -4283,7 +4288,7 @@ export class ReportController extends Controller { }); } - const agency = _salaryProfileEmployee[0] == null ? "" : _salaryProfileEmployee[0].root; + // const agency = _salaryProfileEmployee[0] == null ? "" : _salaryProfileEmployee[0].root; const formattedData = _salaryProfileEmployee.map((profile, index) => { const fullNameParts = [ @@ -4391,7 +4396,7 @@ export class ReportController extends Controller { String(Extension.ToThaiYear(salaryPeriod.year - 1)), ).slice(-2), fifteenPercent: fifteenPercentData + fifteenPointData, - agency: agency, + agency: fifteenPoint?.root == null ? "" : fifteenPoint?.root, data: formattedData, }, }); @@ -4434,8 +4439,13 @@ export class ReportController extends Controller { if (!_salaryProfileEmp) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } - - const agency = _salaryProfileEmp[0] == null ? "" : _salaryProfileEmp[0].root; + const _root = await this.salaryOrgEmployeeRepository.findOne({ + where: { + rootId: rootId, + salaryPeriodId: salaryPeriodId, + }, + }); + // const agency = _salaryProfileEmp[0] == null ? "" : _salaryProfileEmp[0].root; const formattedData = _salaryProfileEmp.map((profile, index) => { const fullNameParts = [ @@ -4480,7 +4490,7 @@ export class ReportController extends Controller { reportName: "emp2-04", data: { year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))), - agency: agency, + agency: _root?.root == null ? "" : _root?.root, data: formattedData, }, }); @@ -4522,8 +4532,13 @@ export class ReportController extends Controller { if (!_salaryPeriod) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } - - const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root; + const _root = await this.salaryOrgEmployeeRepository.findOne({ + where: { + rootId: rootId, + salaryPeriodId: salaryPeriodId, + }, + }); + // const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root; const formattedData = _salaryPeriod.map((profile, index) => { const fullNameParts = [ @@ -4562,7 +4577,7 @@ export class ReportController extends Controller { reportName: "emp2-05", data: { year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))), - agency: agency, + agency: _root?.root == null ? "" : _root?.root, data: formattedData, }, }); @@ -4604,8 +4619,13 @@ export class ReportController extends Controller { if (!_salaryProfileEmp) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } - - const agency = _salaryProfileEmp[0] == null ? "" : _salaryProfileEmp[0].root; + const _root = await this.salaryOrgEmployeeRepository.findOne({ + where: { + rootId: rootId, + salaryPeriodId: salaryPeriodId, + }, + }); + // const agency = _salaryProfileEmp[0] == null ? "" : _salaryProfileEmp[0].root; const formattedData = _salaryProfileEmp.map((profile, index) => { const fullNameParts = [ @@ -4650,7 +4670,7 @@ export class ReportController extends Controller { reportName: "emp2-06", data: { year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))), - agency: agency, + agency: _root?.root == null ? "" : _root?.root, data: formattedData, }, }); @@ -4691,8 +4711,13 @@ export class ReportController extends Controller { if (!_salaryPeriod) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } - - const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root; + const _root = await this.salaryOrgEmployeeRepository.findOne({ + where: { + rootId: rootId, + salaryPeriodId: salaryPeriodId, + }, + }); + // const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root; const formattedData = _salaryPeriod.map((profile, index) => { const fullNameParts = [ @@ -4728,7 +4753,7 @@ export class ReportController extends Controller { reportName: "emp2-07", data: { year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))), - agency: agency, + agency: _root?.root == null ? "" : _root?.root, data: formattedData, }, }); @@ -4767,8 +4792,13 @@ export class ReportController extends Controller { if (!_salaryPeriod) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } - - const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root; + const _root = await this.salaryOrgEmployeeRepository.findOne({ + where: { + rootId: rootId, + salaryPeriodId: salaryPeriodId, + }, + }); + // const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root; const formattedData = _salaryPeriod.map((profile, index) => { const fullNameParts = [ @@ -4801,7 +4831,7 @@ export class ReportController extends Controller { reportName: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01", data: { year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))), - agency: agency, + agency: _root?.root == null ? "" : _root?.root, data: formattedData, }, }); @@ -4886,8 +4916,13 @@ export class ReportController extends Controller { }, }); } - - const agency = _salaryPeriodTarget[0] == null ? "" : _salaryPeriodTarget[0].root; + const _root = await this.salaryOrgEmployeeRepository.findOne({ + where: { + rootId: rootId, + salaryPeriodId: salaryPeriodId, + }, + }); + // const agency = _salaryPeriodTarget[0] == null ? "" : _salaryPeriodTarget[0].root; const formattedData = _salaryPeriodTarget.map((profile, index) => { const fullNameParts = [ @@ -4992,7 +5027,7 @@ export class ReportController extends Controller { yearShortOld: Extension.ToThaiNumber( String(Extension.ToThaiYear(salaryPeriod.year - 1)), ).slice(-2), - agency: agency, + agency: _root?.root == null ? "" : _root?.root, data: formattedData, }, }); @@ -5034,8 +5069,13 @@ export class ReportController extends Controller { if (!_salaryProfileEmp) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } - - const agency = _salaryProfileEmp[0] == null ? "" : _salaryProfileEmp[0].root; + const _root = await this.salaryOrgEmployeeRepository.findOne({ + where: { + rootId: rootId, + salaryPeriodId: salaryPeriodId, + }, + }); + // const agency = _salaryProfileEmp[0] == null ? "" : _salaryProfileEmp[0].root; const formattedData = _salaryProfileEmp.map((profile, index) => { const fullNameParts = [ @@ -5086,7 +5126,7 @@ export class ReportController extends Controller { year: year, yearSlice: year.slice(-2), yearOldSlice: yearOld.slice(-2), - agency: agency, + agency: _root?.root == null ? "" : _root?.root, data: formattedData, }, });