实现企业银行账户与建行制单(corporate-bank-account-payment-order)

这个提交包含在:
2026-08-02 23:36:40 +08:00
父节点 f946d64539
当前提交 5261d2849b
共修改 46 个文件,包含 2751 行新增和 73 行删除
@@ -0,0 +1,42 @@
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 { generatePaymentOrderXls } = require("../src/services/paymentOrderXls");
const temporaryDirectory = fs.mkdtempSync(path.join(os.tmpdir(), "payment-order-xls-"));
const outputPath = path.join(temporaryDirectory, "synthetic-order.xls");
try {
const fieldEncryptionKey = Buffer.alloc(32, 7).toString("base64");
const config = { fieldEncryptionKey };
const encrypt = (value) => encryptStringOrThrow(config, value);
const generated = generatePaymentOrderXls(config, {
batch_no: "PB-20260802-001",
payment_account_snapshot_json: { bankInstitutionCode: "CCB", accountName: "合成测试公司", accountNumberEncrypted: encrypt("6217000000000012345") },
items: [{ id: "1", entity_code: "BX-20260802-0001", amount: "1586.00", snapshot_json: { payee: { name: "合成员工", bankName: "中国建设银行", bankInstitutionCode: "CCB", bankAccountEncrypted: encrypt("6222000000000056789") } } }],
});
fs.writeFileSync(outputPath, generated.buffer);
const check = spawnSync("python3", ["-c", [
"import sys,xlrd",
"book=xlrd.open_workbook(sys.argv[1])",
"assert book.sheet_names()==['Sheet1','Sheet2','Sheet3']",
"assert [(s.nrows,s.ncols) for s in book.sheets()]==[(2,15),(0,0),(0,0)]",
"sheet=book.sheet_by_index(0)",
"assert sheet.cell_type(1,1)==xlrd.XL_CELL_TEXT and sheet.cell_value(1,1)=='6217000000000012345'",
"assert sheet.cell_type(1,3)==xlrd.XL_CELL_TEXT and sheet.cell_value(1,3)=='01'",
"assert sheet.cell_type(1,4)==xlrd.XL_CELL_TEXT and sheet.cell_value(1,4)=='6222000000000056789'",
"assert sheet.cell_type(1,8)==xlrd.XL_CELL_TEXT",
"assert sheet.cell_type(1,9)==xlrd.XL_CELL_NUMBER and sheet.cell_value(1,9)==1586.0",
"assert sheet.cell_value(1,10)=='报销款' and sheet.cell_value(1,5)=='合成员工'",
].join(";"), outputPath], { encoding: "utf8" });
if (check.status !== 0) {
process.stderr.write(check.stderr || check.stdout || "xlrd roundtrip failed\n");
process.exitCode = 1;
} else {
process.stdout.write("[payment-order-xls][PASS] xlrd BIFF8 roundtrip verified\n");
}
} finally {
fs.rmSync(temporaryDirectory, { recursive: true, force: true });
}