fix(import): show "created on import" as the mapping target for source accounts the chart lacks (#2342)
The guided Fortnox import self-mapped a source account that exists in neither the company chart nor BAS (4599) and then rendered its Malkonto select blank, because the dropdown only knew chart + BAS accounts. The row looked unmapped and unmappable while the import created the account correctly. A nameless account (referenced by #TRANS without #KONTO) was worse: the mapper refused the self-map, so it stayed unmapped with no self-target to pick. - account-mapper: the bas_range self-map no longer requires a #KONTO name; unmapped now means exactly "outside 1000-8999". isValidBASRange exported as the auto-create boundary. - AccountMappingStep (shared by both wizards): a target the list cannot name is an explicit "<nr> <name> (skapas vid importen)" option, a "nya konton skapas" badge/filter lists them, out-of-range accounts that block Continue are named, nameless sources say so. - sie-import: skippedVouchers.unmappedAccounts (per account, voucher count) via summarizeUnmappedSkips; warning names the accounts. - Migration result step: names created accounts and the accounts behind "med ej kopplade konton". Closes #2212 Claude-Session: https://claude.ai/code/session_019SaJfqNi4VmsG8FMKq99G6 Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Jakob Wennberg
Claude Fable 5.1
parent
ea4da0eb07
commit
162de2128a
@@ -108,6 +108,20 @@ describe('suggestMappings', () => {
|
||||
expect(result[0].matchType).toBe('bas_range')
|
||||
})
|
||||
|
||||
// Issue #2212: an account referenced only by #TRANS/#IB arrives without a
|
||||
// #KONTO name. Refusing the self-map left it unmapped with no self-target to
|
||||
// pick, while the parser had already promised it would be created.
|
||||
it('self-maps a nameless in-range account (referenced without #KONTO)', () => {
|
||||
const source = [makeSIEAccount('4599', '')]
|
||||
const result = suggestMappings(source, basAccounts)
|
||||
|
||||
expect(result).toHaveLength(1)
|
||||
expect(result[0].targetAccount).toBe('4599')
|
||||
expect(result[0].targetName).toBe('')
|
||||
expect(result[0].matchType).toBe('bas_range')
|
||||
expect(result[0].confidence).toBe(0.7)
|
||||
})
|
||||
|
||||
it('does not self-map accounts outside BAS range (9000+)', () => {
|
||||
const source = [makeSIEAccount('9100', 'Internt konto')]
|
||||
const result = suggestMappings(source, basAccounts)
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
ensureFiscalPeriod,
|
||||
precheckFiscalPeriod,
|
||||
importVouchers,
|
||||
summarizeUnmappedSkips,
|
||||
computeVoucherNumberRanges,
|
||||
linkOpeningBalanceEntryToPeriod,
|
||||
companyHasPriorActivity,
|
||||
@@ -1845,3 +1846,25 @@ describe('precheckFiscalPeriod', () => {
|
||||
).rejects.toThrow(precheck.verdict === 'conflict' ? precheck.message : 'unreachable')
|
||||
})
|
||||
})
|
||||
|
||||
describe('summarizeUnmappedSkips', () => {
|
||||
// Issue #2212: the result step must name WHICH accounts excluded vouchers,
|
||||
// not just how many vouchers were excluded.
|
||||
it('counts vouchers per unmapped account, most excluded first', () => {
|
||||
const summary = summarizeUnmappedSkips([
|
||||
{ reason: 'unmapped', unmappedAccounts: ['0099'] },
|
||||
{ reason: 'unmapped', unmappedAccounts: ['0099', '9100'] },
|
||||
{ reason: 'unmapped', unmappedAccounts: ['9100', '9100'] },
|
||||
{ reason: 'unbalanced' },
|
||||
{ reason: 'single_line', unmappedAccounts: ['0099'] },
|
||||
])
|
||||
expect(summary).toEqual([
|
||||
{ account: '0099', vouchers: 2 },
|
||||
{ account: '9100', vouchers: 2 },
|
||||
])
|
||||
})
|
||||
|
||||
it('is empty when nothing was skipped for a missing mapping', () => {
|
||||
expect(summarizeUnmappedSkips([{ reason: 'empty' }])).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user