Commit Graph

22 Commits

Author SHA1 Message Date
4d9d838cfd Geplante Abwesenheit mit Art, Anlass im Checklisten-Ausdruck, Geburtsdatum Pflicht
All checks were successful
CI / Lint, Typen, Tests, Build (push) Successful in 12m11s
CI / Migrationen auf leerer Datenbank (push) Successful in 10m30s
CI / Ausrollen (push) Successful in 5s
- Vertrag: Eine noch nicht begonnene Langzeitabwesenheit nennt ihre Art.
  start_karenz traegt bei kuenftigem Beginn nur die Daten an der Person
  ein, die Art steht bis zum Beginn in der Vormerkung; die Zeile liest
  sie von dort.
- Checklisten-Ausdruck: Anlass und Anlagedatum im Kopf, wie in der Akte.
- Neueinstellung und Wiedereintritt: Geburtsdatum ist wieder Pflicht.
  Die Spalte bleibt NULL-faehig.

Geprueft: lint, tsc, types:check, 944 Tests, Uebergabe-Waechter
2026-10-28 21:58:26 +01:00
0294c792a4 Planstelle nach Kostenstelle suchen, Berichtskriterien beschriftet, Geburtsdatum freiwillig
Some checks failed
CI / Migrationen auf leerer Datenbank (push) Has been cancelled
CI / Ausrollen (push) Has been cancelled
CI / Lint, Typen, Tests, Build (push) Has been cancelled
- Planstellenauswahl (Versetzen, Befoerdern, Einstellung, Berichtigung):
  Suche auch nach Kostenstellennummer und -bezeichnung; die Kostenstelle
  steht an Treffer und Karte.
