UblEx.Generator.SBDH (UblEx v0.8.1)

Copy Markdown View Source

Generate Standard Business Document Header (SBDH) wrappers for UBL documents.

SBDH is used in Peppol networks for routing and identification of business documents.

Summary

Functions

Strip the StandardBusinessDocument/StandardBusinessDocumentHeader wrapper from UBL XML.

Wrap UBL XML content with an SBDH header.

Functions

strip(xml)

@spec strip(String.t()) :: String.t()

Strip the StandardBusinessDocument/StandardBusinessDocumentHeader wrapper from UBL XML.

Some accounting software cannot process documents with SBDH wrappers. This function extracts the inner UBL document (Invoice, CreditNote, or ApplicationResponse).

If the XML is not wrapped in an SBDH, it is returned unchanged.

Example

sbdh_xml = UblEx.generate_with_sbdh(document_data)
plain_xml = UblEx.Generator.SBDH.strip(sbdh_xml)

wrap(ubl_xml, document_data)

@spec wrap(String.t(), map()) :: String.t()

Wrap UBL XML content with an SBDH header.

Parameters

  • ubl_xml - The UBL XML content to wrap (as string)
  • document_data - Map containing:
    • :type - Document type (:invoice, :credit, :application_response)
    • :number or :id - Document identifier
    • :date - Document date
    • :supplier or :sender - Map with :endpoint_id and :scheme
    • :customer or :receiver - Map with :endpoint_id and :scheme
    • :country - Optional country code (defaults from supplier/sender)

Example

ubl_xml = UblEx.generate(document_data)
sbdh_xml = UblEx.Generator.SBDH.wrap(ubl_xml, document_data)