Python library for generating e-invoices using GST's E-invoicing portal.
Project description
Python library for GST's E-invoicing portal
This is the python library for interacting with GST's E-invoicing portal.
Usage
Install the library:
pip install gst-e-invoicing
Use it in your code:
from gst_irn import Session, Invoice, InvoiceItem
session = Session(
'GSTIN',
client_id='CLIENT_ID',
client_secret='CLIENT_SECRET',
username='USERNAME',
password='PASSWORD',
app_key='APP_KEY',
is_sandbox=True,
force_generate=False,
)
session.generate_token()
# create invoice object
# use Session.get_party to automatically fetch details
# or use Party() to provide details manually
seller = session.get_party('SELLER_GSTIN')
buyer = session.get_party('BUYER_GSTIN')
items = [
InvoiceItem(
hsn_sac='HSN_SAC',
)
]
# provide document details for the invoice
invoice = Invoice(
no="DOC/0001",
dt=dt.date(2022, 5, 19),
items=items,
seller=seller,
buyer=buyer,
)
# submit and get the e-invoice
einvoice = session.generate_einvoice(invoice)
# access irn and qr-code
print(einvoice['Irn'])
# prints irn
# print qr-code
from gst_irn.qr import get_qr_code_image_html
qr_code_image = get_qr_code_image_html(einvoice['SignedQRCode'])
qr_code_image
# prints <img src="...">
Technical details
Schema Spec: https://www.cbic.gov.in/resources/htdocs-cbec/gst/notfctn-60-central-tax-english-2020.pdf Simplified Spec: https://einvoice1.gst.gov.in/Documents/EINVOICE_SCHEMA.xlsx
The key's used in JSON file are CamelCase. The attributes we use in the Python library are snake_case version of the same.
Development
Setting up dev environment:
# create and activate virtual env
python3 -m venv .venv
source .venv/bin/activate
# install requirements
pip install '.[dev]'
# provide credentials
cp .env.sample .env
# edit and update the credentials in .env file
vi .env
# running tests
python -m unittest
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
gst-e-invoicing-0.0.1.tar.gz
(43.7 kB
view hashes)
Built Distribution
Close
Hashes for gst_e_invoicing-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53e70fa9dbc7734d2fab85ddbf19ab42959fba23425a7fc0d96650f7aba0c77a |
|
MD5 | 30dcdf59f7cb2d6c3303d4f9e2c19d70 |
|
BLAKE2b-256 | 770314447194639e6ea99d7e757f01f67e0c8c42737426ee4dbed9dde6891738 |