Giter Club home page Giter Club logo

einvoice-phase2's Introduction

SaudiEInvoice-phase2

SaudiEInvoice is a Python library that helps you create and submit invoices to the Saudi Arabian General Authority of Zakat and Tax (GAZT) using the e-invoicing system.

Getting Started

Prerequisites

Before using SaudiEInvoice, you need to have the following:

  • Python 3.6 or higher
  • OpenSSL library
  • A GAZT account
  • A valid private key file (.pfx format) and its password
  • An e-invoicing API URL provided by GAZT

Installation

To install SaudiEInvoice, you can simply clone this repo.

Usage

To use SaudiEInvoice, you need to create an instance of the SaudiEInvoice class and provide it with the path to a configuration file that contains your GAZT account credentials, private key file path, and the e-invoicing API URL.

from saudieinvoice import SaudiEInvoice
sei = SaudiEInvoice(config_file_path="config.json")

Creating an Invoice

To create an invoice, you can pass an invoice data dictionary to the create_invoice() method. The dictionary should contain the invoice number, invoice date, vendor name, customer name, and a list of line items.

invoice_data = {
    "invoice_number": 123,
    "invoice_date": "02/10/2023",
    "vendor": "example co.",
    "customer": "example customer",
    "line_items": [
        {"product": "product1", "quantity": 1, "price": 20, "total": 20}
    ]
}
encoded_invoice_data = sei.create_invoice(invoice_data)

Submitting an Invoice

To submit an invoice, you can pass the encoded invoice data to the send_invoice() method.

success = sei.send_invoice(encoded_invoice_data)
if success:
    print("Invoice submitted successfully!")
else:
    print("Failed to submit invoice.")

Saving the XML Invoice

To save the generated XML invoice to a file, you can use the built-in ElementTree library in Python.

import xml.etree.ElementTree as ETroot = ET.fromstring(encoded_invoice_data)
xml_invoice = ET.tostring(root, encoding="utf-8")with open("invoice.xml", "wb") as f:
    f.write(xml_invoice)

Contributing

If you'd like to contribute to SaudiEInvoice, please fork the repository and make your changes. Once you're done, submit a pull request and we'll review your changes.

einvoice-phase2's People

Contributors

mohammednabarawy avatar

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.