feat: 成本核算模块(鲁铭成本核算Excel全量适配, 价格库580条+75/85/95三系列模板+估算器基准精确还原)
- 解析12表成本核算工作簿: 价格库8表→产品价格本(华健型材模具/丝吉利娅/索宾柯五金/隔热条/胶条/赛遨辅材/螺丝/其他) - 「铝成本」页→系列成本模板(75框扇齐平1.4/85框扇齐平1.8/95窗纱一体1.8, 八分区JSON) - 估算器口径对齐核算表: 固定/开启/总面积归因缩放+人工每平实际口径+毛利阶梯10%~70% - 75系列基准估算total=1118.20与核算表成本合计完全一致(85/95同) - API /api/costbook: import-excel/series/estimate; 前端 /cost_estimate 页 - 种子 seed_costbook.py; 修复6处解析缺陷; 冒烟60/60+24页巡检0异常+深度审计16/16
This commit is contained in:
+34
@@ -521,3 +521,37 @@ uv run uvicorn huamenchuang.main:app --reload # 启动,http://localhost:8000
|
||||
| **领料出库** | POST | `/api/warehouse/pickout` | `{contract_id, note?}` | 对齐 pickout:按领料清单扣库存+流水;库存不足报缺口 |
|
||||
| **采购单** | POST | `/api/purchases` | `{contract_id?(自动读缺料), items?, note?}` | 缺料清单自动生成(CG+日期+流水) |
|
||||
| 采购列表/入库 | GET/POST | `/api/purchases[?status]` · `/{id}/receive` | — | 入库联动:明细写入库存+StockMove 流水 |
|
||||
|
||||
### 12.27 成本核算模块 `/api/costbook`(v2.36 新增,鲁铭成本核算 Excel 适配)
|
||||
|
||||
> 适配门窗厂成本核算工作簿(12 sheet 格式:铝成本/铝计算/木成本 + 价格库 8 表 + 其他)。
|
||||
> 价格库 8 表(华健开模汇总/丝吉利娅五金/索宾柯/隔热条/胶条/赛遨辅材/螺丝/其他价格)全量导入产品价格本 `/api/products`(同名同材质更新价格,否则新建,material 按 sheet 语义映射);
|
||||
> 「铝成本」页解析为**系列成本模板** `cost_series_templates`(data JSON 含 window/profile/addon/strip/seal/glass/extra/hardware/labor 八分区)。
|
||||
> 种子:`uv run python -m huamenchuang.scripts.seed_costbook`(data/ 下三个鲁铭 xlsx,75/85/95 三系列已预置)。
|
||||
|
||||
| 接口名称 | 方式 | URL 路径 | 请求参数 | 响应示例 |
|
||||
|---|---|---|---|---|
|
||||
| 导入核算 Excel | POST | `/api/costbook/import-excel` | multipart `file`(.xlsx) | `{libraries:{created,updated}, optimize_stats:{bars,total_length,sashes,glasses,glass_area}}`,message 带统计 |
|
||||
| 系列模板列表 | GET | `/api/costbook/series` | — | `[{id,name,series,wall_thick,source_file,enabled,window:{w,h,area,sash_area,...}}]` |
|
||||
| 系列模板详情 | GET | `/api/costbook/series/{id}` | — | `{...brief, data:{window,profile[],addon[],strip[],seal[],glass[],extra[],hardware[],labor}}` |
|
||||
| 新建系列模板 | POST | `/api/costbook/series` | `{name,series,wall_thick,data}` | `{id}` |
|
||||
| 删除系列模板 | DELETE | `/api/costbook/series/{id}` | — | `{code:1}` |
|
||||
| **成本估算** | POST | `/api/costbook/estimate` | `{series_id,width,height,count=1,sash_count?}` | 见下 |
|
||||
|
||||
**估算响应**(口径对齐核算表:固定类料随固定面积、开启类随开启面积、once 类按樘数缩放;人工/其他成本优先用核算表每平实际口径):
|
||||
|
||||
```json
|
||||
{
|
||||
"series": 75, "wall_thick": 1.4, "name": "75框扇齐平",
|
||||
"width": 1600, "height": 1600, "count": 1, "sash_count": 1,
|
||||
"area": 2.56, "open_area": 0.78, "fixed_area": 1.78,
|
||||
"profile": [{"code","name","qty(m)","weight","weight_per_m","unit_price","amount"}],
|
||||
"profile_cost": 466.8, "addon_cost": 14.11, "strip_cost": 17.69, "seal_cost": 27,
|
||||
"glass_cost": 179.2, "extra_cost": 0, "hardware_cost": 55,
|
||||
"labor_cost": 243.2, "other_cost": 115.2,
|
||||
"total": 1118.2, "per_sqm": 436.8,
|
||||
"margin_ladder": {"10%": 1230.02, "20%": 1341.84, "...": "50%=1677.29", "70%": 1900.93}
|
||||
}
|
||||
```
|
||||
|
||||
校验基准:75 系列基准窗(1600×1600,开启 1 扇)估算 total=1118.20,与核算表"成本合计"完全一致(冒烟 COST-1~9)。
|
||||
|
||||
Reference in New Issue
Block a user