On this page
  1. Configuration
  2. Detection methods
  3. What changes for a detected B2G order
  4. Verify before rollout
  5. Related

B2G / Public Sector Detection

German public-sector recipients (Behörden) route incoming e-invoices by their Leitweg-ID — the EN 16931 Buyer Reference (BT-10). An order detected as B2G is generated with the configured B2G Format and strictly requires a resolvable Buyer Reference / Leitweg-ID; generation fails with a clear error when none can be resolved.

B2G handling is off by default. With detection disabled, every order uses Default B2B Format and the normal buyer-reference fallback rules.

Configuration

Open Stores > Configuration > MageB2B > E-Invoice > B2G / Public Sector (Leitweg-ID).

Setting Options Notes
B2G Detection Method disabled, order_reference, customer_group, customer_attribute How public-sector recipients are identified
B2G Customer Groups Customer group multiselect Visible when the method is customer_group
Leitweg-ID Customer Attribute Customer text attribute select Visible when the method is customer_attribute
Setting Location Notes
B2G Format (Public Sector) einvoice/general/b2g_format under General Settings Format used for detected B2G orders — typically XRechnung. When empty, the default format is used for B2G orders as well.

Detection methods

Method An order counts as B2G when Where BT-10 comes from
Order contains Buyer Reference / Leitweg-ID (order_reference) the order carries a value in its einvoice_buyer_reference field that same order value
Customer Group (customer_group) the order's customer group is one of the configured B2G Customer Groups the order's buyer reference field
Customer Attribute contains Leitweg-ID (customer_attribute) the selected customer attribute is non-empty on the order's customer the order's buyer reference first; the customer attribute value is used when the order carries none

Notes on the boundaries:

  • Guest orders have no customer group membership and no customer attribute; they can only be detected through the order reference method.
  • The customer group method only flags the order as B2G. It does not itself supply a Leitweg-ID — the reference must still reach the order, for example through the native checkout field or the einvoice_buyer_reference extension attribute on POST /V1/carts/{cartId}/payment-information (see REST API).
  • With the customer attribute method, a per-order buyer reference wins over the customer master value: the routing identifier communicated with the order is authoritative.

What changes for a detected B2G order

  1. The recipient is typed b2g and the document is generated with B2G Format when one is configured — otherwise the store's Default B2B Format.
  2. A resolvable Buyer Reference / Leitweg-ID (BT-10) is mandatory. When detection flags the order but neither the order field nor (with the customer-attribute method) the customer record yields a value, generation fails: the document is marked error with a message stating that no Buyer Reference / Leitweg-ID could be resolved.
  3. The increment-ID fallback used for ordinary B2B buyer references does not rescue a detected B2G order.

Recover by supplying the recipient's real Leitweg-ID on the order, then regenerate once (see Error Handling).

Verify before rollout

  • Confirm the detection method against how Leitweg-IDs actually reach your orders — checkout field, ERP order import, or customer master data.
  • Generate one manual document for a detected order and check BT-10, the selected format and the recipient type in the XML.
  • Decide deliberately which detection source is authoritative when several could apply; only one method can be active.