gov2-03
This commit is contained in:
parent
af8ee9f6b6
commit
d3dd7012a1
1 changed files with 295 additions and 152 deletions
|
|
@ -912,7 +912,6 @@ export class ReportController extends Controller {
|
||||||
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
id: salaryPeriodId,
|
id: salaryPeriodId,
|
||||||
period: "APR",
|
|
||||||
isActive: true,
|
isActive: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -932,160 +931,304 @@ export class ReportController extends Controller {
|
||||||
},
|
},
|
||||||
relations: ["salaryProfiles"],
|
relations: ["salaryProfiles"],
|
||||||
});
|
});
|
||||||
|
if(salaryPeriod.period === 'APR'){
|
||||||
|
const salaryProfile = await this.salaryProfileRepository.find({
|
||||||
|
where: {
|
||||||
|
salaryOrgId: salaryOrg?.id,
|
||||||
|
type: "FULL", //หนึ่งขั้น
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//รอบปีก่อนๆ
|
||||||
|
const salaryPeriodIncrease1_APR = await this.salaryPeriodRepository.findOne({
|
||||||
|
where: {
|
||||||
|
period: "APR",
|
||||||
|
year: salaryPeriod.year - 2,
|
||||||
|
isActive: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const salaryPeriodIncrease1_OCT = await this.salaryPeriodRepository.findOne({
|
||||||
|
where: {
|
||||||
|
period: "OCT",
|
||||||
|
year: salaryPeriod.year - 2,
|
||||||
|
isActive: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const salaryOrg1_APR = await this.salaryOrgRepository.findOne({
|
||||||
|
where: {
|
||||||
|
salaryPeriodId: salaryPeriodIncrease1_APR?.id,
|
||||||
|
rootId: rootId,
|
||||||
|
snapshot: "SNAP2",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const salaryOrg1_OCT = await this.salaryOrgRepository.findOne({
|
||||||
|
where: {
|
||||||
|
salaryPeriodId: salaryPeriodIncrease1_OCT?.id,
|
||||||
|
rootId: rootId,
|
||||||
|
snapshot: "SNAP2",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const salaryProfile1 = await this.salaryProfileRepository.find({
|
||||||
|
where: {
|
||||||
|
salaryOrgId: In([salaryOrg1_APR?.id, salaryOrg1_OCT?.id]),
|
||||||
|
type: "FULL",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
//รอบปีก่อนหน้า
|
||||||
|
const salaryPeriodIncrease2_APR = await this.salaryPeriodRepository.findOne({
|
||||||
|
where: {
|
||||||
|
period: "APR",
|
||||||
|
year: salaryPeriod.year - 1,
|
||||||
|
isActive: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const salaryPeriodIncrease2_OCT = await this.salaryPeriodRepository.findOne({
|
||||||
|
where: {
|
||||||
|
period: "OCT",
|
||||||
|
year: salaryPeriod.year - 1,
|
||||||
|
isActive: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const salaryOrg2_APR = await this.salaryOrgRepository.findOne({
|
||||||
|
where: {
|
||||||
|
salaryPeriodId: salaryPeriodIncrease2_APR?.id,
|
||||||
|
rootId: rootId,
|
||||||
|
snapshot: "SNAP2",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const salaryOrg2_OCT = await this.salaryOrgRepository.findOne({
|
||||||
|
where: {
|
||||||
|
salaryPeriodId: salaryPeriodIncrease2_OCT?.id,
|
||||||
|
rootId: rootId,
|
||||||
|
snapshot: "SNAP2",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const salaryProfile2 = await this.salaryProfileRepository.find({
|
||||||
|
where: {
|
||||||
|
salaryOrgId: In([salaryOrg2_APR?.id, salaryOrg2_OCT?.id]),
|
||||||
|
type: "FULL",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const year = Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year)));
|
||||||
|
const yearIncrease1 = Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year-2)));
|
||||||
|
const yearIncrease2 = Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year-1)));
|
||||||
|
const fifteenPercent = salaryOrg?.fifteenPercent == undefined || salaryOrg?.fifteenPercent == null ?
|
||||||
|
"๐" : Extension.ToThaiNumber(String(salaryOrg?.fifteenPercent));
|
||||||
|
const fifteenPoint = salaryOrg?.fifteenPoint == undefined || salaryOrg?.fifteenPoint == null ?
|
||||||
|
".๐๐" : "." + Extension.ToThaiNumber(String(salaryOrg?.fifteenPoint));
|
||||||
|
|
||||||
|
return new HttpSuccess({
|
||||||
|
template: "gov1-03",
|
||||||
|
reportName: "gov1-03",
|
||||||
|
data: {
|
||||||
|
year: year,
|
||||||
|
yearIncrease1: yearIncrease1,
|
||||||
|
yearIncrease2: yearIncrease2,
|
||||||
|
yearIncreaseSlice: yearIncrease2.slice(-2),
|
||||||
|
yearSlice: year.slice(-2),
|
||||||
|
point: fifteenPercent + fifteenPoint,
|
||||||
|
root: salaryProfile[0]?.root,
|
||||||
|
profile: salaryProfile.map((item, index) => ({
|
||||||
|
no: Extension.ToThaiNumber(String(index + 1)),
|
||||||
|
fullname:
|
||||||
|
(item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") +
|
||||||
|
(item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") +
|
||||||
|
(item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") +
|
||||||
|
(item.child1 == undefined && item.child1 == null ? "" : item.child1 + "/") +
|
||||||
|
(item.root == undefined && item.root == null ? "" : item.root) +
|
||||||
|
"/" +
|
||||||
|
item.prefix +
|
||||||
|
item.firstName +
|
||||||
|
" " +
|
||||||
|
item.lastName, // สังกัด/ชื่อ-นามสกุล
|
||||||
|
posLevel: item.posLevel,
|
||||||
|
posMasterNo: item.orgShortName + Extension.ToThaiNumber(String(item.posMasterNo)),
|
||||||
|
amount:
|
||||||
|
item.amount == undefined || item.amount == null
|
||||||
|
? "๐"
|
||||||
|
: Extension.ToThaiNumber(String(item.amount.toLocaleString())),
|
||||||
|
salaryIncrease1:
|
||||||
|
salaryProfile1.length > 0
|
||||||
|
? salaryProfile1
|
||||||
|
.filter((profile) => profile.citizenId === item.citizenId)
|
||||||
|
.map((profile) => profile.amount)
|
||||||
|
: "๐", //การเลื่อนเงินเดือนปีก่อนๆหน้า
|
||||||
|
salaryIncrease2:
|
||||||
|
salaryProfile2.length > 0
|
||||||
|
? salaryProfile2
|
||||||
|
.filter((profile) => profile.citizenId === item.citizenId)
|
||||||
|
.map((profile) => profile.amount)
|
||||||
|
: "๐", //การเลื่อนเงินเดือนปีก่อนหน้า
|
||||||
|
score: null, //ผลการประเมินฯ
|
||||||
|
remark: null, //หมายเหตุ
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if(salaryPeriod.period === 'OCT'){
|
||||||
|
//find period APR
|
||||||
|
const salaryPeriod_APR = await this.salaryPeriodRepository.findOne({
|
||||||
|
where: {
|
||||||
|
period: "APR",
|
||||||
|
year: salaryPeriod?.year,
|
||||||
|
isActive: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const salaryOrg_APR = await this.salaryOrgRepository.findOne({
|
||||||
|
where: {
|
||||||
|
salaryPeriodId: salaryPeriod_APR?.id,
|
||||||
|
rootId: rootId,
|
||||||
|
snapshot: "SNAP2",
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const salaryProfile_APR = await this.salaryProfileRepository.find({
|
||||||
|
where: {
|
||||||
|
salaryOrgId: salaryOrg_APR?.id,
|
||||||
|
type: In(["HAFT","FULL"]),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//end period APR
|
||||||
|
|
||||||
const salaryProfile = await this.salaryProfileRepository.find({
|
const salaryProfile = await this.salaryProfileRepository.find({
|
||||||
where: {
|
where: {
|
||||||
salaryOrgId: salaryOrg?.id,
|
salaryOrgId: salaryOrg?.id,
|
||||||
type: "FULL", //หนึ่งขั้น
|
type: In(["FULLHAFT","FULL"]),
|
||||||
},
|
}
|
||||||
select: [
|
});
|
||||||
"id",
|
|
||||||
"prefix",
|
//รอบปีก่อนๆ
|
||||||
"firstName",
|
const salaryPeriodIncrease1_APR = await this.salaryPeriodRepository.findOne({
|
||||||
"lastName",
|
where: {
|
||||||
"root",
|
period: "APR",
|
||||||
"position",
|
year: salaryPeriod.year - 2,
|
||||||
"posType",
|
isActive: true,
|
||||||
"posLevel",
|
},
|
||||||
"orgShortName",
|
});
|
||||||
"posMasterNo",
|
const salaryPeriodIncrease1_OCT = await this.salaryPeriodRepository.findOne({
|
||||||
"amount",
|
where: {
|
||||||
"amountSpecial",
|
period: "OCT",
|
||||||
],
|
year: salaryPeriod.year - 2,
|
||||||
});
|
isActive: true,
|
||||||
|
},
|
||||||
//รอบปีก่อนๆ
|
});
|
||||||
const salaryPeriodIncrease1_APR = await this.salaryPeriodRepository.findOne({
|
const salaryOrg1_APR = await this.salaryOrgRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
period: "APR",
|
salaryPeriodId: salaryPeriodIncrease1_APR?.id,
|
||||||
year: salaryPeriod.year - 2,
|
rootId: rootId,
|
||||||
isActive: true,
|
snapshot: "SNAP2",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const salaryPeriodIncrease1_OCT = await this.salaryPeriodRepository.findOne({
|
const salaryOrg1_OCT = await this.salaryOrgRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
period: "OCT",
|
salaryPeriodId: salaryPeriodIncrease1_OCT?.id,
|
||||||
year: salaryPeriod.year - 2,
|
rootId: rootId,
|
||||||
isActive: true,
|
snapshot: "SNAP2",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const salaryOrg1_APR = await this.salaryOrgRepository.findOne({
|
const salaryProfile1 = await this.salaryProfileRepository.find({
|
||||||
where: {
|
where: {
|
||||||
salaryPeriodId: salaryPeriodIncrease1_APR?.id,
|
salaryOrgId: In([salaryOrg1_APR?.id, salaryOrg1_OCT?.id]),
|
||||||
rootId: rootId,
|
type: "FULL",
|
||||||
snapshot: "SNAP2",
|
},
|
||||||
},
|
});
|
||||||
});
|
//รอบปีก่อนหน้า
|
||||||
const salaryOrg1_OCT = await this.salaryOrgRepository.findOne({
|
const salaryPeriodIncrease2_APR = await this.salaryPeriodRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
salaryPeriodId: salaryPeriodIncrease1_OCT?.id,
|
period: "APR",
|
||||||
rootId: rootId,
|
year: salaryPeriod.year - 1,
|
||||||
snapshot: "SNAP2",
|
isActive: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const salaryProfile1 = await this.salaryProfileRepository.find({
|
const salaryPeriodIncrease2_OCT = await this.salaryPeriodRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
salaryOrgId: In([salaryOrg1_APR?.id, salaryOrg1_OCT?.id]),
|
period: "OCT",
|
||||||
type: "FULL",
|
year: salaryPeriod.year - 1,
|
||||||
},
|
isActive: true,
|
||||||
});
|
},
|
||||||
//รอบปีก่อนหน้า
|
});
|
||||||
const salaryPeriodIncrease2_APR = await this.salaryPeriodRepository.findOne({
|
const salaryOrg2_APR = await this.salaryOrgRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
period: "APR",
|
salaryPeriodId: salaryPeriodIncrease2_APR?.id,
|
||||||
year: salaryPeriod.year - 1,
|
rootId: rootId,
|
||||||
isActive: true,
|
snapshot: "SNAP2",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const salaryPeriodIncrease2_OCT = await this.salaryPeriodRepository.findOne({
|
const salaryOrg2_OCT = await this.salaryOrgRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
period: "OCT",
|
salaryPeriodId: salaryPeriodIncrease2_OCT?.id,
|
||||||
year: salaryPeriod.year - 1,
|
rootId: rootId,
|
||||||
isActive: true,
|
snapshot: "SNAP2",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const salaryOrg2_APR = await this.salaryOrgRepository.findOne({
|
const salaryProfile2 = await this.salaryProfileRepository.find({
|
||||||
where: {
|
where: {
|
||||||
salaryPeriodId: salaryPeriodIncrease2_APR?.id,
|
salaryOrgId: In([salaryOrg2_APR?.id, salaryOrg2_OCT?.id]),
|
||||||
rootId: rootId,
|
type: "FULL",
|
||||||
snapshot: "SNAP2",
|
},
|
||||||
},
|
});
|
||||||
});
|
const year = Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year)));
|
||||||
const salaryOrg2_OCT = await this.salaryOrgRepository.findOne({
|
const yearIncrease1 = Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year-2)));
|
||||||
where: {
|
const yearIncrease2 = Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year-1)));
|
||||||
salaryPeriodId: salaryPeriodIncrease2_OCT?.id,
|
const fifteenPercent = salaryOrg?.fifteenPercent == undefined || salaryOrg?.fifteenPercent == null ?
|
||||||
rootId: rootId,
|
"๐" : Extension.ToThaiNumber(String(salaryOrg?.fifteenPercent));
|
||||||
snapshot: "SNAP2",
|
const fifteenPoint = salaryOrg?.fifteenPoint == undefined || salaryOrg?.fifteenPoint == null ?
|
||||||
},
|
".๐๐" : "." + Extension.ToThaiNumber(String(salaryOrg?.fifteenPoint));
|
||||||
});
|
|
||||||
const salaryProfile2 = await this.salaryProfileRepository.find({
|
return new HttpSuccess({
|
||||||
where: {
|
template: "gov2-03",
|
||||||
salaryOrgId: In([salaryOrg2_APR?.id, salaryOrg2_OCT?.id]),
|
reportName: "gov2-03",
|
||||||
type: "FULL",
|
data: {
|
||||||
},
|
year: year,
|
||||||
});
|
yearIncrease1: yearIncrease1,
|
||||||
const year = Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year)));
|
yearIncrease2: yearIncrease2,
|
||||||
const yearIncrease1 = Extension.ToThaiNumber(
|
yearIncreaseSlice: yearIncrease2.slice(-2),
|
||||||
String(Extension.ToThaiYear(salaryPeriod.year - 2)),
|
yearSlice: year.slice(-2),
|
||||||
);
|
point: fifteenPercent + fifteenPoint,
|
||||||
const yearIncrease2 = Extension.ToThaiNumber(
|
root: salaryProfile[0]?.root,
|
||||||
String(Extension.ToThaiYear(salaryPeriod.year - 1)),
|
profile: salaryProfile.map((item, index) => ({
|
||||||
);
|
no: Extension.ToThaiNumber(String(index + 1)),
|
||||||
const fifteenPercent =
|
fullname:
|
||||||
salaryOrg?.fifteenPercent == undefined || salaryOrg?.fifteenPercent == null
|
(item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") +
|
||||||
? "๐"
|
(item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") +
|
||||||
: Extension.ToThaiNumber(String(salaryOrg?.fifteenPercent));
|
(item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") +
|
||||||
const fifteenPoint =
|
(item.child1 == undefined && item.child1 == null ? "" : item.child1 + "/") +
|
||||||
salaryOrg?.fifteenPoint == undefined || salaryOrg?.fifteenPoint == null
|
(item.root == undefined && item.root == null ? "" : item.root) +
|
||||||
? ".๐๐"
|
"/" +
|
||||||
: "." + Extension.ToThaiNumber(String(salaryOrg?.fifteenPoint));
|
item.prefix +
|
||||||
return new HttpSuccess({
|
item.firstName +
|
||||||
template: "gov1-03",
|
" " +
|
||||||
reportName: "gov1-03",
|
item.lastName, // สังกัด/ชื่อ-นามสกุล
|
||||||
data: {
|
posLevel: item.posLevel,
|
||||||
year: year,
|
posMasterNo: item.orgShortName + Extension.ToThaiNumber(String(item.posMasterNo)),
|
||||||
yearIncrease1: yearIncrease1,
|
amount:
|
||||||
yearIncrease2: yearIncrease2,
|
item.amount == undefined || item.amount == null
|
||||||
yearIncreaseSlice: yearIncrease2.slice(-2),
|
? "๐"
|
||||||
yearSlice: year.slice(-2),
|
: Extension.ToThaiNumber(String(item.amount.toLocaleString())),
|
||||||
point: fifteenPercent + fifteenPoint,
|
salaryIncrease1:
|
||||||
root: salaryProfile[0]?.root,
|
salaryProfile1.length > 0
|
||||||
profile: salaryProfile.map((item, index) => ({
|
? salaryProfile1
|
||||||
no: Extension.ToThaiNumber(String(index + 1)),
|
.filter((profile) => profile.citizenId === item.citizenId)
|
||||||
fullname:
|
.map((profile) => profile.amount)
|
||||||
(item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") +
|
: "๐", //การเลื่อนเงินเดือนปีก่อนๆหน้า
|
||||||
(item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") +
|
salaryIncrease2:
|
||||||
(item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") +
|
salaryProfile2.length > 0
|
||||||
(item.child1 == undefined && item.child1 == null ? "" : item.child1 + "/") +
|
? salaryProfile2
|
||||||
(item.root == undefined && item.root == null ? "" : item.root) +
|
.filter((profile) => profile.citizenId === item.citizenId)
|
||||||
"/" +
|
.map((profile) => profile.amount)
|
||||||
item.prefix +
|
: "๐", //การเลื่อนเงินเดือนปีก่อนหน้า
|
||||||
item.firstName +
|
salaryIncreaseAPR:
|
||||||
" " +
|
salaryProfile_APR.length > 0
|
||||||
item.lastName, // สังกัด/ชื่อ-นามสกุล
|
? salaryProfile_APR
|
||||||
posLevel: item.posLevel,
|
|
||||||
posMasterNo: item.orgShortName + Extension.ToThaiNumber(String(item.posMasterNo)),
|
|
||||||
amount:
|
|
||||||
item.amount == undefined || item.amount == null
|
|
||||||
? "๐"
|
|
||||||
: Extension.ToThaiNumber(String(item.amount.toLocaleString())),
|
|
||||||
salaryIncrease1:
|
|
||||||
salaryProfile1.length > 0
|
|
||||||
? salaryProfile1
|
|
||||||
.filter((profile) => profile.citizenId === item.citizenId)
|
.filter((profile) => profile.citizenId === item.citizenId)
|
||||||
.map((profile) => profile.amount)
|
.map((profile) => profile.amount)
|
||||||
: "๐", //การเลื่อนเงินเดือนปีก่อนๆหน้า
|
: "๐", //การเลื่อนเงินเดือนรอบเมษา
|
||||||
salaryIncrease2:
|
Type: item.type === "FULL" ? "หนึ่งขั้น" : "หนึ่งขั้นครึ่ง",
|
||||||
salaryProfile2.length > 0
|
score1: null, //ผลการประเมินฯ ครั้งที่ 1
|
||||||
? salaryProfile2
|
score2: null, //ผลการประเมินฯ ครั้งที่ 2
|
||||||
.filter((profile) => profile.citizenId === item.citizenId)
|
})),
|
||||||
.map((profile) => profile.amount)
|
},
|
||||||
: "๐", //การเลื่อนเงินเดือนปีก่อนหน้า
|
});
|
||||||
score: null, //ผลการประเมินฯ
|
}
|
||||||
remark: null, //หมายเหตุ
|
|
||||||
})),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue