fix report 25
This commit is contained in:
parent
e4710ed004
commit
5cd2a3ff3d
1 changed files with 27 additions and 26 deletions
|
|
@ -5178,7 +5178,7 @@ export class ReportController extends Controller {
|
||||||
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
||||||
where: {
|
where: {
|
||||||
isRetired: true,
|
isRetired: true,
|
||||||
type: "NONE",
|
isNext: false,
|
||||||
salaryOrg: {
|
salaryOrg: {
|
||||||
snapshot: "SNAP2",
|
snapshot: "SNAP2",
|
||||||
rootId: rootId,
|
rootId: rootId,
|
||||||
|
|
@ -5782,29 +5782,29 @@ export class ReportController extends Controller {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let perviousYearAPR:any;
|
||||||
|
let perviousYearOCT:any;
|
||||||
|
let salaryProfilePerviousAPR:any;
|
||||||
|
let salaryProfilePerviousOCT:any;
|
||||||
|
|
||||||
//งวดปีก่อนหน้า
|
//งวดปีก่อนหน้า
|
||||||
const perviousYearAPR = await this.salaryPeriodRepository.findOne({
|
perviousYearAPR = await this.salaryPeriodRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
period: "APR",
|
period: "APR",
|
||||||
year: salaryPeriodOCT.year - 1,
|
year: salaryPeriodOCT.year - 1,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!perviousYearAPR) {
|
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือนก่อนหน้า");
|
|
||||||
}
|
|
||||||
|
|
||||||
const perviousYearOCT = await this.salaryPeriodRepository.findOne({
|
|
||||||
|
perviousYearOCT = await this.salaryPeriodRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
period: "OCT",
|
period: "OCT",
|
||||||
year: salaryPeriodOCT.year - 1,
|
year: salaryPeriodOCT.year - 1,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!perviousYearOCT) {
|
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือนก่อนหน้า");
|
|
||||||
}
|
|
||||||
|
|
||||||
//ปีก่อนหน้า
|
//ปีก่อนหน้า
|
||||||
const salaryProfilePerviousAPR = await this.salaryProfileEmployeeRepository.find({
|
salaryProfilePerviousAPR = await this.salaryProfileEmployeeRepository.find({
|
||||||
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
||||||
where: {
|
where: {
|
||||||
salaryOrg: {
|
salaryOrg: {
|
||||||
|
|
@ -5818,11 +5818,7 @@ export class ReportController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!salaryProfilePerviousAPR) {
|
salaryProfilePerviousOCT = await this.salaryProfileEmployeeRepository.find({
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
||||||
}
|
|
||||||
|
|
||||||
const salaryProfilePerviousOCT = await this.salaryProfileEmployeeRepository.find({
|
|
||||||
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
||||||
where: {
|
where: {
|
||||||
salaryOrg: {
|
salaryOrg: {
|
||||||
|
|
@ -5836,10 +5832,6 @@ export class ReportController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!salaryProfilePerviousOCT) {
|
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
||||||
}
|
|
||||||
|
|
||||||
//ปีปัจุบัน
|
//ปีปัจุบัน
|
||||||
const salaryProfileCurrentAPR = await this.salaryProfileEmployeeRepository.find({
|
const salaryProfileCurrentAPR = await this.salaryProfileEmployeeRepository.find({
|
||||||
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
||||||
|
|
@ -5881,12 +5873,21 @@ export class ReportController extends Controller {
|
||||||
|
|
||||||
const formattedData = salaryProfileCurrentOCT.map((profile, index) => {
|
const formattedData = salaryProfileCurrentOCT.map((profile, index) => {
|
||||||
//งวดปีก่อนหน้า
|
//งวดปีก่อนหน้า
|
||||||
const matchedAPRProfileOld = salaryProfilePerviousAPR.find(
|
let matchedAPRProfileOld: SalaryProfile | null = null;
|
||||||
(aprProfile_old) => aprProfile_old.citizenId === profile.citizenId,
|
let matchedOCTProfileOld: SalaryProfile | null = null;
|
||||||
);
|
|
||||||
const matchedOCTProfileOld = salaryProfilePerviousOCT.find(
|
if (salaryProfilePerviousAPR && salaryProfilePerviousAPR.length > 0) {
|
||||||
(octProfile_old) => octProfile_old.citizenId === profile.citizenId,
|
matchedAPRProfileOld = salaryProfilePerviousAPR.find(
|
||||||
);
|
(aprProfile_old: SalaryProfile) => aprProfile_old.citizenId === profile.citizenId,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (salaryProfilePerviousOCT && salaryProfilePerviousOCT.length > 0) {
|
||||||
|
matchedOCTProfileOld = salaryProfilePerviousOCT.find(
|
||||||
|
(octProfile_old: SalaryProfile) => octProfile_old.citizenId === profile.citizenId,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const amountUseAPR_Old = matchedAPRProfileOld ? matchedAPRProfileOld.amountUse : 0;
|
const amountUseAPR_Old = matchedAPRProfileOld ? matchedAPRProfileOld.amountUse : 0;
|
||||||
const amountUseOCT_Old = matchedOCTProfileOld ? matchedOCTProfileOld.amountUse : 0;
|
const amountUseOCT_Old = matchedOCTProfileOld ? matchedOCTProfileOld.amountUse : 0;
|
||||||
const amountUseOld = amountUseAPR_Old + amountUseOCT_Old;
|
const amountUseOld = amountUseAPR_Old + amountUseOCT_Old;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue