@e-invoice-eu/core
    Preparing search index...

    Type Alias InvoiceServiceOptions

    Invoice creation options.

    type InvoiceServiceOptions = {
        attachments?: FileInfo[];
        embedPDF?: boolean;
        format: string;
        lang: string;
        libreOfficePath?: string;
        noWarnings?: boolean;
        pdf?: FileInfo;
        postProcessor?: (data: ExpandObject) => Promise<void>;
        spreadsheet?: FileInfo;
    }
    Index

    Properties

    attachments?: FileInfo[]

    An array of supplementary attachments.

    embedPDF?: boolean

    Set to invoice description if invoice should be embedded.

    format: string

    The invoice format like XRECHNUNG-UBL or Factur-X-Extended.

    lang: string

    A language identifier like "fr-ca".

    libreOfficePath?: string

    Path to LibreOffice executable.

    noWarnings?: boolean

    Shut up warnings.

    pdf?: FileInfo

    A PDF version of the invoice. For Factur-X, either data or pdf must be present.

    postProcessor?: (data: ExpandObject) => Promise<void>

    Callback function invoked before the XML is rendered. This allows fine-tuning the output XML, for example by adding currently unsupported CII elements. Another use case is applying fixes for open bugs.

    The data argument is a plain JavaScript object where all nodes are either an Array or another object, and all leaves are strings. The type ExpandObject is defined in xmlbuilder2.

    UBL example:

    const defaultNotes = [
    'We only use organic ingredients (no GMO)!',
    'We work exclusively with regional suppliers.',
    ];

    invoiceServiceOptions.postProcessor = async (data: ExpandObject) => {
    const document = data['Invoice'] ?? data['CreditNote'];
    const notes = document['cbc:Note'];

    if (notes) {
    notes.push(...defaultNotes);
    } else {
    document['cbc:Note'] = [...defaultNotes];
    }

    CII example:

    const defaultNotes = [
    'We only use organic ingredients (no GMO)!',
    'We work exclusively with regional suppliers.',
    ];

    const postProcessor = async (data: ExpandObject) => {
    if (
    data['rsm:CrossIndustryInvoice']['rsm:ExchangedDocument']![
    'ram:IncludedNote'
    ]
    ) {
    if (
    !Array.isArray(
    data['rsm:CrossIndustryInvoice']['rsm:ExchangedDocument']![
    'ram:IncludedNote'
    ],
    )
    ) {
    data['rsm:CrossIndustryInvoice']['rsm:ExchangedDocument']![
    'ram:IncludedNote'
    ] = [
    data['rsm:CrossIndustryInvoice']['rsm:ExchangedDocument']![
    'ram:IncludedNote'
    ],
    ];
    }
    } else {
    data['rsm:CrossIndustryInvoice']['rsm:ExchangedDocument']![
    'ram:IncludedNote'
    ] = [];
    }
    const notes =
    data['rsm:CrossIndustryInvoice']['rsm:ExchangedDocument'][
    'ram:IncludedNote'
    ];
    for (const note of defaultNotes) {
    notes.push({ 'ram:Content': note });
    }
    };
    spreadsheet?: FileInfo

    The spreadsheet data.