feat(captura): fold recibo OCR into Captura as an automatic mode
Build and Push Images / Build jorgecuadros-web (push) Successful in 1m46s
Build and Push Images / Build jorgecuadros-api (push) Successful in 2m17s

Scanning a stack of bills and keying them in are the same daily job, ending
in the same ledger path, so OCR intake becomes a mode of the capture screen
instead of a second menu entry:

- components/Captura.tsx holds the mode switch; the manual check form moves
  verbatim to components/ManualCheckCapture.tsx and the OCR intake to
  components/StatementIntake.tsx.
- /estado-cuenta/lote opens on manual, /recibos on automatic — both render
  Captura, so batch-review links and old bookmarks still land right.
- Nav drops "Recibos (OCR)"; "Captura" covers both, with a NavLink.aliases
  field so /recibos still highlights it.

Also fixes the "El almacenamiento de documentos no está configurado" failure
staff hit on upload. Uploading with no object storage configured used to
succeed, then die on the first put minutes later, leaving a FAILED batch
whose only explanation was that string. createBatch now refuses up front,
GET /statements/status reports storageAvailable alongside ocrAvailable, and
the intake tab explains the situation instead of offering an upload that
cannot work. S3_* documented in .env.example (deploy stacks already set it).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-01 01:04:09 -07:00
co-authored by Claude Opus 5
parent 4d5008b545
commit b59abda895
13 changed files with 981 additions and 824 deletions
@@ -43,10 +43,17 @@ export class StatementsController {
return (req.user as { id: string } | undefined)?.id ?? "";
}
/** Whether this deployment can OCR at all — the UI hides upload without it. */
/**
* Whether this deployment can ingest scans at all — the UI hides automatic
* capture without it. Both halves are needed: OCR to read the page, object
* storage to keep it.
*/
@Get("status")
async status() {
return { ocrAvailable: await this.statements.ocrAvailable() };
return {
ocrAvailable: await this.statements.ocrAvailable(),
storageAvailable: this.statements.storageAvailable(),
};
}
@Get("batches")
@@ -53,6 +53,11 @@ export class StatementsService {
return this.ocr.available();
}
/** Scans are stored as blobs, so no object storage means no intake. */
storageAvailable(): boolean {
return this.storage.available;
}
// --- ingest ---------------------------------------------------------------
/**
@@ -75,6 +80,14 @@ export class StatementsService {
"El servidor no tiene OCR instalado; no se pueden procesar recibos.",
);
}
// Checked here rather than at the first `put`, which would only surface as
// a FAILED batch minutes later.
if (!this.storage.available) {
throw new BadRequestException(
"El almacenamiento de documentos no está configurado; no se pueden " +
"guardar los recibos escaneados.",
);
}
const batch = await this.prisma.statementBatch.create({
data: { serviceKind, uploadedById, label, fileCount: files.length },
+10
View File
@@ -73,6 +73,16 @@ export class StorageService implements OnModuleInit {
}
}
/**
* Whether the deployment has object storage at all. Callers use this to
* refuse work up front instead of failing halfway through — a recibo batch
* that dies on its first `put` leaves a FAILED batch and no explanation the
* office can act on.
*/
get available(): boolean {
return this.client !== null;
}
private require(): S3Client {
if (!this.client) {
throw new ServiceUnavailableException(