Invoice amount calculation

when i try to upload my report it shows a calculation error like :

Invoice line net amount (BT-131) must equal (Invoiced quantity (BT-129) * (Item net price (BT-146) / item price base quantity (BT-149))) + Sum of invoice line charge amount (BT-141) - Sum of invoice line allowance amount (BT-136).

i am having trouble with that .

My XML

<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2">

<ext:UBLExtensions>

<ext:UBLExtension>

<ext:ExtensionURI>urn:oasis:names:specification:ubl:dsig:enveloped:xades</ext:ExtensionURI>

<ext:ExtensionContent>

<sig:UBLDocumentSignatures xmlns:sac="urn:oasis:names:specification:ubl:schema:xsd:SignatureAggregateComponents-2" xmlns:sbc="urn:oasis:names:specification:ubl:schema:xsd:SignatureBasicComponents-2" xmlns:sig="urn:oasis:names:specification:ubl:schema:xsd:CommonSignatureComponents-2">

<sac:SignatureInformation>

<cbc:ID>urn:oasis:names:specification:ubl:signature:1</cbc:ID>

<sbc:ReferencedSignatureID>urn:oasis:names:specification:ubl:signature:Invoice</sbc:ReferencedSignatureID>

<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="signature">

<ds:SignedInfo>

<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2006/12/xml-c14n11"/>

<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256"/>

<ds:Reference Id="invoiceSignedData" URI="">

<ds:Transforms>

<ds:Transform Algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116">

<ds:XPath>not(//ancestor-or-self::ext:UBLExtensions)</ds:XPath>

</ds:Transform>

<ds:Transform Algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116">

<ds:XPath>not(//ancestor-or-self::cac:Signature)</ds:XPath>

</ds:Transform>

<ds:Transform Algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116">

<ds:XPath>not(//ancestor-or-self::cac:AdditionalDocumentReference[cbc:ID='QR'])</ds:XPath>

</ds:Transform>

<ds:Transform Algorithm="http://www.w3.org/2006/12/xml-c14n11"/>

</ds:Transforms>

<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>

<ds:DigestValue>qDoow3tPOxQXjEshiNedLg0hUdkeAW1FDye+jBci9GA=</ds:DigestValue>

</ds:Reference>

<ds:Reference Type="http://www.w3.org/2000/09/xmldsig#SignatureProperties" URI="#xadesSignedProperties">

<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>

<ds:DigestValue>NWM1MTJjNzBiMDU4NmZmNTQ2NDcxODZiYjkwMDIxMDdmYTMwYWIzNTBmMDUwMmQ2NzJkNDYwNDg4MTg5Njc4NA==</ds:DigestValue>

</ds:Reference>

</ds:SignedInfo>

<ds:SignatureValue>MEUCIH/UMseDcvLhhXHyteLkpVcGzksmDtiySfydFyBErNm2AiEAjXO9lygDJBl+DbBiNHDR1kBdtFlRrXKoz/49n/4Yt2k=</ds:SignatureValue>

<ds:KeyInfo>

<ds:X509Data>

<ds:X509Certificate>MIICEDCCAbegAwIBAgIGAZVYsYqWMAoGCCqGSM49BAMCMBUxEzARBgNVBAMMCmVJbnZvaWNpbmcwHhcNMjUwMzAyMjEwOTQwWhcNMzAwMzAyMjEwMDAwWjBKMRcwFQYDVQQDDA5FR1MxLTg4NjQzMTE0NTEQMA4GA1UECwwHUmV2b0VSUDEQMA4GA1UECgwHUmV2b0VSUDELMAkGA1UEBhMCU0EwVjAQBgcqhkjOPQIBBgUrgQQACgNCAAT4R//aFZs02/tUTzdHZQ4jH8lg20fsL8o6302IXtFL+tqB6xxQ5ma+lFmyC2AUfO71ZOLW6+c8h8N5V1d9HKNgo4HAMIG9MAwGA1UdEwEB/wQCMAAwgawGA1UdEQSBpDCBoaSBnjCBmzE/MD0GA1UEBAw2MS1SZXZvRVJQfDItSU9TfDMtNzU3YmEwZWYtYWFkZC00YjE1LWFiZjQtZTFiMTA4OGZkOTM3MR8wHQYKCZImiZPyLGQBAQwPMzAxMTIxOTcxNTAwMDAzMQ0wCwYDVQQMDAQwMTAwMRkwFwYDVQQaDBAxMTExIHdmd3dmLCAwMDAwMQ0wCwYDVQQPDARGb29kMAoGCCqGSM49BAMCA0cAMEQCIBCT4N8c/dlwb0+arXp2xt/3SPeV2kQ/VBH1vf/hJdsaAiBELOpB944SgmmqBQ80u+TOXgZ3qHjXkaQrg7+snoI0rQ==</ds:X509Certificate>

</ds:X509Data>

</ds:KeyInfo>

<ds:Object>

<xades:QualifyingProperties xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" Target="signature">

<xades:SignedProperties xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" Id="xadesSignedProperties">

<xades:SignedSignatureProperties>

<xades:SigningTime>2025-03-03T00:09:45</xades:SigningTime>

<xades:SigningCertificate>

<xades:Cert>

<xades:CertDigest>

<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>

<ds:DigestValue>NzhhN2E5NTM5YTc0Y2NmMmVmNDViMmMyMzExYWY1MjM1NDExMzE1MjBjMTU3NGU3MjQ0OTYxMjRmNjljNjllMA==</ds:DigestValue>

</xades:CertDigest>

<xades:IssuerSerial>

<ds:X509IssuerName>CN=eInvoicing</ds:X509IssuerName>

<ds:X509SerialNumber>1740949785238</ds:X509SerialNumber>

</xades:IssuerSerial>

</xades:Cert>

</xades:SigningCertificate>

</xades:SignedSignatureProperties>

</xades:SignedProperties>

</xades:QualifyingProperties>

</ds:Object>

</ds:Signature>

</sac:SignatureInformation>

</sig:UBLDocumentSignatures>

</ext:ExtensionContent>

</ext:UBLExtension>

</ext:UBLExtensions>

<cbc:ProfileID>reporting:1.0</cbc:ProfileID>

<cbc:ID>0058</cbc:ID>

<cbc:UUID>757ba0ef-aadd-4b15-abf4-e1b1088fd937</cbc:UUID>

<cbc:IssueDate>2025-03-03</cbc:IssueDate>

<cbc:IssueTime>00:09:45</cbc:IssueTime>

<cbc:InvoiceTypeCode name="0200000">388</cbc:InvoiceTypeCode>

<cbc:DocumentCurrencyCode>SAR</cbc:DocumentCurrencyCode>

<cbc:TaxCurrencyCode>SAR</cbc:TaxCurrencyCode>

<cac:AdditionalDocumentReference>

<cbc:ID>ICV</cbc:ID>

<cbc:UUID>1</cbc:UUID>

</cac:AdditionalDocumentReference>

<cac:AdditionalDocumentReference>

<cbc:ID>PIH</cbc:ID>

<cac:Attachment>

<cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain">NjdjZDEzMGItOGQzMi00ZmUzLWJmNmUtZDY1MTI5Yjc1MDhm</cbc:EmbeddedDocumentBinaryObject>

</cac:Attachment>

</cac:AdditionalDocumentReference>

<cac:AdditionalDocumentReference>

<cbc:ID>QR</cbc:ID>

<cac:Attachment>

<cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain">AQdSZXZvRVJQAg8zMDExMjE5NzE1MDAwMDMDEzIwMjUtMDMtMDNUMDA6MDk6NDUEBjExNS4wMAUFMTUuMDAGLHFEb293M3RQT3hRWGpFc2hpTmVkTGcwaFVka2VBVzFGRHllK2pCY2k5R0E9B2BNRVVDSUgvVU1zZURjdkxoaFhIeXRlTGtwVmNHemtzbUR0aXlTZnlkRnlCRXJObTJBaUVBalhPOWx5Z0RKQmwrRGJCaU5IRFIxa0JkdEZsUnJYS296LzQ5bi80WXQyaz0IWDBWMBAGByqGSM49AgEGBSuBBAAKA0IABPhH/9oVmzTb+1RPN0dlDiMfyWDbR+wvyjrfTYhe0Uv62oHrHFDmZr6UWbILYBR87vVk4tbr5zyHw3lXV30co2AJRjBEAiAQk+DfHP3ZcG9Pmq16dsbf90j3ldpEP1QR9b3/4SXbGgIgRCzqQfeOEoJpqgUPNLvkzl4Gd6h415GkK4O/rJ6CNK0=</cbc:EmbeddedDocumentBinaryObject>

</cac:Attachment>

</cac:AdditionalDocumentReference>

<cac:Signature>

<cbc:ID>urn:oasis:names:specification:ubl:signature:Invoice</cbc:ID>

<cbc:SignatureMethod>urn:oasis:names:specification:ubl:dsig:enveloped:xades</cbc:SignatureMethod>

</cac:Signature>

<cac:AccountingSupplierParty>

<cac:Party>

<cac:PartyIdentification>

<cbc:ID schemeID="CRN">301121971500003787878787878</cbc:ID>

</cac:PartyIdentification>

<cac:PostalAddress>

<cbc:StreetName>wfwwf</cbc:StreetName>

<cbc:BuildingNumber>1111</cbc:BuildingNumber>

<cbc:PlotIdentification>srgdg</cbc:PlotIdentification>

<cbc:CitySubdivisionName>Est</cbc:CitySubdivisionName>

<cbc:CityName>0000</cbc:CityName>

<cbc:PostalZone>12345</cbc:PostalZone>

<cac:Country>

<cbc:IdentificationCode>SA</cbc:IdentificationCode>

</cac:Country>

</cac:PostalAddress>

<cac:PartyTaxScheme>

<cbc:CompanyID>301121971500003</cbc:CompanyID>

<cac:TaxScheme>

<cbc:ID>VAT</cbc:ID>

</cac:TaxScheme>

</cac:PartyTaxScheme>

<cac:PartyLegalEntity>

<cbc:RegistrationName>RevoERP</cbc:RegistrationName>

</cac:PartyLegalEntity>

</cac:Party>

</cac:AccountingSupplierParty>

<cac:AccountingCustomerParty/>

<cac:TaxTotal>

<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:Percent>15.00</cbc:Percent>

<cac:TaxScheme>

<cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5153">VAT</cbc:ID>

</cac:TaxScheme>

</cac:TaxCategory>

</cac:TaxSubtotal>

</cac:TaxTotal>

<cac:TaxTotal>

<cbc:TaxAmount currencyID="SAR">15.00</cbc:TaxAmount>

</cac:TaxTotal>

<cac:LegalMonetaryTotal>

<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</cbc:AllowanceTotalAmount>

<cbc:PrepaidAmount currencyID="SAR">0</cbc:PrepaidAmount>

<cbc:PayableAmount currencyID="SAR">115.00</cbc:PayableAmount>

</cac:LegalMonetaryTotal>

<cac:InvoiceLine>

<cbc:ID>333</cbc:ID>

<cbc:InvoicedQuantity unitCode="PCE">1</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:Name>test again</cbc:Name>

<cac:ClassifiedTaxCategory>

<cbc:ID>S</cbc:ID>

<cbc:Percent>15.00</cbc:Percent>

<cac:TaxScheme>

<cbc:ID>VAT</cbc:ID>

</cac:TaxScheme>

</cac:ClassifiedTaxCategory>

</cac:Item>

<cac:Price>

<cbc:PriceAmount currencyID="SAR">10</cbc:PriceAmount>

<cac:AllowanceCharge>

<cbc:ChargeIndicator>false</cbc:ChargeIndicator>

<cbc:AllowanceChargeReason>A discount</cbc:AllowanceChargeReason>

<cbc:Amount currencyID="SAR">0.00</cbc:Amount>

</cac:AllowanceCharge>

</cac:Price>

</cac:InvoiceLine>

</Invoice>

Dear @tushar

Thanks for reaching out, Welcome to our community

In the provided XML you have the following:

One invoice line with:

  1. The Quantity is = in the InvoicedQuantity Tag
  2. The price amount Is = in the PriceAmount Tag
  3. In the LineExtensionAmount here is the wrong calculation the value is = 100
    however, it should be 10 as per the calculation since you don’t have Allowance in the Item level then LineExtensionAmount = (price * Quantity).

I hope it is clear enough now, please let me know if it works.

Thanks,
Ibrahem Daoud.

Thank you for reaching out .

My product Unit price is = 100
Quantity is = 1

LineExtensionAmount = 1 * 100.

isn’t it ?

@tushar check the tag <cbc:PriceAmount currencyID=“SAR”>10</cbc:PriceAmount> it is not 100 it is 10. You have to change the unit price to 100 in this tag.

Solved …

Thank you very much @Ankit_Tiwari . And also @idaoud , thank you.

1 Like