Thêm mới báo giá
1. Thông Tin API
- Endpoint:
/api/v6.1/quote - Method:
POST - Authentication: Yêu cầu
X-API-KEY - Header:
Content-Type: application/jsonX-API-KEY: <your_api_key>
2. Request Body
{
"account_id": 1595,
"contact_id": 1758,
"quote_date": 1752033851,
"assigned_user": 1551,
"quote_number": 1,
"description": "Mô tả",
"project_name": "Dự án 1",
"project_address": "Hà Nội",
"note": "<p>Nội dung báo giá</p>",
"service_charge_after_vat": 0,
"transport": 10,
"transport_amount": 3000,
"discount": 10,
"discount_amount": 3300,
"after_vat": 0,
"vat": 10,
"vat_amount": 2970,
"installation": 10,
"installation_amount": 3300,
"installation_charge_after_discount": 0,
"end_date": 1752080400,
"custom_fields": {
"b1": "1234",
"b2": "3353"
},
"quote_details": [
{
"product_id": 279,
"description": "",
"quantity": 2,
"price": 15000,
"discount": 10,
"discount_amount": 1000,
"vat": 10,
"row_id": 1,
"items": [
{
"alias": "1.1",
"quantity": 1,
"price": 20000,
"vat": 0,
"discount": 0,
"discount_amount": 0,
"title": "SP101 - 1",
"row_id": 2,
"parent_row_id": 1,
"root_row_id": 1
}
],
"variants": [
{
"variant_attributes": [
{
"attribute_id": 1,
"attribute_value_id": 4
},
{
"attribute_id": 2,
"attribute_value_id": 8
}
]
}
]
}
]
}
3. Mô Tả Các Trường
3.1. Thông tin báo giá
| Trường | Loại | Bắt buộc | Mô tả |
|---|---|---|---|
quote_code | string | Mã báo giá | |
account_id | integer | yes | Định danh khách hàng |
contact_id | integer | yes | Id liên hệ khách hàng |
quote_date | timestamp | yes | Ngày tạo báo giá |
end_date | timestamp | Ngày kết thúc | |
assigned_user | integer | Id người thực hiện | |
quote_number | integer | Lần báo giá | |
description | string | Mô tả | |
project_name | string | Tên dự án | |
project_address | string | Địa chỉ dự án | |
note | string | Nội dung báo giá | |
custom_fields | object | Định nghĩa dữ liệu |
3.2. Thông tin tài chính
| Trường | Loại | Bắt buộc | Mô tả |
|---|---|---|---|
after_vat | enum (0,1) | yes | Chiết khấu trước/sau thuế |
discount | numeric | yes | Chiết khấu báo giá (%) |
discount_amount | numeric | yes | Chiết khấu báo giá ($) |
vat | numeric | yes | VAT báo giá (%) |
vat_amount | numeric | yes | VAT báo giá ($) |
service_charge_after_vat | enum (0,1) | yes | Phí dịch vụ trước/sau thuế |
transport | numeric | yes | Phí vận chuyển (%) |
transport_amount | numeric | yes | Phí vận chuyển ($) |
installation_charge_after_discount | enum (0,1) | yes | Phí lắp đặt trước/sau thuế |
installation | numeric | yes | Phí lắp đặt (%) |
installation_amount | numeric | yes | Phí lắp đặt ($) |
3.3. Danh sách sản phẩm (quote_details)
| Trường | Loại | Bắt buộc | Mô tả |
|---|---|---|---|
quote_details | array | yes | Danh sách sản phẩm |
quote_details.*.product_id | integer | yes | Định danh sản phẩm |
quote_details.*.description | string | Mô tả sản phẩm | |
quote_details.*.quantity | integer | yes | Số lượng sản phẩm |
quote_details.*.price | numeric | yes | Đơn giá sản phẩm |
quote_details.*.discount | numeric | yes | Chiết khấu sản phẩm (%) |
quote_details.*.discount_amount | numeric | yes | Chiết khấu sản phẩm ($) |
quote_details.*.vat | numeric | yes | VAT sản phẩm (%) |
quote_details.*.vat_amount | numeric | yes | VAT sản phẩm ($) |
quote_details.*.row_id | integer | yes | Định danh để nối với phụ kiện |
quote_details.*.items | array | Danh sách phụ kiện đi kèm | |
quote_details.*.variants | array | Biến thể của sản phẩm (Bắt buộc nếu sản phẩm có biến thể) |
3.4. Phụ kiện (quote_details.*.items)
| Trường | Loại | Bắt buộc | Mô tả |
|---|---|---|---|
alias | string | Alias phụ kiện | |
title | string | Tên phụ kiện | |
quantity | numeric | yes | Số lượng phụ kiện |
price | numeric | yes | Đơn giá phụ kiện |
discount | numeric | yes | Chiết khấu phụ kiện (%) |
discount_amount | numeric | yes | Chiết khấu phụ kiện ($) |
vat | numeric | yes | VAT phụ kiện (%) |
row_id | integer | yes | Định danh để nối với phụ kiện con |
parent_row_id | integer | yes | Định danh xác định phụ kiện cha |
root_row_id | integer | yes | Định danh xác định sản phẩm |
4. Response
{
"message": "Thêm mới thành công",
"data": {
"id": 67,
"quote_code": "BG090720252"
}
}
5. Ghi Chú
quote_detailsbắt buộc phải có ít nhất một sản phẩm.custom_fieldschứa các trường tùy chỉnh, có thể lấy danh sách từ API custom fields.- Các giá trị ngày tháng (
quote_date,end_date) truyền dưới dạng timestamp. - Nếu sản phẩm có biến thể, trường
variantsbắt buộc phải được truyền.