完善借款、编号、付款与预算并发及验收(09-06-release-gate-integrity)

汇总已落盘的借款本金与还款、兼容历史编号的周期化编号、付款责任与回单核验、报销进度和排序、PWA/采购事务、错误原因与日期校验及ERP退役。
统一共享预算池锁序和锁后判断,恢复差旅原预算选择,补原因码固定夹具及反向完整性检查。
纳入配套迁移、测试、受管QA、分层验收合同、规约及任务记录;原始证据留在ignored artifacts。

关联任务:09-17-company-loan-principal-repayment、09-17-erp-exclusive-retirement、09-18-reimbursement-periodic-numbering、09-08-reimbursement-payment-closeout、09-18-local-concurrency-product-fixes、09-19-budget-pool-concurrency、09-05-error-explainability-payment-readiness。
预算补审由Claude定向验证2文件928项通过,原4446/28及r6结果仍仅对应各自历史输入;本轮未重跑测试。
完整新候选门禁、R1真实入口接入与12项公网义务仍开放。生产编号未启用、差旅仍冻结;不推送、不部署,不宣称发布资格。
这个提交包含在:
2026-09-19 13:11:04 +08:00
父节点 729d90576f
当前提交 1f8d5b658a
共修改 367 个文件,包含 21079 行新增和 12287 行删除
@@ -64,6 +64,11 @@ async function buildApp(options = {}) {
status: "draft",
form_number: "BX-20260408-001",
total_amount: "180.00",
...(options.travelSummary ? {
travel_purpose: "合成出差", travel_location: "合成地点",
travel_start_date: new Date("2026-04-08T00:00:00.000Z"),
travel_end_date: new Date("2026-04-08T00:00:00.000Z"),
} : {}),
};
const approvalRule = options.approvalRule ?? {
id: "55555555-5555-4555-8555-555555555555",
@@ -118,7 +123,7 @@ async function buildApp(options = {}) {
]).map((item) => ({
asset_prior_approval_basis: null,
description: "合成支出",
expense_type: { code: "office_supplies", category: "office", requires_invoice: true },
expense_type: { code: "office_supplies", category: options.travelItem ? "travel" : "office", requires_invoice: true },
invoice_pool_items: [{ id: "invoice-1", total_amount: item.amount }],
...item,
}))),
@@ -314,9 +319,37 @@ describe("reimbursements routes expense standard integration", () => {
missingFields: ["travelPurpose", "travelLocation", "travelStartDate", "travelEndDate"],
}));
expect(tx.workflowInstance.create).not.toHaveBeenCalled();
expect(tx.reimbursementItem.findFirst).not.toHaveBeenCalled();
await app.close();
});
it.each([true, false])("avoids unused bound-invoice counts: per-item guard=%s", async invoiceGuardEnabled => {
resolveEntityPrecheckMock.mockResolvedValue(buildPrecheck());
const { app, tx } = await buildApp({ invoiceGuardEnabled, reimbursementItems: [{
id: "item-no-invoice", amount: "180.00",
expense_type: { code: "office", category: "office", requires_invoice: invoiceGuardEnabled },
}] });
try {
const response = await app.inject({ method: "POST", url: `/api/reimbursements/${REIMBURSEMENT_ID}/submit` });
expect(response.statusCode, response.body).toBe(200);
expect(tx.invoicePool.count).not.toHaveBeenCalled();
expect(tx.reimbursementItem.findFirst).not.toHaveBeenCalled();
expect(tx.reimbursementItem.aggregate).toHaveBeenCalledTimes(1);
expect(tx.workflowHistory.create).toHaveBeenCalled();
} finally { await app.close(); }
});
it("keeps legacy required-invoice rejection when per-item guard is disabled", async () => {
const { app, tx } = await buildApp({ invoiceGuardEnabled: false, boundInvoiceCount: 0 });
try {
const response = await app.inject({ method: "POST", url: `/api/reimbursements/${REIMBURSEMENT_ID}/submit` });
expect(response.statusCode).toBe(400);
expect(response.json().error.details.invoices).toBe("bound_invoice_required");
expect(tx.invoicePool.count).toHaveBeenCalledTimes(1);
expect(tx.workflowInstance.create).not.toHaveBeenCalled();
} finally { await app.close(); }
});
it("rejects submit when the reimbursement has no items", async () => {
const { app, tx } = await buildApp({ reimbursementItems: [] });
@@ -412,6 +445,7 @@ describe("reimbursements routes expense standard integration", () => {
it("skips invoice amount checks for invoice-free allowance items when the guard is on", async () => {
resolveEntityPrecheckMock.mockResolvedValue(buildPrecheck());
const { app } = await buildApp({
travelSummary: true,
invoiceGuardEnabled: true,
boundInvoiceCount: 0,
reimbursementItems: [{
@@ -430,6 +464,7 @@ describe("reimbursements routes expense standard integration", () => {
it("allows an invoice-free allowance-only reimbursement when the guard is off", async () => {
resolveEntityPrecheckMock.mockResolvedValue(buildPrecheck());
const { app } = await buildApp({
travelSummary: true,
invoiceGuardEnabled: false,
boundInvoiceCount: 0,
reimbursementItems: [{
@@ -447,6 +482,7 @@ describe("reimbursements routes expense standard integration", () => {
it("keeps the legacy whole-form invoice requirement for mixed or required items when the guard is off", async () => {
const { app, tx } = await buildApp({
travelSummary: true,
invoiceGuardEnabled: false,
boundInvoiceCount: 0,
reimbursementItems: [
@@ -997,6 +1033,11 @@ describe("reimbursements routes expense standard integration", () => {
});
expect(state.workflowInstanceCreatePayload?.context_data?.budgetCheckRecorded).toBe(true);
expect(resolveApplicableBudgetPoolByContextMock).toHaveBeenCalledWith(expect.any(Object),
expect.any(Object), { forUpdate: true });
const submissionPrecheck = resolveEntityPrecheckMock.mock.calls.find(([arg]) => arg.budgetPoolForWrite?.id === 'aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa');
expect(submissionPrecheck?.[0].budgetPoolForWrite).toMatchObject({ used_amount: '700.00' });
await app.close();
});