fix report

This commit is contained in:
AdisakKanthawilang 2025-01-29 15:21:47 +07:00
parent 896c13709f
commit 5f619ada3c

View file

@ -1078,7 +1078,7 @@ export class ReportController extends Controller {
group: convertGroup,
},
});
if (salaryPeriod.period === "APR") {
let salaryProfileGroup1: any;
let salaryProfileGroup2: any;
@ -1090,6 +1090,7 @@ export class ReportController extends Controller {
},
});
}
//รอบปีก่อนๆ
const salaryPeriodIncrease1_APR = await this.salaryPeriodRepository.findOne({
where: {
@ -1105,23 +1106,30 @@ export class ReportController extends Controller {
isActive: true,
},
});
const salaryOrg1_APR = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease1_APR?.id,
rootId: rootId,
snapshot: "SNAP1",
group: convertGroup,
},
});
const salaryOrg1_OCT = await this.salaryOrgRepository.findOne({
let salaryOrg1_APR = null;
if(salaryPeriodIncrease1_APR) {
salaryOrg1_APR = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease1_APR?.id,
// rootId: rootId,
snapshot: "SNAP1",
group: convertGroup,
},
});
}
let salaryOrg1_OCT = null;
if(salaryPeriodIncrease1_OCT) {
salaryOrg1_OCT = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease1_OCT?.id,
rootId: rootId,
// rootId: rootId,
snapshot: "SNAP1",
group: convertGroup,
},
});
}
const salaryProfile1 = await this.salaryProfileRepository.find({
where: {
@ -1129,7 +1137,6 @@ export class ReportController extends Controller {
// type: "FULL",
},
});
//รอบปีก่อนหน้า
const salaryPeriodIncrease2_APR = await this.salaryPeriodRepository.findOne({
where: {
@ -1145,31 +1152,40 @@ export class ReportController extends Controller {
isActive: true,
},
});
const salaryOrg2_APR = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease2_APR?.id,
rootId: rootId,
snapshot: "SNAP1",
group: convertGroup,
},
});
const salaryOrg2_OCT = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease2_OCT?.id,
rootId: rootId,
snapshot: "SNAP1",
group: convertGroup,
},
});
let salaryOrg2_APR = null;
if(salaryPeriodIncrease2_APR){
salaryOrg2_APR = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease2_APR?.id,
// rootId: rootId,
snapshot: "SNAP1",
group: convertGroup,
},
});
}
let salaryOrg2_OCT = null;
if(salaryPeriodIncrease2_OCT){
salaryOrg2_OCT = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease2_OCT?.id,
// rootId: rootId,
snapshot: "SNAP1",
group: convertGroup,
},
});
}
// console.log("d2",salaryOrg2_APR);
// console.log("d3",salaryOrg2_OCT);
const salaryProfile2 = await this.salaryProfileRepository.find({
where: {
salaryOrgId: In([salaryOrg2_APR?.id, salaryOrg2_OCT?.id]),
// type: "FULL",
},
});
// console.log("d4",salaryProfile2);
const year = Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year)));
const yearIncrease1 = Extension.ToThaiNumber(
String(Extension.ToThaiYear(salaryPeriod.year - 2)),
@ -1364,23 +1380,29 @@ export class ReportController extends Controller {
isActive: true,
},
});
const salaryOrg1_APR = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease1_APR?.id,
rootId: rootId,
snapshot: "SNAP1",
group: convertGroup,
},
});
const salaryOrg1_OCT = await this.salaryOrgRepository.findOne({
let salaryOrg1_APR = null;
if(salaryPeriodIncrease1_APR) {
salaryOrg1_APR = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease1_APR?.id,
// rootId: rootId,
snapshot: "SNAP1",
group: convertGroup,
},
});
}
let salaryOrg1_OCT = null;
if(salaryPeriodIncrease1_OCT) {
salaryOrg1_OCT = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease1_OCT?.id,
rootId: rootId,
// rootId: rootId,
snapshot: "SNAP1",
group: convertGroup,
},
});
}
const salaryProfile1 = await this.salaryProfileRepository.find({
where: {
@ -1404,24 +1426,30 @@ export class ReportController extends Controller {
isActive: true,
},
});
const salaryOrg2_APR = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease2_APR?.id,
rootId: rootId,
snapshot: "SNAP1",
group: convertGroup,
},
});
const salaryOrg2_OCT = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease2_OCT?.id,
rootId: rootId,
snapshot: "SNAP1",
group: convertGroup,
},
});
let salaryOrg2_APR = null;
if(salaryPeriodIncrease2_APR){
salaryOrg2_APR = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease2_APR?.id,
// rootId: rootId,
snapshot: "SNAP1",
group: convertGroup,
},
});
}
let salaryOrg2_OCT = null;
if(salaryPeriodIncrease2_OCT){
salaryOrg2_OCT = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease2_OCT?.id,
// rootId: rootId,
snapshot: "SNAP1",
group: convertGroup,
},
});
}
const salaryProfile2 = await this.salaryProfileRepository.find({
where: {
salaryOrgId: In([salaryOrg2_APR?.id, salaryOrg2_OCT?.id]),
@ -2130,7 +2158,7 @@ export class ReportController extends Controller {
: Extension.ToThaiNumber(String(item.positionSalaryAmount.toLocaleString())) +
(item.amountSpecial > 0
? `(${Extension.ToThaiNumber(String(item.positionSalaryAmount))})`
: "-"),
: ""),
remark: [
item.type === "FULL" ? "หนึ่งขั้น" : "",
item.type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : "",
@ -3271,7 +3299,7 @@ export class ReportController extends Controller {
affiliation: affiliation,
position: profile.position ?? "-",
posLevel: profile.posLevel
? Extension.ToThaiNumber(String(profile.posLevel.toLocaleString()))
? `${profile.posTypeShort} ${Extension.ToThaiNumber(profile.posLevel.toLocaleString())}`
: "-",
};
});
@ -4559,17 +4587,18 @@ export class ReportController extends Controller {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullName: fullName,
affiliation: affiliation,
position: //pos\n
profile.position +
"\n" +
(profile.child4 == undefined && profile.child4 == null ? "" : profile.child4 + " ") +
(profile.child3 == undefined && profile.child3 == null ? "" : profile.child3 + " ") +
(profile.child2 == undefined && profile.child2 == null ? "" : profile.child2 + " ") +
(profile.child1 == undefined && profile.child1 == null ? "" : profile.child1 + " ") +
(profile.root == undefined && profile.root == null ? "" : profile.root),
posLevel: profile.posLevel
? `${profile.posTypeShort} ${Extension.ToThaiNumber(profile.posLevel.toLocaleString())}`
: "-",
position: profile.position??"-",
//pos\n
// profile.position +
// "\n" +
// (profile.child4 == undefined && profile.child4 == null ? "" : profile.child4 + " ") +
// (profile.child3 == undefined && profile.child3 == null ? "" : profile.child3 + " ") +
// (profile.child2 == undefined && profile.child2 == null ? "" : profile.child2 + " ") +
// (profile.child1 == undefined && profile.child1 == null ? "" : profile.child1 + " ") +
// (profile.root == undefined && profile.root == null ? "" : profile.root),
// posLevel: profile.posLevel
// ? `${profile.posTypeShort} ${Extension.ToThaiNumber(profile.posLevel.toLocaleString())}`
// : "-",
posNumber:
profile.orgShortName || profile.posMasterNo
? Extension.ToThaiNumber(profile.orgShortName) +
@ -4753,7 +4782,7 @@ export class ReportController extends Controller {
affiliation: affiliation,
position: profile.position ?? "-",
posLevel: profile.posLevel
? Extension.ToThaiNumber(profile.posLevel.toLocaleString())
? `${profile.posTypeShort} ${Extension.ToThaiNumber(profile.posLevel.toLocaleString())}`
: "-",
posNumber:
profile.orgShortName || profile.posMasterNo
@ -4844,7 +4873,7 @@ export class ReportController extends Controller {
affiliation: affiliation,
position: profile.position ?? "-",
posLevel: profile.posLevel
? Extension.ToThaiNumber(profile.posLevel.toLocaleString())
? `${profile.posTypeShort} ${Extension.ToThaiNumber(profile.posLevel.toLocaleString())}`
: "-",
posNumber:
profile.orgShortName || profile.posMasterNo
@ -5207,14 +5236,15 @@ export class ReportController extends Controller {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullName: fullName,
affiliation: affiliation,
position: //pos\n
profile.position +
"\n" +
(profile.child4 == undefined && profile.child4 == null ? "" : profile.child4 + " ") +
(profile.child3 == undefined && profile.child3 == null ? "" : profile.child3 + " ") +
(profile.child2 == undefined && profile.child2 == null ? "" : profile.child2 + " ") +
(profile.child1 == undefined && profile.child1 == null ? "" : profile.child1 + " ") +
(profile.root == undefined && profile.root == null ? "" : profile.root),
position: profile.position??"-",
//pos\n
// profile.position +
// "\n" +
// (profile.child4 == undefined && profile.child4 == null ? "" : profile.child4 + " ") +
// (profile.child3 == undefined && profile.child3 == null ? "" : profile.child3 + " ") +
// (profile.child2 == undefined && profile.child2 == null ? "" : profile.child2 + " ") +
// (profile.child1 == undefined && profile.child1 == null ? "" : profile.child1 + " ") +
// (profile.root == undefined && profile.root == null ? "" : profile.root),
posLevel: profile.posLevel,
posNumber:
Extension.ToThaiNumber(profile.orgShortName) +
@ -5496,14 +5526,15 @@ export class ReportController extends Controller {
no: Extension.ToThaiNumber((index + 1).toLocaleString()),
fullName: fullName,
affiliation: affiliation,
position: //pos\n
profile.position +
"\n" +
(profile.child4 == undefined && profile.child4 == null ? "" : profile.child4 + " ") +
(profile.child3 == undefined && profile.child3 == null ? "" : profile.child3 + " ") +
(profile.child2 == undefined && profile.child2 == null ? "" : profile.child2 + " ") +
(profile.child1 == undefined && profile.child1 == null ? "" : profile.child1 + " ") +
(profile.root == undefined && profile.root == null ? "" : profile.root),
position: profile.position??"-",
//pos\n
// profile.position +
// "\n" +
// (profile.child4 == undefined && profile.child4 == null ? "" : profile.child4 + " ") +
// (profile.child3 == undefined && profile.child3 == null ? "" : profile.child3 + " ") +
// (profile.child2 == undefined && profile.child2 == null ? "" : profile.child2 + " ") +
// (profile.child1 == undefined && profile.child1 == null ? "" : profile.child1 + " ") +
// (profile.root == undefined && profile.root == null ? "" : profile.root),
posLevel: profile.posLevel,
posNumber:
Extension.ToThaiNumber(profile.orgShortName) +
@ -6318,7 +6349,7 @@ export class ReportController extends Controller {
affiliation: affiliation ?? "-",
position: profile.position ?? "-",
posLevel: profile.posLevel
? Extension.ToThaiNumber(profile.posLevel.toLocaleString())
? `${profile.posTypeShort} ${Extension.ToThaiNumber(profile.posLevel.toLocaleString())}`
: "-",
posNumber:
Extension.ToThaiNumber(profile.orgShortName) +