แสดงกลุ่มทั้งหมดใน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({
|
||||
relations: ["salaryPeriod", "salaryProfiles"],
|
||||
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(),
|
||||
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 _salaryOrgGROUP2 = await this.salaryOrgRepository.findOne({
|
||||
relations: ["salaryPeriod", "salaryProfiles"],
|
||||
where: {
|
||||
group: Like(
|
||||
`%${body.group.trim().toUpperCase() != "GROUP1" && body.group.trim().toUpperCase() != "GROUP2" ? "GROUP2" : "ZXCASD"}%`,
|
||||
),
|
||||
rootId: item.rootId,
|
||||
snapshot: body.snapshot.trim().toUpperCase(),
|
||||
salaryPeriod: { id: body.period },
|
||||
},
|
||||
});
|
||||
const sum = item.salaryProfiles.reduce((accumulator, object) => {
|
||||
return accumulator + object.amountSpecial;
|
||||
}, 0);
|
||||
const sumGROUP2 =
|
||||
_salaryOrgGROUP2 == null
|
||||
? 0
|
||||
: _salaryOrgGROUP2.salaryProfiles.reduce((accumulator, object) => {
|
||||
return accumulator + object.amountSpecial;
|
||||
}, 0);
|
||||
const data = {
|
||||
org: org,
|
||||
group: item.group,
|
||||
total: item.total,
|
||||
fifteenPercent: item.fifteenPercent,
|
||||
chosen: item.quantityUsed,
|
||||
remaining: item.remainQuota,
|
||||
currentAmount: item.currentAmount,
|
||||
sixPercentAmount: item.sixPercentAmount,
|
||||
spentAmount: item.spentAmount,
|
||||
sixPercentSpentAmount: item.sixPercentAmount - item.spentAmount,
|
||||
useAmount: item.useAmount,
|
||||
remainingAmount: item.remainingAmount,
|
||||
totalAmountSpecial: sum,
|
||||
totalBackup: item.salaryProfiles.filter((x) => x.isReserve == true).length,
|
||||
org: item.root,
|
||||
total: item.total + (_salaryOrgGROUP2 == null ? 0 : _salaryOrgGROUP2.total),
|
||||
fifteenPercent:
|
||||
item.fifteenPercent + (_salaryOrgGROUP2 == null ? 0 : _salaryOrgGROUP2.fifteenPercent),
|
||||
chosen:
|
||||
item.quantityUsed + (_salaryOrgGROUP2 == null ? 0 : _salaryOrgGROUP2.quantityUsed),
|
||||
remaining:
|
||||
item.remainQuota + (_salaryOrgGROUP2 == null ? 0 : _salaryOrgGROUP2.remainQuota),
|
||||
currentAmount:
|
||||
item.currentAmount + (_salaryOrgGROUP2 == null ? 0 : _salaryOrgGROUP2.currentAmount),
|
||||
sixPercentAmount:
|
||||
item.sixPercentAmount +
|
||||
(_salaryOrgGROUP2 == null ? 0 : _salaryOrgGROUP2.sixPercentAmount),
|
||||
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);
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -22,6 +22,13 @@ export class SalaryOrgEmployee extends EntityBase {
|
|||
})
|
||||
rootId: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "orgRoot",
|
||||
length: 255,
|
||||
})
|
||||
root: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "คีย์นอก(FK)ของตาราง orgRevision",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue