fix report 16 to 14

This commit is contained in:
AdisakKanthawilang 2024-04-09 15:15:23 +07:00
parent c149234bf9
commit 5879ccf93d

View file

@ -3025,7 +3025,7 @@ export class ReportController extends Controller {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullName: fullName,
position: profile.position,
posLevel: profile.posLevel,
posLevel: profile.posLevel ? Extension.ToThaiNumber(String(profile.posLevel.toLocaleString())): null,
};
});
@ -3275,90 +3275,83 @@ export class ReportController extends Controller {
},
});
}
/**
* API 14-
/**
* API 14-
*
* @summary 14-
* @summary 14-
*
*/
@Get("emp-14/{rootId}/{salaryPeriodId}")
async SalaryReportEmp1_14(@Path() rootId: string, @Path() salaryPeriodId: string) {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
id: salaryPeriodId,
},
});
if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
}
const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
type: In(["HAFT", "FULL", "FULLHAFT"]),
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
},
order: {
positionSalaryAmount: "ASC",
},
});
if (!_salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
}
const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
const formattedData = _salaryPeriod.map((profile, index) => {
const fullNameParts = [
profile.child4,
profile.child3,
profile.child2,
profile.child1,
profile.root,
`${profile.prefix}${profile.firstName} ${profile.lastName}`,
];
const fullName = fullNameParts
.filter((part) => part !== undefined && part !== null)
.join("/");
return {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullName: fullName,
position: profile.position,
posLevel: profile.posLevel
? `${profile.posTypeShort} ${Extension.ToThaiNumber(profile.posLevel.toLocaleString())}`
: null,
posNumber:
Extension.ToThaiNumber(profile.orgShortName) +
Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
positionSalaryAmount: profile.positionSalaryAmount
? Extension.ToThaiNumber(profile.positionSalaryAmount.toLocaleString())
: null,
score: null, //สรุปผลการประเมินฯ ระดับและคะแนน
remark:
`${profile.type === "FULL" ? "หนึ่งขั้น" : ""}\n` +
`${profile.type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : ""}\n` +
`${profile.amountSpecial > 0 ? "ได้รับค่าตอบแทนพิเศษ\n" : ""}` +
`${profile.isNext === true ? "(ได้รับเงินเดือนสูงกว่าขั้นสูงฯ)" : ""}`, // หมายเหตุ
};
});
return new HttpSuccess({
template: "emp1-14",
reportName: "emp1-14",
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
agency: agency,
data: formattedData,
},
});
}
@Get("emp-14/{rootId}/{salaryPeriodId}")
async SalaryReportEmp1_14(@Path() rootId: string, @Path() salaryPeriodId: string) {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
id: salaryPeriodId,
},
});
if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
}
const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
isNext: false,
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
},
order: {
positionSalaryAmount: "ASC",
},
});
if (!_salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
}
const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
const formattedData = _salaryPeriod.map((profile, index) => {
const fullNameParts = [
profile.child4,
profile.child3,
profile.child2,
profile.child1,
profile.root,
`${profile.prefix}${profile.firstName} ${profile.lastName}`,
];
const fullName = fullNameParts
.filter((part) => part !== undefined && part !== null)
.join("/");
return {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullName: fullName,
position: profile.position,
posLevel: profile.posLevel
? `${profile.posTypeShort} ${Extension.ToThaiNumber(profile.posLevel.toLocaleString())}`
: null,
posNumber:
Extension.ToThaiNumber(profile.orgShortName) +
Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
reason: null, // หมายเหตุ
};
});
return new HttpSuccess({
template: "emp1-14",
reportName: "emp1-14",
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
agency: agency,
data: formattedData,
},
});
}
/**
* API 15-()
*
@ -3445,82 +3438,7 @@ export class ReportController extends Controller {
},
});
}
/**
* API 16-
*
* @summary 16-
*
*/
@Get("emp-16/{rootId}/{salaryPeriodId}")
async SalaryReportEmp1_16(@Path() rootId: string, @Path() salaryPeriodId: string) {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
id: salaryPeriodId,
},
});
if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
}
const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
isNext: false,
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
},
order: {
positionSalaryAmount: "ASC",
},
});
if (!_salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
}
const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
const formattedData = _salaryPeriod.map((profile, index) => {
const fullNameParts = [
profile.child4,
profile.child3,
profile.child2,
profile.child1,
profile.root,
`${profile.prefix}${profile.firstName} ${profile.lastName}`,
];
const fullName = fullNameParts
.filter((part) => part !== undefined && part !== null)
.join("/");
return {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullName: fullName,
position: profile.position,
posLevel: profile.posLevel
? `${profile.posTypeShort} ${Extension.ToThaiNumber(profile.posLevel.toLocaleString())}`
: null,
posNumber:
Extension.ToThaiNumber(profile.orgShortName) +
Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
reason: null, // หมายเหตุ
};
});
return new HttpSuccess({
template: "emp1-16",
reportName: "emp1-16",
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
agency: agency,
data: formattedData,
},
});
}
/**
* API 17-
*