axenda / zatca

An unofficial package to help developers implement ZATCA (Fatoora) QR code easily which is required for e-invoicing in Saudi Arabia.
MIT License
54 stars 13 forks source link

The decoded string is wrong when vatRegistrationNumber length is 15 #1

Closed dev-sahar closed 2 years ago

dev-sahar commented 2 years ago

Issue description

When I increase the vatRegistrationNumber to 15 characters/numbers (which is the length of the vat registration number for my KSA company) the decoded string gets missed up.

Steps to reproduce the issue

  1. use this as a sample

     const invoice = new Invoice({
        sellerName: 'شركة تجريبية',
        vatRegistrationNumber: '123456789135785',
        invoiceTimestamp: '2021-02-21T11:20:27.983Z',
        invoiceTotal: '2785.8',
        invoiceVatTotal: '361.8',
      })
    
      invoice.toBase64()
  2. then take the generated base64 string to https://www.base64decode.org/
  3. decode and check the results

What's the expected result?

a readable string similar to this

شركة تجريبية
1234567891357852021-02-21T11:20:27.983Z2785.8361.8

What's the actual result?

image

ihadabs commented 2 years ago

Hi @dev-sahar,

I'm gonna look at it tomorrow, if you can fix the issue, please create a pull request 🙌.

ihadabs commented 2 years ago

@dev-sahar

I how did you asume that the result is invalid? Just checked the output with the ZATCA SDK for the values you provided and it was decoded correctly.

CleanShot 2021-12-07 at 14 30 16@2x

If we're missing somthing here, please, elaborate more.