fix: 优先引导下载银行制单(09-08-reimbursement-payment-closeout)
这个提交包含在:
@@ -1,6 +1,7 @@
|
||||
const fs = require("node:fs");
|
||||
const os = require("node:os");
|
||||
const path = require("node:path");
|
||||
const { spawnSync } = require("node:child_process");
|
||||
|
||||
const { encryptStringOrThrow } = require("../../../src/services/crypto");
|
||||
const {
|
||||
@@ -51,6 +52,43 @@ describe("payment order BIFF8 generator", () => {
|
||||
expect(first.totalAmount).toBe("3.20");
|
||||
});
|
||||
|
||||
it("round-trips the bank template with exact text accounts, headers and decimal amounts", () => {
|
||||
const batch = buildBatch();
|
||||
const payerAccount = "000123456789012345678";
|
||||
const payeeAccount = "000987654321098765432";
|
||||
batch.payment_account_snapshot_json.accountNumberEncrypted = encrypt(payerAccount);
|
||||
batch.items[1].snapshot_json.payee.bankAccountEncrypted = encrypt(payeeAccount);
|
||||
const generated = generatePaymentOrderXls(config, batch);
|
||||
const templatePath = path.resolve(__dirname, "../../../src/assets/payment-order/ccb-payment-order-template.xls");
|
||||
const readback = spawnSync(process.env.PAYMENT_ORDER_PYTHON_BIN ?? "python3", ["-c", [
|
||||
"import json,sys,xlrd",
|
||||
"book=xlrd.open_workbook(file_contents=sys.stdin.buffer.read(),formatting_info=True)",
|
||||
"template=xlrd.open_workbook(sys.argv[1],formatting_info=True)",
|
||||
"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]}))",
|
||||
].join("\n"), templatePath], { input: generated.buffer, maxBuffer: 1024 * 1024 });
|
||||
expect(readback.stderr.toString("utf8")).toBe("");
|
||||
expect(readback.status).toBe(0);
|
||||
const parsed = JSON.parse(readback.stdout.toString("utf8"));
|
||||
expect(parsed).toMatchObject({
|
||||
biff: 80,
|
||||
sheets: ["Sheet1", "Sheet2", "Sheet3"],
|
||||
columns: 15,
|
||||
headerMatches: true,
|
||||
widthsMatch: true,
|
||||
textTypes: [[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", "", "",
|
||||
]);
|
||||
expect(parsed.rows[1][9]).toBe(2);
|
||||
});
|
||||
|
||||
it("fails the whole export and reports every blocking payee issue", () => {
|
||||
const batch = buildBatch();
|
||||
batch.items[1].snapshot_json.payee.bankInstitutionCode = "OTHER";
|
||||
|
||||
在新工单中引用
屏蔽一个用户