Finax examples

For more context see:

  • Finax Overview

  • CreateEInvoice

  • ReadEInvoice

  • Finax Invoice Helper

The following scenarios show the simplified CreateEInvoice macro our consultants typically use. The snippets can be dropped into any async handler (e.g. async onClick()).

Scenario 1: Create a new PDF in the default layout

const result = await app.businessFunction({
  functionName: "Finax",
  methodName: "CreateEInvoice",
  format: "xrechnung",              // or "zugferd"
  cius: "PEPPOL BIS Billing 3.0",   // optional, default is "XRechnung"
  invoice: {/* invoice JSON */},
  options: {
    returnPdf: true,                 // PDF as Base64 in the result
    returnXml: false                 // skip XML in the response
  }
});

// e.g. push the PDF to a field or download component
app.setFieldValue("txtResult", result);

What happens?

  • Finax generates UBL/CII XML based on format.

  • Then it produces the standard PDF and returns it via brixxPostProcessing.

  • No archiving or existing attachment required.

Scenario 2: Reuse an existing PDF and add fresh XML

const result = await app.businessFunction({
  functionName: "Finax",
  methodName: "CreateEInvoice",
  format: "xrechnung",
  cius: "XRechnung",              // optional, only relevant for format "xrechnung"
  invoice: {/* invoice JSON */},
  options: {
    pdfAttachmentId: 4711,   // existing PDF from the archive
    returnPdf: false,        // no Base64 PDF in the response
    returnXml: true          // but do return the XML
  },
  archive: {
    enabled: true,
    appName: "FinanceApp",
    recordId: 12345,
    documentTypeId: 987
  }
});

console.log("Generated XML", result.Xml);
console.log("Attachment IDs", result.PdfAttachmentId, result.XmlAttachmentId);

What happens?

  • The existing PDF (attachment #4711) is reused and linked to the new XML.

  • XML is regenerated by Finax and – because archive.enabled is true – saved as an attachment.

  • returnPdf: false suppresses the Base64 payload while returnXml: true still returns the XML.

Scenario 3: Read an incoming e-invoice

const result = await app.businessFunction({
  functionName: "Finax",
  methodName: "ReadEInvoice",
  attachmentId: 4711,
  returnXml: true               // optional: include original XML
});

console.log("Extracted invoice JSON", result.Invoice);
console.log("Messages", result.Messages);
console.log("XML", result.Xml);

What happens?

  • If the attachment is a PDF (e.g. ZUGFeRD), the controller first extracts the embedded XML.

  • Finax auto-detects the format (UBL, CII, …) and returns the familiar invoice JSON (result.Invoice).

  • With returnXml: true you also receive the XML and the Finax status messages.


Tip: Other variants (pure XML output, conversions without archiving, etc.) work with the same set of fields. Use app.finax and the wrapper methods (app.createFinaxInvoice, app.addFinaxLine, …) for modular invoice construction (see docs/FinaxInvoiceHelper.md).

Last updated

Was this helpful?