Files
accounted/supabase/migrations/20260806130000_enforce_balance_on_posted_insert.sql
T
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

12 lines
589 B
SQL

-- Direct inserts of posted journal entries previously bypassed
-- check_balance_on_post, which only covers draft-to-posted updates. Reuse the
-- same deferred balance function so an atomic transaction may insert the
-- header and lines together, while zero-line or unbalanced posted entries are
-- rejected when the transaction constraints are evaluated.
CREATE CONSTRAINT TRIGGER check_balance_on_posted_insert
AFTER INSERT ON public.journal_entries
DEFERRABLE INITIALLY DEFERRED
FOR EACH ROW
WHEN (NEW.status = 'posted')
EXECUTE FUNCTION public.check_journal_entry_balance();