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
@@ -65,6 +65,13 @@ export interface DashboardChargeabilityRow {
derivation?: DashboardChargeabilityDerivation;
}
export interface DashboardChargeabilityOverview {
rows: DashboardChargeabilityRow[];
top: DashboardChargeabilityRow[];
watchlist: DashboardChargeabilityRow[];
month: string;
}
function toIsoDate(value: Date): string {
return value.toISOString().slice(0, 10);
}
@@ -160,7 +167,7 @@ function summarizeDerivation(
export async function getDashboardChargeabilityOverview(
db: PrismaClient,
input: GetDashboardChargeabilityOverviewInput,
) {
): Promise<DashboardChargeabilityOverview> {
const now = input.now ?? new Date();
const start = new Date(now.getFullYear(), now.getMonth(), 1);
const end = new Date(now.getFullYear(), now.getMonth() + 1, 0);
@@ -294,6 +301,7 @@ export async function getDashboardChargeabilityOverview(
});
return {
rows: stats,
top: [...stats]
.sort((left, right) => right.actualChargeability - left.actualChargeability),
watchlist: [...stats]