This commit is contained in:
AdisakKanthawilang 2025-06-04 15:32:01 +07:00
parent 0af89e7ecf
commit f1c134cb09

View file

@ -4926,8 +4926,8 @@ export class ReportController extends Controller {
* @summary 04- ( ..1) * @summary 04- ( ..1)
* *
*/ */
@Get("emp2-04/{rootId}/{salaryPeriodId}") @Get("emp2-04/{rootId}/{salaryPeriodId}/{type}")
async SalaryReportEmp2_4(@Path() rootId: string, @Path() salaryPeriodId: string) { async SalaryReportEmp2_4(@Path() rootId: string, @Path() salaryPeriodId: string, @Path() type: string = 'ALL') {
const salaryPeriod = await this.salaryPeriodRepository.findOne({ const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: { where: {
id: salaryPeriodId, id: salaryPeriodId,
@ -4938,16 +4938,32 @@ export class ReportController extends Controller {
if (!salaryPeriod) { if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
} }
let condition: any = {
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
};
condition.type = Not("NONE");
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 _salaryProfileEmp = await this.salaryProfileEmployeeRepository.find({ const _salaryProfileEmp = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"], relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: { where: condition,
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
type: Not("NONE"),
},
order: { order: {
rootOrder: "ASC", rootOrder: "ASC",
child1Order: "ASC", child1Order: "ASC",
@ -4958,7 +4974,6 @@ export class ReportController extends Controller {
posMasterNo: "ASC", posMasterNo: "ASC",
}, },
}); });
if (!_salaryProfileEmp) { if (!_salaryProfileEmp) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }