Hi,
'invoice' => [
'invoiceSerialNumber' => 1,
'invoiceIssueDate' => date('Y-m-d'),
'invoiceIssueTime' => date('H:i:s'),
'previousInvoiceHash' => 'NWZlY2ViNjZmZmM4NmYzOGQ5NTI3ODZjNmQ2OTZjNzljMmRiYzIzOWRkNGU5MWI0NjcyOWQ3M2EyN2ZiNTdlOQ==',
'invoiceType' => 'INVOICE', //DEBIT_NOTE, CREDIT_NOTE
'lineItems' => [
[
'id' => 1,
'name' => "Test name",
'quantity' => 2,
'taxExclusivePrice' => 100,
'taxPercent' => 15.0,
'paid' => 0,
"discounts" => [
[
'discountAmount' => 10,
'reason' => 'A Discount',
]
]
]
]
]
this is my invoice data .
<?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>M/pE8z8zucejIxMzLuLoxO/7eCG35PmJgqBR1VLpjtY=</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>
MzEzOGIzZjc5YmE2ODFjOTQxNWYxODQ3OWNkZjAyMTI0NmEzMzQzMDJlM2U4NGI2ZGRjNDIwOTg3OGY3MjY4Yw==
</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>
MEQCIHcqOn2cGXZKaC3/CBYkmOSws9lqJOGxKHwbDAJHT3b1AiBErLn+uCIxrpH6fWHALmL5Ks2tldIbRaW3HtKElqfkPQ==
</ds:SignatureValue>
<ds:KeyInfo>
<ds:X509Data>
<ds:X509Certificate>
MIICJzCCAc2gAwIBAgIGAZWKcsazMAoGCCqGSM49BAMCMBUxEzARBgNVBAMMCmVJbnZvaWNpbmcwHhcNMjUwMzEyMTMwMjA3WhcNMzAwMzExMjEwMDAwWjBJMRcwFQYDVQQDDA5FR1MxLTg4NjQzMTE0NTEUMBIGA1UECwwLVGVzdCBCcmFuY2gxCzAJBgNVBAoMAlFyMQswCQYDVQQGEwJTQTBWMBAGByqGSM49AgEGBSuBBAAKA0IABCTkLYrrL8+V3gAs7aCJXD0ZtzqgYWeOBHExQMQ+Q9hYPEYW6RLYu+jvBnce+YJJkqc6CLyaYpr8X5+rS8Fc+1qjgdcwgdQwDAYDVR0TAQH/BAIwADCBwwYDVR0RBIG7MIG4pIG1MIGyMTswOQYDVQQEDDIxLUlPU3wyLUlPU3wzLWJkMGVhMjcyLWVkOWMtNGI1Ni1iNGFjLTY2MDQwNmY0ZWJlNzEfMB0GCgmSJomT8ixkAQEMDzMwMTEyMTk3MTUwMDAwMzENMAsGA1UEDAwEMDEwMDEkMCIGA1UEGgwbMDAwMCBLaW5nIEZhaGFoZCBzdCwgTGFob3JlMR0wGwYDVQQPDBRUZXN0IEJyYW5jaCBJbmR1c3RyeTAKBggqhkjOPQQDAgNIADBFAiBr5Xc0HbQZpjNzn8ORUnZxmV99CZBoDWtJTqDKusJ+QQIhAM3zD1f/Ey46cEDvmi8isGzLGP2Z1TEiMahbGqhvt2lR
</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-12T13:02:10</xades:SigningTime>
<xades:SigningCertificate>
<xades:Cert>
<xades:CertDigest>
<ds:DigestMethod
Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>
ZWM4YzhiYmRkNjFlYTJhMWQxZTE4NzNiZmZkZTliNWRkZmM4NDVjMjFjNjk4ODNjNzVmNmVmY2Q5MTdiNDUyYQ==
</ds:DigestValue>
</xades:CertDigest>
<xades:IssuerSerial>
<ds:X509IssuerName>CN=eInvoicing</ds:X509IssuerName>
<ds:X509SerialNumber>1741784532659</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>EGS1-886431145</cbc:ID>
<cbc:UUID>bd0ea272-ed9c-4b56-b4ac-660406f4ebe7</cbc:UUID>
<cbc:IssueDate>2025-03-12</cbc:IssueDate>
<cbc:IssueTime>13:02:10</cbc:IssueTime>
<cbc:InvoiceTypeCode name="0200000">388</cbc:InvoiceTypeCode>
<cbc:Note languageID="ar">SAR</cbc:Note>
<cbc:DocumentCurrencyCode>SAR</cbc:DocumentCurrencyCode>
<cbc:TaxCurrencyCode>SAR</cbc:TaxCurrencyCode>
<cac:AdditionalDocumentReference>
<cbc:ID>ICV</cbc:ID>
<cbc:UUID>bd0ea272-ed9c-4b56-b4ac-660406f4ebe7</cbc:UUID>
</cac:AdditionalDocumentReference>
<cac:AdditionalDocumentReference>
<cbc:ID>PIH</cbc:ID>
<cac:Attachment>
<cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain">
NWZlY2ViNjZmZmM4NmYzOGQ5NTI3ODZjNmQ2OTZjNzljMmRiYzIzOWRkNGU5MWI0NjcyOWQ3M2EyN2ZiNTdlOQ==
</cbc:EmbeddedDocumentBinaryObject>
</cac:Attachment>
</cac:AdditionalDocumentReference>
<cac:AdditionalDocumentReference>
<cbc:ID>QR</cbc:ID>
<cac:Attachment>
<cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain">
AQ8zNDY1NDM1NzM0NDU2MzMCDzMwMTEyMTk3MTUwMDAwMwMTMjAyNS0wMy0xMlQxMzowMjoxMAQFMjE4LjUFBDI4LjUGLE0vcEU4ejh6dWNlakl4TXpMdUxveE8vN2VDRzM1UG1KZ3FCUjFWTHBqdFk9B2BNRVFDSUhjcU9uMmNHWFpLYUMzL0NCWWttT1N3czlscUpPR3hLSHdiREFKSFQzYjFBaUJFckxuK3VDSXhycEg2ZldIQUxtTDVLczJ0bGRJYlJhVzNIdEtFbHFma1BRPT0IWDBWMBAGByqGSM49AgEGBSuBBAAKA0IABCTkLYrrL8+V3gAs7aCJXD0ZtzqgYWeOBHExQMQ+Q9hYPEYW6RLYu+jvBnce+YJJkqc6CLyaYpr8X5+rS8Fc+1oJRzBFAiBr5Xc0HbQZpjNzn8ORUnZxmV99CZBoDWtJTqDKusJ+QQIhAM3zD1f/Ey46cEDvmi8isGzLGP2Z1TEiMahbGqhvt2lRCgMzODg=
</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">301121971500003</cbc:ID>
</cac:PartyIdentification>
<cac:PostalAddress>
<cbc:StreetName>King Fahahd st</cbc:StreetName>
<cbc:BuildingNumber>0000</cbc:BuildingNumber>
<cbc:CitySubdivisionName>Est</cbc:CitySubdivisionName>
<cbc:CityName>Lahore</cbc:CityName>
<cbc:PostalZone>31952</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>346543573445633</cbc:RegistrationName>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingSupplierParty>
<cac:AccountingCustomerParty>
<cac:Party>
<cac:PostalAddress>
<cbc:StreetName>King Fahahd st</cbc:StreetName>
<cbc:BuildingNumber>0000</cbc:BuildingNumber>
<cbc:CitySubdivisionName>Est</cbc:CitySubdivisionName>
<cbc:CityName>Lahore</cbc:CityName>
<cbc:PostalZone>31952</cbc:PostalZone>
<cac:Country>
<cbc:IdentificationCode>SA</cbc:IdentificationCode>
</cac:Country>
</cac:PostalAddress>
<cac:PartyTaxScheme>
<cbc:CompanyID>234432342</cbc:CompanyID>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:PartyTaxScheme>
<cac:PartyLegalEntity>
<cbc:RegistrationName>346543573445453</cbc:RegistrationName>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingCustomerParty>
<cac:AllowanceCharge>
<cbc:ChargeIndicator>false</cbc:ChargeIndicator>
<cbc:AllowanceChargeReason>A Discount</cbc:AllowanceChargeReason>
<cbc:Amount currencyID="SAR">10</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">28.5</cbc:TaxAmount>
</cac:TaxTotal>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="SAR">28.5</cbc:TaxAmount>
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="SAR">190</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="SAR">28.5</cbc:TaxAmount>
<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:TaxSubtotal>
</cac:TaxTotal>
<cac:LegalMonetaryTotal>
<cbc:LineExtensionAmount currencyID="SAR">190</cbc:LineExtensionAmount>
<cbc:TaxExclusiveAmount currencyID="SAR">190</cbc:TaxExclusiveAmount>
<cbc:TaxInclusiveAmount currencyID="SAR">218.5</cbc:TaxInclusiveAmount>
<cbc:AllowanceTotalAmount currencyID="SAR">10</cbc:AllowanceTotalAmount>
<cbc:PrepaidAmount currencyID="SAR">0</cbc:PrepaidAmount>
<cbc:PayableAmount currencyID="SAR">218.5</cbc:PayableAmount>
</cac:LegalMonetaryTotal>
<cac:InvoiceLine>
<cbc:ID>1</cbc:ID>
<cbc:InvoicedQuantity unitCode="PCE">2</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount currencyID="SAR">190</cbc:LineExtensionAmount>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="SAR">28.5</cbc:TaxAmount>
<cbc:RoundingAmount currencyID="SAR">218.5</cbc:RoundingAmount>
</cac:TaxTotal>
<cac:Item>
<cbc:Name>Test name</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">95</cbc:PriceAmount>
<cac:AllowanceCharge>
<cbc:ChargeIndicator>true</cbc:ChargeIndicator>
<cbc:AllowanceChargeReason>discount</cbc:AllowanceChargeReason>
<cbc:Amount currencyID="SAR">10</cbc:Amount>
</cac:AllowanceCharge>
</cac:Price>
</cac:InvoiceLine>
</Invoice>
this is my xml for simplified Tax invoice
{
"validationResults": {
"infoMessages": [
{
"type": "INFO",
"code": "XSD_ZATCA_VALID",
"category": "XSD validation",
"message": "Complied with UBL 2.1 standards in line with ZATCA specifications",
"status": "PASS"
}
],
"warningMessages": [
{
"type": "WARNING",
"code": "BR-S-08",
"category": "EN_16931",
"message": "[BR-S-08]-In a VAT breakdown (BG-23) where the VAT category code (BT-118) is ' Standard rated' the VAT category taxable amount (BT-116) shall equal the sum of Invoice line net amounts (BT-131) minus the sum of Document level allowance amounts (BT-92) plus the sum of Document level charge amounts (BT-99) where the VAT category codes (BT-151, BT-95, BT-102) are 'Standard Rate'.",
"status": "WARNING"
},
{
"type": "WARNING",
"code": "BR-CO-13",
"category": "EN_16931",
"message": "Invoice total amount without VAT (BT-109) = S Invoice line net amount (BT-131) - Sum of allowances on document level (BT-107) + Sum of charges on document level (BT-108).",
"status": "WARNING"
},
{
"type": "WARNING",
"code": "certificate-issuer-name",
"category": "CERTIFICATE_ERRORS",
"message": "X509Certificate (CCSID / PCSID) used for signing is not valid certificate (CCSID / PCSID) for this VAT Registration Number.",
"status": "WARNING"
},
{
"type": "WARNING",
"code": "invalid-signing-certificate",
"category": "CERTIFICATE_ERRORS",
"message": "X509Certificate (CCSID / PCSID) used for signing is not valid certificate (CCSID / PCSID) for this VAT Registration Number.",
"status": "WARNING"
}
],
"errorMessages": [
{
"type": "ERROR",
"code": "BR-KSA-34",
"category": "KSA",
"message": "The invoice counter value (KSA-16) contains only digits.",
"status": "ERROR"
},
{
"type": "ERROR",
"code": "BR-KSA-44",
"category": "KSA",
"message": "If it exists in the invoice , the buyer VAT registration number or buyer group VAT registration number (BT-48) must contain 15 digits. The first digit and the last digit is “3”.",
"status": "ERROR"
},
{
"type": "ERROR",
"code": "certificate-permissions",
"category": "CERTIFICATE_ERRORS",
"message": "User only allowed to use the vat number that exists in the authentication certificate",
"status": "ERROR"
},
{
"type": "ERROR",
"code": "signed-properties-hashing",
"category": "CERTIFICATE_ERRORS",
"message": "Invalid signed properties hashing, SignedProperties with id='xadesSignedProperties'",
"status": "ERROR"
}
],
"status": "ERROR"
},
"reportingStatus": "NOT_REPORTED"
}
this is my response .
Can anybody help me to calculate all data ?? having issues .