Planstellennummer: ID und eine fortlaufende Zahl
Eine neue Planstelle bekommt "ID" mit der naechsten freien Zahl, mindestens dreistellig (ID001 ... ID999, ID1000). Eine vorgegebene Nummer (Import) muss dieselbe Form haben; die Meldung nennt die naechste freie. Eine Zahl ist nur einmal vergeben, auch mit anderen fuehrenden Nullen. Bestehende Nummern anderer Form bleiben. Geprueft: Migrationen auf frischer DB, zweiter Lauf leer; Rauchtest 35/35 mit Form, Doppel und Folgenummer; Integrationstests Austausch (8); lint, tsc, types:check, 1012 Tests, Waechter.
This commit is contained in:
@@ -57,6 +57,7 @@ declare
|
||||
v_ging boolean;
|
||||
v_titel text;
|
||||
v_zu uuid; v_px uuid; v_py uuid; v_job uuid; v_pa uuid; v_x uuid;
|
||||
v_psnr text;
|
||||
begin
|
||||
select id into v_wurzel from org_units where parent_id is null;
|
||||
select id into v_ort from locations order by name limit 1;
|
||||
@@ -907,20 +908,35 @@ begin
|
||||
v_zu := create_org_unit(jsonb_build_object(
|
||||
'parent_id', v_wurzel, 'org_number', 'RAUCHTEST-ZU', 'name', 'Rauchtest zu',
|
||||
'unit_type', 'Team', 'valid_from', (current_date - 30)::text));
|
||||
v_px := create_position(jsonb_build_object('org_unit_id', v_zu, 'position_number', 'RAUCHTEST-PS1',
|
||||
v_psnr := next_position_number();
|
||||
v_px := create_position(jsonb_build_object('org_unit_id', v_zu, 'position_number', v_psnr,
|
||||
'job_title', 'Rauchtest Katalog', 'is_chief', false, 'valid_from', (current_date - 30)::text));
|
||||
if (select position_number <> 'RAUCHTEST-PS1' or job_id <> v_job from om_positions where id = v_px) then
|
||||
if (select position_number <> v_psnr or job_id <> v_job from om_positions where id = v_px) then
|
||||
raise exception 'Die Planstelle trägt nicht die vorgegebene Nummer oder nicht die angelegte Tätigkeit.';
|
||||
end if;
|
||||
v_ging := false;
|
||||
begin
|
||||
perform create_position(jsonb_build_object('org_unit_id', v_zu, 'position_number', 'ID00' || substring(v_psnr from 3),
|
||||
'job_title', 'Rauchtest Katalog', 'is_chief', false, 'valid_from', (current_date - 30)::text));
|
||||
v_ging := true;
|
||||
exception when others then v_meldung := SQLERRM;
|
||||
end;
|
||||
if v_ging or v_meldung not like '%bereits vergeben%' then
|
||||
raise exception 'Eine Planstellennummer liess sich doppelt vergeben (%).', v_meldung;
|
||||
end if;
|
||||
v_ging := false;
|
||||
begin
|
||||
perform create_position(jsonb_build_object('org_unit_id', v_zu, 'position_number', 'RAUCHTEST-PS1',
|
||||
'job_title', 'Rauchtest Katalog', 'is_chief', false, 'valid_from', (current_date - 30)::text));
|
||||
v_ging := true;
|
||||
exception when others then v_meldung := SQLERRM;
|
||||
end;
|
||||
if v_ging or v_meldung not like '%bereits vergeben%' then
|
||||
raise exception 'Eine Planstellennummer liess sich doppelt vergeben (%).', v_meldung;
|
||||
if v_ging or v_meldung not like '%hat die Form ID und eine Zahl%' then
|
||||
raise exception 'Eine Planstellennummer ohne die Form ID liess sich vergeben (%).', v_meldung;
|
||||
end if;
|
||||
if next_position_number() !~ '^ID[0-9]{3,}$'
|
||||
or substring(next_position_number() from 3)::int <> substring(v_psnr from 3)::int + 1 then
|
||||
raise exception 'Die nächste Planstellennummer ist nicht die fortlaufende ID-Nummer (%).', next_position_number();
|
||||
end if;
|
||||
|
||||
-- Eine besetzte Planstelle endet nicht vor ihrer Besetzung.
|
||||
|
||||
Reference in New Issue
Block a user