fix(cma): NP-001 verdict 口径统一(block→blocked)——命中即置 check_result=blocked

_eval_np001 原将 verdict 直取 severity('block'),而 check_result 汇总只认 'blocked'
→ e1 命中不生效、check_result 恒 pass,T4 豁免级联失败。改为 severity=='block'→'blocked'。

Ref: 0-P0-project-20260915-cma-treasury-stage1 自验电池 T3/T3b/T4
This commit is contained in:
Hermes CI Fix
2026-09-16 14:44:06 +08:00
parent f1fa781e08
commit 09fb11d86f
+3 -2
View File
@@ -159,7 +159,8 @@ def _eval_np001(db, entity_id, payment, rule) -> dict:
budget_value, scope = bp.budget_value, f"kpi:{bp.kpi_id}@{period}" budget_value, scope = bp.budget_value, f"kpi:{bp.kpi_id}@{period}"
this_amt = _r(payment.amount) this_amt = _r(payment.amount)
if budget_value is None: if budget_value is None:
return {"rule_code": "NP-001", "verdict": severity, "severity": severity, return {"rule_code": "NP-001", "verdict": ("blocked" if severity == "block" else severity),
"severity": severity,
"detail": _hit_detail("NP-001", rule.rule_version, "none", None, this_amt, "detail": _hit_detail("NP-001", rule.rule_version, "none", None, this_amt,
(params.get("unmatched") or "specify_budget_flow") (params.get("unmatched") or "specify_budget_flow")
+ "(未匹配到预算:走指定/补录预算流程并留痕,不直接卡死)")} + "(未匹配到预算:走指定/补录预算流程并留痕,不直接卡死)")}
@@ -175,7 +176,7 @@ def _eval_np001(db, entity_id, payment, rule) -> dict:
prev = float(q.scalar() or 0) prev = float(q.scalar() or 0)
cumulative = _r(prev + this_amt) cumulative = _r(prev + this_amt)
ok = cumulative <= float(budget_value) + TOL ok = cumulative <= float(budget_value) + TOL
verdict = "pass" if ok else severity verdict = "pass" if ok else ("blocked" if severity == "block" else severity)
basis = ("占用口径 %s;占用=已支付+已审批未支付+本单" % (params.get("occupancy") or "paid+approved+pending_approval+this")) basis = ("占用口径 %s;占用=已支付+已审批未支付+本单" % (params.get("occupancy") or "paid+approved+pending_approval+this"))
if not ok: if not ok:
basis += f";占用 {cumulative} 超过预算 {_r(budget_value)}" basis += f";占用 {cumulative} 超过预算 {_r(budget_value)}"