Commit Graph

19 Commits

Author SHA1 Message Date
3f6c7e0ca0 Uebernahme Leiharbeitskraft bei Einstellung und in den Stammdaten
All checks were successful
CI / Lint, Typen, Tests, Build (push) Successful in 11m32s
CI / Migrationen auf leerer Datenbank (push) Successful in 10m10s
CI / Ausrollen (push) Successful in 7s
Neues Kennzeichen "Uebernahme Leiharbeitskraft" mit einem freien Feld
dazu, das erst mit dem Haken erscheint. Gefragt bei interner Besetzung in
Einstellung und Wiedereintritt, aenderbar in "Daten aendern", sichtbar in
den Stammdaten, der Zusammenfassung und im Mitarbeiterexport.

Die Spalten gehoeren zur Gruppe person. Einstellung, Wiedereintritt,
"Daten aendern", Nachtlauf und Feldkarte sind an der laufenden Definition
ergaenzt; ein CHECK haelt Angaben ohne Kennzeichen fern, die Funktionen
leeren sie beim Entfernen des Hakens.

Geprueft: lint, tsc, types:check, 957 Tests, Waechter; alle Migrationen auf
leerer Datenbank, zweiter Lauf ohne Befund; Rauchtest 32/32 mit neuem
Schritt; datierte Aenderung im Nachtlauf als alpenwerk_app.
2026-10-29 08:43:00 +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
d25778d2fa Mehrere Notfallkontakte, Planstelle nicht vor ihrer Einheit, Anstehend fuehrt in die Historie, Uebernahme, Meine Notizen
All checks were successful
CI / Lint, Typen, Tests, Build (push) Successful in 11m47s
CI / Migrationen auf leerer Datenbank (push) Successful in 10m19s
CI / Ausrollen (push) Successful in 7s
- Notfallkontakte: eigene Tabelle employee_emergency_contacts (Migration
  20261019160000), beliebig viele je Person, angelegt, geaendert und
  entfernt wie Angehoerige (add_/update_/delete_emergency_contact, mit
  Historie und Protokoll). Bestand uebernommen. Verhaeltnis-Liste wie bei
  den Angehoerigen (Ehepartner, Lebenspartner, Kind, Sonstige mit Freitext).
  Neueinstellung, Wiedereintritt, Import und Mitarbeiterexport schreiben
  und lesen die Tabelle.
- Planstelle beginnt nicht vor und nicht nach dem Bestehen ihrer
  Organisationseinheit: Ausloeser an om_positions (Migration
  20261019150000), gilt fuer Anlegen, Aendern und Klonen.
- Anstehend auf der Uebersicht: Klick oeffnet die Akte im Reiter Historie,
  bei einer Wiedervorlage im Reiter HR-Notizen (?tab=).
- Uebernahme: Vertrag zeigt Besetzungsart und "Uebernahme Ja/Nein" aus der
  Historie; die Kachel Eintritte (YTD) zaehlt Uebernahmen mit.
- Glocke: "Meine Notizen" schaltet bei hinzugewaehlten Kollegen auf nur
  die eigenen Notizen um.

Rauchtest Schritt 18.

Geprueft: lint, tsc, types:check, 921 Tests, Waechter
2026-10-19 17:17:02 +02:00
b14d3f9aad Austritt und letzte Versetzung zuruecknehmen, Planstelle beim Eintritt berichtigen, Uebersicht Anstehend, Teilzeitvariante, Notiz erledigt von
All checks were successful
CI / Migrationen auf leerer Datenbank (push) Successful in 10m24s
CI / Lint, Typen, Tests, Build (push) Successful in 11m48s
CI / Ausrollen (push) Successful in 7s
Migration 20261019140000:
- austritt_zuruecknehmen: Austrittsangaben leeren, Status neu ableiten,
  beendete Besetzung wieder oeffnen, wenn die Planstelle frei ist (sonst
  ohne Besetzung und mit Hinweis, dass eine andere gebraucht wird),
  Offboarding-Checkliste loeschen, Austritt aus der Historie nehmen und die
  Ruecknahme als eigene Zeile vermerken. Nichtantritt ausgenommen.
- versetzung_zuruecknehmen: nur die letzte wirksame Versetzung, ohne
  spaetere Befoerderung; die Person kehrt auf die vorherige Planstelle
  zurueck, wenn diese frei ist, sonst Abweisung. delete_history_entry
  leitet die wirksame Versetzung dorthin um (Papierkorb in der Historie).
