tk120404 / gst

GSTIN regex and GST checksum validation. Verify/Validate the gstin number using the regex and checksum functions available in various programming languages
Apache License 2.0
10 stars 3 forks source link

Checksum Fails #3

Open patelnav opened 5 years ago

patelnav commented 5 years ago

I've had the checksum fail on some valid GST numbers. Please check your algo with well known GST numbers

jainprashul commented 4 years ago

on js or py

nirmalraghavan commented 3 years ago

JS will fail for 32AADCK5978M1Z0

EFFICIENTCORPORATES commented 2 years ago

The check sum which has been calculated is not comprehensive. There are different types of GSTIN and each has a different Regex. A single GST number can actually comply Regex of different Type GSTIN.

Below are the REGEX for GST Number. using regex in python. (Would be glad to discuss on any Python-related automation for GST)

norm_com_isd = re.compile("[0-9]{2}[a-zA-Z]{5}[0-9]{4}[a-zA-Z]{1}[1-9A-Za-z]{1}[Zz1-9A-Ja-j]{1}[0-9a-zA-Z]{1}")

unbody = re.compile("[0-9]{4}[A-Z]{3}[0-9]{5}[UO]{1}[N][A-Z0-9]{1}")

govt_depid = re.compile("[0-9]{2}[a-zA-Z]{4}[0-9]{5}[a-zA-Z]{1}[0-9]{1}[Z]{1}[0-9]{1}")

nri_id = re.compile("[0-9]{4}[a-zA-Z]{3}[0-9]{5}[N][R][0-9a-zA-Z]{1}")

tds_id = re.compile("[0-9]{2}[a-zA-Z]{4}[a-zA-Z0-9]{1}[0-9]{4}[a-zA-Z]{1}[1-9A-Za-z]{1}[D]{1}[0-9a-zA-Z]{1}")

tcs_id = re.compile("[0-9]{2}[a-zA-Z]{5}[0-9]{4}[a-zA-Z]{1}[1-9A-Za-z]{1}[C]{1}[0-9a-zA-Z]{1}")

oidar_id = re.compile("[9][9][0-9]{2}[a-zA-Z]{3}[0-9]{5}[O][S][0-9a-zA-Z]{1}")
tk120404 commented 2 years ago

@EFFICIENTCORPORATES Please share the details or link to understand the GSTIN

EFFICIENTCORPORATES commented 2 years ago

The Break Up of GSTIN is very well explained by you in your README file... But one thing which we need to understand is that there are different types of GSTIN. A single entity can have its TDS GSTIN, Normal GSTIN and an ISD GSTIN for complying with different rules of GST.

Similarly, the GST Number allocated to Govt Department or a United Nations body is different. Also, a Non-Resident Taxable Person (NRTP) has a different GSTIN. Companies like Amazon Prime, Hotstar, Netflix come under the category of OIDAR and have different GSTIN..

Regex for each one of these GSTIN will be different... For further details you can visit the GST developers site:

https://developer.gst.gov.in/apiportal/taxpayer/returns