Skip to content

[Bug]: [DE] ZUGFeRD export misses Seller Order Reference (BT-14) and lacks extensibility event in InsertApplicableHeaderTradeAgreement #29892

@pri-kise

Description

@pri-kise

Describe the issue

The ZUGFeRD XML export (codeunit 13917 "Export ZUGFeRD Document") does not include the seller’s internal sales order reference when it is available on the posted sales document header.

In Business Central, Sales Invoice Header."Order No." contains the seller’s internal Sales Order No. (invoice created from order). This corresponds to BT-14 (Seller order reference) in EN 16931.

In ZUGFeRD / Factur-X (CII), this reference should be represented using ram:SellerOrderReferencedDocument, but it is currently missing from the generated XML.

Additionally, there is no integration event at the end of InsertApplicableHeaderTradeAgreement(...) to allow partners to extend the header trade agreement node before it is attached to the XML tree (e.g., to add ram:ContractReferencedDocument).

Expected behavior

  • If Order No. is populated on the posted document header, the ZUGFeRD export should include BT-14 via ram:SellerOrderReferencedDocument (following the ZUGFeRD mapping).

  • If Order No. is empty, omit the element (no change).

  • Add an IntegrationEvent to allow extensions to modify/extend the ApplicableHeaderTradeAgreement node before it is added:

    [IntegrationEvent(false, false)]
    local procedure OnAfterInsertApplicableHeaderTradeAgreement(
        var HeaderTradeAgreementElement: XmlElement;
        HeaderRecordRef: RecordRef)
    begin
    end;

    Example call placement:

    OnAfterInsertApplicableHeaderTradeAgreement(HeaderTradeAgreementElement, HeaderRecordRef);
    RootXMLNode.Add(HeaderTradeAgreementElement);

Steps to reproduce

  1. Create a Sales Order and post an invoice created from that order (so "Order No." is populated on the posted Sales Invoice).
  2. Export the posted document as ZUGFeRD.
  3. Inspect the XML near ram:ApplicableHeaderTradeAgreement.
  4. Observe that ram:SellerOrderReferencedDocument (BT-14) is missing.

Additional context

  • Business term: BT-14 Seller order reference (seller’s internal order identifier).
  • Event request enables partner scenarios like adding ram:ContractReferencedDocument for contract numbers.

I will provide a fix for a bug

  • I will provide a fix for a bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions