diff --git a/app/(app)/page.tsx b/app/(app)/page.tsx index 18564ae..6519bf7 100644 --- a/app/(app)/page.tsx +++ b/app/(app)/page.tsx @@ -15,7 +15,8 @@ import { parseArten, parseZeitraum, } from "@/lib/dashboard-filter"; -import { loadDashboardData } from "@/lib/dashboard-data"; +import { EINTRITT_TYPEN, loadDashboardData } from "@/lib/dashboard-data"; +import { werteParameter } from "@/lib/werteliste"; import { KPI_ERKLAERUNGEN } from "@/lib/kpi-erklaerungen"; import { addDaysIso, fmtName, todayIso } from "@/lib/format"; import { anzeige } from "@/lib/anzeige"; @@ -276,7 +277,7 @@ export default async function DashboardPage({ label: "Eintritte (YTD)", value: hiresYtd, tone: "success", - href: `/reports?mode=events&eventType=Eintritt&from=${yearStart}&to=${ytdBis}`, + href: `/reports?${new URLSearchParams({ mode: "events", eventType: werteParameter(EINTRITT_TYPEN) ?? "", from: yearStart, to: ytdBis })}`, }, { label: "Austritte (YTD)", diff --git a/lib/dashboard-data.ts b/lib/dashboard-data.ts index 4f7762e..b859350 100644 --- a/lib/dashboard-data.ts +++ b/lib/dashboard-data.ts @@ -34,6 +34,14 @@ export type DashboardParams = { arten: AnstehendArt[]; }; +/** + * Was die Kachel „Eintritte (YTD)" zählt. Eine Übernahme von extern zählt wie + * ein Eintritt, fachlich so vorgegeben: die Person kommt neu in den eigenen + * Bestand. Der Verweis der Kachel auf die Berichte trägt dieselbe Liste — + * sonst zeigte der Bericht eine kleinere Zahl als die Kachel. + */ +export const EINTRITT_TYPEN: readonly HistoryEventType[] = ["Eintritt", "Wiedereintritt", "Übernahme"]; + export async function loadDashboardData(tx: Tx, p: DashboardParams) { const { userId, today, yearStart, ytdBis, bisIso, arten } = p; const zeigt = (art: AnstehendArt) => arten.includes(art); @@ -67,13 +75,9 @@ export async function loadDashboardData(tx: Tx, p: DashboardParams) { .orderBy("id") ).as("staffRows"), - // Entries/exits count history events, which is what the linked report - // counts too. `entry_date` would also sweep up rehires, whose event is - // logged as 'Wiedereintritt' — the tile and its destination would then - // show different numbers for the same year. - // Eine Übernahme von extern zählt wie ein Eintritt, fachlich so - // vorgegeben: die Person kommt neu in den eigenen Bestand. - jsonObjectFrom(countIn(eb, ["Eintritt", "Wiedereintritt", "Übernahme"])).as("hiresYtd"), + // Ein- und Austritte zählen Ereignisse der Historie, so wie der + // verlinkte Bericht. Was dazugehört, steht bei EINTRITT_TYPEN. + jsonObjectFrom(countIn(eb, EINTRITT_TYPEN)).as("hiresYtd"), jsonObjectFrom(countIn(eb, ["Austritt"])).as("exitsYtd"), ...orgMapsAbfragen(eb),