feat(import): detect and import the article register's Valuta column (#1183)
Fixes #1167. The register export gained a Valuta column in #1166 but the importer ignored it, so re-imported non-SEK articles silently became SEK, breaking the export -> edit -> re-import round-trip. - Column detector recognizes valuta/valutakod/currency (claimed before generic columns; no keyword collision with Momskod). - Parser normalizes to upper-case ISO shape, drops malformed codes with a file-level warning, and carries currency per row. - Execute route validates codes lazily against the currencies table (FK stays the backstop when the reference read fails), imports valid codes, defaults absent to SEK, and in merge mode only overwrites when the file explicitly carries a valid currency. - Edit step shows a muted currency marker next to non-SEK prices; manual column mapping offers Valuta. - Export docblock caveat removed. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
aead2bc1d1
commit
36a1df4f6b
@@ -2166,6 +2166,10 @@ const ImportedArticleRowSchema = z.object({
|
||||
type: ArticleTypeSchema,
|
||||
unit: z.string(),
|
||||
price_excl_vat: nonNegativeAmount,
|
||||
// ISO 4217 shape only; the execute route validates against the currencies
|
||||
// table and drops unknown codes (mirrors revenue_account). Optional so rows
|
||||
// parsed before this field existed still validate.
|
||||
currency: z.string().regex(/^[A-Z]{3}$/).nullable().optional(),
|
||||
vat_rate: vatRatePercent,
|
||||
// The execute route re-validates against the chart of accounts (and drops
|
||||
// unknown/inactive overrides), so a loose nullable string is enough here.
|
||||
@@ -2192,6 +2196,9 @@ export const ArticleColumnOverridesSchema = z.object({
|
||||
type_col: articleColumnIndex,
|
||||
unit_col: articleColumnIndex,
|
||||
price_col: articleColumnIndex,
|
||||
// Optional + defaulted so a mapping payload from a client rendered before
|
||||
// this column existed still validates.
|
||||
currency_col: articleColumnIndex.optional().default(null),
|
||||
vat_rate_col: articleColumnIndex,
|
||||
revenue_account_col: articleColumnIndex,
|
||||
cost_price_col: articleColumnIndex,
|
||||
|
||||
Reference in New Issue
Block a user