Đơn Đặt Hàng KiotViet icon

Đơn Đặt Hàng KiotViet

Quản lý đơn đặt hàng từ KiotViet

Overview

This node manages purchase orders from the KiotViet platform. It allows users to create new purchase orders, retrieve existing ones by ID or list them with filters, update purchase orders, and cancel them. This is useful for automating inventory procurement workflows, synchronizing order data between KiotViet and other systems, or managing supplier orders programmatically.

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.
  • Canceling a purchase order if it was created in error or no longer needed.

Properties

Name Meaning
Thao Tác (operation) The action to perform on purchase orders. Options: Create New, Cancel, Get by ID, Get All, Update
ID ĐƠN ĐẶT Hàng (purchaseOrderId) The unique identifier of the purchase order. Required for get, update, and cancel operations.
Lấy Toàn Bộ (returnAll) Whether to return all purchase orders or limit the number of results. Used with "Get All" operation. Options: true, false
Giới Hạn (limit) Maximum number of purchase orders to return when not returning all. Used with "Get All". Minimum 1.
ID Chi Nhánh (branchId) Branch ID where the purchase order is placed. Required for creating a purchase order.
ID Nhà Cung Cấp (supplierId) Supplier ID for the purchase order. Required for creating a purchase order.
Chi Tiết ĐƠN Hàng (orderDetails) Details of products in the purchase order. Includes product ID, quantity, and price. Used in create and update operations.
Trường Bổ Sung (additionalFields) Additional optional fields such as notes (description) and discount amount. Used in create and update operations.
Bộ Lọc (filters) Filters to apply when listing purchase orders, including status (Processing, Completed, Canceled), createdFrom date, and createdTo date. Used with "Get All".

Output

The node outputs JSON data representing the purchase order(s) returned or affected by the operation:

  • For create, get, update operations: JSON object(s) with purchase order details as returned by the KiotViet API.
  • For getAll: An array of purchase order objects matching the filter criteria or limited by the specified count.
  • For cancel: A JSON object indicating success, e.g., { "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 handle requests.
  • Proper configuration of the API credential in n8n is necessary for successful communication.

Troubleshooting

  • Common issues:

    • Invalid or missing purchase order ID when required will cause errors.
    • Incorrect branch or supplier IDs during creation may result in API errors.
    • Network or authentication failures due to invalid API credentials.
    • Providing malformed product details (e.g., non-numeric IDs or quantities) can cause request failures.
  • Error messages:

    • Errors from the KiotViet API are propagated with their message; ensure IDs and parameters are correct.
    • If the node is set to continue on fail, errors for individual items will be returned in the output JSON under an error field.
  • Resolutions:

    • Verify all required fields are provided and correctly formatted.
    • Check API credentials and network connectivity.
    • Use the "Get All" operation with filters to confirm existing purchase order IDs before referencing them.

Links and References

Discussion