feat(invoices): allow BAS class 1-3 posting-account overrides and complete the aktiekapital note (#1121)
- invoice/article posting-account overrides accept active class 1-3 accounts; class 1-2 (balance-sheet) accounts are rejected on VAT-bearing lines so the ruta 05 tax base always books to a 3xxx account - shared posting-account regex across server schemas, pending-operation re-validation, and client forms - share-capital settings (aktiekapital/antal_aktier) feed the annual-report note; kvotvarde derived per ABL 1 kap 6 $; all-or-nothing pair constraint - signed per-rate VAT breakdown on credit-note PDFs; U+2212 to ASCII hyphen Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
b0044bfe98
commit
43f7ccab9e
@@ -117,17 +117,19 @@ describe('parseArticlesFile', () => {
|
||||
expect(result.rows[0].unit).toBe('st')
|
||||
})
|
||||
|
||||
it('keeps a valid 3xxx revenue account and drops a non-3xxx one', () => {
|
||||
it('keeps class 1-3 posting accounts and drops a class-4 account', () => {
|
||||
const buffer = buildXlsx([
|
||||
['Benämning', 'Försäljningskonto'],
|
||||
['A', '3001'],
|
||||
['B', '1930'],
|
||||
['C', '4000'],
|
||||
])
|
||||
|
||||
const result = parseArticlesFile(buffer, 'konto.xlsx')
|
||||
expect(result.rows[0].revenue_account).toBe('3001')
|
||||
expect(result.rows[1].revenue_account).toBeNull()
|
||||
expect(result.warnings.some((w) => w.toLowerCase().includes('försäljningskonto'))).toBe(true)
|
||||
expect(result.rows[1].revenue_account).toBe('1930')
|
||||
expect(result.rows[2].revenue_account).toBeNull()
|
||||
expect(result.warnings.some((w) => w.toLowerCase().includes('bokföringskonto'))).toBe(true)
|
||||
})
|
||||
|
||||
it('treats a blank cost price as null (not 0)', () => {
|
||||
|
||||
@@ -157,13 +157,13 @@ export function parseArticlesFile(
|
||||
const { rate: vatRate, note: vatNote } = normalizeVatRate(cell(row, columns.vat_rate_col))
|
||||
if (vatNote) vatNoteCount++
|
||||
|
||||
// Keep only well-formed BAS class-3 overrides; the execute route validates
|
||||
// Keep only well-formed BAS class 1-3 overrides; the execute route validates
|
||||
// them further against the chart of accounts.
|
||||
const revenueRaw = cell(row, columns.revenue_account_col)
|
||||
let revenueAccount: string | null = null
|
||||
if (revenueRaw) {
|
||||
const digits = revenueRaw.replace(/\s/g, '')
|
||||
if (/^3\d{3}$/.test(digits)) revenueAccount = digits
|
||||
if (/^[123]\d{3}$/.test(digits)) revenueAccount = digits
|
||||
else droppedAccountCount++
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ export function parseArticlesFile(
|
||||
warnings.push(`${vatNoteCount} rad${vatNoteCount === 1 ? '' : 'er'} hade en momssats som avrundades till närmaste giltiga (0/6/12/25 %).`)
|
||||
}
|
||||
if (droppedAccountCount > 0) {
|
||||
warnings.push(`${droppedAccountCount} rad${droppedAccountCount === 1 ? '' : 'er'} hade ett ogiltigt försäljningskonto (måste vara 3xxx) som ignorerades.`)
|
||||
warnings.push(`${droppedAccountCount} rad${droppedAccountCount === 1 ? '' : 'er'} hade ett ogiltigt bokföringskonto (måste vara klass 1-3) som ignorerades.`)
|
||||
}
|
||||
if (rows.length === 0) {
|
||||
warnings.push('Inga giltiga artiklar hittades. Kontrollera att namn-/benämningskolumnen är korrekt mappad.')
|
||||
|
||||
@@ -36,7 +36,7 @@ export interface ParsedArticleRow {
|
||||
* edit step; cleared once the operator confirms the rate. Not persisted.
|
||||
*/
|
||||
vat_rate_adjusted: boolean
|
||||
/** Optional BAS class-3 revenue-account override (validated server-side). */
|
||||
/** Optional BAS class 1-3 posting-account override (validated server-side). */
|
||||
revenue_account: string | null
|
||||
cost_price: number | null
|
||||
ean: string | null
|
||||
|
||||
Reference in New Issue
Block a user