Create New Sales Order
1. API Information
- Endpoint:
/api/v6.1/sale_order
- Method:
POST
- Authentication: Requires
X-API-KEY
- Header:
Content-Type: application/json
X-API-KEY: <your_api_key>
2. Request Body
{
"account": {
"account_code": "CUSTOMER_001",
"account_name": "Customer ABC",
"contact_name": "Contact Person XYZ",
"account_phone": "0900000000",
"account_email": "[email protected]",
"account_address": "Customer Address"
},
"order_code": "ORDER_001",
"order_date": "2025-03-12",
"assigned_username": "employee01",
"order_source_name": "Sales Source A",
"store_name": "Central Warehouse",
"lading_code": "LD_001",
"campaign_code": "CMP_001",
"opportunity_code": "OPP_001",
"saved_order_details": [
{
"product_code": "PROD_001",
"product_name": "Product A",
"unit_name": "Piece",
"quantity": 1,
"price": 65000,
"product_sale_off": 1,
"cash_discount": 10000,
"note": "Fragile product"
}
],
"order_terms": [
{"term_content": "1. Allow co-inspection"},
{"term_content": "2. No returns allowed"}
],
"custom_fields": {
"warehouse_entry_date": "2025-02-03",
"warehouse_storage": "Secret Warehouse",
"tags": [
"Bulky goods",
"Fragile goods",
"High-tech goods",
"Biochemicals",
"High-grade pharmaceuticals"
]
},
"discount": 10,
"discount_amount": 11000,
"vat": 10,
"vat_amount": 4400,
"transport_amount": 10000,
"installation_amount": 10000,
"payment_method_name":"Bank Transfer",
"saved_sale_order_payments": [
{
"method_name": "Bank Transfer",
"amount": 50000,
"description": "Advance payment 50k",
"pay_date": "2025-02-03"
}
],
"is_auto_approve": 0
}
3. Field Descriptions
3.1. Customer Information (account
)
Field | Type | Description |
---|---|---|
account_code | string | Customer code |
account_name | string | Customer name |
contact_name | string | Contact person |
account_phone | string | Customer phone number |
account_email | string | Customer email |
account_address | string | Customer address |
3.2. Order Information
Field | Type | Description |
---|---|---|
order_code | string | Order code |
order_date | string | Order date (YYYY-MM-DD) |
assigned_username | string | Assigned employee |
order_source_name | string | Order source |
store_name | string | Export warehouse name |
lading_code | string | Bill of lading code |
campaign_code | string | Campaign code |
opportunity_code | string | Opportunity code |
3.3. Product Details (saved_order_details
)
Field | Type | Description |
---|---|---|
product_code | string | Product code |
product_name | string | Product name |
unit_name | string | Unit of measurement |
quantity | int | Quantity |
price | int | Product price |
product_sale_off | int | Product discount (0: no discount, 1: discounted) |
cash_discount | int | Discount amount |
note | string | Product note |
3.4. Order Terms (order_terms
)
Field | Type | Description |
---|---|---|
term_content | string | Term content |
3.5. Payment
Field | Type | Description |
---|---|---|
discount | int | Discount percentage |
discount_amount | int | Discount amount |
vat | int | Tax percentage |
vat_amount | int | Tax amount |
transport_amount | int | Shipping fee |
installation_amount | int | Installation fee |
payment_method_name | string | Payment method |
saved_sale_order_payments | array | List of direct payments |
is_auto_approve | int | Whether to auto-approve the order |
4. Response
{
"message": "Successfully added",
"data": {
"order_id": 189,
"order_code": "ORDER_001"
}
}
5. Notes
order_code
must be unique in the system.\- Some fields like
lading_code
,campaign_code
can be left empty if not applicable.\ order_terms
helps set specific terms for the order.\saved_sale_order_payments
will automatically pay for the order when the order is created.\custom_fields
contain various custom fields depending on business requirements.\- Các giá trị của
custom_fields
có kiểudatetime
có thể truyền dang string theo định dạngYYYY-MM-DD
,Y-m-d H:i:s
hoặc timestamp.\ - Các giá trị của
custom_fields
có kiểuselect
có thể truyền id hoặc tên lựa chọn (nếu lựa chọn không có sẵn sẽ tự tạo mới).