refactor: consolidate AI analyzers into shared lib/ai module and add journal entry reversal columns

Extract shared vision/document analysis logic into lib/ai (vision-client, document-analyzer,
image preprocessing, validation helpers), simplifying invoice-analyzer, receipt-analyzer, and
document classifier. Add migration 046 for journal entry reversal/correction link columns
(reversed_by_id, reverses_id, correction_of_id) required by storno service. Update extension
components and shared UI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jakob Wennberg
2026-02-26 17:14:44 +01:00
co-authored by Claude Opus 4.6
parent 6d647b956c
commit 3f255ea201
42 changed files with 2090 additions and 1127 deletions
@@ -65,6 +65,7 @@ describe('formatExtractionSummary', () => {
supplierName: '',
total: 0,
lineCount: 0,
currency: 'SEK',
})
})
@@ -73,6 +74,7 @@ describe('formatExtractionSummary', () => {
supplierName: '',
total: 0,
lineCount: 0,
currency: 'SEK',
})
})
@@ -106,6 +108,7 @@ describe('formatExtractionSummary', () => {
supplierName: 'Acme AB',
total: 250,
lineCount: 2,
currency: 'SEK',
})
})
@@ -123,6 +126,7 @@ describe('formatExtractionSummary', () => {
supplierName: '',
total: 0,
lineCount: 0,
currency: 'SEK',
})
})
})
@@ -83,8 +83,8 @@ export const EXTENSION_DEFINITIONS: Record<string, ExtensionDefinition[]> = {
"category": "operations",
"icon": "Calendar",
"dataPattern": "core",
"description": "Fullstandig kalendervy med manads-, vecko- och dagsvisning",
"longDescription": "Se alla fakturadatum och deadlines i en interaktiv kalender med manads-, vecko- och dagsvy.",
"description": "Fullständig kalendervy med månads-, vecko- och dagsvisning",
"longDescription": "Se alla fakturadatum och deadlines i en interaktiv kalender med månads-, vecko- och dagsvy.",
"readsCoreTables": [
"invoices",
"deadlines",
+3 -2
View File
@@ -41,14 +41,15 @@ export function getConfidenceLabel(confidence: number | null): { label: string;
export function formatExtractionSummary(
data: InvoiceExtractionResult | null | undefined
): { supplierName: string; total: number; lineCount: number } {
): { supplierName: string; total: number; lineCount: number; currency: string } {
if (!data) {
return { supplierName: '', total: 0, lineCount: 0 }
return { supplierName: '', total: 0, lineCount: 0, currency: 'SEK' }
}
return {
supplierName: data.supplier?.name ?? '',
total: data.totals?.total ?? 0,
lineCount: data.lineItems?.length ?? 0,
currency: data.invoice?.currency || 'SEK',
}
}