fix(import): actionable hint when a bank CSV lands in the opening-balance importer (#953)
* fix(import): hint when a bank statement is uploaded as opening balances Uploading a bank statement CSV to the opening-balance importer produced the generic 'Inga konton med belopp hittades' error with no clue that the file belongs in the bank-transactions importer (#918, users got stuck together with #915). When the opening-balance parse yields zero account rows, the parser now runs the registered bank-file format detectors over the CSV content (the generic CSV fallback never auto-detects, so any match is a real bank format) and reports the matched format name as detected_bank_format on the parse result. The upload step then shows an actionable Swedish error naming the bank plus a button that routes to the bank-transactions importer (/import?mode=bank). Closes #918 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(import): use the standard bank-import CTA wording (CodeRabbit) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
b21aa84268
commit
982fe77f72
@@ -814,10 +814,12 @@ const OB_STEP_LABELS: Record<OpeningBalanceStep, string> = {
|
||||
function OpeningBalanceFlow() {
|
||||
const { toast } = useToast()
|
||||
const { dialogProps, confirm } = useDestructiveConfirm()
|
||||
const router = useRouter()
|
||||
|
||||
const [obStep, setObStep] = useState<OpeningBalanceStep>('upload')
|
||||
const [obIsLoading, setObIsLoading] = useState(false)
|
||||
const [obError, setObError] = useState<string | null>(null)
|
||||
const [obBankFormatHint, setObBankFormatHint] = useState<string | null>(null)
|
||||
const [obFile, setObFile] = useState<File | null>(null)
|
||||
const [parseResult, setParseResult] = useState<OpeningBalanceParseResult | null>(null)
|
||||
const [editedRows, setEditedRows] = useState<{
|
||||
@@ -836,6 +838,7 @@ function OpeningBalanceFlow() {
|
||||
|
||||
const handleFileSelect = useCallback(async (file: File) => {
|
||||
setObError(null)
|
||||
setObBankFormatHint(null)
|
||||
setObIsLoading(true)
|
||||
setObFile(file)
|
||||
|
||||
@@ -859,7 +862,13 @@ function OpeningBalanceFlow() {
|
||||
setParseResult(result)
|
||||
|
||||
if (result.rows.length === 0) {
|
||||
setObError('Inga konton med belopp hittades i filen. Kontrollera att filen innehåller kontonummer och belopp.')
|
||||
if (result.detected_bank_format) {
|
||||
// The file is a bank statement uploaded to the wrong importer (#918)
|
||||
setObBankFormatHint(result.detected_bank_format)
|
||||
setObError(`Filen ser ut som ett kontoutdrag från ${result.detected_bank_format}, inte ingående balanser. Kontoutdrag importeras under "Banktransaktioner".`)
|
||||
} else {
|
||||
setObError('Inga konton med belopp hittades i filen. Kontrollera att filen innehåller kontonummer och belopp.')
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -981,6 +990,7 @@ function OpeningBalanceFlow() {
|
||||
setEditedRows([])
|
||||
setExecuteResult(null)
|
||||
setObError(null)
|
||||
setObBankFormatHint(null)
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -1016,6 +1026,11 @@ function OpeningBalanceFlow() {
|
||||
onFileSelect={handleFileSelect}
|
||||
isLoading={obIsLoading}
|
||||
error={obError}
|
||||
errorAction={
|
||||
obBankFormatHint
|
||||
? { label: 'Importera banktransaktioner', onClick: () => router.push('/import?mode=bank') }
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user