How to fill Credit note XML for discount

Hi,

If a credit note is to be issued for an invoice, how should the values inside the XML populated?

For example, there is a invoice for SAR 100 with tax SAR 15.
A credit note is required to be issued for a discount amount of SAR 20.

Below is our implementation of the credit note issued for this discount.
Kindly check and validate if this implementation is correct.
Invoice
<cac:TaxTotal xmlns=“”>
<cbc:TaxAmount currencyID=“SAR”>15.00</cbc:TaxAmount>
</cac:TaxTotal>
<cac:TaxTotal xmlns=“”>
<cbc:TaxAmount currencyID=“SAR”>15.00</cbc:TaxAmount>
cac:TaxSubtotal
<cbc:TaxableAmount currencyID=“SAR”>100.00</cbc:TaxableAmount>
<cbc:TaxAmount currencyID=“SAR”>15.00</cbc:TaxAmount>
cac:TaxCategory
<cbc:ID schemeAgencyID=“6” schemeID=“UN/ECE 5305”>S</cbc:ID>
cbc:Percent15.0</cbc:Percent>
cac:TaxScheme
<cbc:ID schemeAgencyID=“6” schemeID=“UN/ECE 5153”>VAT</cbc:ID>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal>
<cac:LegalMonetaryTotal xmlns=“”>
<cbc:LineExtensionAmount currencyID=“SAR”>100.00</cbc:LineExtensionAmount>
<cbc:TaxExclusiveAmount currencyID=“SAR”>100.00</cbc:TaxExclusiveAmount>
<cbc:TaxInclusiveAmount currencyID=“SAR”>115.00</cbc:TaxInclusiveAmount>
<cbc:AllowanceTotalAmount currencyID=“SAR”>0.00</cbc:AllowanceTotalAmount>
<cbc:ChargeTotalAmount currencyID=“SAR”>0.00</cbc:ChargeTotalAmount>
<cbc:PrepaidAmount currencyID=“SAR”>0.00</cbc:PrepaidAmount>
<cbc:PayableRoundingAmount currencyID=“SAR”>0.00</cbc:PayableRoundingAmount>
<cbc:PayableAmount currencyID=“SAR”>115.00</cbc:PayableAmount>
</cac:LegalMonetaryTotal>
<cac:InvoiceLine xmlns=“”>
cbc:ID1</cbc:ID>
<cbc:InvoicedQuantity unitCode=“PCE”>5.0</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount currencyID=“SAR”>100.00</cbc:LineExtensionAmount>
cac:TaxTotal
<cbc:TaxAmount currencyID=“SAR”>15.00</cbc:TaxAmount>
<cbc:RoundingAmount currencyID=“SAR”>115.00</cbc:RoundingAmount>
</cac:TaxTotal>
cac:Item
cbc:NameYonex cock</cbc:Name>
cac:ClassifiedTaxCategory
cbc:IDS</cbc:ID>
cbc:Percent15.0</cbc:Percent>
cac:TaxScheme
cbc:IDVAT</cbc:ID>
</cac:TaxScheme>
</cac:ClassifiedTaxCategory>
</cac:Item>
cac:Price
<cbc:PriceAmount currencyID=“SAR”>20.0</cbc:PriceAmount>
cac:AllowanceCharge
cbc:ChargeIndicatorfalse</cbc:ChargeIndicator>
cbc:AllowanceChargeReasondiscount</cbc:AllowanceChargeReason>
<cbc:Amount currencyID=“SAR”>0.00</cbc:Amount>
</cac:AllowanceCharge>
</cac:Price>
</cac:InvoiceLine>

Credit Note for Discount
<cac:TaxTotal xmlns=“”>
<cbc:TaxAmount currencyID=“SAR”>12.00</cbc:TaxAmount>
</cac:TaxTotal>
<cac:TaxTotal xmlns=“”>
<cbc:TaxAmount currencyID=“SAR”>12.00</cbc:TaxAmount>
cac:TaxSubtotal
<cbc:TaxableAmount currencyID=“SAR”>80.00</cbc:TaxableAmount>
<cbc:TaxAmount currencyID=“SAR”>12.00</cbc:TaxAmount>
cac:TaxCategory
<cbc:ID schemeAgencyID=“6” schemeID=“UN/ECE 5305”>S</cbc:ID>
cbc:Percent15.0</cbc:Percent>
cac:TaxScheme
<cbc:ID schemeAgencyID=“6” schemeID=“UN/ECE 5153”>VAT</cbc:ID>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal>
<cac:LegalMonetaryTotal xmlns=“”>
<cbc:LineExtensionAmount currencyID=“SAR”>80.00</cbc:LineExtensionAmount>
<cbc:TaxExclusiveAmount currencyID=“SAR”>80.00</cbc:TaxExclusiveAmount>
<cbc:TaxInclusiveAmount currencyID=“SAR”>92.00</cbc:TaxInclusiveAmount>
<cbc:AllowanceTotalAmount currencyID=“SAR”>0.00</cbc:AllowanceTotalAmount>
<cbc:ChargeTotalAmount currencyID=“SAR”>0.00</cbc:ChargeTotalAmount>
<cbc:PrepaidAmount currencyID=“SAR”>0.00</cbc:PrepaidAmount>
<cbc:PayableRoundingAmount currencyID=“SAR”>0.00</cbc:PayableRoundingAmount>
<cbc:PayableAmount currencyID=“SAR”>92.00</cbc:PayableAmount>
</cac:LegalMonetaryTotal>
<cac:InvoiceLine xmlns=“”>
cbc:ID1</cbc:ID>
<cbc:InvoicedQuantity unitCode=“PCE”>5.0</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount currencyID=“SAR”>80.00</cbc:LineExtensionAmount>
cac:TaxTotal
<cbc:TaxAmount currencyID=“SAR”>12.00</cbc:TaxAmount>
<cbc:RoundingAmount currencyID=“SAR”>92.00</cbc:RoundingAmount>
</cac:TaxTotal>
cac:Item
cbc:NameYonex cock</cbc:Name>
cac:ClassifiedTaxCategory
cbc:IDS</cbc:ID>
cbc:Percent15.0</cbc:Percent>
cac:TaxScheme
cbc:IDVAT</cbc:ID>
</cac:TaxScheme>
</cac:ClassifiedTaxCategory>
</cac:Item>
cac:Price
<cbc:PriceAmount currencyID=“SAR”>80.0</cbc:PriceAmount>
cac:AllowanceCharge
cbc:ChargeIndicatorfalse</cbc:ChargeIndicator>
cbc:AllowanceChargeReasondiscount</cbc:AllowanceChargeReason>
<cbc:Amount currencyID=“SAR”>20.00</cbc:Amount>
</cac:AllowanceCharge>
</cac:Price>
</cac:InvoiceLine>

@itujar_it credit note should be issued only for 20. Please look at sample credit note in SDK. Do not use allowance charge field (discount) in credit note. You should mention Discount in the item description and add a line for SAR 20 in Credit Note.