fix: 修复真实验收中的企业范围与草稿复制问题

显式企业身份核验只访问指定企业,避免回退到全量查询。
复制只清空源单存在的发票与附件字段,避免通用模板拒绝未知属性。
补充隔离回归与指定测试企业验收记录,测试数据已清理。

验证:929 项测试通过,类型检查及版本一致性检查通过。
This commit is contained in:
gitea committed 2026-10-29 22:04:36 +08:00
1 parent 6249feee23
commit 613fe3476c
8 files changed
+108 -14

No files matched your search

+1
View File
@@ -65,6 +65,7 @@ src/domains/bill/
10. **纯接口复制 (`copyBillAsDraft`)**:
- 读取服务端最新的 `flow.form`;
- 清空发票绑定(`invoiceForm.invoices`)、明细与单据发票总额归零、剔除 `detailStatus`;
- 只重置源单实际包含的发票字段,不向通用模板注入 `u_发票总金额` 等租户自定义属性。
- 重算报销/支付金额,附件默认保留;
- `POST /api/flow/v1/flows` 创建新草稿(`name: freeflow.edit`),默认不提交。
11. **草稿删除 (`deleteBillDraft`)**:
+6 -6
View File
@@ -81,20 +81,20 @@ export function buildBillCopyForm(
amountSum += moneyNumber(ft.amount);
// 复制不携带发票绑定;发票总额归零
ft.invoice = "0";
ft.invoiceForm = { type: "exist", invoices: [] };
ft.u_发票总金额 = zeroMoney(ft.u_发票总金额);
if (ft.invoice !== undefined) ft.invoice = "0";
if (ft.invoiceForm !== undefined) ft.invoiceForm = { type: "exist", invoices: [] };
if (ft.u_发票总金额 !== undefined) ft.u_发票总金额 = zeroMoney(ft.u_发票总金额);
delete ft.detailStatus;
if (!keepAttachments) {
if (!keepAttachments && ft.attachments !== undefined) {
ft.attachments = [];
}
}
form.u_发票总金额 = zeroMoney(form.u_发票总金额);
if (form.u_发票总金额 !== undefined) form.u_发票总金额 = zeroMoney(form.u_发票总金额);
form.expenseMoney = { ...(form.expenseMoney ?? {}), standard: amountSum.toFixed(2) };
form.payMoney = { ...(form.payMoney ?? {}), standard: (amountSum - moneyNumber(form.writtenOffMoney)).toFixed(2) };
if (!keepAttachments) {
if (!keepAttachments && form.attachments !== undefined) {
form.attachments = [];
}
+11
View File
@@ -61,6 +61,17 @@ function fixture(options: {
}
describe("bill API write contracts", () => {
test("复制通用模板不注入源单没有的发票或租户自定义字段", async () => {
const { client, writes } = fixture();
await copyBillAsDraft(client, "corp", "f", { keepAttachments: false });
expect(writes).toHaveLength(1);
expect(writes[0].json.form).not.toHaveProperty("u_发票总金额");
expect(writes[0].json.form.details[0].feeTypeForm).not.toHaveProperty("u_发票总金额");
expect(writes[0].json.form.details[0].feeTypeForm).not.toHaveProperty("invoice");
expect(writes[0].json.form.details[0].feeTypeForm).not.toHaveProperty("invoiceForm");
expect(writes[0].json.form).not.toHaveProperty("attachments");
expect(writes[0].json.form.details[0].feeTypeForm).not.toHaveProperty("attachments");
});
test("创建和预演均拒绝缺失明细规格、必填明细与过长表头,不发起创建", async () => {
for (const options of [{ missingDetailSpec: true }, { detailRequired: "u_项目" }, { titleMaxLength: 1 }]) {
const { client, writes } = fixture(options);