From b146ff9c787e4e4e7a3b0ff9d7a26a2decc1a972 Mon Sep 17 00:00:00 2001 From: Vishakh Desai Date: Fri, 26 Apr 2024 17:15:57 +0530 Subject: [PATCH 1/2] fix: temporary disabled GST Transporter ID API validation --- .../client_scripts/e_waybill_actions.js | 6 ++++-- .../gst_india/client_scripts/supplier.js | 19 ++++++++++--------- .../doctype/gst_settings/gst_settings.json | 2 +- .../gst_india/overrides/transaction.py | 18 +++++++++--------- india_compliance/gst_india/utils/__init__.py | 2 +- india_compliance/public/js/transaction.js | 8 ++++---- 6 files changed, 29 insertions(+), 26 deletions(-) diff --git a/india_compliance/gst_india/client_scripts/e_waybill_actions.js b/india_compliance/gst_india/client_scripts/e_waybill_actions.js index 473581f98..d45353185 100644 --- a/india_compliance/gst_india/client_scripts/e_waybill_actions.js +++ b/india_compliance/gst_india/client_scripts/e_waybill_actions.js @@ -1162,9 +1162,11 @@ async function update_gst_tranporter_id(dialog) { } function set_gst_transporter_id_status(dialog) { - const gst_transporter_id_field = dialog.get_field("gst_transporter_id"); + return; + // TODO: Refactor + // const gst_transporter_id_field = dialog.get_field("gst_transporter_id"); - india_compliance.set_gstin_status(gst_transporter_id_field); + // india_compliance.set_gstin_status(gst_transporter_id_field); } function update_generation_dialog(dialog, doc) { diff --git a/india_compliance/gst_india/client_scripts/supplier.js b/india_compliance/gst_india/client_scripts/supplier.js index 05a0bfa11..fcfa08cb9 100644 --- a/india_compliance/gst_india/client_scripts/supplier.js +++ b/india_compliance/gst_india/client_scripts/supplier.js @@ -22,14 +22,15 @@ frappe.ui.form.on(DOCTYPE, { frm.set_value("gst_transporter_id", frm.doc.gstin); }, - gst_transporter_id(frm) { - if ( - !frm.doc.gst_transporter_id || - frm.doc.gst_transporter_id.length < 15 - ) - return; + // TODO: Refactor + // gst_transporter_id(frm) { + // if ( + // !frm.doc.gst_transporter_id || + // frm.doc.gst_transporter_id.length < 15 + // ) + // return; - gst_transporter_id_field = frm.get_field("gst_transporter_id"); - india_compliance.set_gstin_status(gst_transporter_id_field); - }, + // gst_transporter_id_field = frm.get_field("gst_transporter_id"); + // india_compliance.set_gstin_status(gst_transporter_id_field); + // }, }); diff --git a/india_compliance/gst_india/doctype/gst_settings/gst_settings.json b/india_compliance/gst_india/doctype/gst_settings/gst_settings.json index a709fd37f..83da94e18 100644 --- a/india_compliance/gst_india/doctype/gst_settings/gst_settings.json +++ b/india_compliance/gst_india/doctype/gst_settings/gst_settings.json @@ -374,7 +374,7 @@ }, { "default": "1", - "description": "Ensures valid GSTIN and GST Transporter ID in transactions by refreshing status periodically from government database", + "description": "Ensures valid GSTIN in transactions by refreshing status periodically from government database", "fieldname": "validate_gstin_status", "fieldtype": "Check", "label": "Refresh and Validate GSTIN Status in Transactions" diff --git a/india_compliance/gst_india/overrides/transaction.py b/india_compliance/gst_india/overrides/transaction.py index 83b95a367..6f759860a 100644 --- a/india_compliance/gst_india/overrides/transaction.py +++ b/india_compliance/gst_india/overrides/transaction.py @@ -12,8 +12,7 @@ STATE_NUMBERS, ) from india_compliance.gst_india.constants.custom_fields import E_WAYBILL_INV_FIELDS -from india_compliance.gst_india.doctype.gstin.gstin import ( - _validate_gst_transporter_id_info, +from india_compliance.gst_india.doctype.gstin.gstin import ( # _validate_gst_transporter_id_info, _validate_gstin_info, get_gstin_status, ) @@ -1289,23 +1288,24 @@ def validate_gstin_status(gstin, transaction_date): def validate_gst_transporter_id(doc): + # TODO: Refactor if not doc.get("gst_transporter_id"): return - settings = frappe.get_cached_doc("GST Settings") - if not settings.validate_gstin_status: - return + # settings = frappe.get_cached_doc("GST Settings") + # if not settings.validate_gstin_status: + # return doc.gst_transporter_id = validate_gstin( doc.gst_transporter_id, label="GST Transporter ID", is_transporter_id=True ) - gstin_doc = get_gstin_status(doc.gst_transporter_id) + # gstin_doc = get_gstin_status(doc.gst_transporter_id) - if not gstin_doc: - return + # if not gstin_doc: + # return - _validate_gst_transporter_id_info(gstin_doc, throw=True) + # _validate_gst_transporter_id_info(gstin_doc, throw=True) def validate_company_address_field(doc): diff --git a/india_compliance/gst_india/utils/__init__.py b/india_compliance/gst_india/utils/__init__.py index 87b9ba040..b7ce2e622 100644 --- a/india_compliance/gst_india/utils/__init__.py +++ b/india_compliance/gst_india/utils/__init__.py @@ -171,7 +171,7 @@ def validate_gstin( title=_("Invalid {0}").format(label), ) - if not (is_transporter_id and gstin.startswith("88")): + if not is_transporter_id: validate_gstin_check_digit(gstin, label) if is_tcs_gstin and not TCS.match(gstin): diff --git a/india_compliance/public/js/transaction.js b/india_compliance/public/js/transaction.js index 580c1b7f9..c389b4d3b 100644 --- a/india_compliance/public/js/transaction.js +++ b/india_compliance/public/js/transaction.js @@ -179,10 +179,10 @@ function set_and_validate_gstin_status(doctype) { [gstin_field_name](frm) { _set_and_validate_gstin_status(frm, gstin_field_name); }, - - gst_transporter_id(frm) { - _set_and_validate_gstin_status(frm, "gst_transporter_id"); - }, + // TODO: Refactor + // gst_transporter_id(frm) { + // _set_and_validate_gstin_status(frm, "gst_transporter_id"); + // }, posting_date(frm) { if (frm.get_field("posting_date")) From dfe0eb3f7b0dd4f0978bdf3c182b67da37225ae6 Mon Sep 17 00:00:00 2001 From: Vishakh Desai Date: Mon, 29 Apr 2024 11:17:23 +0530 Subject: [PATCH 2/2] fix: commented test_validate_gst_transporter_id_info --- .../gst_india/doctype/gstin/test_gstin.py | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/india_compliance/gst_india/doctype/gstin/test_gstin.py b/india_compliance/gst_india/doctype/gstin/test_gstin.py index e948c983e..b7e648c75 100644 --- a/india_compliance/gst_india/doctype/gstin/test_gstin.py +++ b/india_compliance/gst_india/doctype/gstin/test_gstin.py @@ -1,48 +1,48 @@ # Copyright (c) 2023, Resilient Tech and Contributors # See license.txt -import re +# import re -import frappe -from frappe.tests.utils import FrappeTestCase, change_settings -from frappe.utils import now +# import frappe +# from frappe.tests.utils import FrappeTestCase, change_settings +# from frappe.utils import now -from india_compliance.gst_india.utils.tests import create_transaction +# from india_compliance.gst_india.utils.tests import create_transaction +# TODO: Uncomment after GST Transporter ID validation is fixed +# class TestGSTIN(FrappeTestCase): +# @change_settings("GST Settings", {"validate_gstin_status": 1, "sandbox_mode": 0}) +# def test_validate_gst_transporter_id_info(self): +# # customer gstin +# frappe.get_doc( +# { +# "doctype": "GSTIN", +# "gstin": "24AANFA2641L1ZF", +# "registration_date": "2021-01-01", +# "status": "Active", +# "last_updated_on": now(), +# } +# ).insert(ignore_if_duplicate=True) -class TestGSTIN(FrappeTestCase): - @change_settings("GST Settings", {"validate_gstin_status": 1, "sandbox_mode": 0}) - def test_validate_gst_transporter_id_info(self): - # customer gstin - frappe.get_doc( - { - "doctype": "GSTIN", - "gstin": "24AANFA2641L1ZF", - "registration_date": "2021-01-01", - "status": "Active", - "last_updated_on": now(), - } - ).insert(ignore_if_duplicate=True) +# # gst transporter id +# frappe.get_doc( +# { +# "doctype": "GSTIN", +# "gstin": "88AABCM9407D1ZS", +# "status": "Invalid", +# "last_updated_on": now(), +# } +# ).insert(ignore_if_duplicate=True) - # gst transporter id - frappe.get_doc( - { - "doctype": "GSTIN", - "gstin": "88AABCM9407D1ZS", - "status": "Invalid", - "last_updated_on": now(), - } - ).insert(ignore_if_duplicate=True) +# si = create_transaction( +# doctype="Sales Invoice", +# gst_transporter_id="88AABCM9407D1ZS", +# do_not_save=True, +# ) - si = create_transaction( - doctype="Sales Invoice", - gst_transporter_id="88AABCM9407D1ZS", - do_not_save=True, - ) - - self.assertRaisesRegex( - frappe.ValidationError, - re.compile( - r"^(.*is not Active. Please make sure that transporter ID is valid.*)$" - ), - si.save, - ) +# self.assertRaisesRegex( +# frappe.ValidationError, +# re.compile( +# r"^(.*is not Active. Please make sure that transporter ID is valid.*)$" +# ), +# si.save, +# )