From b7053e8897dbb8fb243a9f1b6cf783c2d5fed7f1 Mon Sep 17 00:00:00 2001 From: Sanket322 Date: Tue, 21 May 2024 11:40:47 +0530 Subject: [PATCH] fix: changes as per review --- .../gst_india/utils/gstr_2/__init__.py | 8 ++++-- ...tr_import_log_with_error_type_RET2B1023.py | 28 ++++++++++--------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/india_compliance/gst_india/utils/gstr_2/__init__.py b/india_compliance/gst_india/utils/gstr_2/__init__.py index 7d684ad7c0..8253d0653c 100644 --- a/india_compliance/gst_india/utils/gstr_2/__init__.py +++ b/india_compliance/gst_india/utils/gstr_2/__init__.py @@ -83,7 +83,9 @@ def download_gstr_2a(gstin, return_periods, otp=None, gst_categories=None): return response if response.error_type == "not_generated": - frappe.msgprint("No data has found for {0}".format(return_period)) + frappe.msgprint( + "Either you do not have any records in GSTR-2B or the generation is still in progress." + ) continue if response.error_type == "no_docs_found": @@ -155,7 +157,9 @@ def download_gstr_2b(gstin, return_periods, otp=None): return response if response.error_type == "not_generated": - frappe.msgprint("No data has found for {0}".format(return_period)) + frappe.msgprint( + "Either you do not have any records in GSTR-2B or the generation is still in progress." + ) continue if response.error_type == "no_docs_found": diff --git a/india_compliance/patches/v14/delete_gstr_import_log_with_error_type_RET2B1023.py b/india_compliance/patches/v14/delete_gstr_import_log_with_error_type_RET2B1023.py index 51225926dc..cf03de74fd 100644 --- a/india_compliance/patches/v14/delete_gstr_import_log_with_error_type_RET2B1023.py +++ b/india_compliance/patches/v14/delete_gstr_import_log_with_error_type_RET2B1023.py @@ -4,23 +4,25 @@ def execute(): - requests = frappe.get_list( + requests = frappe.get_all( "Integration Request", - filters={"url": ("like", "%gstr2b%"), "data": ("!=", ""), "output": ("!=", "")}, + filters={ + "url": ("like", "%gstr2b%"), + "data": ("!=", ""), + "output": ("like", "%RET2B1023%"), + }, fields=["data", "output"], ) for request in requests: request_data = json.loads(request.data) - response = json.loads(request.output) - error = response.get("error", {}) - if error.get("error_cd", "") == "RET2B1023": - frappe.db.delete( - "GSTR Import Log", - filters={ - "data_not_found": 1, - "gstin": request_data.get("gstin", ""), - "return_period": request_data.get("rtnprd", ""), - }, - ) + frappe.db.delete( + "GSTR Import Log", + filters={ + "data_not_found": 1, + "return_type": "GSTR2b", + "gstin": request_data.get("gstin", ""), + "return_period": request_data.get("rtnprd", ""), + }, + )