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
This commit is contained in:
2026-10-20 16:05:00 +02:00
parent 06a1768fc8
commit 0294c792a4
13 changed files with 151 additions and 45 deletions

View File

@@ -0,0 +1,70 @@
-- Geburtsdatum bei der Einstellung freiwillig
--
-- Fachlich vorgegeben: eine Einstellung darf ohne Geburtsdatum erfasst
-- werden; es wird nachgetragen, sobald es vorliegt. Die Spalte ist damit
-- nicht mehr NOT NULL. Ein leer geschicktes Feld wird null und nicht in ein
-- Datum umgewandelt — sonst bräche die Umwandlung von '' ab.
--
-- Geändert wird an der laufenden Definition, an genau einem Anker je
-- Funktion.
alter table employees alter column birth_date drop not null;
do $migration$
declare
v_ziele text[][] := array[
array['hire_employee',
$a$(payload->>'birth_date')::date, payload->>'sv_nummer',$a$,
$a$nullif(payload->>'birth_date', '')::date, payload->>'sv_nummer',$a$],
array['rehire_employee',
$a$birth_date = coalesce((payload->>'birth_date')::date, birth_date),$a$,
$a$birth_date = coalesce(nullif(payload->>'birth_date', '')::date, birth_date),$a$],
array['change_employee_data',
$a$birth_date = coalesce((v_person->>'birth_date')::date, birth_date),$a$,
$a$birth_date = coalesce(nullif(v_person->>'birth_date', '')::date, birth_date),$a$],
array['apply_due_pending_changes',
$a$birth_date = coalesce((v_rec.payload->'person'->>'birth_date')::date, birth_date),$a$,
$a$birth_date = coalesce(nullif(v_rec.payload->'person'->>'birth_date', '')::date, birth_date),$a$]
];
v_def text;
v_treffer integer;
i integer;
begin
for i in 1 .. array_length(v_ziele, 1) 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.prokind = 'f' and p.proname = v_ziele[i][1];
if v_def is null then
raise exception '% ist nicht vorhanden.', v_ziele[i][1];
end if;
if position(v_ziele[i][3] in v_def) > 0 then
raise notice '% ist bereits angepasst — nichts zu tun.', v_ziele[i][1];
continue;
end if;
v_treffer := (length(v_def) - length(replace(v_def, v_ziele[i][2], ''))) / length(v_ziele[i][2]);
if v_treffer <> 1 then
raise exception '%: der Anker kommt % mal vor, erwartet genau einmal.', v_ziele[i][1], v_treffer;
end if;
execute replace(v_def, v_ziele[i][2], v_ziele[i][3]);
end loop;
end
$migration$;
do $pruefung$
declare
v_def text;
begin
if exists (select 1 from information_schema.columns
where table_schema = 'public' and table_name = 'employees'
and column_name = 'birth_date' and is_nullable = 'NO') then
raise exception 'employees.birth_date ist weiter NOT NULL.';
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.prokind = 'f' and p.proname = 'hire_employee';
if position($a$nullif(payload->>'birth_date', '')::date$a$ in v_def) = 0
or position('require_hr_admin()' in v_def) = 0 or position('lehrzeit_von' in v_def) = 0 then
raise exception 'hire_employee ist nicht wie erwartet angepasst.';
end if;
end
$pruefung$;