Commit 901fe3c7 by zhouhaibao

refactor(budget): 精简预算达成数据处理逻辑

- 移除门店资产耗材、市场费总表、人力成本统计表、外施施工费用表的清洗与处理流程
- 精简 FEE_TYPES 枚举,仅保留房租水电和装修摊销两种费用类型
- 统一毛利公式为:嘀加分润 - 房租水电 - 装修摊销,不再区分嘀加自营
- 移除 processor reset 中对已删除费用字段的清零操作
- 精简 Excel 导出列,移除市场费/人员工资/外援施工/技师工资/营销团队工资/门店耗材/F公司毛利
- 未匹配费用追踪仅保留房租水电,跳过 process_consumables 调用
1 parent 31f35605
...@@ -971,9 +971,10 @@ def process_task(conn, task, dry_run=False): ...@@ -971,9 +971,10 @@ def process_task(conn, task, dry_run=False):
log(' dry-run:不写库,样例前 3 行:') log(' dry-run:不写库,样例前 3 行:')
for r in rows[:3]: for r in rows[:3]:
log(f' {r}') log(f' {r}')
# dry-run 也演示装修摊销 / 门店资产耗材预览(依赖库内已有的结果行) # dry-run 也演示装修摊销预览(依赖库内已有的结果行)
_preview_renovation(conn, task_id, stat_month, dry_run=True) _preview_renovation(conn, task_id, stat_month, dry_run=True)
_preview_consumables(conn, task_id, stat_month) # 2026-10 精简:门店资产耗材已移除,跳过预览
# _preview_consumables(conn, task_id, stat_month)
return len(rows) return len(rows)
deleted, inserted = save_budget_rows(conn, task_id, stat_month, rows) deleted, inserted = save_budget_rows(conn, task_id, stat_month, rows)
...@@ -985,13 +986,15 @@ def process_task(conn, task, dry_run=False): ...@@ -985,13 +986,15 @@ def process_task(conn, task, dry_run=False):
# 第二步:装修摊销(来自「装修费用表」附件,仅 1.1 业务) # 第二步:装修摊销(来自「装修费用表」附件,仅 1.1 业务)
ren_updated, ren_unmatched = process_renovation(conn, task_id, stat_month, dry_run=False) ren_updated, ren_unmatched = process_renovation(conn, task_id, stat_month, dry_run=False)
# 第三步:门店资产耗材(来自「门店资产耗材明细表」附件,按业务类型分别匹配) # 第三步:门店资产耗材 —— 2026-10 精简:门店资产耗材明细表已移除,跳过此步骤
cons_updated, cons_unmatched = process_consumables(conn, task_id, stat_month, dry_run=False) log(f' [门店资产耗材] 已移除(2026-10 精简),跳过 process_consumables')
cons_updated, cons_unmatched = 0, 0.0
# 第四步:未匹配金额写库(biz_unmatched_fee,先删后插幂等) # 第四步:未匹配金额写库(biz_unmatched_fee,先删后插幂等)
# 2026-10 精简:cons_unmatched 固定为 0(门店耗材不再处理)
unmatched_rows = write_unmatched_fee(conn, task_id, stat_month, ren_unmatched, cons_unmatched) unmatched_rows = write_unmatched_fee(conn, task_id, stat_month, ren_unmatched, cons_unmatched)
if unmatched_rows: if unmatched_rows:
log(f' 写入 {UNMATCHED_FEE_TABLE}:新增 {unmatched_rows} 行未匹配费用记录') log(f' 写入 {UNMATCHED_FEE_TABLE}:新增 {unmatched_rows} 行未匹配费用记录')
return inserted + ren_updated + cons_updated return inserted + ren_updated
except Exception: except Exception:
if not dry_run: if not dry_run:
update_clean_status(conn, file_row['id'], CLEAN_PENDING) # 失败回退为待清洗 update_clean_status(conn, file_row['id'], CLEAN_PENDING) # 失败回退为待清洗
......
...@@ -134,14 +134,11 @@ class Config: ...@@ -134,14 +134,11 @@ class Config:
'name': '预算达成数据', 'name': '预算达成数据',
'need_period': False, 'need_period': False,
'support_week': False, 'support_week': False,
# 2026-10 精简:移除市场费总表/人力成本统计表/外施施工费用表/门店资产耗材明细表
'forms': [ 'forms': [
'结算数据汇总表', '结算数据汇总表',
'市场费总表',
'人力成本统计表',
'外施施工费用表',
'房租水电费用表', '房租水电费用表',
'装修费用表', '装修费用表',
'门店资产耗材明细表',
], ],
}, },
'store_effect_earnings': { 'store_effect_earnings': {
......
...@@ -245,14 +245,10 @@ class BizUnmatchedFee(db.Model): ...@@ -245,14 +245,10 @@ class BizUnmatchedFee(db.Model):
updated_at = db.Column(db.DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间') updated_at = db.Column(db.DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
# fee_type 枚举常量 # fee_type 枚举常量
# 2026-10 精简:仅保留房租水电(processor 写入)和装修摊销(clean 写入)
FEE_TYPES = [ FEE_TYPES = [
'market_fee',
'external_construction',
'technician_salary',
'marketing_team_salary',
'rent_utilities', 'rent_utilities',
'renovation_amortization', 'renovation_amortization',
'store_consumables',
] ]
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!