Übergabestand 2026-11-24

Alpenwerk HR 0.2.2

- C-Level als Auswahl aus der fachlichen Liste (C1 … VD) statt Ja/Nein; überall als Code angezeigt
- Standorte mit Unterstandorten: bei „Shop“ folgt die Auswahl des einzelnen Shops
- Angehörige und Notfallkontakte im Import: Verhältnis aus der Liste, bei „Sonstige“ mit eigenem Text
- Wochenstunden mit zwei Nachkommastellen (z. B. 19,25)
- Langzeitabwesenheit: „Endet am“ statt Rückkehr; eine anschliessende Abwesenheit lässt sich nur nach der Wochenhilfe (Mutterschutz) planen
- Notizen mit Fälligkeit erscheinen erst ab diesem Tag in der Glocke
- Testinstallationen: mit TESTSYSTEM=1 in app.env trägt jede Seite den Schriftzug „Testsystem“ und einen roten Rahmen
- Next.js 16.4.6
This commit is contained in:
2026-11-24 11:08:43 +01:00
parent 322d0f4407
commit e09d94cb2f
72 changed files with 1451 additions and 332 deletions

View File

@@ -68,3 +68,10 @@ CRON_SECRET=
# und hat jemand in der Auswahl kein Geburtsdatum, lehnt der Export mit einem # und hat jemand in der Auswahl kein Geburtsdatum, lehnt der Export mit einem
# Hinweis ab; die übrige Anwendung ist nicht betroffen. # Hinweis ab; die übrige Anwendung ist nicht betroffen.
LOLYO_STARTPASSWORT= 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=

View File

@@ -67,6 +67,7 @@ Kurzfassung — alles davon ist rein server-seitig:
| `AUTH_URL` | Adresse, unter der die Anwendung von aussen erreichbar ist | | `AUTH_URL` | Adresse, unter der die Anwendung von aussen erreichbar ist |
| `CRON_SECRET` | Schützt `/api/cron/apply-pending-changes` | | `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 | | `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 **Es gibt keine `NEXT_PUBLIC_*`-Variablen.** Nichts wird in das Browser-Bundle
eingebacken, weil der Browser mit nichts spricht ausser der Anwendung selbst. eingebacken, weil der Browser mit nichts spricht ausser der Anwendung selbst.

View File

