修复报销票据门禁提示与 OCR 降级(08-30-b2-submit-error-ocr-fallback)

这个提交包含在:
2026-08-31 20:20:20 +08:00
父节点 8b19538584
当前提交 f57e2236f2
共修改 21 个文件,包含 1829 行新增和 49 行删除
@@ -0,0 +1,42 @@
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);
});
});