diff --git a/india_compliance/gst_india/doctype/purchase_reconciliation_tool/purchase_reconciliation_tool.js b/india_compliance/gst_india/doctype/purchase_reconciliation_tool/purchase_reconciliation_tool.js index bfe0b7461f..b1087a2e9e 100644 --- a/india_compliance/gst_india/doctype/purchase_reconciliation_tool/purchase_reconciliation_tool.js +++ b/india_compliance/gst_india/doctype/purchase_reconciliation_tool/purchase_reconciliation_tool.js @@ -70,6 +70,15 @@ frappe.ui.form.on("Purchase Reconciliation Tool", { await frappe.require("purchase_reconciliation_tool.bundle.js"); frm.trigger("company"); frm.purchase_reconciliation_tool = new PurchaseReconciliationTool(frm); + + frappe.realtime.on("download_failed", message => { + frm.dashboard.hide(); + frappe.msgprint({ + title: __("Download Failed"), + message: message.error, + indicator: "red" + }); + }) }, onload(frm) { diff --git a/india_compliance/gst_india/doctype/purchase_reconciliation_tool/purchase_reconciliation_tool.py b/india_compliance/gst_india/doctype/purchase_reconciliation_tool/purchase_reconciliation_tool.py index 3c9cf1ad9a..674614ffa5 100644 --- a/india_compliance/gst_india/doctype/purchase_reconciliation_tool/purchase_reconciliation_tool.py +++ b/india_compliance/gst_india/doctype/purchase_reconciliation_tool/purchase_reconciliation_tool.py @@ -460,11 +460,20 @@ def download_gstr( if not periods: return - if return_type == ReturnType.GSTR2A: - return download_gstr_2a(company_gstin, periods, gst_categories) + try: + if return_type == ReturnType.GSTR2A: + return download_gstr_2a(company_gstin, periods, gst_categories) - if return_type == ReturnType.GSTR2B: - return download_gstr_2b(company_gstin, periods) + if return_type == ReturnType.GSTR2B: + return download_gstr_2b(company_gstin, periods) + + except Exception as e: + frappe.publish_realtime( + "download_failed", + {"error": str(e)}, + user=frappe.session.user, + doctype="Purchase Reconciliation Tool", + ) def get_periods_to_download(company_gstin, return_type, periods):