b0044bfe98
* fix(arsredovisning): make the aktiekapital note completable via company settings The annual report warned every AB that the aktiekapital note was missing and pointed at Installningar -> Foretag, but the referenced columns (aktiekapital, antal_aktier, kvotvarde) never existed and no settings UI was ever built, so the warning was a dead end and no AB could produce a complete note before Bolagsverket filing. - migration 20260723103000: company_settings.aktiekapital (numeric) and antal_aktier (integer) with positive CHECKs; kvotvarde is intentionally not stored since ABL 1 kap 6 defines it as aktiekapital / antal aktier - build-data.ts (K2 and K3 note paths): select only the two stored columns and derive kvotvarde with roundOre - UpdateSettingsSchema: aktiekapital (positive), antal_aktier (positive integer), both nullable to allow clearing - new ShareCapitalForm section on Installningar -> Foretag, rendered for aktiebolag only, with live derived kvotvarde display; wired through the existing CompanySettingsContent save path (empty string clears to null) - sv/en strings; settings route tests (round-trip, clear, 400 on invalid); builder tests for derived kvotvarde and the empty-settings warning Staging (metjnjrhvujscngnpzdv) already has the columns applied and the note verified end-to-end against a rehearsal company. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(arsredovisning): address PR review findings on the share-capital note - enforce aktiekapital/antal_aktier as an all-or-nothing pair (DB CHECK, K2/K3 note guard now requires both, partial pair warns instead) - numeric(15,2) column, .int() Zod constraint, maxFractionDigits 0 render - guard numberOrNull against NaN; align kvotvarde preview with schema - strengthen clearing test, add fractional and partial-pair tests Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
39 lines
2.0 KiB
SQL
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';
|