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",
"posMasterNo",
"amount",
"amountSpecial",
],
order: {
posMasterNo: "ASC",
},
});
return new HttpSuccess({ return new HttpSuccess({
template: "gov1-04", template: salaryPeriod.period === "APR" ? "gov1-04" : "gov2-04",
reportName: "gov1-04", reportName: salaryPeriod.period === "APR" ? "gov1-04" : "gov2-04",
data: { data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod?.year))), year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod?.year))),
effectiveDate: salaryPeriod?.effectiveDate, effectiveDate: salaryPeriod?.effectiveDate,
root: salaryProfile[0]?.root, root: salaryProfile[0]?.root,
profile: salaryProfile.map((item, index) => ({ profile: salaryProfile.map((item, index) => ({
no: Extension.ToThaiNumber(String(index + 1)), no: Extension.ToThaiNumber(String(index + 1)),
fullname: item.prefix + item.firstName + " " + item.lastName, fullname: item.prefix + item.firstName + " " + item.lastName,
position: log_group: item.salaryOrg.group,
item.position + log_type: item.type,
"/" + position:
(item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") + item.position +
(item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") + "/" +
(item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") + (item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") +
(item.child1 == undefined && item.child1 == null ? "" : item.child1 + "/") + (item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") +
(item.root == undefined && item.root == null ? "" : item.root), (item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") +
posLevel: item.posLevel, (item.child1 == undefined && item.child1 == null ? "" : item.child1 + "/") +
orgShortName: item.orgShortName + Extension.ToThaiNumber(String(item.posMasterNo)), (item.root == undefined && item.root == null ? "" : item.root),
amount: posLevel: item.posLevel,
item.amount == undefined || item.amount == null orgShortName: item.orgShortName + Extension.ToThaiNumber(String(item.posMasterNo)),
? "" amount:
: Extension.ToThaiNumber(String(item.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