diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 5b95cc5..1bcd478 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -1096,7 +1096,7 @@ export class ReportController extends Controller { // }, // select: ["root"], // }); - + //รอบปีก่อนหน้า const salaryPeriodIncrease2_APR = await this.salaryPeriodRepository.findOne({ where: { @@ -1119,7 +1119,7 @@ export class ReportController extends Controller { salaryPeriodId: salaryPeriodIncrease2_APR?.id, // rootId: rootId, // root: rootName?.root, - rootId:salaryOrg?.rootDnaId, + rootId: salaryOrg?.rootDnaId, snapshot: "SNAP1", group: convertGroup, }, @@ -1133,7 +1133,7 @@ export class ReportController extends Controller { salaryPeriodId: salaryPeriodIncrease2_OCT?.id, // rootId: rootId, // root: rootName?.root, - rootId:salaryOrg?.rootDnaId, + rootId: salaryOrg?.rootDnaId, snapshot: "SNAP1", group: convertGroup, }, @@ -1147,8 +1147,8 @@ export class ReportController extends Controller { }, }); - //รอบปีก่อนๆ - const salaryPeriodIncrease1_APR = await this.salaryPeriodRepository.findOne({ + //รอบปีก่อนๆ + const salaryPeriodIncrease1_APR = await this.salaryPeriodRepository.findOne({ where: { period: "APR", year: salaryPeriod.year - 2, @@ -1170,7 +1170,7 @@ export class ReportController extends Controller { salaryPeriodId: salaryPeriodIncrease1_APR?.id, // rootId: rootId, // root: rootName?.root, - rootId:salaryOrg2_APR?.rootDnaId, + rootId: salaryOrg2_APR?.rootDnaId, snapshot: "SNAP1", group: convertGroup, }, @@ -1184,7 +1184,7 @@ export class ReportController extends Controller { salaryPeriodId: salaryPeriodIncrease1_OCT?.id, // rootId: rootId, // root: rootName?.root, - rootId:salaryOrg2_APR?.rootDnaId, + rootId: salaryOrg2_APR?.rootDnaId, snapshot: "SNAP1", group: convertGroup, }, @@ -2503,7 +2503,6 @@ export class ReportController extends Controller { @Path() salaryPeriodId: string, @Path() group: string, ) { - const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { id: salaryPeriodId, @@ -2577,53 +2576,53 @@ export class ReportController extends Controller { const formattedData = salaryProfile.map((item, index) => ({ no: Extension.ToThaiNumber(String(index + 1)), fullname: item.prefix + item.firstName + " " + item.lastName, - root: item.root??"-", - position: item.position??"-", + root: item.root ?? "-", + position: item.position ?? "-", posMasterNo: - Extension.ToThaiNumber(item.orgShortName) + Extension.ToThaiNumber(String(item.posMasterNo)), - posTypeCurrent: item.posType??"-", - posLevelCurrent: item.posLevel??"-", - amountCurrent: item.amount? Extension.ToThaiNumber(item.amount.toLocaleString()):"-", - posTypePrevious: salaryProfilePrevious.length > 0 - ? (() => { - const filteredType = salaryProfilePrevious - .filter((profile) => profile.citizenId === item.citizenId) - .map((profile) => profile.posType); - const posType = filteredType[0]; - return posType - ? posType : "-"; - })() - : "-", - posLevelPrevious: salaryProfilePrevious.length > 0 - ? (() => { - const filteredLevel = salaryProfilePrevious - .filter((profile) => profile.citizenId === item.citizenId) - .map((profile) => profile.posLevel); - const posLevel = filteredLevel[0]; - return posLevel - ? posLevel : "-"; - })() - : "-", - amountPrevious: salaryProfilePrevious.length > 0 - ? (() => { - const filteredAmount = salaryProfilePrevious - .filter((profile) => profile.citizenId === item.citizenId) - .map((profile) => profile.amount); - const amount = filteredAmount[0]; - return amount - ? Extension.ToThaiNumber(amount.toLocaleString()):"-" - })() - : "-", - deduction: "-", //เงินปรับลด - promote: item.amountUse?Extension.ToThaiNumber(item.amountUse.toLocaleString()):"-", //เงินเลื่อนขั้น - qualification: "-", //เงินปรับวุฒิ + Extension.ToThaiNumber(item.orgShortName) + + Extension.ToThaiNumber(String(item.posMasterNo)), + posTypeCurrent: item.posType ?? "-", + posLevelCurrent: item.posLevel ?? "-", + amountCurrent: item.amount ? Extension.ToThaiNumber(item.amount.toLocaleString()) : "-", + posTypePrevious: + salaryProfilePrevious.length > 0 + ? (() => { + const filteredType = salaryProfilePrevious + .filter((profile) => profile.citizenId === item.citizenId) + .map((profile) => profile.posType); + const posType = filteredType[0]; + return posType ? posType : "-"; + })() + : "-", + posLevelPrevious: + salaryProfilePrevious.length > 0 + ? (() => { + const filteredLevel = salaryProfilePrevious + .filter((profile) => profile.citizenId === item.citizenId) + .map((profile) => profile.posLevel); + const posLevel = filteredLevel[0]; + return posLevel ? posLevel : "-"; + })() + : "-", + amountPrevious: + salaryProfilePrevious.length > 0 + ? (() => { + const filteredAmount = salaryProfilePrevious + .filter((profile) => profile.citizenId === item.citizenId) + .map((profile) => profile.amount); + const amount = filteredAmount[0]; + return amount ? Extension.ToThaiNumber(amount.toLocaleString()) : "-"; + })() + : "-", + deduction: "-", //เงินปรับลด + promote: item.amountUse ? Extension.ToThaiNumber(item.amountUse.toLocaleString()) : "-", //เงินเลื่อนขั้น + qualification: "-", //เงินปรับวุฒิ adjustRate: "-", //เงินปรับอัตรา newRate: "-", //อัตราตั้งใหม่ specialPromote: "-", //ลำดับการเลื่อนกรณีพิเศษ - remark: item.remark??"-", + remark: item.remark ?? "-", temporaryPayment: "-", //ถือจ่ายชั่วคราวขั้น - })) - + })); return new HttpSuccess({ template: "gov2-10", @@ -7984,11 +7983,11 @@ export class ReportController extends Controller { positionLevel: salary.posLevel, commandId: v.commandId, remark: v.remark, - orgRoot: salary.root, - orgChild1: salary.child1, - orgChild2: salary.child2, - orgChild3: salary.child3, - orgChild4: salary.child4, + orgRootName: salary.root, + orgChild1Name: salary.child1, + orgChild2Name: salary.child2, + orgChild3Name: salary.child3, + orgChild4Name: salary.child4, commandCode: v.commandCode, commandName: v.commandName, commandNo: v.commandNo, @@ -8024,7 +8023,7 @@ export class ReportController extends Controller { refId: string; // commandAffectDate: Date | null;//เก่า commandDateAffect: Date | null; //ใหม่ (ปรับตาม rabbitMQ ORG) - commandDateSign?: Date | null + commandDateSign?: Date | null; commandNo: string | null; commandYear: number | null; commandId: string | null; @@ -8050,7 +8049,7 @@ export class ReportController extends Controller { id: v.refId, }, }); - + if (salary != null) { await new CallAPI() .PostData(request, "/org/profile-employee/salary/update", { @@ -8061,11 +8060,11 @@ export class ReportController extends Controller { amountSpecial: v.amountSpecial, positionSalaryAmount: v.positionSalaryAmount, mouthSalaryAmount: v.mouthSalaryAmount, - posNo: salary.posMasterNo != null?salary.posMasterNo.toString():null, + posNo: salary.posMasterNo != null ? salary.posMasterNo.toString() : null, posNoAbb: salary.orgShortName, positionName: salary.position, positionType: salary.posType, - positionLevel: salary.posLevel != null?salary.posLevel.toString():null, + positionLevel: salary.posLevel != null ? salary.posLevel.toString() : null, remark: v.remark, orgRoot: salary.root, orgChild1: salary.child1,