Berichte: Kostenstelle als Filter und als Gruppierung
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:
@@ -2,6 +2,7 @@ import type { SelectQueryBuilder } from "kysely";
|
||||
import type { Schema } from "./db/schema";
|
||||
import type { Tx } from "./db";
|
||||
import { ancestorsOf, loadOrgMaps, subtreeOf, type OrgMaps } from "./org";
|
||||
import { loadKontierungen } from "./cost-centers";
|
||||
import { loadPlacements } from "./placement";
|
||||
import type { Austrittsart } from "./types";
|
||||
import { LEERE_CRITERIA, passtImSpeicher, type Criteria } from "./report-criteria";
|
||||
@@ -40,6 +41,8 @@ export type ReportFilters = {
|
||||
/** Id einer Organisationseinheit; wirkt auf die Einheit *und alles darunter*. */
|
||||
division?: string;
|
||||
location?: string;
|
||||
/** Id einer Kostenstelle; gemeint ist die Kontierung der Planstelle zum Stichtag. */
|
||||
kostenstelle?: string;
|
||||
status?: string;
|
||||
/** Alles Weitere — siehe lib/report-criteria.ts. */
|
||||
criteria?: Criteria;
|
||||
@@ -235,12 +238,15 @@ export async function loadSnapshotEmployees(tx: Tx, filters: SnapshotFilters): P
|
||||
return applyCriteria(q, filters.criteria ?? LEERE_CRITERIA);
|
||||
}
|
||||
|
||||
const [data, dependentsCounts, placements, orgMaps, hrNamen] = await Promise.all([
|
||||
const [data, dependentsCounts, placements, orgMaps, hrNamen, kontierung] = await Promise.all([
|
||||
snapshotQuery().execute(),
|
||||
loadDependentsCounts(tx),
|
||||
loadPlacements(tx, { asOf }),
|
||||
filters.division ? loadOrgMaps(tx) : Promise.resolve(null),
|
||||
loadHrNamen(tx),
|
||||
// Die Kostenstelle hängt an der Planstelle, nicht an der Person: gelesen
|
||||
// wird die Kontierung der Planstelle, auf der jemand am Stichtag sitzt.
|
||||
loadKontierungen(tx, { asOf }),
|
||||
]);
|
||||
|
||||
// Der Bereichsfilter meint den ganzen Teilbaum: „Produktion" schliesst
|
||||
@@ -257,8 +263,11 @@ export async function loadSnapshotEmployees(tx: Tx, filters: SnapshotFilters): P
|
||||
const orgUnitId = placement?.current ? placement.orgUnitId : null;
|
||||
if (allowedUnits && (!orgUnitId || !allowedUnits.has(orgUnitId))) continue;
|
||||
if (!passtImSpeicher({ work_days: e.work_days, dependentsCount: dependentsCounts.get(e.id) ?? 0 }, criteria)) continue;
|
||||
const kst = placement?.current ? (kontierung.get(placement.positionId) ?? null) : null;
|
||||
if (filters.kostenstelle && kst?.id !== filters.kostenstelle) continue;
|
||||
|
||||
withDerivedStatus.push({
|
||||
kostenstelle: kst ? `${kst.code} · ${kst.name}` : null,
|
||||
id: e.id,
|
||||
first_name: e.first_name,
|
||||
last_name: e.last_name,
|
||||
|
||||
Reference in New Issue
Block a user