1
0
forked from erp-dev/erp

fix: business cancel service merged

This commit is contained in:
2026-06-11 15:33:31 +08:00
parent 65564f772a
commit 80db7867f4
18 changed files with 574 additions and 125 deletions

View File

@@ -62,6 +62,8 @@
宽进仓将 `numbers` 换为 `quantity` + `num_of_rolls`。至少 1 条明细,否则返回 400。
> 创建成功201返回精简体`{"id", "human_id", "status", "message"}`,不包含 `items`、`total_amount` 等明细字段。需要完整结构请通过编辑PUT/PATCH或审批`review`)接口获取,二者返回完整序列化。
### 2.2 审批
`POST /purchase-orders/<id>/review/`,请求体 `{"action": "approve"}``{"action": "cancel"}`
@@ -99,11 +101,15 @@
销售单 `items` 字段同样支持 `empty_diff_percent``color``spec``batch_number``remarks` 等信息,用途与采购单一致;仓库模式决定使用 `numbers``quantity + num_of_rolls``consume_detail_ids`
顶层可选字段 `kind`(销售单类型):`1=大货``2=样板`。不传或传空时默认 `1`(大货);传入非法枚举值返回 400。
```json
{
"customer": 6,
"warehouse": 3,
"kind": 1,
"order_date": "2025-11-30",
"items": [
{
"product_id": 1001,
@@ -128,6 +134,8 @@
}
```
> 创建成功201返回精简体`{"id", "human_id", "status", "message"}`,不包含 `items`、`total_amount` 等明细字段。需要完整结构请通过编辑PUT/PATCH或审批`review`)接口获取,二者返回完整序列化。
### 3.2 审批
与采购单一致,但方向为出库:

View File

@@ -75,11 +75,12 @@ python manage.py showmigrations business
当前 `items_payload` 中保留的信息包括:
- `product_id`若能通过 `HpID -> Product.human_id` 匹配到本地产品,则写入本地产品 ID否则`null`
- `product_name`:优先本地产品名,否则回退为外部 `HpID`
- `product_id`外部 statement-only 明细不绑定本地产品,固定`null`
- `product_name`:优先使用外部 `HpName`,否则回退为外部 `HpID`
- `quantity`
- `price`
- `unit`
- `color`:来源于外部 i-sale payload 的 `YanSe` 字段;若源端未下发则为空字符串
- `spec`
- `num_of_rolls`
- `external_sub_id`
@@ -137,8 +138,31 @@ python manage.py showmigrations business
- `RiQi` -> statement `occurred_at`
- `KdRiQi` -> statement `recorded_at`
- `JinE` 聚合为外部业务单金额
- `HpID` 优先匹配本地 `Product.human_id`
- 若未匹配到本地产品,仍保留 `HpID` 作为对账单 item 展示标识,不阻塞同步
- 外部业务单仅作为对账依据保存,不再通过 `HpID` 绑定本地 `Product`,避免外部历史数据误入库存/审批产品体系
### 1.3.1 i-sale → 对账单 item 完整字段映射
下表列出 `i-sale/by-customer` 返回的外部字段到对账单 API `records[].items[]` 内各字段的映射关系。
| 外部字段 (I_Sale) | item 字段 | 前端取值路径 | 类型 | 说明 |
|---|---|---|---|---|
| `DanJia` | `price` | `records[].items[].price` | 字符串 | 不含税单价,两位小数 |
| `ShuLiang` | `quantity` | `records[].items[].quantity` | 字符串 | 总数量,两位小数 |
| `JianShu` | `num_of_rolls` | `records[].items[].num_of_rolls` | 整数 | 条数(件数) |
| `HpName` | `product_name` | `records[].items[].product_name` | 字符串 | 品名;空时回退为 `HpID` |
| `YanSe` | `color` | `records[].items[].color` | 字符串 | 颜色;源端未下发则空串 |
| `SeHao` | `spec` | `records[].items[].spec` | 字符串 | 幅宽/规格;源端未下发则空串 |
| `HpID` | `external_product_id` | `records[].items[].external_product_id` | 字符串 | 外部货品 ID |
| `JiJiaDW` | `unit` | `records[].items[].unit` | 字符串 | 计价单位 |
| `SubID` | `external_sub_id` | `records[].items[].external_sub_id` | 整数/null | 外部明细行 ID |
注意事项:
- `price``quantity` 均为**字符串类型**,不是 number前端使用时需注意类型转换。
- 所有 item 字段位于 `records[].items[]` **数组内**,不在 record 顶层。
- `product_id` 固定为 `null`(外部业务单不绑定本地产品)。
- `quantity_of_rolls` 固定为空数组 `[]`(外部数据无逐条明细)。
- 同一 `BianHaoID` 下可能有多条明细行(不同产品/单价),`items` 数组会有多个元素。
## 1.4 已同步客户如何补齐 i-sale 业务依据