Basic Invoice

Basic Invoice Node

Overview

The "Basic Invoice" node generates a PDF invoice document from a JSON payload containing invoice details. It is useful in workflows where you need to create and output invoice files dynamically based on input data, such as automating billing processes or generating invoices for orders.

For example, you can provide an invoice's metadata (like title, sender information, and ID) as a JSON string, and the node will produce a PDF file named accordingly, which can then be sent via email or stored.

Properties

Name Meaning
Payload A JSON string representing all parameters of the invoice. This should include fields like id, date, title, from (with label), and any other relevant invoice details. The node uses this data to generate the invoice PDF.

Output

The node outputs an array of items, each containing:

  • json: An object with a placeholder field { data: 1 } indicating successful processing.
  • binary.invoice: The generated invoice PDF file encoded in base64 format, with the following metadata:
    • data: Base64-encoded PDF content.
    • mimeType: "application/pdf".
    • fileName: A filename constructed from the invoice's title, sender label, and ID, ending with .pdf.
    • fileExtension: "pdf".

This binary output can be used downstream in the workflow for saving, emailing, or further processing the invoice document.

Dependencies

  • The node depends on two internal modules:
    • A module that constructs the invoice document structure from the input JSON.
    • A PDF generation module that converts the invoice document into a PDF buffer.
  • No external API keys or services are required.
  • The node requires valid JSON input for the payload property.

Troubleshooting

  • Invalid JSON in Payload: If the payload string is not valid JSON, the node will throw a parsing error. Ensure the payload is correctly formatted JSON.
  • Missing Required Fields: The PDF filename construction relies on title, from.label, and id fields in the payload. Missing these may cause errors or incorrect filenames.
  • Error Handling: If an error occurs during processing and "Continue On Fail" is enabled, the node will output the error alongside the original input item; otherwise, it will stop execution and throw an error indicating the item index.
  • Empty Payload: Providing an empty payload string will cause JSON parsing to fail.

Links and References

Discussion