0.37.1: Bezahlt-am-Datum setzt die Rate automatisch auf bezahlt
Some checks failed
Prüfung / tests (push) Has been cancelled
Prüfung / container (push) Has been cancelled

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:
Claude
2026-10-26 06:44:38 +00:00
parent ba57e97de9
commit 3bc50cdfec
6 changed files with 33 additions and 2 deletions

View 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';