From e61b7affeefb9a06d58ef21eebee291479ff290f Mon Sep 17 00:00:00 2001 From: Sanket322 Date: Tue, 21 May 2024 22:41:01 +0530 Subject: [PATCH] fix: changes as per review --- .../gst_india/utils/gstr_2/__init__.py | 12 ++++++-- india_compliance/patches.txt | 2 +- ...tr_import_log_with_error_type_RET2B1023.py | 26 ----------------- .../delete_not_generated_gstr_import_log.py | 28 +++++++++++++++++++ 4 files changed, 39 insertions(+), 29 deletions(-) delete mode 100644 india_compliance/patches/v14/delete_gstr_import_log_with_error_type_RET2B1023.py create mode 100644 india_compliance/patches/v14/delete_not_generated_gstr_import_log.py diff --git a/india_compliance/gst_india/utils/gstr_2/__init__.py b/india_compliance/gst_india/utils/gstr_2/__init__.py index 7d684ad7c0..3c7328abf6 100644 --- a/india_compliance/gst_india/utils/gstr_2/__init__.py +++ b/india_compliance/gst_india/utils/gstr_2/__init__.py @@ -83,7 +83,12 @@ 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( + _( + "No record is found in GSTR-2B or generation is still in progress" + ), + title=_("Not Generated"), + ) continue if response.error_type == "no_docs_found": @@ -155,7 +160,10 @@ 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( + _("No record is found in GSTR-2B or generation is still in progress"), + title=_("Not Generated"), + ) continue if response.error_type == "no_docs_found": diff --git a/india_compliance/patches.txt b/india_compliance/patches.txt index ced3778135..2baf81eb77 100644 --- a/india_compliance/patches.txt +++ b/india_compliance/patches.txt @@ -47,4 +47,4 @@ execute:from erpnext.stock.doctype.repost_item_valuation.repost_item_valuation i india_compliance.patches.v14.set_item_details_from_purchase_invoice_to_bill_of_entry india_compliance.patches.v14.update_item_gst_details_and_gst_trearment_in_bill_of_entry india_compliance.patches.v14.update_default_auto_reconciliation_settings -india_compliance.patches.v14.delete_gstr_import_log_with_error_type_RET2B1023 +india_compliance.patches.v14.delete_not_generated_gstr_import_log 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 deleted file mode 100644 index 51225926dc..0000000000 --- a/india_compliance/patches/v14/delete_gstr_import_log_with_error_type_RET2B1023.py +++ /dev/null @@ -1,26 +0,0 @@ -import json - -import frappe - - -def execute(): - requests = frappe.get_list( - "Integration Request", - filters={"url": ("like", "%gstr2b%"), "data": ("!=", ""), "output": ("!=", "")}, - 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", ""), - }, - ) diff --git a/india_compliance/patches/v14/delete_not_generated_gstr_import_log.py b/india_compliance/patches/v14/delete_not_generated_gstr_import_log.py new file mode 100644 index 0000000000..cf03de74fd --- /dev/null +++ b/india_compliance/patches/v14/delete_not_generated_gstr_import_log.py @@ -0,0 +1,28 @@ +import json + +import frappe + + +def execute(): + requests = frappe.get_all( + "Integration Request", + filters={ + "url": ("like", "%gstr2b%"), + "data": ("!=", ""), + "output": ("like", "%RET2B1023%"), + }, + fields=["data", "output"], + ) + + for request in requests: + request_data = json.loads(request.data) + + 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", ""), + }, + )