Assistance Required for ZATCA SDK 3.3.6 - Signed Properties Hashing Error

We are currently using ZATCA SDK version 3.3.6, and in an effort to streamline our process, we are trying to avoid using the Fatoora commands that involve the SDK. Instead, we aim to rely solely on the DLL from the SDK file.
When we generate the JSON request using the Fatoora command, the invoice is posted successfully. However, when we generate the request via the DLL using the RequestGenerator, we encounter the following error during invoice posting:
{
“type”: “ERROR”,
“code”: “signed-properties-hashing”,
“category”: “CERTIFICATE_ERRORS”,
“message”: “Invalid signed properties hashing, SignedProperties with id=‘xadesSignedProperties’”,
“status”: “ERROR”
}
below is screen shot of the difference in decoded base 64 invoice from the 2 methods

DigestValue (SignedPropertiesHash)
The value will be the same if the Signing DateTime and X509Certificate are the same.

SignatureValue
You will not get the same value for every signing even from the same invoice with the same InvoiceHash and PrivateKey.
The only way to make sure the value is correct is to verify it using the PublicKey.
If the result is VALID, then the value is correct.

For your problem, you need to show the Invoice you are signing and how you are signing your Invoice using the DLL in your code.


Since I’m using .NET Framework 4.6, which isn’t compatible with the latest SDK, I’m utilizing reflection to sign the invoice and perform other functionalities.

