feat(invoice-inbox): receipt-aware extraction + OCR pipeline fixes (#1331)
Receipts and invoices were extracted through one invoice-shaped prompt with no document classification. The extractor now also returns documentKind, payment method (+ card last4), purchaseTime, merchantCategory and legibility, validated with .catch(null) so a hallucinated label degrades to unknown instead of sinking the parse. The FieldsRail shows type and payment method above the editable fields. Pipeline fixes, all verified against real failure paths: - PDFs >3 pages: extract from a pdf-lib slice of the first 3 pages instead of skipping entirely (issue #553 gate); truncation recorded in extracted_data.pages and shown in the UI. - Oversized images (>4 MB, over Bedrock's 5 MB cap): downscale to <=2000px JPEG via sharp before base64, instead of erroring to an empty result. - HEIC/HEIF: attempt sharp transcode to JPEG; when libvips lacks HEIF (prebuilt binaries), fall through to today's behavior but show an explicit hint instead of silently blank fields. - Oresavrundning: prompt rule + totals.roundingAmount so receipt totals reconcile with subtotal+VAT for exact-amount transaction matching. - retry-extraction overwrites extracted_data wholesale: a confirm now guards against silently destroying manual field edits. Deliberately NOT added: retry-on-transient-Bedrock-error; the SDK already retries twice by default (maxRetries=2). Co-authored-by: Jakob Wennberg <jakob.wennberg@gmail.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Jakob Wennberg
Claude Fable 5
parent
b1f71912a2
commit
3b3adf96c7
+16
-1
@@ -2797,7 +2797,22 @@
|
||||
"document_loading": "Fetching the document…",
|
||||
"document_load_failed": "The document is still stored but could not be shown right now.",
|
||||
"email_body_label": "Email content",
|
||||
"email_body_empty": "The email had no text."
|
||||
"email_body_empty": "The email had no text.",
|
||||
"doc_kind_label": "Type",
|
||||
"doc_kind_receipt": "Receipt",
|
||||
"doc_kind_supplier_invoice": "Supplier invoice",
|
||||
"doc_kind_government_letter": "Government letter",
|
||||
"doc_kind_other": "Other document",
|
||||
"payment_label": "Paid with",
|
||||
"payment_card": "Card",
|
||||
"payment_swish": "Swish",
|
||||
"payment_cash": "Cash",
|
||||
"payment_invoice": "Invoiced",
|
||||
"payment_other": "Other",
|
||||
"pages_partial_note": "Extracted from the first {analyzed} of {total} pages.",
|
||||
"heic_hint": "HEIC images cannot be AI-extracted yet. Upload the receipt as JPEG or PDF, or fill in the fields manually.",
|
||||
"skipped_hint": "AI extraction did not run for this document. You can link the document to a transaction or create a supplier invoice manually.",
|
||||
"retry_overwrite_confirm": "Re-running extraction overwrites the fields, including your own edits. Continue?"
|
||||
},
|
||||
"inbox_custom_domain": {
|
||||
"title": "Custom inbox domain",
|
||||
|
||||
+16
-1
@@ -2797,7 +2797,22 @@
|
||||
"document_loading": "Hämtar underlaget…",
|
||||
"document_load_failed": "Underlaget finns kvar men kunde inte visas just nu.",
|
||||
"email_body_label": "Mejlets innehåll",
|
||||
"email_body_empty": "Mejlet hade ingen text."
|
||||
"email_body_empty": "Mejlet hade ingen text.",
|
||||
"doc_kind_label": "Typ",
|
||||
"doc_kind_receipt": "Kvitto",
|
||||
"doc_kind_supplier_invoice": "Leverantörsfaktura",
|
||||
"doc_kind_government_letter": "Myndighetsbrev",
|
||||
"doc_kind_other": "Övrigt dokument",
|
||||
"payment_label": "Betalsätt",
|
||||
"payment_card": "Kort",
|
||||
"payment_swish": "Swish",
|
||||
"payment_cash": "Kontant",
|
||||
"payment_invoice": "Faktureras",
|
||||
"payment_other": "Annat",
|
||||
"pages_partial_note": "Tolkad från de första {analyzed} av {total} sidorna.",
|
||||
"heic_hint": "HEIC-bilder kan inte AI-tolkas ännu. Ladda upp kvittot som JPEG eller PDF, eller fyll i fälten manuellt.",
|
||||
"skipped_hint": "AI-tolkning kördes inte för det här dokumentet. Du kan koppla dokumentet till en transaktion eller skapa leverantörsfaktura manuellt.",
|
||||
"retry_overwrite_confirm": "Ny tolkning skriver över fälten, även ändringar du gjort själv. Fortsätta?"
|
||||
},
|
||||
"inbox_custom_domain": {
|
||||
"title": "Egen domän för inkorgen",
|
||||
|
||||
Reference in New Issue
Block a user