- Berichte, weitere Kriterien: statt "Alle" das Thema ("Alle
  Beschaeftigtengruppen", "Alle Geschlechter", "Intern und Extern" ...).
- Einstellung und Wiedereintritt ohne Geburtsdatum moeglich
  (employees.birth_date nicht mehr NOT NULL, leer wird null). Stammdaten
  zeigen "-", das Durchschnittsalter zaehlt nur erfasste Daten.

Rauchtest: Schritt 28.

Geprueft: lint, tsc, types:check, 948 Tests, Uebergabe-Waechter
2026-10-20 16:05:00 +02:00
87001a6f8f PLZ-Pruefung, Ein- und Austritt, Notizen, Planstelle anlegen, Offboarding-Vermerke
All checks were successful
CI / Lint, Typen, Tests, Build (push) Successful in 12m0s
CI / Migrationen auf leerer Datenbank (push) Successful in 10m31s
CI / Ausrollen (push) Successful in 6s
- PLZ gegen Ort (lib/plz.ts) aus dem Verzeichnis der RTR (lib/plz-at.ts,
  erzeugt von scripts/plz-verzeichnis.mjs, 2234 Postleitzahlen mit Postort
  und Bundesland). Gesperrt wird, was sicher falsch ist: unbekannte PLZ
  oder ein Ort, der Postort einer anderen PLZ ist. Ein Ortsteil, der kein
  Postort ist, bekommt einen Hinweis. Bundesland wird angezeigt.
  Neueinstellung, Wiedereintritt, Daten aendern (nur wenn die Adresse
  geaendert wird) und Import.
- Berichte: Ereignistyp "Ein- und Austritt" (Eintritt und Austritt).
- Neueinstellung: Planstelle wird zum Eintrittstag geprueft, sobald Stelle
  und Datum feststehen (besetzt oder vorgemerkt); ein Entwurf mit
  inzwischen vergebener Stelle sagt das.
- Planstelle anlegen: Organisationseinheit mit Lupe, Kostenstelle gleich
  beim Anlegen (in einer Transaktion).
- Mitarbeiterliste: Spalte Austritt zwischen Eintritt und Beschaeftigung.
- Notizen: nach Faelligkeit sortiert; eigene Notiz loeschbar
  (delete_employee_note, Migration 20261019130000, Protokoll behaelt Text).
- Offboarding-Vermerke: Chip retourniert, Garderobenschluessel
  retourniert, Sonstiges (Freitext).

Rauchtest Schritt 14.

Geprueft: lint, tsc, types:check, 917 Tests, Waechter
2026-10-19 15:41:11 +02:00
e1bbcc949f Geschlecht: divers, offen und inter
Some checks failed
CI / Lint, Typen, Tests, Build (push) Has been cancelled
CI / Migrationen auf leerer Datenbank (push) Has been cancelled
CI / Ausrollen (push) Has been cancelled
- Migration 20261015150000: gender_type um d, o, i erweitert (add value,
  aus demselben Grund wie bei worker_type: die Sicht it.mitarbeiter
  liest die Spalte). Die Funktionen wandeln mit ::gender_type um und
  nehmen die Werte ohne Aenderung an.
- lib/geschlecht.ts fuehrt Kuerzel und Bezeichnung. Formulare
  (Einstellung, Daten aendern), Stammdaten, Zusammenfassung,
  Mitarbeiterexport, Berichtsfilter und Import lesen von dort. Die
  Anzeigen der Form gender === "m" ? "maennlich" : "weiblich" sind
  ersetzt; sie haetten jeden weiteren Wert als "weiblich" gezeigt.
- Cornerstone fuehrt d/o/i als "not specified", LOLYO laesst die Anrede
  leer (beides schon bisher das Verhalten fuer unbekannte Werte).

Geprueft: lint, tsc, types:check, 857 Tests (neu: geschlecht.test.ts),
Waechter; Migration in der CI.
2026-10-15 14:30:26 +02:00
d13ff073ed SV-Nummer: hoechstens zehn Ziffern, abweichendes Geburtsdatum nur Hinweis
All checks were successful
CI / Lint, Typen, Tests, Build (push) Successful in 12m31s
CI / Migrationen auf leerer Datenbank (push) Successful in 10m43s
CI / Ausrollen (push) Successful in 8s
Die Nummer wird einmal vergeben und nicht umgeschrieben, wenn das
Geburtsdatum spaeter berichtigt wird. Personen, deren Nummer ein anderes
Datum traegt als der Stammsatz, muessen sich erfassen lassen.

- lib/svnr.ts: svnrHaeltAuf trennt die Eigenschaften der Nummer (Laenge,
  laufende Nummer, Datum, Pruefziffer) von der Uebereinstimmung mit dem
  Stammsatz; svnrErfassbar sperrt "Weiter"/"Speichern" nur noch bei den
  ersten. begrenzeSvnr laesst hoechstens zehn Ziffern zu.
- SvNummerField: die Abweichung steht als Hinweis unter dem Feld, eine
  elfte Ziffer wird verworfen. Bei Einstellung und Wiedereintritt ein
  Haken "Nicht verfuegbar": leert und sperrt das Feld, steht nur im
  Entwurf.
- Angehoerige im Assistenten und im Dialog der Akte: dieselbe Regel,
  dieselbe Begrenzung.
- Migration 20261015100000: fn_validate_employee_svnr prueft nur noch die
  Nummer (is_valid_svnr ohne Geburtsdatum). Ohne sie haette die Datenbank
  abgewiesen, was das Formular zulaesst. Selbstpruefung: kein Vergleich
  mit new.birth_date, Pruefziffer wird weiter geprueft, Trigger vorhanden.

Geprueft: lint, tsc, types:check, 850 Tests (neu: SvNummerField,
svnrHaeltAuf, begrenzeSvnr), Waechter. Die Migration laeuft in der CI auf
leerer Datenbank.
2026-10-15 13:15:51 +02:00
fe2cc8b155 Jahreszahlen in Datumsfeldern haben vier Stellen
Ein <input type="date"> ohne max nimmt Jahreszahlen bis 275760 an. Jedes
Datumsfeld laeuft jetzt ueber DateField:

- min 1900-01-01 und max 2099-12-31 als Vorgabe; mit vierstelligem max
  begrenzt der Browser das Jahressegment schon beim Tippen. Eigene
  Schranken des Aufrufers gehen vor.
- Eine Jahreszahl mit mehr als vier Stellen wird nie gemeldet: das
  Formular behaelt seinen letzten gueltigen Stand, das Feld zeigt
  "Die Jahreszahl hat vier Stellen." Der Tippstand bleibt im Bauteil,
  sonst zeigte das Feld etwas anderes, als das Formular enthaelt.
- 34 Aufrufstellen von TextField type="date" auf DateField umgestellt;
  der Stichtag im Organigramm (ein blankes input) bekommt dieselben
  Schranken.

Geprueft: lint, tsc, types:check, 825 Tests (zwei neue fuer DateField),
Waechter.
2026-10-15 12:36:45 +02:00
muena
86177d648e Uebergabe-Bereinigung: Kommentare, Geheimnisse, CSP, Dokumentation
Kommentare beschreiben den heutigen Stand und warum er so ist, nicht mehr
die Entwicklungsgeschichte: keine Datumsangaben zu Ereignissen, keine
Vorfaelle an Testpersonen, keine Lieferantensicht, keine internen Namen
oder Plattformen. In Migrationen nur Kommentare ausserhalb von
Dollar-Quoting; Kommentare in Funktionskoerpern nur dort, wo ihr Text in
keiner anderen Migration als Anker vorkommt.

- Andreis Anpassungen aus windows-uebergabe nach master uebernommen.
- LOLYO-Startpasswort kommt aus LOLYO_STARTPASSWORT statt aus dem Code;
  ohne Wert lehnt der Export mit Hinweis ab.
- Beispiel- und erzeugte E-Mail-Adressen ohne Kundendomain.
- Content-Security-Policy wird durchgesetzt; form-action fest mit
  login.microsoftonline.com, weil das Paket ohne Umgebungswerte gebaut
  wird. Geprueft im Browser: alle Seiten ohne Verstoss, Weiterleitung zu
  Microsoft geht durch.
- migrate.mjs: einmalige Uebernahme der alten Buchfuehrung entfernt (seit
  20260907100000 ohne Wirkung).
- freischalten.ps1 vergibt und entzieht den HR-Zugang (-Entziehen) und
  protokolliert beides im Audit-Log.
- docs/security-review.md -> docs/sicherheitskonzept.md: beschreibt den
  heutigen Stand ohne offene Punkte. README, entra-sso.md und
  deploy/windows/README.md ohne Widersprueche (Leserolle der IT,
  Freischaltung, Konto des Nachtlaufs), Abnahme-Checkliste statt
  "noch offen".

Geprueft: lint, tsc, types:check, 823 Unit-Tests, Waechter (412 Dateien,
keine Funde), alle 114 Migrationen auf leerem PostgreSQL 18 (zweiter Lauf
leer), rauchtest.sql und vertragsangaben.sql bestanden.
2026-10-14 09:42:51 +02:00
muena
a9216b6a59 Uebergabestand fuer den Kunden wird aus master erzeugt
master bleibt die einzige Quelle. uebergabe/erzeugen.mjs baut den
Branch windows-uebergabe aus master plus Zusatz-Branches, entfernt, was in
uebergabe/ausschluss.txt steht (Docker-Betrieb, Testserver, CI, interne
Unterlagen), streicht Abschnitte zwischen intern:start und intern:end und
legt das Ergebnis als einen Commit auf den Ziel-Branch -- ohne die interne
Historie.

uebergabe/waechter.mjs prueft auf Arbeitsnotizen, interne Namen und
Adressen, Projektjargon, Lieferantensicht, datierte Entwicklungsgeschichte,
echte Kundenadressen und Passwoerter im Code. Laeuft in der CI auf master
und als letzter Schritt beim Erzeugen.
2026-10-14 09:42:51 +02:00
eb2b8843f2 Die fehlenden Felder bei der Neueinstellung, und Betriebsrat vierfach
Some checks failed
CI / Lint, Typen, Tests, Build (push) Successful in 12m9s
CI / Ausrollen (push) Has been cancelled
CI / Migrationen auf leerer Datenbank (push) Has been cancelled
Staatsbuergerschaft, Adresse, Postleitzahl, Ort und Land liessen sich erst
nach dem Anlegen eintragen -- die Testerinnen mussten die frische Akte
sofort wieder oeffnen (gemeldet ueber Lara, 09.10.2026).

Dafuer war keine Migration noetig: hire_employee und rehire_employee
nehmen diese Felder seit jeher entgegen, nur das Formular bot sie nicht
an. Der Assistent folgte der Feldliste aus der Spezifikation, die Funktion
der Tabelle -- und die Liste war kuerzer.

Mit der Staatsbuergerschaft kommt die daran haengende Frage nach dem
Aufenthaltstitel mit. Ohne sie waere dieselbe Luecke eine Stelle weiter:
Staatsbuergerschaft erfassbar, die Pflichtangabe dazu wieder nur in
"Daten aendern".

Befristungsablauf heisst jetzt Zeitablauf. Wirklich umbenannt und nicht
bloss anders beschriftet: exit_reason hat keinen CHECK, und im Bestand
trug keine Zeile den alten Wert -- es gibt nichts, dem das rueckwirkend
eine andere Bedeutung gaebe.

Der Personenkreis "Betriebsraete & Ersatzmitglieder" zerfaellt in vier
(Arbeiter/Angestellte, je mit Ersatzmitglied). Die eine betroffene Zeile
bekommt keinen geratenen Wert, sondern einen leeren Personenkreis und
einen Audit-Eintrag, der sagt was nachzutragen ist.

Nebenbei: tests/unit/kuendigungsschutz.test.ts las einen fest eingetragenen
Migrationspfad und haette nach dieser Aenderung die alte Datei geprueft.
Er sucht jetzt selbst die zuletzt schreibende Migration.
2026-10-13 15:37:20 +02:00
e77eaf7fba Erlernter Beruf und zustaendige HR im Report
All checks were successful
CI / Lint, Typen, Tests, Build (push) Successful in 11m57s
CI / Migrationen auf leerer Datenbank (push) Successful in 10m15s
- Neues freiwilliges Textfeld "Erlernter Beruf": Hiring Wizard (Person,
  Zusammenfassung), Daten aendern, Stammdaten, Wiedereintritt, Export,
  Historie. Gespeichert getrimmt, leer heisst nicht erfasst.
- Reports: Aufteilen nach "Zustaendige HR" mit Gruppe "Nicht zugeordnet"
  und Vorlage "Headcount nach zustaendiger HR".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 11:21:11 +02:00
0e9d2f2296 VL, Bonusanspruch, zustaendige HR und getrennte Suesswaren-Kollektivvertraege
All checks were successful
CI / Lint, Typen, Tests, Build (push) Successful in 12m39s
CI / Migrationen auf leerer Datenbank (push) Successful in 10m41s
Vertrag: VL (1-8, freiwillig) und Bonusanspruch (Vorgabe Nein; bei Ja eine
Bonusregelung: RL ab 01.01.2027, RL bis 31.12.2026, Aussendienst, Shop)
direkt nach dem Hay-Grade -- im Einstellungsassistenten, im Wiedereintritt
und in "Daten aendern", sichtbar im Reiter Vertrag und im Datenexport.

Stammdaten: zustaendige HR. Auswaehlbar sind alle aktiven HR-Konten; die
Datenbank prueft das. Historie und Audit-Log zeigen den Namen.

Kollektivvertraege: Suessware Arbeiter, Suessware Angestellter, Handel.
collective_agreement wird wie der Hay-Grade eine Domain ueber text. Der
Bestand mit "Suesswaren" wird nach der Beschaeftigtengruppe aufgeteilt
(Angestellte -> Angestellter, Arbeiter:innen und Lehrlinge -> Arbeiter),
ebenso geplante Aenderungen und Entwuerfe.

Die Funktionen werden an einzeiligen Ankern der laufenden Definition
ergaenzt (Einstellung, Wiedereintritt, Daten aendern, Nachtlauf,
Feldkarte). app_feld_karte hatte mit 100 Argumenten die Grenze von
jsonb_build_object erreicht; die neuen Felder stehen in einem zweiten
Objekt.

Gegen eine frische Datenbank geprueft: alle Migrationen samt
Selbstpruefung, zweiter Lauf leer, db/tests/rauchtest.sql und der neue
db/tests/vertragsangaben.sql (9 Schritte) bestanden, Umstellung des
Suesswaren-Bestands nachgestellt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 14:56:23 +02:00
c3e19606e2 Die Cornerstone-ID als eigenes, freiwilliges Feld
All checks were successful
CI / Lint, Typen, Tests, Build (push) Successful in 11m58s
CI / Migrationen auf leerer Datenbank (push) Successful in 10m24s
Cornerstone fuehrt jede Person unter einer eigenen Kennung. Der Export
dorthin trug in "User ID" und "Username" bisher die Alpenwerk-UUID --
richtig, solange es nichts Besseres gab, aber nicht die Kennung, unter
der Cornerstone die Person kennt. Jetzt steht dort diese Spalte.

Freiwillig, weil die Zuordnungstabelle des Kunden fuer 434 der 784
Personen keine Kennung liefert. Eindeutig, weil eine Kennung genau einer
Person gehoert. Als Text, weil fuehrende Nullen in einer numerischen
Spalte verlorengingen.

Ohne hinterlegte Kennung bleiben User ID und Username **leer**. Ein
Rueckfall auf die UUID braechte zwei Kennungsarten in eine Datei, ohne
dass es auffiele, und legte in Cornerstone eine zweite Person neben der
bestehenden an. Eine fehlende Angabe soll fehlen; dafuer gibt es einen
eigenen Test.

Fuenf Funktionen mussten mit -- dieselbe Liste und derselbe Grund wie bei
der Firmen-E-Mail: hire_employee und rehire_employee teilen sich den
Schritt "Person", change_employee_data macht das Feld aenderbar,
apply_due_pending_changes sorgt dafuer, dass eine datierte Aenderung
nicht verfaellt, app_feld_karte haelt den Eintrag in der Historie
richtigstellbar. Die Migration ist wieder erzeugt, nicht abgeschrieben,
und prueft jede der fuenf einzeln.

Erfasst wird das Feld in der Akte, in "Daten aendern", bei Einstellung
und Wiedereintritt sowie ueber den Massenimport; es steht im
Mitarbeiterexport und fuellt im Cornerstone-Export User ID und Username.
2026-09-28 10:13:52 +02:00
57acbfae9d Die Firmen-E-Mail als eigenes, freiwilliges Feld
All checks were successful
CI / Lint, Typen, Tests, Build (push) Successful in 11m29s
CI / Migrationen auf leerer Datenbank (push) Successful in 10m27s
employees.email ist die private Adresse (20260811140000). Sie taugt nicht
als Dienstadresse und darf auch nicht als solche benutzt werden: der
Honestly-Export geht an einen fremden Anbieter, der damit im Namen des
Arbeitgebers einlaedt. Die Spalte "Email" stand dort deshalb seit jeher
leer, mit einem Vermerk in lib/honestly.ts, dass die Firmenadresse im
Datenmodell fehlt. Jetzt gibt es sie, und die Spalte fuellt sich.

Eindeutig, aber freiwillig -- mehrere Personen ohne Adresse stoeren den
Index nicht, weil null nie gleich null ist. Geschrieben wird ueber
`case when ? then nullif` statt `coalesce`: eine Dienstadresse muss sich
auch wieder entfernen lassen.

Vier SQL-Funktionen mussten mit, weil `create or replace` die ganze
Fassung ersetzt und ein ausgelassenes Feld dort still verschwindet:
hire_employee und rehire_employee (beide teilen sich den Schritt
"Person" -- das Formular haette das Feld gezeigt und den Wert
weggeworfen), change_employee_data (sonst nicht aenderbar),
apply_due_pending_changes (sonst verfiele eine auf spaeter datierte
Aenderung) und die Feldkarte (sonst waere der Eintrag in der Historie
nicht korrigierbar). Die Selbstpruefung am Ende prueft jede einzeln.
2026-09-23 10:52:26 +02:00
8bb80d3bd2 Der Wiedereintritt oeffnet den Assistenten, vorbefuellt
Aus dem Gespraech vom 17.09.2026. Migration 20260917130000.

Der kleine Dialog fragte Datum und Planstelle und liess alles andere stehen,
wie es beim Austritt war. Nach zwei Jahren Abwesenheit ist das selten noch
richtig — Anschrift, Wochenstunden, Kollektivvertrag, oft auch der Name. Wer
es bemerkte, musste erst wiedereinstellen und danach "Daten aendern"
oeffnen: zwei Vorgaenge fuer einen, und in der Akte stand dann eine
Vertragsaenderung am Tag des Wiedereintritts, die niemand vorgenommen hat.

rehire_employee nimmt jetzt den ganzen Satz entgegen und schreibt ihn in
einer Transaktion. Erst einstellen und dann aendern waeren zwei
Transaktionen, und scheitert die zweite, steht die Person wieder im Dienst —
mit den Daten von damals und ohne dass es jemand merkt.

Jedes Feld mit coalesce: fehlt ein Schluessel, bleibt der bestehende Wert.
Das haelt den schlanken Aufruf am Leben und ist zugleich die Bedingung
dafuer, dass der Assistent nur schickt, was er auch zeigt — Anschrift,
Staatsbuergerschaft und Aufenthaltstitel fragt er naemlich nicht, so wenig
wie bei einer Neueinstellung.

Die Planstelle und das Eintrittsdatum sind bewusst leer: die alte Stelle
kann besetzt oder entfallen sein, und ein vorbelegter Platz, den es so nicht
mehr gibt, waere schlimmer als ein leeres Feld — er sieht nach einer Antwort
aus. Dazu die Pruefungen der Neueinstellung, die hier fehlten: existiert die
Planstelle, gilt sie zum Datum, ist sie frei.

Die Personalnummer steht fest und wird nur gezeigt. Sie zu pruefen faende
zwangslaeufig einen Treffer — die Person selbst — und sperrte das Formular
mit einer Meldung, die stimmt und trotzdem in die Irre fuehrt.

Ein eigenes Bauteil statt eines Schalters im HireWizard: kein Entwurf zu
speichern, keine Angehoerigen anzulegen (die stehen schon in der Akte),
keine Nummer zu pruefen, andere Funktion am Ende. Geteilt werden die
Schritte, und das ist der Teil, der wirklich geteilt gehoert. RehirePanel
ist damit weg.
2026-09-17 12:16:46 +02:00
9ad2954970 Anmerkungen vom 16.09.: Uebersicht gegliedert, Personalnummer prueft frueher
1) Die Kacheln stehen jetzt in drei Gruppen — Personalstand,
Personalbewegung, Recruiting & Vakanzen — in der Reihenfolge aus dem Entwurf
des Kunden. Acht Zahlen nebeneinander sind acht Zahlen; sie beantworten aber
drei verschiedene Fragen, und ohne Ueberschrift muss man jede Beschriftung
einzeln lesen, um das herauszufinden. "Aktives Dienstverhaeltnis" steht
vorn: es ist die Bezugsgroesse fast jeder Personalkennzahl.

