diff --git a/.env.example b/.env.example
index a419765..ce49ea9 100644
--- a/.env.example
+++ b/.env.example
@@ -68,3 +68,10 @@ CRON_SECRET=
# und hat jemand in der Auswahl kein Geburtsdatum, lehnt der Export mit einem
# Hinweis ab; die übrige Anwendung ist nicht betroffen.
LOLYO_STARTPASSWORT=
+
+# ── Testsystem ───────────────────────────────────────────────────────
+#
+# Auf einer Testinstallation auf 1 setzen: jede Seite trägt dann oben den
+# Schriftzug „Testsystem", und der Titel im Browser-Tab beginnt damit. In der
+# Produktion leer lassen.
+TESTSYSTEM=
diff --git a/README.md b/README.md
index c8dd6bc..be94aca 100644
--- a/README.md
+++ b/README.md
@@ -67,6 +67,7 @@ Kurzfassung — alles davon ist rein server-seitig:
| `AUTH_URL` | Adresse, unter der die Anwendung von aussen erreichbar ist |
| `CRON_SECRET` | Schützt `/api/cron/apply-pending-changes` |
| `LOLYO_STARTPASSWORT` | Ersatzpasswort im LOLYO-Export für Personen ohne Geburtsdatum (sonst ist das Passwort das Geburtsdatum als TT.MM.JJJJ). Fehlt der Wert und hat jemand in der Auswahl kein Geburtsdatum, lehnt der Export ab |
+| `TESTSYSTEM` | `1` auf einer Testinstallation: Schriftzug „Testsystem" oben auf jeder Seite und im Titel des Browser-Tabs. In der Produktion leer |
**Es gibt keine `NEXT_PUBLIC_*`-Variablen.** Nichts wird in das Browser-Bundle
eingebacken, weil der Browser mit nichts spricht ausser der Anwendung selbst.
diff --git a/actions/employees.ts b/actions/employees.ts
index b08d923..911957e 100644
--- a/actions/employees.ts
+++ b/actions/employees.ts
@@ -144,7 +144,8 @@ export async function hireEmployee(payload: {
emergency_contact_phone?: string;
emergency_contact_relation?: string;
is_laterale_fuehrung?: boolean;
- is_c_level?: boolean;
+ /** Code aus lib/c-level.ts; "" leert die Angabe. */
+ c_level?: string;
/** Form der Beschäftigung — chk_mitarbeiterart. Leer heisst „unverändert". */
mitarbeiterart?: string;
has_kuendigungsschutz?: boolean;
diff --git a/app/(app)/employees/[id]/checkliste/page.tsx b/app/(app)/employees/[id]/checkliste/page.tsx
index 5dc6334..7bd0b77 100644
--- a/app/(app)/employees/[id]/checkliste/page.tsx
+++ b/app/(app)/employees/[id]/checkliste/page.tsx
@@ -30,8 +30,10 @@ export async function generateMetadata({ params, searchParams }: Props) {
const [{ id }, sp] = await Promise.all([params, searchParams]);
const art = parseArt(sp.art);
const daten = await withUser(await currentUserId(), (tx) => loadChecklistPrint(tx, id, art));
- if (!daten) return { title: artTitel(art) };
- return { title: checklistDateiname(art, daten.kopf, todayIso()) };
+ // Absolut: der Titel ist der Dateiname, eine Vorlage des Layouts gehört
+ // nicht hinein.
+ if (!daten) return { title: { absolute: artTitel(art) } };
+ return { title: { absolute: checklistDateiname(art, daten.kopf, todayIso()) } };
}
export default async function ChecklistPrintPage({ params, searchParams }: Props) {
diff --git a/app/api/export/employees/route.ts b/app/api/export/employees/route.ts
index d75fe76..a83c2f2 100644
--- a/app/api/export/employees/route.ts
+++ b/app/api/export/employees/route.ts
@@ -111,7 +111,9 @@ function employeeExportColumns(
get: (e) => (notfallkontakte.get(e.id) ?? []).map((k) => anzeige(k.relation) ?? "").join("; "),
},
{ header: "Laterale Führung", get: (e) => e.is_laterale_fuehrung },
- { header: "C-Level", get: (e) => e.is_c_level },
+ // Code und Bezeichnung getrennt: der Code ist das, was andere Systeme
+ // weiterverarbeiten, die Bezeichnung das, was ein Mensch liest.
+ { header: "C-Level", get: (e) => e.c_level },
{ header: "Hay-Grade", get: (e) => e.paygrade },
{ header: "VL", get: (e) => e.vl },
{ header: "Bonusanspruch", get: (e) => e.has_bonusanspruch },
diff --git a/app/layout.tsx b/app/layout.tsx
index 783cfda..0745600 100644
--- a/app/layout.tsx
+++ b/app/layout.tsx
@@ -1,6 +1,8 @@
import type { Metadata, Viewport } from "next";
import { Barlow } from "next/font/google";
+import { TestsystemSchriftzug } from "@/components/shell/TestsystemSchriftzug";
import { ToastProvider } from "@/components/ui/Toast";
+import { istTestsystem, TESTSYSTEM_SCHRIFTZUG } from "@/lib/testsystem";
import "./globals.css";
// ═══ Die Schrift ═══
@@ -31,7 +33,7 @@ const din = Barlow({
weight: ["400", "600", "700", "800"],
});
-export const metadata: Metadata = {
+const METADATA: Metadata = {
title: "Alpenwerk HR",
description: "HR-Stammdaten- und Organisationsmanagement für Alpenwerk Industrie GmbH",
// Added to the home screen on iOS this opens without Safari's chrome and
@@ -44,6 +46,15 @@ export const metadata: Metadata = {
manifest: "/manifest.webmanifest",
};
+// Als Funktion, damit TESTSYSTEM bei der Anfrage gelesen wird und nicht beim
+// Bauen. Die Vorlage setzt den Schriftzug auch vor die Titel der Unterseiten;
+// Seiten, deren Titel als Dateiname beim Drucken dient, setzen ihn absolut.
+export function generateMetadata(): Metadata {
+ if (!istTestsystem()) return METADATA;
+ const vorsatz = `[${TESTSYSTEM_SCHRIFTZUG}]`;
+ return { ...METADATA, title: { default: `${vorsatz} Alpenwerk HR`, template: `${vorsatz} %s` } };
+}
+
export const viewport: Viewport = {
width: "device-width",
initialScale: 1,
@@ -63,6 +74,7 @@ export default function RootLayout({
return (
+ {istTestsystem() && }
{children}
diff --git a/components/employees/EmployeeFilters.tsx b/components/employees/EmployeeFilters.tsx
index 2176ef5..0328cae 100644
--- a/components/employees/EmployeeFilters.tsx
+++ b/components/employees/EmployeeFilters.tsx
@@ -5,12 +5,14 @@ import { useEffect, useState } from "react";
import { FILTER_SELECT_CLASS } from "@/components/ui/Field";
import { SearchInput } from "@/components/ui/SearchInput";
import { AUSTRITT_GEPLANT } from "@/lib/employee-status-filter";
+import { zuweisbareStandorte } from "@/lib/standorte";
type EmployeeFiltersProps = {
/** Der ganze Baum, in Tiefensuche-Reihenfolge. */
units: { id: string; name: string; unit_type: string }[];
depthOf: Map;
- locations: { id: string; name: string }[];
+ /** Zur Auswahl kommen nur Standorte, auf denen jemand sitzen kann. */
+ locations: { id: string; name: string; parent_id: string | null }[];
};
// Aktiv and Langzeitabwesenheit are separate statuses — somebody on a
@@ -107,7 +109,7 @@ export function EmployeeFilters({ units, depthOf, locations }: EmployeeFiltersPr
className={FILTER_SELECT_CLASS}
>
Alle Standorte
- {locations.map((l) => (
+ {zuweisbareStandorte(locations).map((l) => (
{l.name}
diff --git a/components/employees/RoleEmploymentFields.tsx b/components/employees/RoleEmploymentFields.tsx
index 245d08e..45721df 100644
--- a/components/employees/RoleEmploymentFields.tsx
+++ b/components/employees/RoleEmploymentFields.tsx
@@ -15,6 +15,7 @@ import {
KUENDIGUNGSSCHUTZ_GRUENDE,
} from "@/lib/kuendigungsschutz";
import { MITARBEITERARTEN } from "@/lib/mitarbeiterart";
+import { C_LEVEL_AUSWAHL } from "@/lib/c-level";
import { anzeigeAuswahl } from "@/lib/anzeige";
import { sortiereWochentage, WOCHENTAGE } from "@/lib/wochentage";
import { KOLLEKTIVVERTRAEGE } from "@/lib/kollektivvertrag";
@@ -64,7 +65,8 @@ export type RoleEmploymentValue = {
*/
dienstwagenArt: DienstwagenArt;
isLateraleFuehrung: boolean;
- isCLevel: boolean;
+ /** Code aus lib/c-level.ts; "" heisst nicht erfasst. */
+ cLevel: string;
/** Betriebsrat, Mutterschutz, Karenz, begünstigte Behinderung, Lehre. */
hasKuendigungsschutz: boolean;
/**
@@ -218,6 +220,16 @@ export function RoleEmploymentFields({
onChange={(v) => onChange({ collectiveAgreement: v as CollectiveAgreement })}
options={KOLLEKTIVVERTRAEGE.map((k) => ({ value: k, label: k }))}
/>
+ {/* Freiwillig: „Bitte wählen…" ist ein wählbarer Eintrag und kein
+ gesperrter Platzhalter, damit sich eine Angabe auch wieder
+ entfernen lässt. */}
+ onChange({ cLevel: v })}
+ options={[{ value: "", label: "Bitte wählen…" }, ...C_LEVEL_AUSWAHL]}
+ />
{/* Toggle group, not a set of fields: a fieldset names the group, and
@@ -259,7 +271,7 @@ export function RoleEmploymentFields({
{day}
onChange({ isLateraleFuehrung: e.target.checked })} />
Laterale Führung
-
- onChange({ isCLevel: e.target.checked })} />
- C-Level
-
void;
+ standorte: readonly Standort[];
+ required?: boolean;
+ /** Land in Klammern dahinter, wie bei der Einstellung. */
+ mitLand?: boolean;
+ hint?: string;
+}) {
+ // Zustand, weil „Shop" gewählt sein kann, ohne dass schon ein Wert feststeht.
+ const [ober, setOber] = useState(() => oberstandortVon(standorte, value));
+ const unter = unterstandorte(standorte, ober);
+ const oberEintrag = standorte.find((s) => s.id === ober);
+
+ const beschriftung = (s: Standort, name: string) => (mitLand && s.country ? `${name} (${s.country})` : name);
+
+ return (
+ <>
+ {
+ setOber(id);
+ onChange(unterstandorte(standorte, id).length > 0 ? "" : id);
+ }}
+ placeholder="Bitte wählen…"
+ options={oberstandorte(standorte).map((s) => ({ value: s.id, label: beschriftung(s, s.name) }))}
+ hint={unter.length > 0 ? undefined : hint}
+ />
+ {unter.length > 0 && (
+ s.id === value) ? value : ""}
+ onChange={onChange}
+ placeholder="Bitte wählen…"
+ options={unter.map((s) => ({ value: s.id, label: kurzname(s, oberEintrag) }))}
+ hint={hint}
+ />
+ )}
+ >
+ );
+}
diff --git a/components/employees/VerhaeltnisField.tsx b/components/employees/VerhaeltnisField.tsx
index 9e31ab5..9d2d0f0 100644
--- a/components/employees/VerhaeltnisField.tsx
+++ b/components/employees/VerhaeltnisField.tsx
@@ -4,6 +4,7 @@ import { useState } from "react";
import { SelectField, TextField } from "@/components/ui/Field";
import { anzeigeAuswahl } from "@/lib/anzeige";
import { EMERGENCY_RELATIONS } from "@/lib/types";
+import { istFreiesVerhaeltnis, SONSTIGE } from "@/lib/verhaeltnis";
// Das Verhältnis zum Notfallkontakt: Auswahl, und unter „Sonstige" ein
// Freifeld.
@@ -23,12 +24,7 @@ import { EMERGENCY_RELATIONS } from "@/lib/types";
// nimmt einen gespeicherten Wert, der nicht in der Liste steht, mit in die
// Auswahl auf.
-const SONSTIGE = "Sonstige";
-
-/** Ob ein gespeicherter Wert frei eingetragen wurde. */
-export function istFreiesVerhaeltnis(wert: string): boolean {
- return wert.trim() !== "" && !(EMERGENCY_RELATIONS as readonly string[]).includes(wert);
-}
+export { istFreiesVerhaeltnis };
export function VerhaeltnisField({
value,
diff --git a/components/employees/panels/DatenAendernPanel.tsx b/components/employees/panels/DatenAendernPanel.tsx
index e20004d..3e285a3 100644
--- a/components/employees/panels/DatenAendernPanel.tsx
+++ b/components/employees/panels/DatenAendernPanel.tsx
@@ -33,6 +33,7 @@ import { fmtDate, fmtFullName, todayIso } from "@/lib/format";
import { plzHinweis, pruefePlzImFormular } from "@/lib/plz";
import { requiresAustrianSvnr, svnrErfassbar } from "@/lib/svnr";
import { vertragsangabenVollstaendig } from "@/lib/vertragsangaben";
+import { nachkommaFehler } from "@/lib/wochenstunden";
import { NotfallkontaktSection } from "@/components/employees/NotfallkontaktSection";
import { AustrittZuruecknehmen } from "@/components/employees/AustrittZuruecknehmen";
import { EintrittPlanstelleBerichtigen } from "@/components/employees/EintrittPlanstelleBerichtigen";
@@ -205,7 +206,7 @@ export function DatenAendernPanel({
behinderungBis: employee.behinderung_bis ?? "",
dienstwagenArt: employee.dienstwagen_art ?? "Verbrenner",
isLateraleFuehrung: employee.is_laterale_fuehrung ?? false,
- isCLevel: employee.is_c_level ?? false,
+ cLevel: employee.c_level ?? "",
});
function updateRole(patch: Partial) {
setRole((prev) => ({ ...prev, ...patch }));
@@ -233,6 +234,11 @@ export function DatenAendernPanel({
showToast(geburtFehler, "error");
return;
}
+ const nachkomma = nachkommaFehler(weeklyHours);
+ if (nachkomma) {
+ showToast(nachkomma, "error");
+ return;
+ }
if (employmentType === "Teilzeit" && (Number(weeklyHours) <= 0 || Number(weeklyHours) >= 38.5)) {
showToast("Wochenstunden bei Teilzeit müssen zwischen 0 und 38,5 liegen.", "error");
return;
@@ -382,7 +388,7 @@ export function DatenAendernPanel({
? { teilzeit_art: teilzeit.variante, teilzeit_bis: teilzeit.bis }
: {}),
is_laterale_fuehrung: role.isLateraleFuehrung,
- is_c_level: role.isCLevel,
+ c_level: role.cLevel,
arbeitszeitmodell: arbeitszeitFuerDb(role.arbeitszeitmodell, role.workDays),
},
});
@@ -533,7 +539,7 @@ export function DatenAendernPanel({
label="Wochenstunden"
dense
type="number"
- step="0.5"
+ step="0.01"
value={weeklyHours}
disabled={employmentType === "Vollzeit"}
onChange={setWeeklyHours}
diff --git a/components/employees/panels/KarenzPanel.tsx b/components/employees/panels/KarenzPanel.tsx
index 8c90060..e5dfa5b 100644
--- a/components/employees/panels/KarenzPanel.tsx
+++ b/components/employees/panels/KarenzPanel.tsx
@@ -10,6 +10,7 @@ import { useToast } from "@/components/ui/Toast";
import { ABSENCE_TYPES, absenceLabel, RUECKKEHR_GRUENDE } from "@/lib/absence";
import { abwesenheitsplan, type PlanZeile } from "@/lib/abwesenheitsplan";
import { fmtDate, fmtName } from "@/lib/format";
+import { nachkommaFehler } from "@/lib/wochenstunden";
import type { Database, EmploymentStatus } from "@/lib/types";
type EmployeeRow = Database["public"]["Tables"]["employees"]["Row"];
@@ -112,7 +113,7 @@ export function KarenzPanel({
async function handleRueckkehr() {
if (!returnDate) {
- showToast("Bitte Rückkehrdatum angeben.", "error");
+ showToast("Bitte angeben, wann die Abwesenheit endet.", "error");
return;
}
if (employmentMode === "Teilzeit") {
@@ -124,6 +125,11 @@ export function KarenzPanel({
showToast("Wochenstunden müssen zwischen 0 und 38,5 liegen.", "error");
return;
}
+ const nachkomma = nachkommaFehler(weeklyHours);
+ if (nachkomma) {
+ showToast(nachkomma, "error");
+ return;
+ }
}
setPending(true);
const result = await rueckkehrAnpassen({
@@ -163,7 +169,9 @@ export function KarenzPanel({
setFolgeAnlegen(false) : onClose}>
{folgeAnlegen ? "Zurück" : "Abbrechen"}
- {isOnKarenz && !folgeAnlegen && !plan.folgende && (
+ {/* Eine anschliessende Abwesenheit gibt es nur nach der Wochenhilfe,
+ fachlich so vorgegeben: auf den Mutterschutz folgt die Karenz. */}
+ {isOnKarenz && istWochenhilfe && !folgeAnlegen && !plan.folgende && (
setFolgeAnlegen(true)}>
Anschliessende Abwesenheit planen
@@ -209,7 +217,7 @@ export function KarenzPanel({
)}
{absenceLabel(status, employee.absence_type)}
{employee.karenz_start_date ? ` seit ${fmtDate(employee.karenz_start_date)}` : ""}
- {bisherigeRueckkehr ? ` · Rückkehr geplant am ${fmtDate(bisherigeRueckkehr)}` : " · Rückkehr offen"}
+ {bisherigeRueckkehr ? ` · endet am ${fmtDate(bisherigeRueckkehr)}` : " · Ende offen"}
{plan.folgende && (
Danach geplant: {plan.folgende.art ?? "Langzeitabwesenheit"} ab{" "}
{fmtDate(plan.folgende.datum)}
- {plan.folgende.rueckkehr ? `, Rückkehr ${fmtDate(plan.folgende.rueckkehr)}` : ""}
+ {plan.folgende.rueckkehr ? `, endet am ${fmtDate(plan.folgende.rueckkehr)}` : ""}
)}
0 && (
- ({ value: l.id, label: l.name }))}
+ standorte={locations}
hint="Wechselt mit der Versetzung zum selben Tag; sonst bleibt der bisherige."
/>
)}
diff --git a/components/employees/tabs/VertragTab.tsx b/components/employees/tabs/VertragTab.tsx
index c64cae8..0cff082 100644
--- a/components/employees/tabs/VertragTab.tsx
+++ b/components/employees/tabs/VertragTab.tsx
@@ -107,7 +107,7 @@ export function VertragTab({
["Dienstwagen", ohneVorgabe(employee, ["has_dienstwagen"], employee.has_dienstwagen ? dienstwagenLabel(employee.dienstwagen_art) : "Nein")],
["Betriebsrat", ohneVorgabe(employee, ["is_betriebsrat"], employee.is_betriebsrat ? "Ja" : "Nein")],
["Laterale Führung", ohneVorgabe(employee, ["is_laterale_fuehrung"], employee.is_laterale_fuehrung ? "Ja" : "Nein")],
- ["C-Level", ohneVorgabe(employee, ["is_c_level"], employee.is_c_level ? "Ja" : "Nein")],
+ ["C-Level", employee.c_level || "–"],
// Das Enddatum steht gleich dabei: „Ja" allein liesse offen, ob der
// Schutz noch läuft, und genau danach fragt man.
// Die Teilzeitvariante gehört neben die Stunden: sie erklärt, warum sie
diff --git a/components/hire/HireWizard.tsx b/components/hire/HireWizard.tsx
index 15182e0..7f76658 100644
--- a/components/hire/HireWizard.tsx
+++ b/components/hire/HireWizard.tsx
@@ -60,7 +60,7 @@ type HireWizardProps = {
/** Ein neuer Entwurf ist angelegt — er trägt bereits meine Sperre. */
onEntwurfAngelegt: (id: string) => void;
openPositions: OpenPositionResolved[];
- locations: { id: string; name: string; country: string }[];
+ locations: { id: string; name: string; country: string; parent_id: string | null }[];
resumeDraft: { id: string; step: number; payload: Record } | null;
initialPositionId?: string;
};
@@ -484,7 +484,7 @@ export function HireWizard({
emergency_contact_phone: draft.emergencyContactPhone.trim() || undefined,
emergency_contact_relation: draft.emergencyContactRelation.trim() || undefined,
is_laterale_fuehrung: draft.isLateraleFuehrung,
- is_c_level: draft.isCLevel,
+ c_level: draft.cLevel,
});
if (!result.success || !result.employeeId) {
setSubmitting(false);
diff --git a/components/hire/HireWizardContext.tsx b/components/hire/HireWizardContext.tsx
index 3df1a4f..5d1c8d4 100644
--- a/components/hire/HireWizardContext.tsx
+++ b/components/hire/HireWizardContext.tsx
@@ -8,7 +8,7 @@ import type { Entwurf } from "@/lib/entwuerfe";
import type { OpenPositionResolved } from "@/lib/positions";
import { HireWizard } from "./HireWizard";
-type Location = { id: string; name: string; country: string };
+type Location = { id: string; name: string; country: string; parent_id: string | null };
type OpenWizardOptions = { draftId?: string; positionId?: string };
diff --git a/components/hire/RehireWizard.tsx b/components/hire/RehireWizard.tsx
index b654996..6864655 100644
--- a/components/hire/RehireWizard.tsx
+++ b/components/hire/RehireWizard.tsx
@@ -64,7 +64,7 @@ type RehireWizardProps = {
onClose: () => void;
employee: EmployeeRow;
openPositions: OpenPositionResolved[];
- locations: { id: string; name: string; country: string }[];
+ locations: { id: string; name: string; country: string; parent_id: string | null }[];
};
export function RehireWizard({ open, onClose, employee, openPositions, locations }: RehireWizardProps) {
@@ -199,7 +199,7 @@ export function RehireWizard({ open, onClose, employee, openPositions, locations
has_dienstwagen: draft.hasDienstwagen,
dienstwagen_art: draft.hasDienstwagen ? draft.dienstwagenArt : "",
is_laterale_fuehrung: draft.isLateraleFuehrung,
- is_c_level: draft.isCLevel,
+ c_level: draft.cLevel,
has_kuendigungsschutz: draft.hasKuendigungsschutz,
kuendigungsschutz_grund: draft.hasKuendigungsschutz ? draft.kuendigungsschutzGrund : "",
diff --git a/components/hire/StepExternePerson.tsx b/components/hire/StepExternePerson.tsx
index 6691676..669432c 100644
--- a/components/hire/StepExternePerson.tsx
+++ b/components/hire/StepExternePerson.tsx
@@ -1,3 +1,4 @@
+import { StandortAuswahl } from "@/components/employees/StandortAuswahl";
import { PlanstellenAuswahl } from "@/components/positions/PlanstellenAuswahl";
import { DateField, SelectField, TextField } from "@/components/ui/Field";
import { todayIso } from "@/lib/format";
@@ -24,7 +25,7 @@ export function StepExternePerson({
}: {
draft: HireDraftData;
update: (patch: Partial) => void;
- locations: { id: string; name: string; country: string }[];
+ locations: { id: string; name: string; country: string; parent_id: string | null }[];
openPositions: OpenPositionResolved[];
stellenFehler?: string | null;
onNummerBefund: (befund: { nummer: number; vergeben: boolean }) => void;
@@ -78,13 +79,12 @@ export function StepExternePerson({
onChange={(id) => update({ positionId: id })}
/>
- update({ locationId })}
- placeholder="Bitte wählen…"
- options={locations.map((l) => ({ value: l.id, label: `${l.name} (${l.country})` }))}
+ standorte={locations}
/>
);
diff --git a/components/hire/StepPerson.tsx b/components/hire/StepPerson.tsx
index 7b32ab3..c9254c6 100644
--- a/components/hire/StepPerson.tsx
+++ b/components/hire/StepPerson.tsx
@@ -1,3 +1,4 @@
+import { StandortAuswahl } from "@/components/employees/StandortAuswahl";
import { SvNummerField } from "@/components/employees/SvNummerField";
import { TitleFields } from "@/components/employees/TitleFields";
import { ZustaendigeHrField } from "@/components/employees/ZustaendigeHrField";
@@ -14,7 +15,7 @@ import type { HireDraftData } from "./types";
type StepPersonProps = {
draft: HireDraftData;
update: (patch: Partial) => void;
- locations: { id: string; name: string; country: string }[];
+ locations: { id: string; name: string; country: string; parent_id: string | null }[];
/** Meldet die geprüfte Personalnummer und ihr Ergebnis — steuert „Weiter". */
onNummerBefund?: (befund: { nummer: number; vergeben: boolean }) => void;
/**
@@ -185,13 +186,12 @@ export function StepPerson({ draft, update, locations, onNummerBefund, nummerGes
/>
update({ phone })} />
- update({ locationId })}
- placeholder="Bitte wählen…"
- options={locations.map((l) => ({ value: l.id, label: `${l.name} (${l.country})` }))}
+ standorte={locations}
/>
update({ zustaendigeHrId })} />
diff --git a/components/hire/StepSummary.tsx b/components/hire/StepSummary.tsx
index f8113e1..197de3a 100644
--- a/components/hire/StepSummary.tsx
+++ b/components/hire/StepSummary.tsx
@@ -46,7 +46,6 @@ export function StepSummary({ draft, selectedPosition, locations, extern = false
draft.isBetriebsrat && "Betriebsrat",
draft.hasDienstwagen && `Dienstwagen (${dienstwagenLabel(draft.dienstwagenArt)})`,
draft.isLateraleFuehrung && "Laterale Führung",
- draft.isCLevel && "C-Level",
draft.hasKuendigungsschutz &&
`Besonderer Kündigungsschutz${draft.kuendigungsschutzBis ? ` bis ${fmtDate(draft.kuendigungsschutzBis)}` : ""}`,
].filter(Boolean);
@@ -89,6 +88,7 @@ export function StepSummary({ draft, selectedPosition, locations, extern = false
: []),
["Anstellungs-/Beschäftigungsart", anzeige(draft.mitarbeiterart)],
["Kollektivvertrag", draft.collectiveAgreement],
+ ["C-Level", draft.cLevel || "–"],
["Arbeitstage", draft.workDays.join(", ") || "–"],
["Merkmale", flags.length > 0 ? flags.join(", ") : "–"],
];
diff --git a/components/hire/StepVertrag.tsx b/components/hire/StepVertrag.tsx
index cf0466b..486caa0 100644
--- a/components/hire/StepVertrag.tsx
+++ b/components/hire/StepVertrag.tsx
@@ -88,7 +88,7 @@ export function StepVertrag({
update({ weeklyHours })}
diff --git a/components/hire/UebernahmeWizard.tsx b/components/hire/UebernahmeWizard.tsx
index 302d93b..a41e002 100644
--- a/components/hire/UebernahmeWizard.tsx
+++ b/components/hire/UebernahmeWizard.tsx
@@ -54,7 +54,7 @@ export function UebernahmeWizard({
open: boolean;
onClose: () => void;
employee: EmployeeRow;
- locations: { id: string; name: string; country: string }[];
+ locations: { id: string; name: string; country: string; parent_id: string | null }[];
}) {
const { showToast } = useToast();
const router = useRouter();
@@ -202,7 +202,7 @@ export function UebernahmeWizard({
has_dienstwagen: draft.hasDienstwagen,
dienstwagen_art: draft.hasDienstwagen ? draft.dienstwagenArt : "",
is_laterale_fuehrung: draft.isLateraleFuehrung,
- is_c_level: draft.isCLevel,
+ c_level: draft.cLevel,
teilzeit_art: teilzeit,
teilzeit_bis: teilzeit ? draft.teilzeitBis : "",
has_kuendigungsschutz: draft.hasKuendigungsschutz,
diff --git a/components/hire/types.ts b/components/hire/types.ts
index c08914d..f0a3be3 100644
--- a/components/hire/types.ts
+++ b/components/hire/types.ts
@@ -106,7 +106,8 @@ export type HireDraftData = {
emergencyContactRelation: string;
angehoerige: HireDraftAngehoerige[];
isLateraleFuehrung: boolean;
- isCLevel: boolean;
+ /** Code aus lib/c-level.ts; "" heisst nicht erfasst. */
+ cLevel: string;
/** Form der Beschäftigung — zweite Achse neben der Beschäftigtengruppe. */
mitarbeiterart: Mitarbeiterart;
hasKuendigungsschutz: boolean;
@@ -182,7 +183,7 @@ export const EMPTY_HIRE_DRAFT: HireDraftData = {
emergencyContactRelation: "",
angehoerige: [],
isLateraleFuehrung: false,
- isCLevel: false,
+ cLevel: "",
mitarbeiterart: MITARBEITERART_STANDARD,
hasKuendigungsschutz: false,
kuendigungsschutzBis: "",
diff --git a/components/reports/ReportsPageClient.tsx b/components/reports/ReportsPageClient.tsx
index 5f1ded1..c6019a2 100644
--- a/components/reports/ReportsPageClient.tsx
+++ b/components/reports/ReportsPageClient.tsx
@@ -220,7 +220,7 @@ function KriterienBlock({
label="Ab"
dense
type="number"
- step="0.5"
+ step="0.01"
value={criteria.stundenVon?.toString() ?? ""}
onChange={(v) => onChange({ hoursFrom: v || undefined })}
/>
@@ -228,7 +228,7 @@ function KriterienBlock({
label="Bis"
dense
type="number"
- step="0.5"
+ step="0.01"
value={criteria.stundenBis?.toString() ?? ""}
onChange={(v) => onChange({ hoursTo: v || undefined })}
/>
diff --git a/components/shell/TestsystemSchriftzug.tsx b/components/shell/TestsystemSchriftzug.tsx
new file mode 100644
index 0000000..8ecf72e
--- /dev/null
+++ b/components/shell/TestsystemSchriftzug.tsx
@@ -0,0 +1,24 @@
+import { TriangleAlert } from "lucide-react";
+import { TESTSYSTEM_SCHRIFTZUG } from "@/lib/testsystem";
+
+// Hängt mittig an der Oberkante, über Kopfleiste und Navigation, und bleibt
+// beim Blättern stehen; ein roter Rahmen um das ganze Fenster wiederholt das
+// Signal am Rand, wo der Blick beim Arbeiten liegt. Mittig, weil die
+// Kopfleiste links den Seitentitel und rechts die Bedienelemente trägt.
+// Beides ist klickdurchlässig, damit es nie etwas verdeckt, das sich sonst
+// bedienen liesse. Auf Ausdrucken erscheint es nicht: Checkliste und
+// Organigramm sind Dokumente, kein Bildschirm.
+export function TestsystemSchriftzug() {
+ return (
+ <>
+
+
+
+ {TESTSYSTEM_SCHRIFTZUG}
+
+ >
+ );
+}
diff --git a/db/migrations/20261123100000_wochenstunden_zwei_nachkommastellen.sql b/db/migrations/20261123100000_wochenstunden_zwei_nachkommastellen.sql
new file mode 100644
index 0000000..a6e50d8
--- /dev/null
+++ b/db/migrations/20261123100000_wochenstunden_zwei_nachkommastellen.sql
@@ -0,0 +1,148 @@
+-- Wochenstunden mit zwei Nachkommastellen
+--
+-- Teilzeit wird in Viertelstunden vereinbart: 19,25 Stunden sind eine
+-- übliche Angabe. Eine Spalte mit einer Nachkommastelle rundet sie beim
+-- Speichern stillschweigend auf 19,3, und in den Stammdaten steht dann ein
+-- Wert, den niemand vereinbart hat. numeric(4,2) reicht bis 99,99; mehr als 38,5
+-- lässt chk_weekly_hours ohnehin nicht zu.
+--
+-- ── Die IT-Sicht steht der Typänderung im Weg ─────────────────────────────
+--
+-- it.mitarbeiter liest die Spalte, und PostgreSQL ändert den Typ einer
+-- Spalte nicht, solange eine Sicht sie verwendet. Die Sicht wird deshalb aus
+-- ihrer eigenen, gespeicherten Definition neu angelegt — nicht aus einer
+-- Abschrift, die hier veralten könnte —, samt Kommentar und Leserechten.
+--
+-- ── Verglichen wird ohne angehängte Nullen ────────────────────────────────
+--
+-- change_employee_data und record_karenz_return schreiben eine Änderung der
+-- Wochenstunden nur, wenn sich der Text unterscheidet. Mit zwei
+-- Nachkommastellen lautete der gespeicherte Wert „38.50", die Eingabe „38.5"
+-- — eine Änderung über nichts in Historie und Bericht. trim_scale nimmt auf
+-- beiden Seiten die angehängten Nullen weg; so steht in der Historie „19.25"
+-- und „38.5", in derselben Schreibweise wie die vorhandenen Einträge.
+
+do $migration$
+declare
+ v_sicht text;
+ v_kommentar text;
+ v_recht record;
+ v_rechte text[] := '{}';
+ v_def text;
+ v_anzahl int;
+ v_alt text;
+ v_neu text;
+begin
+ -- 1. Sicht sichern, entfernen, Typ ändern, Sicht wiederherstellen.
+ select pg_get_viewdef('it.mitarbeiter'::regclass, true),
+ obj_description('it.mitarbeiter'::regclass, 'pg_class')
+ into v_sicht, v_kommentar;
+ if v_sicht is null then raise exception 'it.mitarbeiter ist nicht vorhanden.'; end if;
+
+ for v_recht in
+ select case when a.grantee = 0 then 'public' else quote_ident(r.rolname) end as wem,
+ a.privilege_type as was
+ from pg_class c
+ cross join lateral aclexplode(c.relacl) a
+ left join pg_roles r on r.oid = a.grantee
+ where c.oid = 'it.mitarbeiter'::regclass
+ and a.grantee <> c.relowner
+ loop
+ v_rechte := v_rechte || format('grant %s on it.mitarbeiter to %s', v_recht.was, v_recht.wem);
+ end loop;
+
+ drop view it.mitarbeiter;
+ alter table employees alter column weekly_hours type numeric(4,2);
+ execute 'create view it.mitarbeiter as ' || v_sicht;
+ if v_kommentar is not null then
+ execute format('comment on view it.mitarbeiter is %L', v_kommentar);
+ end if;
+ for i in 1 .. coalesce(array_length(v_rechte, 1), 0) loop
+ execute v_rechte[i];
+ end loop;
+
+ -- 2. change_employee_data: Vergleich ohne angehängte Nullen.
+ v_alt := $anker$v_old.weekly_hours::text, (nullif(v_contract->>'weekly_hours','')::numeric(4,1))::text$anker$;
+ v_neu := $anker$trim_scale(v_old.weekly_hours)::text, trim_scale(nullif(v_contract->>'weekly_hours','')::numeric(4,2))::text$anker$;
+ select pg_get_functiondef(p.oid) into v_def
+ from pg_proc p join pg_namespace n on n.oid = p.pronamespace
+ where n.nspname = 'public' and p.proname = 'change_employee_data' and p.prokind = 'f';
+ if v_def is null then raise exception 'change_employee_data ist nicht vorhanden.'; end if;
+ v_anzahl := (length(v_def) - length(replace(v_def, v_alt, ''))) / length(v_alt);
+ if v_anzahl <> 1 then
+ raise exception 'change_employee_data: Anker der Wochenstunden kommt % mal vor, erwartet einmal.', v_anzahl;
+ end if;
+ execute replace(v_def, v_alt, v_neu);
+
+ -- 3. record_karenz_return: dasselbe bei der Rückkehr mit anderen Stunden.
+ v_alt := $anker$v_old.weekly_hours::text, v_weekly_hours::text)$anker$;
+ v_neu := $anker$trim_scale(v_old.weekly_hours)::text, trim_scale(v_weekly_hours::numeric(4,2))::text)$anker$;
+ select pg_get_functiondef(p.oid) into v_def
+ from pg_proc p join pg_namespace n on n.oid = p.pronamespace
+ where n.nspname = 'public' and p.proname = 'record_karenz_return' and p.prokind = 'f';
+ if v_def is null then raise exception 'record_karenz_return ist nicht vorhanden.'; end if;
+ v_anzahl := (length(v_def) - length(replace(v_def, v_alt, ''))) / length(v_alt);
+ if v_anzahl <> 1 then
+ raise exception 'record_karenz_return: Anker der Wochenstunden kommt % mal vor, erwartet einmal.', v_anzahl;
+ end if;
+ execute replace(v_def, v_alt, v_neu);
+end
+$migration$;
+
+
+-- Selbstprüfung: das Neue und das, was bei der Neuerzeugung verlorengehen kann.
+do $$
+declare
+ v_def text;
+begin
+ if (select format_type(a.atttypid, a.atttypmod)
+ from pg_attribute a
+ where a.attrelid = 'public.employees'::regclass and a.attname = 'weekly_hours') <> 'numeric(4,2)' then
+ raise exception 'employees.weekly_hours ist nicht numeric(4,2).';
+ end if;
+ if (select format_type(a.atttypid, a.atttypmod)
+ from pg_attribute a
+ where a.attrelid = 'it.mitarbeiter'::regclass and a.attname = 'weekly_hours') <> 'numeric(4,2)' then
+ raise exception 'it.mitarbeiter zeigt die Wochenstunden nicht mit zwei Nachkommastellen.';
+ end if;
+ if not has_table_privilege('it_lesen', 'it.mitarbeiter', 'select') then
+ raise exception 'it_lesen kann it.mitarbeiter nicht mehr lesen.';
+ end if;
+ if obj_description('it.mitarbeiter'::regclass, 'pg_class') is null then
+ raise exception 'it.mitarbeiter hat den Kommentar verloren.';
+ end if;
+
+ select pg_get_functiondef(p.oid) into v_def
+ from pg_proc p join pg_namespace n on n.oid = p.pronamespace
+ where n.nspname = 'public' and p.proname = 'change_employee_data' and p.prokind = 'f';
+ if v_def not like '%trim_scale(nullif(v_contract->>''weekly_hours'','''')::numeric(4,2))::text%' then
+ raise exception 'change_employee_data vergleicht die Wochenstunden nicht ohne angehängte Nullen.';
+ end if;
+ if v_def like '%numeric(4,1)%' then
+ raise exception 'change_employee_data rundet noch auf eine Nachkommastelle.';
+ end if;
+ if v_def not like '%require_hr_admin()%' then
+ raise exception 'change_employee_data prüft die Rechte nicht.';
+ end if;
+ if v_def not like '%search_path%' then
+ raise exception 'change_employee_data hat keinen festen search_path.';
+ end if;
+
+ select pg_get_functiondef(p.oid) into v_def
+ from pg_proc p join pg_namespace n on n.oid = p.pronamespace
+ where n.nspname = 'public' and p.proname = 'record_karenz_return' and p.prokind = 'f';
+ if v_def not like '%trim_scale(v_weekly_hours::numeric(4,2))::text%' then
+ raise exception 'record_karenz_return vergleicht die Wochenstunden nicht ohne angehängte Nullen.';
+ end if;
+ if v_def not like '%require_hr_admin()%' then
+ raise exception 'record_karenz_return prüft die Rechte nicht.';
+ end if;
+ if v_def not like '%search_path%' then
+ raise exception 'record_karenz_return hat keinen festen search_path.';
+ end if;
+
+ if (19.25)::numeric(4,2) <> 19.25 then
+ raise exception 'numeric(4,2) hält 19,25 nicht.';
+ end if;
+end
+$$;
diff --git a/db/migrations/20261123120000_c_level_als_auswahl.sql b/db/migrations/20261123120000_c_level_als_auswahl.sql
new file mode 100644
index 0000000..46161d4
--- /dev/null
+++ b/db/migrations/20261123120000_c_level_als_auswahl.sql
@@ -0,0 +1,250 @@
+-- C-Level als Auswahl aus einer fachlichen Liste
+--
+-- C-Level ist die Führungs- bzw. Funktionsstufe einer Person, als Code:
+-- C1 Bereichsleitung, C11 Mitarbeiter gfg., C2 Abteilungsleitung, C3 Experte,
+-- C4 Teamleitung, C8 Lehrling, C9 Mitarbeiter, MG Manager, P Prokurist,
+-- VD Vorstand. Jede Person hat eine Stufe; ein Ja/Nein sagt darüber nichts.
+--
+-- Neue Spalte `c_level`, freiwillig (leer = nicht erfasst), mit CHECK statt
+-- Aufzählungstyp: eine Liste, die sich ändern kann, ist so eine Migration
+-- mit einer Zeile — wie Mitarbeiterart und Personenkreis.
+--
+-- ── Was mit is_c_level geschieht ──────────────────────────────────────────
+--
+-- Die Spalte bleibt, die Oberfläche schreibt sie nicht mehr. Bestehende
+-- Historieneinträge „C-Level: false → true" beziehen sich auf sie; damit
+-- sie sich weiter berichtigen und löschen lassen, führt die Feldkarte sie
+-- unter „C-Level (Ja/Nein)", und die vorhandenen Einträge tragen diese
+-- Bezeichnung. „C-Level" bezeichnet ab hier die neue Spalte.
+--
+-- Die IT-Sicht zeigt statt des Ja/Nein den Code: ein Ja/Nein, das niemand
+-- mehr pflegt, wäre dort eine falsche Auskunft.
+--
+-- Fünf Funktionen werden aus ihrer gespeicherten Definition an genau den
+-- Stellen ergänzt, an denen is_c_level steht; jeder Anker muss genau einmal
+-- vorkommen.
+
+alter table employees add column if not exists c_level text;
+
+do $$
+begin
+ if not exists (select 1 from pg_constraint where conname = 'chk_c_level' and conrelid = 'public.employees'::regclass) then
+ alter table employees add constraint chk_c_level
+ check (c_level in ('C1', 'C11', 'C2', 'C3', 'C4', 'C8', 'C9', 'MG', 'P', 'VD'));
+ end if;
+end
+$$;
+
+comment on column employees.c_level is
+ 'Führungs-/Funktionsstufe als Code (C1 … VD); leer = nicht erfasst. is_c_level ist abgelöst und wird nicht mehr geschrieben.';
+
+do $migration$
+declare
+ v_def text;
+ v_anzahl int;
+
+ -- Ersetzt in der gespeicherten Definition von p_funktion jeden Anker durch
+ -- seinen Ersatz und legt die Funktion neu an. Jeder Anker muss genau einmal
+ -- vorkommen; sonst bricht die Migration ab, bevor etwas geändert ist.
+ v_funktionen text[] := array['hire_employee', 'rehire_employee', 'change_employee_data',
+ 'apply_due_pending_changes', 'app_feld_karte'];
+ v_anker jsonb := jsonb_build_object(
+ 'hire_employee', jsonb_build_array(
+ jsonb_build_array(
+ $a$is_betriebsrat, has_dienstwagen, is_laterale_fuehrung, is_c_level,$a$,
+ $a$is_betriebsrat, has_dienstwagen, is_laterale_fuehrung, is_c_level, c_level,$a$),
+ jsonb_build_array(
+ $a$coalesce((payload->>'is_c_level')::boolean, false),$a$,
+ $a$coalesce((payload->>'is_c_level')::boolean, false),
+ nullif(payload->>'c_level', ''),$a$)),
+ 'rehire_employee', jsonb_build_array(
+ jsonb_build_array(
+ $a$is_c_level = coalesce((payload->>'is_c_level')::boolean, is_c_level),$a$,
+ $a$is_c_level = coalesce((payload->>'is_c_level')::boolean, is_c_level),
+ c_level = case when payload ? 'c_level' then nullif(payload->>'c_level', '') else c_level end,$a$)),
+ 'change_employee_data', jsonb_build_array(
+ jsonb_build_array(
+ $a$is_c_level = coalesce((v_role->>'is_c_level')::boolean, is_c_level),$a$,
+ $a$is_c_level = coalesce((v_role->>'is_c_level')::boolean, is_c_level),
+ c_level = case when v_role ? 'c_level' then nullif(v_role->>'c_level', '') else c_level end,$a$),
+ jsonb_build_array(
+ $a$app_aenderung(v_contract_changes, 'C-Level', v_old.is_c_level::text, v_role->>'is_c_level'); end if;$a$,
+ $a$app_aenderung(v_contract_changes, 'C-Level (Ja/Nein)', v_old.is_c_level::text, v_role->>'is_c_level'); end if;
+ if v_role ? 'c_level' then v_contract_changes := app_aenderung(v_contract_changes, 'C-Level', v_old.c_level, nullif(v_role->>'c_level', '')); end if;$a$)),
+ 'apply_due_pending_changes', jsonb_build_array(
+ jsonb_build_array(
+ $a$is_c_level = coalesce((v_role->>'is_c_level')::boolean, is_c_level),$a$,
+ $a$is_c_level = coalesce((v_role->>'is_c_level')::boolean, is_c_level),
+ c_level = case when v_role ? 'c_level' then nullif(v_role->>'c_level', '') else c_level end,$a$)),
+ 'app_feld_karte', jsonb_build_array(
+ jsonb_build_array(
+ $a$'C-Level', jsonb_build_array('is_c_level', 'boolean', 'role')$a$,
+ $a$'C-Level (Ja/Nein)', jsonb_build_array('is_c_level', 'boolean', 'role')$a$),
+ jsonb_build_array(
+ $a$jsonb_build_array('arbeitszeitmodell', 'arbeitszeit', 'role')$a$,
+ $a$jsonb_build_array('arbeitszeitmodell', 'arbeitszeit', 'role'),
+ 'C-Level', jsonb_build_array('c_level', 'text', 'role')$a$))
+ );
+ v_name text;
+ v_paar jsonb;
+ v_alt text;
+begin
+ foreach v_name in array v_funktionen loop
+ select pg_get_functiondef(p.oid) into v_def
+ from pg_proc p join pg_namespace n on n.oid = p.pronamespace
+ where n.nspname = 'public' and p.proname = v_name and p.prokind = 'f';
+ if v_def is null then raise exception '% ist nicht vorhanden.', v_name; end if;
+
+ for v_paar in select * from jsonb_array_elements(v_anker -> v_name) loop
+ v_alt := v_paar ->> 0;
+ v_anzahl := (length(v_def) - length(replace(v_def, v_alt, ''))) / length(v_alt);
+ if v_anzahl <> 1 then
+ raise exception '%: Anker „%" kommt % mal vor, erwartet einmal.', v_name, v_alt, v_anzahl;
+ end if;
+ v_def := replace(v_def, v_alt, v_paar ->> 1);
+ end loop;
+
+ execute v_def;
+ end loop;
+end
+$migration$;
+
+-- Vorhandene Historieneinträge zum Ja/Nein tragen dessen neue Bezeichnung.
+-- Nur die Bezeichnung im Änderungsdetail ändert sich, nicht Datum, Werte
+-- oder Reihenfolge. Die Prüfung „kein Vorgang ab Austritt" gilt neuen
+-- Vorgängen; sie bleibt für diese eine Umbenennung aus.
+alter table employee_history disable trigger trg_kein_vorgang_ab_austritt;
+
+update employee_history h
+ set changes = (
+ select jsonb_agg(case when e->>'feld' = 'C-Level'
+ then jsonb_set(e, '{feld}', to_jsonb('C-Level (Ja/Nein)'::text))
+ else e end
+ order by i)
+ from jsonb_array_elements(h.changes) with ordinality t(e, i))
+ where jsonb_typeof(h.changes) = 'array'
+ and h.changes @> '[{"feld": "C-Level"}]';
+
+alter table employee_history enable trigger trg_kein_vorgang_ab_austritt;
+
+-- IT-Sicht: der Code statt des abgelösten Ja/Nein. Neu angelegt aus der
+-- gespeicherten Definition, samt Kommentar und Leserechten.
+do $sicht$
+declare
+ v_sicht text;
+ v_kommentar text;
+ v_recht record;
+ v_rechte text[] := '{}';
+ v_anzahl int;
+begin
+ select pg_get_viewdef('it.mitarbeiter'::regclass, true),
+ obj_description('it.mitarbeiter'::regclass, 'pg_class')
+ into v_sicht, v_kommentar;
+ if v_sicht is null then raise exception 'it.mitarbeiter ist nicht vorhanden.'; end if;
+
+ v_anzahl := (length(v_sicht) - length(replace(v_sicht, 'e.is_c_level,', ''))) / length('e.is_c_level,');
+ if v_anzahl <> 1 then
+ raise exception 'it.mitarbeiter: e.is_c_level kommt % mal vor, erwartet einmal.', v_anzahl;
+ end if;
+
+ for v_recht in
+ select case when a.grantee = 0 then 'public' else quote_ident(r.rolname) end as wem,
+ a.privilege_type as was
+ from pg_class c
+ cross join lateral aclexplode(c.relacl) a
+ left join pg_roles r on r.oid = a.grantee
+ where c.oid = 'it.mitarbeiter'::regclass
+ and a.grantee <> c.relowner
+ loop
+ v_rechte := v_rechte || format('grant %s on it.mitarbeiter to %s', v_recht.was, v_recht.wem);
+ end loop;
+
+ drop view it.mitarbeiter;
+ execute 'create view it.mitarbeiter as ' || replace(v_sicht, 'e.is_c_level,', 'e.c_level,');
+ if v_kommentar is not null then
+ execute format('comment on view it.mitarbeiter is %L', v_kommentar);
+ end if;
+ for i in 1 .. coalesce(array_length(v_rechte, 1), 0) loop
+ execute v_rechte[i];
+ end loop;
+end
+$sicht$;
+
+
+-- ── Selbstprüfung ─────────────────────────────────────────────────────────
+do $$
+declare
+ v_def text;
+ v_name text;
+begin
+ if not exists (select 1 from pg_constraint where conname = 'chk_c_level' and conrelid = 'public.employees'::regclass) then
+ raise exception 'chk_c_level fehlt.';
+ end if;
+
+ select pg_get_functiondef(p.oid) into v_def from pg_proc p join pg_namespace n on n.oid = p.pronamespace
+ where n.nspname = 'public' and p.proname = 'hire_employee' and p.prokind = 'f';
+ if v_def not like '%is_c_level, c_level,%' or v_def not like '%nullif(payload->>''c_level'', ''''),%' then
+ raise exception 'hire_employee schreibt c_level nicht.';
+ end if;
+
+ select pg_get_functiondef(p.oid) into v_def from pg_proc p join pg_namespace n on n.oid = p.pronamespace
+ where n.nspname = 'public' and p.proname = 'rehire_employee' and p.prokind = 'f';
+ if v_def not like '%c_level = case when payload ? ''c_level''%' then
+ raise exception 'rehire_employee schreibt c_level nicht.';
+ end if;
+
+ select pg_get_functiondef(p.oid) into v_def from pg_proc p join pg_namespace n on n.oid = p.pronamespace
+ where n.nspname = 'public' and p.proname = 'change_employee_data' and p.prokind = 'f';
+ if v_def not like '%c_level = case when v_role ? ''c_level''%' then
+ raise exception 'change_employee_data schreibt c_level nicht.';
+ end if;
+ if v_def not like '%''C-Level'', v_old.c_level%' or v_def not like '%''C-Level (Ja/Nein)'', v_old.is_c_level%' then
+ raise exception 'change_employee_data protokolliert C-Level nicht wie vorgesehen.';
+ end if;
+ -- Was bei einer Neuerzeugung dieser Funktion verlorengehen kann.
+ if v_def not like '%trim_scale(nullif(v_contract->>''weekly_hours'','''')::numeric(4,2))::text%' then
+ raise exception 'change_employee_data hat den Vergleich der Wochenstunden verloren.';
+ end if;
+ if v_def not like '%cornerstone_id%' then
+ raise exception 'change_employee_data hat die Cornerstone-ID verloren.';
+ end if;
+
+ select pg_get_functiondef(p.oid) into v_def from pg_proc p join pg_namespace n on n.oid = p.pronamespace
+ where n.nspname = 'public' and p.proname = 'apply_due_pending_changes' and p.prokind = 'f';
+ if v_def not like '%c_level = case when v_role ? ''c_level''%' then
+ raise exception 'apply_due_pending_changes schreibt c_level nicht.';
+ end if;
+
+ if app_feld_karte() -> 'C-Level' ->> 0 is distinct from 'c_level'
+ or app_feld_karte() -> 'C-Level (Ja/Nein)' ->> 0 is distinct from 'is_c_level' then
+ raise exception 'app_feld_karte führt C-Level nicht wie vorgesehen.';
+ end if;
+
+ foreach v_name in array array['hire_employee', 'rehire_employee', 'change_employee_data', 'apply_due_pending_changes'] loop
+ select pg_get_functiondef(p.oid) into v_def from pg_proc p join pg_namespace n on n.oid = p.pronamespace
+ where n.nspname = 'public' and p.proname = v_name and p.prokind = 'f';
+ if v_name <> 'apply_due_pending_changes' and v_def not like '%require_hr_admin()%' then
+ raise exception '% prüft die Rechte nicht.', v_name;
+ end if;
+ if v_def not like '%search_path%' then
+ raise exception '% hat keinen festen search_path.', v_name;
+ end if;
+ end loop;
+
+ if exists (select 1 from employee_history
+ where jsonb_typeof(changes) = 'array' and changes @> '[{"feld": "C-Level"}]') then
+ raise exception 'Es gibt noch Historieneinträge mit der alten Bezeichnung „C-Level".';
+ end if;
+ if not exists (select 1 from pg_trigger where tgname = 'trg_kein_vorgang_ab_austritt' and tgenabled = 'O') then
+ raise exception 'trg_kein_vorgang_ab_austritt ist nicht wieder eingeschaltet.';
+ end if;
+
+ if not exists (select 1 from information_schema.columns
+ where table_schema = 'it' and table_name = 'mitarbeiter' and column_name = 'c_level') then
+ raise exception 'it.mitarbeiter zeigt c_level nicht.';
+ end if;
+ if not has_table_privilege('it_lesen', 'it.mitarbeiter', 'select') then
+ raise exception 'it_lesen kann it.mitarbeiter nicht mehr lesen.';
+ end if;
+end
+$$;
diff --git a/db/migrations/20261123140000_standort_shop.sql b/db/migrations/20261123140000_standort_shop.sql
new file mode 100644
index 0000000..83d865c
--- /dev/null
+++ b/db/migrations/20261123140000_standort_shop.sql
@@ -0,0 +1,139 @@
+-- Standorte mit Unterstandorten: „Shop" und die einzelnen Shops
+--
+-- Ein Standort kann Unterstandorte haben. Eine Person sitzt immer auf einem
+-- Standort ohne Unterstandorte: „Shop" allein sagt nicht, wo jemand
+-- arbeitet. Die Oberfläche bietet zuerst die Standorte ohne übergeordneten
+-- an und bei einem mit Unterstandorten eine zweite Auswahl.
+--
+-- Der Name eines Unterstandorts nennt den übergeordneten mit („Shop W17"):
+-- Liste, Berichte, Exporte und IT-Sicht lesen nur den Namen und bleiben so
+-- ohne weitere Verknüpfung eindeutig.
+--
+-- Eine Ebene: ein Unterstandort hat keine eigenen. Zwei Trigger halten das
+-- fest, auch für den Import und den Nachtlauf, die an der Oberfläche
+-- vorbeigehen.
+
+alter table locations add column if not exists parent_id uuid references locations(id);
+
+comment on column locations.parent_id is
+ 'Übergeordneter Standort (etwa „Shop"); leer = Standort der obersten Ebene. Personen sitzen nur auf Standorten ohne Unterstandorte.';
+
+alter table locations drop constraint if exists chk_location_nicht_eigener_parent;
+alter table locations add constraint chk_location_nicht_eigener_parent check (parent_id is null or parent_id <> id);
+
+create index if not exists idx_locations_parent on locations (parent_id) where parent_id is not null;
+
+-- Sitzt schon jemand auf einem Standort „Shop", fehlt die Angabe, auf welchem.
+-- Raten wäre schlechter als anhalten.
+do $pruefung$
+begin
+ if exists (select 1 from employees e join locations l on l.id = e.location_id where l.name = 'Shop') then
+ raise exception 'Auf dem Standort „Shop" sitzen Personen. Sie brauchen zuerst einen anderen Standort; danach die Migration erneut ausführen.';
+ end if;
+end
+$pruefung$;
+
+-- ── Regeln ──────────────────────────────────────────────────────────────
+
+create or replace function public.standort_ebene_pruefen()
+returns trigger
+language plpgsql
+set search_path = public, pg_temp
+as $$
+begin
+ if new.parent_id is null then
+ return new;
+ end if;
+ if exists (select 1 from locations where id = new.parent_id and parent_id is not null) then
+ raise exception 'Ein Unterstandort kann keine eigenen Unterstandorte haben.';
+ end if;
+ if exists (select 1 from locations where parent_id = new.id) then
+ raise exception 'Ein Standort mit Unterstandorten kann nicht selbst unter einem anderen stehen.';
+ end if;
+ if exists (select 1 from employees where location_id = new.parent_id) then
+ raise exception 'Auf dem Standort „%" sitzen Personen; er kann keine Unterstandorte bekommen.',
+ (select name from locations where id = new.parent_id);
+ end if;
+ return new;
+end;
+$$;
+
+drop trigger if exists trg_standort_ebene on locations;
+create trigger trg_standort_ebene
+ before insert or update of parent_id on locations
+ for each row execute function public.standort_ebene_pruefen();
+
+create or replace function public.standort_ohne_unterstandorte()
+returns trigger
+language plpgsql
+set search_path = public, pg_temp
+as $$
+begin
+ if new.location_id is not null and exists (select 1 from locations where parent_id = new.location_id) then
+ raise exception 'Der Standort „%" fasst mehrere zusammen. Bitte einen davon auswählen.',
+ (select name from locations where id = new.location_id);
+ end if;
+ return new;
+end;
+$$;
+
+drop trigger if exists trg_standort_ohne_unterstandorte on employees;
+create trigger trg_standort_ohne_unterstandorte
+ before insert or update of location_id on employees
+ for each row execute function public.standort_ohne_unterstandorte();
+
+-- ── Shop und die einzelnen Shops ────────────────────────────────────────
+
+insert into locations (name, country) values ('Shop', 'Österreich') on conflict (name) do nothing;
+
+insert into locations (name, country, parent_id)
+select v.name, 'Österreich', (select id from locations where name = 'Shop')
+ from (values ('Shop W17'), ('Shop Wodo'), ('Shop Parndorf'), ('Shop Donaupark'), ('Shop W1'), ('Shop Wien Hauptbahnhof')) v(name)
+on conflict (name) do nothing;
+
+-- Bestanden einzelne Shops schon als eigene Standorte, kommen sie unter „Shop".
+update locations
+ set parent_id = (select id from locations where name = 'Shop')
+ where name in ('Shop W17', 'Shop Wodo', 'Shop Parndorf', 'Shop Donaupark', 'Shop W1', 'Shop Wien Hauptbahnhof')
+ and parent_id is null;
+
+-- ── Selbstprüfung ───────────────────────────────────────────────────────
+
+do $migration$
+declare
+ v_shop uuid;
+begin
+ select id into v_shop from locations where name = 'Shop';
+ if v_shop is null then
+ raise exception 'Der Standort „Shop" fehlt.';
+ end if;
+ if (select parent_id from locations where id = v_shop) is not null then
+ raise exception '„Shop" steht unter einem anderen Standort.';
+ end if;
+ if (select count(*) from locations where parent_id = v_shop) <> 6 then
+ raise exception 'Unter „Shop" stehen nicht genau die sechs Shops.';
+ end if;
+ if exists (
+ select 1 from (values ('Shop W17'), ('Shop Wodo'), ('Shop Parndorf'), ('Shop Donaupark'), ('Shop W1'), ('Shop Wien Hauptbahnhof')) v(name)
+ where not exists (select 1 from locations l where l.name = v.name and l.parent_id = v_shop)
+ ) then
+ raise exception 'Ein Shop fehlt oder steht nicht unter „Shop".';
+ end if;
+ if exists (select 1 from employees e join locations l on l.parent_id = e.location_id) then
+ raise exception 'Eine Person sitzt auf einem Standort mit Unterstandorten.';
+ end if;
+ if (select count(*) from pg_trigger
+ where not tgisinternal and tgenabled = 'O'
+ and tgname in ('trg_standort_ebene', 'trg_standort_ohne_unterstandorte')) <> 2 then
+ raise exception 'Die Trigger zu den Unterstandorten fehlen.';
+ end if;
+ if exists (
+ select 1 from pg_proc p join pg_namespace n on n.oid = p.pronamespace
+ where n.nspname = 'public'
+ and p.proname in ('standort_ebene_pruefen', 'standort_ohne_unterstandorte')
+ and (p.prosecdef or not ('search_path=public, pg_temp' = any (coalesce(p.proconfig, '{}'))))
+ ) then
+ raise exception 'Die Triggerfunktionen laufen nicht unter den Rechten des Aufrufers oder ohne search_path.';
+ end if;
+end
+$migration$;
diff --git a/db/tests/rauchtest.sql b/db/tests/rauchtest.sql
index 246f5cb..6cdd576 100644
--- a/db/tests/rauchtest.sql
+++ b/db/tests/rauchtest.sql
@@ -60,7 +60,7 @@ declare
v_psnr text;
begin
select id into v_wurzel from org_units where parent_id is null;
- select id into v_ort from locations order by name limit 1;
+ select l.id into v_ort from locations l where not exists (select 1 from locations u where u.parent_id = l.id) order by l.name limit 1;
select coalesce(max(personnel_number), 0) + 1 into v_nr from employees;
if v_wurzel is null or v_ort is null then
raise exception 'Kein Bestand: es fehlt die oberste Einheit oder ein Standort.';
diff --git a/db/tests/vertragsangaben.sql b/db/tests/vertragsangaben.sql
index bbda0d3..352d6db 100644
--- a/db/tests/vertragsangaben.sql
+++ b/db/tests/vertragsangaben.sql
@@ -62,7 +62,7 @@ begin
raise exception 'Voraussetzung fehlt: zwei aktive und ein abgeschaltetes HR-Konto.';
end if;
select id into v_wurzel from org_units where parent_id is null;
- select id into v_ort from locations order by name limit 1;
+ select l.id into v_ort from locations l where not exists (select 1 from locations u where u.parent_id = l.id) order by l.name limit 1;
select coalesce(max(personnel_number), 0) + 1 into v_nr from employees;
v_einheit := create_org_unit(jsonb_build_object(
@@ -253,7 +253,7 @@ declare
v_e employees%rowtype;
v_a uuid := (select id from employees where last_name = 'Test-A' and first_name = 'Vertrag');
v_p3 uuid := (select p.id from om_positions p join jobs j on j.id = p.job_id where j.title = 'Vertragstest Drei');
- v_ort uuid := (select id from locations order by name limit 1);
+ v_ort uuid := (select l.id from locations l where not exists (select 1 from locations u where u.parent_id = l.id) order by l.name limit 1);
begin
perform apply_due_pending_changes();
select * into v_e from employees where id = v_b;
diff --git a/deploy/windows/app.env.vorlage b/deploy/windows/app.env.vorlage
index 5928fed..344761f 100644
--- a/deploy/windows/app.env.vorlage
+++ b/deploy/windows/app.env.vorlage
@@ -46,6 +46,11 @@ CRON_SECRET={{CRON_SECRET}}
# betroffen.
# LOLYO_STARTPASSWORT=
+# Nur auf einer Testinstallation: jede Seite traegt dann oben den Schriftzug
+# "Testsystem", und der Titel im Browser-Tab beginnt damit. In der Produktion
+# auskommentiert lassen.
+# TESTSYSTEM=1
+
# Nur wenn der Server ins Internet ueber einen Proxy muss: Node.js liest die
# Proxy-Einstellung von Windows NICHT, ohne diese Zeilen scheitert die
# Anmeldung am Abruf von login.microsoftonline.com. konfiguration-anwenden.ps1
diff --git a/lib/anzeige.ts b/lib/anzeige.ts
index 1643a30..7fcfe76 100644
--- a/lib/anzeige.ts
+++ b/lib/anzeige.ts
@@ -1,7 +1,8 @@
// Wie gespeicherte Werte angezeigt und exportiert werden, wo die fachliche
// Bezeichnung vom gespeicherten Wert abweicht.
//
-// Drei Fälle, alle fachlich vorgegeben (der dritte, das Datum, steht unten):
+// Vier Fälle, alle fachlich vorgegeben (Datum und Ende der Abwesenheit
+// stehen unten):
//
// * Nicht gendern. Gespeichert bleibt „Angestellte:r", „Arbeiter:in",
// „Praktikant:in", „Ehepartner:in", „Lebenspartner:in"; angezeigt wird
@@ -42,6 +43,19 @@ const UMBENANNT: readonly (readonly [RegExp, string])[] = [
[new RegExp(`(? zehntel(modell[tag]));
+ const werte = tage.map((tag) => hundertstel(modell[tag]));
const erfasst = werte.some((w) => w !== null);
- const summeZehntel = werte.reduce((s, w) => s + (w ?? 0), 0);
- const summe = summeZehntel / 10;
+ const summeHundertstel = werte.reduce((s, w) => s + (w ?? 0), 0);
+ const summe = summeHundertstel / 100;
if (!erfasst) return { erfasst: false, summe: 0, fehler: null };
if (werte.some((w) => w === null)) {
return { erfasst, summe, fehler: "Für jeden gewählten Arbeitstag müssen Stunden eingetragen sein." };
}
+ if (tage.some((tag) => zuGenau(modell[tag]))) {
+ return { erfasst, summe, fehler: "Stunden je Arbeitstag haben höchstens zwei Nachkommastellen." };
+ }
if (werte.some((w) => (w as number) <= 0)) {
return { erfasst, summe, fehler: "An einem Arbeitstag müssen mehr als 0 Stunden stehen." };
}
- const zuviel = tage.filter((_, i) => (werte[i] as number) > MAX_STUNDEN_JE_TAG * 10);
+ const zuviel = tage.filter((_, i) => (werte[i] as number) > MAX_STUNDEN_JE_TAG * 100);
if (zuviel.length > 0) {
return {
erfasst,
@@ -76,7 +85,7 @@ export function arbeitszeitBefund(
fehler: `An einem Arbeitstag sind höchstens ${MAX_STUNDEN_JE_TAG} Stunden möglich (${zuviel.join(", ")}).`,
};
}
- if (summeZehntel !== Math.round(wochenstunden * 10)) {
+ if (summeHundertstel !== Math.round(wochenstunden * 100)) {
return {
erfasst,
summe,
@@ -98,8 +107,8 @@ export function arbeitszeitFuerDb(
): Record | null {
const eintraege: Record = {};
for (const tag of tage) {
- const z = zehntel(modell[tag]);
- if (z !== null) eintraege[tag] = z / 10;
+ const h = hundertstel(modell[tag]);
+ if (h !== null) eintraege[tag] = h / 100;
}
return Object.keys(eintraege).length > 0 ? eintraege : null;
}
@@ -114,7 +123,7 @@ export function arbeitszeitAusDb(gespeichert: unknown): Arbeitszeitmodell {
return modell;
}
-/** 38,5 statt 38.5 — und 8 statt 8,0. */
+/** 38,5 statt 38.5, 19,25 statt 19.25 — und 8 statt 8,0. */
export function formatStunden(stunden: number): string {
- return (Math.round(stunden * 10) / 10).toLocaleString("de-AT", { maximumFractionDigits: 1 });
+ return (Math.round(stunden * 100) / 100).toLocaleString("de-AT", { maximumFractionDigits: 2 });
}
diff --git a/lib/austausch/importieren.ts b/lib/austausch/importieren.ts
index 7a49c24..d9ad154 100644
--- a/lib/austausch/importieren.ts
+++ b/lib/austausch/importieren.ts
@@ -5,6 +5,7 @@ import { fmtName } from "../format";
import { pruefePlz } from "../plz";
import { requiresAustrianSvnr, svnrErrorMessage, svnrHaeltAuf, validateSvnr } from "../svnr";
import type { Database } from "../types";
+import { SONSTIGE, verhaeltnisAusDatei } from "../verhaeltnis";
import { pruefsumme } from "./abgleich";
import { BLAETTER, WIRKSAM_AB, type Blatt, type Spalte } from "./katalog";
import {
@@ -158,7 +159,7 @@ async function rufe(tx: Tx, fn: MutationFn, payload: Record): P
/** Lookups, die sich mit jedem Blatt ändern können: was die Datei neu anlegt, gilt sofort. */
type Bestand = {
- standorte: Map;
+ standorte: Map;
kostenstellen: Map;
einheiten: Map & { id: string }>;
planstellen: Map & { id: string }>;
@@ -168,7 +169,7 @@ type Bestand = {
async function bestandLaden(tx: Tx, heute: string): Promise {
const [standorte, kostenstellen, einheiten, planstellen, personen, hr] = await Promise.all([
- tx.selectFrom("locations").select(["id", "name", "country"]).execute(),
+ tx.selectFrom("locations").select(["id", "name", "country", "parent_id"]).execute(),
tx.selectFrom("cost_centers").select(["id", "code", "name"]).execute(),
tx
.selectFrom("org_units as u")
@@ -649,6 +650,15 @@ function mitarbeiterZeile(
const planstelle = (n: unknown) => bestand.planstellen.get(String(n));
if (zeile.wert("location_id") && !standortId(zeile.wert("location_id"))) {
zeile.fehler(`Den Standort „${String(zeile.wert("location_id"))}“ gibt es nicht (auch nicht im Blatt „Standorte“).`, "location_id");
+ } else if (zeile.wert("location_id")) {
+ const id = standortId(zeile.wert("location_id"));
+ const unter = [...bestand.standorte.values()].filter((s) => s.parent_id === id).map((s) => s.name);
+ if (unter.length > 0) {
+ zeile.fehler(
+ `„${String(zeile.wert("location_id"))}“ fasst mehrere Standorte zusammen. Bitte einen davon angeben: ${unter.sort((a, b) => a.localeCompare(b, "de")).join(", ")}.`,
+ "location_id"
+ );
+ }
}
if (zeile.wert("zustaendige_hr_id") && !hrId(zeile.wert("zustaendige_hr_id"))) {
zeile.fehler(`„${String(zeile.wert("zustaendige_hr_id"))}“ ist kein aktives HR-Konto.`, "zustaendige_hr_id");
@@ -943,6 +953,34 @@ function eintragZu(zeile: Zeile, aktuell: Datensaetze, person: Person) {
return eintrag;
}
+/**
+ * Das Verhältnis, wie es gespeichert wird: aus der Auswahl und dem Text zu
+ * „Sonstige" (lib/verhaeltnis.ts). Steht eine der beiden Spalten nicht in
+ * der Zeile, gilt der bisherige Wert — der Text aber nur, solange
+ * „Sonstige" gewählt bleibt. `undefined` bei einem Widerspruch.
+ */
+function verhaeltnisDerZeile(zeile: Zeile, feld: string, alt: Record | null): string | null | undefined {
+ const textFeld = `${feld}_sonstige`;
+ const auswahl = (zeile.gesetzt(feld) ? zeile.wert(feld) : alt?.[feld]) as string | null | undefined;
+ const text = (zeile.gesetzt(textFeld) ? zeile.wert(textFeld) : auswahl === SONSTIGE ? alt?.[textFeld] : null) as
+ | string
+ | null
+ | undefined;
+ const ergebnis = verhaeltnisAusDatei(auswahl, text);
+ if ("fehler" in ergebnis) {
+ zeile.fehler(ergebnis.fehler, textFeld);
+ return undefined;
+ }
+ return ergebnis.wert;
+}
+
+/** Die geänderten Felder für die SQL-Funktion: Auswahl und Text als ein Verhältnis. */
+function mitVerhaeltnis(g: Map, feld: string, wert: string | null): Record {
+ const out = Object.fromEntries(g);
+ delete out[`${feld}_sonstige`];
+ return { ...out, [feld]: wert };
+}
+
function angehoerigerZeile(tx: Tx, zeile: Zeile, bestand: Bestand, aktuell: Datensaetze, { modus, heute }: { modus: Modus; heute: string }) {
const person = personZu(zeile, bestand);
if (!person) return;
@@ -953,9 +991,15 @@ function angehoerigerZeile(tx: Tx, zeile: Zeile, bestand: Bestand, aktuell: Date
if (eintrag === null) {
if (zeile.wert("entfernen") === "ja") return zeile.fehler("Ein neuer Eintrag lässt sich nicht entfernen.", "entfernen");
if (!pflichtNeu(zeile)) return;
+ const verhaeltnis = verhaeltnisDerZeile(zeile, "relationship", null);
+ if (verhaeltnis === undefined) return;
const g = zeile.geaendert(null);
zeile.schritt("Angehörige:r angelegt", "last_name", async () => {
- await rufe(tx, "add_employee_dependent", { employee_id: person.id, effective_date: datum, ...Object.fromEntries(g) });
+ await rufe(tx, "add_employee_dependent", {
+ employee_id: person.id,
+ effective_date: datum,
+ ...mitVerhaeltnis(g, "relationship", verhaeltnis),
+ });
});
return;
}
@@ -968,6 +1012,8 @@ function angehoerigerZeile(tx: Tx, zeile: Zeile, bestand: Bestand, aktuell: Date
});
return;
}
+ const verhaeltnis = verhaeltnisDerZeile(zeile, "relationship", eintrag.werte);
+ if (verhaeltnis === undefined) return;
const g = zeile.geaendert(eintrag.werte, (f) => f !== "id" && f !== "entfernen");
if (g.size === 0) return;
const neu = { ...eintrag.werte, ...Object.fromEntries(g) };
@@ -976,7 +1022,7 @@ function angehoerigerZeile(tx: Tx, zeile: Zeile, bestand: Bestand, aktuell: Date
dependent_id: id,
first_name: neu.first_name,
last_name: neu.last_name,
- relationship: neu.relationship,
+ relationship: verhaeltnis,
birth_date: neu.birth_date ?? "",
sv_nummer: neu.sv_nummer ?? "",
});
@@ -993,9 +1039,11 @@ function notfallkontaktZeile(tx: Tx, zeile: Zeile, bestand: Bestand, aktuell: Da
if (eintrag === null) {
if (zeile.wert("entfernen") === "ja") return zeile.fehler("Ein neuer Eintrag lässt sich nicht entfernen.", "entfernen");
if (!pflichtNeu(zeile)) return;
+ const verhaeltnis = verhaeltnisDerZeile(zeile, "relation", null);
+ if (verhaeltnis === undefined) return;
const g = zeile.geaendert(null);
zeile.schritt("Notfallkontakt angelegt", "name", async () => {
- await rufe(tx, "add_emergency_contact", { employee_id: person.id, ...Object.fromEntries(g) });
+ await rufe(tx, "add_emergency_contact", { employee_id: person.id, ...mitVerhaeltnis(g, "relation", verhaeltnis) });
});
return;
}
@@ -1008,10 +1056,12 @@ function notfallkontaktZeile(tx: Tx, zeile: Zeile, bestand: Bestand, aktuell: Da
});
return;
}
+ const verhaeltnis = verhaeltnisDerZeile(zeile, "relation", eintrag.werte);
+ if (verhaeltnis === undefined) return;
const g = zeile.geaendert(eintrag.werte, (f) => f !== "id" && f !== "entfernen");
if (g.size === 0) return;
const neu = { ...eintrag.werte, ...Object.fromEntries(g) };
zeile.schritt("Notfallkontakt geändert", [...g.keys()][0], async () => {
- await rufe(tx, "update_emergency_contact", { id, name: neu.name, phone: neu.phone, relation: neu.relation ?? "" });
+ await rufe(tx, "update_emergency_contact", { id, name: neu.name, phone: neu.phone, relation: verhaeltnis ?? "" });
});
}
diff --git a/lib/austausch/katalog.ts b/lib/austausch/katalog.ts
index 9a0ed80..3463216 100644
--- a/lib/austausch/katalog.ts
+++ b/lib/austausch/katalog.ts
@@ -227,7 +227,7 @@ const MITARBEITER_ROH: Spalte[] = [
feld("Vertrag und Arbeitszeit", "Beschäftigungsausmaß", "Beschäftigungsausmaß", "employment_type", auswahlAusKarte("Beschäftigungsausmaß"), {
hinweis: STUNDEN_HINWEIS,
}),
- feld("Vertrag und Arbeitszeit", "Wochenstunden", "Wochenstunden", "weekly_hours", { art: "zahl", nachkomma: 1 }, {
+ feld("Vertrag und Arbeitszeit", "Wochenstunden", "Wochenstunden", "weekly_hours", { art: "zahl", nachkomma: 2 }, {
hinweis: STUNDEN_HINWEIS,
}),
feld("Vertrag und Arbeitszeit", "Arbeitstage", "Arbeitstage", "work_days", {
@@ -273,7 +273,9 @@ const MITARBEITER_ROH: Spalte[] = [
hinweis: "Pflicht bei Dienstwagen „Ja“.",
}),
feld("Vertrag und Arbeitszeit", "Laterale Führung", "Laterale Führung", "is_laterale_fuehrung", JA_NEIN),
- feld("Vertrag und Arbeitszeit", "C-Level", "C-Level", "is_c_level", JA_NEIN),
+ feld("Vertrag und Arbeitszeit", "C-Level", "C-Level", "c_level", auswahlAusKarte("C-Level"), {
+ hinweis: "Der Code aus der Liste, etwa „C9“.",
+ }),
feld("Vertrag und Arbeitszeit", "Besonderer Kündigungsschutz", "Besonderer Kündigungsschutz", "has_kuendigungsschutz", JA_NEIN),
feld("Vertrag und Arbeitszeit", "Personenkreis", "Kündigungsschutz Personenkreis", "kuendigungsschutz_grund", auswahlAusKarte("Kündigungsschutz Personenkreis"), {
hinweis: KUENDIGUNGSSCHUTZ_HINWEIS,
@@ -328,7 +330,7 @@ const MITARBEITER_ROH: Spalte[] = [
{
titel: "Wochenstunden ab Rückkehr",
feld: "rueckkehr_stunden",
- format: { art: "zahl", nachkomma: 1 },
+ format: { art: "zahl", nachkomma: 2 },
thema: "Langzeitabwesenheit",
hinweis: "Pflicht bei „Reduziert“; weniger als 38,5.",
},
@@ -403,7 +405,7 @@ const MITARBEITER_ROH: Spalte[] = [
const IMMER_BELEGT = new Set([
"last_name", "first_name", "gender", "nationality", "location_id", "position_number", "job_title", "entry_date",
"employment_type", "weekly_hours", "contract_type", "source", "worker_type", "mitarbeiterart", "collective_agreement",
- "work_days", "is_betriebsrat", "has_dienstwagen", "is_laterale_fuehrung", "is_c_level", "has_kuendigungsschutz",
+ "work_days", "is_betriebsrat", "has_dienstwagen", "is_laterale_fuehrung", "has_kuendigungsschutz",
"hat_aufenthaltstitel", "ist_beguenstigt_behindert", "has_bonusanspruch", "ist_uebernahme_leiharbeit",
]);
@@ -469,8 +471,22 @@ const PERSONALNUMMER_VERWEIS: Spalte = {
pflicht: true,
};
-/** Verhältnis bei Angehörigen und Notfallkontakten: Liste oder eigener Text. */
-const VERHAELTNIS: Format = { art: "auswahl", optionen: anzeigeAuswahl(EMERGENCY_RELATIONS), frei: true };
+/**
+ * Verhältnis bei Angehörigen und Notfallkontakten: die Liste wie im Formular,
+ * und für „Sonstige" eine Spalte daneben mit dem eigenen Text
+ * (lib/verhaeltnis.ts).
+ */
+const VERHAELTNIS: Format = { art: "auswahl", optionen: anzeigeAuswahl(EMERGENCY_RELATIONS) };
+const VERHAELTNIS_HINWEIS = "Aus der Liste. Ist es keines davon: „Sonstige“ und den Text in der Spalte daneben.";
+
+function verhaeltnisSonstige(feld: string): Spalte {
+ return {
+ titel: "Verhältnis (Sonstige)",
+ feld,
+ format: TEXT,
+ hinweis: "Nur bei „Sonstige“, etwa Onkel oder Nachbarin. Leer bleibt es bei „Sonstige“.",
+ };
+}
const ENTFERNEN: Spalte = {
titel: "Entfernen",
@@ -485,6 +501,7 @@ export const BLATT_ANGEHOERIGE: Blatt = {
zweck: "Angehörige je Person. Leere ID = neu anlegen.",
schluessel: PERSONALNUMMER_VERWEIS,
wirksamAb: "Leer = heute. Gilt für Neuanlage und Entfernen.",
+ bedingungen: [{ feld: "relationship_sonstige", art: "leer", wenn: { feld: "relationship", nicht: "Sonstige" } }],
spalten: [
{ titel: "ID", feld: "id", format: TEXT, hinweis: "Vergibt das System. Leer = neuer Eintrag." },
{ titel: "Nachname", feld: "last_name", format: TEXT, pflichtNeu: true, pflicht: true },
@@ -495,8 +512,9 @@ export const BLATT_ANGEHOERIGE: Blatt = {
format: VERHAELTNIS,
pflichtNeu: true,
pflicht: true,
- hinweis: "Aus der Liste oder frei eingetragen, wie „Sonstige“ in der Personalakte.",
+ hinweis: VERHAELTNIS_HINWEIS,
},
+ verhaeltnisSonstige("relationship_sonstige"),
{ titel: "Geburtsdatum", feld: "birth_date", format: DATUM },
{ titel: "SV-Nummer", feld: "sv_nummer", format: TEXT },
ENTFERNEN,
@@ -508,6 +526,7 @@ export const BLATT_NOTFALLKONTAKTE: Blatt = {
zweck: "Notfallkontakte je Person. Leere ID = neu anlegen.",
schluessel: PERSONALNUMMER_VERWEIS,
wirksamAb: "Leer lassen: Notfallkontakte gelten sofort.",
+ bedingungen: [{ feld: "relation_sonstige", art: "leer", wenn: { feld: "relation", nicht: "Sonstige" } }],
spalten: [
{ titel: "ID", feld: "id", format: TEXT, hinweis: "Vergibt das System. Leer = neuer Eintrag." },
{ titel: "Name", feld: "name", format: TEXT, pflichtNeu: true, pflicht: true },
@@ -516,8 +535,9 @@ export const BLATT_NOTFALLKONTAKTE: Blatt = {
titel: "Verhältnis",
feld: "relation",
format: VERHAELTNIS,
- hinweis: "Aus der Liste oder frei eingetragen, wie „Sonstige“ in der Personalakte.",
+ hinweis: VERHAELTNIS_HINWEIS,
},
+ verhaeltnisSonstige("relation_sonstige"),
ENTFERNEN,
],
};
diff --git a/lib/austausch/laden.ts b/lib/austausch/laden.ts
index 3f26b25..95432ff 100644
--- a/lib/austausch/laden.ts
+++ b/lib/austausch/laden.ts
@@ -8,6 +8,7 @@ import { loadOrgMaps, type OrgMaps } from "../org";
import { loadPlacements, loadReportingLineMap, type Placement } from "../placement";
import { deriveStatusAsOf } from "../reports";
import type { Database } from "../types";
+import { verhaeltnisFuerDatei } from "../verhaeltnis";
import type { Listen } from "./herunterladen";
import type { Datensatz } from "./herunterladen";
@@ -132,7 +133,14 @@ export async function ladeAngehoerige(tx: Tx, personen: readonly Person[]): Prom
.orderBy("employee_id")
.orderBy("created_at")
.execute();
- return zeilen.map((z) => ({ schluessel: nummer.get(z.employee_id)!, kennung: z.id, werte: { ...z } }));
+ return zeilen.map((z) => {
+ const v = verhaeltnisFuerDatei(z.relationship);
+ return {
+ schluessel: nummer.get(z.employee_id)!,
+ kennung: z.id,
+ werte: { ...z, relationship: v.auswahl, relationship_sonstige: v.sonstige },
+ };
+ });
}
export async function ladeNotfallkontakte(tx: Tx, personen: readonly Person[]): Promise {
@@ -145,7 +153,14 @@ export async function ladeNotfallkontakte(tx: Tx, personen: readonly Person[]):
.orderBy("employee_id")
.orderBy("created_at")
.execute();
- return zeilen.map((z) => ({ schluessel: nummer.get(z.employee_id)!, kennung: z.id, werte: { ...z } }));
+ return zeilen.map((z) => {
+ const v = verhaeltnisFuerDatei(z.relation);
+ return {
+ schluessel: nummer.get(z.employee_id)!,
+ kennung: z.id,
+ werte: { ...z, relation: v.auswahl, relation_sonstige: v.sonstige },
+ };
+ });
}
export async function ladeHistorie(tx: Tx, personen: readonly Person[], b: Bezuege): Promise {
@@ -242,7 +257,13 @@ export async function ladeStandorte(tx: Tx): Promise {
*/
export async function ladeListen(tx: Tx, heute: string): Promise {
const [standorte, jobs, einheiten, stellen, kostenstellen, hr] = await Promise.all([
- tx.selectFrom("locations").select("name").orderBy("name").execute(),
+ // Ohne zusammenfassende Standorte wie „Shop": auf ihnen sitzt niemand.
+ tx
+ .selectFrom("locations as l")
+ .select("l.name")
+ .where((eb) => eb.not(eb.exists(eb.selectFrom("locations as u").select("u.id").whereRef("u.parent_id", "=", "l.id"))))
+ .orderBy("l.name")
+ .execute(),
tx.selectFrom("jobs").select("title").execute(),
tx.selectFrom("org_units").select("org_number").where("valid_to", "is", null).orderBy("org_number").execute(),
// Nur freie Planstellen: niemand sitzt heute oder später darauf, keine
diff --git a/lib/austausch/vergleich.ts b/lib/austausch/vergleich.ts
index 0fec33d..7cdf8ef 100644
--- a/lib/austausch/vergleich.ts
+++ b/lib/austausch/vergleich.ts
@@ -80,7 +80,9 @@ export const GRUPPE_JE_FELD: Readonly s + Math.round(w * 10), 0);
- if (summe !== Math.round(Number(stundenWert(stunden)) * 10)) {
- return `Die Summe des Arbeitszeitmodells beträgt ${String(summe / 10).replace(".", ",")} und muss den Wochenstunden entsprechen.`;
+ // In Hundertsteln gerechnet, wie lib/arbeitszeit.ts: 7,7 × 5 verfehlte sonst die 38,5.
+ const summe = werte.reduce((s, w) => s + Math.round(w * 100), 0);
+ if (summe !== Math.round(Number(stundenWert(stunden)) * 100)) {
+ return `Die Summe des Arbeitszeitmodells beträgt ${String(summe / 100).replace(".", ",")} und muss den Wochenstunden entsprechen.`;
}
}
return null;
diff --git a/lib/c-level.ts b/lib/c-level.ts
new file mode 100644
index 0000000..2bca76a
--- /dev/null
+++ b/lib/c-level.ts
@@ -0,0 +1,21 @@
+// C-Level: die Führungs- bzw. Funktionsstufe einer Person als Code.
+// Fachlich vorgegebene Liste; dieselben Werte stehen in chk_c_level
+// (Migration 20261123120000) — tests/unit/c-level.test.ts gleicht beide ab.
+//
+// Gespeichert und angezeigt wird nur der Code, in Formularen, Akte,
+// Historie, Berichten, Export und Import gleich.
+//
+// Freiwillig: leer heisst „nicht erfasst".
+
+export const C_LEVEL_CODES = ["C1", "C11", "C2", "C3", "C4", "C8", "C9", "MG", "P", "VD"] as const;
+
+export type CLevel = (typeof C_LEVEL_CODES)[number];
+
+/** Für Anzeigen ohne Wert. */
+export const OHNE_C_LEVEL = "Ohne C-Level";
+
+/** Auswahl für Formulare: Wert und Beschriftung sind der Code. */
+export const C_LEVEL_AUSWAHL: readonly { value: CLevel; label: string }[] = C_LEVEL_CODES.map((c) => ({
+ value: c,
+ label: c,
+}));
diff --git a/lib/extern-vorgaben.ts b/lib/extern-vorgaben.ts
index fe9aa2f..dc864eb 100644
--- a/lib/extern-vorgaben.ts
+++ b/lib/extern-vorgaben.ts
@@ -23,7 +23,6 @@ const VORGABEN = {
is_betriebsrat: false,
has_dienstwagen: false,
is_laterale_fuehrung: false,
- is_c_level: false,
has_kuendigungsschutz: false,
ist_beguenstigt_behindert: false,
has_bonusanspruch: false,
diff --git a/lib/historie-felder.ts b/lib/historie-felder.ts
index e6c07ce..da1c09a 100644
--- a/lib/historie-felder.ts
+++ b/lib/historie-felder.ts
@@ -1,5 +1,6 @@
import { ABSENCE_TYPES, KEINE_TEILZEITVARIANTE, STUNDEN_GRUENDE, statusLabel } from "./absence";
import { anzeige, anzeigeAuswahl } from "./anzeige";
+import { C_LEVEL_AUSWAHL } from "./c-level";
import { GESCHLECHTER } from "./geschlecht";
import { HAY_GRADE_WERTE } from "./hay-grade";
import { KOLLEKTIVVERTRAEGE } from "./kollektivvertrag";
@@ -88,7 +89,9 @@ export const FELD_OPTIONEN: Record = {
Dienstwagen: JA_NEIN,
Betriebsrat: JA_NEIN,
"Laterale Führung": JA_NEIN,
- "C-Level": JA_NEIN,
+ // Das abgelöste Ja/Nein (is_c_level); ältere Einträge tragen es.
+ "C-Level (Ja/Nein)": JA_NEIN,
+ "C-Level": C_LEVEL_AUSWAHL,
"Besonderer Kündigungsschutz": JA_NEIN,
"Begünstigt behindert": JA_NEIN,
Aufenthaltstitel: JA_NEIN,
diff --git a/lib/notes.ts b/lib/notes.ts
index 9d65bfb..c6a1de0 100644
--- a/lib/notes.ts
+++ b/lib/notes.ts
@@ -81,7 +81,7 @@ export function sichtbareNotizen(userId: string, spalte = "n.author_user_id"): E
* formatiert Postgres sie anders als der Treiber es sonst täte, und der
* Unterschied fällt erst beim Vergleichen auf.
*/
-export function offeneNotizenAbfrage(eb: OrgEb, userId: string) {
+export function offeneNotizenAbfrage(eb: OrgEb, userId: string, heute: string) {
return eb
.selectFrom("employee_notes as n")
.leftJoin("employees as e", "e.id", "n.employee_id")
@@ -101,6 +101,10 @@ export function offeneNotizenAbfrage(eb: OrgEb, userId: string) {
.select((x) => [zeitstempel(x.ref("n.created_at")).as("created_at"), zeitstempel(x.ref("n.done_at")).as("done_at")])
.where("n.done", "=", false)
.where(sichtbareNotizen(userId))
+ // Eine Notiz mit Fälligkeit erscheint erst an diesem Tag, fachlich so
+ // vorgegeben: vorher ist sie eine Wiedervorlage, keine Aufgabe. In der
+ // Akte steht sie unabhängig davon. Ohne Fälligkeit gleich.
+ .where((x) => x.or([x("n.due_date", "is", null), x("n.due_date", "<=", heute)]))
// Nach Fälligkeit, die nächste oben, fachlich so vorgegeben; ohne
// Fälligkeit danach, die jüngste zuerst.
.orderBy(sql`n.due_date asc nulls last`)
@@ -119,9 +123,9 @@ export function baueOffeneNotizen(rows: NotizZeile[], userId: string): OpenNote[
});
}
-export async function loadOpenNotes(tx: Tx, userId: string): Promise {
+export async function loadOpenNotes(tx: Tx, userId: string, heute: string): Promise {
const { notes } = await tx
- .selectNoFrom((eb) => [jsonArrayFrom(offeneNotizenAbfrage(eb, userId)).as("notes")])
+ .selectNoFrom((eb) => [jsonArrayFrom(offeneNotizenAbfrage(eb, userId, heute)).as("notes")])
.executeTakeFirstOrThrow();
return baueOffeneNotizen(notes as NotizZeile[], userId);
}
diff --git a/lib/report-criteria.ts b/lib/report-criteria.ts
index 9cda166..d84dca0 100644
--- a/lib/report-criteria.ts
+++ b/lib/report-criteria.ts
@@ -3,6 +3,7 @@ import { AUSTRITTSART_LABELS, AUSTRITTSARTEN, BEENDIGUNGSART_WERTE } from "./bee
import { fmtDate } from "./format";
import { GESCHLECHTER } from "./geschlecht";
import { HAY_GRADE_WERTE } from "./hay-grade";
+import { C_LEVEL_CODES } from "./c-level";
import { KUENDIGUNGSSCHUTZ_GRUENDE } from "./kuendigungsschutz";
import { MITARBEITERARTEN } from "./mitarbeiterart";
import { anzeige } from "./anzeige";
@@ -57,6 +58,7 @@ export const AUSWAHL_KRITERIEN: readonly AuswahlKriterium[] = [
{ key: "mitarbeiterart", label: "Anstellungs-/Beschäftigungsart", alle: "Alle Anstellungs-/Beschäftigungsarten", optionen: werte(...MITARBEITERARTEN) },
{ key: "kv", label: "Kollektivvertrag", alle: "Alle Kollektivverträge", optionen: werte(...KOLLEKTIVVERTRAEGE) },
{ key: "paygrade", label: "Hay-Grade", alle: "Alle Hay-Grades", optionen: werte(...HAY_GRADE_WERTE) },
+ { key: "clevel", label: "C-Level", alle: "Alle C-Level", optionen: C_LEVEL_CODES.map((c) => ({ wert: c, label: c })) },
{ key: "source", label: "Intern/Extern", alle: "Intern und Extern", optionen: werte("Intern", "Extern") },
{
key: "gender",
@@ -101,7 +103,6 @@ export const JANEIN_KRITERIEN: readonly JaNeinKriterium[] = [
{ key: "dienstwagen", label: "Dienstwagen" },
{ key: "betriebsrat", label: "Betriebsrat" },
{ key: "lateral", label: "Laterale Führung" },
- { key: "clevel", label: "C-Level" },
{ key: "kuendigungsschutz", label: "Besonderer Kündigungsschutz" },
{ key: "behindert", label: "Begünstigt behindert" },
// Die Auswertung der Übernahmen von Leiharbeitskräften. Das Ereignis
diff --git a/lib/reports-data.ts b/lib/reports-data.ts
index ffe9ee8..af16c02 100644
--- a/lib/reports-data.ts
+++ b/lib/reports-data.ts
@@ -5,6 +5,7 @@ import { ancestorsOf, loadOrgMaps, subtreeOf, type OrgMaps } from "./org";
import { istBereich } from "./org-art";
import { loadKontierungen } from "./cost-centers";
import { loadPlacements } from "./placement";
+import { zuweisbareStandorte } from "./standorte";
import type { Austrittsart } from "./types";
import { LEERE_CRITERIA, passtImSpeicher, type Criteria } from "./report-criteria";
import { werteListe } from "./werteliste";
@@ -77,6 +78,7 @@ export function applyCriteria(
if (a.mitarbeiterart?.length) q = q.where("mitarbeiterart", "in", a.mitarbeiterart as Mitarbeiterart[]);
if (a.kv?.length) q = q.where("collective_agreement", "in", a.kv as CollectiveAgreement[]);
if (a.paygrade?.length) q = q.where("paygrade", "in", a.paygrade as PaygradeType[]);
+ if (a.clevel?.length) q = q.where("c_level", "in", a.clevel);
if (a.source?.length) q = q.where("source", "in", a.source as SourceType[]);
if (a.gender?.length) q = q.where("gender", "in", a.gender as GenderType[]);
if (a.dienstwagenArt?.length) q = q.where("dienstwagen_art", "in", a.dienstwagenArt as DienstwagenArt[]);
@@ -93,7 +95,6 @@ export function applyCriteria(
if (j.dienstwagen) q = q.where("has_dienstwagen", "=", j.dienstwagen === "ja");
if (j.betriebsrat) q = q.where("is_betriebsrat", "=", j.betriebsrat === "ja");
if (j.lateral) q = q.where("is_laterale_fuehrung", "=", j.lateral === "ja");
- if (j.clevel) q = q.where("is_c_level", "=", j.clevel === "ja");
if (j.kuendigungsschutz) q = q.where("has_kuendigungsschutz", "=", j.kuendigungsschutz === "ja");
// „In einer Teilzeitvariante" heisst: es steht eine drin, gleich welche.
if (j.teilzeit === "ja") q = q.where("teilzeit_art", "is not", null);
@@ -181,10 +182,10 @@ export async function loadOrgLookups(tx: Tx): Promise<{
locations: { id: string; name: string }[];
}> {
const orgMaps = await loadOrgMaps(tx);
- const locations = orgMaps.locationList.map((l) => ({ id: l.id, name: l.name }));
+ const alleStandorte = orgMaps.locationList.map((l) => ({ id: l.id, name: l.name }));
return {
- lookups: lookupsFromOrgMaps(orgMaps, locations),
+ lookups: lookupsFromOrgMaps(orgMaps, alleStandorte),
orgMaps,
// Jede Ebene, nicht nur die Bereiche: wer eine einzelne Abteilung
// auswerten will, soll sie nicht über einen Umweg zusammensuchen müssen.
@@ -195,7 +196,9 @@ export async function loadOrgLookups(tx: Tx): Promise<{
depth: orgMaps.depthOf.get(u.id) ?? 0,
unitType: u.unit_type,
})),
- locations,
+ // Zur Auswahl nur Standorte, auf denen jemand sitzen kann; „Shop" selbst
+ // ergäbe immer eine leere Auswertung.
+ locations: zuweisbareStandorte(orgMaps.locationList).map((l) => ({ id: l.id, name: l.name })),
};
}
@@ -222,7 +225,7 @@ const SNAPSHOT_EMPLOYEE_COLUMNS = [
"is_betriebsrat",
"has_dienstwagen",
"is_laterale_fuehrung",
- "is_c_level",
+ "c_level",
"teilzeit_art",
"zustaendige_hr_id",
] as const;
@@ -310,7 +313,7 @@ export async function loadSnapshotEmployees(tx: Tx, filters: SnapshotFilters): P
is_betriebsrat: e.is_betriebsrat,
has_dienstwagen: e.has_dienstwagen,
is_laterale_fuehrung: e.is_laterale_fuehrung,
- is_c_level: e.is_c_level,
+ c_level: e.c_level,
teilzeit_art: e.teilzeit_art,
dependents_count: dependentsCounts.get(e.id) ?? 0,
// Ein gelöschtes Konto setzt die Zuordnung auf null (on delete set
diff --git a/lib/reports.ts b/lib/reports.ts
index f349b3b..6920775 100644
--- a/lib/reports.ts
+++ b/lib/reports.ts
@@ -2,6 +2,7 @@ import { ABSENCE_TYPES, statusLabel } from "./absence";
import { BEENDIGUNGSART_WERTE } from "./beendigung";
import { fmtName, todayIso, yearsBetweenIso } from "./format";
import { HAY_GRADE_WERTE, OHNE_HAY_GRADE } from "./hay-grade";
+import { C_LEVEL_CODES, OHNE_C_LEVEL } from "./c-level";
import { anzeige } from "./anzeige";
import { WOCHENTAGE } from "./wochentage";
import { werteListe } from "./werteliste";
@@ -138,7 +139,7 @@ export type ReportEmployee = {
is_betriebsrat: boolean;
has_dienstwagen: boolean;
is_laterale_fuehrung: boolean;
- is_c_level: boolean;
+ c_level: string | null;
teilzeit_art: string | null;
/**
* Die Kostenstelle der Planstelle zum Stichtag, als „Nummer · Bezeichnung";
@@ -265,7 +266,8 @@ export function groupKeyFor(e: ReportEmployee, dim: GroupDimension, lookups: Org
case "laterale_fuehrung":
return e.is_laterale_fuehrung ? "Ja" : "Nein";
case "c_level":
- return e.is_c_level ? "Ja" : "Nein";
+ // Eine eigene Gruppe statt „–": wer keine Stufe hat, ist hier eine Antwort.
+ return e.c_level || OHNE_C_LEVEL;
case "has_dependents":
return e.dependents_count > 0 ? "Ja" : "Nein";
case "teilzeit_art":
@@ -302,6 +304,7 @@ export function groupKeyFor(e: ReportEmployee, dim: GroupDimension, lookups: Org
const EIGENE_REIHENFOLGE: Partial> = {
weekday: WOCHENTAGE,
paygrade: [OHNE_HAY_GRADE, ...HAY_GRADE_WERTE],
+ c_level: [...C_LEVEL_CODES, OHNE_C_LEVEL],
};
function rang(dim: GroupDimension, key: string): number {
diff --git a/lib/shell-data.ts b/lib/shell-data.ts
index 663c949..cf458cc 100644
--- a/lib/shell-data.ts
+++ b/lib/shell-data.ts
@@ -67,7 +67,7 @@ export async function loadShellData(tx: Tx, userId: string): Promise(alle: readonly T[]): T[] {
+ return alle.filter((s) => !s.parent_id);
+}
+
+/** Die Unterstandorte eines Standorts, leer bei einem gewöhnlichen. */
+export function unterstandorte(alle: readonly T[], id: string): T[] {
+ return id ? alle.filter((s) => s.parent_id === id) : [];
+}
+
+/** Standorte, auf denen eine Person sitzen kann — für Filter und Importlisten. */
+export function zuweisbareStandorte(alle: readonly T[]): T[] {
+ const gruppen = new Set(alle.map((s) => s.parent_id).filter(Boolean));
+ return alle.filter((s) => !gruppen.has(s.id));
+}
+
+/** Welcher Eintrag der ersten Auswahl zu einem gespeicherten Standort gehört. */
+export function oberstandortVon(alle: readonly StandortEintrag[], id: string): string {
+ const s = alle.find((x) => x.id === id);
+ return s ? (s.parent_id ?? s.id) : "";
+}
+
+/** „Shop W17" unter „Shop" zeigt die zweite Auswahl als „W17". */
+export function kurzname(unter: StandortEintrag, ober: StandortEintrag | undefined): string {
+ const praefix = ober ? `${ober.name} ` : "";
+ return praefix && unter.name.startsWith(praefix) ? unter.name.slice(praefix.length) : unter.name;
+}
diff --git a/lib/testsystem.ts b/lib/testsystem.ts
new file mode 100644
index 0000000..764f850
--- /dev/null
+++ b/lib/testsystem.ts
@@ -0,0 +1,14 @@
+// Ob diese Installation ein Testsystem ist (TESTSYSTEM in der Konfiguration
+// des Servers). Dann trägt jede Seite den Schriftzug „Testsystem" und der
+// Titel im Browser-Tab beginnt damit — wer zwischen Test und Produktion
+// wechselt, sieht so auf einen Blick, wo er arbeitet.
+//
+// Gelesen wird zur Laufzeit, nicht beim Bauen: dasselbe Paket läuft in Test
+// und Produktion, und ohne den Eintrag erscheint nichts.
+
+export const TESTSYSTEM_SCHRIFTZUG = "Testsystem";
+
+export function istTestsystem(wert: string | undefined = process.env.TESTSYSTEM): boolean {
+ const w = wert?.trim().toLowerCase();
+ return w === "1" || w === "true" || w === "ja";
+}
diff --git a/lib/types.ts b/lib/types.ts
index 1df2e5f..d6e94fa 100644
--- a/lib/types.ts
+++ b/lib/types.ts
@@ -197,9 +197,9 @@ export type Database = {
public: {
Tables: {
locations: {
- Row: { id: string; name: string; country: string };
- Insert: { id?: string; name: string; country: string };
- Update: Partial<{ id: string; name: string; country: string }>;
+ Row: { id: string; name: string; country: string; parent_id: string | null };
+ Insert: { id?: string; name: string; country: string; parent_id?: string | null };
+ Update: Partial<{ id: string; name: string; country: string; parent_id: string | null }>;
};
profiles: {
Row: {
@@ -359,6 +359,8 @@ export type Database = {
emergency_contact_relation: string | null;
is_laterale_fuehrung: boolean;
is_c_level: boolean;
+ /** Code aus lib/c-level.ts (chk_c_level); null = nicht erfasst. */
+ c_level: string | null;
title_prefix: string[];
title_suffix: string[];
created_at: string;
@@ -433,6 +435,7 @@ export type Database = {
emergency_contact_relation?: string | null;
is_laterale_fuehrung?: boolean;
is_c_level?: boolean;
+ c_level?: string | null;
title_prefix?: string[];
title_suffix?: string[];
created_at?: string;
diff --git a/lib/verhaeltnis.ts b/lib/verhaeltnis.ts
new file mode 100644
index 0000000..60e4b72
--- /dev/null
+++ b/lib/verhaeltnis.ts
@@ -0,0 +1,41 @@
+import { EMERGENCY_RELATIONS } from "./types";
+
+// Das Verhältnis bei Angehörigen und Notfallkontakten: ein Wert aus der Liste,
+// und unter „Sonstige" ein frei eingetragener Text. Gespeichert wird dann der
+// Text selbst („Onkel"); steht nichts darin, bleibt „Sonstige" gespeichert
+// (components/employees/VerhaeltnisField.tsx).
+//
+// Die Austauschdatei führt beides wie das Formular in zwei Spalten: die
+// Auswahl und daneben den Text zu „Sonstige". So bleibt die Auswahl in Excel
+// eine feste Liste, und ein eigener Text hat trotzdem seinen Platz.
+
+export const SONSTIGE = "Sonstige";
+
+/** Ob ein gespeicherter Wert frei eingetragen wurde. */
+export function istFreiesVerhaeltnis(wert: string): boolean {
+ return wert.trim() !== "" && !(EMERGENCY_RELATIONS as readonly string[]).includes(wert);
+}
+
+/** Der gespeicherte Wert, aufgeteilt in Auswahl und Text zu „Sonstige". */
+export function verhaeltnisFuerDatei(gespeichert: string | null | undefined): { auswahl: string | null; sonstige: string | null } {
+ const wert = gespeichert ?? "";
+ if (istFreiesVerhaeltnis(wert)) return { auswahl: SONSTIGE, sonstige: wert };
+ return { auswahl: wert || null, sonstige: null };
+}
+
+/**
+ * Auswahl und Text aus der Datei zum Wert, der gespeichert wird. Ein Text
+ * ohne „Sonstige" ist ein Widerspruch; welche der beiden Angaben gilt, lässt
+ * sich nicht entscheiden.
+ */
+export function verhaeltnisAusDatei(
+ auswahl: string | null | undefined,
+ sonstige: string | null | undefined
+): { wert: string | null } | { fehler: string } {
+ const text = sonstige?.trim() ?? "";
+ if (text && auswahl !== SONSTIGE) {
+ return { fehler: `Ein Text zu „Sonstige“ steht nur bei der Auswahl „Sonstige“.` };
+ }
+ if (auswahl === SONSTIGE && text) return { wert: text };
+ return { wert: auswahl ?? null };
+}
diff --git a/lib/wiedereintritt.ts b/lib/wiedereintritt.ts
index 9ff0e37..5261b2e 100644
--- a/lib/wiedereintritt.ts
+++ b/lib/wiedereintritt.ts
@@ -103,7 +103,7 @@ export function vorbelegungAus(employee: EmployeeRow): Partial {
// „Verbrenner" ist dabei die Vorgabe, nicht eine Behauptung.
dienstwagenArt: employee.dienstwagen_art ?? "Verbrenner",
isLateraleFuehrung: employee.is_laterale_fuehrung,
- isCLevel: employee.is_c_level,
+ cLevel: employee.c_level ?? "",
// Leer: die Notfallkontakte stehen in employee_emergency_contacts und
// bleiben beim Wiedereintritt erhalten. Das Feld im Assistenten nimmt nur
// einen weiteren auf. Vorbelegt aus den Spalten an der Person käme ein
diff --git a/lib/wochenstunden.ts b/lib/wochenstunden.ts
index 00c622f..6537249 100644
--- a/lib/wochenstunden.ts
+++ b/lib/wochenstunden.ts
@@ -13,6 +13,15 @@ export function stundenWert(text: string): string {
return text.trim().replace(",", ".");
}
+/**
+ * Höchstens zwei Nachkommastellen, wie die Spalte (numeric(4,2)). Eine
+ * dritte rundete die Datenbank stillschweigend weg, und gespeichert wäre ein
+ * anderer Wert als der eingegebene.
+ */
+export function nachkommaFehler(text: string): string | null {
+ return /\.\d{3,}$/.test(stundenWert(text)) ? "Wochenstunden haben höchstens zwei Nachkommastellen." : null;
+}
+
/**
* Fehlertext oder null. Ohne Beschäftigungsausmaß wird nur der Rahmen
* geprüft (mehr als 0, höchstens 38,5).
@@ -21,6 +30,8 @@ export function wochenstundenFehler(ausmass: string | undefined, text: string):
const wert = stundenWert(text);
const stunden = Number(wert);
const zahl = wert !== "" && Number.isFinite(stunden);
+ const nachkomma = nachkommaFehler(text);
+ if (nachkomma) return nachkomma;
if (ausmass === "Teilzeit" && (!zahl || stunden <= 0 || stunden >= VOLLZEIT_STUNDEN)) {
return "Wochenstunden bei Teilzeit müssen zwischen 0 und 38,5 liegen.";
}
diff --git a/package-lock.json b/package-lock.json
index b7a1428..0515fa9 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,19 +1,19 @@
{
"name": "alpenwerk-hr",
- "version": "0.2.1",
+ "version": "0.2.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "alpenwerk-hr",
- "version": "0.2.1",
+ "version": "0.2.2",
"dependencies": {
"@dagrejs/dagre": "^3.0.0",
"@xyflow/react": "^12.11.2",
"exceljs": "^4.4.0",
"kysely": "^0.29.4",
"lucide-react": "^1.26.0",
- "next": "^16.4.3",
+ "next": "^16.4.6",
"next-auth": "^5.0.0-beta.32",
"pg": "^8.22.0",
"react": "^19.2.8",
@@ -31,7 +31,7 @@
"@types/react-dom": "^19.2.3",
"@vitest/coverage-v8": "^4.1.12",
"eslint": "^9.39.5",
- "eslint-config-next": "^16.4.3",
+ "eslint-config-next": "^16.4.6",
"jsdom": "^29.1.1",
"postcss": "^8.5.19",
"tailwindcss": "^4.3.3",
@@ -1059,9 +1059,6 @@
"cpu": [
"arm"
],
- "libc": [
- "glibc"
- ],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -1078,9 +1075,6 @@
"cpu": [
"arm64"
],
- "libc": [
- "glibc"
- ],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -1097,9 +1091,6 @@
"cpu": [
"ppc64"
],
- "libc": [
- "glibc"
- ],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -1116,9 +1107,6 @@
"cpu": [
"riscv64"
],
- "libc": [
- "glibc"
- ],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -1135,9 +1123,6 @@
"cpu": [
"s390x"
],
- "libc": [
- "glibc"
- ],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -1154,9 +1139,6 @@
"cpu": [
"x64"
],
- "libc": [
- "glibc"
- ],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -1173,9 +1155,6 @@
"cpu": [
"arm64"
],
- "libc": [
- "musl"
- ],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -1192,9 +1171,6 @@
"cpu": [
"x64"
],
- "libc": [
- "musl"
- ],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -1211,9 +1187,6 @@
"cpu": [
"arm"
],
- "libc": [
- "glibc"
- ],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -1236,9 +1209,6 @@
"cpu": [
"arm64"
],
- "libc": [
- "glibc"
- ],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -1261,9 +1231,6 @@
"cpu": [
"ppc64"
],
- "libc": [
- "glibc"
- ],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -1286,9 +1253,6 @@
"cpu": [
"riscv64"
],
- "libc": [
- "glibc"
- ],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -1311,9 +1275,6 @@
"cpu": [
"s390x"
],
- "libc": [
- "glibc"
- ],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -1336,9 +1297,6 @@
"cpu": [
"x64"
],
- "libc": [
- "glibc"
- ],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -1361,9 +1319,6 @@
"cpu": [
"arm64"
],
- "libc": [
- "musl"
- ],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -1386,9 +1341,6 @@
"cpu": [
"x64"
],
- "libc": [
- "musl"
- ],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -1573,15 +1525,15 @@
}
},
"node_modules/@next/env": {
- "version": "16.4.3",
- "resolved": "https://registry.npmjs.org/@next/env/-/env-16.4.3.tgz",
- "integrity": "sha512-a7tz1QCcWWkwC/rPJcPMJk/UNRu9CFhDd3OHYE5hddbJrs8BqRTalxI6GlKCWEGzRLHN+S/B7a4PAHCtm25aBQ==",
+ "version": "16.4.6",
+ "resolved": "https://registry.npmjs.org/@next/env/-/env-16.4.6.tgz",
+ "integrity": "sha512-SunBjJ6t+oBtecS3dTjdVuMhUogP5wD/vrGL5EVuQYM1iS4O5ilL51HkiJ3sPjMzRHiCChvr4dbaSJbR7F3lxA==",
"license": "MIT"
},
"node_modules/@next/eslint-plugin-next": {
- "version": "16.4.3",
- "resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-16.4.3.tgz",
- "integrity": "sha512-oxuC06wt/71h6ACYCV9GbKOfnf5a7VlRe/p80YHTut15TNgDEmynDnaq8t/xhy5rlvk7dhItIPs6H3rvIM4kyw==",
+ "version": "16.4.6",
+ "resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-16.4.6.tgz",
+ "integrity": "sha512-HdqERVOafOD8JaUSAkwf9aSu/1rsHlkN8C5GcXYBH3C/z1MxBhZFxB5rz/xqMMRiIj7r9tIv8OCLQ9JWUxCvWA==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -1590,9 +1542,9 @@
}
},
"node_modules/@next/swc-darwin-arm64": {
- "version": "16.4.3",
- "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-16.4.3.tgz",
- "integrity": "sha512-4yq5EXBt+VDtAZwTyfijaFp5D2C5oz3Ikw5a2kiX2K9nw72vrZX2q5UuAlkPtUMO1tQz6JTKpaKWjS7OOefTDQ==",
+ "version": "16.4.6",
+ "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-16.4.6.tgz",
+ "integrity": "sha512-kJ4VVZkley17xKaJx72QN2IBqjrj7zenCQZaUF0l9ShS/1Mt2kW4+Z5KGG6vgr3L/J562xTOizVyM1iA/u5nlg==",
"cpu": [
"arm64"
],
@@ -1606,9 +1558,9 @@
}
},
"node_modules/@next/swc-darwin-x64": {
- "version": "16.4.3",
- "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-16.4.3.tgz",
- "integrity": "sha512-1Rvkn/LUhnEF8WxnRkOrqGhbwXui1bkWFxONKIbN+r7C+9KHDSZ+iUoj4CzymVMWUyZIyx9szcb9+kbKhD500A==",
+ "version": "16.4.6",
+ "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-16.4.6.tgz",
+ "integrity": "sha512-eIPGZIqC+8JKaeZmvnCANJQF4xWkkHqSnAAajtFxgwDMAOnCgxNvP52SeWZ41PyVwoe+Le/NQuZSaQ8j7YshSA==",
"cpu": [
"x64"
],
@@ -1622,15 +1574,12 @@
}
},
"node_modules/@next/swc-linux-arm64-gnu": {
- "version": "16.4.3",
- "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-16.4.3.tgz",
- "integrity": "sha512-dCKpXErGg3abUM6t5JTJV/ottVBTStJB5lRJTbgdUdQaQ+jNHiK56Hsc0YAEg/rinSh42hYG3HWiYmEMdilnxg==",
+ "version": "16.4.6",
+ "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-16.4.6.tgz",
+ "integrity": "sha512-9nI6O8vvczH2D9ZNdMGqb/3NuT15T9ksOZnAmx9/gjF2cOi74+xxyf1Hk96uIMfm14c9y6wHeBq6SH8g6udvcA==",
"cpu": [
"arm64"
],
- "libc": [
- "glibc"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -1641,15 +1590,12 @@
}
},
"node_modules/@next/swc-linux-arm64-musl": {
- "version": "16.4.3",
- "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-16.4.3.tgz",
- "integrity": "sha512-WwYbhWkhYBvBtib1K4W0kL8MW2snBD2A5b3SN4vPpqalZbZs5+bQ1yzAdepVoOqrFfEW3dmREy4Zs1MrWcrFbw==",
+ "version": "16.4.6",
+ "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-16.4.6.tgz",
+ "integrity": "sha512-7/qPhTxDp2ScluOJOhLuhWmlA17o1yZ0SIgpISBCpBxXgtnK4+KGywBpFkfLPiU1rnSM1faFGzYkH6i7JdTrqA==",
"cpu": [
"arm64"
],
- "libc": [
- "musl"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -1660,15 +1606,12 @@
}
},
"node_modules/@next/swc-linux-x64-gnu": {
- "version": "16.4.3",
- "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-16.4.3.tgz",
- "integrity": "sha512-QymWvfUwDEC5/lpJOsxX5VAbyoR2D13+2Jsjz4be7gT4LPqEgdpkeLIR/HFfCLgKzoMhpJbp6I/JnogyNZHcaA==",
+ "version": "16.4.6",
+ "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-16.4.6.tgz",
+ "integrity": "sha512-oOpbNa8XOW1qCGd9VvzC4fbkkRxEls7/WI6tz+YHC0xRA7KpV1U7DrAnCPjzVyOk/karzWEepCOcTIDmwK8FwQ==",
"cpu": [
"x64"
],
- "libc": [
- "glibc"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -1679,15 +1622,12 @@
}
},
"node_modules/@next/swc-linux-x64-musl": {
- "version": "16.4.3",
- "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-16.4.3.tgz",
- "integrity": "sha512-Vmjd9D7DpA4Vv3cUlr82QWgJD/BQZmns801vtC5VWHg6jCIA4a5vMKpQnfrM2pyCrp2eV0ENdUg4PlN3bAc2Yw==",
+ "version": "16.4.6",
+ "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-16.4.6.tgz",
+ "integrity": "sha512-aM8CZ+OR2EwXaAYw7KGkW2GDmNDsLBIRe1MMRZCJPTdw/xhTD0IMUVO4sf3KqrzuRouGzwwLZn34+gFeVXiUQA==",
"cpu": [
"x64"
],
- "libc": [
- "musl"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -1698,9 +1638,9 @@
}
},
"node_modules/@next/swc-win32-arm64-msvc": {
- "version": "16.4.3",
- "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-16.4.3.tgz",
- "integrity": "sha512-lG1pPdPLk7gTyGb00n5JIMLdBJgjb+UEhSdZvFbhUMg0DyC6z4B7RnpSKF9VCd4imkLObVbXOFA0kFCpw7yFow==",
+ "version": "16.4.6",
+ "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-16.4.6.tgz",
+ "integrity": "sha512-U0p7/tEtqvHX2crhd841CDwKtp5CFkKXVjOhmfccR3Pvp64sj8KBwRqsvltqLOwVBbj0NtkxwXSDpEHYGbxeXQ==",
"cpu": [
"arm64"
],
@@ -1714,9 +1654,9 @@
}
},
"node_modules/@next/swc-win32-x64-msvc": {
- "version": "16.4.3",
- "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-16.4.3.tgz",
- "integrity": "sha512-NmQC9RkJdnPXRaMxtkCzobB3teVjqF33oSOnwDfi+XYGWWYpt+xlGK3mtktSKLbdjwaWbJu2OkkMiRFGUUncKg==",
+ "version": "16.4.6",
+ "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-16.4.6.tgz",
+ "integrity": "sha512-3ZG15/5WIdlTQsIEvc9sPTTSL5XFrlLklIKmfF4fwsDnoAhu6NcBDXsk3mbGxNyo6aVLEGex+fHCv2MahY7a9g==",
"cpu": [
"x64"
],
@@ -1906,9 +1846,6 @@
"arm64"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -1926,9 +1863,6 @@
"arm64"
],
"dev": true,
- "libc": [
- "musl"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -1946,9 +1880,6 @@
"ppc64"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -1966,9 +1897,6 @@
"s390x"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -1986,9 +1914,6 @@
"x64"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -2006,9 +1931,6 @@
"x64"
],
"dev": true,
- "libc": [
- "musl"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -2232,9 +2154,6 @@
"arm64"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -2252,9 +2171,6 @@
"arm64"
],
"dev": true,
- "libc": [
- "musl"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -2272,9 +2188,6 @@
"x64"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -2292,9 +2205,6 @@
"x64"
],
"dev": true,
- "libc": [
- "musl"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -2984,9 +2894,6 @@
"arm64"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -3001,9 +2908,6 @@
"arm64"
],
"dev": true,
- "libc": [
- "musl"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -3018,9 +2922,6 @@
"loong64"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -3035,9 +2936,6 @@
"loong64"
],
"dev": true,
- "libc": [
- "musl"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -3052,9 +2950,6 @@
"ppc64"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -3069,9 +2964,6 @@
"riscv64"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -3086,9 +2978,6 @@
"riscv64"
],
"dev": true,
- "libc": [
- "musl"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -3103,9 +2992,6 @@
"s390x"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -3120,9 +3006,6 @@
"x64"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -3137,9 +3020,6 @@
"x64"
],
"dev": true,
- "libc": [
- "musl"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -4975,13 +4855,13 @@
}
},
"node_modules/eslint-config-next": {
- "version": "16.4.3",
- "resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-16.4.3.tgz",
- "integrity": "sha512-j9IqBma6abp800frdUURaizYMgXOK+jNGyq6CsYcM9AxpSJs5D/TgMNGeAmRUilZvA7g9V1Tr71gNg9/SVTuMQ==",
+ "version": "16.4.6",
+ "resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-16.4.6.tgz",
+ "integrity": "sha512-IBGGrVf9E6pL0NGL0hmeicVGeSyv1VEzIWq6IecDqkw+YFByhEtDJS9u1r6s6a1VxK6rssh69KyNFQUgfaacqw==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@next/eslint-plugin-next": "16.4.3",
+ "@next/eslint-plugin-next": "16.4.6",
"eslint-import-resolver-node": "^0.3.6",
"eslint-import-resolver-typescript": "^3.5.2",
"eslint-plugin-import": "^2.32.0",
@@ -7099,9 +6979,6 @@
"arm64"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -7123,9 +7000,6 @@
"arm64"
],
"dev": true,
- "libc": [
- "musl"
- ],
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -7147,9 +7021,6 @@
"x64"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -7171,9 +7042,6 @@
"x64"
],
"dev": true,
- "libc": [
- "musl"
- ],
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -7569,12 +7437,12 @@
"license": "MIT"
},
"node_modules/next": {
- "version": "16.4.3",
- "resolved": "https://registry.npmjs.org/next/-/next-16.4.3.tgz",
- "integrity": "sha512-OqxKTGi9u80FydydsMNYNjnuje9Au+kvHlt2GZ//ftdpDHm1dxKqAaENoOOTX5wKzn+9vaKUNIfZeyZUuLhCnA==",
+ "version": "16.4.6",
+ "resolved": "https://registry.npmjs.org/next/-/next-16.4.6.tgz",
+ "integrity": "sha512-QZJiYhaZLJMo2KpkQGQIwvmd79WVsAWeYIU554a8d7zArS3si/IRy3lBNV/rtYhE70oLwdLYhPAXLPx8HwcwtA==",
"license": "MIT",
"dependencies": {
- "@next/env": "16.4.3",
+ "@next/env": "16.4.6",
"@swc/helpers": "0.5.23",
"baseline-browser-mapping": "^2.9.19",
"caniuse-lite": "^1.0.30001579",
@@ -7588,14 +7456,14 @@
"node": ">=20.9.0"
},
"optionalDependencies": {
- "@next/swc-darwin-arm64": "16.4.3",
- "@next/swc-darwin-x64": "16.4.3",
- "@next/swc-linux-arm64-gnu": "16.4.3",
- "@next/swc-linux-arm64-musl": "16.4.3",
- "@next/swc-linux-x64-gnu": "16.4.3",
- "@next/swc-linux-x64-musl": "16.4.3",
- "@next/swc-win32-arm64-msvc": "16.4.3",
- "@next/swc-win32-x64-msvc": "16.4.3",
+ "@next/swc-darwin-arm64": "16.4.6",
+ "@next/swc-darwin-x64": "16.4.6",
+ "@next/swc-linux-arm64-gnu": "16.4.6",
+ "@next/swc-linux-arm64-musl": "16.4.6",
+ "@next/swc-linux-x64-gnu": "16.4.6",
+ "@next/swc-linux-x64-musl": "16.4.6",
+ "@next/swc-win32-arm64-msvc": "16.4.6",
+ "@next/swc-win32-x64-msvc": "16.4.6",
"sharp": "^0.35.5"
},
"peerDependencies": {
@@ -9939,9 +9807,6 @@
"arm64"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -9963,9 +9828,6 @@
"arm64"
],
"dev": true,
- "libc": [
- "musl"
- ],
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -9987,9 +9849,6 @@
"x64"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -10011,9 +9870,6 @@
"x64"
],
"dev": true,
- "libc": [
- "musl"
- ],
"license": "MPL-2.0",
"optional": true,
"os": [
diff --git a/package.json b/package.json
index b55804f..f3fb51c 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "alpenwerk-hr",
- "version": "0.2.1",
+ "version": "0.2.2",
"private": true,
"scripts": {
"dev": "next dev",
@@ -25,7 +25,7 @@
"exceljs": "^4.4.0",
"kysely": "^0.29.4",
"lucide-react": "^1.26.0",
- "next": "^16.4.3",
+ "next": "^16.4.6",
"next-auth": "^5.0.0-beta.32",
"pg": "^8.22.0",
"react": "^19.2.8",
@@ -43,7 +43,7 @@
"@types/react-dom": "^19.2.3",
"@vitest/coverage-v8": "^4.1.12",
"eslint": "^9.39.5",
- "eslint-config-next": "^16.4.3",
+ "eslint-config-next": "^16.4.6",
"jsdom": "^29.1.1",
"postcss": "^8.5.19",
"tailwindcss": "^4.3.3",
diff --git a/tests/components/HireWizardEntwurf.test.tsx b/tests/components/HireWizardEntwurf.test.tsx
index 3e66106..064c121 100644
--- a/tests/components/HireWizardEntwurf.test.tsx
+++ b/tests/components/HireWizardEntwurf.test.tsx
@@ -35,7 +35,7 @@ vi.mock("@/actions/hireDrafts", () => ({
}));
vi.mock("next/navigation", () => ({ useRouter: () => ({ refresh: vi.fn(), push: vi.fn() }) }));
-const LOCATIONS = [{ id: "l1", name: "Wien", country: "Österreich" }];
+const LOCATIONS = [{ id: "l1", name: "Wien", country: "Österreich", parent_id: null }];
function zeige(resumeDraft: { id: string; step: number; payload: Record } | null = null) {
const onClose = vi.fn();
diff --git a/tests/components/HireWizardSchritte.test.tsx b/tests/components/HireWizardSchritte.test.tsx
index d6e9eb1..a4a97e6 100644
--- a/tests/components/HireWizardSchritte.test.tsx
+++ b/tests/components/HireWizardSchritte.test.tsx
@@ -40,7 +40,7 @@ const POSITION = {
kostenstelle: null,
} as unknown as OpenPositionResolved;
-const LOCATIONS = [{ id: "l1", name: "Wien", country: "AT" }];
+const LOCATIONS = [{ id: "l1", name: "Wien", country: "AT", parent_id: null }];
/** Ein Entwurf, in dem alles bis einschliesslich Vertrag vollständig ist. */
const VOLLSTAENDIG = {
diff --git a/tests/components/KarenzPanel.test.tsx b/tests/components/KarenzPanel.test.tsx
new file mode 100644
index 0000000..cd2c6e9
--- /dev/null
+++ b/tests/components/KarenzPanel.test.tsx
@@ -0,0 +1,48 @@
+import { render, screen } from "@testing-library/react";
+import { describe, expect, it, vi } from "vitest";
+import { KarenzPanel } from "@/components/employees/panels/KarenzPanel";
+import { ToastProvider } from "@/components/ui/Toast";
+import type { Database } from "@/lib/types";
+
+vi.mock("@/actions/employees", () => ({
+ rueckkehrAnpassen: vi.fn(async () => ({ success: true })),
+ startKarenz: vi.fn(async () => ({ success: true })),
+}));
+vi.mock("next/navigation", () => ({ useRouter: () => ({ refresh: vi.fn(), push: vi.fn() }) }));
+
+type EmployeeRow = Database["public"]["Tables"]["employees"]["Row"];
+
+function zeige(absenceType: string) {
+ const employee = {
+ id: "e1",
+ first_name: "Magdalena",
+ last_name: "Zeller",
+ job_title: "Schnitte",
+ weekly_hours: 38.5,
+ absence_type: absenceType,
+ karenz_start_date: "2026-09-01",
+ karenz_return_date: "2027-08-31",
+ geburtstermin_voraussichtlich: null,
+ geburtstermin_tatsaechlich: null,
+ } as unknown as EmployeeRow;
+ return render(
+
+ {}} employee={employee} status="Karenz" history={[]} today="2026-11-23" />
+
+ );
+}
+
+// Auf den Mutterschutz folgt die Karenz; bei anderen Arten gibt es keine
+// anschliessende Abwesenheit.
+describe("KarenzPanel: anschliessende Abwesenheit", () => {
+ it("bietet sie bei der Wochenhilfe an", () => {
+ zeige("Wochenhilfe (Mutterschutz)");
+ expect(screen.getByRole("button", { name: "Anschliessende Abwesenheit planen" })).toBeInTheDocument();
+ });
+
+ it("bietet sie bei anderen Arten nicht an", () => {
+ zeige("Bildungskarenz");
+ expect(screen.queryByRole("button", { name: "Anschliessende Abwesenheit planen" })).not.toBeInTheDocument();
+ expect(screen.getByLabelText(/^Endet am/)).toBeInTheDocument();
+ });
+});
diff --git a/tests/components/RoleEmploymentFields.test.tsx b/tests/components/RoleEmploymentFields.test.tsx
index e6a974a..d3d0b84 100644
--- a/tests/components/RoleEmploymentFields.test.tsx
+++ b/tests/components/RoleEmploymentFields.test.tsx
@@ -18,7 +18,7 @@ const WERT: RoleEmploymentValue = {
hasDienstwagen: false,
dienstwagenArt: "Verbrenner",
isLateraleFuehrung: false,
- isCLevel: false,
+ cLevel: "",
hasKuendigungsschutz: false,
kuendigungsschutzBis: "",
kuendigungsschutzGrund: "",
diff --git a/tests/components/StandortAuswahl.test.tsx b/tests/components/StandortAuswahl.test.tsx
new file mode 100644
index 0000000..111aa86
--- /dev/null
+++ b/tests/components/StandortAuswahl.test.tsx
@@ -0,0 +1,53 @@
+import { fireEvent, render, screen } from "@testing-library/react";
+import { useState } from "react";
+import { describe, expect, it } from "vitest";
+import { StandortAuswahl } from "@/components/employees/StandortAuswahl";
+
+const STANDORTE = [
+ { id: "hernals", name: "Wien-Hernals", country: "Österreich", parent_id: null },
+ { id: "shop", name: "Shop", country: "Österreich", parent_id: null },
+ { id: "w17", name: "Shop W17", country: "Österreich", parent_id: "shop" },
+ { id: "wodo", name: "Shop Wodo", country: "Österreich", parent_id: "shop" },
+];
+
+function Formular({ start = "" }: { start?: string }) {
+ const [wert, setWert] = useState(start);
+ return (
+ <>
+
+ {wert}
+ >
+ );
+}
+
+describe("StandortAuswahl", () => {
+ it("zeigt zuerst nur die oberste Ebene", () => {
+ render( );
+ const optionen = Array.from((screen.getByLabelText(/^Standort/) as HTMLSelectElement).options).map((o) => o.value);
+ expect(optionen).toEqual(["", "hernals", "shop"]);
+ expect(screen.queryByLabelText(/^Shop/)).not.toBeInTheDocument();
+ });
+
+ it("verlangt unter „Shop“ den einzelnen Shop und meldet erst ihn", () => {
+ render( );
+ fireEvent.change(screen.getByLabelText(/^Standort/), { target: { value: "shop" } });
+ expect(screen.getByTestId("stand").textContent).toBe("");
+ const shops = screen.getByLabelText(/^Shop/) as HTMLSelectElement;
+ expect(Array.from(shops.options).map((o) => o.text)).toEqual(["Bitte wählen…", "W17", "Wodo"]);
+ fireEvent.change(shops, { target: { value: "wodo" } });
+ expect(screen.getByTestId("stand").textContent).toBe("wodo");
+ });
+
+ it("öffnet einen gespeicherten Shop mit beiden Auswahlen", () => {
+ render( );
+ expect((screen.getByLabelText(/^Standort/) as HTMLSelectElement).value).toBe("shop");
+ expect((screen.getByLabelText(/^Shop/) as HTMLSelectElement).value).toBe("w17");
+ });
+
+ it("schliesst die zweite Auswahl beim Wechsel auf einen gewöhnlichen Standort", () => {
+ render( );
+ fireEvent.change(screen.getByLabelText(/^Standort/), { target: { value: "hernals" } });
+ expect(screen.getByTestId("stand").textContent).toBe("hernals");
+ expect(screen.queryByLabelText(/^Shop/)).not.toBeInTheDocument();
+ });
+});
diff --git a/tests/components/UebernahmeWizard.test.tsx b/tests/components/UebernahmeWizard.test.tsx
index e233b8e..529b249 100644
--- a/tests/components/UebernahmeWizard.test.tsx
+++ b/tests/components/UebernahmeWizard.test.tsx
@@ -60,7 +60,7 @@ const MIT_STAATSBUERGERSCHAFT = { ...EXTERN, nationality: "Deutschland" } as Emp
function zeige(employee: EmployeeRow = MIT_STAATSBUERGERSCHAFT) {
return render(
- {}} employee={employee} locations={[{ id: "l1", name: "Wien", country: "Österreich" }]} />
+ {}} employee={employee} locations={[{ id: "l1", name: "Wien", country: "Österreich", parent_id: null }]} />
);
}
@@ -102,7 +102,7 @@ describe("Übernahme", () => {
open
onClose={() => {}}
employee={{ ...EXTERN, birth_date: "2090-01-01" } as EmployeeRow}
- locations={[{ id: "l1", name: "Wien", country: "Österreich" }]}
+ locations={[{ id: "l1", name: "Wien", country: "Österreich", parent_id: null }]}
/>
);
diff --git a/tests/components/VertragTab.test.tsx b/tests/components/VertragTab.test.tsx
index ff393a3..c8dc098 100644
--- a/tests/components/VertragTab.test.tsx
+++ b/tests/components/VertragTab.test.tsx
@@ -57,6 +57,7 @@ function mitarbeiter(teil: Partial = {}): EmployeeRow {
teilzeit_bis: null,
is_laterale_fuehrung: false,
is_c_level: false,
+ c_level: null,
title_prefix: [],
title_suffix: [],
emergency_contact_name: null,
@@ -87,7 +88,16 @@ describe("VertragTab — Merkmale", () => {
render( );
expect(wertZu("Dienstwagen")).toBe("Nein");
expect(wertZu("Betriebsrat")).toBe("Nein");
- expect(wertZu("C-Level")).toBe("Nein");
+ });
+
+ it("zeigt C-Level als Code", () => {
+ render( );
+ expect(wertZu("C-Level")).toBe("C4");
+ });
+
+ it("zeigt bei C-Level ohne Angabe einen Strich", () => {
+ render( );
+ expect(wertZu("C-Level")).toBe("–");
});
it("nennt beim Dienstwagen die Antriebsart statt eines blossen Ja", () => {
@@ -101,9 +111,8 @@ describe("VertragTab — Merkmale", () => {
});
it("zeigt gesetzte Merkmale als Ja", () => {
- render( );
+ render( );
expect(wertZu("Betriebsrat")).toBe("Ja");
- expect(wertZu("C-Level")).toBe("Ja");
expect(wertZu("Laterale Führung")).toBe("Nein");
});
diff --git a/tests/unit/anzeige.test.ts b/tests/unit/anzeige.test.ts
index 34bb870..7d50d34 100644
--- a/tests/unit/anzeige.test.ts
+++ b/tests/unit/anzeige.test.ts
@@ -45,6 +45,17 @@ describe("anzeige", () => {
expect(anzeige("Rückkehr vom 2026-12-01 auf 2027-03-12")).toBe("Rückkehr vom 01.12.2026 auf 12.03.2027");
});
+ it("nennt das Ende einer Langzeitabwesenheit „endet am“, die Rückkehr als Ereignis nicht", () => {
+ expect(anzeige("Elternkarenz, geplante Rückkehr am 2026-12-01")).toBe("Elternkarenz, endet am 01.12.2026");
+ expect(anzeige("Elternkarenz ab 2026-03-01, geplante Rückkehr 2026-12-01")).toBe(
+ "Elternkarenz ab 01.03.2026, endet am 01.12.2026"
+ );
+ expect(anzeige("Rückkehr aus Elternkarenz am 2026-12-01")).toBe("Elternkarenz endet am 01.12.2026");
+ expect(anzeige("Geplante Rückkehr")).toBe("Endet am");
+ expect(anzeige("Rückkehr")).toBe("Rückkehr");
+ expect(anzeige("Beschäftigungsausmaß ab Rückkehr")).toBe("Beschäftigungsausmaß ab Rückkehr");
+ });
+
it("lässt Zeitstempel und Kennungen stehen", () => {
expect(anzeige("2026-11-03T10:00:00Z")).toBe("2026-11-03T10:00:00Z");
expect(anzeige("b83ce601-9191-4b67-8979-5ce851b601cf")).toBe("b83ce601-9191-4b67-8979-5ce851b601cf");
diff --git a/tests/unit/arbeitszeit.test.ts b/tests/unit/arbeitszeit.test.ts
index 985187b..c149047 100644
--- a/tests/unit/arbeitszeit.test.ts
+++ b/tests/unit/arbeitszeit.test.ts
@@ -24,13 +24,32 @@ describe("arbeitszeitBefund", () => {
expect(b.fehler).toBeNull();
});
- it("rechnet in Zehnteln und nicht in Gleitkommazahlen", () => {
+ it("rechnet in Hundertsteln und nicht in Gleitkommazahlen", () => {
// 7,7 × 5 ergibt als Gleitkommazahl 38,49999… — die Prüfung „exakt
// gleich" wiese eine völlig richtige Eingabe zurück.
const b = arbeitszeitBefund({ Mo: "7.7", Di: "7.7", Mi: "7.7", Do: "7.7", Fr: "7.7" }, WOCHE, 38.5);
expect(b.fehler).toBeNull();
});
+ it("verteilt Wochenstunden mit zwei Nachkommastellen", () => {
+ // 19,25 Stunden an fünf Tagen sind 3,85 je Tag.
+ const b = arbeitszeitBefund({ Mo: "3,85", Di: "3,85", Mi: "3,85", Do: "3,85", Fr: "3,85" }, WOCHE, 19.25);
+ expect(b.summe).toBe(19.25);
+ expect(b.fehler).toBeNull();
+ });
+
+ it("nennt eine Summe mit zwei Nachkommastellen ungerundet", () => {
+ const b = arbeitszeitBefund({ Mo: "4", Di: "4", Mi: "4", Do: "4", Fr: "3,75" }, WOCHE, 19.25);
+ expect(b.fehler).toContain("19,75");
+ expect(b.fehler).toContain("19,25");
+ });
+
+ it("weist eine dritte Nachkommastelle zurück", () => {
+ // Gespeichert würde ein anderer Wert als der eingegebene.
+ const b = arbeitszeitBefund({ Mo: "3,855", Di: "3,85", Mi: "3,85", Do: "3,85", Fr: "3,845" }, WOCHE, 19.25);
+ expect(b.fehler).toContain("zwei Nachkommastellen");
+ });
+
it("nimmt auch das Komma, wie es auf einer deutschen Tastatur entsteht", () => {
const b = arbeitszeitBefund({ Mo: "8", Di: "8", Mi: "8", Do: "8", Fr: "6,5" }, WOCHE, 38.5);
expect(b.fehler).toBeNull();
@@ -79,6 +98,10 @@ describe("arbeitszeitFuerDb", () => {
expect(arbeitszeitFuerDb({ Mo: "8", Fr: "6,5" }, ["Mo", "Fr"])).toEqual({ Mo: 8, Fr: 6.5 });
});
+ it("behält zwei Nachkommastellen", () => {
+ expect(arbeitszeitFuerDb({ Mo: "3,85", Fr: "7,75" }, ["Mo", "Fr"])).toEqual({ Mo: 3.85, Fr: 7.75 });
+ });
+
it("lässt weggefallene Arbeitstage heraus", () => {
// Sonst bliebe ein Dienstag mit acht Stunden an einer Person stehen, die
// dienstags nicht mehr arbeitet — und die Bedingung in der Datenbank
diff --git a/tests/unit/austausch-katalog.test.ts b/tests/unit/austausch-katalog.test.ts
index 0966490..0da718f 100644
--- a/tests/unit/austausch-katalog.test.ts
+++ b/tests/unit/austausch-katalog.test.ts
@@ -48,6 +48,7 @@ const NICHT_IM_BLATT_MITARBEITER: Record = {
Notfallkontakt: "eigenes Blatt „Notfallkontakte“",
"Notfallkontakt Telefon": "eigenes Blatt „Notfallkontakte“",
"Notfallkontakt Verhältnis": "eigenes Blatt „Notfallkontakte“",
+ "C-Level (Ja/Nein)": "abgelöst durch „C-Level“, wird nicht mehr erfasst",
};
describe("Blatt „Mitarbeiter“ und die Feldkarte", () => {
@@ -116,6 +117,7 @@ const FREIE_EINGABE = new Set([
"Nachname", "Vorname", "SV-Nummer", "Adresse", "Postleitzahl", "Ort", "Private E-Mail", "Firmen-E-Mail",
"Private Telefonnummer", "Cornerstone-ID", "Erlernter Beruf", "Angaben zur Übernahme", "Wochenstunden",
"Arbeitszeitmodell", "Wochenstunden ab Rückkehr", "ID", "Name", "Telefonnummer", "Bezeichnung",
+ "Verhältnis (Sonstige)",
]);
describe("Auswahl in der Datei", () => {
@@ -231,6 +233,8 @@ describe("Zellen hin und zurück", () => {
expect(ausZelle({ art: "zahl", nachkomma: 1 }, "38,5")).toEqual({ art: "wert", wert: 38.5 });
expect(ausZelle({ art: "zahl", nachkomma: 1 }, 7.7)).toEqual({ art: "wert", wert: 7.7 });
expect(ausZelle({ art: "zahl", nachkomma: 1 }, "7,75").art).toBe("fehler");
+ expect(ausZelle({ art: "zahl", nachkomma: 2 }, "19,25")).toEqual({ art: "wert", wert: 19.25 });
+ expect(ausZelle({ art: "zahl", nachkomma: 2 }, "19,255").art).toBe("fehler");
});
it("weist Werte ausserhalb der Auswahl ab, ausser bei freier Auswahl", () => {
diff --git a/tests/unit/c-level.test.ts b/tests/unit/c-level.test.ts
new file mode 100644
index 0000000..fd333d5
--- /dev/null
+++ b/tests/unit/c-level.test.ts
@@ -0,0 +1,40 @@
+import { readFileSync } from "node:fs";
+import { join } from "node:path";
+import { describe, expect, it } from "vitest";
+import { C_LEVEL_AUSWAHL, C_LEVEL_CODES } from "@/lib/c-level";
+import { feldwertAnzeige, optionenFuer } from "@/lib/historie-felder";
+import { parseCriteria } from "@/lib/report-criteria";
+
+// Die Liste steht als CHECK in der Migration und hier für die Oberfläche.
+// Laufen die beiden auseinander, bietet das Formular einen Wert an, den die
+// Datenbank abweist.
+const MIGRATION = join(process.cwd(), "db/migrations/20261123120000_c_level_als_auswahl.sql");
+
+function werteAusDerBedingung(): string[] {
+ const sql = readFileSync(MIGRATION, "utf8");
+ const block = sql.match(/check \(c_level in \(([^)]*)\)\)/)?.[1];
+ expect(block, "Die Bedingung steht nicht mehr in der Migration").toBeDefined();
+ return [...block!.matchAll(/'([^']+)'/g)].map((m) => m[1]);
+}
+
+describe("C-Level", () => {
+ it("stimmt mit der Bedingung in der Datenbank überein", () => {
+ expect(werteAusDerBedingung()).toEqual([...C_LEVEL_CODES]);
+ });
+
+ it("zeigt nur den Code", () => {
+ expect(C_LEVEL_AUSWAHL[0]).toEqual({ value: "C1", label: "C1" });
+ expect(C_LEVEL_AUSWAHL.every((o) => o.value === o.label)).toBe(true);
+ expect(feldwertAnzeige("C-Level", "C4")).toBe("C4");
+ });
+
+ it("berichtigt in der Historie mit derselben Auswahl, das abgelöste Ja/Nein getrennt davon", () => {
+ expect(optionenFuer("C-Level", "C4")?.map((o) => o.value)).toEqual([...C_LEVEL_CODES]);
+ expect(optionenFuer("C-Level (Ja/Nein)", "true")?.map((o) => o.value)).toEqual(["true", "false"]);
+ });
+
+ it("filtert im Bericht nach mehreren Stufen und verwirft Unbekanntes", () => {
+ const werte: Record = { clevel: "C1|C9|ja" };
+ expect(parseCriteria((k) => werte[k]).auswahl.clevel).toEqual(["C1", "C9"]);
+ });
+});
diff --git a/tests/unit/extern-vorgaben.test.ts b/tests/unit/extern-vorgaben.test.ts
index 6f53787..dbfbfb1 100644
--- a/tests/unit/extern-vorgaben.test.ts
+++ b/tests/unit/extern-vorgaben.test.ts
@@ -20,7 +20,6 @@ const EXTERN = {
is_betriebsrat: false,
has_dienstwagen: false,
is_laterale_fuehrung: false,
- is_c_level: false,
has_kuendigungsschutz: false,
ist_beguenstigt_behindert: false,
has_bonusanspruch: false,
diff --git a/tests/unit/org.test.ts b/tests/unit/org.test.ts
index 401485e..6491551 100644
--- a/tests/unit/org.test.ts
+++ b/tests/unit/org.test.ts
@@ -14,7 +14,7 @@ const units: OrgUnit[] = [
{ id: "cnc", org_number: "22002000", name: "CNC", parent_id: "fert", unit_type: "Team" },
{ id: "it", org_number: "20200000", name: "IT", parent_id: "gmbh", unit_type: "Bereich" },
];
-const locations = [{ id: "loc-1", name: "Wien-Hernals", country: "Österreich" }];
+const locations = [{ id: "loc-1", name: "Wien-Hernals", country: "Österreich", parent_id: null }];
const maps = buildOrgMaps(units, locations);
describe("buildOrgMaps", () => {
diff --git a/tests/unit/report-criteria.test.ts b/tests/unit/report-criteria.test.ts
index f57ce79..3d67aa8 100644
--- a/tests/unit/report-criteria.test.ts
+++ b/tests/unit/report-criteria.test.ts
@@ -37,8 +37,8 @@ describe("parseCriteria", () => {
});
it("nimmt ja/nein an und sonst nichts", () => {
- const c = aus({ dienstwagen: "ja", betriebsrat: "vielleicht", clevel: "nein" });
- expect(c.jaNein).toEqual({ dienstwagen: "ja", clevel: "nein" });
+ const c = aus({ dienstwagen: "ja", betriebsrat: "vielleicht", lateral: "nein" });
+ expect(c.jaNein).toEqual({ dienstwagen: "ja", lateral: "nein" });
});
it("prüft Zeiträume auf echte Kalenderdaten", () => {
diff --git a/tests/unit/reports.test.ts b/tests/unit/reports.test.ts
index 0335afb..6de553f 100644
--- a/tests/unit/reports.test.ts
+++ b/tests/unit/reports.test.ts
@@ -40,7 +40,7 @@ function emp(overrides: Partial = {}): ReportEmployee {
is_betriebsrat: false,
has_dienstwagen: false,
is_laterale_fuehrung: false,
- is_c_level: false,
+ c_level: null,
teilzeit_art: null,
dependents_count: 0,
...overrides,
@@ -128,11 +128,15 @@ describe("groupKeyFor", () => {
});
it("resolves the Rolle & Anstellung boolean dimensions as Ja/Nein", () => {
- const e = emp({ is_betriebsrat: true, has_dienstwagen: false, is_laterale_fuehrung: true, is_c_level: false });
+ const e = emp({ is_betriebsrat: true, has_dienstwagen: false, is_laterale_fuehrung: true });
expect(groupKeyFor(e, "betriebsrat", lookups)).toBe("Ja");
expect(groupKeyFor(e, "dienstwagen", lookups)).toBe("Nein");
expect(groupKeyFor(e, "laterale_fuehrung", lookups)).toBe("Ja");
- expect(groupKeyFor(e, "c_level", lookups)).toBe("Nein");
+ });
+
+ it("gruppiert nach C-Level mit Code und Bezeichnung, ohne Angabe als eigene Gruppe", () => {
+ expect(groupKeyFor(emp({ c_level: "C9" }), "c_level", lookups)).toBe("C9");
+ expect(groupKeyFor(emp({ c_level: null }), "c_level", lookups)).toBe("Ohne C-Level");
});
it("resolves worker_type/collective_agreement directly", () => {
diff --git a/tests/unit/testsystem.test.ts b/tests/unit/testsystem.test.ts
new file mode 100644
index 0000000..ca82f9e
--- /dev/null
+++ b/tests/unit/testsystem.test.ts
@@ -0,0 +1,12 @@
+import { describe, expect, it } from "vitest";
+import { istTestsystem } from "@/lib/testsystem";
+
+describe("istTestsystem", () => {
+ it("erkennt die eingeschaltete Einstellung", () => {
+ for (const w of ["1", "true", "TRUE", " ja "]) expect(istTestsystem(w), w).toBe(true);
+ });
+
+ it("bleibt ohne Eintrag oder mit anderem Wert aus", () => {
+ for (const w of [undefined, "", "0", "false", "nein", "Produktion"]) expect(istTestsystem(w), String(w)).toBe(false);
+ });
+});
diff --git a/tests/unit/verhaeltnis-standorte.test.ts b/tests/unit/verhaeltnis-standorte.test.ts
new file mode 100644
index 0000000..89e42ca
--- /dev/null
+++ b/tests/unit/verhaeltnis-standorte.test.ts
@@ -0,0 +1,79 @@
+import { readFileSync } from "node:fs";
+import { join } from "node:path";
+import { describe, expect, it } from "vitest";
+import { BLATT_ANGEHOERIGE, BLATT_NOTFALLKONTAKTE } from "@/lib/austausch/katalog";
+import { kurzname, oberstandorte, oberstandortVon, unterstandorte, zuweisbareStandorte } from "@/lib/standorte";
+import { verhaeltnisAusDatei, verhaeltnisFuerDatei } from "@/lib/verhaeltnis";
+
+describe("Verhältnis in der Austauschdatei", () => {
+ it("teilt einen frei eingetragenen Wert in „Sonstige“ und den Text", () => {
+ expect(verhaeltnisFuerDatei("Onkel")).toEqual({ auswahl: "Sonstige", sonstige: "Onkel" });
+ expect(verhaeltnisFuerDatei("Kind")).toEqual({ auswahl: "Kind", sonstige: null });
+ expect(verhaeltnisFuerDatei("Sonstige")).toEqual({ auswahl: "Sonstige", sonstige: null });
+ expect(verhaeltnisFuerDatei(null)).toEqual({ auswahl: null, sonstige: null });
+ });
+
+ it("speichert bei „Sonstige“ den Text, ohne Text „Sonstige“", () => {
+ expect(verhaeltnisAusDatei("Sonstige", " Nachbarin ")).toEqual({ wert: "Nachbarin" });
+ expect(verhaeltnisAusDatei("Sonstige", null)).toEqual({ wert: "Sonstige" });
+ expect(verhaeltnisAusDatei("Kind", null)).toEqual({ wert: "Kind" });
+ expect(verhaeltnisAusDatei(null, null)).toEqual({ wert: null });
+ });
+
+ it("weist einen Text ohne „Sonstige“ ab", () => {
+ expect(verhaeltnisAusDatei("Kind", "Onkel")).toHaveProperty("fehler");
+ expect(verhaeltnisAusDatei(null, "Onkel")).toHaveProperty("fehler");
+ });
+
+ it("hat in beiden Blättern die Spalte gleich hinter der Auswahl, die Auswahl ohne freie Eingabe", () => {
+ for (const [blatt, feld] of [
+ [BLATT_ANGEHOERIGE, "relationship"],
+ [BLATT_NOTFALLKONTAKTE, "relation"],
+ ] as const) {
+ const i = blatt.spalten.findIndex((s) => s.feld === feld);
+ expect(blatt.spalten[i + 1].feld).toBe(`${feld}_sonstige`);
+ const format = blatt.spalten[i].format;
+ expect(format.art === "auswahl" && format.frei).toBeFalsy();
+ }
+ });
+});
+
+const ALLE = [
+ { id: "hernals", name: "Wien-Hernals", parent_id: null },
+ { id: "shop", name: "Shop", parent_id: null },
+ { id: "w17", name: "Shop W17", parent_id: "shop" },
+ { id: "hbf", name: "Shop Wien Hauptbahnhof", parent_id: "shop" },
+];
+
+describe("Standorte mit Unterstandorten", () => {
+ it("zeigt zuerst die oberste Ebene und unter „Shop“ die Shops", () => {
+ expect(oberstandorte(ALLE).map((s) => s.id)).toEqual(["hernals", "shop"]);
+ expect(unterstandorte(ALLE, "shop").map((s) => s.id)).toEqual(["w17", "hbf"]);
+ expect(unterstandorte(ALLE, "hernals")).toEqual([]);
+ expect(kurzname(ALLE[3], ALLE[1])).toBe("Wien Hauptbahnhof");
+ });
+
+ it("findet zu einem gespeicherten Shop die erste Auswahl", () => {
+ expect(oberstandortVon(ALLE, "w17")).toBe("shop");
+ expect(oberstandortVon(ALLE, "hernals")).toBe("hernals");
+ expect(oberstandortVon(ALLE, "")).toBe("");
+ });
+
+ it("bietet in Filtern nur Standorte an, auf denen jemand sitzen kann", () => {
+ expect(zuweisbareStandorte(ALLE).map((s) => s.id)).toEqual(["hernals", "w17", "hbf"]);
+ });
+
+ it("legt in der Migration genau die sechs Shops an", () => {
+ const sql = readFileSync(join(process.cwd(), "db/migrations/20261123140000_standort_shop.sql"), "utf8");
+ const einfuegen = sql.match(/from \(values ([^\n]+)\) v\(name\)\non conflict/)?.[1];
+ expect(einfuegen).toBeDefined();
+ expect([...einfuegen!.matchAll(/'([^']+)'/g)].map((m) => m[1])).toEqual([
+ "Shop W17",
+ "Shop Wodo",
+ "Shop Parndorf",
+ "Shop Donaupark",
+ "Shop W1",
+ "Shop Wien Hauptbahnhof",
+ ]);
+ });
+});
diff --git a/tests/unit/wochenstunden.test.ts b/tests/unit/wochenstunden.test.ts
new file mode 100644
index 0000000..8816dbc
--- /dev/null
+++ b/tests/unit/wochenstunden.test.ts
@@ -0,0 +1,45 @@
+import { readFileSync, readdirSync } from "node:fs";
+import { join } from "node:path";
+import { describe, expect, it } from "vitest";
+import { nachkommaFehler, wochenstundenFehler } from "@/lib/wochenstunden";
+import { formatStunden } from "@/lib/arbeitszeit";
+
+describe("wochenstundenFehler", () => {
+ it("nimmt Teilzeit mit zwei Nachkommastellen, mit Komma und mit Punkt", () => {
+ expect(wochenstundenFehler("Teilzeit", "19,25")).toBeNull();
+ expect(wochenstundenFehler("Teilzeit", "19.25")).toBeNull();
+ expect(wochenstundenFehler("Teilzeit", "19,5")).toBeNull();
+ });
+
+ it("weist eine dritte Nachkommastelle zurück", () => {
+ expect(wochenstundenFehler("Teilzeit", "19,255")).toContain("zwei Nachkommastellen");
+ expect(nachkommaFehler("19.255")).not.toBeNull();
+ expect(nachkommaFehler("19.25")).toBeNull();
+ expect(nachkommaFehler("38")).toBeNull();
+ });
+});
+
+describe("formatStunden", () => {
+ it("zeigt zwei Nachkommastellen ohne angehängte Null", () => {
+ expect(formatStunden(19.25)).toBe("19,25");
+ expect(formatStunden(38.5)).toBe("38,5");
+ expect(formatStunden(8)).toBe("8");
+ });
+});
+
+describe("Spalte weekly_hours", () => {
+ // Die Eingaben lassen zwei Nachkommastellen zu. Hätte die Spalte weniger,
+ // rundete die Datenbank stillschweigend, und gespeichert wäre ein anderer
+ // Wert als der eingegebene.
+ it("hat in der zuletzt festgelegten Form zwei Nachkommastellen", () => {
+ const verzeichnis = join(process.cwd(), "db", "migrations");
+ const typen = readdirSync(verzeichnis)
+ .filter((f) => f.endsWith(".sql"))
+ .sort()
+ .flatMap((f) => {
+ const text = readFileSync(join(verzeichnis, f), "utf8");
+ return [...text.matchAll(/weekly_hours\s+(?:type\s+)?numeric\((\d+),(\d+)\)/gi)].map((m) => `${m[1]},${m[2]}`);
+ });
+ expect(typen.at(-1)).toBe("4,2");
+ });
+});