const { INVOICE_AMOUNT_EVIDENCE_STATUS, resolveInvoiceAmountEvidence, } = require("../../../src/services/invoiceAmountEvidence"); describe("resolveInvoiceAmountEvidence", () => { it("treats a present amount, including zero, as verified", () => { expect(resolveInvoiceAmountEvidence({ totalAmount: "0.00", ocrAttempts: 0, ocrLastRequestedAt: null, ocrCompletedAt: null, ocrLastError: null, })).toBe(INVOICE_AMOUNT_EVIDENCE_STATUS.verified); }); it("requires manual review when no amount and no OCR execution evidence exist", () => { expect(resolveInvoiceAmountEvidence({ totalAmount: null, ocrAttempts: 0, ocrLastRequestedAt: null, ocrCompletedAt: null, ocrLastError: null, })).toBe(INVOICE_AMOUNT_EVIDENCE_STATUS.manualReview); }); it.each([ ["attempt count", { ocrAttempts: 1 }], ["request time", { ocrLastRequestedAt: new Date("2026-08-30T10:00:00.000Z") }], ["completion time", { ocrCompletedAt: new Date("2026-08-30T10:00:01.000Z") }], ["last error", { ocrLastError: "amount_missing" }], ])("treats missing amount with %s as OCR failed", (_label, evidence) => { expect(resolveInvoiceAmountEvidence({ totalAmount: null, ocrAttempts: 0, ocrLastRequestedAt: null, ocrCompletedAt: null, ocrLastError: null, ...evidence, })).toBe(INVOICE_AMOUNT_EVIDENCE_STATUS.ocrFailed); }); });