toXml method

void toXml(
  1. XmlBuilder builder
)

Converts the BillingReference instance to an XML representation using the XmlBuilder.

This method constructs the XML structure for the billing reference, which includes the invoice number and the issue date formatted according to ISO 8601.

Example:

XmlBuilder builder = XmlBuilder();
billingReference.toXml(builder);

Implementation

void toXml(XmlBuilder builder) {
  builder.element('cac:BillingReference', nest: () {
    // Invoice document reference element
    builder.element('cac:InvoiceDocumentReference', nest: () {
      // Invoice ID element containing the invoice number and issue date
      builder.element('cbc:ID', nest: invoiceNumber);
      if (invoiceIssueDate != null) {
        builder.element('cbc:IssueDate',
            nest: invoiceIssueDate?.toIso8601String().split('T')[0]);
      }
    });
  });
}