Skip to content

Commit

Permalink
fix: error handling for download
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanket322 committed Dec 9, 2024
1 parent d4f5226 commit 4523b41
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 4523b41

Please sign in to comment.