diff --git a/backend/app/api/reports.py b/backend/app/api/reports.py index d736f80c..eebd254c 100644 --- a/backend/app/api/reports.py +++ b/backend/app/api/reports.py @@ -2418,15 +2418,20 @@ def get_dupont_analysis( # 存量/流量缺失时 raw 值为 None(如博海存量仅到区间外)⇒ 显式「-」,不得 None 格式化 return "-" if v is None else f"{v:.2f}" + def _fmt_val(v): + # 叙述段(恒等式三因子 / ROE / 偏差)表现层口径:缺失同族显式「-」; + # 有值时**原样输出**(不经 :.2f,保证有值路径逐字节不变)。 + return "-" if v is None else v + detail = (f"{label}口径(流量累计 {win['period_start']}~{win['period_end']}," f"存量{'平均' if cur['basis'] == 'average' else '期末回落'}" f"{',年化 ×12/' + str(win['months']) if annualize else ',非年化'}):" f"净利润 {_fmt(cur['raw']['net_profit'])}万 / 营业收入 {_fmt(cur['raw']['revenue'])}万 / " f"平均总资产 {_fmt(cur['raw']['total_assets'])}万 / 平均净资产 {_fmt(cur['raw']['equity'])}万;" - f"ROE = {factors['net_profit_margin']['value']}% × {factors['asset_turnover']['value']} × " - f"{factors['equity_multiplier']['value']} = {None if roe_exact is None else round(roe_exact, 2)}%" + f"ROE = {_fmt_val(factors['net_profit_margin']['value'])}% × {_fmt_val(factors['asset_turnover']['value'])} × " + f"{_fmt_val(factors['equity_multiplier']['value'])} = {_fmt_val(None if roe_exact is None else round(roe_exact, 2))}%" f"(恒等式 {'通过' if identity.get('status') == 'pass' else identity.get('status')}," - f"偏差 {identity.get('diff')} ≤ 容差 {identity.get('tolerance')})") + f"偏差 {_fmt_val(identity.get('diff'))} ≤ 容差 {identity.get('tolerance')})") if cur["basis_fallback"]: detail += f"|⚠️ {cur['basis_fallback_reason']}(basis_fallback=true)"