fix gov1-04

This commit is contained in:
AdisakKanthawilang 2024-03-20 19:12:43 +07:00
parent dc8b7f815a
commit 1b2e4239f5

View file

@ -1025,7 +1025,7 @@ export class ReportController extends Controller {
}); });
} }
/** /**
* API 1 * API 1
* *
* @summary 1 * @summary 1
@ -1033,90 +1033,84 @@ export class ReportController extends Controller {
* @param {string} rootId Guid, *Id Root * @param {string} rootId Guid, *Id Root
* @param {string} salaryPeriodId Guid, *Id Period * @param {string} salaryPeriodId Guid, *Id Period
*/ */
@Get("gov1-04/{rootId}/{salaryPeriodId}") @Get("gov1-04/{rootId}/{salaryPeriodId}")
async SalaryReport4(@Path() rootId: string, @Path() salaryPeriodId: string) { async SalaryReport4(@Path() rootId: string, @Path() salaryPeriodId: string) {
const salaryPeriod = await this.salaryPeriodRepository.findOne({ const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: { where: {
id: salaryPeriodId, id: salaryPeriodId,
period: "APR", // period: "APR",
isActive: true, isActive: true,
}, },
}); });
if (!salaryPeriod) { if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
} }
const salaryOrg = await this.salaryOrgRepository.findOne({ const salaryOrg = await this.salaryOrgRepository.findOne({
where: { where: {
salaryPeriodId: salaryPeriodId, salaryPeriodId: salaryPeriodId,
rootId: rootId, rootId: rootId,
snapshot: "SNAP2", snapshot: "SNAP2",
}, },
order: { order: {
group: "ASC", group: "ASC",
}, },
relations: ["salaryProfiles"], relations: ["salaryProfiles"],
}); });
const salaryProfile = await this.salaryProfileRepository.find({ const salaryProfile = await this.salaryProfileRepository.find({
where: { relations: ["salaryOrg"],
salaryOrgId: salaryOrg?.id, where: {
type: Not("NONE"), //ทุก Type ยกเว้นไม่ได้เลื่อน salaryOrgId: salaryOrg?.id,
}, },
select: [ order: {
"id", salaryOrg: {
"prefix", group: "ASC",
"firstName", },
"lastName", type: "DESC",
"root", posMasterNo: "ASC",
"position", },
"posType", });
"posLevel",
"orgShortName", return new HttpSuccess({
"posMasterNo", template: salaryPeriod.period === "APR" ? "gov1-04" : "gov2-04",
"amount", reportName: salaryPeriod.period === "APR" ? "gov1-04" : "gov2-04",
"amountSpecial", data: {
], year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod?.year))),
order: { effectiveDate: salaryPeriod?.effectiveDate,
posMasterNo: "ASC", root: salaryProfile[0]?.root,
}, profile: salaryProfile.map((item, index) => ({
}); no: Extension.ToThaiNumber(String(index + 1)),
fullname: item.prefix + item.firstName + " " + item.lastName,
return new HttpSuccess({ log_group: item.salaryOrg.group,
template: "gov1-04", log_type: item.type,
reportName: "gov1-04", position:
data: { item.position +
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod?.year))), "/" +
effectiveDate: salaryPeriod?.effectiveDate, (item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") +
root: salaryProfile[0]?.root, (item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") +
profile: salaryProfile.map((item, index) => ({ (item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") +
no: Extension.ToThaiNumber(String(index + 1)), (item.child1 == undefined && item.child1 == null ? "" : item.child1 + "/") +
fullname: item.prefix + item.firstName + " " + item.lastName, (item.root == undefined && item.root == null ? "" : item.root),
position: posLevel: item.posLevel,
item.position + orgShortName: item.orgShortName + Extension.ToThaiNumber(String(item.posMasterNo)),
"/" + amount:
(item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") + item.amount == undefined || item.amount == null
(item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") + ? ""
(item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") + : Extension.ToThaiNumber(String(item.amount)),
(item.child1 == undefined && item.child1 == null ? "" : item.child1 + "/") +
(item.root == undefined && item.root == null ? "" : item.root),
posLevel: item.posLevel,
orgShortName: item.orgShortName + Extension.ToThaiNumber(String(item.posMasterNo)),
amount:
item.amount == undefined || item.amount == null
? ""
: Extension.ToThaiNumber(String(item.amount)),
amountSpecial: amountSpecial:
item.amountSpecial == undefined || item.amountSpecial == null (item.positionSalaryAmount == undefined || item.positionSalaryAmount == null ? "" : Extension.ToThaiNumber(String(item.positionSalaryAmount))) +
? "" (item.amountSpecial == undefined || item.amountSpecial == null ? "" : `(${Extension.ToThaiNumber(String(item.amountSpecial))})`),
: Extension.ToThaiNumber(String(item.amountSpecial)), score: null, //สรุปผลการประเมินฯ ระดับและคะแนน
score: null, //สรุปผลการประเมินฯ ระดับและคะแนน remark:
remark: null, //หมายเหตุ `${item.type == "FULL" ? "" : "หนึ่งขั้น"}\n` +
})), `${item.amountSpecial != 0 ? "" : "ได้รับค่าตอบแทนพิเศษ"}\n` +
}, `${item.isNext == true ? "" : "(ได้รับเงินเดือนสูงกว่าขั้นสูงฯ)"}`, // หมายเหตุ
}); })),
} },
});
}
/** /**
* API 2 * API 2