2) Der Namensfilter in "Anstehend" ist jetzt immer da. Die Schwelle "erst ab
neun Eintraegen" war in der Bedienung falsch — das Feld erschien bei 180
Tagen und verschwand bei 30, und ein Bedienelement, das je nach Zeitraum da
ist oder nicht, wirkt wie ein Fehler.

3b) Der Filter heisst jetzt "Aktives Dienstverhaeltnis (Aktiv +
Langzeitabwesenheit)" — derselbe Name wie die Kachel, die dorthin verlinkt.

6) Die Personalnummer wird gegen die Datenbank geprueft, waehrend sie
eingetippt wird, und nennt bei einem Treffer die Person, die sie schon hat.
hire_employee weist sie weiterhin ab — das bleibt die verbindliche Pruefung,
denn zwischen Frage und Anlegen kann jemand anderes dieselbe Nummer
vergeben. Nur kam diese Abweisung bisher nach sechs Schritten Eingabe, und
das Feld steht im ersten Schritt.

Gemerkt wird dabei die gepruefte *Nummer* samt Ergebnis, nicht ein Ja/Nein:
so ist die Sperre eine Ableitung aus dem, was im Feld steht, und es gibt
keinen Zustand, dessen Zuruecksetzen man vergessen koennte.

Zu 4) geprueft, nichts geaendert: die FTE-Kachel rechnet bereits Summe der
Wochenstunden der heute Aktiven durch 38,5. Der Berichtemanager rechnet
dieselbe Formel, nur als Summe der Einzelquotienten geschrieben.
2026-09-16 22:23:04 +02:00
c23df08648 Ask for the optional things separately, and stop claiming numbers are issued
A round of interface corrections from use, plus one schema change behind
them.

