Files
accounted/lib/documents/classifier.ts
T
Jakob Wennberg 3f255ea201 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>
2026-02-26 17:14:44 +01:00

28 lines
860 B
TypeScript

/**
* Document Classifier — thin wrapper around lib/ai/document-analyzer.
*
* SERVER-ONLY: delegates to the shared vision client.
*
* Classifies documents as supplier invoices, receipts, government letters,
* or unknown. Also detects EU reverse charge for supplier invoices.
*
* This module preserves the original public API — existing callers see no change.
*/
import 'server-only'
import { classifyDocument as classifyCore } from '@/lib/ai/document-analyzer'
// Re-export the type so existing imports work
export type { DocumentClassification } from '@/lib/ai/document-analyzer'
/**
* Classify a document using Claude Haiku Vision.
* Determines if it's a supplier invoice, receipt, government letter, or unknown.
*/
export async function classifyDocument(
base64: string,
mimeType: string
) {
return classifyCore(base64, mimeType)
}