Berichte: Kostenstelle als Filter und als Gruppierung
All checks were successful
CI / Lint, Typen, Tests, Build (push) Successful in 12m3s
CI / Ausrollen (push) Successful in 11s
CI / Migrationen auf leerer Datenbank (push) Successful in 10m40s

Im Bestand laesst sich nach Kostenstelle filtern ("Alle Kostenstellen")
und gruppieren ("Kostenstelle", Planstellen ohne Kontierung als eigene
Gruppe). Gemeint ist die Kontierung der Planstelle, auf der jemand am
Stichtag sitzt. Der Filter gilt auch fuer die Exporte dieser Seite.

Geprueft: lint, tsc, 950 Tests, Uebergabe-Waechter
This commit is contained in:
2026-10-20 16:08:02 +02:00
parent 0294c792a4
commit ae4918fc6d
7 changed files with 70 additions and 6 deletions

View File

@@ -31,6 +31,7 @@ type SearchParams = Record<string, string | string[] | undefined> & {
split?: string;
division?: string;
location?: string;
kostenstelle?: string;
status?: string;
asOf?: string;
eventType?: string;
@@ -66,8 +67,8 @@ export default async function ReportsPage({ searchParams }: { searchParams: Prom
// Alles in einer Transaktion — dort gilt der Sitzungskontext, und der
// Lesestand ist über alle Abfragen hinweg derselbe.
const { lookups, units, locations, events, employees, savedReports } = await withUser(userId, async (tx) => {
const [{ lookups, units, locations }, events, employees, savedReports] = await Promise.all([
const { lookups, units, locations, events, employees, savedReports, kostenstellen } = await withUser(userId, async (tx) => {
const [{ lookups, units, locations }, events, employees, savedReports, kostenstellen] = await Promise.all([
loadOrgLookups(tx),
mode === "events"
? loadEventHistory(tx, {
@@ -83,6 +84,7 @@ export default async function ReportsPage({ searchParams }: { searchParams: Prom
? loadSnapshotEmployees(tx, {
division: params.division,
location: params.location,
kostenstelle: params.kostenstelle,
status: params.status,
criteria,
asOf,
@@ -96,8 +98,11 @@ export default async function ReportsPage({ searchParams }: { searchParams: Prom
.orderBy("created_at", "desc")
.execute()
: Promise.resolve([]),
// Für den Filter: alle Kostenstellen, auch beendete — ein Stichtag in
// der Vergangenheit kann eine meinen, die es heute nicht mehr gibt.
tx.selectFrom("cost_centers").select(["id", "code", "name"]).orderBy("code").execute(),
]);
return { lookups, units, locations, events, employees, savedReports };
return { lookups, units, locations, events, employees, savedReports, kostenstellen };
});
if (mode === "events") {
@@ -136,6 +141,7 @@ export default async function ReportsPage({ searchParams }: { searchParams: Prom
filters={{
division: params.division ?? "",
location: params.location ?? "",
kostenstelle: params.kostenstelle ?? "",
status: params.status ?? "",
}}
criteria={criteria}
@@ -144,6 +150,7 @@ export default async function ReportsPage({ searchParams }: { searchParams: Prom
recordCount={employees.length}
units={units}
locations={locations}
kostenstellen={kostenstellen}
savedReports={savedReports}
/>
</Suspense>

View File

@@ -73,6 +73,7 @@ export async function GET(request: NextRequest) {
const employees = await loadSnapshotEmployees(tx, {
division: params.get("division") ?? undefined,
location: params.get("location") ?? undefined,
kostenstelle: params.get("kostenstelle") ?? undefined,
status: params.get("status") ?? undefined,
criteria: parseCriteria((k) => params.get(k)),
asOf,