Actions22
Overview
The node interacts with the Distru API to manage various business entities. Specifically, the "Upsert Invoice" operation allows users to create a new invoice or update an existing one in the Distru system. This is useful for automating invoice management workflows such as syncing invoices from other systems, updating billing information, or adding charges and items programmatically.
Practical examples include:
- Automatically creating invoices when orders are processed.
- Updating invoice details like due dates or billing locations based on external triggers.
- Adding or modifying invoice line items and associated charges (taxes, discounts).
Properties
| Name | Meaning |
|---|---|
| ID | The unique identifier of the invoice to update. Leave empty to create a new invoice. |
| Order ID | Identifier of the order associated with this invoice. |
| Billing Location ID | Identifier of the billing location for the invoice. |
| Invoice Number | The invoice number string. |
| Invoice Datetime | The date and time when the invoice was issued. |
| Due Datetime | The date and time when the invoice payment is due. |
| Items | A collection of invoice items. Each item includes: |
| - Order Item ID: Associated order item identifier. | |
| - Quantity: Number of units for the item. | |
| - ID: Invoice item ID if updating an existing item. | |
| Charges | A collection of charges, discounts, or taxes applied to the invoice. Each charge includes: |
| - Name: Name of the charge/discount/tax. | |
| - Type: One of CHARGE, DISCOUNT, TAX. | |
| - Price: Flat price amount. | |
| - Percentage: Percentage amount. | |
| - Unit Type: PERCENT or PRICE indicating how the charge is calculated. | |
| - ID: Charge ID if updating an existing charge. | |
| Invoice Items (JSON) | JSON array representing the entire list of invoice items. Overrides the form-based items. |
| Invoice Charges (JSON) | JSON array representing the entire list of charges. Overrides the form-based charges. |
Output
The node outputs an array of JSON objects representing the response from the Distru API after upserting the invoice. The main output field json contains the full invoice data returned by the API, including updated or newly created invoice details such as IDs, timestamps, items, charges, and related metadata.
No binary data output is produced by this operation.
Dependencies
- Requires an API token credential for authenticating with the Distru API.
- The base URL for the API depends on whether staging mode is enabled; it uses either the production or staging endpoint.
- The node uses HTTP POST requests to the
/invoicesendpoint of the Distru API.
Troubleshooting
- Missing API Token: If the API token is not set in credentials, the node will throw an error "Distru API token is not set!" Ensure the API key credential is configured properly.
- Invalid IDs: The node converts string IDs into UUID format expected by the API. Providing invalid or malformed IDs may cause API errors.
- API Errors: Any errors returned by the Distru API during the upsert request will be thrown unless "Continue On Fail" is enabled, in which case the error message will be included in the output JSON.
- Conflicting Input: If both JSON input fields (
itemsJsonorchargesJson) and form inputs for items or charges are provided, the JSON fields override the form inputs. Make sure to provide only one source of truth to avoid confusion.
Links and References
- Distru API Documentation (general reference for API endpoints and data models)
- n8n documentation on Creating Custom Nodes