Files
accounted/lib/bookkeeping/__tests__/bas-ef-equity-accounts.test.ts
T
fe1ff8649b 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>
2026-08-10 14:04:08 +02:00

58 lines
2.8 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import { getBASReference } from '@/lib/bookkeeping/bas-reference'
/**
* The enskild firma equity block must match the official BAS kontoplan.
*
* 2012 "Avräkning för skatter och avgifter" was added 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 chart has no 2012: the block
* runs 2010, 2011, 2013, 2017, 2018, 2019, and the official "Avräkning för
* skatter och avgifter (skattekonto)" accounts are 1630/1640 (asset) and 2850
* (liability). 2012 is a program convention (Visma, Bokio, Björn Lundén), not
* standard BAS. A non-standard account in BAS_REFERENCE leaks into every chart
* the backfill seeds, and from there into SIE export and SRU filing, so the
* reference must not carry it. Owner taxes paid by the firm are an eget uttag
* on 2013, which is what the "Preliminär F-skatt (EF)" template books since
* migration 20260810120000.
*/
describe('enskild firma equity accounts (20xx)', () => {
it('carries exactly the official BAS block for delägare 1', () => {
for (const account of ['2010', '2011', '2013', '2017', '2018', '2019']) {
expect(getBASReference(account), `${account} missing from BAS reference`).toBeDefined()
}
})
it('does not carry 2012: not in official BAS, verified against bas.se in #1409', () => {
// Pinned like 2113 below: prevents a well-meaning "fix" that re-adds the
// program-convention account instead of keeping the reference official.
expect(getBASReference('2012')).toBeUndefined()
})
it('keeps the skattekonto asset account the template settles against', () => {
const skattekonto = getBASReference('1630')
expect(skattekonto?.account_type).toBe('asset')
})
it('shares the equity SRU code across the sub-accounts, since they all net into 2010', () => {
const siblings = ['2011', '2013', '2018'].map((a) => getBASReference(a)?.sru_code)
expect(new Set(siblings).size).toBe(1)
expect(siblings[0]).toBe(getBASReference('2010')?.sru_code)
})
})
describe('periodiseringsfond accounts', () => {
it('offers the generic account plus the year-tagged block', () => {
expect(getBASReference('2110')?.account_name).toContain('Periodiseringsfond')
// 2120-2129 are year-tagged (2126 = tax year 2026).
expect(getBASReference('2126')?.account_name).toContain('2026')
})
it('does not carry 2113: the pre-2020 year-tagged funds are long reversed', () => {
// The seeded "Periodiseringsfond" templates referenced 2113 (tax year 2013),
// so they could never resolve. Pinning this prevents a well-meaning
// "fix" that re-adds an obsolete account instead of correcting the template.
expect(getBASReference('2113')).toBeUndefined()
})
})