Post-audit cleanup batch: dead email forks, Docker extension drift, English error locale (#653)
* chore(email): remove dead, diverged email-template forks (audit E2)
extensions/general/email/lib/{invoice,reminder}-templates.ts had zero importers and had diverged from the live lib/email/* copies (which carry later i18n / CSP / Räntelagen-dunning fixes). Pure deletion of a drift hazard.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(docker): hosted preset was missing skatteverket / invoice-inbox / document-extraction / cloud-backup (audit E7)
docker/extensions.hosted.json shipped only 5 of the 9 extensions in extensions.config.json — so a Docker 'hosted' image silently ran without Skatteverket filing, the invoice inbox, document extraction and cloud backup. Aligned with the hosted config.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(errors): return English error messages on the en locale (audit C9)
The structured-error branches in getErrorMessage returned hardcoded Swedish regardless of locale, so English users saw Swedish prose. For the en locale, prefer the registry's English message for any known code; the Swedish (default) path is left entirely unchanged, and codes absent from the registry still fall through. + regression test.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
b91f0bdbf8
commit
c1be9f15dd
@@ -95,6 +95,25 @@ describe('getErrorMessage — typed bookkeeping error codes', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('getErrorMessage — English locale uses registry English (C9)', () => {
|
||||
it('returns the registry English message for a known structured code instead of Swedish', () => {
|
||||
const code = 'FISCAL_PERIOD_NOT_FOUND'
|
||||
const sv = getErrorMessage({ error: { code, message: '...' } })
|
||||
const en = getErrorMessage({ error: { code, message: '...' } }, { locale: 'en' })
|
||||
|
||||
expect(sv).toMatch(/[åäö]/i) // default (Swedish) path is unchanged
|
||||
expect(en).not.toBe(sv) // English locale now differs
|
||||
expect(en).not.toMatch(/[åäö]/i) // …and is no longer Swedish prose
|
||||
expect(en.toLowerCase()).toContain('fiscal period')
|
||||
})
|
||||
|
||||
it('leaves the Swedish (default-locale) message identical to before', () => {
|
||||
expect(getErrorMessage({ error: { code: 'CANNOT_REVERSE_NON_POSTED', message: '...' } })).toBe(
|
||||
'Endast bokförda verifikationer kan stornas.',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('getErrorMessage — existing patterns still work', () => {
|
||||
it('regex match for "Entry date ... outside fiscal period" on plain string', () => {
|
||||
const msg = getErrorMessage('Entry date 2024-06-15 is outside fiscal period "FY 2025"')
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
import { formatCurrency } from '@/lib/utils'
|
||||
import { getErrorEntry } from './structured-errors'
|
||||
|
||||
type ErrorContext =
|
||||
| 'invoice'
|
||||
@@ -279,6 +280,17 @@ export function getErrorMessage(
|
||||
details?: unknown
|
||||
}
|
||||
|
||||
// For English UI, return the registry's English message for any known
|
||||
// code instead of falling through to the Swedish branches below (which
|
||||
// ignored locale — English users were shown Swedish prose). The Swedish
|
||||
// path is left entirely unchanged; codes absent from the registry still
|
||||
// fall through. The dynamic branches (amounts / lock date / reason) keep
|
||||
// owning Swedish display.
|
||||
if (locale === 'en' && typeof structured.code === 'string') {
|
||||
const entry = getErrorEntry(structured.code)
|
||||
if (entry?.message_en) return entry.message_en
|
||||
}
|
||||
|
||||
if (structured.code === 'ACCOUNTS_NOT_IN_CHART' && Array.isArray(structured.account_numbers)) {
|
||||
const numbers = structured.account_numbers as string[]
|
||||
return `Följande konton behöver aktiveras: ${numbers.join(', ')}`
|
||||
|
||||
Reference in New Issue
Block a user