Organisationseinheit umbenennen, Mitarbeiterliste nach Eintritt, zwei Beschriftungen ohne Gendern
- Organigramm, Leiste einer Einheit: Stift an der Bezeichnung. Geaendert wird nur die Bezeichnung (rename_org_unit), die bisherige steht im Protokoll. - Mitarbeiterliste: auch ohne Filter nach Eintritt, juengste zuerst; Ausgetretene allein nach Austritt. - "Angehoerigen hinzufuegen" im Einstellungsassistenten und die Beschriftung des Entfernen-Knopfs ohne ":n". Rauchtest: Schritt 29. Geprueft: lint, tsc, types:check, 950 Tests, Uebergabe-Waechter
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
-- Eine Organisationseinheit umbenennen — nur die Bezeichnung.
|
||||
--
|
||||
-- Fachlich vorgegeben: die Bezeichnung lässt sich berichtigen. Nummer, Art,
|
||||
-- übergeordnete Einheit und Gültigkeit bleiben; eine Umbenennung ist keine
|
||||
-- Umorganisation und hat keinen Stichtag. Der alte Name steht im Protokoll.
|
||||
create or replace function public.rename_org_unit(payload jsonb)
|
||||
returns void
|
||||
language plpgsql
|
||||
set search_path = public, pg_temp
|
||||
as $$
|
||||
declare
|
||||
v_id uuid := (payload->>'org_unit_id')::uuid;
|
||||
v_name text := nullif(btrim(payload->>'name'), '');
|
||||
v_alt org_units%rowtype;
|
||||
begin
|
||||
perform require_hr_admin();
|
||||
|
||||
if v_name is null then
|
||||
raise exception 'Bitte eine Bezeichnung angeben.';
|
||||
end if;
|
||||
|
||||
select * into v_alt from org_units where id = v_id for update;
|
||||
if not found then
|
||||
raise exception 'Die Organisationseinheit existiert nicht.';
|
||||
end if;
|
||||
if v_alt.name = v_name then
|
||||
raise exception 'Die Bezeichnung ist unverändert.';
|
||||
end if;
|
||||
|
||||
update org_units set name = v_name where id = v_id;
|
||||
|
||||
insert into audit_log (actor_user_id, actor_name, action, target_label, details)
|
||||
values (app_current_user_id(), current_actor_name(), 'Organisationseinheit umbenannt',
|
||||
v_alt.org_number || ' · ' || v_name,
|
||||
'Bisherige Bezeichnung: ' || v_alt.name);
|
||||
end;
|
||||
$$;
|
||||
|
||||
grant execute on function public.rename_org_unit(jsonb) to alpenwerk_app;
|
||||
|
||||
do $pruefung$
|
||||
declare
|
||||
v_def text;
|
||||
begin
|
||||
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 = 'rename_org_unit';
|
||||
if position(E'begin\n perform require_hr_admin();' in v_def) = 0
|
||||
or position('insert into audit_log' in v_def) = 0 then
|
||||
raise exception 'rename_org_unit prüft die Rechte nicht oder schreibt kein Protokoll.';
|
||||
end if;
|
||||
end
|
||||
$pruefung$;
|
||||
Reference in New Issue
Block a user