Uebersicht: Eintritte (YTD) verweist auf dieselben Ereignistypen, die sie zaehlt
Some checks failed
CI / Migrationen auf leerer Datenbank (push) Has been cancelled
CI / Ausrollen (push) Has been cancelled
CI / Lint, Typen, Tests, Build (push) Has been cancelled

Die Kachel zaehlt Eintritt, Wiedereintritt und Uebernahme, der Verweis
oeffnete den Bericht nur mit "Eintritt" - der Bericht zeigte damit weniger
Ereignisse als die Kachel. Beide lesen jetzt EINTRITT_TYPEN.

Geprueft: lint, tsc, Unit-Tests, Waechter.
This commit is contained in:
2026-11-03 09:36:35 +01:00
parent 3134229a72
commit 5abaaa36dd
2 changed files with 14 additions and 9 deletions

View File

@@ -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)",

View File

@@ -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),