Skip to content

Commit e94a87a

Browse files
committed
fix(purchase-reco): add alert for ongoing download jobs
1 parent 8e531ab commit e94a87a

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

india_compliance/gst_india/doctype/purchase_reconciliation_tool/purchase_reconciliation_tool.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,14 @@ async function download_gstr(
12231223
gst_categories,
12241224
};
12251225
frm.events.show_progress(frm, "download");
1226-
await frm.taxpayer_api_call("download_gstr", args);
1226+
const { message } = await frm.taxpayer_api_call("download_gstr", args);
1227+
1228+
if (message.message) {
1229+
frappe.show_alert({
1230+
message: message.message,
1231+
indicator: message.indicator || "blue",
1232+
});
1233+
}
12271234
});
12281235
}
12291236

india_compliance/gst_india/doctype/purchase_reconciliation_tool/purchase_reconciliation_tool.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from frappe.model.document import Document
1010
from frappe.query_builder.functions import IfNull
1111
from frappe.utils import add_to_date, cint, now_datetime
12+
from frappe.utils.background_jobs import is_job_enqueued
1213
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
1314
get_accounting_dimensions,
1415
)
@@ -53,7 +54,6 @@
5354
save_gstr_2a,
5455
save_gstr_2b,
5556
)
56-
from india_compliance.utils import get_hash
5757

5858
STATUS_MAP = {
5959
"Accept": "Reconciled",
@@ -134,14 +134,16 @@ def download_gstr(
134134
):
135135
frappe.has_permission("Purchase Reconciliation Tool", "write", throw=True)
136136

137-
TaxpayerBaseAPI(company_gstin).validate_auth_token()
137+
job_id = f"purchase_reconciliation_tool:{company_gstin}:{return_type}"
138138

139-
job_id = get_hash(
140-
{
141-
"company_gstin": company_gstin,
142-
"return_type": return_type,
139+
if is_job_enqueued(job_id):
140+
return {
141+
"message": _(
142+
"A download job is already in progress for the GSTIN - {0} and Return Type - {1}"
143+
).format(company_gstin, return_type),
143144
}
144-
)
145+
146+
TaxpayerBaseAPI(company_gstin).validate_auth_token()
145147

146148
frappe.enqueue(
147149
download_gstr,

0 commit comments

Comments
 (0)