feat(stats): show gross earned leave by rule (#67)
This commit is contained in:
1 parent
3fbf9c3172
commit
da08ee054d
10 files changed
+571
-9
No files matched your search
@@ -202,6 +202,25 @@ export class CalendarYear {
|
||||
}
|
||||
|
||||
protected readonly displayedPlan = this.userInput.displayedPlanSignal;
|
||||
protected readonly earnedLeave = computed(() => {
|
||||
const byRule = new Map<string, { ruleId: string; label: string; quantity: number }>();
|
||||
for (const contribution of this.displayedPlan()?.ifThenContributions ?? []) {
|
||||
const entitlement = contribution.earnedEntitlement;
|
||||
if (!entitlement?.added || entitlement.quantity <= 0) continue;
|
||||
const entry = byRule.get(contribution.ruleId) ?? {
|
||||
ruleId: contribution.ruleId,
|
||||
label: contribution.label,
|
||||
quantity: 0,
|
||||
};
|
||||
entry.quantity += entitlement.quantity;
|
||||
byRule.set(entry.ruleId, entry);
|
||||
}
|
||||
const contributions = [...byRule.values()];
|
||||
return {
|
||||
total: contributions.reduce((total, contribution) => total + contribution.quantity, 0),
|
||||
contributions,
|
||||
};
|
||||
});
|
||||
|
||||
protected readonly planExplanation = computed(() => {
|
||||
const explanation = this.planningExplanation();
|
||||
|
||||
Reference in new issue
Block a user