This commit is contained in:
Kittapath 2024-03-20 18:05:57 +07:00
parent 3d6ceb2229
commit 78801a8c6c

View file

@ -212,7 +212,7 @@ export class ReportController extends Controller {
* @summary 1 * @summary 1
* *
*/ */
@Get("gov1-01/{rootId}/{salaryPeriodId}") @Get("gov-01/{rootId}/{salaryPeriodId}")
async SalaryReport1(@Path() rootId: string, @Path() salaryPeriodId: string) { async SalaryReport1(@Path() rootId: string, @Path() salaryPeriodId: string) {
const salaryPeriod = await this.salaryPeriodRepository.findOne({ const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: { where: {
@ -222,16 +222,13 @@ export class ReportController extends Controller {
if (!salaryPeriod) { if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
} }
const salaryPeriodAPR = await this.salaryProfileRepository.find({ const _salaryPeriod = await this.salaryProfileRepository.find({
relations: ["salaryOrg", "salaryOrg.salaryPeriod"], relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
where: { where: {
salaryOrg: { salaryOrg: {
snapshot: "SNAP1", snapshot: "SNAP1",
rootId: rootId, rootId: rootId,
salaryPeriodId: salaryPeriodId, salaryPeriodId: salaryPeriodId,
salaryPeriod: {
period: "APR",
},
}, },
}, },
order: { order: {
@ -240,13 +237,13 @@ export class ReportController extends Controller {
}, },
}); });
if (!salaryPeriodAPR) { if (!_salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
const agency = salaryPeriodAPR[0] == null ? "" : salaryPeriodAPR[0].root; const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
const formattedData = salaryPeriodAPR.map((profile, index) => { const formattedData = _salaryPeriod.map((profile, index) => {
const fullNameParts = [ const fullNameParts = [
profile?.child4, profile?.child4,
profile?.child3, profile?.child3,
@ -274,12 +271,10 @@ export class ReportController extends Controller {
}); });
return new HttpSuccess({ return new HttpSuccess({
template: "gov1-01", template: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
reportName: "gov1-01", reportName: salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01",
data: { data: {
date: Extension.ToThaiNumber( year: Extension.ToThaiNumber((salaryPeriod.year + 543).toString()),
Extension.ToThaiFullDate(new Date(`${salaryPeriod.year}-03-01`)),
),
agency: agency, agency: agency,
data: formattedData, data: formattedData,
}, },
@ -292,7 +287,7 @@ export class ReportController extends Controller {
* @summary * @summary
* *
*/ */
@Get("gov1-02/{rootId}/{salaryPeriodId}") @Get("gov-02/{rootId}/{salaryPeriodId}")
async SalaryReport2(@Path() rootId: string, @Path() salaryPeriodId: string) { async SalaryReport2(@Path() rootId: string, @Path() salaryPeriodId: string) {
const salaryPeriod = await this.salaryPeriodRepository.findOne({ const salaryPeriod = await this.salaryPeriodRepository.findOne({
where: { where: {
@ -302,181 +297,564 @@ export class ReportController extends Controller {
if (!salaryPeriod) { if (!salaryPeriod) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
} }
const salaryPeriodAPR = await this.salaryOrgRepository.find({ const _salaryPeriod = await this.salaryOrgRepository.find({
relations: ["salaryPeriod", "salaryProfiles"], relations: ["salaryPeriod", "salaryProfiles"],
where: { where: {
snapshot: "SNAP1", snapshot: "SNAP1",
rootId: rootId, rootId: rootId,
salaryPeriodId: salaryPeriodId, salaryPeriodId: salaryPeriodId,
salaryPeriod: {
period: "APR",
},
}, },
order: { group: "ASC" }, order: { group: "ASC" },
}); });
const agency = const agency =
salaryPeriodAPR[0] == null || salaryPeriodAPR[0].salaryProfiles[0] == null _salaryPeriod[0] == null || _salaryPeriod[0].salaryProfiles[0] == null
? "" ? ""
: salaryPeriodAPR[0].salaryProfiles[0].root; : _salaryPeriod[0].salaryProfiles[0].root;
if (salaryPeriod.period == "APR") {
let data1 = _salaryPeriod.find((x) => x.group == "GROUP2");
let formattedData1;
if (data1 != null) {
formattedData1 = {
total: Extension.ToThaiNumber(data1.total.toString()),
fifteenPercent: Extension.ToThaiNumber(data1.fifteenPercent.toString()),
full: Extension.ToThaiNumber(
data1.salaryProfiles.filter((x) => x.type == "FULL").length.toString(),
),
haft: Extension.ToThaiNumber(
data1.salaryProfiles.filter((x) => x.type == "HAFT").length.toString(),
),
notPromoted: Extension.ToThaiNumber(
data1.salaryProfiles.filter((x) => x.type == "NONE").length.toString(),
),
reason: null,
};
}
let data2 = _salaryPeriod.find((x) => x.group == "GROUP1");
let formattedData2;
if (data2 != null) {
formattedData2 = {
total: Extension.ToThaiNumber(data2.total.toString()),
fifteenPercent: Extension.ToThaiNumber(data2.fifteenPercent.toString()),
full: Extension.ToThaiNumber(
data2.salaryProfiles
.filter(
(x) =>
x.posLevel == "อาวุโส" ||
x.posLevel == "ชำนาญการพิเศษ" ||
(x.posLevel == "ต้น" && x.posType == "อำนวยการ"),
)
.filter((x) => x.type == "FULL")
.length.toString(),
),
haft: Extension.ToThaiNumber(
data2.salaryProfiles
.filter(
(x) =>
x.posLevel == "อาวุโส" ||
x.posLevel == "ชำนาญการพิเศษ" ||
(x.posLevel == "ต้น" && x.posType == "อำนวยการ"),
)
.filter((x) => x.type == "HAFT")
.length.toString(),
),
notPromoted: Extension.ToThaiNumber(
data2.salaryProfiles
.filter(
(x) =>
x.posLevel == "อาวุโส" ||
x.posLevel == "ชำนาญการพิเศษ" ||
(x.posLevel == "ต้น" && x.posType == "อำนวยการ"),
)
.filter((x) => x.type == "NONE")
.length.toString(),
),
reason: null,
};
}
let data3 = _salaryPeriod.find((x) => x.group == "GROUP1");
let formattedData3;
if (data3 != null) {
formattedData3 = {
total: Extension.ToThaiNumber(data3.total.toString()),
fifteenPercent: Extension.ToThaiNumber(data3.fifteenPercent.toString()),
full: Extension.ToThaiNumber(
data3.salaryProfiles
.filter(
(x) =>
x.posLevel == "ปฏิบัติงาน" ||
x.posLevel == "ชำนาญงาน" ||
x.posLevel == "ปฏิบัติการ" ||
x.posLevel == "ชำนาญการ",
)
.filter((x) => x.type == "FULL")
.length.toString(),
),
haft: Extension.ToThaiNumber(
data3.salaryProfiles
.filter(
(x) =>
x.posLevel == "ปฏิบัติงาน" ||
x.posLevel == "ชำนาญงาน" ||
x.posLevel == "ปฏิบัติการ" ||
x.posLevel == "ชำนาญการ",
)
.filter((x) => x.type == "HAFT")
.length.toString(),
),
notPromoted: Extension.ToThaiNumber(
data3.salaryProfiles
.filter(
(x) =>
x.posLevel == "ปฏิบัติงาน" ||
x.posLevel == "ชำนาญงาน" ||
x.posLevel == "ปฏิบัติการ" ||
x.posLevel == "ชำนาญการ",
)
.filter((x) => x.type == "NONE")
.length.toString(),
),
reason: null,
};
}
let data4 = _salaryPeriod.find((x) => x.group == "GROUP1");
let formattedData4;
if (data4 != null) {
formattedData4 = {
total: Extension.ToThaiNumber(data4.total.toString()),
fifteenPercent: Extension.ToThaiNumber(data4.fifteenPercent.toString()),
full: Extension.ToThaiNumber(
data4.salaryProfiles.filter((x) => x.type == "FULL").length.toString(),
),
haft: Extension.ToThaiNumber(
data4.salaryProfiles.filter((x) => x.type == "HAFT").length.toString(),
),
notPromoted: Extension.ToThaiNumber(
data4.salaryProfiles.filter((x) => x.type == "NONE").length.toString(),
),
reason: null,
};
}
let data1 = salaryPeriodAPR.find((x) => x.group == "GROUP2"); return new HttpSuccess({
let formattedData1; template: "gov1-02",
if (data1 != null) { reportName: "gov1-02",
formattedData1 = { data: {
total: Extension.ToThaiNumber(data1.salaryProfiles.length.toString()), date: Extension.ToThaiNumber(
fifteenPercent: Extension.ToThaiNumber(data1.fifteenPercent.toString()), Extension.ToThaiFullDate(new Date(`${salaryPeriod.year}-03-01`)),
full: Extension.ToThaiNumber( ),
data1.salaryProfiles.filter((x) => x.type == "FULL").length.toString(), dateNow: Extension.ToThaiNumber(Extension.ToThaiFullDate(new Date())),
), agency: agency,
haft: Extension.ToThaiNumber( data1: formattedData1,
data1.salaryProfiles.filter((x) => x.type == "HAFT").length.toString(), data2: formattedData2,
), data3: formattedData3,
notPromoted: Extension.ToThaiNumber( data4: formattedData4,
data1.salaryProfiles.filter((x) => x.type == "NONE").length.toString(), },
), });
reason: null, } else {
}; let data1 = _salaryPeriod.find((x) => x.group == "GROUP2");
} const _salaryPeriodAPR = await this.salaryOrgRepository.find({
let data2 = salaryPeriodAPR.find((x) => x.group == "GROUP1"); where: {
let formattedData2; snapshot: "SNAP1",
if (data2 != null) { rootId: rootId,
formattedData2 = { salaryPeriod: {
total: Extension.ToThaiNumber( period: "APR",
data2.salaryProfiles year: salaryPeriod.year,
.filter( },
(x) => },
x.posLevel == "อาวุโส" || order: { group: "ASC" },
x.posLevel == "ชำนาญการพิเศษ" || });
(x.posLevel == "ต้น" && x.posType == "อำนวยการ"), let formattedData1;
) if (data1 != null) {
.length.toString(), const haftSalary = data1.salaryProfiles
), .filter((x) => x.type == "HAFT")
fifteenPercent: Extension.ToThaiNumber(data2.fifteenPercent.toString()), .reduce((accumulator, object: any) => {
full: Extension.ToThaiNumber( return (
data2.salaryProfiles accumulator +
.filter( (object.amount == null ? 0 : object.amount) +
(x) => (object.amountSpecial == null ? 0 : object.amountSpecial)
x.posLevel == "อาวุโส" || );
x.posLevel == "ชำนาญการพิเศษ" || }, 0);
(x.posLevel == "ต้น" && x.posType == "อำนวยการ"),
)
.filter((x) => x.type == "FULL")
.length.toString(),
),
haft: Extension.ToThaiNumber(
data2.salaryProfiles
.filter(
(x) =>
x.posLevel == "อาวุโส" ||
x.posLevel == "ชำนาญการพิเศษ" ||
(x.posLevel == "ต้น" && x.posType == "อำนวยการ"),
)
.filter((x) => x.type == "HAFT")
.length.toString(),
),
notPromoted: Extension.ToThaiNumber(
data2.salaryProfiles
.filter(
(x) =>
x.posLevel == "อาวุโส" ||
x.posLevel == "ชำนาญการพิเศษ" ||
(x.posLevel == "ต้น" && x.posType == "อำนวยการ"),
)
.filter((x) => x.type == "NONE")
.length.toString(),
),
reason: null,
};
}
let data3 = salaryPeriodAPR.find((x) => x.group == "GROUP1");
let formattedData3;
if (data3 != null) {
formattedData3 = {
total: Extension.ToThaiNumber(
data3.salaryProfiles
.filter(
(x) =>
x.posLevel == "ปฏิบัติงาน" ||
x.posLevel == "ชำนาญงาน" ||
x.posLevel == "ปฏิบัติการ" ||
x.posLevel == "ชำนาญการ",
)
.length.toString(),
),
fifteenPercent: Extension.ToThaiNumber(data3.fifteenPercent.toString()),
full: Extension.ToThaiNumber(
data3.salaryProfiles
.filter(
(x) =>
x.posLevel == "ปฏิบัติงาน" ||
x.posLevel == "ชำนาญงาน" ||
x.posLevel == "ปฏิบัติการ" ||
x.posLevel == "ชำนาญการ",
)
.filter((x) => x.type == "FULL")
.length.toString(),
),
haft: Extension.ToThaiNumber(
data3.salaryProfiles
.filter(
(x) =>
x.posLevel == "ปฏิบัติงาน" ||
x.posLevel == "ชำนาญงาน" ||
x.posLevel == "ปฏิบัติการ" ||
x.posLevel == "ชำนาญการ",
)
.filter((x) => x.type == "HAFT")
.length.toString(),
),
notPromoted: Extension.ToThaiNumber(
data3.salaryProfiles
.filter(
(x) =>
x.posLevel == "ปฏิบัติงาน" ||
x.posLevel == "ชำนาญงาน" ||
x.posLevel == "ปฏิบัติการ" ||
x.posLevel == "ชำนาญการ",
)
.filter((x) => x.type == "NONE")
.length.toString(),
),
reason: null,
};
}
let data4 = salaryPeriodAPR.find((x) => x.group == "GROUP1");
let formattedData4;
if (data4 != null) {
formattedData4 = {
total: Extension.ToThaiNumber(data4.salaryProfiles.length.toString()),
fifteenPercent: Extension.ToThaiNumber(data4.fifteenPercent.toString()),
full: Extension.ToThaiNumber(
data4.salaryProfiles.filter((x) => x.type == "FULL").length.toString(),
),
haft: Extension.ToThaiNumber(
data4.salaryProfiles.filter((x) => x.type == "HAFT").length.toString(),
),
notPromoted: Extension.ToThaiNumber(
data4.salaryProfiles.filter((x) => x.type == "NONE").length.toString(),
),
reason: null,
};
}
return new HttpSuccess({ const fullSalary = data1.salaryProfiles
template: "gov1-02", .filter((x) => x.type == "FULL")
reportName: "gov1-02", .reduce((accumulator, object: any) => {
data: { return (
date: Extension.ToThaiNumber( accumulator +
Extension.ToThaiFullDate(new Date(`${salaryPeriod.year}-03-01`)), (object.amount == null ? 0 : object.amount) +
), (object.amountSpecial == null ? 0 : object.amountSpecial)
dateNow: Extension.ToThaiNumber(Extension.ToThaiFullDate(new Date())), );
agency: agency, }, 0);
data1: formattedData1, const fullHaftSalary = data1.salaryProfiles
data2: formattedData2, .filter((x) => x.type == "NONE")
data3: formattedData3, .reduce((accumulator, object: any) => {
data4: formattedData4, return (
}, accumulator +
}); (object.amount == null ? 0 : object.amount) +
(object.amountSpecial == null ? 0 : object.amountSpecial)
);
}, 0);
formattedData1 = {
totalSalary: Extension.ToThaiNumber(data1.currentAmount.toString()),
totalUser: Extension.ToThaiNumber(data1.total.toString()),
sixPercentAmount: Extension.ToThaiNumber(data1.sixPercentAmount.toString()),
spentAmount: Extension.ToThaiNumber(data1.spentAmount.toString()),
remainingAmount: Extension.ToThaiNumber(
(data1.sixPercentAmount - data1.spentAmount).toString(),
),
haft: Extension.ToThaiNumber(
data1.salaryProfiles.filter((x) => x.type == "HAFT").length.toString(),
),
full: Extension.ToThaiNumber(
data1.salaryProfiles.filter((x) => x.type == "FULL").length.toString(),
),
fullHaft: Extension.ToThaiNumber(
data1.salaryProfiles.filter((x) => x.type == "HAFT").length.toString(),
),
notPromoted: Extension.ToThaiNumber(
data1.salaryProfiles.filter((x) => x.type == "NONE").length.toString(),
),
haftSalary: Extension.ToThaiNumber(haftSalary.toString()),
fullSalary: Extension.ToThaiNumber(fullSalary.toString()),
fullHaftSalary: Extension.ToThaiNumber(fullHaftSalary.toString()),
total: Extension.ToThaiNumber((haftSalary + fullSalary + fullHaftSalary).toString()),
summary: Extension.ToThaiNumber(
(
data1.sixPercentAmount -
data1.spentAmount -
haftSalary -
fullSalary -
fullHaftSalary
).toString(),
),
reason: null,
};
}
let data2 = _salaryPeriod.find((x) => x.group == "GROUP1");
let formattedData2;
if (data2 != null) {
const haftSalary = data2.salaryProfiles
.filter((x) => x.type == "HAFT")
.filter(
(x) =>
x.posLevel == "อาวุโส" ||
x.posLevel == "ชำนาญการพิเศษ" ||
(x.posLevel == "ต้น" && x.posType == "อำนวยการ"),
)
.reduce((accumulator, object: any) => {
return (
accumulator +
(object.amount == null ? 0 : object.amount) +
(object.amountSpecial == null ? 0 : object.amountSpecial)
);
}, 0);
const fullSalary = data2.salaryProfiles
.filter((x) => x.type == "FULL")
.filter(
(x) =>
x.posLevel == "อาวุโส" ||
x.posLevel == "ชำนาญการพิเศษ" ||
(x.posLevel == "ต้น" && x.posType == "อำนวยการ"),
)
.reduce((accumulator, object: any) => {
return (
accumulator +
(object.amount == null ? 0 : object.amount) +
(object.amountSpecial == null ? 0 : object.amountSpecial)
);
}, 0);
const fullHaftSalary = data2.salaryProfiles
.filter((x) => x.type == "NONE")
.filter(
(x) =>
x.posLevel == "อาวุโส" ||
x.posLevel == "ชำนาญการพิเศษ" ||
(x.posLevel == "ต้น" && x.posType == "อำนวยการ"),
)
.reduce((accumulator, object: any) => {
return (
accumulator +
(object.amount == null ? 0 : object.amount) +
(object.amountSpecial == null ? 0 : object.amountSpecial)
);
}, 0);
formattedData2 = {
totalSalary: Extension.ToThaiNumber(data2.currentAmount.toString()),
totalUser: Extension.ToThaiNumber(data2.total.toString()),
sixPercentAmount: Extension.ToThaiNumber(data2.sixPercentAmount.toString()),
spentAmount: Extension.ToThaiNumber(data2.spentAmount.toString()),
remainingAmount: Extension.ToThaiNumber(
(data2.sixPercentAmount - data2.spentAmount).toString(),
),
haft: Extension.ToThaiNumber(
data2.salaryProfiles
.filter(
(x) =>
x.posLevel == "อาวุโส" ||
x.posLevel == "ชำนาญการพิเศษ" ||
(x.posLevel == "ต้น" && x.posType == "อำนวยการ"),
)
.filter((x) => x.type == "HAFT")
.length.toString(),
),
full: Extension.ToThaiNumber(
data2.salaryProfiles
.filter(
(x) =>
x.posLevel == "อาวุโส" ||
x.posLevel == "ชำนาญการพิเศษ" ||
(x.posLevel == "ต้น" && x.posType == "อำนวยการ"),
)
.filter((x) => x.type == "FULL")
.length.toString(),
),
fullHaft: Extension.ToThaiNumber(
data2.salaryProfiles
.filter(
(x) =>
x.posLevel == "อาวุโส" ||
x.posLevel == "ชำนาญการพิเศษ" ||
(x.posLevel == "ต้น" && x.posType == "อำนวยการ"),
)
.filter((x) => x.type == "HAFT")
.length.toString(),
),
notPromoted: Extension.ToThaiNumber(
data2.salaryProfiles
.filter(
(x) =>
x.posLevel == "อาวุโส" ||
x.posLevel == "ชำนาญการพิเศษ" ||
(x.posLevel == "ต้น" && x.posType == "อำนวยการ"),
)
.filter((x) => x.type == "NONE")
.length.toString(),
),
haftSalary: Extension.ToThaiNumber(haftSalary.toString()),
fullSalary: Extension.ToThaiNumber(fullSalary.toString()),
fullHaftSalary: Extension.ToThaiNumber(fullHaftSalary.toString()),
total: Extension.ToThaiNumber((haftSalary + fullSalary + fullHaftSalary).toString()),
summary: Extension.ToThaiNumber(
(
data2.sixPercentAmount -
data2.spentAmount -
haftSalary -
fullSalary -
fullHaftSalary
).toString(),
),
reason: null,
};
}
let data3 = _salaryPeriod.find((x) => x.group == "GROUP1");
let formattedData3;
if (data3 != null) {
const haftSalary = data3.salaryProfiles
.filter((x) => x.type == "HAFT")
.filter(
(x) =>
x.posLevel == "ปฏิบัติงาน" ||
x.posLevel == "ชำนาญงาน" ||
x.posLevel == "ปฏิบัติการ" ||
x.posLevel == "ชำนาญการ",
)
.reduce((accumulator, object: any) => {
return (
accumulator +
(object.amount == null ? 0 : object.amount) +
(object.amountSpecial == null ? 0 : object.amountSpecial)
);
}, 0);
const fullSalary = data3.salaryProfiles
.filter((x) => x.type == "FULL")
.filter(
(x) =>
x.posLevel == "ปฏิบัติงาน" ||
x.posLevel == "ชำนาญงาน" ||
x.posLevel == "ปฏิบัติการ" ||
x.posLevel == "ชำนาญการ",
)
.reduce((accumulator, object: any) => {
return (
accumulator +
(object.amount == null ? 0 : object.amount) +
(object.amountSpecial == null ? 0 : object.amountSpecial)
);
}, 0);
const fullHaftSalary = data3.salaryProfiles
.filter((x) => x.type == "NONE")
.filter(
(x) =>
x.posLevel == "ปฏิบัติงาน" ||
x.posLevel == "ชำนาญงาน" ||
x.posLevel == "ปฏิบัติการ" ||
x.posLevel == "ชำนาญการ",
)
.reduce((accumulator, object: any) => {
return (
accumulator +
(object.amount == null ? 0 : object.amount) +
(object.amountSpecial == null ? 0 : object.amountSpecial)
);
}, 0);
formattedData3 = {
totalSalary: Extension.ToThaiNumber(data3.currentAmount.toString()),
totalUser: Extension.ToThaiNumber(data3.total.toString()),
sixPercentAmount: Extension.ToThaiNumber(data3.sixPercentAmount.toString()),
spentAmount: Extension.ToThaiNumber(data3.spentAmount.toString()),
remainingAmount: Extension.ToThaiNumber(
(data3.sixPercentAmount - data3.spentAmount).toString(),
),
haft: Extension.ToThaiNumber(
data3.salaryProfiles
.filter((x) => x.type == "HAFT")
.filter(
(x) =>
x.posLevel == "ปฏิบัติงาน" ||
x.posLevel == "ชำนาญงาน" ||
x.posLevel == "ปฏิบัติการ" ||
x.posLevel == "ชำนาญการ",
)
.length.toString(),
),
full: Extension.ToThaiNumber(
data3.salaryProfiles
.filter((x) => x.type == "FULL")
.filter(
(x) =>
x.posLevel == "ปฏิบัติงาน" ||
x.posLevel == "ชำนาญงาน" ||
x.posLevel == "ปฏิบัติการ" ||
x.posLevel == "ชำนาญการ",
)
.length.toString(),
),
fullHaft: Extension.ToThaiNumber(
data3.salaryProfiles
.filter((x) => x.type == "HAFT")
.filter(
(x) =>
x.posLevel == "ปฏิบัติงาน" ||
x.posLevel == "ชำนาญงาน" ||
x.posLevel == "ปฏิบัติการ" ||
x.posLevel == "ชำนาญการ",
)
.length.toString(),
),
notPromoted: Extension.ToThaiNumber(
data3.salaryProfiles
.filter((x) => x.type == "NONE")
.filter(
(x) =>
x.posLevel == "ปฏิบัติงาน" ||
x.posLevel == "ชำนาญงาน" ||
x.posLevel == "ปฏิบัติการ" ||
x.posLevel == "ชำนาญการ",
)
.length.toString(),
),
haftSalary: Extension.ToThaiNumber(haftSalary.toString()),
fullSalary: Extension.ToThaiNumber(fullSalary.toString()),
fullHaftSalary: Extension.ToThaiNumber(fullHaftSalary.toString()),
total: Extension.ToThaiNumber((haftSalary + fullSalary + fullHaftSalary).toString()),
summary: Extension.ToThaiNumber(
(
data3.sixPercentAmount -
data3.spentAmount -
haftSalary -
fullSalary -
fullHaftSalary
).toString(),
),
reason: null,
};
}
let data4 = _salaryPeriod.find((x) => x.group == "GROUP1");
let formattedData4;
if (data4 != null) {
const haftSalary = data4.salaryProfiles
.filter((x) => x.type == "HAFT")
.reduce((accumulator, object: any) => {
return (
accumulator +
(object.amount == null ? 0 : object.amount) +
(object.amountSpecial == null ? 0 : object.amountSpecial)
);
}, 0);
const fullSalary = data4.salaryProfiles
.filter((x) => x.type == "FULL")
.reduce((accumulator, object: any) => {
return (
accumulator +
(object.amount == null ? 0 : object.amount) +
(object.amountSpecial == null ? 0 : object.amountSpecial)
);
}, 0);
const fullHaftSalary = data4.salaryProfiles
.filter((x) => x.type == "NONE")
.reduce((accumulator, object: any) => {
return (
accumulator +
(object.amount == null ? 0 : object.amount) +
(object.amountSpecial == null ? 0 : object.amountSpecial)
);
}, 0);
formattedData4 = {
totalSalary: Extension.ToThaiNumber(data4.currentAmount.toString()),
totalUser: Extension.ToThaiNumber(data4.total.toString()),
sixPercentAmount: Extension.ToThaiNumber(data4.sixPercentAmount.toString()),
spentAmount: Extension.ToThaiNumber(data4.spentAmount.toString()),
remainingAmount: Extension.ToThaiNumber(
(data4.sixPercentAmount - data4.spentAmount).toString(),
),
haft: Extension.ToThaiNumber(
data4.salaryProfiles.filter((x) => x.type == "HAFT").length.toString(),
),
full: Extension.ToThaiNumber(
data4.salaryProfiles.filter((x) => x.type == "FULL").length.toString(),
),
fullHaft: Extension.ToThaiNumber(
data4.salaryProfiles.filter((x) => x.type == "HAFT").length.toString(),
),
notPromoted: Extension.ToThaiNumber(
data4.salaryProfiles.filter((x) => x.type == "NONE").length.toString(),
),
haftSalary: Extension.ToThaiNumber(haftSalary.toString()),
fullSalary: Extension.ToThaiNumber(fullSalary.toString()),
fullHaftSalary: Extension.ToThaiNumber(fullHaftSalary.toString()),
total: Extension.ToThaiNumber((haftSalary + fullSalary + fullHaftSalary).toString()),
summary: Extension.ToThaiNumber(
(
data4.sixPercentAmount -
data4.spentAmount -
haftSalary -
fullSalary -
fullHaftSalary
).toString(),
),
reason: null,
};
}
return new HttpSuccess({
template: "gov2-02",
reportName: "gov2-02",
data: {
date: Extension.ToThaiNumber(
Extension.ToThaiFullDate(new Date(`${salaryPeriod.year}-03-01`)),
),
dateNow: Extension.ToThaiNumber(Extension.ToThaiFullDate(new Date())),
agency: agency,
data1: formattedData1,
data2: formattedData2,
data3: formattedData3,
data4: formattedData4,
},
});
}
} }
/** /**
@ -547,8 +925,12 @@ export class ReportController extends Controller {
(item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") + (item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") +
(item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") + (item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") +
(item.child1 == undefined && item.child1 == null ? "" : item.child1 + "/") + (item.child1 == undefined && item.child1 == null ? "" : item.child1 + "/") +
(item.root == undefined && item.root == null ? "" : item.root)+ (item.root == undefined && item.root == null ? "" : item.root) +
"/" + item.prefix + item.firstName + " " + item.lastName, // สังกัด/ชื่อ-นามสกุล "/" +
item.prefix +
item.firstName +
" " +
item.lastName, // สังกัด/ชื่อ-นามสกุล
posLevel: item.posLevel, posLevel: item.posLevel,
posMasterNo: Extension.ToThaiNumber(String(item.posMasterNo)), posMasterNo: Extension.ToThaiNumber(String(item.posMasterNo)),
amount: amount:
@ -559,8 +941,8 @@ export class ReportController extends Controller {
salaryIncrease2: null, //การเลื่อนเงินเดือนปีก่อนหน้า salaryIncrease2: null, //การเลื่อนเงินเดือนปีก่อนหน้า
score: null, //ผลการประเมินฯ score: null, //ผลการประเมินฯ
remark: null, //หมายเหตุ remark: null, //หมายเหตุ
})) })),
} },
}); });
} }
@ -618,10 +1000,10 @@ export class ReportController extends Controller {
"amountSpecial", "amountSpecial",
], ],
order: { order: {
"posMasterNo": "ASC", posMasterNo: "ASC",
} },
}); });
return new HttpSuccess({ return new HttpSuccess({
template: "gov1-04", template: "gov1-04",
reportName: "gov1-04", reportName: "gov1-04",