feat: CMA P1+P2 Round1 — 成本法对比+杜邦分析+本量利

This commit is contained in:
Hermes CI Fix
2026-07-16 16:39:24 +08:00
parent 46fa811d52
commit 4b25f46124
8728 changed files with 1772671 additions and 151 deletions
+62
View File
@@ -202,6 +202,68 @@ def cost_breakdown(product_code: str = Query(...),
return get_cost_breakdown(product_code, period)
@router.get("/comparison")
def cost_method_comparison(entity: str = Query("hanke")):
"""三种成本法对比分析:传统/变动/作业成本法 (CMA P1)"""
if entity == "hanke":
gross_revenue = 713 # 万
channel_rebate_rate = 0.828
net_revenue = round(gross_revenue * (1 - channel_rebate_rate), 2)
weighted_cost_rate = 0.4862
book_cost = 717 # 万
total_expenses = 546 # 万
non_value_added = 26 # 万
traditional = {
"revenue": gross_revenue,
"cost": book_cost,
"gross_profit": round(gross_revenue - book_cost, 2),
"gross_margin": round((gross_revenue - book_cost) / gross_revenue * 100, 2),
"expenses": total_expenses,
"net_profit": round(gross_revenue - book_cost - total_expenses, 2),
}
var_cost = round(net_revenue * weighted_cost_rate, 2)
variable = {
"revenue": net_revenue,
"cost": var_cost,
"gross_profit": round(net_revenue - var_cost, 2),
"gross_margin": round((1 - weighted_cost_rate) * 100, 2),
"expenses": total_expenses,
"net_profit": round(net_revenue - var_cost - total_expenses, 2),
}
abc_cost = round(net_revenue * weighted_cost_rate, 2)
abc_exp = total_expenses - non_value_added
abc = {
"revenue": net_revenue,
"cost": abc_cost,
"gross_profit": round(net_revenue - abc_cost, 2),
"gross_margin": round((1 - weighted_cost_rate) * 100, 2),
"expenses": abc_exp,
"net_profit": round(net_revenue - abc_cost - abc_exp, 2),
}
return {
"entity": "hanke",
"entity_name": "陕西酣客(白酒经销)",
"traditional": traditional,
"variable": variable,
"abc": abc,
"insights": [
{"method": "传统成本法", "conclusion": "毛利率为负", "decision": "❌ 不赚钱,别卖了", "detail": "未剔除渠补,账面收入虚高"},
{"method": "变动成本法", "conclusion": "毛利率18.6%", "decision": "✅ 业务能赚钱→砍费用", "detail": "剔除渠补后净收入122万,成本率48.62%"},
{"method": "作业成本法", "conclusion": "识别非增值作业26万", "decision": "✅ 可再省", "detail": "剔除冗余招待费等非增值作业"},
],
"notes": {
"net_revenue": "毛收入713万 × (1-渠补率82.8%) = 净收入122万",
"variable_cost": "净收入122万 × 加权成本率48.62% = 成本59.3万",
"abc_expenses": "总费用546万 - 非增值作业26万 = 520万",
},
}
return {"error": "不支持的实体"}
@router.get("/dashboard")
def cost_dashboard(period: Optional[str] = Query(None)):
"""成本分析首页—汇总数据"""