Skip to main content

An unofficial package help developers to implement ZATCA (Fatoora) QR code easily which required for e-invoicing

Project description

ZATCA (Fatoora) QR-Code Implementation

An unofficial package help developers to implement ZATCA (Fatoora) QR code easily which required for e-invoicing

PyPI - Python Version PyPI License Code style: black test-salla Upload Python Package

Requirements

  • python >= 3.8
  • zbar-tools

Installation

You can install the package via pypi (pip):

$ pip3 install fatoora

or via github (git):

$ git clone https://github.com/TheAwiteb/fatoora/
$ cd fatoora
$ python3 setup.py install

Usage

Generate Base64

from fatoora import Fatoora

fatoora_obj = Fatoora(
    seller_name="Awiteb",
    tax_number=1234567891, # or "1234567891"
    invoice_date="2021-07-12T14:25:09+00:00", # ISO8601 @see https://en.wikipedia.org/wiki/ISO_8601
    total_amount=100, # or 100.0, 100.00, "100.0", "100.00"
    tax_amount=15, # or 15.0, 15.00, "15.0", "15.00"
)

print(fatoora_obj.base64)
# AQZBd2l0ZWICCjEyMzQ1Njc4OTEDFDIwMjEtMDctMTJUMTQ6MjU6MDlaBAYxMDAuMDAFBTE1LjAw

Render A QR Code Image

You can render the tags as QR code image easily

from fatoora import Fatoora

fatoora_obj = Fatoora(
    seller_name="Awiteb",
    tax_number=1234567891,
    invoice_date="2021-07-12T14:25:09+00:00", 
    total_amount=100,
    tax_amount=15,
)

fatoora_obj.qrcode("qr_code.png")

Generate hash (sha256)

from fatoora import Fatoora

fatoora_obj = Fatoora(
    seller_name="Awiteb",
    tax_number=1234567891, 
    invoice_date="2021-07-12T14:25:09+00:00", 
    total_amount=100, 
    tax_amount=15, 
)

print(fatoora_obj.hash)
# 7074ff5ad3b05534744037778ad1542e3c8057acd8308f50b95c7834f4955ed0

Read qr code

from fatoora import Fatoora

fatoora_obj = Fatoora(
    seller_name="Awiteb",
    tax_number=1234567891, 
    invoice_date="2021-07-12T14:25:09+00:00", 
    total_amount=100, 
    tax_amount=15, 
)

fatoora_obj.qrcode("qr_code.png")

print(Fatoora.read_qrcode("qr_code.png", dct=True))
# {'seller_name': 'Awiteb', 'tax_number': '1234567891', 'invoice_date': '2021-07-12T14:25:09+00:00', 'total_amount': '100.00', 'tax_amount': '15.00'}

print(Fatoora.read_qrcode("qr_code.png", dct=False))
# AQZBd2l0ZWICCjEyMzQ1Njc4OTEDFDIwMjEtMDctMTJUMTQ6MjU6MDlaBAYxMDAuMDAFBTE1LjAw

Extra Methods

fatoora_obj = Fatoora(
    seller_name="Awiteb",
    tax_number=1234567891, 
    invoice_date="2021-07-12T14:25:09+00:00", 
    total_amount=100, 
    tax_amount=15, 
)

print(fatoora_obj.invoice_date.year)
# 2021

print(fatoora_obj.invoice_date.isoformat())
# 2021-07-12T14:25:09+00:00

print(fatoora_obj.invoice_date.timestamp())
#1626099909.0

print(fatoora_obj.json())
# "{"seller_name": "Awiteb", "tax_number": "1234567891", "invoice_date": "2021-07-12T14:25:09+00:00", "total_amount": "100.00", "tax_amount": "15.00"}"

print(fatoora_obj.dict())
# {'seller_name': 'Awiteb', 'tax_number': '1234567891', 'invoice_date': '2021-07-12T14:25:09+00:00', 'total_amount': '100.00', 'tax_amount': '15.00'}

# Use class to get fatoora details by base64

print(Fatoora.base2dict(fatoora_obj.base64))
# {'seller_name': 'Awiteb', 'tax_number': '1234567891', 'invoice_date': '2021-07-12T14:25:09+00:00', 'total_amount': '100.00', 'tax_amount': '15.00'}

Security

If you discover any security related issues.

License

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fatoora-1.0.1.tar.gz (4.7 kB view hashes)

Uploaded Source

Built Distribution

fatoora-1.0.1-py3-none-any.whl (5.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page