const INVOICE_AMOUNT_EVIDENCE_STATUS = Object.freeze({ verified: "verified", manualReview: "manual_review", ocrFailed: "ocr_failed", }); function resolveInvoiceAmountEvidence({ totalAmount, ocrAttempts, ocrLastRequestedAt, ocrCompletedAt, ocrLastError, }) { if (totalAmount != null) { return INVOICE_AMOUNT_EVIDENCE_STATUS.verified; } const hasOcrExecutionEvidence = Number(ocrAttempts ?? 0) > 0 || ocrLastRequestedAt != null || ocrCompletedAt != null || (typeof ocrLastError === "string" && ocrLastError.trim().length > 0); return hasOcrExecutionEvidence ? INVOICE_AMOUNT_EVIDENCE_STATUS.ocrFailed : INVOICE_AMOUNT_EVIDENCE_STATUS.manualReview; } module.exports = { INVOICE_AMOUNT_EVIDENCE_STATUS, resolveInvoiceAmountEvidence, };