fix(budget): 年度分解400提示优化——含可用年份+双路径引导 (budget-decompose-400-hint)
This commit is contained in:
@@ -220,7 +220,18 @@ def auto_decompose_budget(
|
|||||||
kpi_version_used[kid] = chosen.version
|
kpi_version_used[kid] = chosen.version
|
||||||
|
|
||||||
if not kpi_annual:
|
if not kpi_annual:
|
||||||
raise HTTPException(400, "该年度没有可分解的预算,请先在预算执行中录入年度预算")
|
# 查询该企业有哪些年份有年度预算行(供提示)
|
||||||
|
from sqlalchemy import distinct
|
||||||
|
avail_years = [r[0] for r in db.query(distinct(BudgetPlan.budget_year)).filter(
|
||||||
|
BudgetPlan.entity_id == entity_id,
|
||||||
|
BudgetPlan.period.like("%-00"),
|
||||||
|
BudgetPlan.status == "active",
|
||||||
|
).order_by(BudgetPlan.budget_year).all()]
|
||||||
|
hint = f"该年度({year})没有年度预算总额(period=YYYY-00)"
|
||||||
|
if avail_years:
|
||||||
|
hint += f";现有年度数据年份:{', '.join(str(y) for y in avail_years)}"
|
||||||
|
hint += "。请先在预算录入中填写该年度预算总额,或改用战略预算编制按地图录入;如需按已有月度数据反向生成请咨询管理员。"
|
||||||
|
raise HTTPException(400, hint)
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
created_count = 0
|
created_count = 0
|
||||||
@@ -293,7 +304,7 @@ def auto_decompose_budget(
|
|||||||
|
|
||||||
# ── 单KPI模式(原有逻辑)──
|
# ── 单KPI模式(原有逻辑)──
|
||||||
if annual_budget is None:
|
if annual_budget is None:
|
||||||
raise HTTPException(400, "缺少必要参数: annual_budget")
|
raise HTTPException(400, "缺少必要参数: annual_budget(单KPI分解需传年度预算值)")
|
||||||
|
|
||||||
kpi = db.query(KPIDefinition).filter(KPIDefinition.id == kpi_id).first()
|
kpi = db.query(KPIDefinition).filter(KPIDefinition.id == kpi_id).first()
|
||||||
if not kpi:
|
if not kpi:
|
||||||
|
|||||||
Reference in New Issue
Block a user