fix(bookkeeping): drop non-standard account 2012, book EF F-skatt on 2013 (#1409) (#1489)

Primary-source check against bas.se (BAS 2026 v2): the official kontoplan
has no account 2012; the enskild firma equity block is 2010, 2011, 2013,
2017, 2018, 2019. 2012 'Avräkning för skatter och avgifter' is a program
convention (Visma, Bokio, Björn Lundén), not standard BAS, and a
non-standard account in BAS_REFERENCE leaks via the backfill into charts,
SIE export and SRU filing.

- remove 2012 from class-2-equity-liabilities.ts, with a tombstone comment
- migration retargets 'Preliminär F-skatt (EF)' lines 2012 -> 2013
  (system row plus any clones still carrying the seeded shape)
- pin 2012's absence in bas-ef-equity-accounts.test.ts (2113 precedent)
- correct the swedish-year-end-closing references that motivated #1388,
  regenerate atom seed migration

Companies whose charts already got 2012 backfilled keep it: existing
history stays valid; only future template use books 2013.

Closes #1409

Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Jakob Wennberg
2026-08-10 14:04:08 +02:00
committed by GitHub
co-authored by Jakob Wennberg Claude Fable 5
parent 3ff12faa77
commit fe1ff8649b
11 changed files with 17631 additions and 46 deletions
@@ -0,0 +1,29 @@
-- "Preliminär F-skatt (EF)" booked Debit 2012 / Credit 1630. Account 2012
-- "Avräkning för skatter och avgifter" was added to BAS_REFERENCE in #1388 on
-- the strength of the swedish-year-end-closing skill alone; the primary-source
-- check (#1409, bas.se BAS 2026 v2) shows the official kontoplan has no 2012:
-- the enskild firma equity block is 2010, 2011, 2013, 2017, 2018, 2019, and
-- "Avräkning för skatter och avgifter (skattekonto)" is 1630/1640 (asset) and
-- 2850 (liability). 2012 is a program convention (Visma, Bokio, Björn Lundén),
-- not standard BAS, so the reference drops it and the template moves to 2013
-- "Övriga egna uttag": owner taxes paid by an enskild firma are an eget uttag.
--
-- Scope: every enskild_firma template row still carrying a 2012 line, i.e. the
-- seeded system row plus any clone of it. Charts that already had 2012
-- backfilled keep the account and its history; only future template use moves
-- to 2013. account-backfill seeds 2013 on demand (it is standard BAS), so the
-- template works for charts that lack it.
UPDATE public.booking_template_library
SET lines = (
SELECT jsonb_agg(
CASE
WHEN line->>'account' = '2012' THEN jsonb_set(line, '{account}', '"2013"')
ELSE line
END
ORDER BY ord
)
FROM jsonb_array_elements(lines) WITH ORDINALITY AS t(line, ord)
)
WHERE entity_type = 'enskild_firma'
AND lines @> '[{"account": "2012"}]';
File diff suppressed because it is too large Load Diff