Files
accounted/supabase/migrations/20260526182000_cap_reminder_fee_at_60.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

22 lines
856 B
SQL

-- Tighten reminder_fee_amount upper bound to the statutory cap.
--
-- Lag 1981:739 about late-payment fee caps the lagstadgad
-- påminnelseavgift at 60 kr. The original migration only enforced
-- `>= 0`, so a user could set 500 kr in settings and the cron would
-- happily book it. Add a hard upper bound at the DB level — the
-- application layer also clamps in lib/invoices/reminder-processor.ts.
ALTER TABLE public.company_settings
DROP CONSTRAINT IF EXISTS company_settings_reminder_fee_check;
-- Clamp any rows over 60 down before re-applying the constraint.
UPDATE public.company_settings
SET reminder_fee_amount = 60
WHERE reminder_fee_amount > 60;
ALTER TABLE public.company_settings
ADD CONSTRAINT company_settings_reminder_fee_check
CHECK (reminder_fee_amount >= 0 AND reminder_fee_amount <= 60);
NOTIFY pgrst, 'reload schema';