fix: 完善报销制单备注(09-08-reimbursement-payment-closeout)

这个提交包含在:
2026-09-11 22:27:40 +08:00
父节点 5d8cdf12b4
当前提交 2b4e3faa0e
共修改 5 个文件,包含 74 行新增和 5 行删除
+1 -1
查看文件
@@ -156,7 +156,7 @@ function buildPaymentOrderRows(config, batch) {
serial,
Number(amount.toFixed(2)),
"报销款",
entityCode,
`${payeeName}报销款 ${entityCode}`,
"0",
"",
"",
@@ -7,6 +7,7 @@ const { encryptStringOrThrow } = require("../../../src/services/crypto");
const {
PaymentOrderXlsError,
buildCustomerSerial,
buildPaymentOrderRows,
generatePaymentOrderXls,
} = require("../../../src/services/paymentOrderXls");
@@ -42,6 +43,41 @@ function buildBatch(overrides = {}) {
}
describe("payment order BIFF8 generator", () => {
it("uses frozen payee names and keeps separate rows for the same payee", () => {
const batch = buildBatch();
for (const item of batch.items) {
item.snapshot_json.payee.name = " 合成收款人 ";
item.snapshot_json.submitter = { name: "合成提交人" };
item.owner = { name: "已改名归属人" };
}
const result = buildPaymentOrderRows(config, batch);
expect(result.rows.map((row) => row.slice(10, 12))).toEqual([
["报销款", "合成收款人报销款 BX-20260802-0001"],
["报销款", "合成收款人报销款 BX-20260802-0002"],
]);
expect(result.serials).toEqual(["PB-20260802-002-R001", "PB-20260802-002-R002"]);
expect(result.totalAmount).toBe("3.20");
});
it("preserves complete names and document codes without truncation", () => {
const batch = buildBatch();
const name = "合成姓名".repeat(20);
const code = "BX-20260802-000123456789";
batch.items = [batch.items[0]];
batch.items[0].snapshot_json.payee.name = ` ${name} `;
batch.items[0].entity_code = ` ${code} `;
expect(buildPaymentOrderRows(config, batch).rows[0][11]).toBe(`${name}报销款 ${code}`);
});
it.each([
["payee_name_missing", (item) => { item.snapshot_json.payee.name = " "; }],
["entity_code_missing", (item) => { item.entity_code = " "; }],
])("rejects the entire export for %s", (code, invalidate) => {
const batch = buildBatch();
invalidate(batch.items[0]);
expect(() => buildPaymentOrderRows(config, batch)).toThrow(expect.objectContaining({ code }));
});
it("generates a BIFF8 workbook with stable rows, totals and customer serials", () => {
const first = generatePaymentOrderXls(config, buildBatch());
const second = generatePaymentOrderXls(config, buildBatch());
@@ -67,7 +103,7 @@ describe("payment order BIFF8 generator", () => {
"sheet=book.sheet_by_index(0)",
"source=template.sheet_by_index(0)",
"rows=[row for row in range(1,sheet.nrows) if sheet.cell_value(row,0) != '']",
"print(json.dumps({'biff':book.biff_version,'sheets':book.sheet_names(),'columns':sheet.ncols,'headerMatches':sheet.row_values(0)==source.row_values(0),'widthsMatch':all(sheet.computed_column_width(col)==source.computed_column_width(col) for col in range(15)),'rows':[sheet.row_values(row) for row in rows],'textTypes':[[sheet.cell_type(row,col) for col in [1,3,4,8]] for row in rows],'amountFormats':[book.format_map[book.xf_list[sheet.cell_xf_index(row,9)].format_key].format_str for row in rows]}))",
"print(json.dumps({'biff':book.biff_version,'sheets':book.sheet_names(),'columns':sheet.ncols,'headerMatches':sheet.row_values(0)==source.row_values(0),'widthsMatch':all(sheet.computed_column_width(col)==source.computed_column_width(col) for col in range(15)),'rows':[sheet.row_values(row) for row in rows],'textTypes':[[sheet.cell_type(row,col) for col in [1,3,4,8,10,11]] for row in rows],'amountFormats':[book.format_map[book.xf_list[sheet.cell_xf_index(row,9)].format_key].format_str for row in rows]}))",
].join("\n"), templatePath], { input: generated.buffer, maxBuffer: 1024 * 1024 });
expect(readback.stderr.toString("utf8")).toBe("");
expect(readback.status).toBe(0);
@@ -78,15 +114,16 @@ describe("payment order BIFF8 generator", () => {
columns: 15,
headerMatches: true,
widthsMatch: true,
textTypes: [[1, 1, 1, 1], [1, 1, 1, 1]],
textTypes: [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]],
amountFormats: ["0.00", "0.00"],
});
expect(parsed.rows).toHaveLength(2);
expect(parsed.rows[0]).toEqual([
"1", payerAccount, "合成测试公司", "01", payeeAccount, "甲", "中国建设银行", "",
"PB-20260802-002-R001", 1.2, "报销款", "BX-20260802-0001", "0", "", "",
"PB-20260802-002-R001", 1.2, "报销款", "甲报销款 BX-20260802-0001", "0", "", "",
]);
expect(parsed.rows[1][9]).toBe(2);
expect(parsed.rows[1].slice(10, 12)).toEqual(["报销款", "乙报销款 BX-20260802-0002"]);
});
it("fails the whole export and reports every blocking payee issue", () => {