R56 A1-A6:费用标准管控
这个提交包含在:
@@ -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: {
|
||||
|
||||
在新工单中引用
屏蔽一个用户