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 a2353f83d..0dd8ead51 100644 --- a/india_compliance/gst_india/doctype/gst_settings/gst_settings.json +++ b/india_compliance/gst_india/doctype/gst_settings/gst_settings.json @@ -41,7 +41,7 @@ "e_invoice_applicable_from", "e_invoice_applicable_companies", "gstr_1_section_break", - "analyze_filed_data", + "compare_gstr_1_data", "filing_frequency", "column_break_cxmn", "restrict_changes_after_gstr_1", @@ -572,14 +572,6 @@ "fieldtype": "Section Break", "label": "GSTR-1" }, - { - "default": "0", - "depends_on": "eval: india_compliance.is_api_enabled(doc)", - "description": "Compare Books with GSTR 1 Filed or Invoice data before filing", - "fieldname": "analyze_filed_data", - "fieldtype": "Check", - "label": "Analyze Filed Data" - }, { "fieldname": "column_break_cxmn", "fieldtype": "Column Break" @@ -591,6 +583,7 @@ "options": "Monthly\nQuarterly" }, { + "depends_on": "eval: doc.restrict_changes_after_gstr_1", "fieldname": "role_allowed_to_modify", "fieldtype": "Link", "label": "Role Allowed to Modify Transactions", @@ -599,16 +592,24 @@ { "default": "0", "depends_on": "eval: india_compliance.is_api_enabled(doc)", - "description": "Ensures restrictions to cancel or create transactions after return is marked as filed", + "description": "Prevent any modifications to transactions once they have been reported in GSTR-1", "fieldname": "restrict_changes_after_gstr_1", "fieldtype": "Check", - "label": "Restrict changes after GSTR 1 is filed" + "label": "Restrict Changes to Transactions After Filing" + }, + { + "default": "0", + "depends_on": "eval: india_compliance.is_api_enabled(doc)", + "description": "Use APIs to compare records with GST Portal Data Before and After Filing", + "fieldname": "compare_gstr_1_data", + "fieldtype": "Check", + "label": "Compare Data with GST Portal" } ], "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2024-05-17 15:46:11.169920", + "modified": "2024-06-09 17:27:54.720233", "modified_by": "Administrator", "module": "GST India", "name": "GST Settings", diff --git a/india_compliance/gst_india/doctype/gst_settings/gst_settings.py b/india_compliance/gst_india/doctype/gst_settings/gst_settings.py index 12092f362..a83961928 100644 --- a/india_compliance/gst_india/doctype/gst_settings/gst_settings.py +++ b/india_compliance/gst_india/doctype/gst_settings/gst_settings.py @@ -270,7 +270,7 @@ def validate_e_invoice_applicable_companies(self): company_list.append(row.company) - def is_sek_valid(self, gstin, throw=True, threshold=30): + def is_sek_valid(self, gstin, throw=False, threshold=30): for credential in self.credentials: if credential.service == "Returns" and credential.gstin == gstin: break @@ -290,6 +290,22 @@ def is_sek_valid(self, gstin, throw=True, threshold=30): ): return True + def has_valid_credentials(self, gstin, service, throw=False): + for credential in self.credentials: + if credential.gstin == gstin and credential.service == service: + break + else: + message = _( + "No credential found for the GSTIN {0} in the GST Settings" + ).format(gstin) + + if throw: + frappe.throw(message) + + return False + + return True + @frappe.whitelist() def disable_api_promo(): diff --git a/india_compliance/gst_india/doctype/gstr_1_beta/gstr_1_beta.js b/india_compliance/gst_india/doctype/gstr_1_beta/gstr_1_beta.js index 7bcb16cd1..5b2a81a9e 100644 --- a/india_compliance/gst_india/doctype/gstr_1_beta/gstr_1_beta.js +++ b/india_compliance/gst_india/doctype/gstr_1_beta/gstr_1_beta.js @@ -2082,7 +2082,7 @@ function is_gstr1_api_enabled() { return ( india_compliance.is_api_enabled() && !gst_settings.sandbox_mode && - gst_settings.analyze_filed_data + gst_settings.compare_gstr_1_data ); } diff --git a/india_compliance/gst_india/doctype/gstr_1_log/gstr_1_log.py b/india_compliance/gst_india/doctype/gstr_1_log/gstr_1_log.py index 15f4f6c7e..b9c4f7616 100644 --- a/india_compliance/gst_india/doctype/gstr_1_log/gstr_1_log.py +++ b/india_compliance/gst_india/doctype/gstr_1_log/gstr_1_log.py @@ -777,7 +777,11 @@ def is_gstr1_api_enabled(self, settings=None): if not settings: settings = frappe.get_cached_doc("GST Settings") - return is_production_api_enabled(settings) and settings.analyze_filed_data + return ( + is_production_api_enabled(settings) + and settings.compare_gstr_1_data + and settings.has_valid_credentials(self.gstin, "Returns") + ) def is_sek_needed(self, settings=None): if not self.is_gstr1_api_enabled(settings): diff --git a/india_compliance/gst_india/setup/__init__.py b/india_compliance/gst_india/setup/__init__.py index d1bb53b75..a4fa622a8 100644 --- a/india_compliance/gst_india/setup/__init__.py +++ b/india_compliance/gst_india/setup/__init__.py @@ -216,7 +216,7 @@ def set_default_gst_settings(): "reconcile_for_b2b": 1, "reconcile_for_cdnr": 1, # GSTR-1 - "analyze_filed_data": 1, + "compare_gstr_1_data": 1, "freeze_transactions": 1, "filing_frequency": "Monthly", } diff --git a/india_compliance/patches/v14/update_default_gstr1_settings.py b/india_compliance/patches/v14/update_default_gstr1_settings.py index 0352027a3..e8f4ef986 100644 --- a/india_compliance/patches/v14/update_default_gstr1_settings.py +++ b/india_compliance/patches/v14/update_default_gstr1_settings.py @@ -5,7 +5,7 @@ def execute(): frappe.db.set_single_value( "GST Settings", { - "analyze_filed_data": 1, + "compare_gstr_1_data": 1, "freeze_transactions": 1, "filing_frequency": "Monthly", },