Overview
This node manages purchase orders in the KiotViet system. It allows users to create new purchase orders, retrieve existing ones by ID or list them with filters, update orders, and cancel orders. This is useful for automating procurement workflows, integrating order management into broader business processes, or synchronizing purchase data between KiotViet and other systems.
Practical examples:
- Automatically creating a purchase order when stock levels fall below a threshold.
- Fetching details of a specific purchase order to verify its status.
- Listing all purchase orders within a date range or by status for reporting.
- Updating an existing purchase order with new product quantities or prices.
- Canceling a purchase order that was entered by mistake.
Properties
| Name | Meaning |
|---|---|
| ID Chi Nhánh | Branch ID where the purchase order is placed (required for creation). |
| ID Nhà Cung Cấp | Supplier ID for the purchase order (required for creation). |
| Chi Tiết ĐơN Hàng | Order details consisting of multiple products, each with: - ID Sản Phẩm (Product ID) - Số Lượng (Quantity) - Giá (Unit Price) |
| Trường Bổ Sung | Additional optional fields for the order: - Ghi Chú (Notes) - Chiết Khấu (Discount amount) |
| ID ĐƠN ĐẶT HÀNG | Purchase order ID used for get, update, or cancel operations. |
| Lấy Toàn Bộ | Boolean flag to return all results or limit the number when listing purchase orders. |
| Giới Hạn | Maximum number of results to return when not returning all (used in listing). |
| Bộ Lọc | Filters for listing purchase orders: - Trạng Thái (Status): Processing, Completed, Canceled - Từ Ngày (Created From date YYYY-MM-DD) - Đến Ngày (Created To date YYYY-MM-DD) |
Output
The node outputs JSON data representing the purchase order(s) returned or affected by the operation:
- For create and update, it returns the created or updated purchase order object including IDs, product details, and any additional fields.
- For get, it returns a single purchase order object by ID.
- For getAll, it returns a list of purchase orders matching the filters and pagination settings.
- For cancel, it returns a success confirmation object
{ success: true }.
No binary data output is produced by this node.
Dependencies
- Requires an API key credential for authenticating with the KiotViet API.
- The node uses a shared KiotViet API helper class to perform HTTP requests.
- Proper configuration of the API credential in n8n is necessary for successful communication.
Troubleshooting
- Invalid or missing branchId or supplierId on create: Ensure these required fields are provided and are valid integers.
- Invalid purchaseOrderId on get, update, or cancel: Confirm the purchase order ID exists and is correctly formatted as an integer.
- API authentication errors: Verify the API key credential is correctly set up and has sufficient permissions.
- Empty or malformed orderDetails: When creating or updating, ensure product details include valid product IDs, quantities, and prices.
- Rate limits or network issues: Handle transient API failures by enabling "Continue On Fail" to avoid stopping the workflow.
Common error messages typically relate to invalid parameters or authentication failures and can be resolved by checking input values and credentials.
Links and References
- KiotViet API Documentation (official API docs for purchase orders)
- n8n documentation on creating custom nodes