修复铁路OCR空金额回退(07-28-travel-reimbursement-guide)
这个提交包含在:
@@ -222,7 +222,7 @@ function normalizeFullVatInvoiceInfo(info, documentSubtype) {
|
||||
|
||||
function normalizeElectronicTrainTicket(info) {
|
||||
const taxAmount = toNumberString(info?.Tax);
|
||||
const totalAmount = toNumberString(info?.Total ?? info?.Fare);
|
||||
const totalAmount = toNumberString(info?.Total) ?? toNumberString(info?.Fare);
|
||||
|
||||
return {
|
||||
...buildBaseNormalizedResult({
|
||||
|
||||
@@ -199,6 +199,39 @@ describe("Tencent general invoice OCR", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("falls back to a parseable railway fare when total is an empty string", () => {
|
||||
const normalized = normalizeGeneralInvoiceResult({
|
||||
MixedInvoiceItems: [
|
||||
buildInvoiceItem("ElectronicTrainTicketFull", "ElectronicTrainTicketFull", {
|
||||
Number: "251234",
|
||||
Date: "2026-07-26",
|
||||
Total: "",
|
||||
Fare: "¥100.00",
|
||||
Buyer: "合成公司",
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
expect(normalized.totalAmount).toBe("100.00");
|
||||
expect(normalized.diagnostics.trainAmountFields).toEqual({
|
||||
total: {
|
||||
present: true,
|
||||
isString: true,
|
||||
isNumber: false,
|
||||
nonEmpty: false,
|
||||
parseable: false,
|
||||
},
|
||||
fare: {
|
||||
present: true,
|
||||
isString: true,
|
||||
isNumber: false,
|
||||
nonEmpty: true,
|
||||
parseable: true,
|
||||
},
|
||||
});
|
||||
expect(buildMissingRequiredOcrError("vat", normalized)).toBeNull();
|
||||
});
|
||||
|
||||
it("returns safe terminal quality results for zero, multiple and unsupported invoices", () => {
|
||||
expect(normalizeGeneralInvoiceResult({ MixedInvoiceItems: [] })).toEqual(
|
||||
expect.objectContaining({ qualityError: "invoice_not_detected", documentCount: 0 }),
|
||||
|
||||
在新工单中引用
屏蔽一个用户