feat(P17B-1,P17B-2): 补齐采购预算闭环与归档模型接口
这个提交包含在:
@@ -0,0 +1,41 @@
|
||||
const {
|
||||
summarizeBudgetLedgerByPool,
|
||||
buildPurchaseBudgetValidationError,
|
||||
} = require("../../../src/services/purchaseBudget");
|
||||
|
||||
describe("purchaseBudget service", () => {
|
||||
it("summarizes reserve confirm release by pool", () => {
|
||||
expect(
|
||||
summarizeBudgetLedgerByPool([
|
||||
{ budget_pool_id: "pool-1", kind: "reserve", amount: "120.00" },
|
||||
{ budget_pool_id: "pool-1", kind: "confirm", amount: "120.00" },
|
||||
{ budget_pool_id: "pool-1", kind: "release", amount: "20.00" },
|
||||
{ budget_pool_id: "pool-2", kind: "reserve", amount: "80.00" },
|
||||
]),
|
||||
).toEqual([
|
||||
{
|
||||
budgetPoolId: "pool-1",
|
||||
reserve: 120,
|
||||
confirm: 120,
|
||||
release: 20,
|
||||
outstanding: 100,
|
||||
confirmPending: 0,
|
||||
},
|
||||
{
|
||||
budgetPoolId: "pool-2",
|
||||
reserve: 80,
|
||||
confirm: 0,
|
||||
release: 0,
|
||||
outstanding: 80,
|
||||
confirmPending: 80,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("builds VALID_001 validation error", () => {
|
||||
const error = buildPurchaseBudgetValidationError({ budget: "reserve_already_exists" });
|
||||
expect(error.code).toBe("VALID_001");
|
||||
expect(error.statusCode).toBe(409);
|
||||
expect(error.details).toEqual({ budget: "reserve_already_exists" });
|
||||
});
|
||||
});
|
||||
在新工单中引用
屏蔽一个用户