report 04

This commit is contained in:
Kittapath 2024-03-21 09:51:42 +07:00
parent 8d3fa8f7a7
commit 342f95302d

View file

@ -904,7 +904,7 @@ export class ReportController extends Controller {
* @param {string} rootId Guid, *Id Root
* @param {string} salaryPeriodId Guid, *Id Period
*/
@Get("gov1-03/{rootId}/{salaryPeriodId}")
@Get("gov-03/{rootId}/{salaryPeriodId}")
async SalaryReport3(@Path() rootId: string, @Path() salaryPeriodId: string) {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
@ -1066,7 +1066,7 @@ export class ReportController extends Controller {
});
}
/**
/**
* API 1
*
* @summary 1
@ -1074,85 +1074,93 @@ export class ReportController extends Controller {
* @param {string} rootId Guid, *Id Root
* @param {string} salaryPeriodId Guid, *Id Period
*/
@Get("gov1-04/{rootId}/{salaryPeriodId}")
async SalaryReport4(@Path() rootId: string, @Path() salaryPeriodId: string) {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
id: salaryPeriodId,
// period: "APR",
isActive: true,
},
});
if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
}
const salaryOrg = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodId,
rootId: rootId,
snapshot: "SNAP2",
},
order: {
group: "ASC",
},
relations: ["salaryProfiles"],
});
const salaryProfile = await this.salaryProfileRepository.find({
relations: ["salaryOrg"],
where: {
salaryOrgId: salaryOrg?.id,
},
order: {
salaryOrg: {
group: "ASC",
},
type: "DESC",
posMasterNo: "ASC",
},
});
return new HttpSuccess({
@Get("gov-04/{rootId}/{salaryPeriodId}")
async SalaryReport4(@Path() rootId: string, @Path() salaryPeriodId: string) {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
id: salaryPeriodId,
// period: "APR",
isActive: true,
},
});
if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
}
const salaryOrg = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodId,
rootId: rootId,
snapshot: "SNAP2",
},
order: {
group: "ASC",
},
relations: ["salaryProfiles"],
});
const salaryProfile = await this.salaryProfileRepository.find({
relations: ["salaryOrg"],
where: {
salaryOrgId: salaryOrg?.id,
},
order: {
salaryOrg: {
group: "ASC",
},
type: "DESC",
posMasterNo: "ASC",
},
});
return new HttpSuccess({
template: salaryPeriod.period === "APR" ? "gov1-04" : "gov2-04",
reportName: salaryPeriod.period === "APR" ? "gov1-04" : "gov2-04",
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod?.year))),
effectiveDate: salaryPeriod?.effectiveDate,
root: salaryProfile[0]?.root,
profile: salaryProfile.map((item, index) => ({
no: Extension.ToThaiNumber(String(index + 1)),
fullname: item.prefix + item.firstName + " " + item.lastName,
log_group: item.salaryOrg.group,
log_type: item.type,
log_isNext: item.isNext,
position:
item.position +
"/" +
(item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") +
(item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") +
(item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") +
(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)),
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod?.year))),
effectiveDate: salaryPeriod?.effectiveDate,
root: salaryProfile[0]?.root,
profile: salaryProfile.map((item, index) => ({
no: Extension.ToThaiNumber(String(index + 1)),
fullname: item.prefix + item.firstName + " " + item.lastName,
log_group: item.salaryOrg.group,
log_type: item.type,
log_isNext: item.isNext,
position:
item.position +
"/" +
(item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") +
(item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") +
(item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") +
(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 || item.amount == 0
? ""
: Extension.ToThaiNumber(String(item.amount)),
amountSpecial:
(item.positionSalaryAmount == undefined || item.positionSalaryAmount == null ? "" : Extension.ToThaiNumber(String(item.positionSalaryAmount))) +
(item.amountSpecial == undefined || item.amountSpecial == null ? "" : `(${Extension.ToThaiNumber(String(item.amountSpecial))})`),
score: null, //สรุปผลการประเมินฯ ระดับและคะแนน
remark:
`${item.type === "FULL" ? "หนึ่งขั้น" : ""}\n` +
`${(item.type === "FULL" && item.amountSpecial == 0 && item.amountSpecial == null && item.amountSpecial == undefined) ? "ได้รับค่าตอบแทนพิเศษ\n" : ""}` +
`${(item.type === "FULL" && item.isNext === true) ? "(ได้รับเงินเดือนสูงกว่าขั้นสูงฯ)" : ""}`, // หมายเหตุ
})),
},
});
}
(item.positionSalaryAmount == undefined ||
item.positionSalaryAmount == null ||
item.positionSalaryAmount == 0
? ""
: Extension.ToThaiNumber(String(item.positionSalaryAmount))) +
(item.amountSpecial == undefined ||
item.amountSpecial == null ||
item.amountSpecial == 0
? ""
: `(${Extension.ToThaiNumber(String(item.amountSpecial))})`),
score: null, //สรุปผลการประเมินฯ ระดับและคะแนน
remark:
`${item.type === "FULL" ? "หนึ่งขั้น" : ""}\n` +
`${item.amountSpecial > 0 ? "ได้รับค่าตอบแทนพิเศษ\n" : ""}` +
`${item.isNext === true ? "(ได้รับเงินเดือนสูงกว่าขั้นสูงฯ)" : ""}`, // หมายเหตุ
})),
},
});
}
/**
* API 2
@ -1162,7 +1170,7 @@ export class ReportController extends Controller {
* @param {string} rootId Guid, *Id Root
* @param {string} salaryPeriodId Guid, *Id Period
*/
@Get("gov1-05/{rootId}/{salaryPeriodId}")
@Get("gov-05/{rootId}/{salaryPeriodId}")
async SalaryReport5(@Path() rootId: string, @Path() salaryPeriodId: string) {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
@ -1247,7 +1255,7 @@ export class ReportController extends Controller {
// * @param {string} rootId Guid, *Id Root
// * @param {string} salaryPeriodId Guid, *Id Period
// */
// @Get("gov1-06/{rootId}/{salaryPeriodId}")
// @Get("gov-06/{rootId}/{salaryPeriodId}")
// async SalaryReport6(){
// }
@ -1260,7 +1268,7 @@ export class ReportController extends Controller {
* @param {string} rootId Guid, *Id Root
* @param {string} salaryPeriodId Guid, *Id Period
*/
@Get("gov1-07/{rootId}/{salaryPeriodId}")
@Get("gov-07/{rootId}/{salaryPeriodId}")
async SalaryReport7(@Path() rootId: string, @Path() salaryPeriodId: string) {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
@ -1344,7 +1352,7 @@ export class ReportController extends Controller {
* @param {string} rootId Guid, *Id Root
* @param {string} salaryPeriodId Guid, *Id Period
*/
@Get("gov1-08/{rootId}/{salaryPeriodId}")
@Get("gov-08/{rootId}/{salaryPeriodId}")
async SalaryReport8(@Path() rootId: string, @Path() salaryPeriodId: string) {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {