增加铁路OCR金额字段安全诊断(07-28-travel-reimbursement-guide)
这个提交包含在:
@@ -139,12 +139,66 @@ describe("Tencent general invoice OCR", () => {
|
||||
totalAmount: "553.00",
|
||||
sellerName: null,
|
||||
buyerName: "合成公司",
|
||||
diagnostics: {
|
||||
trainAmountFields: {
|
||||
total: {
|
||||
present: true,
|
||||
isString: true,
|
||||
isNumber: false,
|
||||
nonEmpty: true,
|
||||
parseable: true,
|
||||
},
|
||||
fare: {
|
||||
present: false,
|
||||
isString: false,
|
||||
isNumber: false,
|
||||
nonEmpty: false,
|
||||
parseable: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(buildMissingRequiredOcrError("vat", normalized)).toBeNull();
|
||||
expect(shouldDeduplicateByInvoiceNumberOnly(normalized)).toBe(true);
|
||||
expect(JSON.stringify(normalized)).not.toContain("SENSITIVE-");
|
||||
});
|
||||
|
||||
it("reports only boolean railway amount field diagnostics", () => {
|
||||
const normalized = normalizeGeneralInvoiceResult({
|
||||
MixedInvoiceItems: [
|
||||
buildInvoiceItem("ElectronicTrainTicketFull", "ElectronicTrainTicketFull", {
|
||||
Number: "251234",
|
||||
Date: "2026-07-26",
|
||||
Fare: "not-a-number-sensitive-marker",
|
||||
Buyer: "合成公司",
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
expect(normalized.diagnostics).toEqual({
|
||||
trainAmountFields: {
|
||||
total: {
|
||||
present: false,
|
||||
isString: false,
|
||||
isNumber: false,
|
||||
nonEmpty: false,
|
||||
parseable: false,
|
||||
},
|
||||
fare: {
|
||||
present: true,
|
||||
isString: true,
|
||||
isNumber: false,
|
||||
nonEmpty: true,
|
||||
parseable: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(JSON.stringify(normalized.diagnostics)).not.toContain("sensitive-marker");
|
||||
expect(sanitizeOcrResultForPersistence("tencent", normalized)).not.toHaveProperty(
|
||||
"diagnostics",
|
||||
);
|
||||
});
|
||||
|
||||
it("returns safe terminal quality results for zero, multiple and unsupported invoices", () => {
|
||||
expect(normalizeGeneralInvoiceResult({ MixedInvoiceItems: [] })).toEqual(
|
||||
expect.objectContaining({ qualityError: "invoice_not_detected", documentCount: 0 }),
|
||||
|
||||
在新工单中引用
屏蔽一个用户