Giter Site home page Giter Site logo

wes4m / zatca-xml-js Goto Github PK

View Code? Open in Web Editor NEW
67.0 11.0 56.0 6.26 MB

An implementation of Saudi Arabia ZATCA's E-Invoicing requirements, processes, and standards in TypeScript.

License: MIT License

TypeScript 100.00%
tax zatca saudi typescript xml invoice phase-1 phase-2

zatca-xml-js's People

Contributors

wes4m avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zatca-xml-js's Issues

IRN Sequence incase of an EGS with both Standard and Simplified to be issued

First of all, big thanks to @wes4m for publishing this repo.

I've a doubt regarding the sequence of Invoice reference numbers in case of an EGS which issues both Standard and simplified invoices from a same billing point. Invoice Reference Number or IRN need to be in sequence as per VAT regulations [mentioned in ZATCA resolutions]

Usecase: We issued a Simplified invoices in between 2 Standard Invoices which got cleared in real time, but the former was rejected during reporting process [which is done in batch after certain hours].

Possible answers:

  1. Just resubmit with same IRN?
  2. Issue as fresh B2C?
  3. We issue notes to cancel the same and reissue? But we haven't reported the invoice in the first place. So where to give reference to?

cant wrap my head around it. please explain me if am missing out something. thanks in advance

Prepaid Invoices code 386 and Supplier Address

Hello,

I have read about the new implementation of prepaid invoices in ZATCA XML standards. So currently we have 388 (invoice), 383 (debit note), 381 (credit note) and 386 for prepaid invoices.

In the ZATCA's documentation, it shows about the prepaid amount adjustments and doesn't provide any clarity on the how the prepaid invoices XML looks like.

Does anyone has clarity on the following or received any communication from ZATCA?:

  1. When we receive an advance of 100 SAR for a total transaction value of 300 then first we need to issue an advance invoice with code 386. But in that should we show the amount in prepaid amount or show it as payable amount itself in legal monetary total? Also, when issuing the final invoice should the code be 388 or 386?

  2. How should the XMLs be prepared in case of multiple advance receipts? Say for example we received an advance in 3 stages and then we issue the invoice. Should the XML show 386, 386, 386, and then 388? Should the intermediate advance invoices refer to the previous advance invoices?

  3. What should we do in XML in case we issued a 386 invoice and it needs a correction? How can we raise a debit or credit note for that? What happens if we need to refund the advance?

Another doubt about the supplier XML data: When creating certificates for phase 2 e-invoicing, we have to give the address information. If a taxpayer has 20 branches but all of them have the same VAT number, the question is whether we have to make 20 separate certificates for each branch to use for invoicing. Or is it possible to show the different branch addresses in the XML file using only one certificate?

Query Regarding ZATCA E-Invoicing Integration

Issue 1: Inconsistency in E-Invoicing Statistics

After successfully integrating and following the official documentation provided by ZATCA, I have encountered an inconsistency in the e-invoicing statistics displayed on the Fatoora portal's simulation section. Despite receiving a "status":"PASS", "reportingStatus": "REPORTED" for submitted simplified invoices via the API endpoint "https://gw-fatoora.zatca.gov.sa/e-invoicing/simulation/invoices/reporting/single" and despite receiving a "status": "PASS", "clearanceStatus": "CLEARED" for standard invoices via "https://gw-fatoora.zatca.gov.sa/e-invoicing/simulation/invoices/clearance/single", the total count of submitted documents does not reflect accurately on the portal. This issue persists even after multiple checks over several days. Also, if I submitted and got a successful response from the API as the document is accepted and while checking on the Fatoora statistics page sometimes it is counted in rejected documents. Why is this mismatch happening? If I received REPORTED, CLEARED status with no error or warning messages, can I confirm that my document is submitted and accepted by ZATCA successfully? Please clarify this.

Issue 2: Lack of Clarity on Tax Amount Calculation

Additionally, I seek clarification on the calculation of the total tax amount payable to ZATCA for the submitted and accepted invoice documents. As there is no provision to retrieve this information from the ZATCA side, could you please confirm whether we need to calculate this amount internally based on the submitted invoices? For instance, if five invoices are successfully submitted and accepted, how do we determine the total tax amount owed to ZATCA?

Could someone please clarify these doubts?

Worked, How do I get PIH (previous invoice hash)?

I have pretty much the same example as you. When I run checkInvoiceCompliance or reportInvoice I get Request failed with status code 400.

One more question, do I store PIH in a DB or how do you get it?

Not an Issue just a question

Firstly, I wanted to say thank you for this; it has helped me a lot in my development work.

Although I have read most of Zatca's documentation, I don't really understand the implementation differences between tax invoices and simplified invoices.

I know that tax invoices are intended for B2B transactions, but does that mean the buyer must also be registered with Zatca?

Another question:

As a company that generates invoices for its clients, what do you think is the best course of action? Should the client create their own Zatca account and add our server as an EGS, or should we create a Zatca account and add our clients as part of a group?

Final question, I promise:

I've been having an issue creating a developer account. When I register, it states that a verification email has been sent to my inbox, but I never receive anything—even if I resend the email or try different email accounts. Have you encountered anything like this before?

Thanks again.

Invoice sub-types disscussion

Hey @wes4m,
Just want to discuss few things. So, in this repo are we doing only simplified tax invoice? If yes, please suggest me on how we can post below transactions.
● For Tax Invoice, code is 380 and subtype is 01. ex. <cbc:InvoiceTypeCode name=”010000”>380</cbc:InvoiceTypeCode>
● For Simplified Tax Invoice, code is 380 and subtype is 02. ex. <cbc:InvoiceTypeCode name=”020000”>380</cbc:InvoiceTypeCode>
● For tax invoice debit note, code is 383 and subtype is 01. ex. <cbc:InvoiceTypeCode name=”010000”>383</cbc:InvoiceTypeCode>
● For simplified debit note, code is 383 and subtype is 02. ex. <cbc:InvoiceTypeCode name=”020000”>383</cbc:InvoiceTypeCode>
● For tax invoice credit note, code is 381 and subtype is 01. ex. <cbc:InvoiceTypeCode name=”010000”>381</cbc:InvoiceTypeCode>
● For simplified credit note, code is 381 and subtype is 02. ex. <cbc:InvoiceTypeCode name=”020000”>381</cbc:InvoiceTypeCode>
● For self-billed invoice, code is 389 and subtype is 01. ex. <cbc:InvoiceTypeCode name=”010000”>389</cbc:InvoiceTypeCode>

Can not run in letest version node

I am trying to run this project. when I run I am getting this error:

PS C:\xampp\htdocs\zatca_xml> npm run example

[email protected] example
tsc --project tsconfig.build.json && node lib/examples/full.js

error:068000A8:asn1 encoding routines::wrong tag
(node:2084) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use node --trace-deprecation ... to show where the warning was created)

my node --version
v19.2.0

Can you help me to run this project: email: [email protected]

General Rules Errors

I wanted to inform you all that XML is getting validated on the sandbox test xml site. However, the same data is not accepted by Zatca. The strange part is that when I add only one line item, Zatca is accepting the invoice . On the other hand, when I add more than one line item, Zatca is throwing me some general business rules error. Fortunately, the XML for the same invoice which has multiple line items is accepted by the sandbox test portal xml validator.

Please let me know if anyone is facing the same problem. The problem is clear – for one line item invoices I am getting the response perfectly, but for multiple line items it is not accepting and throwing the business rules errors

Invoice Compliance Check include egs_uuid which is wrong

I'm requesting ZATCA invoice compliance check API with UUID generated for my device,
But the invoiceXML is using another generated UUID,
So the API return the following error:

"errorMessages": [
      {
        "type": "ERROR",
        "code": "INVOICE_UUID_VALIDATION",
        "category": "MISSING_UUID_IN_INVOICE",
        "message": "UUID provided in the invoice doesn't match UUID in the provided Request",
        "status": "ERROR"
      },

Just a question now: Do we add a unique UUID per each invoice, or it's only 1 UUID per each EGS generating invoices ?

401 Unauthorized /invoices/reporting/single

Hi,
I am using sandbox account and testing apis using postman
https://gw-fatoora.zatca.gov.sa/e-invoicing/developer-portal/compliance this API is working fine with CSR in body and gives me successful response including requestID,binarySecurityToken,secret and etc

now when I am trying to use
https://gw-fatoora.zatca.gov.sa/e-invoicing/developer-portal/invoices/reporting/single
binarySecurityToken as Username in Basic Auth
secret as Password in Basic Auth

response is 401 Unauthorized

Unable to validate using web validator

I wanted to understand why the xml is not getting validated the web validator provided ZATCA. I am getting SIGNATURE_ERROR when trying to do so.

If that is disabled, is there any official communication from ZATCA saying that the web validator wont work for the certificates that we generate? Just wanted to clarify wheather there is any issue in the certificate geenration process in case there is no official notificaiton from ZATCA.

NEW VERSION OF SANDBOX (ISSUES AFTER THAT)

@wes4m
I have been working on this package since very long time and everything was good and running fine.
Yesterday, I think zatca has updated the sandbox because of the there was no service available till today. Below message was in response everytime when I hit the API.

<html>
      <head><title>503 Service Temporarily Unavailable</title></head>
      <body>
          <center><h1>503 Service Temporarily Unavailable</h1></center>
          <hr><center>nginx</center>
      </body>
</html>

Now that the server is up and running again. I tried to execute the same request and I am facing below errors

{
  "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": [],
  "errorMessages": [
      {
          "type": "ERROR",
          "code": "GENERAL",
          "category": "BUSINESS_RULES",
          "message": "Unable to execute Business Rules validation",
          "status": "ERROR"
      },
      {
          "type": "ERROR",
          "code": "BR-KSA-EN16931-11",
          "category": "KSA",
          "message": "Invoice line net amount (BT-131) must equal (Invoiced quantity (BT-130) * (Item net price (BT-146) / item price base quantity (BT-149))-))- Sum of invoice line allowance amount (BT-136)",
          "status": "ERROR"
      },
      {
          "type": "ERROR",
          "code": "BR-KSA-EN16931-06",
          "category": "KSA",
          "message": "Charge on price level (BG-29) is NOT allowed. Only value 'false' allowed.",
          "status": "ERROR"
      },
      {
          "type": "ERROR",
          "code": "BR-KSA-EN16931-06",
          "category": "KSA",
          "message": "Charge on price level (BG-29) is NOT allowed. Only value 'false' allowed.",
          "status": "ERROR"
      }
  ],
  "status": "ERROR"
}

Don't understand what went wrong.
After some research I see that it is related to lineitem Discount

"discounts": [
    { "amount": 2, "reason": "A discount" },
    { "amount": 2, "reason": "A second discount" }
]

I think there is some miscalculation while calculating the discounts or some new features they have updated in this publish Strange is that when I don't pass any discount the Invoice is getting reported.

The full exemple issueComplianceCertificate return warningMessages messages

First salam alaikum and thank you very much

I found that running the full exemple return three warning messages:

{
    "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": "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-KSA-EN16931-11",
                "category": "KSA",
                "message": "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)",
                "status": "WARNING"
            },
            {
                "type": "WARNING",
                "code": "invoiceTimeStamp_QRCODE_INVALID",
                "category": "QRCODE_VALIDATION",
                "message": "Time on QR Code does not match with Invoice Issue Time (KSA-25). If ZATCA's SDK was used to generate QR Code, kindly use the latest version of SDK",
                "status": "WARNING"
            }
        ],
        "errorMessages": [],
        "status": "WARNING"
    },
    "reportingStatus": "REPORTED",
    "clearanceStatus": null,
    "qrSellertStatus": null,
    "qrBuyertStatus": null
}

The BR-S-08 code warning:
image

The BR-KSA-EN16931-11 code warning:
image

Only Sandbox environment is available

Currently the only environment available is Sandbox, in case we want to move to production environment there is no way of doing that:

const settings = {
    API_VERSION: "V2",
    SANDBOX_BASEURL: "https://gw-apic-gov.gazt.gov.sa/e-invoicing/developer-portal",
    PRODUCTION_BASEURL: "TODO"
};

Incorrect XML hashing

Hello. Thank you for this detailed project. I've been having issues with Phase 2 QR, getting the following errors in ZATCA's XML Web validator :

