Files
accounted/supabase/migrations/20260723103000_company_settings_share_capital.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

39 lines
2.0 KiB
SQL

-- Share-capital facts for the annual report aktiekapital note (K2/K3, ÅRL).
-- The report builder has read these since the ÅR feature shipped, but the
-- columns were never created, so the "fyll i under Inställningar → Företag"
-- warning was a dead end for every AB. Kvotvärde is intentionally NOT stored:
-- ABL 1 kap 6 § defines it as aktiekapital / antal aktier, so it is derived
-- at read time to keep a Bolagsverket-filed note internally consistent.
ALTER TABLE public.company_settings
ADD COLUMN IF NOT EXISTS aktiekapital numeric(15,2),
ADD COLUMN IF NOT EXISTS antal_aktier integer;
COMMENT ON COLUMN public.company_settings.aktiekapital IS
'Registered share capital in SEK per Bolagsverket. Used for the aktiekapital note in the annual report; may differ from the booked 2081 balance during a pending emission.';
COMMENT ON COLUMN public.company_settings.antal_aktier IS
'Total number of issued shares per Bolagsverket. Used for the aktiekapital note; kvotvärde is derived as aktiekapital / antal_aktier.';
ALTER TABLE public.company_settings
DROP CONSTRAINT IF EXISTS company_settings_aktiekapital_positive;
ALTER TABLE public.company_settings
ADD CONSTRAINT company_settings_aktiekapital_positive
CHECK (aktiekapital IS NULL OR aktiekapital > 0);
ALTER TABLE public.company_settings
DROP CONSTRAINT IF EXISTS company_settings_antal_aktier_positive;
ALTER TABLE public.company_settings
ADD CONSTRAINT company_settings_antal_aktier_positive
CHECK (antal_aktier IS NULL OR antal_aktier > 0);
-- The aktiekapital note (ÅRL 5 kap 14 §) needs both the registered amount
-- and the number of shares; a lone value would produce an incomplete
-- statutory note, so the pair is all-or-nothing.
ALTER TABLE public.company_settings
DROP CONSTRAINT IF EXISTS company_settings_share_capital_pair;
ALTER TABLE public.company_settings
ADD CONSTRAINT company_settings_share_capital_pair
CHECK ((aktiekapital IS NULL) = (antal_aktier IS NULL));
NOTIFY pgrst, 'reload schema';