feat(api): explain dashboard chargeability by chapter

This commit is contained in:
2026-03-31 23:34:03 +02:00
parent a8fcc4dacb
commit 703406a76b
7 changed files with 403 additions and 31 deletions
@@ -838,6 +838,38 @@ describe("dashboard router", () => {
},
},
]);
vi.mocked(getDashboardChargeabilityOverview).mockResolvedValue({
rows: [
{
id: "res_1",
eid: "pparker",
displayName: "Peter Parker",
chapter: "Delivery",
chargeabilityTarget: 78,
actualChargeability: 70,
expectedChargeability: 76,
derivation: {
weeklyAvailabilityHours: 40,
baseWorkingDays: 22,
effectiveWorkingDayEquivalent: 21,
baseAvailableHours: 176,
effectiveAvailableHours: 168,
publicHolidayCount: 1,
publicHolidayWorkdayCount: 1,
publicHolidayHoursDeduction: 8,
absenceDayEquivalent: 0,
absenceHoursDeduction: 0,
actualBookedHours: 117.6,
expectedBookedHours: 127.7,
targetBookedHours: 131,
unassignedHours: 40.3,
},
},
],
top: [],
watchlist: [],
month: "2026-03",
});
const caller = createControllerCaller({});
const result = await caller.getDetail({ section: "all" });
@@ -929,8 +961,28 @@ describe("dashboard router", () => {
chargeabilityByChapter: [
{
chapter: "Delivery",
headcount: 4,
headcount: 1,
avgTargetPct: 78,
avgActualPct: 70,
avgExpectedPct: 76,
gapToTargetPct: 8,
avgTarget: "78%",
avgActual: "70%",
avgExpected: "76%",
explainability: {
month: "2026-03",
resourceCount: 1,
derivedHeadcount: 1,
baseAvailableHours: 176,
effectiveAvailableHours: 168,
actualBookedHours: 117.6,
expectedBookedHours: 127.7,
targetBookedHours: 131,
publicHolidayHoursDeduction: 8,
absenceDayEquivalent: 0,
absenceHoursDeduction: 0,
unassignedHours: 40.3,
},
},
],
});
@@ -943,6 +995,14 @@ describe("dashboard router", () => {
groupBy: "project",
}),
);
expect(getDashboardChargeabilityOverview).toHaveBeenCalledWith(
expect.anything(),
expect.objectContaining({
includeProposed: false,
topN: 10,
watchlistThreshold: 15,
}),
);
});
});
});