category : QR_CODE_ERROR
code :publicKey
message : public key of the certificate does not match with qr code certificate

category : QR_CODE_ERROR
code :hashedXml
message : hashedXml does not match with qr code hashedXml

category : QR_CODE_ERROR
code :certificate signature
message : certificate signature value in the invoice doesn't match the certificate signature value in tag 9 of the QR code

Let's take the hashedXml error first :
I believe that ZATCA requires the XML to be hashed into SHA256 binary object before converting to base64, however the function "getInvoiceHash(invoice_xml)" takes the plain SHA256 and convert directly to base64. could that be the reason for the HashedXml error ?

Calculation Error In rounding amount

@wes4m
sample JSON
{
"uuid":"6f4d20e0-6bfe-4a80-9389-7dabe6620f12",
"custom_id":"EGS1-886431145",
"model":"IOS",
"CRN_number":"454634645645654",
"VAT_name":"Wesam Alzahir",
"VAT_number":"301121971500003",
"location":{
"city":"Khobar",
"city_subdivision":"West",
"street":"King Fahahd st",
"plot_identification":"0000",
"building":"0000",
"postal_zone":"31952"
},
"branch_name":"My Branch Name",
"branch_industry":"Food",
"invoice_counter_number":"1",
"invoice_serial_number":"EGS1-886431145-1",
"issue_date":"2022-03-13",
"issue_time":"14:40:40",
"previous_invoice_hash":"NWZlY2ViNjZmZmM4NmYzOGQ5NTI3ODZjNmQ2OTZjNzljMmRiYzIzOWRkNGU5MWI0NjcyOWQ3M2EyN2ZiNTdlOQ==",
"line_items":[
{
"id":"1",
"name":"TEST NAME",
"quantity":5,
"tax_exclusive_price":10,
"VAT_percent":0.15,
"other_taxes":[
{
"percent_amount":1
}
],
"discounts":[
{
"amount":0,
"reason":"A discount"
},
{
"amount":0,
"reason":"A second discount"
}
]
}
]
}

Below is the xml generated from the sample json
cac:TaxTotal
<cbc:TaxAmount currencyID="SAR">57.50</cbc:TaxAmount>
cac:TaxSubtotal
<cbc:TaxableAmount currencyID="SAR">50.00</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="SAR">7.50</cbc:TaxAmount>
cac:TaxCategory
<cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5305">S</cbc:ID>
cbc:Percent15.00</cbc:Percent>
cac:TaxScheme
<cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5153">VAT</cbc:ID>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
cac:TaxSubtotal
<cbc:TaxableAmount currencyID="SAR">50.00</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="SAR">50.00</cbc:TaxAmount>
cac:TaxCategory
<cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5305">S</cbc:ID>
cbc:Percent100.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">57.50</cbc:TaxAmount>
</cac:TaxTotal>
cac:LegalMonetaryTotal
<cbc:LineExtensionAmount currencyID="SAR">50.00</cbc:LineExtensionAmount>
<cbc:TaxExclusiveAmount currencyID="SAR">50.00</cbc:TaxExclusiveAmount>
<cbc:TaxInclusiveAmount currencyID="SAR">107.5</cbc:TaxInclusiveAmount> ?? On what basic this value is coming
<cbc:AllowanceTotalAmount currencyID="SAR">0</cbc:AllowanceTotalAmount>
<cbc:PrepaidAmount currencyID="SAR">0</cbc:PrepaidAmount>
<cbc:PayableAmount currencyID="SAR">107.5</cbc:PayableAmount>--??
</cac:LegalMonetaryTotal>
cac:InvoiceLine
cbc:ID1</cbc:ID>
<cbc:InvoicedQuantity unitCode="PCE">5</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount currencyID="SAR">50.00</cbc:LineExtensionAmount>
cac:TaxTotal
<cbc:TaxAmount currencyID="SAR">57.50</cbc:TaxAmount>
<cbc:RoundingAmount currencyID="SAR">107.50</cbc:RoundingAmount> ????
</cac:TaxTotal>
cac:Item
cbc:NameTEST NAME</cbc:Name>
cac:ClassifiedTaxCategory
cbc:IDS</cbc:ID>
cbc:Percent15.00</cbc:Percent>
cac:TaxScheme
cbc:IDVAT</cbc:ID>
</cac:TaxScheme>
</cac:ClassifiedTaxCategory>
cac:ClassifiedTaxCategory
cbc:IDS</cbc:ID>
cbc:Percent100.00</cbc:Percent>
cac:TaxScheme
cbc:IDVAT</cbc:ID>
</cac:TaxScheme>
</cac:ClassifiedTaxCategory>
</cac:Item>
cac:Price
<cbc:PriceAmount currencyID="SAR">10</cbc:PriceAmount>
cac:AllowanceCharge
cbc:ChargeIndicatorfalse</cbc:ChargeIndicator>
cbc:AllowanceChargeReasonA discount</cbc:AllowanceChargeReason>
<cbc:Amount currencyID="SAR">0.00</cbc:Amount>
</cac:AllowanceCharge>
cac:AllowanceCharge
cbc:ChargeIndicatorfalse</cbc:ChargeIndicator>
cbc:AllowanceChargeReasonA second discount</cbc:AllowanceChargeReason>
<cbc:Amount currencyID="SAR">0.00</cbc:Amount>
</cac:AllowanceCharge>
</cac:Price>
</cac:InvoiceLine>
Correct me if I am wrong
I think there is miscalculation, I have mention the spots in bold in the above xml which show the miscalculation.
Kindly help me to understand on that basis the value 107.50 is calculated and what should be the value inside
cbc:RoundingAmount

     <cac:TaxTotal>
        <cbc:TaxAmount currencyID="SAR">57.50</cbc:TaxAmount>
        _**<cbc:RoundingAmount currencyID="SAR">??</cbc:RoundingAmount>**_     ????
    </cac:TaxTotal>

