0.37.1: Bezahlt-am-Datum setzt die Rate automatisch auf bezahlt
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AmyPfuNc4sCRfaF3oURXZz
This commit is contained in:
16
src/server/migrations/026_zahlung_bezahlt.sql
Normal file
16
src/server/migrations/026_zahlung_bezahlt.sql
Normal file
@@ -0,0 +1,16 @@
|
||||
-- Rechnung mit „Bezahlt am“ ist bezahlt (Henning, 26.10.2026): das Datum setzt den Status automatisch.
|
||||
-- Wird der Status ausdrücklich von „bezahlt“ zurückgenommen, fällt das Datum weg.
|
||||
create or replace function zahlung_bezahlt_abgleichen() returns trigger language plpgsql as $$
|
||||
begin
|
||||
if tg_op = 'UPDATE' and old.status = 'bezahlt' and new.status <> 'bezahlt' then
|
||||
new.bezahlt_am := null;
|
||||
elsif new.bezahlt_am is not null then
|
||||
new.status := 'bezahlt';
|
||||
end if;
|
||||
return new;
|
||||
end $$;
|
||||
|
||||
create trigger zahlung_bezahlt before insert or update on zahlung
|
||||
for each row execute function zahlung_bezahlt_abgleichen();
|
||||
|
||||
update zahlung set status = 'bezahlt' where bezahlt_am is not null and status <> 'bezahlt';
|
||||
Reference in New Issue
Block a user