修复铁路OCR空金额回退(07-28-travel-reimbursement-guide)
ci-e2e / e2e (push) Canceled after 0s
ci-minimal / check-minimal (push) Canceled after 0s

这个提交包含在:
2026-07-29 15:32:16 +08:00
父节点 5f2788ccac
当前提交 665cf4add5
共修改 4 个文件,包含 58 行新增和 2 行删除
+1 -1
查看文件
@@ -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 }),