fix(arsredovisning): make the aktiekapital note completable via compa… (#1118)
* 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>
This commit is contained in:
co-authored by
Claude Fable 5
parent
466e55a015
commit
b0044bfe98
@@ -97,6 +97,54 @@ describe('PUT /api/settings', () => {
|
||||
expect(deadlineMocks.regenerate).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('round-trips share capital fields and clears them with null', async () => {
|
||||
const updates = { aktiekapital: 25000, antal_aktier: 500 }
|
||||
enqueueMany([
|
||||
{ data: { entity_type: 'aktiebolag', onboarding_complete: true } },
|
||||
{ data: { id: 's1', ...updates } },
|
||||
{ data: null, count: 5 },
|
||||
])
|
||||
|
||||
const response = await PUT(createMockRequest('/api/settings', {
|
||||
method: 'PUT',
|
||||
body: updates,
|
||||
}), { params: Promise.resolve({}) })
|
||||
const { status, body } = await parseJsonResponse<{ data: typeof updates }>(response)
|
||||
|
||||
expect(status).toBe(200)
|
||||
expect(body.data).toMatchObject(updates)
|
||||
|
||||
enqueueMany([
|
||||
{ data: { entity_type: 'aktiebolag', onboarding_complete: true } },
|
||||
{ data: { id: 's1', aktiekapital: null, antal_aktier: null } },
|
||||
{ data: null, count: 5 },
|
||||
])
|
||||
const clearResponse = await PUT(createMockRequest('/api/settings', {
|
||||
method: 'PUT',
|
||||
body: { aktiekapital: null, antal_aktier: null },
|
||||
}), { params: Promise.resolve({}) })
|
||||
const cleared = await parseJsonResponse<{ data: Record<string, unknown> }>(clearResponse)
|
||||
expect(cleared.status).toBe(200)
|
||||
expect(cleared.body.data.aktiekapital).toBeNull()
|
||||
expect(cleared.body.data.antal_aktier).toBeNull()
|
||||
})
|
||||
|
||||
it('rejects non-positive aktiekapital and fractional antal_aktier', async () => {
|
||||
for (const body of [
|
||||
{ aktiekapital: 0 },
|
||||
{ aktiekapital: -25000 },
|
||||
{ aktiekapital: 25000.5 },
|
||||
{ antal_aktier: 0 },
|
||||
{ antal_aktier: 500.5 },
|
||||
]) {
|
||||
const response = await PUT(createMockRequest('/api/settings', {
|
||||
method: 'PUT',
|
||||
body,
|
||||
}), { params: Promise.resolve({}) })
|
||||
expect((await parseJsonResponse(response)).status).toBe(400)
|
||||
}
|
||||
})
|
||||
|
||||
it('updates invoice email recipients and payment accounts', async () => {
|
||||
const updates = {
|
||||
invoice_email_cc_addresses: ['info@example.com', 'owner@example.com'],
|
||||
|
||||
Reference in New Issue
Block a user