fix(settings): validate share-capital pair before saving (#1137) (#1160)

* fix(settings): validate share-capital pair before saving (#1137)

Entering aktiekapital without antal aktier (or vice versa) died on the DB
pair constraint company_settings_share_capital_pair as a raw 500 with the
generic 'Vardet uppfyller inte de tillatna kraven' toast. The pair rule
(ARL 5 kap 14 $: the aktiekapital note needs both values) now surfaces as
a clear 400 in the PUT route, checked against effective body-or-stored
values so partial API updates are covered too. The form additionally marks
each field required when its sibling is filled, so the browser blocks a
one-sided submit before the request is sent.

Fixes #1137

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs: decision-log entry for share-capital pair validation placement

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs(settings): correct the share-capital note citation to ÅRL 5 kap 34 §

5 kap 14 § is ställda säkerheter; the antal aktier/kvotvärde note is 5 kap 34 §
(flagged by the Swedish compliance review bot, verified against the
swedish-financial-reporting skill).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* test(settings): assert the pair message on the one-sided-clear rejection

CodeRabbit review on #1160. Its second suggestion (assert the update
payload on the partial-update test) is skipped: createQueuedMockSupabase
proxies away builder args, so payloads are not recordable, same as every
other test in this suite.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Jakob Wennberg
2026-07-24 20:07:24 +02:00
committed by GitHub
co-authored by Claude Fable 5
parent 8a9162b948
commit 8a7fd567bd
4 changed files with 85 additions and 1 deletions
+2
View File
@@ -57,6 +57,7 @@ export function ShareCapitalForm({ settings }: ShareCapitalFormProps) {
step="1"
value={aktiekapital}
onChange={(e) => setAktiekapital(e.target.value)}
required={antalAktier.trim() !== ''}
/>
<p className="text-xs text-muted-foreground">{t('aktiekapital_help')}</p>
</div>
@@ -71,6 +72,7 @@ export function ShareCapitalForm({ settings }: ShareCapitalFormProps) {
step="1"
value={antalAktier}
onChange={(e) => setAntalAktier(e.target.value)}
required={aktiekapital.trim() !== ''}
/>
<p className="text-xs text-muted-foreground">{t('antal_aktier_help')}</p>
</div>