Package: fatoora
Archived, see#23ZATCA (Fatoora) QR-Code ImplementationAnunofficial packagehelp developers to implement ZATCA (Fatoora) QR code easily which required for e-invoicingTable of ContentsRequirementsInstallationWith PyPiWith GitHubUsagevariablesGenerate Base64Render A QR Code ImageThe content is the base64 of the invoiceThe content is the invoice urlGenerate hash (sha256)Read qr codeExtra MethodsExtra FunctionsDiscussionsIssuesSecurityDonatingProject use this packageLicenseRequirementsPython>= 3.8InstallationPyPi$pip3installfatooraGitHub$gitclonehttps://github.com/TheAwiteb/fatoora/
$cdfatoora
$python3setup.pyinstallUsageVariablesHere the features of the variables of the Fatoora class will be explainedSeller’s name.Seller’ tax number, which is the VAT registration number.Invoice date, which is the timestamp of the electronic invoice.Invoice total amount, which is the electronic invoice totalwith VAT.Tax amount, which is the VAT total.NameFeatureHow will it be in the tagHow will it be when you callseller_namesaved directly without processingNo changes will be made to itNo changes will be made to ittax_numberreceives the tax number as a text and a number as well, and save it as stringnumber as stringnumber as stringinvoice_datereceives the date as timestamp or datetime object, or string ISO 8601 Zulu formatstring of date as ISO 8601 Zulu formatdatetime objecttotal_amountreceives the tax number as a text and a number as wellIt is of type str as floatIt is of type floattax_amountsame total_amount +AcceptNonevalue to get VAT auto fromtotal_amountsame total_amountsame total_amountNote: Thetax_amountis rounded to the nearest two decimal places, if it is greater than that ( iftax_amount==15its will be15.0)Note: If you settax_amounttoNonethevat_rates==0.15you can change it inFatooraobjectGenerate Base64fromfatooraimportFatoorafatoora_obj=Fatoora(seller_name="Awiteb",tax_number=1234567891,# or "1234567891"invoice_date=1635872693.3186214,# timestamp or datetime object, or string ISO 8601 Zulu formattotal_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)# AQZBd2l0ZWICCjEyMzQ1Njc4OTEDFDIwMjEtMTEtMDJUMTc6MDQ6NTNaBAUxMDAuMAUEMTUuMA==Render A QR Code ImageYou can render the tags as QR code image easilyThe content is the base64 of the invoicefromfatooraimportFatoorafatoora_obj=Fatoora(seller_name="Awiteb",tax_number=1234567891,invoice_date=1635872693.3186214,total_amount=100,tax_amount=15,)fatoora_obj.qrcode("qr_code.png")The content is the invoice urlfromfatooraimportFatoorafatoora_obj=Fatoora(seller_name="Awiteb",tax_number=1234567891,invoice_date=1635872693.3186214,total_amount=100,tax_amount=15,qrcode_url="https://example.com")fatoora_obj.qrcode("qr_code_with_url.png")Generate hash (sha256)fromfatooraimportFatoorafatoora_obj=Fatoora(seller_name="Awiteb",tax_number=1234567891,invoice_date=1635872693.3186214,total_amount=100,tax_amount=15,)print(fatoora_obj.hash)# 20b8ddb6ed9cb98be3d8535a1f4f28e35888842c1b0aed0e90c3e7fb51080dd9Read qr codefromfatooraimportFatoorafatoora_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': '2021-11-02T17:04:53Z', 'total_amount': '100.0', 'tax_amount': '15.0'}print(Fatoora.read_qrcode("qr_code.png",dct=False))# AQZBd2l0ZWICCjEyMzQ1Njc4OTEDFDIwMjEtMTEtMDJUMTc6MDQ6NTNaBAUxMDAuMAUEMTUuMA==Extra MethodsfromfatooraimportFatoorafatoora_obj=Fatoora(seller_name="Awiteb",tax_number=1234567891,invoice_date=1635872693.3186214,total_amount=100,tax_amount=15,)print(fatoora_obj.invoice_date.year)# 2021print(fatoora_obj.invoice_date.isoformat())# 2021-11-02T17:04:53print(fatoora_obj.invoice_date.timestamp())# 1635861893.0print(fatoora_obj.json())# '{"seller_name": "Awiteb", "tax_number": "1234567891", "invoice_date": "2021-11-02T17:04:53Z", "total_amount": "100.0", "tax_amount": "15.0"}'print(fatoora_obj.dict())# {'seller_name': 'Awiteb', 'tax_number': '1234567891', 'invoice_date': '2021-11-02T17:04:53Z', 'total_amount': '100.0', 'tax_amount': '15.0'}# Use class to get fatoora details by base64print(Fatoora.base2dict(fatoora_obj.base64))# {'seller_name': 'Awiteb', 'tax_number': '1234567891', 'invoice_date': '2021-11-02T17:04:53Z', 'total_amount': '100.0', 'tax_amount': '15.0'}Extra Functionsimportfatooraprint(fatoora.is_valid_iso8601_zulu_format("invalid date"))# Falseprint(fatoora.is_valid_iso8601_zulu_format("2021-11-02T17:04:53Z"))# TrueDiscussionsQuestion, feature request, discuss about fatoorahereIssuesYou can report a bug fromhereSecurityIf you discover any security related issues.DonatingCurrencyAddressBinanceBNB BEP200xD89c146B03B72191be91064D313610981dCAF6d4USD CoinUSDC BEP200xD89c146B03B72191be91064D313610981dCAF6d4BitcoinBTCbc1q0ltmqmsc4qs740ssyf9k9jq99nwxtqu8aupmdjBitcoin CashBCHqrpm6zyte3d4z2u9r24l04m3havc2wd9vgqlz8sjgrLicenseThe MIT License (MIT). Please seeLicense Filefor more information.