worker_type had two values because the field was named after them: "Angestellte:r / Arbeiter:in". Lehrlinge are the third social-insurance category in Austria; until now they were filed as one of the other two, which they are not -- and which skewed every report grouped by this column by exactly those people. Adding the value is one line. The label was the work: the field was called after its two values in six places, and each of them becomes wrong with a third. They now read "Beschaeftigtengruppe", the name the import has used all along. One label deliberately keeps the old wording: app_feld_karte() in the database. That string is not a caption there but a key -- stored rows in employee_history and pending_changes carry it, and the map is how reverting or correcting a history entry finds the field again. Renaming it without rewriting those rows would make every older entry for this field unrevertable, and nobody would notice until they tried. The migration's assertion reads pg_enum rather than comparing against 'Lehrling'::worker_type: migrations run inside a transaction, and Postgres refuses to use a freshly added enum value in the transaction that added it. This has not been run against a live database here -- the CI migration job is the first real execution. Three hand-kept lists of the same enum (reports, import, the form) now have a test holding them to one another, each mutation-checked. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
72 lines
3.1 KiB
TypeScript
72 lines
3.1 KiB
TypeScript
import { dienstwagenLabel } from "@/lib/dienstwagen";
|
||
import { fmtDate } from "@/lib/format";
|
||
import type { Database } from "@/lib/types";
|
||
|
||
type EmployeeRow = Database["public"]["Tables"]["employees"]["Row"];
|
||
|
||
const PAYGRADE_LABELS: Record<string, string> = {
|
||
A: "A – Einstieg",
|
||
B: "B – Qualifiziert",
|
||
C: "C – Erfahren",
|
||
D: "D – Spezialist:in",
|
||
E: "E – Teamleitung",
|
||
F: "F – Bereichsleitung / GF",
|
||
};
|
||
|
||
export function VertragTab({ employee }: { employee: EmployeeRow }) {
|
||
// Früher stand hier eine einzige Zeile „Merkmale" mit allem, was zutraf,
|
||
// durch Kommas getrennt — und ein Gedankenstrich, wenn nichts zutraf. Damit
|
||
// liess sich nicht ablesen, ob jemand *keinen* Dienstwagen hat oder ob
|
||
// niemand die Frage je beantwortet hat. Jedes Merkmal steht jetzt für sich,
|
||
// mit Ja oder Nein, wie jede andere Zeile auf diesem Blatt auch.
|
||
const rows: [string, string][] = [
|
||
["Eintrittsdatum", fmtDate(employee.entry_date)],
|
||
["Vertragsart", employee.contract_type === "befristet" ? `befristet bis ${fmtDate(employee.contract_end_date)}` : "unbefristet"],
|
||
["Kollektivvertrag", employee.collective_agreement ?? "–"],
|
||
["Beschäftigungsausmaß", employee.employment_type],
|
||
["Wochenstunden", `${employee.weekly_hours} h`],
|
||
["Urlaubsanspruch", "25 Tage"],
|
||
["Paygrade", PAYGRADE_LABELS[employee.paygrade] ?? employee.paygrade],
|
||
["Beschäftigtengruppe", employee.worker_type ?? "–"],
|
||
["Arbeitstage", employee.work_days?.join(", ") || "–"],
|
||
// Beim Dienstwagen steht die Antriebsart statt eines blossen „Ja" — das
|
||
// war die Frage dahinter, seit E-Fahrzeuge getrennt zu führen sind.
|
||
["Dienstwagen", employee.has_dienstwagen ? dienstwagenLabel(employee.dienstwagen_art) : "Nein"],
|
||
["Betriebsrat", employee.is_betriebsrat ? "Ja" : "Nein"],
|
||
["Laterale Führung", employee.is_laterale_fuehrung ? "Ja" : "Nein"],
|
||
["C-Level", employee.is_c_level ? "Ja" : "Nein"],
|
||
// Das Enddatum steht gleich dabei: „Ja" allein liesse offen, ob der
|
||
// Schutz noch läuft, und genau danach fragt man.
|
||
// Die Teilzeitvariante gehört neben die Stunden: sie erklärt, warum sie
|
||
// sind, wie sie sind.
|
||
[
|
||
"Teilzeitvariante",
|
||
employee.teilzeit_art
|
||
? employee.teilzeit_bis
|
||
? `${employee.teilzeit_art} bis ${fmtDate(employee.teilzeit_bis)}`
|
||
: `${employee.teilzeit_art} (Ende offen)`
|
||
: "–",
|
||
],
|
||
[
|
||
"Besonderer Kündigungsschutz",
|
||
employee.has_kuendigungsschutz
|
||
? employee.kuendigungsschutz_bis
|
||
? `bis ${fmtDate(employee.kuendigungsschutz_bis)}`
|
||
: "Ja (Ende offen)"
|
||
: "Nein",
|
||
],
|
||
];
|
||
if (employee.exit_date) rows.push(["Austrittsdatum", fmtDate(employee.exit_date)]);
|
||
|
||
return (
|
||
<dl className="grid grid-cols-1 gap-x-8 gap-y-4 sm:grid-cols-2 lg:grid-cols-3">
|
||
{rows.map(([label, value]) => (
|
||
<div key={label}>
|
||
<dt className="text-xs font-semibold uppercase tracking-wide text-ink-muted">{label}</dt>
|
||
<dd className="mt-1 text-sm text-ink">{value}</dd>
|
||
</div>
|
||
))}
|
||
</dl>
|
||
);
|
||
}
|