fix(bookkeeping): allow a first rakenskapsar shorter than 6 months (#1165)

The validator enforced a 6-month minimum on the FIRST fiscal period,
citing BFL 3 kap. The law says the opposite: BFL 3 kap 3 par expressly
allows a rakenskapsar shorter than 12 months, with no floor, when
bokforingsskyldigheten begins (Bolagsverket: the first year may be
"hur kort som helst", max 18 months). The floor only applied to
isFirstPeriod, exactly the case the law exempts, and blocked an
autumn-registered AB from shortening its first year to Dec 31 to file
an early arsredovisning.

Drop the minimum, keep the 18-month cap and the day-boundary rules,
and remove the now-dead Swedish error mapping.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Jakob Wennberg
2026-07-25 11:23:18 +02:00
committed by GitHub
co-authored by Claude Fable 5
parent 98886e68d8
commit 47938520d6
5 changed files with 25 additions and 18 deletions
@@ -84,16 +84,16 @@ describe('validatePeriodDuration', () => {
expect(result).toContain('18 months')
})
it('enforces 6-month minimum for first period (2 months)', () => {
expect(validatePeriodDuration('2026-03-25', '2026-05-31', { isFirstPeriod: true })).toBe(
'First fiscal period must be at least 6 months (BFL 3 kap.)'
)
// BFL 3 kap 3 § sets NO minimum for a first räkenskapsår: it may be
// "hur kort som helst" (Bolagsverket). A 6-month floor here blocked an
// autumn-registered AB from shortening its first year to Dec 31 for an
// early årsredovisning (real customer case 2026-07-25).
it('allows a short first period (3 months, autumn registration to Dec 31)', () => {
expect(validatePeriodDuration('2025-10-01', '2025-12-31', { isFirstPeriod: true })).toBeNull()
})
it('enforces 6-month minimum for first period (5 months)', () => {
expect(validatePeriodDuration('2026-08-01', '2026-12-31', { isFirstPeriod: true })).toBe(
'First fiscal period must be at least 6 months (BFL 3 kap.)'
)
it('allows a very short first period (2 months, mid-month start)', () => {
expect(validatePeriodDuration('2026-03-25', '2026-05-31', { isFirstPeriod: true })).toBeNull()
})
it('allows exactly 6 months for first period', () => {
+7 -7
View File
@@ -1,7 +1,10 @@
/**
* Validates fiscal period duration per BFL 3 kap.
* Maximum 18 months for any fiscal period (first year may be extended).
* Normal ongoing periods are 12 months.
* Normal ongoing periods are 12 months. There is NO minimum length: BFL
* 3 kap 3 § expressly allows a räkenskapsår shorter than 12 months when
* bokföringsskyldigheten begins or the year is re-laid, with no floor
* (Bolagsverket: the first year may be "hur kort som helst").
*/
/**
@@ -56,16 +59,13 @@ export function validatePeriodDuration(start: string, end: string, options?: Val
return 'Period end must be the last day of a month'
}
// Max 18 months per BFL 3 kap.
// Max 18 months per BFL 3 kap. No minimum: a first (or re-laid) year may
// be arbitrarily short, e.g. an autumn-registered AB shortening its first
// year to end at Dec 31 for an early årsredovisning.
const months = monthsBetween(start, end)
if (months > 18) {
return `Period duration ${months} months exceeds maximum 18 months (BFL 3 kap.)`
}
// First fiscal period must be at least 6 months per BFL 3 kap.
if (options?.isFirstPeriod && months < 6) {
return `First fiscal period must be at least 6 months (BFL 3 kap.)`
}
return null
}
@@ -89,14 +89,19 @@ describe('computeFiscalPeriod', () => {
expect(result.periodName).toBe('')
})
it('rejects a first year shorter than 6 months', () => {
// BFL 3 kap 3 § allows a first räkenskapsår of any length up to 18 months:
// an autumn-registered AB may end its first year at Dec 31 (Bolagsverket
// offers this explicitly on the registration certificate).
it('accepts a first year shorter than 6 months', () => {
const result = computeFiscalPeriod({
entity_type: 'aktiebolag',
is_first_fiscal_year: true,
first_year_start: '2026-10-01',
first_year_end: '2026-12-31',
})
expect(result.error).toContain('at least 6 months')
expect(result.error).toBeNull()
expect(result.startStr).toBe('2026-10-01')
expect(result.endStr).toBe('2026-12-31')
})
it('rejects an end date that is not the last day of a month', () => {