phase-3: ingestion, from a QR in the camera to a card in the bandeja
The whole pipeline: storage behind one driver interface (local disk and S3), a portable job queue with a poller, QR and CDC parsing, OCR through the Anthropic API, dedupe, manual entry, and the bandeja that turns all of it into one decision per card. Scanning tries the trustworthy door first: a QR is parsed and prefilled from its CDC; a photo without one is queued for OCR when a key is configured and otherwise opens the manual form against the stored file. A QR that will not parse records an ingest error and falls through rather than losing the photo. Job claiming is the only dialect divergence, as SPEC allows: FOR UPDATE SKIP LOCKED on Postgres, a conditional UPDATE against SQLite's single writer. Retry backoff follows SPEC exactly and a job abandoned by a killed process returns to the queue once its lock goes stale, which is the phase 3 acceptance case. OCR uses structured outputs rather than parsing prose, so the model cannot return anything but the RULES.md schema, and every field is nullable because unreadable is a real answer. Web: scan with live QR decoding (BarcodeDetector, ZXing fallback, wasm served from our own origin), manual entry with the IVA split worked out from the total, the bandeja with swipe, buttons and keyboard all doing the same thing, and the documents list and detail with an editable classification. The seed now carries Maria's 34 purchases and 8 sales and Carlos's 6, all classified through the real rules, plus the two open ingest errors. Two defects found and fixed with tests: seeded documents could be dated in the future, which would corrupt any projection computed from them, and the category buttons announced their keyboard shortcut as part of their name. 255 vitest tests, 37 Playwright tests, rules coverage still 100%, typecheck and lint clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
0d7651b17c
commit
b074456b70
@@ -301,6 +301,58 @@ export const en: Record<MessageKey, string> = {
|
||||
"common.saving": "Saving...",
|
||||
"common.skip": "Skip",
|
||||
|
||||
// Scan, bandeja and documents (phase 3)
|
||||
"scan.title": "Scan",
|
||||
"scan.torch": "Torch",
|
||||
"scan.shutter": "Take the photo",
|
||||
"scan.cameraDenied": "We could not open the camera. You can still upload a photo.",
|
||||
"scan.uploading": "Uploading...",
|
||||
"scan.result.title": "Got it, we read it",
|
||||
"scan.result.emitter": "Issuer",
|
||||
"scan.result.date": "Date",
|
||||
"scan.result.total": "Total",
|
||||
"scan.needsManual": "We could not find the QR. Fill in the details and we will attach your photo.",
|
||||
"scan.another": "Scan another",
|
||||
"scan.goToBandeja": "Go to the inbox",
|
||||
"manual.direction": "Is this a purchase or a sale of yours?",
|
||||
"manual.direction.purchase": "Purchase",
|
||||
"manual.direction.sale": "Sale",
|
||||
"manual.ivaSplit.help": "We work the IVA out from the total. If your factura splits it differently, correct it.",
|
||||
"manual.iva10": "IVA 10%",
|
||||
"manual.iva5": "IVA 5%",
|
||||
"manual.exenta": "Exempt",
|
||||
"manual.regime": "Supplier regime",
|
||||
"manual.regime.normal": "Normal",
|
||||
"manual.regime.resimple": "RESIMPLE",
|
||||
"manual.regime.unknown": "Not sure",
|
||||
"manual.submit": "Save factura",
|
||||
"bandeja.count": "{count} to review",
|
||||
"bandeja.swipeHint": "Swipe right to confirm, left to change the category.",
|
||||
"bandeja.keyboardHint": "With a keyboard: J and K to move, Enter to confirm, 1 to 8 for the category, X to discard.",
|
||||
"bandeja.category": "Category",
|
||||
"bandeja.confidence.high": "High confidence",
|
||||
"bandeja.confidence.low": "Worth a look",
|
||||
"bandeja.whyThis": "Why this category?",
|
||||
"docs.empty": "You have not added any documents yet.",
|
||||
"docs.emptyCta": "Scan the first one",
|
||||
"docs.filter.all": "All",
|
||||
"docs.filter.direction": "Type",
|
||||
"docs.filter.status": "Status",
|
||||
"docs.monthTotal": "Month total",
|
||||
"docs.count": "{count} documents",
|
||||
"docs.detail.title": "Document",
|
||||
"docs.detail.ivaCredit": "IVA credit",
|
||||
"docs.detail.deductible": "Deductible for IRP",
|
||||
"docs.detail.notDeductible": "Not deductible",
|
||||
"docs.detail.source.scan_qr": "Scanned from a QR",
|
||||
"docs.detail.source.scan_ocr": "Read from a photo",
|
||||
"docs.detail.source.manual": "Entered by hand",
|
||||
"docs.errors.title": "Some could not be processed",
|
||||
"docs.errors.retry": "Enter it by hand",
|
||||
"status.needs_review": "To review",
|
||||
"status.confirmed": "Confirmed",
|
||||
"status.rejected": "Discarded",
|
||||
|
||||
// Chrome (es.extra.ts)
|
||||
"common.language": "Language",
|
||||
"common.languageEs": "Español",
|
||||
|
||||
@@ -102,6 +102,58 @@ export const esExtra = {
|
||||
"common.saving": "Guardando...",
|
||||
"common.skip": "Omitir",
|
||||
|
||||
// Scan, bandeja and documents (phase 3)
|
||||
"scan.title": "Escanear",
|
||||
"scan.torch": "Linterna",
|
||||
"scan.shutter": "Sacar la foto",
|
||||
"scan.cameraDenied": "No pudimos abrir la camara. Podés subir una foto igual.",
|
||||
"scan.uploading": "Subiendo...",
|
||||
"scan.result.title": "Listo, la leimos",
|
||||
"scan.result.emitter": "Emisor",
|
||||
"scan.result.date": "Fecha",
|
||||
"scan.result.total": "Total",
|
||||
"scan.needsManual": "No encontramos el QR. Completá los datos y adjuntamos tu foto.",
|
||||
"scan.another": "Escanear otra",
|
||||
"scan.goToBandeja": "Ir a la bandeja",
|
||||
"manual.direction": "¿Es una compra o una venta tuya?",
|
||||
"manual.direction.purchase": "Compra",
|
||||
"manual.direction.sale": "Venta",
|
||||
"manual.ivaSplit.help": "Calculamos el IVA sobre el total. Si tu factura tiene otro reparto, corregilo.",
|
||||
"manual.iva10": "IVA 10%",
|
||||
"manual.iva5": "IVA 5%",
|
||||
"manual.exenta": "Exentas",
|
||||
"manual.regime": "Regimen del proveedor",
|
||||
"manual.regime.normal": "Normal",
|
||||
"manual.regime.resimple": "RESIMPLE",
|
||||
"manual.regime.unknown": "No se",
|
||||
"manual.submit": "Guardar factura",
|
||||
"bandeja.count": "{count} por revisar",
|
||||
"bandeja.swipeHint": "Deslizá a la derecha para confirmar, a la izquierda para cambiar la categoria.",
|
||||
"bandeja.keyboardHint": "Con teclado: J y K para moverte, Enter para confirmar, 1 a 8 para la categoria, X para descartar.",
|
||||
"bandeja.category": "Categoria",
|
||||
"bandeja.confidence.high": "Alta confianza",
|
||||
"bandeja.confidence.low": "Revisar",
|
||||
"bandeja.whyThis": "¿Por que esta categoria?",
|
||||
"docs.empty": "Todavia no cargaste ningun comprobante.",
|
||||
"docs.emptyCta": "Escanear el primero",
|
||||
"docs.filter.all": "Todos",
|
||||
"docs.filter.direction": "Tipo",
|
||||
"docs.filter.status": "Estado",
|
||||
"docs.monthTotal": "Total del mes",
|
||||
"docs.count": "{count} comprobantes",
|
||||
"docs.detail.title": "Comprobante",
|
||||
"docs.detail.ivaCredit": "Credito de IVA",
|
||||
"docs.detail.deductible": "Deducible de IRP",
|
||||
"docs.detail.notDeductible": "No deducible",
|
||||
"docs.detail.source.scan_qr": "Escaneada por QR",
|
||||
"docs.detail.source.scan_ocr": "Leida de una foto",
|
||||
"docs.detail.source.manual": "Cargada a mano",
|
||||
"docs.errors.title": "No pudimos procesar algunas",
|
||||
"docs.errors.retry": "Cargala a mano",
|
||||
"status.needs_review": "Por revisar",
|
||||
"status.confirmed": "Confirmada",
|
||||
"status.rejected": "Descartada",
|
||||
|
||||
// Chrome
|
||||
"common.language": "Idioma",
|
||||
"common.languageEs": "Español",
|
||||
|
||||
Reference in New Issue
Block a user