Configurable mapping of the buyer reference in e-invoices (ZUGFeRD / XRechnung)
In the current default behavior, the <BuyerReference> field in the generated e-invoice (ZUGFeRD / EN16931) is populated with the purchase order number.
However, for invoices to public sector clients (government agencies), the routing ID is generally required in the <BuyerReference> field. If the purchase order number is used instead, this can lead to:
- Validation errors in ERP/accounting systems (e.g., Lexware)
- Rejections by public sector clients
- Problems with input tax deduction
- Rejection by Peppol/XRechnung validators
Currently, there is no configuration option in the admin panel to adjust the BuyerReference mapping.
Problem:
- The <BuyerReference> parameter is not flexibly configurable by default.
- Merchants with government clients must provide the routing ID.
- - Currently, customization is only possible via:
- custom code
- event subscriber (ZugferdInvoiceGeneratedEvent)
- plugin customizations.
- This results in unnecessary implementation effort for a common scenario.
Proposal
Introduce a configurable option in the document/e-invoice setup:
Option A – Selection field in the Admin
In the section:
"Settings → Documents → E-Invoice"
Configurable mapping field for BuyerReference (fe):
- Dropdown:
- Order number
- Customer number
- Custom field (from Customer)
- Custom field (from Order)
- Freely definable mapping (e.g., via Twig expression)