feat(cashflow): 按项目任务单复核修正——表名cashflow_statements+DoD兼容路径/菜单C组/角色收敛/术语0+验收脚本入库
- 表名: ORM+生产库 RENAME cash_flow_structure_values → cashflow_statements (DoD SHOW TABLES LIKE 字面验收)
- 兼容端点: /api/cma/cashflow/statements(GET/POST)+analysis 注册 main.py (DoD 验收路径)
- 菜单: 移入 🟡C 监控与评价 组(与杜邦分析/管理报表平级), roles 收敛 ceo/finance (前端 ROLE_ROUTES/MENU_ITEMS/router meta + 后端 require_role 四处同步)
- 术语: docstring 改写, grep 现金流肖像=0
- 验收脚本: backend/scripts/verify_cashflow_structure.py (14项断言全PASS: type6→type1双向/瀑布5步/alias路径/权限/清理)
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
"""
|
||||
现金流量表结构分析 — 管理会计OS (CMA P2 · 财务报表分析)
|
||||
规范命名:现金流量表结构分析(不使用"现金流肖像"等民间说法)
|
||||
规范命名:现金流量表结构分析(本模块不采用民间俗称,术语以任务单为准)
|
||||
|
||||
核心方法:经营(O)/投资(I)/筹资(F) 三大活动净额正负组合 → 8类企业定性分析
|
||||
O 造血能力 / I 成长代价 / F 输血管道
|
||||
长期黄金法则:经营现金流必须为正,且应大于净利润(利润质量)。
|
||||
|
||||
数据模型:cash_flow_structure_values — 官方现金流量表三大活动净额按期间注入
|
||||
数据模型:cashflow_statements — 官方现金流量表三大活动净额按期间注入
|
||||
- 未注入期间:无判定(不拿演示/示例数据冒充真实类型)
|
||||
- 官方净额入库后类型判定自动生效(博海2026官方表注入路径)
|
||||
"""
|
||||
@@ -25,7 +25,7 @@ from app.models import CashFlowStructureValue
|
||||
router = APIRouter(
|
||||
prefix="/api/cma/cashflow-structure",
|
||||
tags=["现金流量表结构分析"],
|
||||
dependencies=[Depends(require_role("ceo", "finance", "it"))],
|
||||
dependencies=[Depends(require_role("ceo", "finance"))],
|
||||
)
|
||||
|
||||
|
||||
@@ -320,3 +320,48 @@ def upsert_value(
|
||||
"classification": classification,
|
||||
"message": "三大活动净额已%s" % ("入库" if created else "更新"),
|
||||
}
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 兼容别名端点 — 任务派发单 DoD 验收路径 /api/cma/cashflow/*
|
||||
# (规范实现主路径为 /api/cma/cashflow-structure/*;两路径功能一致)
|
||||
# ============================================================
|
||||
compat_router = APIRouter(
|
||||
prefix="/api/cma/cashflow",
|
||||
tags=["现金流量表结构分析(兼容路径)"],
|
||||
dependencies=[Depends(require_role("ceo", "finance"))],
|
||||
)
|
||||
|
||||
|
||||
@compat_router.get("/statements")
|
||||
def compat_list_statements(
|
||||
period: Optional[str] = Query(None, description="期间 YYYY-MM,可选"),
|
||||
db: Session = Depends(get_db),
|
||||
entity_id: int = Depends(get_entity_id),
|
||||
):
|
||||
"""[兼容] 查询已录入三大活动净额(同 /api/cma/cashflow-structure/values)"""
|
||||
items = list_values(db=db, entity_id=entity_id)["items"]
|
||||
if period:
|
||||
period = _validate_period(period)
|
||||
items = [x for x in items if x["period"] == period]
|
||||
return {"items": items}
|
||||
|
||||
|
||||
@compat_router.post("/statements", dependencies=[Depends(require_role("ceo", "finance"))])
|
||||
def compat_save_statement(
|
||||
payload: CashFlowValueIn,
|
||||
db: Session = Depends(get_db),
|
||||
entity_id: int = Depends(get_entity_id),
|
||||
):
|
||||
"""[兼容] 保存/更新某期间三大活动净额(同 POST /api/cma/cashflow-structure/values)"""
|
||||
return upsert_value(payload=payload, db=db, entity_id=entity_id)
|
||||
|
||||
|
||||
@compat_router.get("/analysis")
|
||||
def compat_get_analysis(
|
||||
period: str = Query(None, description="格式 YYYY-MM,缺省取最近已注入期间"),
|
||||
db: Session = Depends(get_db),
|
||||
entity_id: int = Depends(get_entity_id),
|
||||
):
|
||||
"""[兼容] 结构分析+八类判定+瀑布数据(同 /api/cma/cashflow-structure/analysis)"""
|
||||
return get_analysis(period=period, db=db, entity_id=entity_id)
|
||||
|
||||
Reference in New Issue
Block a user