Git Product home page Git Product logo

zatca's Introduction

(Kotlin & Java)- ZATCA (Fatoora) QR-Code Implementation

QR-Code implementation for the e-invoicing (Fatoora)

Zatca-Fatoora

  • Enter seller information

  • Base64 and QR Generated

How QR Generated

In this repo, we will demonstrate how to simply implement a QR code for the ZATCA (Fatoora). For this, the following steps will be explored:

Using TLV to start generating the QR code:

Example: seller name is "Shawrma House"

  • tag_seller_name = "1"
  • length_seller_name = "Shawrma House"?.toByteArray()?.size?.toString()
  • value_seller_name = "Shawrma House"

By Creating a TLV Byte Array for field like this:

 tlv1 = byteArrayOf(tag_seller_name.toByte(), length_seller_name.toByte()).plus(value_seller_name.toByteArray())

Then do same for the 5 tags and Convert to base64 code:

 var tlvs = tlv1 + tlv2 + tlv3 + tlv4 + tlv5
   var text = Base64.encodeToString(tlvs, Base64.DEFAULT)
            return text.replace("\n", "")

Finally, Genearte the QR-cod from String using Zxing

Usage

Step 1. Add ZatcaQRCodeGeneration class to your project

Step 2. use class Builder to add your merchant data like below:

builder.sellerName(sellerNameEditText?.text?.toString()) // Shawrma House
                .taxNumber(taxNumberEditText?.text?.toString()) // 1234567890
                .invoiceDate(dateTimeEditText?.text?.toString()) //..> date format recommended to be with this format "yyyy-MM-dd HH:mm:ss"
                .totalAmount(totalAmountWithVatEditText?.text?.toString()) // 100
                .taxAmount(vatAmountEditText?.text?.toString()) // 15

Output Base64 =

AQ1TaGF3cm1hIEhvdXNlAgoxMjM0NTY3ODkwAxMyMi8xMS8yMDIxIDAzOjAwIGFtBAMxMDAFAjE1

Finally, you can convert Base64 string to Bitmap then render QR code image (you can pass Bitmap to your ImageView)

showBottomSheet(builder.getBase64())

Testing

Contributing

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

Credits

License

The MIT License (MIT). Please see License File for more information.

(back to top)

zatca's People

Contributors

iabdelgawaad avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

zatca's Issues

Issue with arabic seller name

Hi, I have used your code to fulfil the zatca. There is one problem if the seller name is Arabic then QR code is not able to scan and it says QR is not compatible with Zakat, Tax and Custom Authority.

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.