销售出库/退货单
销售入库/退货单列表
HTTP请求
GET /api/sales.json请求参数
| 参数名 | 是否必须 | 默认值 | 说明 |
|---|---|---|---|
| category | 否 | out | out: 销售出库;in: 销售退货 |
| date | 否 | 本月 | 出库日期 |
| status | 否 | 无 | 审批状态(draft[草稿] approving[待审批] submitted[已提交] rejected[已驳回] passed[审批通过] deprecated[已作废]) |
| tax_added | 否 | 无 | 是否含税 |
| customer_id | 否 | 无 | 客户 |
| customer_type_id | 否 | 无 | 客户类型 |
| province_id | 否 | 无 | 省 |
| city_id | 否 | 无 | 市 |
| district_id | 否 | 无 | 区 |
| warehouse_id | 否 | 无 | 仓库 |
| product_category_id | 否 | all | 产品分类 |
| product_id | 否 | all | 产品 |
| department_id | 否 | all | 销售人员部门 |
| seller_id | 否 | all | 销售人员 |
| creator_department_id | 否 | all | 创建人部门 |
| creator_id | 否 | all | 创建人 |
| keyword | 否 | 无 | 关键词 |
| keyword_type | 否 | 无 | 关键词类型(product_items.name: 产品名称, product_items.spec: 规格; product_items.attr_names: 属性; sales.number: 单据编号/备注;) |
| created_at | 否 | 无 | 创建时间(created_at=’2024-01-01/2024-03-15’ 或者Unix时间戳毫秒级格式 created_at=’1710401628293/1710401628299’; 注意日期之间用/隔开 ) |
| updated_at | 否 | 无 | 更新时间(updated_at=’2024-01-01/2024-03-15’ 或者Unix时间戳毫秒级格式 updated_at=’1710401628293/1710401628299’; 注意日期之间用/隔开 ) |
| sort | 否 | 无 | 排序字段(仅支持created_at, updated_at) |
| order | 否 | 无 | 排序方式(仅支持desc, asc) |
| page | 否 | 1 | 第几页 |
| per | 否 | 15 | 每页返回数 |
- 返回字段说明
| 字段 | 类型 | 说明 |
|---|---|---|
| id | integer | ID |
| number | string | 入库/退货订单编号 |
| type | string | 订单类型 |
| type_name | string | 类型名字 |
| category | string | 分类名字 |
| io_at | string | 出库/退货日期 |
| amount | string | 订单金额 |
| warehouse_id | integer | 关联仓库ID |
| warehouse_name | string | 关联仓库名字 |
| customer_or_supplier_name | string | 顾客姓名 |
| purchaser_or_seller_name | string | 销售员姓名 |
| status | string | 订单状态 |
| status_value | string | 订单状态值 |
| creator | string | 创建人 |
| operator | string | 操作人 |
| operated_at | string | 最新操作时间 |
| created_at | string | 创建时间 |
| next_status | string | 下一级状态 |
| entry_or_io_at | string | 出库时间 |
| seller_name | string | 销售员 |
| created_at | string | 创建时间 |
| updated_at | string | 更新时间 |
- 返回 JSON 数据
{
"status": {
"code": 200,
"message": "OK"
},
"sales": [
{
"id": 15546,
"number": "XSCKD201804250002",
"type": "sale",
"type_name": "销售出库单",
"category": "out",
"amount": "58.50000",
"warehouse_id": 3905,
"warehouse_name": "GGGGG",
"customer_or_supplier_name": "国金",
"purchaser_or_seller_name": "谢芝林",
"status": "审批通过",
"status_value": "passed",
"creator": "谢芝林",
"operator": "谢芝林",
"operated_at": "2018-04-25 20:04",
"created_at": "2018-04-25 20:03",
"next_status": null,
"entry_or_io_at": "2018-04-25",
"created_at": "2023-07-20 16:13:11",
"updated_at": "2023-07-20 16:13:11",
"seller_name": "谢芝林"
},
{ ... }
]
}销售出库/退货单新增
HTTP请求
POST /api/sales.json请求参数
| 参数名 | 是否必须 | 说明 |
|---|---|---|
| category | 是 | out(出库)/in(退货) |
| status | 是 | 审批状态(draft[草稿] approving[待审批] submitted[已提交] rejected[已驳回] passed[审批通过] deprecated[已作废]) |
| approved_level | 否 | 审批级别(开启审批必须) |
| number | 是 | 单据编号(自定义字段已包含) |
| customer_id | 是 | 客户ID(自定义字段已包含) |
| sale_order_id | 否 | 关联销售订单ID |
| seller_id | 是 | 销售人员ID(自定义字段已包含) |
| parent_id | 否 | 退货单需要,关联的出库单ID |
| total_quantity | 是 | 数量合计 |
| total_base_quantity | 是 | 基本数量合计(开启多单位时候对应的基本单位的数量,未开启时候跟数量一致) |
| total_deduction | 是 | 优惠额合计(优惠金额) |
| total_amount | 是 | 金额合计(不含税和优惠金额) |
| total_tax_amount | 否 | 税额合计(开启税率必须) |
| total_amount_with_tax | 否 | 优惠后税价合计(开启税率必须) |
| total_fee_amount | 否 | 其他费用合计 |
| discount | 是 | 优惠率(自定义字段已包含) |
| deduction | 是 | 优惠额(自定义字段已包含) |
| amount | 是 | 优惠后金额(自定义字段已包含,税价合计-优惠金额) |
| note | 否 | 备注 |
| contact_id | 否 | 联系人ID |
| contact_name | 否 | 联系人姓名 |
| contact_mobile | 否 | 联系人手机 |
| contact_phone | 否 | 联系人电话 |
| contact_address | 否 | 联系人地址 |
| customer_address | 否 | 客户地址 |
| allow_negative_inventory | 否 | 允许提交负库存 |
| gt_order_quantity | 否 | 允许大于订单数量 |
| 表头/表尾自定义字段 | 根据设置 | 包含类型 default/custom |
| document_addition_attributes | 是 | 抄送 |
| document_addition_attributes.copy_to[] | 是 | 抄送人ID |
| document_approvers_params | 否 | 开启审批必须 |
| document_approvers_params.level | 否 | 审批级别 |
| document_approvers_params.member_ids[] | 否 | 审批人ID |
| attachments_attributes[] | 否 | 附件 |
| attachments_attributes[0].filename | 否 | 文件名 |
| attachments_attributes[0].url | 否 | 文件URL |
| fees_attributes | 否 | 其他费用 |
| fees_attributes.expense_type_id | 否 | 费用类型 |
| fees_attributes.amount | 否 | 费用金额 |
| fees_attributes.supplier_fees_attributes | 否 | 供应商其他费用 |
| fees_attributes.supplier_fees_attributes.expense_type_id | 否 | 供应商其他费用类型 |
| fees_attributes.supplier_fees_attributes.supplier_id | 否 | 供应商其他费用供应商ID |
| fees_attributes.supplier_fees_attributes.io_at | 否 | 供应商其他费用时间 |
| fees_attributes.supplier_fees_attributes.document_number | 否 | 供应商其他费用单据编号 |
| fees_attributes.supplier_fees_attributes.status | 否 | 供应商其他费用状态 |
| fees_attributes.supplier_fees_attributes.amount | 否 | 供应商其他费用金额 |
| fees_attributes.supplier_fees_attributes.remaining_amount | 否 | 供应商其他费用剩余金额 |
| product_items_attributes[] | 是 | 产品项 |
| product_items_attributes[0].order_item_id | 否 | 关联订单项ID |
| product_items_attributes[0].product_attr_group_id | 是 | 产品属性组ID |
| product_items_attributes[0].product_unit_id | 是 | 产品单位ID |
| product_items_attributes[0].product_id | 是 | 产品ID |
| product_items_attributes[0].warehouse_id | 是 | 仓库ID |
| product_items_attributes[0].name | 是 | 产品项名称(产品名称) |
| product_items_attributes[0].product_number | 是 | 产品编号 |
| product_items_attributes[0].attr_names | 否 | 产品项属性名称 |
| product_items_attributes[0].spec | 否 | 产品项规格 |
| product_items_attributes[0].unit | 是 | 产品项单位 |
| product_items_attributes[0].quantity | 是 | 产品项数量 |
| product_items_attributes[0].base_unit | 是 | 基本单位 |
| product_items_attributes[0].base_quantity | 是 | 基本数量(开启多单位时候基本数量等于基本单位与当前单位的换算率 * 当前数量;未开启多单位时候和当前数量一致) |
| product_items_attributes[0].deputy_unit_quantity | 是 | 副单位数(需要产品开启多单位) |
| product_items_attributes[0].price | 是 | 产品项价格 |
| product_items_attributes[0].price_with_tax | 否 | 含税价 |
| product_items_attributes[0].discount | 否 | 产品项折扣率 |
| product_items_attributes[0].deduction | 否 | 产品项优惠金额 |
| product_items_attributes[0].amount | 是 | 产品项金额 |
| product_items_attributes[0].tax_rate | 否 | 税率 |
| product_items_attributes[0].tax_amount | 否 | 税额 |
| product_items_attributes[0].amount_with_tax | 否 | 税价合计 |
| product_items_attributes[0].note | 否 | 产品项备注 |
| product_items_attributes[0].batch_number | 否 | 批次编号 |
| product_items_attributes[0].batch_id | 否 | 批次ID |
| product_items_attributes[0].produced_at | 否 | 生产日期 |
| product_items_attributes[0].expired_at | 否 | 有效期 |
| product_items_attributes[0].parent_id | 否 | 关联入库单产品项ID |
| product_items_attributes[0].modified | 是 | 最后一次修改字段名称 |
| product_items_attributes[0].position | 否 | 产品位置参数(出库单产品显示顺序) |
| product_items_attributes[0].表体自定义字段 | 根据设置 | 包含类型 default/custom |
返回字段说明
字段 | 类型 | 说明
— | — | —
id | integer | 单据ID
category | string | 类别返回 JSON 数据
{
"status": {
"code": 200,
"message": "OK"
},
"sale": {
"id" :61868,
"category": "out"
}
}销售出库/退货单详情
curl -H "Authorization: Token token=<token>, uid=<uid>" \
http://example.com/api/sales/:id.json{
"status": {
"code": 200,
"message": "OK"
},
"sale": {
"id": 735,
"category": "out",
"approved_level": 0,
"status": "approving",
"creator_name": "XXX",
"sale_order_id": null,
"type_name": "销售出库单",
"copy_to_member_names": [],
"copy_to": [],
"parent_id": null,
"parent_number": null,
"print_count": 0,
"discount": "0.0",
"deduction": "0.0",
"amount": "11.6",
"total_quantity": "1.0",
"total_base_quantity": null,
"total_fee_amount": "0.0",
"number": "XSCKD201903290001",
"io_at": "2019-03-29",
"customer_id": 2,
"customer_name": "客户1",
"seller_id": 1,
"seller_name": "XXX",
"note": null,
"contact_id": 75,
"contact_name": "张三",
"contact_mobile": "13612345678",
"contact_phone": "4561321654",
"contact_address": "asf2wer",
"customer_address": "儿童问题",
"has_approve_permission": true,
"has_revoke_permission": true,
"sensitive_access": true,
"contact_sensitive_access": true,
"customer_sensitive_access": true,
"note_editable": true,
"attachment_editable": true,
"allow_negative_inventory": true,
"gt_order_quantity": true,
"total_deduction": "0.0",
"total_amount": "10.0",
"total_tax_amount": "1.6",
"total_amount_with_tax": "11.6",
"status_i18n": "待1级审批",
"created_at": "2019-03-29",
"sale_order_number": null,
"children": [],
"has_serial_code": false,
"document_addition_id": 378,
"product_items": [
{
"id": 1392,
"product_id": 1,
"product_attr_group_id": 1,
"product_unit_id": 131,
"product_item_id": null,
"parent_id": null,
"name": "测试商品1",
"product_number": "DG001",
"attr_names": "",
"spec": "XS",
"unit": "个",
"quantity": "1.0",
"price": "10.0",
"price_with_tax": "11.6",
"discount": "0.0",
"deduction": "0.0",
"amount": "10.0",
"tax_rate": "16.0",
"tax_amount": "1.6",
"amount_with_tax": "11.6",
"batch_id": null,
"batch_number": null,
"expired_at": null,
"produced_at": null,
"modified": "quantity",
"product_images": [],
"warehouse_id": 25,
"warehouse_name": "名字很长很长很长的仓库",
"base_unit": "",
"base_quantity": null,
"deputy_unit_quantity": "",
"note": "aa",
"serial_code_status": "serial_closed",
"order_number": null,
"product_image": "",
"serial_codes_attributes": []
}
],
"fees": [],
"attachments": [],
"allow_add_other": false,
"custom_number_setting": "auto",
"approval_information": {},
"document_approvers": [
{
"level": 1,
"status": "approving",
"mode": "single",
"name": "XXX"
}
]
}
}HTTP请求
GET /api/sales/:id.json请求参数
无
返回字段说明
| 返回值字段 | 字段类型 | 字段说明 |
|---|---|---|
| id | integer | ID |
| sale_order_id | integer | 关联销售订单ID |
| sale_order_number | string | 关联销售订单编号 |
| category | string | 类别 |
| approved_level | integer | 审批层级 |
| status | string | 审批状态(draft[草稿] approving[待审批] submitted[已提交] rejected[已驳回] passed[审批通过] deprecated[已作废]) |
| type_name | string | 单据类型名称 |
| creator_name | string | 创建人姓名 |
| seller_name | string | 销售人姓名 |
| customer_name | string | 客户名称 |
| contact_name | string | 联系人姓名 |
| copy_to_member_names | array | 抄送人姓名 |
| copy_to | array | 抄送人 |
| discount | string | 优惠率 |
| deduction | string | 优惠额 |
| amount | string | 优惠后金额 |
| total_quantity | string | 数量合计 |
| total_base_quantity | string | 基本数量合计(开启多单位时候对应的基本单位的数量,未开启时候跟数量一致) |
| total_fee_amount | string | 其他费用金额合计 |
| number | string | 编号 |
| io_at | string | 出库/退货日期 |
| customer_id | string | 客户ID |
| seller_id | string | 销售人ID |
| note | string | 备注 |
| contact_id | string | 联系人ID |
| contact_mobile | string | 联系人手机 |
| contact_phone | string | 联系人电话 |
| contact_address | string | 联系人地址 |
| customer_address | string | 客户地址 |
| has_approve_permission | string | 是否有审批权限 |
| has_revoke_permission | string | 是否有撤回权限 |
| sensitive_access | string | 单据字段权限 |
| contact_sensitive_access | string | 联系人字段权限 |
| customer_sensitive_access | string | 客户字段权限 |
| note_editable | string | 备注是否可编辑 |
| attachment_editable | string | 附件是否可编辑 |
| total_deduction | string | 折扣额合计 |
| total_amount | string | 金额合计 |
| total_tax_amount | string | 税额合计 |
| total_amount_with_tax | string | 税价合计的合计 |
| document_addition_id | integer | 条件审批人的ID |
| created_at | string | 创建时间 |
| status_i18n | string | 审批状态中文 |
| print_count | integer | 打印次数 |
| parent_id | integer | 关联出库单ID |
| parent_number | string | 关联出库单编号 |
| allow_negative_inventory | boolean | 是否允许负库存 |
| gt_order_quantity | boolean | 是否允许大于关联订单数量 |
| has_serial_code | boolean | 是否有序列号 |
| children | array | 关联的退货单 |
| allow_add_other | boolean | 是否添加订单之外的产品 |
| custom_number_setting | string | 自动编号设置 |
| approval_information | hash | 审批信息 |
| document_approvers[0][level] | integer | 审批层级 |
| document_approvers[0][status] | string | 审批状态 |
| document_approvers[0][mode] | string | 审批模式 |
| document_approvers[0][name] | string | 审批人姓名 |
| product_items[0][id] | integer | 产品项ID |
| product_items[0][product_id] | string | 产品ID |
| product_items[0][product_attr_group_id] | string | 产品属性组ID |
| product_items[0][product_unit_id] | string | 产品单位ID |
| product_items[0][order_item_id] | string | 关联销售订单的ID |
| product_items[0][parent_id] | string | 关联出库单的产品项的ID |
| product_items[0][quantity] | string | 数量 |
| product_items[0][price] | string | 价格 |
| product_items[0][price_with_tax] | string | 含税价 |
| product_items[0][discount] | string | 折扣率 |
| product_items[0][deduction] | string | 折扣额 |
| product_items[0][amount] | string | 金额(不含税; 单价 * 数量 - 折扣金额) |
| product_items[0][tax_rate] | string | 税率 |
| product_items[0][tax_amount] | string | 税额 |
| product_items[0][amount_with_tax] | string | 税价合计 |
| product_items[0][modified] | string | 最后修改字段 |
| product_items[0][product_images] | array | 产品图片 |
| product_items[0][name] | string | 产品名称 |
| product_items[0][product_number] | string | 产品编号 |
| product_items[0][attr_names] | string | 产品属性名称 |
| product_items[0][spec] | string | 产品规格 |
| product_items[0][warehouse_id] | string | 仓库ID |
| product_items[0][warehouse_name] | string | 仓库名称 |
| product_items[0][unit] | string | 单位名称 |
| product_items[0][base_unit] | string | 基本单位名称 |
| product_items[0][base_quantity] | string | 基本数量(开启多单位时候基本数量等于基本单位与当前单位的换算率 * 当前数量;未开启多单位时候和当前数量一致) |
| product_items[0][deputy_unit_quantity] | string | 副单位数(需要开启多单位) |
| product_items[0][note] | string | 备注 |
| product_items[0][sale_order_id] | string | 关联的销售订单ID |
| product_items[0][sale_order_number] | string | 关联的销售订单编号 |
| product_items[0][product_image] | string | 产品图片 |
| product_items[0][batch_id] | string | 批次号ID |
| product_items[0][batch_number] | string | 批次号编号 |
| product_items[0][expired_at] | string | 有效日期 |
| product_items[0][produced_at] | string | 生产日期 |
| product_items[0][serial_code_status] | string | 启用序列号状态 |
| product_items[0][order_number] | string | 关联销售订单编号 |
| product_items[0][serial_codes_attributes] | string | 序列号属性 |
| fees | array | 其他费用 |
| attachments[0][id] | integer | 附件ID |
| attachments[0][filename] | string | 附件文件名 |
| attachments[0][url] | string | 附件URL |
编辑销售单
curl -i -X PUT --header "Authorization: Token token=<user_token>, uid=<uid>" \
http://example.com/api/sales/:id.json{
"status": {
"code": "200",
"message": "OK"
},
"sale": {
"id": 57,
"category": "out"
}
}HTTP请求
PUT /api/sales/:id.json请求参数
| 参数名 | 是否必填 | 默认值 | 字段说明 |
|---|---|---|---|
| status | 是 | 无 | 审批状态(draft[草稿] approving[待审批] submitted[已提交] rejected[已驳回] passed[审批通过] deprecated[已作废]) |
| parent_id | 否 | 无 退货单需要,关联的出库单ID | |
| number | 是 | 无 | 编号 |
| category | 是 | in | out: 出库单, in: 退货单 |
| io_at | 是 | 无 | 出库/退货日期 |
| customer_id | 是 | 无 | 客户ID |
| seller_id | 是 | 无 | 销售人ID |
| discount | 是 | 无 | 优惠率 |
| deduction | 是 | 无 | 优惠金额 |
| amount | 是 | 无 | 优惠后金额 |
| note | 否 | 无 | 备注 |
| contact_id | 否 | 无 | 联系人ID |
| contact_name | 否 | 无 | 联系人姓名 |
| contact_mobile | 否 | 无 | 联系人手机 |
| contact_phone | 否 | 无 | 联系人电话 |
| contact_address | 否 | 无 | 联系人地址 |
| customer_address | 否 | 无 | 客户地址 |
| total_quantity | 否 | 无 | 数量合计 |
| total_base_quantity | 否 | 无 | 基本数量合计(开启多单位时候对应的基本单位的数量,未开启时候跟数量一致) |
| total_deduction | 否 | 无 | 优惠额合计(优惠金额) |
| total_amount | 否 | 无 | 金额合计(不含税和优惠金额) |
| total_tax_amount | 否 | 无 | 税额合计(开启税率必须) |
| total_amount_with_tax | 否 | 无 | 优惠后税价合计(开启税率必须) |
| document_addition_attributes[0][copy_to][] | 否 | 无 | 条件审批抄送人ID |
| document_approvers_params[0][level] | 否 | 无 | 审批层级 |
| document_approvers_params[0][member_ids][] | 否 | 无 | 审批人ID |
| attachments_attributes[0][id] | 否 | 无 | 附件ID |
| attachments_attributes[0][dn_key] | 否 | 无 | 七牛存储的key |
| attachments_attributes[0][key] | 否 | 无 | 同上 |
| attachments_attributes[0][filename] | 否 | 无 | 文件名 |
| attachments_attributes[0][url] | 否 | 无 | 文件URL |
| attachments_attributes[0][size] | 否 | 无 | 文件大小 |
| product_items_attributes[0][id] | 是 | 无 | 产品项ID |
| product_items_attributes[0][product_attr_group_id] | 是 | 无 | 产品属性组ID |
| product_items_attributes[0][product_unit_id] | 是 | 无 | 产品单位ID |
| product_items_attributes[0][parent_id] | 否 | 无 | 关联了出库单的退货单的产品项需要 |
| product_items_attributes[0][product_item_id] | 否 | 无 | 从销售订单生成的销售出库单需要 |
| product_items_attributes[0][product_id] | 是 | 无 | 产品ID |
| product_items_attributes[0][warehouse_id] | 是 | 无 | 仓库ID |
| product_items_attributes[0][name] | 是 | 无 | 产品项名称 |
| product_items_attributes[0][product_number] | 是 | 无 | 产品项编号 |
| product_items_attributes[0][attr_names] | 否 | 无 | 产品项属性名称 |
| product_items_attributes[0][spec] | 否 | 无 | 产品项规格 |
| product_items_attributes[0][unit] | 是 | 无 | 产品项单位 |
| product_items_attributes[0][quantity] | 是 | 无 | 产品项数量 |
| product_items_attributes[0][base_unit] | 否 | 无 | 基本单位 |
| product_items_attributes[0][base_quantity] | 否 | 无 | 基本数量(开启多单位时候基本数量等于基本单位与当前单位的换算率 * 当前数量;未开启多单位时候和当前数量一致) |
| product_items_attributes[0][deputy_unit_quantity] | 否 | 无 | 副单位数(需要开启多单位) |
| product_items_attributes[0][price] | 是 | 无 | 产品项价格 |
| product_items_attributes[0][price_with_tax] | 否 | 无 | 含税价 |
| product_items_attributes[0][discount] | 是 | 无 | 产品项折扣率 |
| product_items_attributes[0][deduction] | 是 | 无 | 产品项折扣额 |
| product_items_attributes[0][amount] | 是 | 无 | 产品项金额 |
| product_items_attributes[0][tax_rate] | 否 | 无 | 税率 |
| product_items_attributes[0][tax_amount] | 否 | 无 | 税额 |
| product_items_attributes[0][amount_with_tax] | 否 | 无 | 税价合计 |
| product_items_attributes[0][batch_id] | 否 | 无 | 批次号ID |
| product_items_attributes[0][batch_number] | 否 | 无 | 批次号编号 |
| product_items_attributes[0][produced_at] | 否 | 无 | 生产日期 |
| product_items_attributes[0][expired_at] | 否 | 无 | 有效日期 |
| product_items_attributes[0][note] | 是 | 无 | 产品项备注 |
| product_items_attributes[0][modified] | 是 | 无 | 最后修改字段 |
| product_items_attributes[0][_destroy] | 否 | false | 产品项是否删除 |
- 返回字段说明
| 返回值字段 | 字段类型 | 字段说明 |
|---|---|---|
| id | string | ID |
| category | string | 类别 |
销售出库/退货单获取自动编号
HTTP请求
GET /api/sales/get_auto_number.json请求参数
| 参数名 | 是否必须 | 说明 |
|---|---|---|
| category | 否 | 类别 out/in,默认 out |
- 返回字段说明
| 字段 | 类型 | 说明 |
|---|---|---|
| number | string | 编号 |
- 返回 JSON 数据
{
"status": {
"code": 200,
"message": "OK"
},
"number": "XSD20180528001"
}文档更新时间: 2025-06-12 14:32 作者:姜河