Document Storage, Email and Downloads

Generation creates the document content. Storage and delivery decide what happens next. Configure these separately so that a valid file is not lost, attached twice or mistaken for a transmitted invoice.

What each format produces

Format XML Hybrid PDF Automatic attachment choice
ZUGFeRD Yes Yes PDF
Factur-X Yes Yes PDF
XRechnung Yes No XML
EN 16931 Yes No XML
PEPPOL BIS Billing 3.0 Yes No XML

The Automatic attachment strategy sends the hybrid PDF when one exists; otherwise it sends XML. XML only, PDF only and Both let you override that choice. Selecting PDF-only for an XML-only format leaves no PDF to attach.

Permanent storage

With Permanent Storage, generated files are written below the configured Magento media path. The default locations are:

pub/media/einvoice/
pub/media/einvoice/creditmemo/

The invoice or credit memo stores the format, status, generation time and relative XML/PDF paths. Admin downloads, API enrichment and customer PDF downloads can reuse those files.

Use permanent storage when you want predictable downloads, backup coverage and a stable hand-off to another system. Treat the directory as invoice data: restrict access, include it in retention planning and avoid serving raw files through guessable public links.

On-demand generation

With On-Demand Generation, the file manager does not persist XML or PDF during normal generation. When a supported action later asks for the document, the service can generate it again from the Magento invoice or credit memo.

This reduces stored files but changes the operational risk:

  • a later configuration or source-data change can affect regenerated output;
  • downloads and emails do more work at request time;
  • the original generated bytes are not preserved as an archive;
  • generation must still be enabled and healthy when the file is requested.

Choose on-demand only when those trade-offs fit your accounting and retention process.

Filename patterns

Invoice patterns can use:

  • {invoice_increment_id}
  • {invoice_id}
  • {format}
  • {type}
  • {date}
  • {datetime}

Credit-memo patterns use the corresponding credit-memo and order identifiers documented in the configuration screen. Path separators and unsafe filename characters are removed by the storage service.

Use a stable, readable pattern. Do not put customer names, email addresses or other personal data in filenames.

Email attachments

Invoice and credit-memo email attachments have separate enable switches and strategies. The sender plugin looks up or generates the document immediately before the Magento email is sent, registers the chosen attachments, sends the message and then clears the temporary registry.

For a safe rollout:

  1. keep attachments disabled while validating files;
  2. configure the invoice attachment switch and strategy without changing the credit-memo switch;
  3. send an invoice email to a reserved .example address captured by local Mailpit;
  4. inspect the Mailpit message, filename, MIME type and actual attachment contents;
  5. repeat with the separate credit-memo attachment switch and a new credit-memo email;
  6. confirm how async generation interacts with the moment each email is sent;
  7. record this as local Mailpit evidence, not real recipient delivery.

If queue or cron generation happens after the transactional email, the document may not yet be available. Align email timing with the selected generation mode.

Customer download

The storefront invoice page can show Download E-Invoice PDF when the customer is allowed to view the invoice and a generated PDF is available. This is for hybrid invoice formats. XML-only formats do not produce a customer PDF through that action.

The controller checks invoice ownership and document availability before returning a file. Guest and registered-customer invoice layouts are supported.

What this does not deliver

Saving a PEPPOL BIS XML file does not send it through PEPPOL. Creating XRechnung XML does not upload it to a public-sector portal. Connect the stored or on-demand output to the delivery service required by the recipient.