The private email address is now optional. It was NOT NULL — the wrong
default for a private detail: someone without one had to invent one, and
invented data in a personnel file is worse than missing data. Both fields
are relabelled to say whose they are, "Private E-Mail" and "Private
Telefonnummer", because the company address does not exist until the person
starts. Uniqueness stays; several NULLs coexist in a Postgres unique index,
which is exactly what is wanted.

The summary step still promised that "Personalnummer und
Firmen-E-Mail-Adresse werden automatisch vergeben". Neither is true any
more. Removed rather than reworded — the step lists what was entered, and a
banner claiming otherwise is worse than no banner.

Dependents move into the wizard as step three, optional. They can only be
attached after the hire, because add_employee_dependent needs an id that
does not exist while the form is open, so they are collected in the draft
and written afterwards. That puts them outside the transaction the person is
created in: if one fails the person still exists, so the message names who
is missing instead of failing silently, and the SV number is checked in the
step rather than after.

The emergency contact gets its own step, second to last, and its
relationship is a dropdown of the common ones rather than free text —
otherwise "Gattin", "Ehefrau" and "Frau" end up side by side and nothing can
be counted. "Sonstige" is there because a closed list would otherwise be
presumptuous.

On the master-data tab it now sits below the dependents rather than above:
both are people around the employee, and this is the one you reach for in a
hurry.

Returning from a long absence: the choice read "unverändert", which made you
open the file to find out what you were agreeing to. It now reads "Wie vor
Abwesenheit (38,5 h)" with the hours actually worked, and the alternative is
"Reduziert" — whose hours field starts empty on purpose. A number already
filled in gets confirmed rather than read off the agreement it comes from.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-11 21:47:04 +02:00
9d754359e0 Enter the personnel number, tell the two kinds of company car apart, record who to call
Three requests from use, one of which changes the schema's mind about
something.

The personnel number is no longer issued. It was GENERATED ALWAYS AS
IDENTITY, which refuses a supplied value outright — but it has to match Loga
and Interflex, and a number this application invents is unknown there, so the
same person ends up with two. Identity dropped, entered everywhere instead:
in the wizard, in the import, and validated against a duplicate with a
message that names the number.

Worth stating plainly: the column had no unique constraint. The identity
prevented collisions as a side effect, and once the value comes from outside
that side effect is gone. The constraint is the point now, and it was
missing.

Company cars distinguish Verbrenner from Elektro, tied to has_dienstwagen by
a CHECK so "E-KFZ" cannot appear against someone without a car. The list
filters on it — with, without, only electric, only combustion — which is the
question the report was really about; it was answerable before only through
an export and manual work.

Emergency contact is name, phone and relationship. Relationship stays free
text: the examples given — Gattin/Gatte, Schwester/Bruder, Freund — are not
a list that closes without telling someone their arrangement does not count.
Name and phone are all-or-nothing, in the database and in both forms: a name
without a number helps nobody, a number without a name does not say who
answers.

Two mistakes of mine on the way, both caught by checks I had written into
the migrations rather than by me:

  - The first CHECK on the car type would have permitted exactly the case it
    was written against. `art in (…)` yields NULL rather than false when the
    column is null, and a CHECK counts NULL as satisfied. It needs an
    explicit `is not null` in front.
  - The constraint was added before the backfill, so it rejected every
    existing row with a car.

Existing cars are recorded as Verbrenner, which is an assumption — but a
visible one: "Elektro" appears nowhere nobody confirmed it.

hire_employee and change_employee_data both had to learn the new columns.
They name their columns one by one, and what is missing there is dropped in
silence — the interface would have collected the fields and thrown them
away, which is what happened to the email address this morning.

Verified against the live database, all rolled back: a hire without a number
is refused, a duplicate is refused naming it, a freely chosen one goes
through; E-KFZ plus contact arrive intact; a contact without a phone is
refused. A change records both, with before and after in the audit detail.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-11 21:27:00 +02:00
e44f71a60d Stop offering positions that are already spoken for, and let hiring work again
Two reports, four defects, all of them in the way of ordinary use.

A position with a signed starter is not vacant. loadOpenPositions asked "is
anyone on it today?", so three positions whose new holders begin in
September and October were listed as open, labelled "vacant for 2 days".
That same list feeds the hire wizard, so it invited filling a position a
second time — discovered at the partial unique index, after the second
interview. Vacancy now means no assignment that still stands, including one
that has not started. An assignment that ended still frees the position.

Hiring was broken three times over, each fault hidden behind the previous
one:

  1. hire_employee cast to ::weekday[], a type that no longer exists — it
     was replaced by text plus a CHECK constraint and the function was never
     updated. apply_due_pending_changes had the same problem with
     ::relationship_type, which would have broken the nightly run.
     PL/pgSQL resolves types in embedded statements at execution time, so
     both functions were created without complaint and failed only in use.
  2. Fourteen functions called auth.uid(). The application connects as a
     role with no rights on the auth schema, so every write — hire,
     transfer, promote, exit, notes, positions — failed with "permission
     denied for schema auth". They now use app_current_user_id(), which is
     where #23 was heading anyway. Its own fallback also caught only
     "function missing" and now catches the privilege error too, so a call
     without session context returns null instead of raising.
  3. The audit line built a name as `payload->>'a' || ' ' || payload->>'b'`.
     `||` binds tighter than `->>`, so Postgres reads
     `payload ->> ('a' || ' ' || payload) ->> 'b'`. The ACL failure above
     had aborted analysis before the parser ever reached it.

And the wizard collected an email, showed it in the summary, and dropped it:
the server action's signature had no such field. employees.email is NOT
NULL, so every hire that got past the three faults above would have failed
there. It is now passed through and required in step one, rather than
refused by the database at the end of step four.

Verified against the live database, each rolled back: a hire now creates the
employee, the assignment, the history entry and an audit line reading "Probe
Einstellung"; open positions drop from 13 to 10, and the three that
disappear are exactly the ones with a starter.

Migrations rewrite the affected functions in place rather than restating
them — retyping 165 lines of working PL/pgSQL to change two words is the
larger risk. Each one asserts the result afterwards.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-05 12:10:17 +02:00
d9367a8ce4 Form primitives, keyboard-operable comboboxes, dialog focus, route states
Accessibility work on the UI layer, all of it rooted in one structural gap:
there were no form primitives, so every field was hand-assembled and every
field got the same details wrong.

Form primitives
- components/ui/Field.tsx (Field/TextField/SelectField/TextareaField) and
  Button.tsx. Field generates the control id with useId and derives htmlFor
  from it, which is what makes the association impossible to omit rather
  than merely conventional.
- 92 labels existed, 4 used htmlFor, and no input carried an id at all: a
  screen reader announced an unnamed edit box and clicking a label focused
  nothing. Now every label resolves to its control (0 unassociated), and the
  input class chain that appeared verbatim 85 times appears zero times.
- Field also takes a render prop, so Lookup, CountryPicker and Picklist get
  the same wiring instead of a second, partial solution.
- SearchInput replaces three hand-rolled copies of the icon-in-a-box search
  whose input had only a placeholder — not a label — and killed its own
  focus ring with outline-none and nothing in its place.
- Toggle groups (workdays, reorg change type) became fieldsets with
  aria-pressed; colour alone was carrying the selected state.

Comboboxes
- Lookup and CountryPicker were text inputs with a div of clickable buttons
  underneath: typeable, but no keyboard path to a result and nothing telling
  a screen reader a list had appeared. Both now carry role=combobox,
  aria-expanded/controls/activedescendant and listbox semantics, with arrow
  keys, Enter and Escape. Escape stops propagation, or it would close the
  surrounding dialog along with the dropdown.

Dialogs
- useDialogFocus centralises what Modal and SlideOver each owed the
  keyboard and neither provided beyond Escape: focus into the dialog on
  open, Tab and Shift+Tab cycling within it, focus restored to the trigger
  on close.
- SlideOver stays mounted for its transition, and aria-hidden does not
  remove anything from the tab order — so every closed panel was leaving
  invisible tab stops at the end of the page. `inert` fixes that.

Route states
- loading.tsx, error.tsx, not-found.tsx and global-error.tsx. Every page in
  the (app) group is server-rendered per request, so without loading.tsx a
  navigation showed nothing at all until the server answered, and a render
  error dropped the user on Next's own screen with no way back.

Tests
- 22 component tests (vitest jsdom project). Two of them found limits of the
  environment rather than of the code: jsdom implements neither `inert` nor
  scrollIntoView, so the inert test asserts the attribute and the missing
  scrollIntoView — which was taking the whole render down from inside an
  effect — is stubbed in the setup file.
2026-07-25 13:11:09 +02:00
8d978981b0 SVNR validation, CI, and a dependency/security pass
Positions
- Removed the "Besetzen" action, the StaffInternallyModal behind it and the
  now-unreachable staffPositionInternally server action: a position is filled
  through the hire process, not from the positions list. Note that
  transfer_employee has no position_id at all and never touched `positions`,
  so with staff_position_internally out of the UI, hire_employee is the only
  thing that closes a position — a transfer into an open one leaves it open.
  The RPC itself is still in the database and still covered by its tests.

SVNR
- Austrian social security numbers are now validated: ten digits, weighted
  check digit mod 11, and the TTMMJJ tail cross-checked against birth_date,
  which is what catches a transposed date that a valid check digit would let
  through. A serial whose weighted sum lands on 11 is rejected rather than
  wrapped — those are never issued.
- Applies to Austrian locations only; the German/Czech/Slovenian equivalents
  have their own formats and stay free-form.
- Enforced by a trigger, not inside hire_employee/change_employee_data, for
  the same reason as the assignment history: both have been redefined by
  half a dozen migrations. Only a *newly written* value is checked, so a
  legacy number never blocks an unrelated transfer or address change.
- The seed drew a random four-digit prefix, so its check digit was right
  only by chance and every seeded Austrian row would now be rejected;
  it computes the check digit properly now.

Tech stack
- next 16.2.11 closes nine advisories against 16.2.10, including a
  middleware/proxy bypass in App Router apps on Turbopack — proxy.ts is this
  app's entry gate. RLS remains the real boundary, so the blast radius was a
  blank page rather than data, but it is a patch-level fix. Also react
  19.2.8, tailwind 4.3.3, lucide-react 1.26, supabase-js/ssr, postcss.
- CI runs lint, typecheck, schema/type drift, tests and build; a second job
  replays every migration onto an empty database and runs the integration
  suite against it, so a migration that cannot be replayed from scratch
  fails here instead of during a restore.
- scripts/check-schema-types.mjs diffs the hand-written lib/supabase/types.ts
  against the migrations. Reading the SQL rather than a live database keeps
  Postgres out of the fast CI job. Verified in both directions.
- vitest now runs two projects: node for logic, jsdom for components. The
  first component test covers the org chart expand control, which broke
  earlier this session when elementsSelectable={false} made React Flow
  compute pointer-events:none for the whole node; re-introducing that prop
  fails three of these tests.
- Content-Security-Policy is emitted report-only. Enforcing a policy derived
  from inspection rather than from violation reports risks blanking the app;
  'unsafe-inline' on script-src is required until a nonce is threaded through
  proxy.ts, which is a separate change.
- Fixed supabase/seed.ts, which this session's SVNR change had broken: the
  extensionless "../lib/svnr" import does not resolve under Node's ESM
  loader, so the seed failed at startup.
- engines pinned to node >=22 <25, tsconfig target ES2022, and the dead
  test:e2e script removed (no Playwright is installed).
2026-07-25 11:13:10 +02:00
79f0e19bf8 Org assignment history, mobile support, and a correctness pass
Data model
- employee_assignments records org placement over time (valid_from/valid_to),
  written by a trigger on `employees` rather than inside each RPC: ~70
  `update employees` statements spread over fifteen migrations mean per-call
  bookkeeping would miss paths today and again with every future RPC. A
  partial unique index enforces the one-open-interval invariant the trigger
  relies on when closing the current row.
- The Organigramm gains a Stichtag (default today). Membership comes from
  entry/exit/karenz, past placement from the new history, future placement
  projected from pending_org_changes. Placements predating the migration are
  backfilled with today's values and flagged as such in the UI, since
  employee_history only ever stored free text and cannot be reconstructed.

Correctness
- Reports and exports silently truncated at PostgREST's 1000-row cap
  (db.max_rows); employee_history is already past it at ~800 staff. Every
  whole-table read now pages explicitly.
- XLSX date cells were a day early: ExcelJS converts a Date to an Excel
  serial straight off getTime(), so a Date built at local midnight lands on
  the previous day's serial in any positive-offset zone.
- Date handling is pinned to Europe/Vienna throughout, and date-only strings
  are formatted without a Date round-trip. The dashboard's YTD window was
  built by round-tripping a local Date through toISOString(), which shifted
  it a day early and dropped 31 December entirely.
- Export routes parsed measure/group/split/eventType with unchecked `as`
  casts, so an unknown value reached column headers as `undefined` and the
  Content-Disposition filename. Parsed against the label maps now, with the
  filename slugged as a backstop.
- toXlsx keyed columns by header text, silently dropping the second of any
  two columns sharing a name — split columns take their header from data.
- The org chart tree walks had no cycle guard; nothing in the schema forbids
  a manager_id cycle, and one would hang the tab rather than misreport.
- The login page reflected ?error= verbatim, letting anyone put arbitrary
  text on the real sign-in screen; messages are looked up by code now.
- React Flow needs elementsSelectable on, or it sets pointer-events:none on
  the whole node and the expand control stops responding.

UI
- Mobile: the shell was unusable below lg — a fixed 236px margin pushed
  content off-screen with no mobile navigation at all. The sidebar is now a
  drawer, dvh replaces vh, safe-area insets are honoured, inputs are 16px so
  iOS stops zooming on focus, and form grids stack.
- Org chart nodes redesigned: per-kind accent stripes and icons, vacant
  roles called out, expand control moved to the bottom edge carrying the
  child count.
- Pagination is windowed; it previously rendered one link per page (54 for
  the employee list, unbounded for the audit log).
- Positions page reduced to open positions with a single "Besetzen" action.
- The employee Organisation tab links into the org chart focused on that
  person, reusing the chart's existing search-match highlighting.

Also included, uncommitted until now
- Dependants, HR notes, academic titles, split address fields, position
  validity and role/employment fields, with their migrations and UI.
- Docker/compose deployment setup, data-model and security-review docs.
2026-07-24 23:38:10 +02:00
f91a69147e Phase 3: Hire wizard, draft resume, and two real SQL bugfixes
- components/hire/: 4-step Hire Wizard (Person/Position/Vertrag/
  Zusammenfassung) matching sec4.4, with a HireWizardProvider context so it
  can be opened both from the global "+ Neueinstellung" button and from a
  "Fortsetzen" link on a saved draft.
- actions/hireDrafts.ts: save/delete hire_drafts (owner-scoped RLS already
  in place from Phase 1). Dashboard now shows the "Entwuerfe" card the
  Phase 1 plan deferred, since the wizard it depends on now exists.
- lib/positions.ts: shared open-positions loader (position number, org
  breadcrumb, resolved manager name) used by both the wizard and (later)
  the Positions page.

Two real bugs found via live testing and fixed in supabase/functions.sql:
1. hire_employee/rehire_employee: a two-branch CASE returning bare string
   literals defaults to `text`, not the target enum, so `status = case
   when ... then 'Geplant' else 'Aktiv' end` failed against the
   employment_status column. Fixed with an explicit ::employment_status
   cast on the whole CASE expression.
2. Postgres precedence gotcha: ->> and || sit at the *same* precedence
   tier and left-associate, so `payload->>'first_name' || ' ' ||
   payload->>'last_name'` does not group the way it reads - it tries to
   apply ->> to an intermediate text value and fails with "operator does
   not exist: text ->> unknown". Fixed by parenthesizing every ->>'...'
   expression that participates in a || chain.

Also fixed: hire_employee referenced v_position.title outside the branch
that assigns v_position, raising "record not assigned" whenever a hire
wasn't tied to a position_id; extracted a v_job_title variable instead.

Verified live end-to-end: wizard search -> select position -> submit
creates the employee, closes the position, and writes matching
employee_history + audit_log rows atomically.
2026-07-13 22:37:59 +02:00