Skip to content

[Bug]: xRechnung/ZUGfeRD export uses Sell-to Customer's Buyer Reference instead of Bill-to Customer's when Bill-to differs #29868

@miljance

Description

@miljance

Describe the issue

When the Buyer Reference setting on the E-Document Service is set to "Customer Reference" (E-Invoice Routing No. from the Customer card), and a Sales Invoice has a Bill-to Customer that differs from the Sell-to Customer, the xRechnung / ZUGFeRD XML export writes the Buyer Reference (BT-10) of the Sell-to Customer into cbc:BuyerReference. The correct behavior is to use the Buyer Reference of the Bill-to Customer, since the Bill-to Customer is the actual invoice recipient and the Buyer Reference (Leitweg-ID) is used to route the e-invoice to the correct receiving system.

Expected behavior

When the Buyer Reference is sourced from the Customer card ("Customer Reference" setting) and the Sales Invoice has a Bill-to Customer that differs from the Sell-to Customer, the cbc:BuyerReference (BT-10) in the exported XML should contain the E-Invoice Routing No. of the Bill-to Customer, not the Sell-to Customer.

Steps to reproduce

  1. Use Business Central for Germany.
  2. Enable E-Document Service for XRechnung.
  3. In setup:
    • Set Buyer Reference Mandatory = Yes
    • Set Buyer Reference = Customer Reference
  4. Configure a Workflow and a Document Sending Profile for XRechnung (per [docs]). Mark the sending profile as default.
  5. Create two Customers:
    • Customer A with E-Invoice Routing No. = 11-AAA-11
    • Customer B with E-Invoice Routing No. = 22-BBB-22
  6. Create a new Sales Invoice:
    • Sell-to Customer = Customer A
    • Bill-to Customer = Customer B
  7. Add a Sales Line with any value.
  8. Post the Sales Invoice.
  9. Open the Posted Sales InvoiceRelated → E-Document → Open E-Document.
  10. From E-Document Logs, export the XML file.
  11. Inspect <cbc:BuyerReference> in the XML.
    • Actual result: <cbc:BuyerReference>11-AAA-11</cbc:BuyerReference> (Sell-to Customer's E-Invoice Routing No.)
    • Expected result: <cbc:BuyerReference>22-BBB-22</cbc:BuyerReference> (Bill-to Customer's E-Invoice Routing No.)

Additional context

No response

I will provide a fix for a bug

  • I will provide a fix for a bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    FinanceGitHub request for Finance areaapprovedThe issue is approved

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions