Coder Social home page Coder Social logo

mittal-analytics / gst-e-invoicing Goto Github PK

View Code? Open in Web Editor NEW
18.0 1.0 1.0 154 KB

Python library for generating IRN on GST's e-invoicing portal (IRP). (GST einvoicing)

Home Page: https://mittal-analytics.github.io/gst-e-invoicing/

License: GNU General Public License v3.0

Python 80.19% HTML 19.81%
gst gst-e-invoice gst-einvoice

gst-e-invoicing's Introduction

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

gst-e-invoicing's People

Contributors

pratyushmittal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

impranshu

gst-e-invoicing's Issues

greetings from gnukhata team

hi.
I am one of the contributors to Gnukhata https://gitlab.com/gnukhata/gkapp/ and i came across your repo and long story short, our project is in serious need of some GST goodness and your project looks like a nice drop-in enhancement.

Your license is Gpl 3, same as ours so we've been thinking if we could use your code and not have to reinvent the wheel when you've already done most of the work.

May i (my personal question here) know why did you release this for public? i saw your website and it looks like you are into financial statement analysis and stuff. Why would you spend time to build your own GST e-invoicing library and then open sourcing it?

That said, our GST returns, e-way bill and others are not ready for prime time because we are operating without any docs, currently we do blackbox testing by making same entries in our software and tally/marg and comparing return outputs. Haha. And we don't have e-way bill/e-invoicing so we cannot just tell people to drop their proprietary softwares and use our free one when it is not ready.

What do you think about this?

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.