R56 A1-A6:费用标准管控

这个提交包含在:
2026-04-08 12:47:40 +08:00
父节点 40c3b7632a
当前提交 845558ab17
共修改 25 个文件,包含 2993 行新增和 10 行删除
+26 -1
查看文件
@@ -663,16 +663,37 @@ function buildBudgetHint(budgetPool, reimbursementAmount, controlMode) {
}
function buildPrecheckBlockedError(precheck) {
const standardViolations = Array.isArray(precheck?.standardChecks)
? precheck.standardChecks.filter((item) => item.exceeded && item.controlMode === "block")
: [];
return new AppError({
code: "VALID_001",
message: "参数校验失败",
statusCode: 409,
statusCode: standardViolations.length ? 400 : 409,
details: {
precheck: precheck.blockingReasons,
...(standardViolations.length ? { standardViolations } : {}),
},
});
}
function listExceededStandardViolations(precheck, controlMode = null) {
if (!Array.isArray(precheck?.standardChecks)) {
return [];
}
return precheck.standardChecks.filter((item) => {
if (!item.exceeded) {
return false;
}
if (!controlMode) {
return true;
}
return item.controlMode === controlMode;
});
}
function buildSkippedNotificationResult(reason) {
return { skipped: true, reason };
}
@@ -2079,6 +2100,8 @@ async function reimbursementRoutes(fastify) {
if (authoritativePrecheck.decision === "block") {
throw buildPrecheckBlockedError(authoritativePrecheck);
}
const standardViolations = listExceededStandardViolations(authoritativePrecheck);
const standardWarnings = listExceededStandardViolations(authoritativePrecheck, "warn");
const openedRiskFlags = await createRiskFlagsFromPrecheck(tx, {
entityType: "reimbursement",
entityId: reimbursementId,
@@ -2238,6 +2261,7 @@ async function reimbursementRoutes(fastify) {
department_id: reimbursement.department_id,
workflow_steps_snapshot: workflowSteps,
approval_rule_id: approvalRule.id,
standardViolations,
},
context_department_id: reimbursement.department_id,
created_by: request.employee.id,
@@ -2319,6 +2343,7 @@ async function reimbursementRoutes(fastify) {
status: "reviewing",
budget: budgetCheck,
precheckDecision: authoritativePrecheck.decision,
standardWarnings,
openedRiskFlagCount: openedRiskFlags.length,
},
sideEffectsContext: {