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
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
variables
Here the features of the variables of the Fatoora class will be explained
Name | Feature | How will it be in the tag | How will it be when you call |
---|---|---|---|
seller_name | saved directly without processing | No changes will be made to it | No changes will be made to it |
tax_number | receives the tax number as a text and a number as well, and save it as string | number as string | number as string |
invoice_date | receives the date as timestamp number or string or float and saving it as float in string with 4 decimal digits | string of timestamp with 4 decimal digits | datetime object |
total_amount | receives the tax number as a text and a number as well, It will be converted to a number with two decimal digits | It is of type str and has two decimal digits | It is of type str and has two decimal digits |
tax_amount | same total_amount | same total_amount | same total_amount |
Generate Base64
from fatoora import Fatoora
fatoora_obj = Fatoora(
seller_name="Awiteb",
tax_number=1234567891, # or "1234567891"
invoice_date=1635872693.3186214, # Timestamp
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)
# AQZBd2l0ZWICCjEyMzQ1Njc4OTEDDzE2MzU4NzI2OTMuMzE4NgQGMTAwLjAwBQUxNS4wMA==
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=1635872693.3186214,
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=1635872693.3186214,
total_amount=100,
tax_amount=15,
)
print(fatoora_obj.hash)
# 0863de708b8bfb02541e3662c327f7a6a22173b635690960ad5a1ba506096522
Read qr code
from fatoora import Fatoora
fatoora_obj = Fatoora(
seller_name="Awiteb",
tax_number=1234567891,
invoice_date=1635872693.3186214,
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': '1635872693.3186', 'total_amount': '100.00', 'tax_amount': '15.00'}
print(Fatoora.read_qrcode("qr_code.png", dct=False))
# AQZBd2l0ZWICCjEyMzQ1Njc4OTEDDzE2MzU4NzI2OTMuMzE4NgQGMTAwLjAwBQUxNS4wMA==
Extra Methods
fatoora_obj = Fatoora(
seller_name="Awiteb",
tax_number=1234567891,
invoice_date=1635872693.3186214,
total_amount=100,
tax_amount=15,
)
print(fatoora_obj.invoice_date.year)
# 2021
print(fatoora_obj.invoice_date.isoformat())
# 2021-11-02T20:04:53.318600
print(fatoora_obj.invoice_date.timestamp())
# 1635872693.3186
print(fatoora_obj.json())
# '{"seller_name": "Awiteb", "tax_number": "1234567891", "invoice_date": "1635872693.3186", "total_amount": "100.00", "tax_amount": "15.00"}'
print(fatoora_obj.dict())
# {'seller_name': 'Awiteb', 'tax_number': '1234567891', 'invoice_date': '1635872693.3186', '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': '1635872693.3186', 'total_amount': '100.00', 'tax_amount': '15.00'}
Discussions
Question, feature request, discuss about fatoora here
Issues
You can report a problem here
Security
If you discover any security related issues.
License
The MIT License (MIT). Please see License File for more information.
Project details
Release history Release notifications | RSS feed
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.1.0.tar.gz
(5.4 kB
view hashes)