gov1-03 & gov2-03 ปรับ Group1,2

This commit is contained in:
Bright 2024-03-22 17:44:56 +07:00
parent 4ee6991bbe
commit db910ec9f9

View file

@ -920,21 +920,33 @@ export class ReportController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
}
const salaryOrg = await this.salaryOrgRepository.findOne({
const salaryOrg_Group1 = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodId,
rootId: rootId,
snapshot: "SNAP2",
},
order: {
group: "ASC",
},
relations: ["salaryProfiles"],
group: "GROUP1"
}
});
const salaryOrg_Group2 = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodId,
rootId: rootId,
snapshot: "SNAP2",
group: "GROUP2"
}
});
if (salaryPeriod.period === "APR") {
const salaryProfile = await this.salaryProfileRepository.find({
const salaryProfileGroup1 = await this.salaryProfileRepository.find({
where: {
salaryOrgId: salaryOrg?.id,
salaryOrgId: salaryOrg_Group1?.id,
type: "FULL", //หนึ่งขั้น
},
});
const salaryProfileGroup2 = await this.salaryProfileRepository.find({
where: {
salaryOrgId: salaryOrg_Group2?.id,
type: "FULL", //หนึ่งขั้น
},
});
@ -954,26 +966,51 @@ export class ReportController extends Controller {
isActive: true,
},
});
const salaryOrg1_APR = await this.salaryOrgRepository.findOne({
const salaryOrg1_APR_Group1 = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease1_APR?.id,
rootId: rootId,
snapshot: "SNAP2",
group: "GROUP1"
},
});
const salaryOrg1_OCT = await this.salaryOrgRepository.findOne({
const salaryOrg1_APR_Group2 = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease1_APR?.id,
rootId: rootId,
snapshot: "SNAP2",
group: "GROUP2"
},
});
const salaryOrg1_OCT_Group1 = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease1_OCT?.id,
rootId: rootId,
snapshot: "SNAP2",
group: "GROUP1"
},
});
const salaryProfile1 = await this.salaryProfileRepository.find({
const salaryOrg1_OCT_Group2 = await this.salaryOrgRepository.findOne({
where: {
salaryOrgId: In([salaryOrg1_APR?.id, salaryOrg1_OCT?.id]),
salaryPeriodId: salaryPeriodIncrease1_OCT?.id,
rootId: rootId,
snapshot: "SNAP2",
group: "GROUP2"
},
});
const salaryProfile1_Group1 = await this.salaryProfileRepository.find({
where: {
salaryOrgId: In([salaryOrg1_APR_Group1?.id, salaryOrg1_OCT_Group1?.id]),
type: "FULL",
},
});
const salaryProfile1_Group2 = await this.salaryProfileRepository.find({
where: {
salaryOrgId: In([salaryOrg1_APR_Group2?.id, salaryOrg1_OCT_Group2?.id]),
type: "FULL",
},
});
//รอบปีก่อนหน้า
const salaryPeriodIncrease2_APR = await this.salaryPeriodRepository.findOne({
where: {
@ -989,23 +1026,47 @@ export class ReportController extends Controller {
isActive: true,
},
});
const salaryOrg2_APR = await this.salaryOrgRepository.findOne({
const salaryOrg2_APR_Group1 = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease2_APR?.id,
rootId: rootId,
snapshot: "SNAP2",
group: "GROUP1"
},
});
const salaryOrg2_OCT = await this.salaryOrgRepository.findOne({
const salaryOrg2_APR_Group2 = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease2_APR?.id,
rootId: rootId,
snapshot: "SNAP2",
group: "GROUP2"
},
});
const salaryOrg2_OCT_GROUP1 = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease2_OCT?.id,
rootId: rootId,
snapshot: "SNAP2",
group: "GROUP1"
},
});
const salaryProfile2 = await this.salaryProfileRepository.find({
const salaryOrg2_OCT_GROUP2 = await this.salaryOrgRepository.findOne({
where: {
salaryOrgId: In([salaryOrg2_APR?.id, salaryOrg2_OCT?.id]),
salaryPeriodId: salaryPeriodIncrease2_OCT?.id,
rootId: rootId,
snapshot: "SNAP2",
group: "GROUP2"
},
});
const salaryProfile2_Group1 = await this.salaryProfileRepository.find({
where: {
salaryOrgId: In([salaryOrg2_APR_Group1?.id, salaryOrg2_OCT_GROUP1?.id]),
type: "FULL",
},
});
const salaryProfile2_Group2 = await this.salaryProfileRepository.find({
where: {
salaryOrgId: In([salaryOrg2_APR_Group2?.id, salaryOrg2_OCT_GROUP2?.id]),
type: "FULL",
},
});
@ -1016,15 +1077,22 @@ export class ReportController extends Controller {
const yearIncrease2 = Extension.ToThaiNumber(
String(Extension.ToThaiYear(salaryPeriod.year - 1)),
);
const fifteenPercent =
salaryOrg?.fifteenPercent == undefined || salaryOrg?.fifteenPercent == null
const fifteenPercent_Group1 =
salaryOrg_Group1?.fifteenPercent == undefined || salaryOrg_Group1?.fifteenPercent == null
? ""
: Extension.ToThaiNumber(String(salaryOrg?.fifteenPercent));
const fifteenPoint =
salaryOrg?.fifteenPoint == undefined || salaryOrg?.fifteenPoint == null
: Extension.ToThaiNumber(String(salaryOrg_Group1?.fifteenPercent));
const fifteenPoint_Group1 =
salaryOrg_Group1?.fifteenPoint == undefined || salaryOrg_Group1?.fifteenPoint == null
? "."
: "." + Extension.ToThaiNumber(String(salaryOrg?.fifteenPoint));
: "." + Extension.ToThaiNumber(String(salaryOrg_Group1?.fifteenPoint));
const fifteenPercent_Group2 =
salaryOrg_Group2?.fifteenPercent == undefined || salaryOrg_Group2?.fifteenPercent == null
? ""
: Extension.ToThaiNumber(String(salaryOrg_Group2?.fifteenPercent));
const fifteenPoint_Group2 =
salaryOrg_Group2?.fifteenPoint == undefined || salaryOrg_Group2?.fifteenPoint == null
? "."
: "." + Extension.ToThaiNumber(String(salaryOrg_Group2?.fifteenPoint));
return new HttpSuccess({
template: "gov1-03",
reportName: "gov1-03",
@ -1034,9 +1102,10 @@ export class ReportController extends Controller {
yearIncrease2: yearIncrease2,
yearIncreaseSlice: yearIncrease2.slice(-2),
yearSlice: year.slice(-2),
point: fifteenPercent + fifteenPoint,
root: salaryProfile[0]?.root,
profile: salaryProfile.map((item, index) => ({
point: fifteenPercent_Group1 + fifteenPoint_Group1,
pointGroup2: fifteenPercent_Group2 + fifteenPoint_Group2,
root: salaryProfileGroup1[0]?.root,
profile: salaryProfileGroup1.map((item, index) => ({
no: Extension.ToThaiNumber(String(index + 1)),
fullname:
(item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") +
@ -1056,9 +1125,9 @@ export class ReportController extends Controller {
? ""
: Extension.ToThaiNumber(String(item.amount.toLocaleString())),
salaryIncrease1:
salaryProfile1.length > 0
salaryProfile1_Group1.length > 0
? (() => {
const filteredAmount = salaryProfile1
const filteredAmount = salaryProfile1_Group1
.filter((profile) => profile.citizenId === item.citizenId)
.map((profile) => profile.amount);
const Amount = filteredAmount[0];
@ -1066,9 +1135,51 @@ export class ReportController extends Controller {
})()
: "", //การเลื่อนเงินเดือนปีก่อนๆหน้า
salaryIncrease2:
salaryProfile2.length > 0
salaryProfile2_Group1.length > 0
? (() => {
const filteredAmount = salaryProfile2
const filteredAmount = salaryProfile2_Group1
.filter((profile) => profile.citizenId === item.citizenId)
.map((profile) => profile.amount);
const Amount = filteredAmount[0];
return Amount === undefined || Amount === null ? "" : Extension.ToThaiNumber(Amount?.toLocaleString());
})()
: "", //การเลื่อนเงินเดือนปีก่อนหน้า
score: null, //ผลการประเมินฯ
remark: null, //หมายเหตุ
})),
profileGroup2: salaryProfileGroup2.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_Group2.length > 0
? (() => {
const filteredAmount = salaryProfile1_Group2
.filter((profile) => profile.citizenId === item.citizenId)
.map((profile) => profile.amount);
const Amount = filteredAmount[0];
return Amount === undefined || Amount === null ? "" : Extension.ToThaiNumber(Amount?.toLocaleString());
})()
: "", //การเลื่อนเงินเดือนปีก่อนๆหน้า
salaryIncrease2:
salaryProfile2_Group2.length > 0
? (() => {
const filteredAmount = salaryProfile2_Group2
.filter((profile) => profile.citizenId === item.citizenId)
.map((profile) => profile.amount);
const Amount = filteredAmount[0];
@ -1080,8 +1191,9 @@ export class ReportController extends Controller {
})),
},
});
} else if (salaryPeriod.period === "OCT") {
//find period APR
}
else if (salaryPeriod.period === "OCT") {
// find period APR
const salaryPeriod_APR = await this.salaryPeriodRepository.findOne({
where: {
period: "APR",
@ -1089,24 +1201,45 @@ export class ReportController extends Controller {
isActive: true,
},
});
const salaryOrg_APR = await this.salaryOrgRepository.findOne({
const salaryOrg_APR_Group1 = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriod_APR?.id,
rootId: rootId,
snapshot: "SNAP2",
group: "GROUP1"
},
});
const salaryProfile_APR = await this.salaryProfileRepository.find({
const salaryOrg_APR_Group2 = await this.salaryOrgRepository.findOne({
where: {
salaryOrgId: salaryOrg_APR?.id,
salaryPeriodId: salaryPeriod_APR?.id,
rootId: rootId,
snapshot: "SNAP2",
group: "GROUP2"
},
});
const salaryProfile_APR_Group1 = await this.salaryProfileRepository.find({
where: {
salaryOrgId: salaryOrg_APR_Group1?.id,
type: In(["HAFT", "FULL"]),
},
});
const salaryProfile_APR_Group2 = await this.salaryProfileRepository.find({
where: {
salaryOrgId: salaryOrg_APR_Group2?.id,
type: In(["HAFT", "FULL"]),
},
});
//end period APR
const salaryProfile = await this.salaryProfileRepository.find({
const salaryProfileGroup1 = await this.salaryProfileRepository.find({
where: {
salaryOrgId: salaryOrg?.id,
salaryOrgId: salaryOrg_Group1?.id,
type: In(["FULLHAFT", "FULL"]),
},
});
const salaryProfileGroup2 = await this.salaryProfileRepository.find({
where: {
salaryOrgId: salaryOrg_Group2?.id,
type: In(["FULLHAFT", "FULL"]),
},
});
@ -1126,26 +1259,51 @@ export class ReportController extends Controller {
isActive: true,
},
});
const salaryOrg1_APR = await this.salaryOrgRepository.findOne({
const salaryOrg1_APR_Group1 = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease1_APR?.id,
rootId: rootId,
snapshot: "SNAP2",
group: "GROUP1"
},
});
const salaryOrg1_OCT = await this.salaryOrgRepository.findOne({
const salaryOrg1_APR_Group2 = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease1_APR?.id,
rootId: rootId,
snapshot: "SNAP2",
group: "GROUP2"
},
});
const salaryOrg1_OCT_Group1 = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease1_OCT?.id,
rootId: rootId,
snapshot: "SNAP2",
group: "GROUP1"
},
});
const salaryProfile1 = await this.salaryProfileRepository.find({
const salaryOrg1_OCT_Group2 = await this.salaryOrgRepository.findOne({
where: {
salaryOrgId: In([salaryOrg1_APR?.id, salaryOrg1_OCT?.id]),
salaryPeriodId: salaryPeriodIncrease1_OCT?.id,
rootId: rootId,
snapshot: "SNAP2",
group: "GROUP2"
},
});
const salaryProfile1_Group1 = await this.salaryProfileRepository.find({
where: {
salaryOrgId: In([salaryOrg1_APR_Group1?.id, salaryOrg1_OCT_Group1?.id]),
type: "FULL",
},
});
const salaryProfile1_Group2 = await this.salaryProfileRepository.find({
where: {
salaryOrgId: In([salaryOrg1_APR_Group2?.id, salaryOrg1_OCT_Group2?.id]),
type: "FULL",
},
});
//รอบปีก่อนหน้า
const salaryPeriodIncrease2_APR = await this.salaryPeriodRepository.findOne({
where: {
@ -1161,23 +1319,47 @@ export class ReportController extends Controller {
isActive: true,
},
});
const salaryOrg2_APR = await this.salaryOrgRepository.findOne({
const salaryOrg2_APR_Group1 = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease2_APR?.id,
rootId: rootId,
snapshot: "SNAP2",
group: "GROUP1"
},
});
const salaryOrg2_OCT = await this.salaryOrgRepository.findOne({
const salaryOrg2_APR_Group2 = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease2_APR?.id,
rootId: rootId,
snapshot: "SNAP2",
group: "GROUP2"
},
});
const salaryOrg2_OCT_GROUP1 = await this.salaryOrgRepository.findOne({
where: {
salaryPeriodId: salaryPeriodIncrease2_OCT?.id,
rootId: rootId,
snapshot: "SNAP2",
group: "GROUP1"
},
});
const salaryProfile2 = await this.salaryProfileRepository.find({
const salaryOrg2_OCT_GROUP2 = await this.salaryOrgRepository.findOne({
where: {
salaryOrgId: In([salaryOrg2_APR?.id, salaryOrg2_OCT?.id]),
salaryPeriodId: salaryPeriodIncrease2_OCT?.id,
rootId: rootId,
snapshot: "SNAP2",
group: "GROUP2"
},
});
const salaryProfile2_Group1 = await this.salaryProfileRepository.find({
where: {
salaryOrgId: In([salaryOrg2_APR_Group1?.id, salaryOrg2_OCT_GROUP1?.id]),
type: "FULL",
},
});
const salaryProfile2_Group2 = await this.salaryProfileRepository.find({
where: {
salaryOrgId: In([salaryOrg2_APR_Group2?.id, salaryOrg2_OCT_GROUP2?.id]),
type: "FULL",
},
});
@ -1189,14 +1371,21 @@ export class ReportController extends Controller {
String(Extension.ToThaiYear(salaryPeriod.year - 1)),
);
const fifteenPercent =
salaryOrg?.fifteenPercent == undefined || salaryOrg?.fifteenPercent == null
salaryOrg_Group1?.fifteenPercent == undefined || salaryOrg_Group1?.fifteenPercent == null
? ""
: Extension.ToThaiNumber(String(salaryOrg?.fifteenPercent));
: Extension.ToThaiNumber(String(salaryOrg_Group1?.fifteenPercent));
const fifteenPoint =
salaryOrg?.fifteenPoint == undefined || salaryOrg?.fifteenPoint == null
salaryOrg_Group1?.fifteenPoint == undefined || salaryOrg_Group1?.fifteenPoint == null
? "."
: "." + Extension.ToThaiNumber(String(salaryOrg?.fifteenPoint));
: "." + Extension.ToThaiNumber(String(salaryOrg_Group1?.fifteenPoint));
const fifteenPercent_Group2 =
salaryOrg_Group2?.fifteenPercent == undefined || salaryOrg_Group2?.fifteenPercent == null
? ""
: Extension.ToThaiNumber(String(salaryOrg_Group2?.fifteenPercent));
const fifteenPoint_Group2 =
salaryOrg_Group2?.fifteenPoint == undefined || salaryOrg_Group2?.fifteenPoint == null
? "."
: "." + Extension.ToThaiNumber(String(salaryOrg_Group2?.fifteenPoint));
return new HttpSuccess({
template: "gov2-03",
reportName: "gov2-03",
@ -1207,8 +1396,9 @@ export class ReportController extends Controller {
yearIncreaseSlice: yearIncrease2.slice(-2),
yearSlice: year.slice(-2),
point: fifteenPercent + fifteenPoint,
root: salaryProfile[0]?.root,
profile: salaryProfile.map((item, index) => ({
pointGroup2: fifteenPercent_Group2 + fifteenPoint_Group2,
root: salaryProfileGroup1[0]?.root,
profile: salaryProfileGroup1.map((item, index) => ({
no: Extension.ToThaiNumber(String(index + 1)),
fullname:
(item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") +
@ -1228,9 +1418,9 @@ export class ReportController extends Controller {
? ""
: Extension.ToThaiNumber(String(item.amount.toLocaleString())),
salaryIncrease1:
salaryProfile1.length > 0
salaryProfile1_Group1.length > 0
? (() => {
const filteredAmount = salaryProfile1
const filteredAmount = salaryProfile1_Group1
.filter((profile) => profile.citizenId === item.citizenId)
.map((profile) => profile.amount);
const Amount = filteredAmount[0];
@ -1238,9 +1428,9 @@ export class ReportController extends Controller {
})()
: "", //การเลื่อนเงินเดือนปีก่อนๆหน้า
salaryIncrease2:
salaryProfile2.length > 0
salaryProfile2_Group1.length > 0
? (() => {
const filteredAmount = salaryProfile2
const filteredAmount = salaryProfile2_Group1
.filter((profile) => profile.citizenId === item.citizenId)
.map((profile) => profile.amount);
const Amount = filteredAmount[0];
@ -1248,9 +1438,62 @@ export class ReportController extends Controller {
})()
: "", //การเลื่อนเงินเดือนปีก่อนหน้า
salaryIncreaseAPR:
salaryProfile_APR.length > 0
salaryProfile_APR_Group1.length > 0
? (() => {
const filteredAmount = salaryProfile_APR
const filteredAmount = salaryProfile_APR_Group1
.filter((profile) => profile.citizenId === item.citizenId)
.map((profile) => profile.amount);
const Amount = filteredAmount[0];
return Amount === undefined || Amount === null ? "" : Extension.ToThaiNumber(Amount?.toLocaleString());
})()
: "", //การเลื่อนเงินเดือนรอบเมษา
Type: item.type === "FULL" ? "หนึ่งขั้น" : "หนึ่งขั้นครึ่ง",
score1: null, //ผลการประเมินฯ ครั้งที่ 1
score2: null, //ผลการประเมินฯ ครั้งที่ 2
})),
profileGroup2: salaryProfileGroup2.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_Group2.length > 0
? (() => {
const filteredAmount = salaryProfile1_Group2
.filter((profile) => profile.citizenId === item.citizenId)
.map((profile) => profile.amount);
const Amount = filteredAmount[0];
return Amount === undefined || Amount === null ? "" : Extension.ToThaiNumber(Amount?.toLocaleString());
})()
: "", //การเลื่อนเงินเดือนปีก่อนๆหน้า
salaryIncrease2:
salaryProfile2_Group2.length > 0
? (() => {
const filteredAmount = salaryProfile2_Group2
.filter((profile) => profile.citizenId === item.citizenId)
.map((profile) => profile.amount);
const Amount = filteredAmount[0];
return Amount === undefined || Amount === null ? "" : Extension.ToThaiNumber(Amount?.toLocaleString());
})()
: "", //การเลื่อนเงินเดือนปีก่อนหน้า
salaryIncreaseAPR:
salaryProfile_APR_Group2.length > 0
? (() => {
const filteredAmount = salaryProfile_APR_Group2
.filter((profile) => profile.citizenId === item.citizenId)
.map((profile) => profile.amount);
const Amount = filteredAmount[0];