แสดงกลุ่มทั้งหมดในdashboard

This commit is contained in:
Kittapath 2024-03-28 16:57:13 +07:00
parent acbc71c2e6
commit 7280da0b05
3 changed files with 64 additions and 32 deletions

View file

@ -124,26 +124,21 @@ export class SalaryPeriodEmployeeController extends Controller {
const _salaryOrg = await this.salaryOrgRepository.find({
relations: ["salaryPeriod", "salaryProfiles"],
where: {
group: Like(`%${body.group.trim().toUpperCase()}%`),
group: Like(
`%${body.group.trim().toUpperCase() == "GROUP1" ? "GROUP1" : body.group.trim().toUpperCase() == "GROUP2" ? "GROUP2" : "GROUP1"}%`,
),
snapshot: body.snapshot.trim().toUpperCase(),
salaryPeriod: { period: body.period.trim().toUpperCase(), year: body.year },
salaryPeriod: { id: body.period },
},
});
const salaryOrg: any[] = [];
await Promise.all(
_salaryOrg.map(async (item) => {
const fullNameParts = [
item == null || item.salaryProfiles.length == 0 || item.salaryProfiles[0].root == null
? null
: item.salaryProfiles[0].root,
];
const org = fullNameParts.filter((part) => part !== undefined && part !== null).join("/");
const sum = item.salaryProfiles.reduce((accumulator, object) => {
return accumulator + object.amountSpecial;
}, 0);
const data = {
org: org,
group: item.group,
org: item.root,
total: item.total,
fifteenPercent: item.fifteenPercent,
chosen: item.quantityUsed,