<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:sig="urn:oasis:names:specification:ubl:schema:xsd:CommonSignatureComponents-2" xmlns:sac="urn:oasis:names:specification:ubl:schema:xsd:SignatureAggregateComponents-2" xmlns:sbc="urn:oasis:names:specification:ubl:schema:xsd:SignatureBasicComponents-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>lFS8YN+qUbaFovNz6gnrr/gIiyUMTPbH0X05JYdFX4Y=</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>OThiZjY1NTE4ZjUzMDU0YWNkZmJlNGQ5Y2EzZmIxMTgwN2NkOWZjYWVlZTg3NjUwZTU2MDVjNDk2NmFlNjYwOA==</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>MEYCIQCsA9sXSglvP50ZPoat/42i4nE53lymVWNvhBqS8EuMeQIhAI4Vg4BlBdvqCQ04A+RAlvsEFKwcpBo5Q15+Aj6k8XR/</ds:SignatureValue>
<ds:KeyInfo>
<ds:X509Data>
<ds:X509Certificate>MIID3jCCA4SgAwIBAgITEQAAOAPF90Ajs/xcXwABAAA4AzAKBggqhkjOPQQDAjBiMRUwEwYKCZImiZPyLGQBGRYFbG9jYWwxEzARBgoJkiaJk/IsZAEZFgNnb3YxFzAVBgoJkiaJk/IsZAEZFgdleHRnYXp0MRswGQYDVQQDExJQUlpFSU5WT0lDRVNDQTQtQ0EwHhcNMjQwMTExMDkxOTMwWhcNMjkwMTA5MDkxOTMwWjB1MQswCQYDVQQGEwJTQTEmMCQGA1UEChMdTWF4aW11bSBTcGVlZCBUZWNoIFN1cHBseSBMVEQxFjAUBgNVBAsTDVJpeWFkaCBCcmFuY2gxJjAkBgNVBAMTHVRTVC04ODY0MzExNDUtMzk5OTk5OTk5OTAwMDAzMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEoWCKa0Sa9FIErTOv0uAkC1VIKXxU9nPpx2vlf4yhMejy8c02XJblDq7tPydo8mq0ahOMmNo8gwni7Xt1KT9UeKOCAgcwggIDMIGtBgNVHREEgaUwgaKkgZ8wgZwxOzA5BgNVBAQMMjEtVFNUfDItVFNUfDMtZWQyMmYxZDgtZTZhMi0xMTE4LTliNTgtZDlhOGYxMWU0NDVmMR8wHQYKCZImiZPyLGQBAQwPMzk5OTk5OTk5OTAwMDAzMQ0wCwYDVQQMDAQxMTAwMREwDwYDVQQaDAhSUlJEMjkyOTEaMBgGA1UEDwwRU3VwcGx5IGFjdGl2aXRpZXMwHQYDVR0OBBYEFEX+YvmmtnYoDf9BGbKo7ocTKYK1MB8GA1UdIwQYMBaAFJvKqqLtmqwskIFzVvpP2PxT+9NnMHsGCCsGAQUFBwEBBG8wbTBrBggrBgEFBQcwAoZfaHR0cDovL2FpYTQuemF0Y2EuZ292LnNhL0NlcnRFbnJvbGwvUFJaRUludm9pY2VTQ0E0LmV4dGdhenQuZ292LmxvY2FsX1BSWkVJTlZPSUNFU0NBNC1DQSgxKS5jcnQwDgYDVR0PAQH/BAQDAgeAMDwGCSsGAQQBgjcVBwQvMC0GJSsGAQQBgjcVCIGGqB2E0PsShu2dJIfO+xnTwFVmh/qlZYXZhD4CAWQCARIwHQYDVR0lBBYwFAYIKwYBBQUHAwMGCCsGAQUFBwMCMCcGCSsGAQQBgjcVCgQaMBgwCgYIKwYBBQUHAwMwCgYIKwYBBQUHAwIwCgYIKoZIzj0EAwIDSAAwRQIhALE/ichmnWXCUKUbca3yci8oqwaLvFdHVjQrveI9uqAbAiA9hC4M8jgMBADPSzmd2uiPJA6gKR3LE03U75eqbC/rXA==</ds:X509Certificate>
</ds:X509Data>
</ds:KeyInfo>
<ds:Object>
<xades:QualifyingProperties xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" Target="signature">
<xades:SignedProperties Id="xadesSignedProperties">
<xades:SignedSignatureProperties>
<xades:SigningTime>2024-10-24T16:23:36</xades:SigningTime>
<xades:SigningCertificate>
<xades:Cert>
<xades:CertDigest>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>ZDMwMmI0MTE1NzVjOTU2NTk4YzVlODhhYmI0ODU2NDUyNTU2YTVhYjhhMDFmN2FjYjk1YTA2OWQ0NjY2MjQ4NQ==</ds:DigestValue>
</xades:CertDigest>
<xades:IssuerSerial>
<ds:X509IssuerName>CN=PRZEINVOICESCA4-CA, DC=extgazt, DC=gov, DC=local</ds:X509IssuerName>
<ds:X509SerialNumber>379112742831380471835263969587287663520528387</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>13</cbc:ID>
<cbc:UUID>d52d917b-2450-495e-9833-cd9a68851eb4</cbc:UUID>
<cbc:IssueDate>2024-10-24</cbc:IssueDate>
<cbc:IssueTime>15:45:21</cbc:IssueTime>
<cbc:InvoiceTypeCode name="0200000">388</cbc:InvoiceTypeCode>
<cbc:Note languageID="en"/>
<cbc:DocumentCurrencyCode>SAR</cbc:DocumentCurrencyCode>
<cbc:TaxCurrencyCode>SAR</cbc:TaxCurrencyCode>
<cac:AdditionalDocumentReference>
<cbc:ID>ICV</cbc:ID>
<cbc:UUID>13</cbc:UUID>
</cac:AdditionalDocumentReference>
<cac:AdditionalDocumentReference>
<cbc:ID>PIH</cbc:ID>
<cac:Attachment>
<cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain">Xgp3WNVGjK/gGq9J70biIb0XcVorXwR1eb3KYmEdas0=</cbc:EmbeddedDocumentBinaryObject>
</cac:Attachment>
</cac:AdditionalDocumentReference>
<cac:AdditionalDocumentReference>
<cbc:ID>QR</cbc:ID>
<cac:Attachment>
<cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain">ARVTcGVlZCBUZWNoIFN1cHBseSBMVEQCDzM5OTk5OTk5OTkwMDAwMwMTMjAyNC0xMC0yNFQxNTo0NToyMQQFNzcuMDUFBTEwLjA1BixsRlM4WU4rcVViYUZvdk56NmducnIvZ0lpeVVNVFBiSDBYMDVKWWRGWDRZPQdgTUVZQ0lRQ3NBOXNYU2dsdlA1MFpQb2F0LzQyaTRuRTUzbHltVldOdmhCcVM4RXVNZVFJaEFJNFZnNEJsQmR2cUNRMDRBK1JBbHZzRUZLd2NwQm81UTE1K0FqNms4WFIvCFgwVjAQBgcqhkjOPQIBBgUrgQQACgNCAAShYIprRJr0UgStM6/S4CQLVUgpfFT2c+nHa+V/jKEx6PLxzTZcluUOru0/J2jyarRqE4yY2jyDCeLte3UpP1R4CUcwRQIhALE/ichmnWXCUKUbca3yci8oqwaLvFdHVjQrveI9uqAbAiA9hC4M8jgMBADPSzmd2uiPJA6gKR3LE03U75eqbC/rXA==</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">1010010000</cbc:ID>
</cac:PartyIdentification>
<cac:PostalAddress>
<cbc:StreetName>Prince Sultan</cbc:StreetName>
<cbc:BuildingNumber>2322</cbc:BuildingNumber>
<cbc:CitySubdivisionName>Al-Murabba</cbc:CitySubdivisionName>
<cbc:CityName>Riyadh</cbc:CityName>
<cbc:PostalZone>23333</cbc:PostalZone>
<cac:Country>
<cbc:IdentificationCode>SA</cbc:IdentificationCode>
</cac:Country>
</cac:PostalAddress>
<cac:PartyTaxScheme>
<cbc:CompanyID>399999999900003</cbc:CompanyID>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:PartyTaxScheme>
<cac:PartyLegalEntity>
<cbc:RegistrationName>Speed Tech Supply LTD</cbc:RegistrationName>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingSupplierParty>
<cac:AccountingCustomerParty>
<cac:Party>
<cac:PostalAddress>
<cbc:StreetName/>
<cbc:CitySubdivisionName/>
<cac:Country>
<cbc:IdentificationCode>SA</cbc:IdentificationCode>
</cac:Country>
</cac:PostalAddress>
<cac:PartyTaxScheme>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:PartyTaxScheme>
<cac:PartyLegalEntity>
<cbc:RegistrationName/>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingCustomerParty>
<cac:PaymentMeans>
<cbc:PaymentMeansCode>10</cbc:PaymentMeansCode>
</cac:PaymentMeans>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="SAR">10.05</cbc:TaxAmount>
</cac:TaxTotal>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="SAR">10.05</cbc:TaxAmount>
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="SAR">67.00</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="SAR">10.05</cbc:TaxAmount>
<cac:TaxCategory>
<cbc:ID>S</cbc:ID>
<cbc:Percent>15</cbc:Percent>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal>
<cac:LegalMonetaryTotal>
<cbc:LineExtensionAmount currencyID="SAR">67.00</cbc:LineExtensionAmount>
<cbc:TaxExclusiveAmount currencyID="SAR">67.00</cbc:TaxExclusiveAmount>
<cbc:TaxInclusiveAmount currencyID="SAR">77.05</cbc:TaxInclusiveAmount>
<cbc:AllowanceTotalAmount currencyID="SAR">0</cbc:AllowanceTotalAmount>
<cbc:PrepaidAmount currencyID="SAR">0</cbc:PrepaidAmount>
<cbc:PayableAmount currencyID="SAR">77.05</cbc:PayableAmount>
</cac:LegalMonetaryTotal>
<cac:InvoiceLine>
<cbc:ID>1</cbc:ID>
<cbc:InvoicedQuantity unitCode="">1.00000</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount currencyID="SAR">67.00</cbc:LineExtensionAmount>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="SAR">10.05</cbc:TaxAmount>
<cbc:RoundingAmount currencyID="SAR">77.05</cbc:RoundingAmount>
</cac:TaxTotal>
<cac:Item>
<cbc:Name>igyu</cbc:Name>
<cac:ClassifiedTaxCategory>
<cbc:ID>S</cbc:ID>
<cbc:Percent>15</cbc:Percent>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:ClassifiedTaxCategory>
</cac:Item>
<cac:Price>
<cbc:PriceAmount currencyID="SAR">67.00</cbc:PriceAmount>
<cac:AllowanceCharge>
<cbc:ChargeIndicator>true</cbc:ChargeIndicator>
<cbc:AllowanceChargeReason/>
<cbc:Amount currencyID="SAR">0</cbc:Amount>
</cac:AllowanceCharge>
</cac:Price>
</cac:InvoiceLine>
</Invoice>

this is my signed invoice

Not sure, I think you need to add this line in your Invoice

<?xml version="1.0" encoding="UTF-8"?>

and resigned your XML.

Your xml

Your xml + encoding tag

For your code, as you use Zatca.eInvoice.SDK you can try this simple code to signing, Create Api Payload, get InvoiceHash and get base64QrCode.

using Newtonsoft.Json;
using System;
using System.IO;
using System.Text;
using System.Xml;
using Zatca.EInvoice.SDK;
using Zatca.EInvoice.SDK.Contracts.Models;

namespace ConsoleApp2
{
    internal class Program
    {
        static void Main()
        {
            string x509CertificateContent = "MIID3jCCA4SgAwIBAgITEQAAOAPF90Ajs/xcXwABAAA4AzAKBggqhkjOPQQDAjBiMRUwEwYKCZImiZPyLGQBGRYFbG9jYWwxEzARBgoJkiaJk/IsZAEZFgNnb3YxFzAVBgoJkiaJk/IsZAEZFgdleHRnYXp0MRswGQYDVQQDExJQUlpFSU5WT0lDRVNDQTQtQ0EwHhcNMjQwMTExMDkxOTMwWhcNMjkwMTA5MDkxOTMwWjB1MQswCQYDVQQGEwJTQTEmMCQGA1UEChMdTWF4aW11bSBTcGVlZCBUZWNoIFN1cHBseSBMVEQxFjAUBgNVBAsTDVJpeWFkaCBCcmFuY2gxJjAkBgNVBAMTHVRTVC04ODY0MzExNDUtMzk5OTk5OTk5OTAwMDAzMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEoWCKa0Sa9FIErTOv0uAkC1VIKXxU9nPpx2vlf4yhMejy8c02XJblDq7tPydo8mq0ahOMmNo8gwni7Xt1KT9UeKOCAgcwggIDMIGtBgNVHREEgaUwgaKkgZ8wgZwxOzA5BgNVBAQMMjEtVFNUfDItVFNUfDMtZWQyMmYxZDgtZTZhMi0xMTE4LTliNTgtZDlhOGYxMWU0NDVmMR8wHQYKCZImiZPyLGQBAQwPMzk5OTk5OTk5OTAwMDAzMQ0wCwYDVQQMDAQxMTAwMREwDwYDVQQaDAhSUlJEMjkyOTEaMBgGA1UEDwwRU3VwcGx5IGFjdGl2aXRpZXMwHQYDVR0OBBYEFEX+YvmmtnYoDf9BGbKo7ocTKYK1MB8GA1UdIwQYMBaAFJvKqqLtmqwskIFzVvpP2PxT+9NnMHsGCCsGAQUFBwEBBG8wbTBrBggrBgEFBQcwAoZfaHR0cDovL2FpYTQuemF0Y2EuZ292LnNhL0NlcnRFbnJvbGwvUFJaRUludm9pY2VTQ0E0LmV4dGdhenQuZ292LmxvY2FsX1BSWkVJTlZPSUNFU0NBNC1DQSgxKS5jcnQwDgYDVR0PAQH/BAQDAgeAMDwGCSsGAQQBgjcVBwQvMC0GJSsGAQQBgjcVCIGGqB2E0PsShu2dJIfO+xnTwFVmh/qlZYXZhD4CAWQCARIwHQYDVR0lBBYwFAYIKwYBBQUHAwMGCCsGAQUFBwMCMCcGCSsGAQQBgjcVCgQaMBgwCgYIKwYBBQUHAwMwCgYIKwYBBQUHAwIwCgYIKoZIzj0EAwIDSAAwRQIhALE/ichmnWXCUKUbca3yci8oqwaLvFdHVjQrveI9uqAbAiA9hC4M8jgMBADPSzmd2uiPJA6gKR3LE03U75eqbC/rXA=="; 
            string privateKeyContent = "MHQCAQEEIL14JV+5nr/sE8Sppaf2IySovrhVBtt8+yz+g4NRKyz8oAcGBSuBBAAKoUQDQgAEoWCKa0Sa9FIErTOv0uAkC1VIKXxU9nPpx2vlf4yhMejy8c02XJblDq7tPydo8mq0ahOMmNo8gwni7Xt1KT9UeA==";
            string xmlPath = @"C:\Tmp\testxml.xml";
           
            XmlDocument xmlDocument = new XmlDocument();
            xmlDocument.Load(xmlPath);

            // Make sure xml has encoding tag and not linearized to avoid Hasing Error by Zatca Server
            xmlDocument = PrettyXml(xmlDocument);

            // Call GenerateRequestApi and capture the results
            var (requestResult, invoiceHash, base64QrCode) = GenerateRequestApi(xmlDocument, x509CertificateContent, privateKeyContent);

            // Print all results
            Console.WriteLine("Request Result: \n" + JsonConvert.SerializeObject(requestResult.InvoiceRequest));
            Console.WriteLine("\nInvoice Hash: " + invoiceHash);
            Console.WriteLine("\nBase64 QR Code: " + base64QrCode);

            Console.ReadLine();
        } 

        public static (RequestResult requestResult, string InvoiceHash, string Base64QrCode) GenerateRequestApi(XmlDocument document, string x509CertificateContent, string privateKey)
        {
            SignResult signedInvoiceResult = new EInvoiceSigner().SignDocument(document, x509CertificateContent, privateKey);

            if (signedInvoiceResult.IsValid)
            {
                // Get InvoiceHash and  QrCode from Signed Invoice
                var (invoiceHash, base64QrCode) = ExtractInvoiceHashAndBase64QrCode(signedInvoiceResult.SignedEInvoice);

                var requestResult = new RequestGenerator().GenerateRequest(signedInvoiceResult.SignedEInvoice);
                return (requestResult, invoiceHash, base64QrCode);
            }
            else
            {
                // Handle the case when the signing is not valid
                return (null, null, null); // Adjust as needed
            }
        }

        public static (string invoiceHash, string base64QRCode) ExtractInvoiceHashAndBase64QrCode(XmlDocument doc)
        {
            XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
            nsmgr.AddNamespace("ext", "urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2");
            nsmgr.AddNamespace("ds", "http://www.w3.org/2000/09/xmldsig#");
            nsmgr.AddNamespace("cbc", "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2");
            nsmgr.AddNamespace("cac", "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2");

            // Extracting specific DigestValue for invoiceSignedData
            string invoiceHash = doc.SelectSingleNode("//ds:Reference[@Id='invoiceSignedData']/ds:DigestValue", nsmgr)?.InnerText;
            string base64QRCode = doc.SelectSingleNode("//cac:AdditionalDocumentReference[cbc:ID='QR']/cac:Attachment/cbc:EmbeddedDocumentBinaryObject", nsmgr)?.InnerText;

            return (invoiceHash, base64QRCode);
        }

        public static XmlDocument PrettyXml(XmlDocument inputXml)
        {
            XmlDocument formattedXml = new XmlDocument() { PreserveWhitespace = true};

            using (MemoryStream memoryStream = new MemoryStream())
            {
                using (StreamWriter streamWriter = new StreamWriter(memoryStream, new UTF8Encoding(false))) // false to exclude BOM
                {
                    XmlWriterSettings settings = new XmlWriterSettings()
                    {
                        Indent = true,
                        IndentChars = "    ",
                        OmitXmlDeclaration = false,
                        Encoding = Encoding.UTF8,
                    };

                    using (XmlWriter xmlWriter = XmlWriter.Create(streamWriter, settings))
                    {
                        inputXml.Save(xmlWriter);
                    }
                }

                // Get the UTF-8 encoded string from the MemoryStream
                string utf8Xml = Encoding.UTF8.GetString(memoryStream.ToArray()).Trim();
                
                // Load the UTF-8 XML string into the new XmlDocument
                formattedXml.LoadXml(utf8Xml);
            }

            return formattedXml;
        }
    }
}

actually that encode tag exists in my signed xml but still i get the above hashing error and i also tried with how u generate the api request, that also results in error.

Did you try my code on the same original invoice?

Let try it, and share the result.

yes have tried it with your code but code same hasshing error

Interesting, can you share your original invoice xml please…

Invoice shared above is good in my code

Hello, could you please help me out on your path? i have tried it with your code but when my code in line SignDocument method its getting error. description its like([Error] Generating EInvoice Hash إنشاء هاش الفاتورة الإلكترونية[Error] Generating EInvoice Signature انشاء التوقيع محليا[Error] Populating Signed Signature Properties توقيع الفاتورة محليا[Error] Generating EInvoice QR Code) also i have been using 3.3.6 sdk thanks for your help…

@Taha
Please Share your Origional Invoice XML, maybe something missing in your XML.

Even when i am using standard Invoice xml its getting same error description, not make sense at all…

Please edit your message, make sure use this preformated tag for your xml

image

okay

<?xml version="1.0" encoding="UTF-8"?>
<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">
	<cbc:ProfileID>reporting:1.0</cbc:ProfileID>
	<cbc:ID>SME00023</cbc:ID>
	<cbc:UUID>8d487816-70b8-4ade-a618-9d620b73814a</cbc:UUID>
	<cbc:IssueDate>2022-09-07</cbc:IssueDate>
	<cbc:IssueTime>12:21:28</cbc:IssueTime>
	<cbc:InvoiceTypeCode name="0100000">388</cbc:InvoiceTypeCode>
	<cbc:DocumentCurrencyCode>SAR</cbc:DocumentCurrencyCode>
	<cbc:TaxCurrencyCode>SAR</cbc:TaxCurrencyCode>
	<cac:AccountingSupplierParty>
		<cac:Party>
			<cac:PartyIdentification>
				<cbc:ID schemeID="CRN">1010010000</cbc:ID>
			</cac:PartyIdentification>
			<cac:PostalAddress>
				<cbc:StreetName>الامير سلطان | Prince Sultan</cbc:StreetName>
				<cbc:BuildingNumber>2322</cbc:BuildingNumber>
				<cbc:CitySubdivisionName>المربع | Al-Murabba</cbc:CitySubdivisionName>
				<cbc:CityName>الرياض | Riyadh</cbc:CityName>
				<cbc:PostalZone>23333</cbc:PostalZone>
				<cac:Country>
					<cbc:IdentificationCode>SA</cbc:IdentificationCode>
				</cac:Country>
			</cac:PostalAddress>
			<cac:PartyTaxScheme>
				<cbc:CompanyID>399999999900003</cbc:CompanyID>
				<cac:TaxScheme>
					<cbc:ID>VAT</cbc:ID>
				</cac:TaxScheme>
			</cac:PartyTaxScheme>
			<cac:PartyLegalEntity>
				<cbc:RegistrationName>شركة توريد التكنولوجيا بأقصى سرعة المحدودة | Maximum Speed Tech Supply LTD</cbc:RegistrationName>
			</cac:PartyLegalEntity>
		</cac:Party>
	</cac:AccountingSupplierParty>
	<cac:AccountingCustomerParty>
		<cac:Party>
			<cac:PostalAddress>
				<cbc:StreetName>صلاح الدين | Salah Al-Din</cbc:StreetName>
				<cbc:BuildingNumber>1111</cbc:BuildingNumber>
				<cbc:CitySubdivisionName>المروج | Al-Murooj</cbc:CitySubdivisionName>
				<cbc:CityName>الرياض | Riyadh</cbc:CityName>
				<cbc:PostalZone>12222</cbc:PostalZone>
				<cac:Country>
					<cbc:IdentificationCode>SA</cbc:IdentificationCode>
				</cac:Country>
			</cac:PostalAddress>
			<cac:PartyTaxScheme>
				<cbc:CompanyID>399999999800003</cbc:CompanyID>
				<cac:TaxScheme>
					<cbc:ID>VAT</cbc:ID>
				</cac:TaxScheme>
			</cac:PartyTaxScheme>
			<cac:PartyLegalEntity>
				<cbc:RegistrationName>شركة نماذج فاتورة المحدودة | Fatoora Samples LTD</cbc:RegistrationName>
			</cac:PartyLegalEntity>
		</cac:Party>
	</cac:AccountingCustomerParty>
	<cac:Delivery>
		<cbc:ActualDeliveryDate>2022-09-07</cbc:ActualDeliveryDate>
	</cac:Delivery>
	<cac:PaymentMeans>
		<cbc:PaymentMeansCode>10</cbc:PaymentMeansCode>
	</cac:PaymentMeans>
	<cac:AllowanceCharge>
		<cbc:ChargeIndicator>false</cbc:ChargeIndicator>
		<cbc:AllowanceChargeReason>discount</cbc:AllowanceChargeReason>
		<cbc:Amount currencyID="SAR">0.00</cbc:Amount>
		<cac:TaxCategory>
			<cbc:ID schemeID="UN/ECE 5305"
			        schemeAgencyID="6">S</cbc:ID>
			<cbc:Percent>15</cbc:Percent>
			<cac:TaxScheme>
				<cbc:ID schemeID="UN/ECE 5153"
				        schemeAgencyID="6">VAT</cbc:ID>
			</cac:TaxScheme>
		</cac:TaxCategory>
	</cac:AllowanceCharge>
	<cac:TaxTotal>
		<cbc:TaxAmount currencyID="SAR">0.6</cbc:TaxAmount>
	</cac:TaxTotal>
	<cac:TaxTotal>
		<cbc:TaxAmount currencyID="SAR">0.6</cbc:TaxAmount>
		<cac:TaxSubtotal>
			<cbc:TaxableAmount currencyID="SAR">4.00</cbc:TaxableAmount>
			<cbc:TaxAmount currencyID="SAR">0.60</cbc:TaxAmount>
			<cac:TaxCategory>
				<cbc:ID schemeID="UN/ECE 5305"
				        schemeAgencyID="6">S</cbc:ID>
				<cbc:Percent>15.00</cbc:Percent>
				<cac:TaxScheme>
					<cbc:ID schemeID="UN/ECE 5153"
					        schemeAgencyID="6">VAT</cbc:ID>
				</cac:TaxScheme>
			</cac:TaxCategory>
		</cac:TaxSubtotal>
	</cac:TaxTotal>
	<cac:LegalMonetaryTotal>
		<cbc:LineExtensionAmount currencyID="SAR">4.00</cbc:LineExtensionAmount>
		<cbc:TaxExclusiveAmount currencyID="SAR">4.00</cbc:TaxExclusiveAmount>
		<cbc:TaxInclusiveAmount currencyID="SAR">4.60</cbc:TaxInclusiveAmount>
		<cbc:AllowanceTotalAmount currencyID="SAR">0.00</cbc:AllowanceTotalAmount>
		<cbc:PrepaidAmount currencyID="SAR">0.00</cbc:PrepaidAmount>
		<cbc:PayableAmount currencyID="SAR">4.60</cbc:PayableAmount>
	</cac:LegalMonetaryTotal>
	<cac:InvoiceLine>
		<cbc:ID>1</cbc:ID>
		<cbc:InvoicedQuantity unitCode="PCE">2.000000</cbc:InvoicedQuantity>
		<cbc:LineExtensionAmount currencyID="SAR">4.00</cbc:LineExtensionAmount>
		<cac:TaxTotal>
			<cbc:TaxAmount currencyID="SAR">0.60</cbc:TaxAmount>
			<cbc:RoundingAmount currencyID="SAR">4.60</cbc:RoundingAmount>
		</cac:TaxTotal>
		<cac:Item>
			<cbc:Name>قلم رصاص</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">2.00</cbc:PriceAmount>
			<cac:AllowanceCharge>
				<cbc:ChargeIndicator>true</cbc:ChargeIndicator>
				<cbc:AllowanceChargeReason>discount</cbc:AllowanceChargeReason>
				<cbc:Amount currencyID="SAR">0.00</cbc:Amount>
			</cac:AllowanceCharge>
		</cac:Price>
	</cac:InvoiceLine>
</Invoice>

There are missing ICV and PIH in your Invoice,

What does that mean? could you please light me up…

Should I manually add the PIH and ICV in the xml by myself?

by the way that’s not signed invoice

You cannot sing until you have ICV and PIH

	<cac:AdditionalDocumentReference>
		<cbc:ID>ICV</cbc:ID>
		<cbc:UUID>367</cbc:UUID>
	</cac:AdditionalDocumentReference>
	<cac:AdditionalDocumentReference>
		<cbc:ID>PIH</cbc:ID>
		<cac:Attachment>
			<cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain">jm5rGEtLkD+MvuyqZAekOzq66E8oseRHLhiIpqe2ElI=</cbc:EmbeddedDocumentBinaryObject>
		</cac:Attachment>
	</cac:AdditionalDocumentReference>

Where could you put it in my xml file, i really dont have any idea
thats my xml file, could you please edit my xml file and send me

<?xml version="1.0" encoding="UTF-8"?>
<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:sig="urn:oasis:names:specification:ubl:schema:xsd:CommonSignatureComponents-2" xmlns:sac="urn:oasis:names:specification:ubl:schema:xsd:SignatureAggregateComponents-2" xmlns:sbc="urn:oasis:names:specification:ubl:schema:xsd:SignatureBasicComponents-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>DA3Zu0b61favkHETr8e82GCfMa2YZLtTPlnWrdNalvQ=</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>YjA0NGM3MDJjNTk0NzIyMzk2NTU3M2U1MGQwYThiNWFiMjAwOWQ2ODMzZGI1ZTM2MGRhMDgzNjEyZDU5M2JmMQ==</ds:DigestValue>
                            </ds:Reference>
                        </ds:SignedInfo>
                        <ds:SignatureValue>MEYCIQCXTJBA3J/pWFBIn6OrFl6h7O/+M+ua3OD4S1LF6eRZvgIhAMVQIBAkDWzTG2YYfBalOaYcnyFCxT3gyz7ya+4e1Ik9</ds:SignatureValue>
                        <ds:KeyInfo>
                            <ds:X509Data>
                                <ds:X509Certificate>MIID3jCCA4SgAwIBAgITEQAAOAPF90Ajs/xcXwABAAA4AzAKBggqhkjOPQQDAjBiMRUwEwYKCZImiZPyLGQBGRYFbG9jYWwxEzARBgoJkiaJk/IsZAEZFgNnb3YxFzAVBgoJkiaJk/IsZAEZFgdleHRnYXp0MRswGQYDVQQDExJQUlpFSU5WT0lDRVNDQTQtQ0EwHhcNMjQwMTExMDkxOTMwWhcNMjkwMTA5MDkxOTMwWjB1MQswCQYDVQQGEwJTQTEmMCQGA1UEChMdTWF4aW11bSBTcGVlZCBUZWNoIFN1cHBseSBMVEQxFjAUBgNVBAsTDVJpeWFkaCBCcmFuY2gxJjAkBgNVBAMTHVRTVC04ODY0MzExNDUtMzk5OTk5OTk5OTAwMDAzMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEoWCKa0Sa9FIErTOv0uAkC1VIKXxU9nPpx2vlf4yhMejy8c02XJblDq7tPydo8mq0ahOMmNo8gwni7Xt1KT9UeKOCAgcwggIDMIGtBgNVHREEgaUwgaKkgZ8wgZwxOzA5BgNVBAQMMjEtVFNUfDItVFNUfDMtZWQyMmYxZDgtZTZhMi0xMTE4LTliNTgtZDlhOGYxMWU0NDVmMR8wHQYKCZImiZPyLGQBAQwPMzk5OTk5OTk5OTAwMDAzMQ0wCwYDVQQMDAQxMTAwMREwDwYDVQQaDAhSUlJEMjkyOTEaMBgGA1UEDwwRU3VwcGx5IGFjdGl2aXRpZXMwHQYDVR0OBBYEFEX+YvmmtnYoDf9BGbKo7ocTKYK1MB8GA1UdIwQYMBaAFJvKqqLtmqwskIFzVvpP2PxT+9NnMHsGCCsGAQUFBwEBBG8wbTBrBggrBgEFBQcwAoZfaHR0cDovL2FpYTQuemF0Y2EuZ292LnNhL0NlcnRFbnJvbGwvUFJaRUludm9pY2VTQ0E0LmV4dGdhenQuZ292LmxvY2FsX1BSWkVJTlZPSUNFU0NBNC1DQSgxKS5jcnQwDgYDVR0PAQH/BAQDAgeAMDwGCSsGAQQBgjcVBwQvMC0GJSsGAQQBgjcVCIGGqB2E0PsShu2dJIfO+xnTwFVmh/qlZYXZhD4CAWQCARIwHQYDVR0lBBYwFAYIKwYBBQUHAwMGCCsGAQUFBwMCMCcGCSsGAQQBgjcVCgQaMBgwCgYIKwYBBQUHAwMwCgYIKwYBBQUHAwIwCgYIKoZIzj0EAwIDSAAwRQIhALE/ichmnWXCUKUbca3yci8oqwaLvFdHVjQrveI9uqAbAiA9hC4M8jgMBADPSzmd2uiPJA6gKR3LE03U75eqbC/rXA==</ds:X509Certificate>
                            </ds:X509Data>
                        </ds:KeyInfo>
                        <ds:Object>
                            <xades:QualifyingProperties xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" Target="signature">
                                <xades:SignedProperties Id="xadesSignedProperties">
                                    <xades:SignedSignatureProperties>
                                        <xades:SigningTime>2024-11-04T15:58:22</xades:SigningTime>
                                        <xades:SigningCertificate>
                                            <xades:Cert>
                                                <xades:CertDigest>
                                                    <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                                                    <ds:DigestValue>ZDMwMmI0MTE1NzVjOTU2NTk4YzVlODhhYmI0ODU2NDUyNTU2YTVhYjhhMDFmN2FjYjk1YTA2OWQ0NjY2MjQ4NQ==</ds:DigestValue>
                                                </xades:CertDigest>
                                                <xades:IssuerSerial>
                                                    <ds:X509IssuerName>CN=PRZEINVOICESCA4-CA, DC=extgazt, DC=gov, DC=local</ds:X509IssuerName>
                                                    <ds:X509SerialNumber>379112742831380471835263969587287663520528387</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>SME00023</cbc:ID>
	<cbc:UUID>8d487816-70b8-4ade-a618-9d620b73814a</cbc:UUID>
	<cbc:IssueDate>2022-09-07</cbc:IssueDate>
	<cbc:IssueTime>12:21:28</cbc:IssueTime>
	<cbc:InvoiceTypeCode name="0100000">388</cbc:InvoiceTypeCode>
	<cbc:DocumentCurrencyCode>SAR</cbc:DocumentCurrencyCode>
	<cbc:TaxCurrencyCode>SAR</cbc:TaxCurrencyCode>
	<cac:AdditionalDocumentReference>
        <cbc:ID>QR</cbc:ID>
        <cac:Attachment>
            <cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain">AW/YtNix2YPYqSDYqtmI2LHZitivINin2YTYqtmD2YbZiNmE2YjYrNmK2Kcg2KjYo9mC2LXZiSDYs9ix2LnYqSDYp9mE2YXYrdiv2YjYr9ipIHwgTWF4aW11bSBTcGVlZCBUZWNoIFN1cHBseSBMVEQCDzM5OTk5OTk5OTkwMDAwMwMTMjAyMi0wOS0wN1QxMjoyMToyOAQENC42MAUDMC42BixEQTNadTBiNjFmYXZrSEVUcjhlODJHQ2ZNYTJZWkx0VFBsbldyZE5hbHZRPQdgTUVZQ0lRQ1hUSkJBM0ovcFdGQkluNk9yRmw2aDdPLytNK3VhM09ENFMxTEY2ZVJadmdJaEFNVlFJQkFrRFd6VEcyWVlmQmFsT2FZY255RkN4VDNneXo3eWErNGUxSWs5CFgwVjAQBgcqhkjOPQIBBgUrgQQACgNCAAShYIprRJr0UgStM6/S4CQLVUgpfFT2c+nHa+V/jKEx6PLxzTZcluUOru0/J2jyarRqE4yY2jyDCeLte3UpP1R4</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">1010010000</cbc:ID>
			</cac:PartyIdentification>
			<cac:PostalAddress>
				<cbc:StreetName>الامير سلطان | Prince Sultan</cbc:StreetName>
				<cbc:BuildingNumber>2322</cbc:BuildingNumber>
				<cbc:CitySubdivisionName>المربع | Al-Murabba</cbc:CitySubdivisionName>
				<cbc:CityName>الرياض | Riyadh</cbc:CityName>
				<cbc:PostalZone>23333</cbc:PostalZone>
				<cac:Country>
					<cbc:IdentificationCode>SA</cbc:IdentificationCode>
				</cac:Country>
			</cac:PostalAddress>
			<cac:PartyTaxScheme>
				<cbc:CompanyID>399999999900003</cbc:CompanyID>
				<cac:TaxScheme>
					<cbc:ID>VAT</cbc:ID>
				</cac:TaxScheme>
			</cac:PartyTaxScheme>
			<cac:PartyLegalEntity>
				<cbc:RegistrationName>شركة توريد التكنولوجيا بأقصى سرعة المحدودة | Maximum Speed Tech Supply LTD</cbc:RegistrationName>
			</cac:PartyLegalEntity>
		</cac:Party>
	</cac:AccountingSupplierParty>
	<cac:AccountingCustomerParty>
		<cac:Party>
			<cac:PostalAddress>
				<cbc:StreetName>صلاح الدين | Salah Al-Din</cbc:StreetName>
				<cbc:BuildingNumber>1111</cbc:BuildingNumber>
				<cbc:CitySubdivisionName>المروج | Al-Murooj</cbc:CitySubdivisionName>
				<cbc:CityName>الرياض | Riyadh</cbc:CityName>
				<cbc:PostalZone>12222</cbc:PostalZone>
				<cac:Country>
					<cbc:IdentificationCode>SA</cbc:IdentificationCode>
				</cac:Country>
			</cac:PostalAddress>
			<cac:PartyTaxScheme>
				<cbc:CompanyID>399999999800003</cbc:CompanyID>
				<cac:TaxScheme>
					<cbc:ID>VAT</cbc:ID>
				</cac:TaxScheme>
			</cac:PartyTaxScheme>
			<cac:PartyLegalEntity>
				<cbc:RegistrationName>شركة نماذج فاتورة المحدودة | Fatoora Samples LTD</cbc:RegistrationName>
			</cac:PartyLegalEntity>
		</cac:Party>
	</cac:AccountingCustomerParty>
	<cac:Delivery>
		<cbc:ActualDeliveryDate>2022-09-07</cbc:ActualDeliveryDate>
	</cac:Delivery>
	<cac:PaymentMeans>
		<cbc:PaymentMeansCode>10</cbc:PaymentMeansCode>
	</cac:PaymentMeans>
	<cac:AllowanceCharge>
		<cbc:ChargeIndicator>false</cbc:ChargeIndicator>
		<cbc:AllowanceChargeReason>discount</cbc:AllowanceChargeReason>
		<cbc:Amount currencyID="SAR">0.00</cbc:Amount>
		<cac:TaxCategory>
			<cbc:ID schemeID="UN/ECE 5305" schemeAgencyID="6">S</cbc:ID>
			<cbc:Percent>15</cbc:Percent>
			<cac:TaxScheme>
				<cbc:ID schemeID="UN/ECE 5153" schemeAgencyID="6">VAT</cbc:ID>
			</cac:TaxScheme>
		</cac:TaxCategory>
	</cac:AllowanceCharge>
	<cac:TaxTotal>
		<cbc:TaxAmount currencyID="SAR">0.6</cbc:TaxAmount>
	</cac:TaxTotal>
	<cac:TaxTotal>
		<cbc:TaxAmount currencyID="SAR">0.6</cbc:TaxAmount>
		<cac:TaxSubtotal>
			<cbc:TaxableAmount currencyID="SAR">4.00</cbc:TaxableAmount>
			<cbc:TaxAmount currencyID="SAR">0.60</cbc:TaxAmount>
			<cac:TaxCategory>
				<cbc:ID schemeID="UN/ECE 5305" schemeAgencyID="6">S</cbc:ID>
				<cbc:Percent>15.00</cbc:Percent>
				<cac:TaxScheme>
					<cbc:ID schemeID="UN/ECE 5153" schemeAgencyID="6">VAT</cbc:ID>
				</cac:TaxScheme>
			</cac:TaxCategory>
		</cac:TaxSubtotal>
	</cac:TaxTotal>
	<cac:LegalMonetaryTotal>
		<cbc:LineExtensionAmount currencyID="SAR">4.00</cbc:LineExtensionAmount>
		<cbc:TaxExclusiveAmount currencyID="SAR">4.00</cbc:TaxExclusiveAmount>
		<cbc:TaxInclusiveAmount currencyID="SAR">4.60</cbc:TaxInclusiveAmount>
		<cbc:AllowanceTotalAmount currencyID="SAR">0.00</cbc:AllowanceTotalAmount>
		<cbc:PrepaidAmount currencyID="SAR">0.00</cbc:PrepaidAmount>
		<cbc:PayableAmount currencyID="SAR">4.60</cbc:PayableAmount>
	</cac:LegalMonetaryTotal>
	<cac:InvoiceLine>
		<cbc:ID>1</cbc:ID>
		<cbc:InvoicedQuantity unitCode="PCE">2.000000</cbc:InvoicedQuantity>
		<cbc:LineExtensionAmount currencyID="SAR">4.00</cbc:LineExtensionAmount>
		<cac:TaxTotal>
			<cbc:TaxAmount currencyID="SAR">0.60</cbc:TaxAmount>
			<cbc:RoundingAmount currencyID="SAR">4.60</cbc:RoundingAmount>
		</cac:TaxTotal>
		<cac:Item>
			<cbc:Name>قلم رصاص</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">2.00</cbc:PriceAmount>
			<cac:AllowanceCharge>
				<cbc:ChargeIndicator>true</cbc:ChargeIndicator>
				<cbc:AllowanceChargeReason>discount</cbc:AllowanceChargeReason>
				<cbc:Amount currencyID="SAR">0.00</cbc:Amount>
			</cac:AllowanceCharge>
		</cac:Price>
	</cac:InvoiceLine>
</Invoice>