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.
Documentation
Usage
Install the library:
pip install gst-e-invoicing
Use it in your code:
from gst_irn import Session, get_invoice, get_seller_dtls
from gst_irn.codes import States
with open('public_key.pem') as f:
public_key = f.read()
session = Session(
'GSTIN',
client_id='CLIENT_ID',
client_secret='CLIENT_SECRET',
username='USERNAME',
password='PASSWORD',
public_key=public_key,
# use the sandbox url, or production url
# or pass-through APIs provided by GSPs
base_url='https://einv-apisandbox.nic.in',
)
session.generate_token()
# create invoice object
# can also use the helper functions for the same
invoice = {
"Version": "1.1",
"TranDtls": {"TaxSch": "GST", "SupTyp": "B2B"},
"DocDtls": {
"Typ": "inv",
"No": "221",
"Dt": "21/09/2021",
},
"SellerDtls": {
"Gstin": "09GSTNUMBER1Z5",
"LglNm": "PARTY NAME",
"Addr1": "Seller Address",
"Loc": "City",
"Pin": 111111,
"Stcd": States.UTTAR_PRADESH.value,
},
"BuyerDtls": {
"Gstin": "37GSTNUMBER2ZP",
"LglNm": "BUYER NAME",
"Pos": States.KOLKATA.value,
"Addr1": "Buyer Address",
"Loc": "City",
"Pin": 555555,
"Stcd": States.KOLKATA.value,
},
"ItemList": [
{
"SlNo": "1",
"IsServc": "Y",
"HsnCd": "998431",
"UnitPrice": 100,
"IgstAmt": 12,
"TotAmt": 100,
"AssAmt": 100,
"GstRt": 12.0,
"TotItemVal": 112,
}
],
"ValDtls": {"TotInvVal": 112, "AssVal": 100, "IgstVal": 12},
"EwbDtls": {"Distance": 10},
}
# 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="...">
Find the full documentation here: https://mittal-analytics.github.io/gst-e-invoicing/
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.7.1.tar.gz
(19.7 kB
view details)
Built Distribution
File details
Details for the file gst-e-invoicing-0.7.1.tar.gz
.
File metadata
- Download URL: gst-e-invoicing-0.7.1.tar.gz
- Upload date:
- Size: 19.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31a0a7ca31d17e0ce18f0b495cbac5c3305f4a1abc7d01f00c219e5fdc5d4bc5 |
|
MD5 | 2c5fe3c301a84fc7428a0c8eff5cd236 |
|
BLAKE2b-256 | fbc8473e54d891712926e2d3a0a3040c4c5abd2ea771b4e8e40e9b03f1238467 |
File details
Details for the file gst_e_invoicing-0.7.1-py3-none-any.whl
.
File metadata
- Download URL: gst_e_invoicing-0.7.1-py3-none-any.whl
- Upload date:
- Size: 20.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34d0cac6a68f2d06974042e3ea91c151efc7b0745613a00cff05eea4091d624d |
|
MD5 | cd4496c226e5cfe9ec00a05d3da20e75 |
|
BLAKE2b-256 | ad0b033cadb1bc67b3be08e7b3c7eed468873daf66e9f715c10625cb6fb60f0c |