- eintritt_planstelle_berichtigen: beim Eintritt gewaehlte Planstelle
  richtigstellen, solange keine Versetzung/Befoerderung folgte; keine
  Versetzung in der Historie.
- app_planstelle_frei_ab: gemeinsame Pruefung (besetzt oder vorgemerkt).

Oberflaeche:
- Daten aendern: "Austritt zuruecknehmen" mit Rueckfrage; Abschnitt
  "Planstelle beim Eintritt".
- Uebersicht, Karte Anstehend: Art "Anstehend" mit der vorgemerkten
  Historie aller Personen.
- Teilzeitvariante auch im Reiter Stammdaten, "Keine" statt Strich; in den
  Formularen heisst der leere Eintrag "Keine (vertragliche
  Stundenaenderung)".
- Notizen: bei erledigten steht, von wem und wann.

Rauchtest Schritte 15-17.

Geprueft: lint, tsc, types:check, 919 Tests, Waechter
2026-10-19 16:36:49 +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
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
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
1816ab68ad Den Notfallkontakt an Ort und Stelle anlegen statt ueber "Daten aendern"
Bei den Angehoerigen steht ein "+ Hinzufuegen", beim Notfallkontakt stand
nichts: der einzige Weg zu einer Telefonnummer fuehrte ueber ein Formular
ueber saemtliche Stammdaten. Jetzt steht der Knopf an derselben Stelle,
mit einem Fenster fuer Name, Telefonnummer und Verhaeltnis; ist ein
Kontakt hinterlegt, heisst er "Aendern" und daneben laesst er sich
entfernen.

Geschrieben wird ueber dieselbe Funktion wie in "Daten aendern" --
change_employee_data mit nur den drei Feldern. Der Eintrag landet damit
in der Historie und im Protokoll wie jede andere Stammdatenaenderung. Die
Datenbank fasst nur die Felder an, die im Aufruf stehen: sie prueft auf
das Vorhandensein des Schluessels, nicht auf seinen Wert (Migration
20260917120000, Zeilen 209-211). Adresse, E-Mail und der Rest bleiben
unberuehrt.
2026-09-23 10:41:24 +02:00
b87c8ad64c Remove Supabase
Some checks failed
CI / Lint, Typen, Tests, Build (push) Failing after 5m40s
CI / Migrationen auf leerer Datenbank (push) Has been cancelled
The database moved to a container of our own; the platform is gone.
This takes out what was left of it — and, where the leftovers were load
bearing, moves rather than deletes.

Moved, not deleted:

  supabase/migrations/  -> db/migrations/      the schema's source of truth
  supabase/build-org.ts -> scripts/build-org.ts
  lib/supabase/types.ts -> lib/types.ts        52 import sites repointed

The bookkeeping needed care. It lived in `supabase_migrations.schema_migrations`,
and simply renaming the schema would have left the runner facing an empty
table: it would have called all 67 migrations pending and replayed them
against a database that is long since current. So the runner now creates
`migrationen.schema_migrations` and, once, copies the old rows across —
guarded so a second run does nothing and a fresh database skips it entirely.
Only then does migration 20260907100000 drop the old schema.

Deleted: the CLI config, the seed, the historical schema/function dumps
(nothing read them), scripts/umzug-von-supabase.sh (the move is done), and
both Supabase packages plus the CLI. Nothing in the application imported
them — the build now succeeds with no environment variables at all, which
is the proof.

Integration tests: six of them signed in through Supabase Auth and asserted
against the anon key and the service role. That model is gone, so the tests
were not portable — they are deleted. session-context and
employee-status-filter already ran on pg and are untouched; om-reporting is
ported to a direct connection because it guards a real risk (the reporting
line rule exists twice, once in SQL and once in TypeScript).

CI: the integration job started a Supabase stack. It now runs a postgres
service, applies deploy/db-init and every migration to an empty database —
that was the valuable part, and it still holds — then checks that a second
run is a no-op, which is what proves the bookkeeping works.

Docs: security-review.md audited a service-role key, a cookie adapter and
auth.users, none of which exist. Restating findings about removed components
would suggest today's system had been reviewed; it has not. It now records
what was removed and says a fresh review is due. data-model.md was already
marked obsolete and described the pre-OM schema; azure-migration.md was a
plan for a route not taken. Both deleted.

Verified: npm ci, typecheck, lint, 445 tests, build — all clean without the
packages. Integration tests skip cleanly with no database. Migration SQL and
the runner are reviewed but NOT executed: no Docker here, and the old
instance no longer resolves.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 10:43:22 +02:00
d2f4a7aab7 Ask for a residence permit only where one is needed
Employees from outside the EU, the EEA and Switzerland need a residence
permit, and HR needs to know when it expires — about eighty people in
the current data, across Türkei, Serbien and Bosnien. Two columns, the
same shape as the dismissal protection: a flag and a date that only
means anything with it. The date is optional, because an open-ended
permit has none and a mandatory field would force an invented one.

The nationality coupling deliberately stays out of the database. Putting
it there would mean keeping the country list in two places — SQL and
lib/countries.ts, where the picker needs it anyway — so an EU accession
would become a migration instead of a line in a list. Worse, correcting
somebody's nationality would fail the constraint while the old permit
was still attached, which is exactly the moment someone is fixing a
mistake. The UI decides whether the fields appear, and clears them when
the nationality moves into the free-movement area.

So the list is the load-bearing part, and it is tested: 31 entries, all
of them values the picker can actually produce, no duplicates, no third
countries. A missing nationality reads as "no permit required" — an
unanswered question is a reason to record it, not to demand papers.

The permit shows on the Stammdaten tab only for the nationalities it
applies to. A line reading "Aufenthaltstitel: Nein" under an Austrian
citizenship would look like information rather than a question that does
not arise.

Filter by it and by when it expires — the question behind that being
"whose permit runs out next quarter" — plus columns in the export.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-14 13:27:26 +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
4eba557121 Show every field the edit dialog can change
The master-data tab summarised where the edit dialog itemises. Titles were
collapsed into one line, street, postcode and town were fused into a single
"Adresse", and first and last name appeared only in the page header — so
checking a value meant opening the change dialog to see it, which puts you
inside a form when you only wanted to look.

The tab now mirrors the dialog's "Person" section field for field and in the
same order, personnel number included.

Two deliberate departures from a literal mirror:

  - Standort sits at the end rather than between Adresse and Land. It is the
    workplace, not part of the person's address, and next to the postal
    fields it reads as though it were.
  - The emergency contact keeps the separate block it got earlier today,
    with its phone number as a tel: link. In an emergency someone reaches
    for it in a hurry; it should not be one cell among fourteen.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-11 21:33:28 +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
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
901c5c426e Consolidation pass: HR-only access, effective-dated mutations, data integrity guards, test suite
Reworks the app from a two-role (hr_admin/manager) model to a single
HR-only role gated by profiles.is_active, fixes transfer/promote/karenz/
reorg RPCs to actually defer future-dated changes via a new
pending_org_changes table instead of writing them immediately (applied
by a daily Vercel Cron route), makes reorg undo append-only instead of
deleting history, adds Karenz-return and history-date integrity guards,
deprecates the salary column, and adds explicit schema grants + perf
indexes needed to run against a fresh (non-hosted) Postgres instance.

Adds vitest unit + integration test suites (the latter against a real
local Supabase instance) covering all of the above, plus lint/typecheck/
build wiring (`npm run check`).
2026-07-14 20:32:20 +02:00
366731ec85 Phase 2/3: Employees list/detail + mutation RPCs + action panels
- supabase/functions.sql, functions_2.sql: Postgres RPCs for every
  employee/position/reorg mutation (hire, terminate, transfer, promote,
  start/adjust/return karenz, change data, rehire, create position, staff
  internally, apply/undo reorg). Each resolves manager_id server-side,
  writes history + audit atomically, and enforces hr_admin via
  require_hr_admin() (backed by the existing RLS policy).
- actions/employees.ts, positions.ts, reorg.ts: Server Actions wrapping
  the RPCs, returning success/error for client-side toast handling.
- Employees list (search/filter/pagination) and detail (4 tabs: Stammdaten,
  Vertrag & Gehalt, Organisation, Historie) reading from employees_directory.
- 6 action slide-over panels: Transfer, Promote, Karenz (start/adjust/
  return), Daten aendern (person+contract diffing), Terminate (with direct-
  report reparenting warning + offboarding checklist), Rehire.
- lib/org.ts: shared division/department/team/location lookups.

Verified live: promote mutation updates salary, writes history/audit, and
the detail page reflects it after refresh, no console errors.

Note: the spec's Karenz-verwalten panel only covers employees already on
Karenz; added a start-Karenz mode (Karenzbeginn/geplante Rueckkehr) to
cover the Aktiv-employee case implied by the header button but not
specified in the panel list.
2026-07-13 22:07:38 +02:00