Signing Invoice

fie path : signing/index.js
line No: 144
/**

  • Removes header and footer from private key string.
  • @param privatek_key_string ec-secp256k1 private key string.
  • @returns String base64 encoded private key body.
    */
    const cleanUpPrivateKeyString = (certificate_string) => {
    return certificate_string.replace("-----BEGIN EC PRIVATE KEY-----\n", "").replace("-----END EC PRIVATE KEY-----", "").trim();

};
this above function is not returning the trim certificate as it is not matching -----BEGIN EC PRIVATE KEY-----\n because of the that additional /n . Hence the process is getting out of the execution.

EGS-ONBOARDING

@wes4m
How can we captured OTP dynamically(Automatically).

image

Please look at the 6th point which says

OTP code will be
automatically entered
in the Taxpayer’s
solution / device
(based on the https
header on the browser)

Please suggest us how?

Canonical XML for InvoiceHash

Needed information on how you found this workaround.

export const getInvoiceHash = (invoice_xml: XMLDocument): string => {
    let pure_invoice_string: string = getPureInvoiceString(invoice_xml);
    // A dumb workaround for whatever reason ZATCA XML devs decided to include those trailing spaces and a newlines. (without it the hash is incorrect)
    pure_invoice_string = pure_invoice_string.replace("<cbc:ProfileID>", "\n    <cbc:ProfileID>");
    pure_invoice_string = pure_invoice_string.replace("<cac:AccountingSupplierParty>", "\n    \n    <cac:AccountingSupplierParty>");
    
    return createHash("sha256").update(pure_invoice_string).digest('base64');
}

Could it be an error on their side or is it about using the right canonicalization method?

User only allowed to use the vat number that exists in the authentication certificate

Hello i facing an issue when i trying to run full example script

errorMessages: [
{
type: 'ERROR',
code: 'certificate-permissions',
category: 'CERTIFICATE_ERRORS',
message: 'Production CSID does not cover Simplified documents',
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'
}
]

how can i implement this example for production

Production CSID doesn't cover simplified document

Hi All,
When we do reporting for the simplified document we are usually getting this error.
"Production CSID doesn't cover simplified document"
are we doing some thing wrong or it is from Zatca?

Signature Error

I tried to generate an invoice using the examples/full.ts provided in the git but from yesterday onwards the following error has been shown when trying to TestXML in https://sandbox.zatca.gov.sa/TestXML

