This commit is contained in:
AdisakKanthawilang 2025-06-25 17:31:26 +07:00
parent 59eec3d7b9
commit 2fc4fd3121

View file

@ -1698,11 +1698,12 @@ export class ReportController extends Controller {
* @param {string} rootId Guid, *Id Root
* @param {string} salaryPeriodId Guid, *Id Period
*/
@Get("gov-04/{rootId}/{salaryPeriodId}/{group}")
@Get("gov-04/{rootId}/{salaryPeriodId}/{group}/{type}")
async SalaryReport4(
@Path() rootId: string,
@Path() salaryPeriodId: string,
@Path() group: string,
@Path() type: string = 'ALL'
) {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
@ -1714,18 +1715,34 @@ export class ReportController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
}
const convertGroup = group.toUpperCase();
let condition: any = {
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
group: convertGroup,
salaryPeriodId: salaryPeriodId,
},
};
// condition.type = In(["HAFT", "FULL", "FULLHAFT"]);
condition.isRetired = salaryPeriod.period === "APR" ? In([true, false]) : false; //กรองเฉพาะคนที่ไม่เกษียณเฉพาะรอบตุลา
if(salaryPeriod.period == "APR"){
if(type == "HAFT"){
condition.type = "HAFT";
}else if(type == "FULL"){
condition.type = "FULL";
}
}else{
if(type == "HAFT"){
condition.type = "HAFT";
}else if(type == "FULL"){
condition.type = "FULL";
}else if(type == "FULLHAFT"){
condition.type = "FULLHAFT";
}
}
const _salaryPeriod = await this.salaryProfileRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: {
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
group: convertGroup,
salaryPeriodId: salaryPeriodId,
},
type: In(["HAFT", "FULL", "FULLHAFT"]),
isRetired: salaryPeriod.period === "APR" ? In([true, false]) : false, //กรองเฉพาะคนที่ไม่เกษียณเฉพาะรอบตุลา
},
where: condition,
order: {
salaryOrg: {
group: "ASC",