แสดงกลุ่มทั้งหมดในdashboard
This commit is contained in:
parent
acbc71c2e6
commit
7280da0b05
3 changed files with 64 additions and 32 deletions
|
|
@ -123,38 +123,68 @@ export class SalaryPeriodController extends Controller {
|
||||||
const _salaryOrg = await this.salaryOrgRepository.find({
|
const _salaryOrg = await this.salaryOrgRepository.find({
|
||||||
relations: ["salaryPeriod", "salaryProfiles"],
|
relations: ["salaryPeriod", "salaryProfiles"],
|
||||||
where: {
|
where: {
|
||||||
group: Like(`%${body.group}%`),
|
group: Like(
|
||||||
|
`%${body.group.trim().toUpperCase() == "GROUP1" ? "GROUP1" : body.group.trim().toUpperCase() == "GROUP2" ? "GROUP2" : "GROUP1"}%`,
|
||||||
|
),
|
||||||
snapshot: body.snapshot.trim().toUpperCase(),
|
snapshot: body.snapshot.trim().toUpperCase(),
|
||||||
salaryPeriod: { period: body.period.trim().toUpperCase(), year: body.year },
|
salaryPeriod: { id: body.period },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const salaryOrg: any[] = [];
|
const salaryOrg: any[] = [];
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
_salaryOrg.map(async (item) => {
|
_salaryOrg.map(async (item) => {
|
||||||
const fullNameParts = [
|
const _salaryOrgGROUP2 = await this.salaryOrgRepository.findOne({
|
||||||
item == null || item.salaryProfiles.length == 0 || item.salaryProfiles[0].root == null
|
relations: ["salaryPeriod", "salaryProfiles"],
|
||||||
? null
|
where: {
|
||||||
: item.salaryProfiles[0].root,
|
group: Like(
|
||||||
];
|
`%${body.group.trim().toUpperCase() != "GROUP1" && body.group.trim().toUpperCase() != "GROUP2" ? "GROUP2" : "ZXCASD"}%`,
|
||||||
const org = fullNameParts.filter((part) => part !== undefined && part !== null).join("/");
|
),
|
||||||
|
rootId: item.rootId,
|
||||||
|
snapshot: body.snapshot.trim().toUpperCase(),
|
||||||
|
salaryPeriod: { id: body.period },
|
||||||
|
},
|
||||||
|
});
|
||||||
const sum = item.salaryProfiles.reduce((accumulator, object) => {
|
const sum = item.salaryProfiles.reduce((accumulator, object) => {
|
||||||
return accumulator + object.amountSpecial;
|
return accumulator + object.amountSpecial;
|
||||||
}, 0);
|
}, 0);
|
||||||
|
const sumGROUP2 =
|
||||||
|
_salaryOrgGROUP2 == null
|
||||||
|
? 0
|
||||||
|
: _salaryOrgGROUP2.salaryProfiles.reduce((accumulator, object) => {
|
||||||
|
return accumulator + object.amountSpecial;
|
||||||
|
}, 0);
|
||||||
const data = {
|
const data = {
|
||||||
org: org,
|
org: item.root,
|
||||||
group: item.group,
|
total: item.total + (_salaryOrgGROUP2 == null ? 0 : _salaryOrgGROUP2.total),
|
||||||
total: item.total,
|
fifteenPercent:
|
||||||
fifteenPercent: item.fifteenPercent,
|
item.fifteenPercent + (_salaryOrgGROUP2 == null ? 0 : _salaryOrgGROUP2.fifteenPercent),
|
||||||
chosen: item.quantityUsed,
|
chosen:
|
||||||
remaining: item.remainQuota,
|
item.quantityUsed + (_salaryOrgGROUP2 == null ? 0 : _salaryOrgGROUP2.quantityUsed),
|
||||||
currentAmount: item.currentAmount,
|
remaining:
|
||||||
sixPercentAmount: item.sixPercentAmount,
|
item.remainQuota + (_salaryOrgGROUP2 == null ? 0 : _salaryOrgGROUP2.remainQuota),
|
||||||
spentAmount: item.spentAmount,
|
currentAmount:
|
||||||
sixPercentSpentAmount: item.sixPercentAmount - item.spentAmount,
|
item.currentAmount + (_salaryOrgGROUP2 == null ? 0 : _salaryOrgGROUP2.currentAmount),
|
||||||
useAmount: item.useAmount,
|
sixPercentAmount:
|
||||||
remainingAmount: item.remainingAmount,
|
item.sixPercentAmount +
|
||||||
totalAmountSpecial: sum,
|
(_salaryOrgGROUP2 == null ? 0 : _salaryOrgGROUP2.sixPercentAmount),
|
||||||
totalBackup: item.salaryProfiles.filter((x) => x.isReserve == true).length,
|
spentAmount:
|
||||||
|
item.spentAmount + (_salaryOrgGROUP2 == null ? 0 : _salaryOrgGROUP2.spentAmount),
|
||||||
|
sixPercentSpentAmount:
|
||||||
|
item.sixPercentAmount -
|
||||||
|
item.spentAmount +
|
||||||
|
(_salaryOrgGROUP2 == null ? 0 : _salaryOrgGROUP2.sixPercentAmount) -
|
||||||
|
(_salaryOrgGROUP2 == null ? 0 : _salaryOrgGROUP2.spentAmount),
|
||||||
|
useAmount: item.useAmount + (_salaryOrgGROUP2 == null ? 0 : _salaryOrgGROUP2.useAmount),
|
||||||
|
remainingAmount:
|
||||||
|
item.remainingAmount +
|
||||||
|
(_salaryOrgGROUP2 == null ? 0 : _salaryOrgGROUP2.remainingAmount),
|
||||||
|
totalAmountSpecial: sum + sumGROUP2,
|
||||||
|
totalBackup:
|
||||||
|
item.salaryProfiles.filter((x) => x.isReserve == true).length +
|
||||||
|
(_salaryOrgGROUP2 == null
|
||||||
|
? 0
|
||||||
|
: _salaryOrgGROUP2.salaryProfiles.filter((x) => x.isReserve == true).length),
|
||||||
};
|
};
|
||||||
salaryOrg.push(data);
|
salaryOrg.push(data);
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -124,26 +124,21 @@ export class SalaryPeriodEmployeeController extends Controller {
|
||||||
const _salaryOrg = await this.salaryOrgRepository.find({
|
const _salaryOrg = await this.salaryOrgRepository.find({
|
||||||
relations: ["salaryPeriod", "salaryProfiles"],
|
relations: ["salaryPeriod", "salaryProfiles"],
|
||||||
where: {
|
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(),
|
snapshot: body.snapshot.trim().toUpperCase(),
|
||||||
salaryPeriod: { period: body.period.trim().toUpperCase(), year: body.year },
|
salaryPeriod: { id: body.period },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const salaryOrg: any[] = [];
|
const salaryOrg: any[] = [];
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
_salaryOrg.map(async (item) => {
|
_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) => {
|
const sum = item.salaryProfiles.reduce((accumulator, object) => {
|
||||||
return accumulator + object.amountSpecial;
|
return accumulator + object.amountSpecial;
|
||||||
}, 0);
|
}, 0);
|
||||||
const data = {
|
const data = {
|
||||||
org: org,
|
org: item.root,
|
||||||
group: item.group,
|
|
||||||
total: item.total,
|
total: item.total,
|
||||||
fifteenPercent: item.fifteenPercent,
|
fifteenPercent: item.fifteenPercent,
|
||||||
chosen: item.quantityUsed,
|
chosen: item.quantityUsed,
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,13 @@ export class SalaryOrgEmployee extends EntityBase {
|
||||||
})
|
})
|
||||||
rootId: string;
|
rootId: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "orgRoot",
|
||||||
|
length: 255,
|
||||||
|
})
|
||||||
|
root: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "คีย์นอก(FK)ของตาราง orgRevision",
|
comment: "คีย์นอก(FK)ของตาราง orgRevision",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue