Skip to content

Commit

Permalink
fix: data not generated in error_code and patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanket322 committed May 20, 2024
1 parent 9c3341c commit dafce77
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion india_compliance/gst_india/api_classes/returns.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class ReturnsAPI(ReturnsAuthenticate):
"RET13508": "no_docs_found",
"RET13509": "no_docs_found",
"RET13510": "no_docs_found",
"RET2B1023": "no_docs_found",
"RET2B1023": "not_generated",
"RET2B1016": "no_docs_found",
"RT-3BAS1009": "no_docs_found",
"RET2B1018": "requested_before_cutoff_date",
Expand Down
8 changes: 8 additions & 0 deletions india_compliance/gst_india/utils/gstr_2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ def download_gstr_2a(gstin, return_periods, otp=None, gst_categories=None):
if response.error_type in ["otp_requested", "invalid_otp"]:
return response

if response.error_type == "not_generated":
frappe.msgprint("No data has found for {0}".format(return_period))
continue

if response.error_type == "no_docs_found":
create_import_log(
gstin,
Expand Down Expand Up @@ -150,6 +154,10 @@ def download_gstr_2b(gstin, return_periods, otp=None):
if response.error_type in ["otp_requested", "invalid_otp"]:
return response

if response.error_type == "not_generated":
frappe.msgprint("No data has found for {0}".format(return_period))
continue

if response.error_type == "no_docs_found":
create_import_log(
gstin, ReturnType.GSTR2B.value, return_period, data_not_found=True
Expand Down
1 change: 1 addition & 0 deletions india_compliance/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +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
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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", ""),
},
)

0 comments on commit dafce77

Please sign in to comment.