const { normalizeVatInvoiceResult, } = require("../../../src/services/ocr/tencent"); describe("tencent VAT OCR normalization", () => { it("normalizes identifiers, date and amounts from Tencent result", () => { const normalized = normalizeVatInvoiceResult({ InvoiceCode: " 0440 0320 4111 ", InvoiceNum: " 1234 5678 ", InvoiceDate: "2026年4月28日", AmountWithoutTax: "1,488.50", TaxAmount: "194.50", AmountInFiguers: "¥1683.00", SellerName: " 北京悦海堂餐饮管理有限公司 ", BuyerName: " 华印公司 ", }); expect(normalized).toEqual( expect.objectContaining({ invoiceCode: "044003204111", invoiceNumber: "12345678", invoiceDate: "2026-04-28", amount: "1488.50", taxAmount: "194.50", totalAmount: "1683.00", sellerName: "北京悦海堂餐饮管理有限公司", buyerName: "华印公司", }), ); }); it("derives amount from total and tax when Tencent omits AmountWithoutTax", () => { const result = normalizeVatInvoiceResult({ InvoiceCode: "044003204111", InvoiceNum: "12345678", InvoiceDate: "2026/04/28", TaxAmount: 194.5, TotalAmount: 1683, SellerName: "北京悦海堂餐饮管理有限公司", BuyerName: "华印公司", }); expect(result).toEqual( expect.objectContaining({ amount: "1488.50", taxAmount: "194.50", totalAmount: "1683.00", }), ); }); });