category : SIGNATURE_ERROR code :X509IssuerName message : wrong X509IssuerName category : SIGNATURE_ERROR code :X509SerialNumber message : wrong X509SerialNumber

Which is the correct correct X509IssuerName

Can you please tell me the difference between these certificate issuer names in Zatca:

  1. CN=PEZEINVOICESCA2-CA, DC=extgazt, DC=gov, DC=local
  2. CN=PEZEINVOICESCA1-CA, DC=extgazt, DC=gov, DC=local
  3. CN=TSZEINVOICE-SubCA-1, DC=extgazt, DC=gov, DC=local
  4. CN=PRZEINVOICESCA4-CA, DC=extgazt, DC=gov, DC=local

Which one is valid for pre-production, and which one for production? Is the change in issuer name due to CSR config file changes?

Error in ZATCA Validations

I am getting error in https://sandbox.zatca.gov.sa/TestXML

error 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".

Rounding Amount and Calculation Error !

@wes4m @HaimenToshi @adriantoro26 There is an error from zatca when I tried to execute below calculation "message": "The line VAT amount (KSA-11) must be Invoice line net amount (BT-131) x (Line VAT rate (BT-152)/100).", 3000.07=20000.50*15/100;> 3000.075 (calculator value) I assume Zatca calculation is rounding up the value to 3000.075 to 3000.08. I tried to round up the thing with in this package but entire calculation is getting messed up. Suggest me what we can do

Test case Json for line


"line_items": [
       {
           "id": "1",
           "name": "NPR75L-KL5VAYSN",
           "quantity": 1,
           "Sales_unit": "UN",
           "tax_exclusive_price": 20000.5,
           "net_price": 20000.5,
           "line_amount_without_tax": 20000.5,
           "line_amount_withtax": 23000.575,
           "advance%": 0,
           "advance_amount": 0,
           "advance_vat": 0,
           "advance_amount_after_tax": 0,
           "model_year": "",
           "tax_level1": "SR15",
           "VAT_percent": 0.15,
           "other_taxes": [],
           "discounts": [
               {
                   "amount": 0,
                   "reason": 0
               },
               {
                   "amount": 0,
                   "reason": 0
               }
           ]
       }
   ]

QR Code unparsable

QR Code gets unparsable if Seller name is in Arabic. if it is in English working as expected.

Can't validate generated XML through the sandbox portal

Hey, first of all thanks for your tremendous efforts, I was trying the library out and it works great, the compliance API succeeds. However, I can't seem to be able to write the generated XML to a file then upload that to the sandbox portal validator.

Errors:
image

Code used to write to file:

fs.writeFile(__dirname + '/tmp/test.xml', signed_invoice_string, {
            flag: "w"
          }, function(err) {
            if (err) {
              return console.log(err);
            }
            console.log("The file was saved!");
});

Validator link: https://sandbox.zatca.gov.sa/TestXML

wrong tag

I am getting this error message

Error: error:068000A8:asn1 encoding routines::wrong tag

Adding discount Invoice Compliance failing

  1. If i am adding discount getting error

const line_item: ZATCASimplifiedInvoiceLineItem = {
id: "1",
name: "TEST NAME",
quantity: 5,
tax_exclusive_price: 10,
VAT_percent: 0.02,
discounts: [
{amount: 10, reason: "A discount"}
]
};

{"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-KSA-EN16931-11","category":"KSA","message":"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)","status":"WARNING"}],"errorMessages":[],"status":"WARNING"},"reportingStatus":"REPORTED","clearanceStatus":null,"qrSellertStatus":null,"qrBuyertStatus":null}

  1. QR code generation formatted_datetime getting error for adding below format
    const formatted_datetime = moment(datetime).format("YYYY-MM-DDTHH:mm:ss")+"Z";
    const formatted_datetime = moment(datetime).format("YYYY-MM-DDTHH:mm:ss"); working fine

Handle 202 status code in axios response

Problem
Currently, an error may be thrown when calling checkInvoiceCompliance.

Reason
Currently when checking the status code from Zatca API only 200 status code is accepted while the Zatca API may return other values such as 201 or 202.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.