Commit 4cebafc4 by 周立明 Committed by zhouhaibao

fix(data-process): 修复单行非嘀加数据装修摊销未分摊问题

- 增加兜底逻辑:当 key 下仅有 1 行且非嘀加时,仍将该行纳入分摊
- 多行全非嘀加时保持原有跳过行为,费用计入未匹配金额
- 添加日志区分单行兜底与多行跳过两种场景
1 parent 642410a9
...@@ -439,8 +439,15 @@ def compute_renovation_amounts(detail_rows, biz_rows, stat_month, n_months=RENOV ...@@ -439,8 +439,15 @@ def compute_renovation_amounts(detail_rows, biz_rows, stat_month, n_months=RENOV
# --- 服务商过滤:只保留 service_provider 含"嘀加"的行(嘀加自营/嘀加直营) --- # --- 服务商过滤:只保留 service_provider 含"嘀加"的行(嘀加自营/嘀加直营) ---
dijia_rows = [r for r in rows if _is_dijia_row(r)] dijia_rows = [r for r in rows if _is_dijia_row(r)]
if not dijia_rows: if not dijia_rows:
# 全是非嘀加 → 不分摊(费用=0),跳过 # 全是非嘀加
continue if len(rows) == 1:
# 只有一条行,即使不是嘀加自营,也分摊给他
logger.info(f"[装修摊销] key={key}: 仅 1 行且非嘀加 → 兜底全部分摊给该行")
dijia_rows = rows
else:
# 多行全非嘀加 → 不分摊(费用=0),跳过(差值进 unmatched_amount)
logger.info(f"[装修摊销] key={key}: {len(rows)} 行全非嘀加 → 跳过(进未匹配)")
continue
if len(dijia_rows) < len(rows): if len(dijia_rows) < len(rows):
logger.info(f"[装修摊销] key={key}: {len(rows)} 行中有 {len(dijia_rows)} 行" logger.info(f"[装修摊销] key={key}: {len(rows)} 行中有 {len(dijia_rows)} 行"
f" 服务商=嘀加,参与分摊;跳过 {len(rows)-len(dijia_rows)} 行") f" 服务商=嘀加,参与分摊;跳过 {len(rows)-len(dijia_rows)} 行")
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!