Issuing b2c invoice on reporting

Hello Zatca team
I’m facing an issue with validating the simplified invoice, although we used your latest SDK Simulation (zatca-einvoicing-sdk-Java-238-R3.4.0) with Java. It show us this error in the screenshot.

We also tried on different versions of java (11 and 17) both result in the same issue.
The following is the xml simplified invoice, please help us fix this issue.

<?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>IOiXDWh3gJpdHS0V3gZP+QVG/ckONhvEIOHpxf/w06w=</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>NTgxZDk3Nzg3YTBmMWI5OTFjZjFkYjlmNzk5YmUxZjkzYzc2NmM4ODljZDFmMTNmN2VkOWVhNzlmNWMxNDdhYQ==</ds:DigestValue>
                            </ds:Reference>
                        </ds:SignedInfo>
                        <ds:SignatureValue>MEYCIQDnHqlaiqVjTSvBWqFyv6mWD69qsds/mD5vTPog/4kqwAIhAIEUqcvCf7ICZdDrTdt3Lwuj6y2NhwitnL2G5fQHqi7v</ds:SignatureValue>
                        <ds:KeyInfo>
                            <ds:X509Data>
                                <ds:X509Certificate>MIICCjCCAbCgAwIBAgIGAZVgrFrWMAoGCCqGSM49BAMCMBUxEzARBgNVBAMMCmVJbnZvaWNpbmcwHhcNMjUwMzA0MTAyMDU4WhcNMzAwMzAzMjEwMDAwWjBeMSAwHgYDVQQDDBdQUk8tMTI2LTMxMDExMDgwODgwMDAwMzEWMBQGA1UECwwNUml5YWRoIEJyYW5jaDEVMBMGA1UECgwMd2FuaSB0cmFkaW5nMQswCQYDVQQGEwJTQTBWMBAGByqGSM49AgEGBSuBBAAKA0IABK3VNjaG/WvoP/LxltOoVYSpPUq/txwpvWmxctliAYkqzOJ06IhOFGzpnXuKUSDASrdophCsQc1VNc6TQEoAjpqjgaUwgaIwDAYDVR0TAQH/BAIwADCBkQYDVR0RBIGJMIGGpIGDMIGAMRowGAYDVQQEDBExLUJTV3wyLVRLUHwzLVJPTDEfMB0GCgmSJomT8ixkAQEMDzMxMDExMDgwODgwMDAwMzENMAsGA1UEDAwEMTEwMDEdMBsGA1UEGgwUMzU3MixUaGUga2hhZGVyLDY5MTIxEzARBgNVBA8MClRoZSBraGFkZXIwCgYIKoZIzj0EAwIDSAAwRQIhANaTl6aUzMA4Ljuh7Yrav6YoeDB8/IKjrGud0VGAoVtQAiBJcifxdQmFOkN+PpsRbjyS4OizTmXYssaPJVHd09Q3bA==</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-05T16:07:47</xades:SigningTime>
                                        <xades:SigningCertificate>
                                            <xades:Cert>
                                                <xades:CertDigest>
                                                    <ds:DigestMethod xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                                                    <ds:DigestValue xmlns:ds="http://www.w3.org/2000/09/xmldsig#">ZGZmNDk3ZWMyN2UxNTkyYmVhNDA1MjBjNTM2ZmNhMjNlODQ4MGNhYWZlZTVjMzIzMmJiZDM0NTI5ZTliYzdlMg==</ds:DigestValue>
                                                </xades:CertDigest>
                                                <xades:IssuerSerial>
                                                    <ds:X509IssuerName xmlns:ds="http://www.w3.org/2000/09/xmldsig#">CN=eInvoicing</ds:X509IssuerName>
                                                    <ds:X509SerialNumber xmlns:ds="http://www.w3.org/2000/09/xmldsig#">1741083663062</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>ORD-00121</cbc:ID>
    <cbc:UUID>bf7e70e6-f930-4b92-a329-201a31150c57</cbc:UUID>
    <cbc:IssueDate>2025-03-05</cbc:IssueDate>
    <cbc:IssueTime>16:07:47</cbc:IssueTime>
    <cbc:InvoiceTypeCode name="0200000">388</cbc:InvoiceTypeCode>
    <cbc:Note languageID="ar">ABC</cbc:Note>
    <cbc:DocumentCurrencyCode>SAR</cbc:DocumentCurrencyCode>
    <cbc:TaxCurrencyCode>SAR</cbc:TaxCurrencyCode>
    <cac:AdditionalDocumentReference>
        <cbc:ID>ICV</cbc:ID>
        <cbc:UUID>54654</cbc:UUID>
    </cac:AdditionalDocumentReference>
    <cac:AdditionalDocumentReference>
        <cbc:ID>PIH</cbc:ID>
        <cac:Attachment>
            <cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain">X+zrZv/IbzjZUnhsbWlsecLbwjndTpG0ZynXOif7V+k=</cbc:EmbeddedDocumentBinaryObject>
        </cac:Attachment>
    </cac:AdditionalDocumentReference>

    <cac:AdditionalDocumentReference>
        <cbc:ID>QR</cbc:ID>
        <cac:Attachment>
            <cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain">AQx3YW5pIHRyYWRpbmcCDzMxMDExMDgwODgwMDAwMwMTMjAyNS0wMy0wNVQxNjowNzo0NwQGMTQwLjAwBQYxNDAuMDAGLElPaVhEV2gzZ0pwZEhTMFYzZ1pQK1FWRy9ja09OaHZFSU9IcHhmL3cwNnc9B2BNRVlDSVFEbkhxbGFpcVZqVFN2QldxRnl2Nm1XRDY5cXNkcy9tRDV2VFBvZy80a3F3QUloQUlFVXFjdkNmN0lDWmREclRkdDNMd3VqNnkyTmh3aXRuTDJHNWZRSHFpN3YIWDBWMBAGByqGSM49AgEGBSuBBAAKA0IABK3VNjaG/WvoP/LxltOoVYSpPUq/txwpvWmxctliAYkqzOJ06IhOFGzpnXuKUSDASrdophCsQc1VNc6TQEoAjpoJRzBFAiEA1pOXppTMwDguO6Htitq/pih4MHz8gqOsa53RUYChW1ACIElyJ/F1CYU6Q34+mxFuPJLg6LNOZdiyxo8lUd3T1Dds</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">1010701011</cbc:ID>
            </cac:PartyIdentification>
            <cac:PostalAddress>
                <cbc:StreetName>The khader</cbc:StreetName>
                <cbc:BuildingNumber>3572</cbc:BuildingNumber>
                <cbc:CitySubdivisionName>The khader</cbc:CitySubdivisionName>
                <cbc:CityName>The khader</cbc:CityName>
                <cbc:PostalZone>12646</cbc:PostalZone>
                <cac:Country>
                    <cbc:IdentificationCode>SA</cbc:IdentificationCode>
                </cac:Country>
            </cac:PostalAddress>
            <cac:PartyTaxScheme>
                <cbc:CompanyID>310110808800003</cbc:CompanyID>
                <cac:TaxScheme>
                    <cbc:ID>VAT</cbc:ID>
                </cac:TaxScheme>
            </cac:PartyTaxScheme>
            <cac:PartyLegalEntity>
                <cbc:RegistrationName>wani trading</cbc:RegistrationName>
            </cac:PartyLegalEntity>
        </cac:Party>
    </cac:AccountingSupplierParty>
     <cac:AccountingCustomerParty>
        <cac:Party>
            <cac:PostalAddress>
                <cbc:StreetName>street</cbc:StreetName>
                <cbc:BuildingNumber>1234</cbc:BuildingNumber>
                <cbc:CitySubdivisionName>Riyadh Area</cbc:CitySubdivisionName>
                <cbc:CityName>Riyadh</cbc:CityName>
                <cbc:PostalZone>24263</cbc:PostalZone>
                <cac:Country>
                    <cbc:IdentificationCode>SA</cbc:IdentificationCode>
                </cac:Country>
            </cac:PostalAddress>
            <cac:PartyTaxScheme>
                <cbc:CompanyID>323456789123453</cbc:CompanyID>
                <cac:TaxScheme>
                    <cbc:ID>VAT</cbc:ID>
                </cac:TaxScheme>
            </cac:PartyTaxScheme>
            <cac:PartyLegalEntity>
                <cbc:RegistrationName>Walk-in Customer</cbc:RegistrationName>
            </cac:PartyLegalEntity>
        </cac:Party>
    </cac:AccountingCustomerParty>
    <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: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">140.00</cbc:TaxAmount>
    </cac:TaxTotal>
    <cac:TaxTotal>
        <cbc:TaxAmount currencyID="SAR">18.26</cbc:TaxAmount>
        <cac:TaxSubtotal>
            <cbc:TaxableAmount currencyID="SAR">121.74</cbc:TaxableAmount>
            <cbc:TaxAmount currencyID="SAR">18.26</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">121.74</cbc:LineExtensionAmount>
        <cbc:TaxExclusiveAmount currencyID="SAR">121.74</cbc:TaxExclusiveAmount>
        <cbc:TaxInclusiveAmount currencyID="SAR">140.00</cbc:TaxInclusiveAmount>
        <cbc:AllowanceTotalAmount currencyID="SAR">0.00</cbc:AllowanceTotalAmount>
        <cbc:PrepaidAmount currencyID="SAR">0.00</cbc:PrepaidAmount>
        <cbc:PayableAmount currencyID="SAR">140.00</cbc:PayableAmount>
    </cac:LegalMonetaryTotal>
<cac:InvoiceLine>
    <cbc:ID>106301</cbc:ID>
    <cbc:InvoicedQuantity unitCode="PCE">1</cbc:InvoicedQuantity>
    <cbc:LineExtensionAmount currencyID="SAR">121.74</cbc:LineExtensionAmount>
    <cac:TaxTotal>
            <cbc:TaxAmount currencyID="SAR">18.26</cbc:TaxAmount>
            <cbc:RoundingAmount currencyID="SAR">140.00</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">121.74</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>```

Dear @koot ,

Thank you for reaching out,

You are receiving such an error is related to missing of the replacement of private key kindly use java version 11 a following the below steps: -

1- Decode binarySecurityToken base64, replace it with cert.pem file in the SDK following this path (SDK\Data\Certificates).

2- When you generate the CSR you must receive the private key along with the CSR, here comes the second step to replace the private key with the (ec-secp256k1-priv-key.pem) file in the same directory for cert.pem (SDK\Data\cert.pem)

3- Select the invoice you want to sign from the sample you can follow the samples path in the SDK (SDK\Data\Samples\Simplified\Invoice).

4- Open the invoice that you want to sign and ensure that (cbc:CompanyID) tag under the (cac:AccountingSupplierParty) in the XML match the same VAT you are put in the config file, If not replace it with your VAT, and save the changes.

5- Open the CLI from the same directory for the invoice you want to sign.

6- Using the command (fatoora -sign -invoice “the invoice you want to sign”), This command will generate a new signed XML in the same directory.

7- Validate the signed XML using this command (fatoora -validate -invoice “the signed XML”)

After following the previous steps, the SIGNATURE error will disappear, and the validation process will pass successfully.

For any further support do not hesitate to reach out.
Thanks,

@halrashidy

We followed the same steps, and it worked on the SDK.

We have two questions:
1. How can we test it through API integration? We generate the invoice hash, sign the invoice, and send it to the compliance check API endpoint before generating the production CSID.
Can you explain the steps we need to follow?

2. Another thing: I noticed a change in time between the invoice and signed invoice (around 3 hours difference). The signed invoice seems in the past .

Can this cause any issue?

Thanks