toXml method

void toXml(
  1. XmlBuilder builder
)

Converts the LegalMonetaryTotal instance into XML format using the XmlBuilder.

This method generates an XML representation of the monetary totals for the invoice. It adds elements for each of the financial totals, with the currency set to SAR (Saudi Riyal). Example:

<cbc:LineExtensionAmount currencyID="SAR">1000.00</cbc:LineExtensionAmount>
<cbc:TaxExclusiveAmount currencyID="SAR">950.00</cbc:TaxExclusiveAmount>
<cbc:TaxInclusiveAmount currencyID="SAR">1050.00</cbc:TaxInclusiveAmount>
<cbc:AllowanceTotalAmount currencyID="SAR">50.00</cbc:AllowanceTotalAmount>
<cbc:PrepaidAmount currencyID="SAR">200.00</cbc:PrepaidAmount>
<cbc:PayableAmount currencyID="SAR">850.00</cbc:PayableAmount>

Implementation

void toXml(XmlBuilder builder) {
  builder.element('cbc:LineExtensionAmount',
      nest: lineExtensionAmount, attributes: {'currencyID': 'SAR'});
  builder.element('cbc:TaxExclusiveAmount',
      nest: taxExclusiveAmount, attributes: {'currencyID': 'SAR'});
  builder.element('cbc:TaxInclusiveAmount',
      nest: taxInclusiveAmount, attributes: {'currencyID': 'SAR'});
  builder.element('cbc:AllowanceTotalAmount',
      nest: allowanceTotalAmount.toString(),
      attributes: {'currencyID': 'SAR'});
  builder.element('cbc:PrepaidAmount',
      nest: prepaidAmount.toString(), attributes: {'currencyID': 'SAR'});
  builder.element('cbc:PayableAmount',
      nest: payableAmount, attributes: {'currencyID': 'SAR'});
}