This commit is contained in:
Bright 2024-03-25 15:57:38 +07:00
parent 9d6992e4e1
commit e05e6c625e

View file

@ -2487,33 +2487,73 @@ export class ReportController extends Controller {
const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: {
id: salaryPeriodId,
period: "APR",
isActive: true
},
});
if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
}
const _salaryPeriod = await this.salaryProfileRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
const salaryPeriodAPR = await this.salaryPeriodRepository.findOne({
where: {
id: salaryPeriodId,
year: salaryPeriod.year - 1,
period: "APR",
isActive: true
},
});
const salaryPeriodOCT = await this.salaryPeriodRepository.findOne({
where: {
id: salaryPeriodId,
year: salaryPeriod.year - 1,
period: "OCT",
isActive: true
},
});
const _salaryProfileEmp = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg",],
where: {
salaryOrg: {
snapshot: "SNAP1",
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: salaryPeriodId,
},
type: "NONE"
},
order: {
orgShortName: "ASC",
posMasterNo: "ASC",
},
});
if (!_salaryPeriod) {
if (!_salaryProfileEmp) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
}
const _salaryProfileEmpAPR = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg",],
where: {
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: salaryPeriodAPR?.id,
}
}
});
const _salaryProfileEmpOCT = await this.salaryProfileEmployeeRepository.find({
relations: ["salaryOrg",],
where: {
salaryOrg: {
snapshot: "SNAP2",
rootId: rootId,
salaryPeriodId: salaryPeriodOCT?.id,
}
}
});
const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
const formattedData = _salaryPeriod.map((profile, index) => {
const agency = _salaryProfileEmp[0] == null ? "" : _salaryProfileEmp[0].root;
const formattedData = _salaryProfileEmp.map((profile, index) => {
const fullNameParts = [
profile.child4,
profile.child3,
@ -2530,11 +2570,31 @@ export class ReportController extends Controller {
return {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullName: fullName,
posLevel: profile.posLevel,
position: profile.position,
posNumber:
profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()),
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null,
reason: null,
amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "",
type1: _salaryProfileEmpAPR.length > 0
? (() => {
const type = _salaryProfileEmpAPR
.filter((profileAPR) => profileAPR.citizenId === profile.citizenId)
.map((profile) => profile.type);
const Type = type[0];
return Type === "HALF" ? "0.5 ขั้น" : Type === "FULL" ? "1 ขั้น" : "ไม่ได้เลื่อนขั้นฯ";
})()
: null, //เมษา ปีก่อนหน้า
type2: _salaryProfileEmpOCT.length > 0
? (() => {
const type = _salaryProfileEmpOCT
.filter((profileOCT) => profileOCT.citizenId === profile.citizenId)
.map((profile) => profile.type);
const Type = type[0];
return Type === "HALF" ? "0.5 ขั้น" : Type === "FULL" ? "1 ขั้น" : "ไม่ได้เลื่อนขั้นฯ";
})()
: null, //ตุลา ปีก่อนหน้า
type: profile.type === "HALF" ? "0.5 ขั้น" : profile.type === "FULL" ? "1 ขั้น" : "ไม่ได้เลื่อนขั้นฯ",
score: null, //ผลการประเมิน
remark: null, //หมายเหตุ
};
});
@ -2543,11 +2603,14 @@ export class ReportController extends Controller {
reportName: "emp1-09",
data: {
year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))),
yearBeforeSlice: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year-1)).slice(-2)),
yearSlice: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year)).slice(-2)),
agency: agency,
data: formattedData,
},
});
}
// /**
// * API 10-รายชื่อลูกจ้างประจำผู้มีผลการประเมินดีเด่น
// *