feat: add 4 new Swedish bank CSV parsers and improve transaction categorization

Add auto-detecting CSV parsers for Länsförsäkringar, ICA Banken, Skandia,
and Lunar. Refine SEB detection to avoid false matches. Update bank file
upload UI with new bank options and export instructions. Include booking
templates, improved AI categorization, and transaction review enhancements.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jakob Wennberg
2026-02-23 20:38:44 +01:00
co-authored by Claude Opus 4.6
parent 431f385b4b
commit bbb82866ee
24 changed files with 4366 additions and 48 deletions
+42 -1
View File
@@ -1,6 +1,7 @@
import { suggestCategory } from '@/lib/tax/expense-warnings'
import { getExpenseAccountForCategory } from '@/lib/bookkeeping/category-mapping'
import type { Transaction, TransactionCategory, MappingRule } from '@/types'
import { findMatchingTemplates, type TemplateMatch } from '@/lib/bookkeeping/booking-templates'
import type { Transaction, TransactionCategory, EntityType, MappingRule } from '@/types'
export interface SuggestedCategory {
category: TransactionCategory
@@ -177,3 +178,43 @@ export function mergeAiSuggestions(
.sort((a, b) => b.confidence - a.confidence)
.slice(0, 5)
}
// ============================================================
// Template Suggestions
// ============================================================
export interface SuggestedTemplate {
template_id: string
name_sv: string
name_en: string
group: string
debit_account: string
credit_account: string
confidence: number
description_sv: string
risk_level: string
requires_review: boolean
}
/**
* Get suggested booking templates for a transaction.
* Uses multi-signal matching (MCC, keywords, description patterns).
*/
export function getSuggestedTemplates(
transaction: Transaction,
entityType?: EntityType
): SuggestedTemplate[] {
const matches = findMatchingTemplates(transaction, entityType)
return matches.map((m: TemplateMatch) => ({
template_id: m.template.id,
name_sv: m.template.name_sv,
name_en: m.template.name_en,
group: m.template.group,
debit_account: m.template.debit_account,
credit_account: m.template.credit_account,
confidence: m.confidence,
description_sv: m.template.description_sv,
risk_level: m.template.risk_level,
requires_review: m.template.requires_review,
}))
}