fix: Validation for duplicate Tax Category

This commit is contained in:
Deepesh Garg
2020-11-21 21:36:44 +05:30
parent 98d8718979
commit 71349d5a49
2 changed files with 11 additions and 1 deletions

View File

@@ -239,6 +239,9 @@ doc_events = {
"Website Settings": {
"validate": "erpnext.portal.doctype.products_settings.products_settings.home_page_is_products"
},
"Tax Category": {
"validate": "erpnext.regional.india.utils.validate_tax_category"
},
"Sales Invoice": {
"on_submit": ["erpnext.regional.create_transaction_log", "erpnext.regional.italy.utils.sales_invoice_on_submit"],
"on_cancel": "erpnext.regional.italy.utils.sales_invoice_on_cancel",

View File

@@ -52,6 +52,13 @@ def validate_gstin_for_india(doc, method):
frappe.throw(_("Invalid GSTIN! First 2 digits of GSTIN should match with State number {0}.")
.format(doc.gst_state_number))
def validate_tax_category(doc, method):
if doc.get('gst_state') and frappe.db.get_value('Tax category', {'gst_state': doc.gst_state, 'is_inter_state': doc.is_inter_state}):
if doc.is_inter_state:
frappe.throw(_("Inter State tax category for GST State {0} already exists").format(doc.gst_state))
else:
frappe.throw(_("Intra State tax category for GST State {0} already exists").format(doc.gst_state))
def update_gst_category(doc, method):
for link in doc.links:
if link.link_doctype in ['Customer', 'Supplier']:
@@ -523,7 +530,7 @@ def get_address_details(data, doc, company_address, billing_address):
data.transType = 1
data.actualToStateCode = data.toStateCode
shipping_address = billing_address
if doc.gst_category == 'SEZ':
data.toStateCode = 99