mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-09 08:02:51 +00:00
fix: GST Validation for UIN and OIDAR (#17866)
* fix: GST Validation for UIN and OIDAR * fix: Define GST category * fix: Get gst category only for Customer and Supplier * fix: GST validation * fix: GST validation fixes
This commit is contained in:
@@ -14,6 +14,15 @@ def validate_gstin_for_india(doc, method):
|
||||
if not hasattr(doc, 'gstin') or not doc.gstin:
|
||||
return
|
||||
|
||||
gst_category = []
|
||||
|
||||
if len(doc.links):
|
||||
link_doctype = doc.links[0].get("link_doctype")
|
||||
link_name = doc.links[0].get("link_name")
|
||||
|
||||
if link_doctype in ["Customer", "Supplier"]:
|
||||
gst_category = frappe.db.get_value(link_doctype, {'name': link_name}, ['gst_category'])
|
||||
|
||||
doc.gstin = doc.gstin.upper().strip()
|
||||
if not doc.gstin or doc.gstin == 'NA':
|
||||
return
|
||||
@@ -21,6 +30,11 @@ def validate_gstin_for_india(doc, method):
|
||||
if len(doc.gstin) != 15:
|
||||
frappe.throw(_("Invalid GSTIN! A GSTIN must have 15 characters."))
|
||||
|
||||
if gst_category and gst_category == 'UIN Holders':
|
||||
p = re.compile("^[0-9]{4}[A-Z]{3}[0-9]{5}[0-9A-Z]{3}")
|
||||
if not p.match(doc.gstin):
|
||||
frappe.throw(_("Invalid GSTIN! The input you've entered doesn't match the GSTIN format for UIN Holders or Non-Resident OIDAR Service Providers"))
|
||||
else:
|
||||
p = re.compile("^[0-9]{2}[A-Z]{4}[0-9A-Z]{1}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}[1-9A-Z]{1}[0-9A-Z]{1}$")
|
||||
if not p.match(doc.gstin):
|
||||
frappe.throw(_("Invalid GSTIN! The input you've entered doesn't match the format of GSTIN."))
|
||||
|
||||
Reference in New Issue
Block a user