@@ -144,7 +144,8 @@ export async function hireEmployee(payload: {
emergency_contact_phone?: string; emergency_contact_phone?: string;
emergency_contact_relation?: string; emergency_contact_relation?: string;
is_laterale_fuehrung?: boolean; 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". */ /** Form der Beschäftigung — chk_mitarbeiterart. Leer heisst „unverändert". */
mitarbeiterart?: string; mitarbeiterart?: string;
has_kuendigungsschutz?: boolean; has_kuendigungsschutz?: boolean;

View File

@@ -30,8 +30,10 @@ export async function generateMetadata({ params, searchParams }: Props) {
const [{ id }, sp] = await Promise.all([params, searchParams]); const [{ id }, sp] = await Promise.all([params, searchParams]);
const art = parseArt(sp.art); const art = parseArt(sp.art);
const daten = await withUser(await currentUserId(), (tx) => loadChecklistPrint(tx, id, art)); const daten = await withUser(await currentUserId(), (tx) => loadChecklistPrint(tx, id, art));
if (!daten) return { title: artTitel(art) }; // Absolut: der Titel ist der Dateiname, eine Vorlage des Layouts gehört
return { title: checklistDateiname(art, daten.kopf, todayIso()) }; // 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) { export default async function ChecklistPrintPage({ params, searchParams }: Props) {

View File

@@ -111,7 +111,9 @@ function employeeExportColumns(
get: (e) => (notfallkontakte.get(e.id) ?? []).map((k) => anzeige(k.relation) ?? "").join("; "), get: (e) => (notfallkontakte.get(e.id) ?? []).map((k) => anzeige(k.relation) ?? "").join("; "),
}, },
{ header: "Laterale Führung", get: (e) => e.is_laterale_fuehrung }, { 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: "Hay-Grade", get: (e) => e.paygrade },
{ header: "VL", get: (e) => e.vl }, { header: "VL", get: (e) => e.vl },
{ header: "Bonusanspruch", get: (e) => e.has_bonusanspruch }, { header: "Bonusanspruch", get: (e) => e.has_bonusanspruch },

View File

@@ -1,6 +1,8 @@
import type { Metadata, Viewport } from "next"; import type { Metadata, Viewport } from "next";
import { Barlow } from "next/font/google"; import { Barlow } from "next/font/google";
import { TestsystemSchriftzug } from "@/components/shell/TestsystemSchriftzug";
import { ToastProvider } from "@/components/ui/Toast"; import { ToastProvider } from "@/components/ui/Toast";
import { istTestsystem, TESTSYSTEM_SCHRIFTZUG } from "@/lib/testsystem";
import "./globals.css"; import "./globals.css";
// ═══ Die Schrift ═══ // ═══ Die Schrift ═══
@@ -31,7 +33,7 @@ const din = Barlow({
weight: ["400", "600", "700", "800"], weight: ["400", "600", "700", "800"],
}); });
export const metadata: Metadata = { const METADATA: Metadata = {
title: "Alpenwerk HR", title: "Alpenwerk HR",
description: "HR-Stammdaten- und Organisationsmanagement für Alpenwerk Industrie GmbH", description: "HR-Stammdaten- und Organisationsmanagement für Alpenwerk Industrie GmbH",
// Added to the home screen on iOS this opens without Safari's chrome and // 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", 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 = { export const viewport: Viewport = {
width: "device-width", width: "device-width",
initialScale: 1, initialScale: 1,
@@ -63,6 +74,7 @@ export default function RootLayout({
return ( return (
<html lang="de-AT" className={`${din.variable} h-full antialiased`}> <html lang="de-AT" className={`${din.variable} h-full antialiased`}>
<body className="flex min-h-dvh flex-col font-sans"> <body className="flex min-h-dvh flex-col font-sans">
{istTestsystem() && <TestsystemSchriftzug />}
<ToastProvider>{children}</ToastProvider> <ToastProvider>{children}</ToastProvider>
</body> </body>
</html> </html>

View File

@@ -5,12 +5,14 @@ import { useEffect, useState } from "react";
import { FILTER_SELECT_CLASS } from "@/components/ui/Field"; import { FILTER_SELECT_CLASS } from "@/components/ui/Field";
import { SearchInput } from "@/components/ui/SearchInput"; import { SearchInput } from "@/components/ui/SearchInput";
import { AUSTRITT_GEPLANT } from "@/lib/employee-status-filter"; import { AUSTRITT_GEPLANT } from "@/lib/employee-status-filter";
import { zuweisbareStandorte } from "@/lib/standorte";
type EmployeeFiltersProps = { type EmployeeFiltersProps = {
/** Der ganze Baum, in Tiefensuche-Reihenfolge. */ /** Der ganze Baum, in Tiefensuche-Reihenfolge. */
units: { id: string; name: string; unit_type: string }[]; units: { id: string; name: string; unit_type: string }[];
depthOf: Map<string, number>; depthOf: Map<string, number>;
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 // Aktiv and Langzeitabwesenheit are separate statuses — somebody on a
@@ -107,7 +109,7 @@ export function EmployeeFilters({ units, depthOf, locations }: EmployeeFiltersPr
className={FILTER_SELECT_CLASS} className={FILTER_SELECT_CLASS}
> >
<option value="">Alle Standorte</option> <option value="">Alle Standorte</option>
{locations.map((l) => ( {zuweisbareStandorte(locations).map((l) => (
<option key={l.id} value={l.id}> <option key={l.id} value={l.id}>
{l.name} {l.name}
</option> </option>

View File

@@ -15,6 +15,7 @@ import {
KUENDIGUNGSSCHUTZ_GRUENDE, KUENDIGUNGSSCHUTZ_GRUENDE,
} from "@/lib/kuendigungsschutz"; } from "@/lib/kuendigungsschutz";
import { MITARBEITERARTEN } from "@/lib/mitarbeiterart"; import { MITARBEITERARTEN } from "@/lib/mitarbeiterart";
import { C_LEVEL_AUSWAHL } from "@/lib/c-level";
import { anzeigeAuswahl } from "@/lib/anzeige"; import { anzeigeAuswahl } from "@/lib/anzeige";
import { sortiereWochentage, WOCHENTAGE } from "@/lib/wochentage"; import { sortiereWochentage, WOCHENTAGE } from "@/lib/wochentage";
import { KOLLEKTIVVERTRAEGE } from "@/lib/kollektivvertrag"; import { KOLLEKTIVVERTRAEGE } from "@/lib/kollektivvertrag";
@@ -64,7 +65,8 @@ export type RoleEmploymentValue = {
*/ */
dienstwagenArt: DienstwagenArt; dienstwagenArt: DienstwagenArt;
isLateraleFuehrung: boolean; isLateraleFuehrung: boolean;
isCLevel: boolean; /** Code aus lib/c-level.ts; "" heisst nicht erfasst. */
cLevel: string;
/** Betriebsrat, Mutterschutz, Karenz, begünstigte Behinderung, Lehre. */ /** Betriebsrat, Mutterschutz, Karenz, begünstigte Behinderung, Lehre. */
hasKuendigungsschutz: boolean; hasKuendigungsschutz: boolean;
/** /**
@@ -218,6 +220,16 @@ export function RoleEmploymentFields({
onChange={(v) => onChange({ collectiveAgreement: v as CollectiveAgreement })} onChange={(v) => onChange({ collectiveAgreement: v as CollectiveAgreement })}
options={KOLLEKTIVVERTRAEGE.map((k) => ({ value: k, label: k }))} 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. */}
<SelectField
label="C-Level"
dense
value={value.cLevel}
onChange={(v) => onChange({ cLevel: v })}
options={[{ value: "", label: "Bitte wählen…" }, ...C_LEVEL_AUSWAHL]}
/>
</div> </div>
{/* Toggle group, not a set of fields: a fieldset names the group, and {/* Toggle group, not a set of fields: a fieldset names the group, and
@@ -259,7 +271,7 @@ export function RoleEmploymentFields({
<span className="w-5 font-semibold">{day}</span> <span className="w-5 font-semibold">{day}</span>
<input <input
type="number" type="number"
step="0.5" step="0.01"
min="0" min="0"
max={MAX_STUNDEN_JE_TAG} max={MAX_STUNDEN_JE_TAG}
inputMode="decimal" inputMode="decimal"
@@ -312,10 +324,6 @@ export function RoleEmploymentFields({
<input type="checkbox" checked={value.isLateraleFuehrung} onChange={(e) => onChange({ isLateraleFuehrung: e.target.checked })} /> <input type="checkbox" checked={value.isLateraleFuehrung} onChange={(e) => onChange({ isLateraleFuehrung: e.target.checked })} />
Laterale Führung Laterale Führung
</label> </label>
<label className="flex items-center gap-2 text-sm text-ink-body">
<input type="checkbox" checked={value.isCLevel} onChange={(e) => onChange({ isCLevel: e.target.checked })} />
C-Level
</label>
<label className="flex items-center gap-2 text-sm text-ink-body"> <label className="flex items-center gap-2 text-sm text-ink-body">
<input <input
type="checkbox" type="checkbox"

View File

@@ -0,0 +1,63 @@
"use client";
import { useState } from "react";
import { SelectField } from "@/components/ui/Field";
import { kurzname, oberstandorte, oberstandortVon, unterstandorte, type StandortEintrag } from "@/lib/standorte";
type Standort = StandortEintrag & { country?: string };
// Standort in zwei Stufen: die oberste Ebene, und bei einem Standort mit
// Unterstandorten („Shop") eine zweite Auswahl. Gemeldet wird nur ein
// Standort, auf dem eine Person sitzen kann; solange die zweite Auswahl
// fehlt, ist der Wert leer — ein Pflichtfeld bleibt damit offen.
export function StandortAuswahl({
value,
onChange,
standorte,
required,
mitLand,
hint,
}: {
value: string;
onChange: (id: string) => 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 (
<>
<SelectField
label="Standort"
required={required}
value={ober}
onChange={(id) => {
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 && (
<SelectField
label={oberEintrag?.name ?? "Standort"}
required
value={unter.some((s) => s.id === value) ? value : ""}
onChange={onChange}
placeholder="Bitte wählen…"
options={unter.map((s) => ({ value: s.id, label: kurzname(s, oberEintrag) }))}
hint={hint}
/>
)}
</>
);
}

View File

@@ -4,6 +4,7 @@ import { useState } from "react";
import { SelectField, TextField } from "@/components/ui/Field"; import { SelectField, TextField } from "@/components/ui/Field";
import { anzeigeAuswahl } from "@/lib/anzeige"; import { anzeigeAuswahl } from "@/lib/anzeige";
import { EMERGENCY_RELATIONS } from "@/lib/types"; import { EMERGENCY_RELATIONS } from "@/lib/types";
import { istFreiesVerhaeltnis, SONSTIGE } from "@/lib/verhaeltnis";
// Das Verhältnis zum Notfallkontakt: Auswahl, und unter „Sonstige" ein // Das Verhältnis zum Notfallkontakt: Auswahl, und unter „Sonstige" ein
// Freifeld. // Freifeld.
@@ -23,12 +24,7 @@ import { EMERGENCY_RELATIONS } from "@/lib/types";
// nimmt einen gespeicherten Wert, der nicht in der Liste steht, mit in die // nimmt einen gespeicherten Wert, der nicht in der Liste steht, mit in die
// Auswahl auf. // Auswahl auf.
const SONSTIGE = "Sonstige"; export { istFreiesVerhaeltnis };
/** Ob ein gespeicherter Wert frei eingetragen wurde. */
export function istFreiesVerhaeltnis(wert: string): boolean {
return wert.trim() !== "" && !(EMERGENCY_RELATIONS as readonly string[]).includes(wert);
}
export function VerhaeltnisField({ export function VerhaeltnisField({
value, value,

View File

@@ -33,6 +33,7 @@ import { fmtDate, fmtFullName, todayIso } from "@/lib/format";
import { plzHinweis, pruefePlzImFormular } from "@/lib/plz"; import { plzHinweis, pruefePlzImFormular } from "@/lib/plz";
import { requiresAustrianSvnr, svnrErfassbar } from "@/lib/svnr"; import { requiresAustrianSvnr, svnrErfassbar } from "@/lib/svnr";
import { vertragsangabenVollstaendig } from "@/lib/vertragsangaben"; import { vertragsangabenVollstaendig } from "@/lib/vertragsangaben";
import { nachkommaFehler } from "@/lib/wochenstunden";
import { NotfallkontaktSection } from "@/components/employees/NotfallkontaktSection"; import { NotfallkontaktSection } from "@/components/employees/NotfallkontaktSection";
import { AustrittZuruecknehmen } from "@/components/employees/AustrittZuruecknehmen"; import { AustrittZuruecknehmen } from "@/components/employees/AustrittZuruecknehmen";
import { EintrittPlanstelleBerichtigen } from "@/components/employees/EintrittPlanstelleBerichtigen"; import { EintrittPlanstelleBerichtigen } from "@/components/employees/EintrittPlanstelleBerichtigen";
@@ -205,7 +206,7 @@ export function DatenAendernPanel({
behinderungBis: employee.behinderung_bis ?? "", behinderungBis: employee.behinderung_bis ?? "",
dienstwagenArt: employee.dienstwagen_art ?? "Verbrenner", dienstwagenArt: employee.dienstwagen_art ?? "Verbrenner",
isLateraleFuehrung: employee.is_laterale_fuehrung ?? false, isLateraleFuehrung: employee.is_laterale_fuehrung ?? false,
isCLevel: employee.is_c_level ?? false, cLevel: employee.c_level ?? "",
}); });
function updateRole(patch: Partial<RoleEmploymentValue>) { function updateRole(patch: Partial<RoleEmploymentValue>) {
setRole((prev) => ({ ...prev, ...patch })); setRole((prev) => ({ ...prev, ...patch }));
@@ -233,6 +234,11 @@ export function DatenAendernPanel({
showToast(geburtFehler, "error"); showToast(geburtFehler, "error");
return; return;
} }
const nachkomma = nachkommaFehler(weeklyHours);
if (nachkomma) {
showToast(nachkomma, "error");
return;
}
if (employmentType === "Teilzeit" && (Number(weeklyHours) <= 0 || Number(weeklyHours) >= 38.5)) { if (employmentType === "Teilzeit" && (Number(weeklyHours) <= 0 || Number(weeklyHours) >= 38.5)) {
showToast("Wochenstunden bei Teilzeit müssen zwischen 0 und 38,5 liegen.", "error"); showToast("Wochenstunden bei Teilzeit müssen zwischen 0 und 38,5 liegen.", "error");
return; return;
@@ -382,7 +388,7 @@ export function DatenAendernPanel({
? { teilzeit_art: teilzeit.variante, teilzeit_bis: teilzeit.bis } ? { teilzeit_art: teilzeit.variante, teilzeit_bis: teilzeit.bis }
: {}), : {}),
is_laterale_fuehrung: role.isLateraleFuehrung, is_laterale_fuehrung: role.isLateraleFuehrung,
is_c_level: role.isCLevel, c_level: role.cLevel,
arbeitszeitmodell: arbeitszeitFuerDb(role.arbeitszeitmodell, role.workDays), arbeitszeitmodell: arbeitszeitFuerDb(role.arbeitszeitmodell, role.workDays),
}, },
}); });
@@ -533,7 +539,7 @@ export function DatenAendernPanel({
label="Wochenstunden" label="Wochenstunden"
dense dense
type="number" type="number"
step="0.5" step="0.01"
value={weeklyHours} value={weeklyHours}
disabled={employmentType === "Vollzeit"} disabled={employmentType === "Vollzeit"}
onChange={setWeeklyHours} onChange={setWeeklyHours}

View File

@@ -10,6 +10,7 @@ import { useToast } from "@/components/ui/Toast";
import { ABSENCE_TYPES, absenceLabel, RUECKKEHR_GRUENDE } from "@/lib/absence"; import { ABSENCE_TYPES, absenceLabel, RUECKKEHR_GRUENDE } from "@/lib/absence";
import { abwesenheitsplan, type PlanZeile } from "@/lib/abwesenheitsplan"; import { abwesenheitsplan, type PlanZeile } from "@/lib/abwesenheitsplan";
import { fmtDate, fmtName } from "@/lib/format"; import { fmtDate, fmtName } from "@/lib/format";
import { nachkommaFehler } from "@/lib/wochenstunden";
import type { Database, EmploymentStatus } from "@/lib/types"; import type { Database, EmploymentStatus } from "@/lib/types";
type EmployeeRow = Database["public"]["Tables"]["employees"]["Row"]; type EmployeeRow = Database["public"]["Tables"]["employees"]["Row"];
@@ -112,7 +113,7 @@ export function KarenzPanel({
async function handleRueckkehr() { async function handleRueckkehr() {
if (!returnDate) { if (!returnDate) {
showToast("Bitte Rückkehrdatum angeben.", "error"); showToast("Bitte angeben, wann die Abwesenheit endet.", "error");
return; return;
} }
if (employmentMode === "Teilzeit") { if (employmentMode === "Teilzeit") {
@@ -124,6 +125,11 @@ export function KarenzPanel({
showToast("Wochenstunden müssen zwischen 0 und 38,5 liegen.", "error"); showToast("Wochenstunden müssen zwischen 0 und 38,5 liegen.", "error");
return; return;
} }
const nachkomma = nachkommaFehler(weeklyHours);
if (nachkomma) {
showToast(nachkomma, "error");
return;
}
} }
setPending(true); setPending(true);
const result = await rueckkehrAnpassen({ const result = await rueckkehrAnpassen({
@@ -163,7 +169,9 @@ export function KarenzPanel({
<Button variant="ghost" onClick={folgeAnlegen ? () => setFolgeAnlegen(false) : onClose}> <Button variant="ghost" onClick={folgeAnlegen ? () => setFolgeAnlegen(false) : onClose}>
{folgeAnlegen ? "Zurück" : "Abbrechen"} {folgeAnlegen ? "Zurück" : "Abbrechen"}
</Button> </Button>
{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 && (
<Button variant="secondary" onClick={() => setFolgeAnlegen(true)}> <Button variant="secondary" onClick={() => setFolgeAnlegen(true)}>
Anschliessende Abwesenheit planen Anschliessende Abwesenheit planen
</Button> </Button>
@@ -209,7 +217,7 @@ export function KarenzPanel({
)} )}
<DateField label="Beginn" required value={karenzStart} onChange={setKarenzStart} /> <DateField label="Beginn" required value={karenzStart} onChange={setKarenzStart} />
<DateField <DateField
label={absenceType === WOCHENHILFE ? "Ende" : "Geplante Rückkehr"} label="Endet am"
value={plannedReturn} value={plannedReturn}
onChange={setPlannedReturn} onChange={setPlannedReturn}
hint="Optional. Leer lassen, solange es nicht feststeht; später über „Rückkehr anpassen“ nachtragen." hint="Optional. Leer lassen, solange es nicht feststeht; später über „Rückkehr anpassen“ nachtragen."
@@ -223,18 +231,18 @@ export function KarenzPanel({
<p className="rounded bg-surface px-3 py-2 text-sm text-ink-body"> <p className="rounded bg-surface px-3 py-2 text-sm text-ink-body">
<span className="font-semibold">{absenceLabel(status, employee.absence_type)}</span> <span className="font-semibold">{absenceLabel(status, employee.absence_type)}</span>
{employee.karenz_start_date ? ` seit ${fmtDate(employee.karenz_start_date)}` : ""} {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"}
</p> </p>
{plan.folgende && ( {plan.folgende && (
<p className="rounded bg-surface px-3 py-2 text-sm text-ink-body"> <p className="rounded bg-surface px-3 py-2 text-sm text-ink-body">
Danach geplant: <span className="font-semibold">{plan.folgende.art ?? "Langzeitabwesenheit"}</span> ab{" "} Danach geplant: <span className="font-semibold">{plan.folgende.art ?? "Langzeitabwesenheit"}</span> ab{" "}
{fmtDate(plan.folgende.datum)} {fmtDate(plan.folgende.datum)}
{plan.folgende.rueckkehr ? `, Rückkehr ${fmtDate(plan.folgende.rueckkehr)}` : ""} {plan.folgende.rueckkehr ? `, endet am ${fmtDate(plan.folgende.rueckkehr)}` : ""}
</p> </p>
)} )}
<DateField <DateField
label="Rückkehrdatum" label="Endet am"
required required
value={returnDate} value={returnDate}
onChange={setReturnDate} onChange={setReturnDate}
@@ -281,7 +289,7 @@ export function KarenzPanel({
label="Reduzierte Wochenstunden" label="Reduzierte Wochenstunden"
required required
type="number" type="number"
step="0.5" step="0.01"
max="38" max="38"
value={weeklyHours} value={weeklyHours}
onChange={setWeeklyHours} onChange={setWeeklyHours}

View File

@@ -5,7 +5,8 @@ import { useMemo, useState } from "react";
import { geplantenVorgangErsetzen, transferEmployee } from "@/actions/employees"; import { geplantenVorgangErsetzen, transferEmployee } from "@/actions/employees";
import { Button } from "@/components/ui/Button"; import { Button } from "@/components/ui/Button";
import { PlanstellenAuswahl } from "@/components/positions/PlanstellenAuswahl"; import { PlanstellenAuswahl } from "@/components/positions/PlanstellenAuswahl";
import { DateField, SelectField } from "@/components/ui/Field"; import { StandortAuswahl } from "@/components/employees/StandortAuswahl";
import { DateField } from "@/components/ui/Field";
import { SlideOver } from "@/components/ui/SlideOver"; import { SlideOver } from "@/components/ui/SlideOver";
import { useToast } from "@/components/ui/Toast"; import { useToast } from "@/components/ui/Toast";
import { mitBisherigerStelle, type GeplanterVorgang } from "@/lib/geplanter-vorgang"; import { mitBisherigerStelle, type GeplanterVorgang } from "@/lib/geplanter-vorgang";
@@ -23,7 +24,7 @@ type TransferPanelProps = {
/** Eine geplante Versetzung, die geändert wird (lib/geplanter-vorgang.ts). */ /** Eine geplante Versetzung, die geändert wird (lib/geplanter-vorgang.ts). */
ersetzt?: GeplanterVorgang | null; ersetzt?: GeplanterVorgang | null;
/** Die Standorte zur Auswahl — mit der Versetzung kann auch der Standort wechseln. */ /** Die Standorte zur Auswahl — mit der Versetzung kann auch der Standort wechseln. */
locations?: { id: string; name: string }[]; locations?: { id: string; name: string; parent_id: string | null }[];
}; };
// Eine Versetzung ist der Wechsel auf eine andere Planstelle — nicht die // Eine Versetzung ist der Wechsel auf eine andere Planstelle — nicht die
@@ -58,6 +59,11 @@ export function TransferPanel({ open, onClose, employee, openPositions, ersetzt,
showToast("Bitte Datum und Zielplanstelle angeben.", "error"); showToast("Bitte Datum und Zielplanstelle angeben.", "error");
return; return;
} }
// Leer heisst hier: „Shop" gewählt, der einzelne Shop noch nicht.
if (!ersetzt && !standort) {
showToast("Bitte den Standort vollständig auswählen.", "error");
return;
}
setPending(true); setPending(true);
const result = ersetzt const result = ersetzt
? await geplantenVorgangErsetzen({ ? await geplantenVorgangErsetzen({
@@ -125,11 +131,10 @@ export function TransferPanel({ open, onClose, employee, openPositions, ersetzt,
{/* Nur bei einer neuen Versetzung: an einer geplanten werden {/* Nur bei einer neuen Versetzung: an einer geplanten werden
Planstelle und Datum geändert. */} Planstelle und Datum geändert. */}
{!ersetzt && locations.length > 0 && ( {!ersetzt && locations.length > 0 && (
<SelectField <StandortAuswahl
label="Standort"
value={standort} value={standort}
onChange={setStandort} onChange={setStandort}
options={locations.map((l) => ({ value: l.id, label: l.name }))} standorte={locations}
hint="Wechselt mit der Versetzung zum selben Tag; sonst bleibt der bisherige." hint="Wechselt mit der Versetzung zum selben Tag; sonst bleibt der bisherige."
/> />
)} )}

View File

@@ -107,7 +107,7 @@ export function VertragTab({
["Dienstwagen", ohneVorgabe(employee, ["has_dienstwagen"], employee.has_dienstwagen ? dienstwagenLabel(employee.dienstwagen_art) : "Nein")], ["Dienstwagen", ohneVorgabe(employee, ["has_dienstwagen"], employee.has_dienstwagen ? dienstwagenLabel(employee.dienstwagen_art) : "Nein")],
["Betriebsrat", ohneVorgabe(employee, ["is_betriebsrat"], employee.is_betriebsrat ? "Ja" : "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")], ["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 // Das Enddatum steht gleich dabei: „Ja" allein liesse offen, ob der
// Schutz noch läuft, und genau danach fragt man. // Schutz noch läuft, und genau danach fragt man.
// Die Teilzeitvariante gehört neben die Stunden: sie erklärt, warum sie // Die Teilzeitvariante gehört neben die Stunden: sie erklärt, warum sie

View File

@@ -60,7 +60,7 @@ type HireWizardProps = {
/** Ein neuer Entwurf ist angelegt — er trägt bereits meine Sperre. */ /** Ein neuer Entwurf ist angelegt — er trägt bereits meine Sperre. */
onEntwurfAngelegt: (id: string) => void; onEntwurfAngelegt: (id: string) => void;
openPositions: OpenPositionResolved[]; 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<string, unknown> } | null; resumeDraft: { id: string; step: number; payload: Record<string, unknown> } | null;
initialPositionId?: string; initialPositionId?: string;
}; };
@@ -484,7 +484,7 @@ export function HireWizard({
emergency_contact_phone: draft.emergencyContactPhone.trim() || undefined, emergency_contact_phone: draft.emergencyContactPhone.trim() || undefined,
emergency_contact_relation: draft.emergencyContactRelation.trim() || undefined, emergency_contact_relation: draft.emergencyContactRelation.trim() || undefined,
is_laterale_fuehrung: draft.isLateraleFuehrung, is_laterale_fuehrung: draft.isLateraleFuehrung,
is_c_level: draft.isCLevel, c_level: draft.cLevel,
}); });
if (!result.success || !result.employeeId) { if (!result.success || !result.employeeId) {
setSubmitting(false); setSubmitting(false);

View File

@@ -8,7 +8,7 @@ import type { Entwurf } from "@/lib/entwuerfe";
import type { OpenPositionResolved } from "@/lib/positions"; import type { OpenPositionResolved } from "@/lib/positions";
import { HireWizard } from "./HireWizard"; 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 }; type OpenWizardOptions = { draftId?: string; positionId?: string };

View File

@@ -64,7 +64,7 @@ type RehireWizardProps = {
onClose: () => void; onClose: () => void;
employee: EmployeeRow; employee: EmployeeRow;
openPositions: OpenPositionResolved[]; 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) { 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, has_dienstwagen: draft.hasDienstwagen,
dienstwagen_art: draft.hasDienstwagen ? draft.dienstwagenArt : "", dienstwagen_art: draft.hasDienstwagen ? draft.dienstwagenArt : "",
is_laterale_fuehrung: draft.isLateraleFuehrung, is_laterale_fuehrung: draft.isLateraleFuehrung,
is_c_level: draft.isCLevel, c_level: draft.cLevel,
has_kuendigungsschutz: draft.hasKuendigungsschutz, has_kuendigungsschutz: draft.hasKuendigungsschutz,
kuendigungsschutz_grund: draft.hasKuendigungsschutz ? draft.kuendigungsschutzGrund : "", kuendigungsschutz_grund: draft.hasKuendigungsschutz ? draft.kuendigungsschutzGrund : "",

View File

@@ -1,3 +1,4 @@
import { StandortAuswahl } from "@/components/employees/StandortAuswahl";
import { PlanstellenAuswahl } from "@/components/positions/PlanstellenAuswahl"; import { PlanstellenAuswahl } from "@/components/positions/PlanstellenAuswahl";
import { DateField, SelectField, TextField } from "@/components/ui/Field"; import { DateField, SelectField, TextField } from "@/components/ui/Field";
import { todayIso } from "@/lib/format"; import { todayIso } from "@/lib/format";
@@ -24,7 +25,7 @@ export function StepExternePerson({
}: { }: {
draft: HireDraftData; draft: HireDraftData;
update: (patch: Partial<HireDraftData>) => void; update: (patch: Partial<HireDraftData>) => void;
locations: { id: string; name: string; country: string }[]; locations: { id: string; name: string; country: string; parent_id: string | null }[];
openPositions: OpenPositionResolved[]; openPositions: OpenPositionResolved[];
stellenFehler?: string | null; stellenFehler?: string | null;
onNummerBefund: (befund: { nummer: number; vergeben: boolean }) => void; onNummerBefund: (befund: { nummer: number; vergeben: boolean }) => void;
@@ -78,13 +79,12 @@ export function StepExternePerson({
onChange={(id) => update({ positionId: id })} onChange={(id) => update({ positionId: id })}
/> />
<SelectField <StandortAuswahl
label="Standort"
required required
mitLand
value={draft.locationId} value={draft.locationId}
onChange={(locationId) => update({ locationId })} onChange={(locationId) => update({ locationId })}
placeholder="Bitte wählen…" standorte={locations}
options={locations.map((l) => ({ value: l.id, label: `${l.name} (${l.country})` }))}
/> />
</div> </div>
); );

View File

@@ -1,3 +1,4 @@
import { StandortAuswahl } from "@/components/employees/StandortAuswahl";
import { SvNummerField } from "@/components/employees/SvNummerField"; import { SvNummerField } from "@/components/employees/SvNummerField";
import { TitleFields } from "@/components/employees/TitleFields"; import { TitleFields } from "@/components/employees/TitleFields";
import { ZustaendigeHrField } from "@/components/employees/ZustaendigeHrField"; import { ZustaendigeHrField } from "@/components/employees/ZustaendigeHrField";
@@ -14,7 +15,7 @@ import type { HireDraftData } from "./types";
type StepPersonProps = { type StepPersonProps = {
draft: HireDraftData; draft: HireDraftData;
update: (patch: Partial<HireDraftData>) => void; update: (patch: Partial<HireDraftData>) => 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". */ /** Meldet die geprüfte Personalnummer und ihr Ergebnis — steuert „Weiter". */
onNummerBefund?: (befund: { nummer: number; vergeben: boolean }) => void; onNummerBefund?: (befund: { nummer: number; vergeben: boolean }) => void;
/** /**
@@ -185,13 +186,12 @@ export function StepPerson({ draft, update, locations, onNummerBefund, nummerGes
/> />
<TextField label="Private Telefonnummer" type="tel" value={draft.phone} onChange={(phone) => update({ phone })} /> <TextField label="Private Telefonnummer" type="tel" value={draft.phone} onChange={(phone) => update({ phone })} />
</div> </div>
<SelectField <StandortAuswahl
label="Standort"
required required
mitLand
value={draft.locationId} value={draft.locationId}
onChange={(locationId) => update({ locationId })} onChange={(locationId) => update({ locationId })}
placeholder="Bitte wählen…" standorte={locations}
options={locations.map((l) => ({ value: l.id, label: `${l.name} (${l.country})` }))}
/> />
<ZustaendigeHrField value={draft.zustaendigeHrId} onChange={(zustaendigeHrId) => update({ zustaendigeHrId })} /> <ZustaendigeHrField value={draft.zustaendigeHrId} onChange={(zustaendigeHrId) => update({ zustaendigeHrId })} />
</div> </div>

View File

@@ -46,7 +46,6 @@ export function StepSummary({ draft, selectedPosition, locations, extern = false
draft.isBetriebsrat && "Betriebsrat", draft.isBetriebsrat && "Betriebsrat",
draft.hasDienstwagen && `Dienstwagen (${dienstwagenLabel(draft.dienstwagenArt)})`, draft.hasDienstwagen && `Dienstwagen (${dienstwagenLabel(draft.dienstwagenArt)})`,
draft.isLateraleFuehrung && "Laterale Führung", draft.isLateraleFuehrung && "Laterale Führung",
draft.isCLevel && "C-Level",
draft.hasKuendigungsschutz && draft.hasKuendigungsschutz &&
`Besonderer Kündigungsschutz${draft.kuendigungsschutzBis ? ` bis ${fmtDate(draft.kuendigungsschutzBis)}` : ""}`, `Besonderer Kündigungsschutz${draft.kuendigungsschutzBis ? ` bis ${fmtDate(draft.kuendigungsschutzBis)}` : ""}`,
].filter(Boolean); ].filter(Boolean);
@@ -89,6 +88,7 @@ export function StepSummary({ draft, selectedPosition, locations, extern = false
: []), : []),
["Anstellungs-/Beschäftigungsart", anzeige(draft.mitarbeiterart)], ["Anstellungs-/Beschäftigungsart", anzeige(draft.mitarbeiterart)],
["Kollektivvertrag", draft.collectiveAgreement], ["Kollektivvertrag", draft.collectiveAgreement],
["C-Level", draft.cLevel || "–"],
["Arbeitstage", draft.workDays.join(", ") || "–"], ["Arbeitstage", draft.workDays.join(", ") || "–"],
["Merkmale", flags.length > 0 ? flags.join(", ") : "–"], ["Merkmale", flags.length > 0 ? flags.join(", ") : "–"],
]; ];

View File

@@ -88,7 +88,7 @@ export function StepVertrag({
<TextField <TextField
label="Wochenstunden" label="Wochenstunden"
type="number" type="number"
step="0.5" step="0.01"
value={draft.weeklyHours} value={draft.weeklyHours}
disabled={draft.employmentType === "Vollzeit"} disabled={draft.employmentType === "Vollzeit"}
onChange={(weeklyHours) => update({ weeklyHours })} onChange={(weeklyHours) => update({ weeklyHours })}

View File

@@ -54,7 +54,7 @@ export function UebernahmeWizard({
open: boolean; open: boolean;
onClose: () => void; onClose: () => void;
employee: EmployeeRow; employee: EmployeeRow;
locations: { id: string; name: string; country: string }[]; locations: { id: string; name: string; country: string; parent_id: string | null }[];
}) { }) {
const { showToast } = useToast(); const { showToast } = useToast();
const router = useRouter(); const router = useRouter();
@@ -202,7 +202,7 @@ export function UebernahmeWizard({
has_dienstwagen: draft.hasDienstwagen, has_dienstwagen: draft.hasDienstwagen,
dienstwagen_art: draft.hasDienstwagen ? draft.dienstwagenArt : "", dienstwagen_art: draft.hasDienstwagen ? draft.dienstwagenArt : "",
is_laterale_fuehrung: draft.isLateraleFuehrung, is_laterale_fuehrung: draft.isLateraleFuehrung,
is_c_level: draft.isCLevel, c_level: draft.cLevel,
teilzeit_art: teilzeit, teilzeit_art: teilzeit,
teilzeit_bis: teilzeit ? draft.teilzeitBis : "", teilzeit_bis: teilzeit ? draft.teilzeitBis : "",
has_kuendigungsschutz: draft.hasKuendigungsschutz, has_kuendigungsschutz: draft.hasKuendigungsschutz,

View File

@@ -106,7 +106,8 @@ export type HireDraftData = {
emergencyContactRelation: string; emergencyContactRelation: string;
angehoerige: HireDraftAngehoerige[]; angehoerige: HireDraftAngehoerige[];
isLateraleFuehrung: boolean; 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. */ /** Form der Beschäftigung — zweite Achse neben der Beschäftigtengruppe. */
mitarbeiterart: Mitarbeiterart; mitarbeiterart: Mitarbeiterart;
hasKuendigungsschutz: boolean; hasKuendigungsschutz: boolean;
@@ -182,7 +183,7 @@ export const EMPTY_HIRE_DRAFT: HireDraftData = {
emergencyContactRelation: "", emergencyContactRelation: "",
angehoerige: [], angehoerige: [],
isLateraleFuehrung: false, isLateraleFuehrung: false,
isCLevel: false, cLevel: "",
mitarbeiterart: MITARBEITERART_STANDARD, mitarbeiterart: MITARBEITERART_STANDARD,
hasKuendigungsschutz: false, hasKuendigungsschutz: false,
kuendigungsschutzBis: "", kuendigungsschutzBis: "",

View File

@@ -220,7 +220,7 @@ function KriterienBlock({
label="Ab" label="Ab"
dense dense
type="number" type="number"
step="0.5" step="0.01"
value={criteria.stundenVon?.toString() ?? ""} value={criteria.stundenVon?.toString() ?? ""}
onChange={(v) => onChange({ hoursFrom: v || undefined })} onChange={(v) => onChange({ hoursFrom: v || undefined })}
/> />
@@ -228,7 +228,7 @@ function KriterienBlock({
label="Bis" label="Bis"
dense dense
type="number" type="number"
step="0.5" step="0.01"
value={criteria.stundenBis?.toString() ?? ""} value={criteria.stundenBis?.toString() ?? ""}
onChange={(v) => onChange({ hoursTo: v || undefined })} onChange={(v) => onChange({ hoursTo: v || undefined })}
/> />

View File

@@ -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 (
<>
<div aria-hidden className="pointer-events-none fixed inset-0 z-[70] border-[3px] border-red-600 print:hidden" />
<div
role="note"
className="pointer-events-none fixed left-1/2 top-0 z-[70] flex -translate-x-1/2 items-center gap-1.5 rounded-b-lg bg-red-600 px-5 pb-1.5 pt-[max(0.375rem,env(safe-area-inset-top))] text-sm font-bold uppercase tracking-[0.15em] text-white shadow-md print:hidden"
>
<TriangleAlert className="h-4 w-4" aria-hidden />
{TESTSYSTEM_SCHRIFTZUG}
</div>
</>
);
}

View File

@@ -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
$$;

View File

@@ -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
$$;

View File

@@ -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$;

View File

@@ -60,7 +60,7 @@ declare
v_psnr text; v_psnr text;
begin begin
select id into v_wurzel from org_units where parent_id is null; 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; select coalesce(max(personnel_number), 0) + 1 into v_nr from employees;
if v_wurzel is null or v_ort is null then if v_wurzel is null or v_ort is null then
raise exception 'Kein Bestand: es fehlt die oberste Einheit oder ein Standort.'; raise exception 'Kein Bestand: es fehlt die oberste Einheit oder ein Standort.';

View File

@@ -62,7 +62,7 @@ begin
raise exception 'Voraussetzung fehlt: zwei aktive und ein abgeschaltetes HR-Konto.'; raise exception 'Voraussetzung fehlt: zwei aktive und ein abgeschaltetes HR-Konto.';
end if; end if;
select id into v_wurzel from org_units where parent_id is null; 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; select coalesce(max(personnel_number), 0) + 1 into v_nr from employees;
v_einheit := create_org_unit(jsonb_build_object( v_einheit := create_org_unit(jsonb_build_object(
@@ -253,7 +253,7 @@ declare
v_e employees%rowtype; v_e employees%rowtype;
v_a uuid := (select id from employees where last_name = 'Test-A' and first_name = 'Vertrag'); 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_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 begin
perform apply_due_pending_changes(); perform apply_due_pending_changes();
select * into v_e from employees where id = v_b; select * into v_e from employees where id = v_b;

View File

@@ -46,6 +46,11 @@ CRON_SECRET={{CRON_SECRET}}
# betroffen. # betroffen.
# LOLYO_STARTPASSWORT= # 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 # Nur wenn der Server ins Internet ueber einen Proxy muss: Node.js liest die
# Proxy-Einstellung von Windows NICHT, ohne diese Zeilen scheitert die # Proxy-Einstellung von Windows NICHT, ohne diese Zeilen scheitert die
# Anmeldung am Abruf von login.microsoftonline.com. konfiguration-anwenden.ps1 # Anmeldung am Abruf von login.microsoftonline.com. konfiguration-anwenden.ps1

View File

@@ -1,7 +1,8 @@
// Wie gespeicherte Werte angezeigt und exportiert werden, wo die fachliche // Wie gespeicherte Werte angezeigt und exportiert werden, wo die fachliche
// Bezeichnung vom gespeicherten Wert abweicht. // 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", // * Nicht gendern. Gespeichert bleibt „Angestellte:r", „Arbeiter:in",
// „Praktikant:in", „Ehepartner:in", „Lebenspartner:in"; angezeigt wird // „Praktikant:in", „Ehepartner:in", „Lebenspartner:in"; angezeigt wird
@@ -42,6 +43,19 @@ const UMBENANNT: readonly (readonly [RegExp, string])[] = [
[new RegExp(`(?<![${BUCHSTABE}])Schwangerschaft(?![${BUCHSTABE}])`, "g"), "Mutterschutz"], [new RegExp(`(?<![${BUCHSTABE}])Schwangerschaft(?![${BUCHSTABE}])`, "g"), "Mutterschutz"],
]; ];
// Das Ende einer Langzeitabwesenheit heisst fachlich „Endet am", nicht
// „Rückkehr". Gespeichert bleibt das Datum, an dem die Person zurück ist, und
// mit ihm die Texte der Datenbank: „Elternkarenz, geplante Rückkehr am …",
// „Rückkehr aus Elternkarenz am …" und das Feld „Geplante Rückkehr". Nur
// diese drei Formen mit einem Datum dahinter; die Rückkehr als Ereignis
// behält ihren Namen. Läuft nach der Datumsumstellung, deshalb TT.MM.JJJJ.
const DATUM_TMJ = String.raw`\d{2}\.\d{2}\.\d{4}`;
const ABWESENHEIT_ENDE: readonly (readonly [RegExp, string])[] = [
[new RegExp(`geplante Rückkehr (?:am )?(${DATUM_TMJ})`, "g"), "endet am $1"],
[new RegExp(`(?<![${BUCHSTABE}])Rückkehr aus ([^,]+?) am (${DATUM_TMJ})`, "g"), "$1 endet am $2"],
[/^Geplante Rückkehr$/, "Endet am"],
];
// Ein Datum in einem Text, den die Datenbank zusammensetzt („wirksam ab // Ein Datum in einem Text, den die Datenbank zusammensetzt („wirksam ab
// 2026-11-03"), oder als gespeicherter Feldwert. Gezeigt wird es wie jedes // 2026-11-03"), oder als gespeicherter Feldwert. Gezeigt wird es wie jedes
// andere Datum der Anwendung: TT.MM.JJJJ. Nicht getroffen werden Zeitstempel // andere Datum der Anwendung: TT.MM.JJJJ. Nicht getroffen werden Zeitstempel
@@ -56,6 +70,9 @@ export function anzeige(text: string | null | undefined): string | null | undefi
if (!text) return text; if (!text) return text;
let ergebnis = text.replace(ISO_DATUM, "$3.$2.$1"); let ergebnis = text.replace(ISO_DATUM, "$3.$2.$1");
for (const [muster, ersatz] of UMBENANNT) ergebnis = ergebnis.replace(muster, ersatz); for (const [muster, ersatz] of UMBENANNT) ergebnis = ergebnis.replace(muster, ersatz);
if (ergebnis.includes("ückkehr")) {
for (const [muster, ersatz] of ABWESENHEIT_ENDE) ergebnis = ergebnis.replace(muster, ersatz);
}
if (!ergebnis.includes(":")) return ergebnis; if (!ergebnis.includes(":")) return ergebnis;
for (const [gegendert, ungegendert] of AUSNAHMEN) ergebnis = ergebnis.split(gegendert).join(ungegendert); for (const [gegendert, ungegendert] of AUSNAHMEN) ergebnis = ergebnis.split(gegendert).join(ungegendert);
for (const [muster, ersatz] of REGELN) ergebnis = ergebnis.replace(muster, ersatz); for (const [muster, ersatz] of REGELN) ergebnis = ergebnis.replace(muster, ersatz);

View File

@@ -18,12 +18,13 @@
// nichts aus, und eine Summe, die nicht aufgeht, ist schlechter als keine // nichts aus, und eine Summe, die nicht aufgeht, ist schlechter als keine
// Angabe — sie sieht aus wie eine. // Angabe — sie sieht aus wie eine.
// //
// ── Warum in Zehnteln gerechnet wird ────────────────────────────────────── // ── Warum in Hundertsteln gerechnet wird ──────────────────────────────────
// //
// `weekly_hours` ist numeric(4,1), die Eingaben sind es auch. In // `weekly_hours` ist numeric(4,2), die Eingaben sind es auch: 19,25 Stunden
// Gleitkommazahlen trifft 7,7 × 5 die 38,5 trotzdem nicht (38,49999…), und // verteilen sich etwa als 3,85 an fünf Tagen. In Gleitkommazahlen trifft
// die Prüfung „exakt gleich" schlüge bei einer völlig richtigen Eingabe fehl. // 7,7 × 5 die 38,5 trotzdem nicht (38,49999…), und die Prüfung „exakt
// Gerechnet wird deshalb in ganzen Zehntelstunden. // gleich" schlüge bei einer völlig richtigen Eingabe fehl. Gerechnet wird
// deshalb in ganzen Hundertstelstunden.
import type { Weekday } from "./types"; import type { Weekday } from "./types";
@@ -41,13 +42,18 @@ export type ArbeitszeitBefund = {
fehler: string | null; fehler: string | null;
}; };
/** Zehntelstunden als ganze Zahl; null, wenn das Feld leer oder keine Zahl ist. */ /** Hundertstelstunden als ganze Zahl; null, wenn das Feld leer oder keine Zahl ist. */
function zehntel(wert: string | undefined): number | null { function hundertstel(wert: string | undefined): number | null {
const roh = (wert ?? "").trim().replace(",", "."); const roh = (wert ?? "").trim().replace(",", ".");
if (roh === "") return null; if (roh === "") return null;
const zahl = Number(roh); const zahl = Number(roh);
if (!Number.isFinite(zahl)) return null; if (!Number.isFinite(zahl)) return null;
return Math.round(zahl * 10); return Math.round(zahl * 100);
}
/** Mehr als zwei Nachkommastellen lassen sich nicht so speichern, wie sie dastehen. */
function zuGenau(wert: string | undefined): boolean {
return /[.,]\d{3,}$/.test((wert ?? "").trim());
} }
export function arbeitszeitBefund( export function arbeitszeitBefund(
@@ -55,20 +61,23 @@ export function arbeitszeitBefund(
tage: readonly Weekday[], tage: readonly Weekday[],
wochenstunden: number wochenstunden: number
): ArbeitszeitBefund { ): ArbeitszeitBefund {
const werte = tage.map((tag) => zehntel(modell[tag])); const werte = tage.map((tag) => hundertstel(modell[tag]));
const erfasst = werte.some((w) => w !== null); const erfasst = werte.some((w) => w !== null);
const summeZehntel = werte.reduce<number>((s, w) => s + (w ?? 0), 0); const summeHundertstel = werte.reduce<number>((s, w) => s + (w ?? 0), 0);
const summe = summeZehntel / 10; const summe = summeHundertstel / 100;
if (!erfasst) return { erfasst: false, summe: 0, fehler: null }; if (!erfasst) return { erfasst: false, summe: 0, fehler: null };
if (werte.some((w) => w === null)) { if (werte.some((w) => w === null)) {
return { erfasst, summe, fehler: "Für jeden gewählten Arbeitstag müssen Stunden eingetragen sein." }; 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)) { if (werte.some((w) => (w as number) <= 0)) {
return { erfasst, summe, fehler: "An einem Arbeitstag müssen mehr als 0 Stunden stehen." }; 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) { if (zuviel.length > 0) {
return { return {
erfasst, erfasst,
@@ -76,7 +85,7 @@ export function arbeitszeitBefund(
fehler: `An einem Arbeitstag sind höchstens ${MAX_STUNDEN_JE_TAG} Stunden möglich (${zuviel.join(", ")}).`, 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 { return {
erfasst, erfasst,
summe, summe,
@@ -98,8 +107,8 @@ export function arbeitszeitFuerDb(
): Record<string, number> | null { ): Record<string, number> | null {
const eintraege: Record<string, number> = {}; const eintraege: Record<string, number> = {};
for (const tag of tage) { for (const tag of tage) {
const z = zehntel(modell[tag]); const h = hundertstel(modell[tag]);
if (z !== null) eintraege[tag] = z / 10; if (h !== null) eintraege[tag] = h / 100;
} }
return Object.keys(eintraege).length > 0 ? eintraege : null; return Object.keys(eintraege).length > 0 ? eintraege : null;
} }
@@ -114,7 +123,7 @@ export function arbeitszeitAusDb(gespeichert: unknown): Arbeitszeitmodell {
return modell; 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 { 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 });
} }

View File

@@ -5,6 +5,7 @@ import { fmtName } from "../format";
import { pruefePlz } from "../plz"; import { pruefePlz } from "../plz";
import { requiresAustrianSvnr, svnrErrorMessage, svnrHaeltAuf, validateSvnr } from "../svnr"; import { requiresAustrianSvnr, svnrErrorMessage, svnrHaeltAuf, validateSvnr } from "../svnr";
import type { Database } from "../types"; import type { Database } from "../types";
import { SONSTIGE, verhaeltnisAusDatei } from "../verhaeltnis";
import { pruefsumme } from "./abgleich"; import { pruefsumme } from "./abgleich";
import { BLAETTER, WIRKSAM_AB, type Blatt, type Spalte } from "./katalog"; import { BLAETTER, WIRKSAM_AB, type Blatt, type Spalte } from "./katalog";
import { import {
@@ -158,7 +159,7 @@ async function rufe(tx: Tx, fn: MutationFn, payload: Record<string, unknown>): P
/** Lookups, die sich mit jedem Blatt ändern können: was die Datei neu anlegt, gilt sofort. */ /** Lookups, die sich mit jedem Blatt ändern können: was die Datei neu anlegt, gilt sofort. */
type Bestand = { type Bestand = {
standorte: Map<string, { id: string; name: string; country: string }>; standorte: Map<string, { id: string; name: string; country: string; parent_id: string | null }>;
kostenstellen: Map<string, { id: string; name: string }>; kostenstellen: Map<string, { id: string; name: string }>;
einheiten: Map<string, Record<string, unknown> & { id: string }>; einheiten: Map<string, Record<string, unknown> & { id: string }>;
planstellen: Map<string, Record<string, unknown> & { id: string }>; planstellen: Map<string, Record<string, unknown> & { id: string }>;
@@ -168,7 +169,7 @@ type Bestand = {
async function bestandLaden(tx: Tx, heute: string): Promise<Bestand> { async function bestandLaden(tx: Tx, heute: string): Promise<Bestand> {
const [standorte, kostenstellen, einheiten, planstellen, personen, hr] = await Promise.all([ 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("cost_centers").select(["id", "code", "name"]).execute(),
tx tx
.selectFrom("org_units as u") .selectFrom("org_units as u")
@@ -649,6 +650,15 @@ function mitarbeiterZeile(
const planstelle = (n: unknown) => bestand.planstellen.get(String(n)); const planstelle = (n: unknown) => bestand.planstellen.get(String(n));
if (zeile.wert("location_id") && !standortId(zeile.wert("location_id"))) { 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"); 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"))) { 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"); 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; 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<string, unknown> | 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<string, unknown>, feld: string, wert: string | null): Record<string, unknown> {
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 }) { function angehoerigerZeile(tx: Tx, zeile: Zeile, bestand: Bestand, aktuell: Datensaetze, { modus, heute }: { modus: Modus; heute: string }) {
const person = personZu(zeile, bestand); const person = personZu(zeile, bestand);
if (!person) return; if (!person) return;
@@ -953,9 +991,15 @@ function angehoerigerZeile(tx: Tx, zeile: Zeile, bestand: Bestand, aktuell: Date
if (eintrag === null) { if (eintrag === null) {
if (zeile.wert("entfernen") === "ja") return zeile.fehler("Ein neuer Eintrag lässt sich nicht entfernen.", "entfernen"); if (zeile.wert("entfernen") === "ja") return zeile.fehler("Ein neuer Eintrag lässt sich nicht entfernen.", "entfernen");
if (!pflichtNeu(zeile)) return; if (!pflichtNeu(zeile)) return;
const verhaeltnis = verhaeltnisDerZeile(zeile, "relationship", null);
if (verhaeltnis === undefined) return;
const g = zeile.geaendert(null); const g = zeile.geaendert(null);
zeile.schritt("Angehörige:r angelegt", "last_name", async () => { 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; return;
} }
@@ -968,6 +1012,8 @@ function angehoerigerZeile(tx: Tx, zeile: Zeile, bestand: Bestand, aktuell: Date
}); });
return; return;
} }
const verhaeltnis = verhaeltnisDerZeile(zeile, "relationship", eintrag.werte);
if (verhaeltnis === undefined) return;
const g = zeile.geaendert(eintrag.werte, (f) => f !== "id" && f !== "entfernen"); const g = zeile.geaendert(eintrag.werte, (f) => f !== "id" && f !== "entfernen");
if (g.size === 0) return; if (g.size === 0) return;
const neu = { ...eintrag.werte, ...Object.fromEntries(g) }; const neu = { ...eintrag.werte, ...Object.fromEntries(g) };
@@ -976,7 +1022,7 @@ function angehoerigerZeile(tx: Tx, zeile: Zeile, bestand: Bestand, aktuell: Date
dependent_id: id, dependent_id: id,
first_name: neu.first_name, first_name: neu.first_name,
last_name: neu.last_name, last_name: neu.last_name,
relationship: neu.relationship, relationship: verhaeltnis,
birth_date: neu.birth_date ?? "", birth_date: neu.birth_date ?? "",
sv_nummer: neu.sv_nummer ?? "", sv_nummer: neu.sv_nummer ?? "",
}); });
@@ -993,9 +1039,11 @@ function notfallkontaktZeile(tx: Tx, zeile: Zeile, bestand: Bestand, aktuell: Da
if (eintrag === null) { if (eintrag === null) {
if (zeile.wert("entfernen") === "ja") return zeile.fehler("Ein neuer Eintrag lässt sich nicht entfernen.", "entfernen"); if (zeile.wert("entfernen") === "ja") return zeile.fehler("Ein neuer Eintrag lässt sich nicht entfernen.", "entfernen");
if (!pflichtNeu(zeile)) return; if (!pflichtNeu(zeile)) return;
const verhaeltnis = verhaeltnisDerZeile(zeile, "relation", null);
if (verhaeltnis === undefined) return;
const g = zeile.geaendert(null); const g = zeile.geaendert(null);
zeile.schritt("Notfallkontakt angelegt", "name", async () => { 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; return;
} }
@@ -1008,10 +1056,12 @@ function notfallkontaktZeile(tx: Tx, zeile: Zeile, bestand: Bestand, aktuell: Da
}); });
return; return;
} }
const verhaeltnis = verhaeltnisDerZeile(zeile, "relation", eintrag.werte);
if (verhaeltnis === undefined) return;
const g = zeile.geaendert(eintrag.werte, (f) => f !== "id" && f !== "entfernen"); const g = zeile.geaendert(eintrag.werte, (f) => f !== "id" && f !== "entfernen");
if (g.size === 0) return; if (g.size === 0) return;
const neu = { ...eintrag.werte, ...Object.fromEntries(g) }; const neu = { ...eintrag.werte, ...Object.fromEntries(g) };
zeile.schritt("Notfallkontakt geändert", [...g.keys()][0], async () => { 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 ?? "" });
}); });
} }

View File

@@ -227,7 +227,7 @@ const MITARBEITER_ROH: Spalte[] = [
feld("Vertrag und Arbeitszeit", "Beschäftigungsausmaß", "Beschäftigungsausmaß", "employment_type", auswahlAusKarte("Beschäftigungsausmaß"), { feld("Vertrag und Arbeitszeit", "Beschäftigungsausmaß", "Beschäftigungsausmaß", "employment_type", auswahlAusKarte("Beschäftigungsausmaß"), {
hinweis: STUNDEN_HINWEIS, 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, hinweis: STUNDEN_HINWEIS,
}), }),
feld("Vertrag und Arbeitszeit", "Arbeitstage", "Arbeitstage", "work_days", { feld("Vertrag und Arbeitszeit", "Arbeitstage", "Arbeitstage", "work_days", {
@@ -273,7 +273,9 @@ const MITARBEITER_ROH: Spalte[] = [
hinweis: "Pflicht bei Dienstwagen „Ja“.", hinweis: "Pflicht bei Dienstwagen „Ja“.",
}), }),
feld("Vertrag und Arbeitszeit", "Laterale Führung", "Laterale Führung", "is_laterale_fuehrung", JA_NEIN), 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", "Besonderer Kündigungsschutz", "Besonderer Kündigungsschutz", "has_kuendigungsschutz", JA_NEIN),
feld("Vertrag und Arbeitszeit", "Personenkreis", "Kündigungsschutz Personenkreis", "kuendigungsschutz_grund", auswahlAusKarte("Kündigungsschutz Personenkreis"), { feld("Vertrag und Arbeitszeit", "Personenkreis", "Kündigungsschutz Personenkreis", "kuendigungsschutz_grund", auswahlAusKarte("Kündigungsschutz Personenkreis"), {
hinweis: KUENDIGUNGSSCHUTZ_HINWEIS, hinweis: KUENDIGUNGSSCHUTZ_HINWEIS,
@@ -328,7 +330,7 @@ const MITARBEITER_ROH: Spalte[] = [
{ {
titel: "Wochenstunden ab Rückkehr", titel: "Wochenstunden ab Rückkehr",
feld: "rueckkehr_stunden", feld: "rueckkehr_stunden",
format: { art: "zahl", nachkomma: 1 }, format: { art: "zahl", nachkomma: 2 },
thema: "Langzeitabwesenheit", thema: "Langzeitabwesenheit",
hinweis: "Pflicht bei „Reduziert“; weniger als 38,5.", hinweis: "Pflicht bei „Reduziert“; weniger als 38,5.",
}, },
@@ -403,7 +405,7 @@ const MITARBEITER_ROH: Spalte[] = [
const IMMER_BELEGT = new Set([ const IMMER_BELEGT = new Set([
"last_name", "first_name", "gender", "nationality", "location_id", "position_number", "job_title", "entry_date", "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", "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", "hat_aufenthaltstitel", "ist_beguenstigt_behindert", "has_bonusanspruch", "ist_uebernahme_leiharbeit",
]); ]);
@@ -469,8 +471,22 @@ const PERSONALNUMMER_VERWEIS: Spalte = {
pflicht: true, 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 = { const ENTFERNEN: Spalte = {
titel: "Entfernen", titel: "Entfernen",
@@ -485,6 +501,7 @@ export const BLATT_ANGEHOERIGE: Blatt = {
zweck: "Angehörige je Person. Leere ID = neu anlegen.", zweck: "Angehörige je Person. Leere ID = neu anlegen.",
schluessel: PERSONALNUMMER_VERWEIS, schluessel: PERSONALNUMMER_VERWEIS,
wirksamAb: "Leer = heute. Gilt für Neuanlage und Entfernen.", wirksamAb: "Leer = heute. Gilt für Neuanlage und Entfernen.",
bedingungen: [{ feld: "relationship_sonstige", art: "leer", wenn: { feld: "relationship", nicht: "Sonstige" } }],
spalten: [ spalten: [
{ titel: "ID", feld: "id", format: TEXT, hinweis: "Vergibt das System. Leer = neuer Eintrag." }, { titel: "ID", feld: "id", format: TEXT, hinweis: "Vergibt das System. Leer = neuer Eintrag." },
{ titel: "Nachname", feld: "last_name", format: TEXT, pflichtNeu: true, pflicht: true }, { titel: "Nachname", feld: "last_name", format: TEXT, pflichtNeu: true, pflicht: true },
@@ -495,8 +512,9 @@ export const BLATT_ANGEHOERIGE: Blatt = {
format: VERHAELTNIS, format: VERHAELTNIS,
pflichtNeu: true, pflichtNeu: true,
pflicht: 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: "Geburtsdatum", feld: "birth_date", format: DATUM },
{ titel: "SV-Nummer", feld: "sv_nummer", format: TEXT }, { titel: "SV-Nummer", feld: "sv_nummer", format: TEXT },
ENTFERNEN, ENTFERNEN,
@@ -508,6 +526,7 @@ export const BLATT_NOTFALLKONTAKTE: Blatt = {
zweck: "Notfallkontakte je Person. Leere ID = neu anlegen.", zweck: "Notfallkontakte je Person. Leere ID = neu anlegen.",
schluessel: PERSONALNUMMER_VERWEIS, schluessel: PERSONALNUMMER_VERWEIS,
wirksamAb: "Leer lassen: Notfallkontakte gelten sofort.", wirksamAb: "Leer lassen: Notfallkontakte gelten sofort.",
bedingungen: [{ feld: "relation_sonstige", art: "leer", wenn: { feld: "relation", nicht: "Sonstige" } }],
spalten: [ spalten: [
{ titel: "ID", feld: "id", format: TEXT, hinweis: "Vergibt das System. Leer = neuer Eintrag." }, { titel: "ID", feld: "id", format: TEXT, hinweis: "Vergibt das System. Leer = neuer Eintrag." },
{ titel: "Name", feld: "name", format: TEXT, pflichtNeu: true, pflicht: true }, { titel: "Name", feld: "name", format: TEXT, pflichtNeu: true, pflicht: true },
@@ -516,8 +535,9 @@ export const BLATT_NOTFALLKONTAKTE: Blatt = {
titel: "Verhältnis", titel: "Verhältnis",
feld: "relation", feld: "relation",
format: VERHAELTNIS, format: VERHAELTNIS,
hinweis: "Aus der Liste oder frei eingetragen, wie „Sonstige“ in der Personalakte.", hinweis: VERHAELTNIS_HINWEIS,
}, },
verhaeltnisSonstige("relation_sonstige"),
ENTFERNEN, ENTFERNEN,
], ],
}; };

View File

@@ -8,6 +8,7 @@ import { loadOrgMaps, type OrgMaps } from "../org";
import { loadPlacements, loadReportingLineMap, type Placement } from "../placement"; import { loadPlacements, loadReportingLineMap, type Placement } from "../placement";
import { deriveStatusAsOf } from "../reports"; import { deriveStatusAsOf } from "../reports";
import type { Database } from "../types"; import type { Database } from "../types";
import { verhaeltnisFuerDatei } from "../verhaeltnis";
import type { Listen } from "./herunterladen"; import type { Listen } from "./herunterladen";
import type { Datensatz } 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("employee_id")
.orderBy("created_at") .orderBy("created_at")
.execute(); .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<Datensatz[]> { export async function ladeNotfallkontakte(tx: Tx, personen: readonly Person[]): Promise<Datensatz[]> {
@@ -145,7 +153,14 @@ export async function ladeNotfallkontakte(tx: Tx, personen: readonly Person[]):
.orderBy("employee_id") .orderBy("employee_id")
.orderBy("created_at") .orderBy("created_at")
.execute(); .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<Datensatz[]> { export async function ladeHistorie(tx: Tx, personen: readonly Person[], b: Bezuege): Promise<Datensatz[]> {
@@ -242,7 +257,13 @@ export async function ladeStandorte(tx: Tx): Promise<Datensatz[]> {
*/ */
export async function ladeListen(tx: Tx, heute: string): Promise<Listen> { export async function ladeListen(tx: Tx, heute: string): Promise<Listen> {
const [standorte, jobs, einheiten, stellen, kostenstellen, hr] = await Promise.all([ 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("jobs").select("title").execute(),
tx.selectFrom("org_units").select("org_number").where("valid_to", "is", null).orderBy("org_number").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 // Nur freie Planstellen: niemand sitzt heute oder später darauf, keine

View File

@@ -80,7 +80,9 @@ export const GRUPPE_JE_FELD: Readonly<Record<string, "person" | "contract" | "ro
is_betriebsrat: "role", is_betriebsrat: "role",
has_dienstwagen: "role", has_dienstwagen: "role",
is_laterale_fuehrung: "role", is_laterale_fuehrung: "role",
// Abgelöst durch c_level; die Feldkarte führt es weiter für ältere Einträge.
is_c_level: "role", is_c_level: "role",
c_level: "role",
dienstwagen_art: "role", dienstwagen_art: "role",
lehrzeit_von: "role", lehrzeit_von: "role",
lehrzeit_bis: "role", lehrzeit_bis: "role",

View File

@@ -50,10 +50,10 @@ function arbeitszeitmodellFehler(text: string, stunden: string | undefined, tage
} }
} }
if (stunden !== undefined) { if (stunden !== undefined) {
// In Zehnteln gerechnet, wie lib/arbeitszeit.ts: 7,7 × 5 verfehlte sonst die 38,5. // 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 * 10), 0); const summe = werte.reduce((s, w) => s + Math.round(w * 100), 0);
if (summe !== Math.round(Number(stundenWert(stunden)) * 10)) { if (summe !== Math.round(Number(stundenWert(stunden)) * 100)) {
return `Die Summe des Arbeitszeitmodells beträgt ${String(summe / 10).replace(".", ",")} und muss den Wochenstunden entsprechen.`; return `Die Summe des Arbeitszeitmodells beträgt ${String(summe / 100).replace(".", ",")} und muss den Wochenstunden entsprechen.`;
} }
} }
return null; return null;

21
lib/c-level.ts Normal file
View File

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

View File

@@ -23,7 +23,6 @@ const VORGABEN = {
is_betriebsrat: false, is_betriebsrat: false,
has_dienstwagen: false, has_dienstwagen: false,
is_laterale_fuehrung: false, is_laterale_fuehrung: false,
is_c_level: false,
has_kuendigungsschutz: false, has_kuendigungsschutz: false,
ist_beguenstigt_behindert: false, ist_beguenstigt_behindert: false,
has_bonusanspruch: false, has_bonusanspruch: false,

View File

@@ -1,5 +1,6 @@
import { ABSENCE_TYPES, KEINE_TEILZEITVARIANTE, STUNDEN_GRUENDE, statusLabel } from "./absence"; import { ABSENCE_TYPES, KEINE_TEILZEITVARIANTE, STUNDEN_GRUENDE, statusLabel } from "./absence";
import { anzeige, anzeigeAuswahl } from "./anzeige"; import { anzeige, anzeigeAuswahl } from "./anzeige";
import { C_LEVEL_AUSWAHL } from "./c-level";
import { GESCHLECHTER } from "./geschlecht"; import { GESCHLECHTER } from "./geschlecht";
import { HAY_GRADE_WERTE } from "./hay-grade"; import { HAY_GRADE_WERTE } from "./hay-grade";
import { KOLLEKTIVVERTRAEGE } from "./kollektivvertrag"; import { KOLLEKTIVVERTRAEGE } from "./kollektivvertrag";
@@ -88,7 +89,9 @@ export const FELD_OPTIONEN: Record<string, readonly Option[]> = {
Dienstwagen: JA_NEIN, Dienstwagen: JA_NEIN,
Betriebsrat: JA_NEIN, Betriebsrat: JA_NEIN,
"Laterale Führung": 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, "Besonderer Kündigungsschutz": JA_NEIN,
"Begünstigt behindert": JA_NEIN, "Begünstigt behindert": JA_NEIN,
Aufenthaltstitel: JA_NEIN, Aufenthaltstitel: JA_NEIN,

View File

@@ -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 * formatiert Postgres sie anders als der Treiber es sonst täte, und der
* Unterschied fällt erst beim Vergleichen auf. * 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 return eb
.selectFrom("employee_notes as n") .selectFrom("employee_notes as n")
.leftJoin("employees as e", "e.id", "n.employee_id") .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")]) .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("n.done", "=", false)
.where(sichtbareNotizen(userId)) .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 // Nach Fälligkeit, die nächste oben, fachlich so vorgegeben; ohne
// Fälligkeit danach, die jüngste zuerst. // Fälligkeit danach, die jüngste zuerst.
.orderBy(sql`n.due_date asc nulls last`) .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<OpenNote[]> { export async function loadOpenNotes(tx: Tx, userId: string, heute: string): Promise<OpenNote[]> {
const { notes } = await tx const { notes } = await tx
.selectNoFrom((eb) => [jsonArrayFrom(offeneNotizenAbfrage(eb, userId)).as("notes")]) .selectNoFrom((eb) => [jsonArrayFrom(offeneNotizenAbfrage(eb, userId, heute)).as("notes")])
.executeTakeFirstOrThrow(); .executeTakeFirstOrThrow();
return baueOffeneNotizen(notes as NotizZeile[], userId); return baueOffeneNotizen(notes as NotizZeile[], userId);
} }

View File

@@ -3,6 +3,7 @@ import { AUSTRITTSART_LABELS, AUSTRITTSARTEN, BEENDIGUNGSART_WERTE } from "./bee
import { fmtDate } from "./format"; import { fmtDate } from "./format";
import { GESCHLECHTER } from "./geschlecht"; import { GESCHLECHTER } from "./geschlecht";
import { HAY_GRADE_WERTE } from "./hay-grade"; import { HAY_GRADE_WERTE } from "./hay-grade";
import { C_LEVEL_CODES } from "./c-level";
import { KUENDIGUNGSSCHUTZ_GRUENDE } from "./kuendigungsschutz"; import { KUENDIGUNGSSCHUTZ_GRUENDE } from "./kuendigungsschutz";
import { MITARBEITERARTEN } from "./mitarbeiterart"; import { MITARBEITERARTEN } from "./mitarbeiterart";
import { anzeige } from "./anzeige"; 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: "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: "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: "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: "source", label: "Intern/Extern", alle: "Intern und Extern", optionen: werte("Intern", "Extern") },
{ {
key: "gender", key: "gender",
@@ -101,7 +103,6 @@ export const JANEIN_KRITERIEN: readonly JaNeinKriterium[] = [
{ key: "dienstwagen", label: "Dienstwagen" }, { key: "dienstwagen", label: "Dienstwagen" },
{ key: "betriebsrat", label: "Betriebsrat" }, { key: "betriebsrat", label: "Betriebsrat" },
{ key: "lateral", label: "Laterale Führung" }, { key: "lateral", label: "Laterale Führung" },
{ key: "clevel", label: "C-Level" },
{ key: "kuendigungsschutz", label: "Besonderer Kündigungsschutz" }, { key: "kuendigungsschutz", label: "Besonderer Kündigungsschutz" },
{ key: "behindert", label: "Begünstigt behindert" }, { key: "behindert", label: "Begünstigt behindert" },
// Die Auswertung der Übernahmen von Leiharbeitskräften. Das Ereignis // Die Auswertung der Übernahmen von Leiharbeitskräften. Das Ereignis

View File

@@ -5,6 +5,7 @@ import { ancestorsOf, loadOrgMaps, subtreeOf, type OrgMaps } from "./org";
import { istBereich } from "./org-art"; import { istBereich } from "./org-art";
import { loadKontierungen } from "./cost-centers"; import { loadKontierungen } from "./cost-centers";
import { loadPlacements } from "./placement"; import { loadPlacements } from "./placement";
import { zuweisbareStandorte } from "./standorte";
import type { Austrittsart } from "./types"; import type { Austrittsart } from "./types";
import { LEERE_CRITERIA, passtImSpeicher, type Criteria } from "./report-criteria"; import { LEERE_CRITERIA, passtImSpeicher, type Criteria } from "./report-criteria";
import { werteListe } from "./werteliste"; import { werteListe } from "./werteliste";
@@ -77,6 +78,7 @@ export function applyCriteria<O>(
if (a.mitarbeiterart?.length) q = q.where("mitarbeiterart", "in", a.mitarbeiterart as Mitarbeiterart[]); 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.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.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.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.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[]); if (a.dienstwagenArt?.length) q = q.where("dienstwagen_art", "in", a.dienstwagenArt as DienstwagenArt[]);
@@ -93,7 +95,6 @@ export function applyCriteria<O>(
if (j.dienstwagen) q = q.where("has_dienstwagen", "=", j.dienstwagen === "ja"); if (j.dienstwagen) q = q.where("has_dienstwagen", "=", j.dienstwagen === "ja");
if (j.betriebsrat) q = q.where("is_betriebsrat", "=", j.betriebsrat === "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.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"); if (j.kuendigungsschutz) q = q.where("has_kuendigungsschutz", "=", j.kuendigungsschutz === "ja");
// „In einer Teilzeitvariante" heisst: es steht eine drin, gleich welche. // „In einer Teilzeitvariante" heisst: es steht eine drin, gleich welche.
if (j.teilzeit === "ja") q = q.where("teilzeit_art", "is not", null); 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 }[]; locations: { id: string; name: string }[];
}> { }> {
const orgMaps = await loadOrgMaps(tx); 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 { return {
lookups: lookupsFromOrgMaps(orgMaps, locations), lookups: lookupsFromOrgMaps(orgMaps, alleStandorte),
orgMaps, orgMaps,
// Jede Ebene, nicht nur die Bereiche: wer eine einzelne Abteilung // Jede Ebene, nicht nur die Bereiche: wer eine einzelne Abteilung
// auswerten will, soll sie nicht über einen Umweg zusammensuchen müssen. // 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, depth: orgMaps.depthOf.get(u.id) ?? 0,
unitType: u.unit_type, 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", "is_betriebsrat",
"has_dienstwagen", "has_dienstwagen",
"is_laterale_fuehrung", "is_laterale_fuehrung",
"is_c_level", "c_level",
"teilzeit_art", "teilzeit_art",
"zustaendige_hr_id", "zustaendige_hr_id",
] as const; ] as const;
@@ -310,7 +313,7 @@ export async function loadSnapshotEmployees(tx: Tx, filters: SnapshotFilters): P
is_betriebsrat: e.is_betriebsrat, is_betriebsrat: e.is_betriebsrat,
has_dienstwagen: e.has_dienstwagen, has_dienstwagen: e.has_dienstwagen,
is_laterale_fuehrung: e.is_laterale_fuehrung, is_laterale_fuehrung: e.is_laterale_fuehrung,
is_c_level: e.is_c_level, c_level: e.c_level,
teilzeit_art: e.teilzeit_art, teilzeit_art: e.teilzeit_art,
dependents_count: dependentsCounts.get(e.id) ?? 0, dependents_count: dependentsCounts.get(e.id) ?? 0,
// Ein gelöschtes Konto setzt die Zuordnung auf null (on delete set // Ein gelöschtes Konto setzt die Zuordnung auf null (on delete set

View File

@@ -2,6 +2,7 @@ import { ABSENCE_TYPES, statusLabel } from "./absence";
import { BEENDIGUNGSART_WERTE } from "./beendigung"; import { BEENDIGUNGSART_WERTE } from "./beendigung";
import { fmtName, todayIso, yearsBetweenIso } from "./format"; import { fmtName, todayIso, yearsBetweenIso } from "./format";
import { HAY_GRADE_WERTE, OHNE_HAY_GRADE } from "./hay-grade"; 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 { anzeige } from "./anzeige";
import { WOCHENTAGE } from "./wochentage"; import { WOCHENTAGE } from "./wochentage";
import { werteListe } from "./werteliste"; import { werteListe } from "./werteliste";
@@ -138,7 +139,7 @@ export type ReportEmployee = {
is_betriebsrat: boolean; is_betriebsrat: boolean;
has_dienstwagen: boolean; has_dienstwagen: boolean;
is_laterale_fuehrung: boolean; is_laterale_fuehrung: boolean;
is_c_level: boolean; c_level: string | null;
teilzeit_art: string | null; teilzeit_art: string | null;
/** /**
* Die Kostenstelle der Planstelle zum Stichtag, als „Nummer · Bezeichnung"; * 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": case "laterale_fuehrung":
return e.is_laterale_fuehrung ? "Ja" : "Nein"; return e.is_laterale_fuehrung ? "Ja" : "Nein";
case "c_level": 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": case "has_dependents":
return e.dependents_count > 0 ? "Ja" : "Nein"; return e.dependents_count > 0 ? "Ja" : "Nein";
case "teilzeit_art": case "teilzeit_art":
@@ -302,6 +304,7 @@ export function groupKeyFor(e: ReportEmployee, dim: GroupDimension, lookups: Org
const EIGENE_REIHENFOLGE: Partial<Record<GroupDimension, readonly string[]>> = { const EIGENE_REIHENFOLGE: Partial<Record<GroupDimension, readonly string[]>> = {
weekday: WOCHENTAGE, weekday: WOCHENTAGE,
paygrade: [OHNE_HAY_GRADE, ...HAY_GRADE_WERTE], paygrade: [OHNE_HAY_GRADE, ...HAY_GRADE_WERTE],
c_level: [...C_LEVEL_CODES, OHNE_C_LEVEL],
}; };
function rang(dim: GroupDimension, key: string): number { function rang(dim: GroupDimension, key: string): number {

View File

@@ -67,7 +67,7 @@ export async function loadShellData(tx: Tx, userId: string): Promise<ShellErgebn
).as("profile"), ).as("profile"),
...orgMapsAbfragen(eb), ...orgMapsAbfragen(eb),
jsonArrayFrom(offeneStellenAbfrage(eb, asOf)).as("open"), jsonArrayFrom(offeneStellenAbfrage(eb, asOf)).as("open"),
jsonArrayFrom(offeneNotizenAbfrage(eb, userId)).as("notes"), jsonArrayFrom(offeneNotizenAbfrage(eb, userId, asOf)).as("notes"),
// Alle freigeschalteten HR-Personen ausser der eigenen, dazu die // Alle freigeschalteten HR-Personen ausser der eigenen, dazu die
// eigene Auswahl. Beides in derselben Rundreise wie der Rest der // eigene Auswahl. Beides in derselben Rundreise wie der Rest der
// Hülle — die Einstellung steckt in der Glocke, also muss sie beim // Hülle — die Einstellung steckt in der Glocke, also muss sie beim

34
lib/standorte.ts Normal file
View File

@@ -0,0 +1,34 @@
// Standorte mit Unterstandorten (Migration 20261123140000): „Shop" fasst die
// einzelnen Shops zusammen. Eine Person sitzt nur auf einem Standort ohne
// Unterstandorte; die Auswahl zeigt zuerst die oberste Ebene und bei einem
// zusammenfassenden Standort eine zweite Liste.
export type StandortEintrag = { id: string; name: string; parent_id?: string | null };
/** Standorte der obersten Ebene, wie die erste Auswahl sie zeigt. */
export function oberstandorte<T extends StandortEintrag>(alle: readonly T[]): T[] {
return alle.filter((s) => !s.parent_id);
}
/** Die Unterstandorte eines Standorts, leer bei einem gewöhnlichen. */
export function unterstandorte<T extends StandortEintrag>(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<T extends StandortEintrag>(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;
}

14
lib/testsystem.ts Normal file
View File

@@ -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";
}

View File

@@ -197,9 +197,9 @@ export type Database = {
public: { public: {
Tables: { Tables: {
locations: { locations: {
Row: { id: string; name: string; country: string }; Row: { id: string; name: string; country: string; parent_id: string | null };
Insert: { id?: string; name: string; country: string }; Insert: { id?: string; name: string; country: string; parent_id?: string | null };
Update: Partial<{ id: string; name: string; country: string }>; Update: Partial<{ id: string; name: string; country: string; parent_id: string | null }>;
}; };
profiles: { profiles: {
Row: { Row: {
@@ -359,6 +359,8 @@ export type Database = {
emergency_contact_relation: string | null; emergency_contact_relation: string | null;
is_laterale_fuehrung: boolean; is_laterale_fuehrung: boolean;
is_c_level: 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_prefix: string[];
title_suffix: string[]; title_suffix: string[];
created_at: string; created_at: string;
@@ -433,6 +435,7 @@ export type Database = {
emergency_contact_relation?: string | null; emergency_contact_relation?: string | null;
is_laterale_fuehrung?: boolean; is_laterale_fuehrung?: boolean;
is_c_level?: boolean; is_c_level?: boolean;
c_level?: string | null;
title_prefix?: string[]; title_prefix?: string[];
title_suffix?: string[]; title_suffix?: string[];
created_at?: string; created_at?: string;

41
lib/verhaeltnis.ts Normal file
View File

@@ -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 };
}

View File

@@ -103,7 +103,7 @@ export function vorbelegungAus(employee: EmployeeRow): Partial<HireDraftData> {
// „Verbrenner" ist dabei die Vorgabe, nicht eine Behauptung. // „Verbrenner" ist dabei die Vorgabe, nicht eine Behauptung.
dienstwagenArt: employee.dienstwagen_art ?? "Verbrenner", dienstwagenArt: employee.dienstwagen_art ?? "Verbrenner",
isLateraleFuehrung: employee.is_laterale_fuehrung, isLateraleFuehrung: employee.is_laterale_fuehrung,
isCLevel: employee.is_c_level, cLevel: employee.c_level ?? "",
// Leer: die Notfallkontakte stehen in employee_emergency_contacts und // Leer: die Notfallkontakte stehen in employee_emergency_contacts und
// bleiben beim Wiedereintritt erhalten. Das Feld im Assistenten nimmt nur // bleiben beim Wiedereintritt erhalten. Das Feld im Assistenten nimmt nur
// einen weiteren auf. Vorbelegt aus den Spalten an der Person käme ein // einen weiteren auf. Vorbelegt aus den Spalten an der Person käme ein

View File

@@ -13,6 +13,15 @@ export function stundenWert(text: string): string {
return text.trim().replace(",", "."); 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 * Fehlertext oder null. Ohne Beschäftigungsausmaß wird nur der Rahmen
* geprüft (mehr als 0, höchstens 38,5). * 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 wert = stundenWert(text);
const stunden = Number(wert); const stunden = Number(wert);
const zahl = wert !== "" && Number.isFinite(stunden); const zahl = wert !== "" && Number.isFinite(stunden);
const nachkomma = nachkommaFehler(text);
if (nachkomma) return nachkomma;
if (ausmass === "Teilzeit" && (!zahl || stunden <= 0 || stunden >= VOLLZEIT_STUNDEN)) { if (ausmass === "Teilzeit" && (!zahl || stunden <= 0 || stunden >= VOLLZEIT_STUNDEN)) {
return "Wochenstunden bei Teilzeit müssen zwischen 0 und 38,5 liegen."; return "Wochenstunden bei Teilzeit müssen zwischen 0 und 38,5 liegen.";
} }

244
package-lock.json generated
View File

@@ -1,19 +1,19 @@
{ {
"name": "alpenwerk-hr", "name": "alpenwerk-hr",
"version": "0.2.1", "version": "0.2.2",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "alpenwerk-hr", "name": "alpenwerk-hr",
"version": "0.2.1", "version": "0.2.2",
"dependencies": { "dependencies": {
"@dagrejs/dagre": "^3.0.0", "@dagrejs/dagre": "^3.0.0",
"@xyflow/react": "^12.11.2", "@xyflow/react": "^12.11.2",
"exceljs": "^4.4.0", "exceljs": "^4.4.0",
"kysely": "^0.29.4", "kysely": "^0.29.4",
"lucide-react": "^1.26.0", "lucide-react": "^1.26.0",
"next": "^16.4.3", "next": "^16.4.6",
"next-auth": "^5.0.0-beta.32", "next-auth": "^5.0.0-beta.32",
"pg": "^8.22.0", "pg": "^8.22.0",
"react": "^19.2.8", "react": "^19.2.8",
@@ -31,7 +31,7 @@
"@types/react-dom": "^19.2.3", "@types/react-dom": "^19.2.3",
"@vitest/coverage-v8": "^4.1.12", "@vitest/coverage-v8": "^4.1.12",
"eslint": "^9.39.5", "eslint": "^9.39.5",
"eslint-config-next": "^16.4.3", "eslint-config-next": "^16.4.6",
"jsdom": "^29.1.1", "jsdom": "^29.1.1",
"postcss": "^8.5.19", "postcss": "^8.5.19",
"tailwindcss": "^4.3.3", "tailwindcss": "^4.3.3",
@@ -1059,9 +1059,6 @@
"cpu": [ "cpu": [
"arm" "arm"
], ],
"libc": [
"glibc"
],
"license": "LGPL-3.0-or-later", "license": "LGPL-3.0-or-later",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1078,9 +1075,6 @@
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
"libc": [
"glibc"
],
"license": "LGPL-3.0-or-later", "license": "LGPL-3.0-or-later",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1097,9 +1091,6 @@
"cpu": [ "cpu": [
"ppc64" "ppc64"
], ],
"libc": [
"glibc"
],
"license": "LGPL-3.0-or-later", "license": "LGPL-3.0-or-later",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1116,9 +1107,6 @@
"cpu": [ "cpu": [
"riscv64" "riscv64"
], ],
"libc": [
"glibc"
],
"license": "LGPL-3.0-or-later", "license": "LGPL-3.0-or-later",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1135,9 +1123,6 @@
"cpu": [ "cpu": [
"s390x" "s390x"
], ],
"libc": [
"glibc"
],
"license": "LGPL-3.0-or-later", "license": "LGPL-3.0-or-later",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1154,9 +1139,6 @@
"cpu": [ "cpu": [
"x64" "x64"
], ],
"libc": [
"glibc"
],
"license": "LGPL-3.0-or-later", "license": "LGPL-3.0-or-later",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1173,9 +1155,6 @@
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
"libc": [
"musl"
],
"license": "LGPL-3.0-or-later", "license": "LGPL-3.0-or-later",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1192,9 +1171,6 @@
"cpu": [ "cpu": [
"x64" "x64"
], ],
"libc": [
"musl"
],
"license": "LGPL-3.0-or-later", "license": "LGPL-3.0-or-later",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1211,9 +1187,6 @@
"cpu": [ "cpu": [
"arm" "arm"
], ],
"libc": [
"glibc"
],
"license": "Apache-2.0", "license": "Apache-2.0",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1236,9 +1209,6 @@
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
"libc": [
"glibc"
],
"license": "Apache-2.0", "license": "Apache-2.0",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1261,9 +1231,6 @@
"cpu": [ "cpu": [
"ppc64" "ppc64"
], ],
"libc": [
"glibc"
],
"license": "Apache-2.0", "license": "Apache-2.0",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1286,9 +1253,6 @@
"cpu": [ "cpu": [
"riscv64" "riscv64"
], ],
"libc": [
"glibc"
],
"license": "Apache-2.0", "license": "Apache-2.0",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1311,9 +1275,6 @@
"cpu": [ "cpu": [
"s390x" "s390x"
], ],
"libc": [
"glibc"
],
"license": "Apache-2.0", "license": "Apache-2.0",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1336,9 +1297,6 @@
"cpu": [ "cpu": [
"x64" "x64"
], ],
"libc": [
"glibc"
],
"license": "Apache-2.0", "license": "Apache-2.0",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1361,9 +1319,6 @@
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
"libc": [
"musl"
],
"license": "Apache-2.0", "license": "Apache-2.0",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1386,9 +1341,6 @@
"cpu": [ "cpu": [
"x64" "x64"
], ],
"libc": [
"musl"
],
"license": "Apache-2.0", "license": "Apache-2.0",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1573,15 +1525,15 @@
} }
}, },
"node_modules/@next/env": { "node_modules/@next/env": {
"version": "16.4.3", "version": "16.4.6",
"resolved": "https://registry.npmjs.org/@next/env/-/env-16.4.3.tgz", "resolved": "https://registry.npmjs.org/@next/env/-/env-16.4.6.tgz",
"integrity": "sha512-a7tz1QCcWWkwC/rPJcPMJk/UNRu9CFhDd3OHYE5hddbJrs8BqRTalxI6GlKCWEGzRLHN+S/B7a4PAHCtm25aBQ==", "integrity": "sha512-SunBjJ6t+oBtecS3dTjdVuMhUogP5wD/vrGL5EVuQYM1iS4O5ilL51HkiJ3sPjMzRHiCChvr4dbaSJbR7F3lxA==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/@next/eslint-plugin-next": { "node_modules/@next/eslint-plugin-next": {
"version": "16.4.3", "version": "16.4.6",
"resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-16.4.3.tgz", "resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-16.4.6.tgz",
"integrity": "sha512-oxuC06wt/71h6ACYCV9GbKOfnf5a7VlRe/p80YHTut15TNgDEmynDnaq8t/xhy5rlvk7dhItIPs6H3rvIM4kyw==", "integrity": "sha512-HdqERVOafOD8JaUSAkwf9aSu/1rsHlkN8C5GcXYBH3C/z1MxBhZFxB5rz/xqMMRiIj7r9tIv8OCLQ9JWUxCvWA==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
@@ -1590,9 +1542,9 @@
} }
}, },
"node_modules/@next/swc-darwin-arm64": { "node_modules/@next/swc-darwin-arm64": {
"version": "16.4.3", "version": "16.4.6",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-16.4.3.tgz", "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-16.4.6.tgz",
"integrity": "sha512-4yq5EXBt+VDtAZwTyfijaFp5D2C5oz3Ikw5a2kiX2K9nw72vrZX2q5UuAlkPtUMO1tQz6JTKpaKWjS7OOefTDQ==", "integrity": "sha512-kJ4VVZkley17xKaJx72QN2IBqjrj7zenCQZaUF0l9ShS/1Mt2kW4+Z5KGG6vgr3L/J562xTOizVyM1iA/u5nlg==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -1606,9 +1558,9 @@
} }
}, },
"node_modules/@next/swc-darwin-x64": { "node_modules/@next/swc-darwin-x64": {
"version": "16.4.3", "version": "16.4.6",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-16.4.3.tgz", "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-16.4.6.tgz",
"integrity": "sha512-1Rvkn/LUhnEF8WxnRkOrqGhbwXui1bkWFxONKIbN+r7C+9KHDSZ+iUoj4CzymVMWUyZIyx9szcb9+kbKhD500A==", "integrity": "sha512-eIPGZIqC+8JKaeZmvnCANJQF4xWkkHqSnAAajtFxgwDMAOnCgxNvP52SeWZ41PyVwoe+Le/NQuZSaQ8j7YshSA==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -1622,15 +1574,12 @@
} }
}, },
"node_modules/@next/swc-linux-arm64-gnu": { "node_modules/@next/swc-linux-arm64-gnu": {
"version": "16.4.3", "version": "16.4.6",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-16.4.3.tgz", "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-16.4.6.tgz",
"integrity": "sha512-dCKpXErGg3abUM6t5JTJV/ottVBTStJB5lRJTbgdUdQaQ+jNHiK56Hsc0YAEg/rinSh42hYG3HWiYmEMdilnxg==", "integrity": "sha512-9nI6O8vvczH2D9ZNdMGqb/3NuT15T9ksOZnAmx9/gjF2cOi74+xxyf1Hk96uIMfm14c9y6wHeBq6SH8g6udvcA==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
"libc": [
"glibc"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1641,15 +1590,12 @@
} }
}, },
"node_modules/@next/swc-linux-arm64-musl": { "node_modules/@next/swc-linux-arm64-musl": {
"version": "16.4.3", "version": "16.4.6",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-16.4.3.tgz", "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-16.4.6.tgz",
"integrity": "sha512-WwYbhWkhYBvBtib1K4W0kL8MW2snBD2A5b3SN4vPpqalZbZs5+bQ1yzAdepVoOqrFfEW3dmREy4Zs1MrWcrFbw==", "integrity": "sha512-7/qPhTxDp2ScluOJOhLuhWmlA17o1yZ0SIgpISBCpBxXgtnK4+KGywBpFkfLPiU1rnSM1faFGzYkH6i7JdTrqA==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
"libc": [
"musl"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1660,15 +1606,12 @@
} }
}, },
"node_modules/@next/swc-linux-x64-gnu": { "node_modules/@next/swc-linux-x64-gnu": {
"version": "16.4.3", "version": "16.4.6",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-16.4.3.tgz", "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-16.4.6.tgz",
"integrity": "sha512-QymWvfUwDEC5/lpJOsxX5VAbyoR2D13+2Jsjz4be7gT4LPqEgdpkeLIR/HFfCLgKzoMhpJbp6I/JnogyNZHcaA==", "integrity": "sha512-oOpbNa8XOW1qCGd9VvzC4fbkkRxEls7/WI6tz+YHC0xRA7KpV1U7DrAnCPjzVyOk/karzWEepCOcTIDmwK8FwQ==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
"libc": [
"glibc"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1679,15 +1622,12 @@
} }
}, },
"node_modules/@next/swc-linux-x64-musl": { "node_modules/@next/swc-linux-x64-musl": {
"version": "16.4.3", "version": "16.4.6",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-16.4.3.tgz", "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-16.4.6.tgz",
"integrity": "sha512-Vmjd9D7DpA4Vv3cUlr82QWgJD/BQZmns801vtC5VWHg6jCIA4a5vMKpQnfrM2pyCrp2eV0ENdUg4PlN3bAc2Yw==", "integrity": "sha512-aM8CZ+OR2EwXaAYw7KGkW2GDmNDsLBIRe1MMRZCJPTdw/xhTD0IMUVO4sf3KqrzuRouGzwwLZn34+gFeVXiUQA==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
"libc": [
"musl"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1698,9 +1638,9 @@
} }
}, },
"node_modules/@next/swc-win32-arm64-msvc": { "node_modules/@next/swc-win32-arm64-msvc": {
"version": "16.4.3", "version": "16.4.6",
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-16.4.3.tgz", "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-16.4.6.tgz",
"integrity": "sha512-lG1pPdPLk7gTyGb00n5JIMLdBJgjb+UEhSdZvFbhUMg0DyC6z4B7RnpSKF9VCd4imkLObVbXOFA0kFCpw7yFow==", "integrity": "sha512-U0p7/tEtqvHX2crhd841CDwKtp5CFkKXVjOhmfccR3Pvp64sj8KBwRqsvltqLOwVBbj0NtkxwXSDpEHYGbxeXQ==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -1714,9 +1654,9 @@
} }
}, },
"node_modules/@next/swc-win32-x64-msvc": { "node_modules/@next/swc-win32-x64-msvc": {
"version": "16.4.3", "version": "16.4.6",
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-16.4.3.tgz", "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-16.4.6.tgz",
"integrity": "sha512-NmQC9RkJdnPXRaMxtkCzobB3teVjqF33oSOnwDfi+XYGWWYpt+xlGK3mtktSKLbdjwaWbJu2OkkMiRFGUUncKg==", "integrity": "sha512-3ZG15/5WIdlTQsIEvc9sPTTSL5XFrlLklIKmfF4fwsDnoAhu6NcBDXsk3mbGxNyo6aVLEGex+fHCv2MahY7a9g==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -1906,9 +1846,6 @@
"arm64" "arm64"
], ],
"dev": true, "dev": true,
"libc": [
"glibc"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1926,9 +1863,6 @@
"arm64" "arm64"
], ],
"dev": true, "dev": true,
"libc": [
"musl"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1946,9 +1880,6 @@
"ppc64" "ppc64"
], ],
"dev": true, "dev": true,
"libc": [
"glibc"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1966,9 +1897,6 @@
"s390x" "s390x"
], ],
"dev": true, "dev": true,
"libc": [
"glibc"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1986,9 +1914,6 @@
"x64" "x64"
], ],
"dev": true, "dev": true,
"libc": [
"glibc"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -2006,9 +1931,6 @@
"x64" "x64"
], ],
"dev": true, "dev": true,
"libc": [
"musl"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -2232,9 +2154,6 @@
"arm64" "arm64"
], ],
"dev": true, "dev": true,
"libc": [
"glibc"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -2252,9 +2171,6 @@
"arm64" "arm64"
], ],
"dev": true, "dev": true,
"libc": [
"musl"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -2272,9 +2188,6 @@
"x64" "x64"
], ],
"dev": true, "dev": true,
"libc": [
"glibc"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -2292,9 +2205,6 @@
"x64" "x64"
], ],
"dev": true, "dev": true,
"libc": [
"musl"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -2984,9 +2894,6 @@
"arm64" "arm64"
], ],
"dev": true, "dev": true,
"libc": [
"glibc"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -3001,9 +2908,6 @@
"arm64" "arm64"
], ],
"dev": true, "dev": true,
"libc": [
"musl"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -3018,9 +2922,6 @@
"loong64" "loong64"
], ],
"dev": true, "dev": true,
"libc": [
"glibc"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -3035,9 +2936,6 @@
"loong64" "loong64"
], ],
"dev": true, "dev": true,
"libc": [
"musl"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -3052,9 +2950,6 @@
"ppc64" "ppc64"
], ],
"dev": true, "dev": true,
"libc": [
"glibc"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -3069,9 +2964,6 @@
"riscv64" "riscv64"
], ],
"dev": true, "dev": true,
"libc": [
"glibc"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -3086,9 +2978,6 @@
"riscv64" "riscv64"
], ],
"dev": true, "dev": true,
"libc": [
"musl"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -3103,9 +2992,6 @@
"s390x" "s390x"
], ],
"dev": true, "dev": true,
"libc": [
"glibc"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -3120,9 +3006,6 @@
"x64" "x64"
], ],
"dev": true, "dev": true,
"libc": [
"glibc"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -3137,9 +3020,6 @@
"x64" "x64"
], ],
"dev": true, "dev": true,
"libc": [
"musl"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -4975,13 +4855,13 @@
} }
}, },
"node_modules/eslint-config-next": { "node_modules/eslint-config-next": {
"version": "16.4.3", "version": "16.4.6",
"resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-16.4.3.tgz", "resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-16.4.6.tgz",
"integrity": "sha512-j9IqBma6abp800frdUURaizYMgXOK+jNGyq6CsYcM9AxpSJs5D/TgMNGeAmRUilZvA7g9V1Tr71gNg9/SVTuMQ==", "integrity": "sha512-IBGGrVf9E6pL0NGL0hmeicVGeSyv1VEzIWq6IecDqkw+YFByhEtDJS9u1r6s6a1VxK6rssh69KyNFQUgfaacqw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "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-node": "^0.3.6",
"eslint-import-resolver-typescript": "^3.5.2", "eslint-import-resolver-typescript": "^3.5.2",
"eslint-plugin-import": "^2.32.0", "eslint-plugin-import": "^2.32.0",
@@ -7099,9 +6979,6 @@
"arm64" "arm64"
], ],
"dev": true, "dev": true,
"libc": [
"glibc"
],
"license": "MPL-2.0", "license": "MPL-2.0",
"optional": true, "optional": true,
"os": [ "os": [
@@ -7123,9 +7000,6 @@
"arm64" "arm64"
], ],
"dev": true, "dev": true,
"libc": [
"musl"
],
"license": "MPL-2.0", "license": "MPL-2.0",
"optional": true, "optional": true,
"os": [ "os": [
@@ -7147,9 +7021,6 @@
"x64" "x64"
], ],
"dev": true, "dev": true,
"libc": [
"glibc"
],
"license": "MPL-2.0", "license": "MPL-2.0",
"optional": true, "optional": true,
"os": [ "os": [
@@ -7171,9 +7042,6 @@
"x64" "x64"
], ],
"dev": true, "dev": true,
"libc": [
"musl"
],
"license": "MPL-2.0", "license": "MPL-2.0",
"optional": true, "optional": true,
"os": [ "os": [
@@ -7569,12 +7437,12 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/next": { "node_modules/next": {
"version": "16.4.3", "version": "16.4.6",
"resolved": "https://registry.npmjs.org/next/-/next-16.4.3.tgz", "resolved": "https://registry.npmjs.org/next/-/next-16.4.6.tgz",
"integrity": "sha512-OqxKTGi9u80FydydsMNYNjnuje9Au+kvHlt2GZ//ftdpDHm1dxKqAaENoOOTX5wKzn+9vaKUNIfZeyZUuLhCnA==", "integrity": "sha512-QZJiYhaZLJMo2KpkQGQIwvmd79WVsAWeYIU554a8d7zArS3si/IRy3lBNV/rtYhE70oLwdLYhPAXLPx8HwcwtA==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@next/env": "16.4.3", "@next/env": "16.4.6",
"@swc/helpers": "0.5.23", "@swc/helpers": "0.5.23",
"baseline-browser-mapping": "^2.9.19", "baseline-browser-mapping": "^2.9.19",
"caniuse-lite": "^1.0.30001579", "caniuse-lite": "^1.0.30001579",
@@ -7588,14 +7456,14 @@
"node": ">=20.9.0" "node": ">=20.9.0"
}, },
"optionalDependencies": { "optionalDependencies": {
"@next/swc-darwin-arm64": "16.4.3", "@next/swc-darwin-arm64": "16.4.6",
"@next/swc-darwin-x64": "16.4.3", "@next/swc-darwin-x64": "16.4.6",
"@next/swc-linux-arm64-gnu": "16.4.3", "@next/swc-linux-arm64-gnu": "16.4.6",
"@next/swc-linux-arm64-musl": "16.4.3", "@next/swc-linux-arm64-musl": "16.4.6",
"@next/swc-linux-x64-gnu": "16.4.3", "@next/swc-linux-x64-gnu": "16.4.6",
"@next/swc-linux-x64-musl": "16.4.3", "@next/swc-linux-x64-musl": "16.4.6",
"@next/swc-win32-arm64-msvc": "16.4.3", "@next/swc-win32-arm64-msvc": "16.4.6",
"@next/swc-win32-x64-msvc": "16.4.3", "@next/swc-win32-x64-msvc": "16.4.6",
"sharp": "^0.35.5" "sharp": "^0.35.5"
}, },
"peerDependencies": { "peerDependencies": {
@@ -9939,9 +9807,6 @@
"arm64" "arm64"
], ],
"dev": true, "dev": true,
"libc": [
"glibc"
],
"license": "MPL-2.0", "license": "MPL-2.0",
"optional": true, "optional": true,
"os": [ "os": [
@@ -9963,9 +9828,6 @@
"arm64" "arm64"
], ],
"dev": true, "dev": true,
"libc": [
"musl"
],
"license": "MPL-2.0", "license": "MPL-2.0",
"optional": true, "optional": true,
"os": [ "os": [
@@ -9987,9 +9849,6 @@
"x64" "x64"
], ],
"dev": true, "dev": true,
"libc": [
"glibc"
],
"license": "MPL-2.0", "license": "MPL-2.0",
"optional": true, "optional": true,
"os": [ "os": [
@@ -10011,9 +9870,6 @@
"x64" "x64"
], ],
"dev": true, "dev": true,
"libc": [
"musl"
],
"license": "MPL-2.0", "license": "MPL-2.0",
"optional": true, "optional": true,
"os": [ "os": [

View File

@@ -1,6 +1,6 @@
{ {
"name": "alpenwerk-hr", "name": "alpenwerk-hr",
"version": "0.2.1", "version": "0.2.2",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",
@@ -25,7 +25,7 @@
"exceljs": "^4.4.0", "exceljs": "^4.4.0",
"kysely": "^0.29.4", "kysely": "^0.29.4",
"lucide-react": "^1.26.0", "lucide-react": "^1.26.0",
"next": "^16.4.3", "next": "^16.4.6",
"next-auth": "^5.0.0-beta.32", "next-auth": "^5.0.0-beta.32",
"pg": "^8.22.0", "pg": "^8.22.0",
"react": "^19.2.8", "react": "^19.2.8",
@@ -43,7 +43,7 @@
"@types/react-dom": "^19.2.3", "@types/react-dom": "^19.2.3",
"@vitest/coverage-v8": "^4.1.12", "@vitest/coverage-v8": "^4.1.12",
"eslint": "^9.39.5", "eslint": "^9.39.5",
"eslint-config-next": "^16.4.3", "eslint-config-next": "^16.4.6",
"jsdom": "^29.1.1", "jsdom": "^29.1.1",
"postcss": "^8.5.19", "postcss": "^8.5.19",
"tailwindcss": "^4.3.3", "tailwindcss": "^4.3.3",

View File

@@ -35,7 +35,7 @@ vi.mock("@/actions/hireDrafts", () => ({
})); }));
vi.mock("next/navigation", () => ({ useRouter: () => ({ refresh: vi.fn(), push: vi.fn() }) })); 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<string, unknown> } | null = null) { function zeige(resumeDraft: { id: string; step: number; payload: Record<string, unknown> } | null = null) {
const onClose = vi.fn(); const onClose = vi.fn();

View File

@@ -40,7 +40,7 @@ const POSITION = {
kostenstelle: null, kostenstelle: null,
} as unknown as OpenPositionResolved; } 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. */ /** Ein Entwurf, in dem alles bis einschliesslich Vertrag vollständig ist. */
const VOLLSTAENDIG = { const VOLLSTAENDIG = {

View File

@@ -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(
<ToastProvider>
<KarenzPanel open onClose={() => {}} employee={employee} status="Karenz" history={[]} today="2026-11-23" />
</ToastProvider>
);
}
// 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();
});
});

View File

@@ -18,7 +18,7 @@ const WERT: RoleEmploymentValue = {
hasDienstwagen: false, hasDienstwagen: false,
dienstwagenArt: "Verbrenner", dienstwagenArt: "Verbrenner",
isLateraleFuehrung: false, isLateraleFuehrung: false,
isCLevel: false, cLevel: "",
hasKuendigungsschutz: false, hasKuendigungsschutz: false,
kuendigungsschutzBis: "", kuendigungsschutzBis: "",
kuendigungsschutzGrund: "", kuendigungsschutzGrund: "",

View File

@@ -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 (
<>
<StandortAuswahl required value={wert} onChange={setWert} standorte={STANDORTE} />
<output data-testid="stand">{wert}</output>
</>
);
}
describe("StandortAuswahl", () => {
it("zeigt zuerst nur die oberste Ebene", () => {
render(<Formular />);
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(<Formular />);
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(<Formular start="w17" />);
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(<Formular start="w17" />);
fireEvent.change(screen.getByLabelText(/^Standort/), { target: { value: "hernals" } });
expect(screen.getByTestId("stand").textContent).toBe("hernals");
expect(screen.queryByLabelText(/^Shop/)).not.toBeInTheDocument();
});
});

View File

@@ -60,7 +60,7 @@ const MIT_STAATSBUERGERSCHAFT = { ...EXTERN, nationality: "Deutschland" } as Emp
function zeige(employee: EmployeeRow = MIT_STAATSBUERGERSCHAFT) { function zeige(employee: EmployeeRow = MIT_STAATSBUERGERSCHAFT) {
return render( return render(
<ToastProvider> <ToastProvider>
<UebernahmeWizard open onClose={() => {}} employee={employee} locations={[{ id: "l1", name: "Wien", country: "Österreich" }]} /> <UebernahmeWizard open onClose={() => {}} employee={employee} locations={[{ id: "l1", name: "Wien", country: "Österreich", parent_id: null }]} />
</ToastProvider> </ToastProvider>
); );
} }
@@ -102,7 +102,7 @@ describe("Übernahme", () => {
open open
onClose={() => {}} onClose={() => {}}
employee={{ ...EXTERN, birth_date: "2090-01-01" } as EmployeeRow} 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 }]}
/> />
</ToastProvider> </ToastProvider>
); );

View File

@@ -57,6 +57,7 @@ function mitarbeiter(teil: Partial<EmployeeRow> = {}): EmployeeRow {
teilzeit_bis: null, teilzeit_bis: null,
is_laterale_fuehrung: false, is_laterale_fuehrung: false,
is_c_level: false, is_c_level: false,
c_level: null,
title_prefix: [], title_prefix: [],
title_suffix: [], title_suffix: [],
emergency_contact_name: null, emergency_contact_name: null,
@@ -87,7 +88,16 @@ describe("VertragTab — Merkmale", () => {
render(<VertragTab employee={mitarbeiter()} />); render(<VertragTab employee={mitarbeiter()} />);
expect(wertZu("Dienstwagen")).toBe("Nein"); expect(wertZu("Dienstwagen")).toBe("Nein");
expect(wertZu("Betriebsrat")).toBe("Nein"); expect(wertZu("Betriebsrat")).toBe("Nein");
expect(wertZu("C-Level")).toBe("Nein"); });
it("zeigt C-Level als Code", () => {
render(<VertragTab employee={mitarbeiter({ c_level: "C4" })} />);
expect(wertZu("C-Level")).toBe("C4");
});
it("zeigt bei C-Level ohne Angabe einen Strich", () => {
render(<VertragTab employee={mitarbeiter()} />);
expect(wertZu("C-Level")).toBe("–");
}); });
it("nennt beim Dienstwagen die Antriebsart statt eines blossen Ja", () => { it("nennt beim Dienstwagen die Antriebsart statt eines blossen Ja", () => {
@@ -101,9 +111,8 @@ describe("VertragTab — Merkmale", () => {
}); });
it("zeigt gesetzte Merkmale als Ja", () => { it("zeigt gesetzte Merkmale als Ja", () => {
render(<VertragTab employee={mitarbeiter({ is_betriebsrat: true, is_c_level: true })} />); render(<VertragTab employee={mitarbeiter({ is_betriebsrat: true })} />);
expect(wertZu("Betriebsrat")).toBe("Ja"); expect(wertZu("Betriebsrat")).toBe("Ja");
expect(wertZu("C-Level")).toBe("Ja");
expect(wertZu("Laterale Führung")).toBe("Nein"); expect(wertZu("Laterale Führung")).toBe("Nein");
}); });

View File

@@ -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"); 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", () => { it("lässt Zeitstempel und Kennungen stehen", () => {
expect(anzeige("2026-11-03T10:00:00Z")).toBe("2026-11-03T10:00:00Z"); 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"); expect(anzeige("b83ce601-9191-4b67-8979-5ce851b601cf")).toBe("b83ce601-9191-4b67-8979-5ce851b601cf");

View File

@@ -24,13 +24,32 @@ describe("arbeitszeitBefund", () => {
expect(b.fehler).toBeNull(); 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 // 7,7 × 5 ergibt als Gleitkommazahl 38,49999… — die Prüfung „exakt
// gleich" wiese eine völlig richtige Eingabe zurück. // 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); 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(); 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", () => { 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); const b = arbeitszeitBefund({ Mo: "8", Di: "8", Mi: "8", Do: "8", Fr: "6,5" }, WOCHE, 38.5);
expect(b.fehler).toBeNull(); 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 }); 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", () => { it("lässt weggefallene Arbeitstage heraus", () => {
// Sonst bliebe ein Dienstag mit acht Stunden an einer Person stehen, die // Sonst bliebe ein Dienstag mit acht Stunden an einer Person stehen, die
// dienstags nicht mehr arbeitet — und die Bedingung in der Datenbank // dienstags nicht mehr arbeitet — und die Bedingung in der Datenbank

View File

@@ -48,6 +48,7 @@ const NICHT_IM_BLATT_MITARBEITER: Record<string, string> = {
Notfallkontakt: "eigenes Blatt „Notfallkontakte“", Notfallkontakt: "eigenes Blatt „Notfallkontakte“",
"Notfallkontakt Telefon": "eigenes Blatt „Notfallkontakte“", "Notfallkontakt Telefon": "eigenes Blatt „Notfallkontakte“",
"Notfallkontakt Verhältnis": "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", () => { 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", "Nachname", "Vorname", "SV-Nummer", "Adresse", "Postleitzahl", "Ort", "Private E-Mail", "Firmen-E-Mail",
"Private Telefonnummer", "Cornerstone-ID", "Erlernter Beruf", "Angaben zur Übernahme", "Wochenstunden", "Private Telefonnummer", "Cornerstone-ID", "Erlernter Beruf", "Angaben zur Übernahme", "Wochenstunden",
"Arbeitszeitmodell", "Wochenstunden ab Rückkehr", "ID", "Name", "Telefonnummer", "Bezeichnung", "Arbeitszeitmodell", "Wochenstunden ab Rückkehr", "ID", "Name", "Telefonnummer", "Bezeichnung",
"Verhältnis (Sonstige)",
]); ]);
describe("Auswahl in der Datei", () => { 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 }, "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.7)).toEqual({ art: "wert", wert: 7.7 });
expect(ausZelle({ art: "zahl", nachkomma: 1 }, "7,75").art).toBe("fehler"); 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", () => { it("weist Werte ausserhalb der Auswahl ab, ausser bei freier Auswahl", () => {

View File

@@ -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<string, string> = { clevel: "C1|C9|ja" };
expect(parseCriteria((k) => werte[k]).auswahl.clevel).toEqual(["C1", "C9"]);
});
});

View File

@@ -20,7 +20,6 @@ const EXTERN = {
is_betriebsrat: false, is_betriebsrat: false,
has_dienstwagen: false, has_dienstwagen: false,
is_laterale_fuehrung: false, is_laterale_fuehrung: false,
is_c_level: false,
has_kuendigungsschutz: false, has_kuendigungsschutz: false,
ist_beguenstigt_behindert: false, ist_beguenstigt_behindert: false,
has_bonusanspruch: false, has_bonusanspruch: false,

View File

@@ -14,7 +14,7 @@ const units: OrgUnit[] = [
{ id: "cnc", org_number: "22002000", name: "CNC", parent_id: "fert", unit_type: "Team" }, { 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" }, { 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); const maps = buildOrgMaps(units, locations);
describe("buildOrgMaps", () => { describe("buildOrgMaps", () => {

View File

@@ -37,8 +37,8 @@ describe("parseCriteria", () => {
}); });
it("nimmt ja/nein an und sonst nichts", () => { it("nimmt ja/nein an und sonst nichts", () => {
const c = aus({ dienstwagen: "ja", betriebsrat: "vielleicht", clevel: "nein" }); const c = aus({ dienstwagen: "ja", betriebsrat: "vielleicht", lateral: "nein" });
expect(c.jaNein).toEqual({ dienstwagen: "ja", clevel: "nein" }); expect(c.jaNein).toEqual({ dienstwagen: "ja", lateral: "nein" });
}); });
it("prüft Zeiträume auf echte Kalenderdaten", () => { it("prüft Zeiträume auf echte Kalenderdaten", () => {

View File

@@ -40,7 +40,7 @@ function emp(overrides: Partial<ReportEmployee> = {}): ReportEmployee {
is_betriebsrat: false, is_betriebsrat: false,
has_dienstwagen: false, has_dienstwagen: false,
is_laterale_fuehrung: false, is_laterale_fuehrung: false,
is_c_level: false, c_level: null,
teilzeit_art: null, teilzeit_art: null,
dependents_count: 0, dependents_count: 0,
...overrides, ...overrides,
@@ -128,11 +128,15 @@ describe("groupKeyFor", () => {
}); });
it("resolves the Rolle & Anstellung boolean dimensions as Ja/Nein", () => { 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, "betriebsrat", lookups)).toBe("Ja");
expect(groupKeyFor(e, "dienstwagen", lookups)).toBe("Nein"); expect(groupKeyFor(e, "dienstwagen", lookups)).toBe("Nein");
expect(groupKeyFor(e, "laterale_fuehrung", lookups)).toBe("Ja"); 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", () => { it("resolves worker_type/collective_agreement directly", () => {

View File

@@ -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);
});
});

View File

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

View File

@@ -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");
});
});