Files
accounted/supabase/migrations/20260526121500_k3_framework.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

27 lines
1.4 KiB
SQL

-- Add accounting_framework to companies.
--
-- Swedish AB can apply either K2 (BFNAR 2016:10, simplified ruleset for
-- mindre företag) or K3 (BFNAR 2012:1, full principles-based). K2 is the
-- default and what most of our customers use. K3 becomes mandatory when the
-- company crosses any two of the three K2 thresholds (turnover >80 MSEK,
-- assets >40 MSEK, employees >50) and is permitted earlier on a voluntary
-- basis. The choice has substantial downstream effects (component
-- depreciation, latent tax recognition, cash flow statement, more noter).
--
-- Only meaningful for entity_type='aktiebolag'. Enskild firma stays on the
-- simpler EF rules and does not consume this column. The application keeps
-- the K3 settings UI hidden for EF entities.
--
-- Default 'k2' so existing AB rows keep the current behavior (the engine and
-- arsredovisning builder were written against K2 assumptions). Switching
-- K2 → K3 is a deliberate user action gated by a confirmation dialog.
ALTER TABLE public.companies
ADD COLUMN accounting_framework TEXT NOT NULL DEFAULT 'k2'
CHECK (accounting_framework IN ('k2', 'k3'));
COMMENT ON COLUMN public.companies.accounting_framework IS
'Swedish accounting framework. K2 (BFNAR 2016:10) is the simplified ruleset for small AB and the default. K3 (BFNAR 2012:1) is required for medium-to-large AB and required-when-larger-than-K2-thresholds. Only meaningful for entity_type=aktiebolag.';
NOTIFY pgrst, 'reload schema';