Skip to content

Commit dda0adf

Browse files
authored
Merge pull request resilient-tech#3805 from resilient-tech/mergify/bp/version-15-hotfix/pr-3793
fix: give job_id argument to frappe.enqueue in purchase reconciliation tool and GST IMS (backport resilient-tech#3793)
2 parents 3cf565f + 4ca5300 commit dda0adf

4 files changed

Lines changed: 48 additions & 6 deletions

File tree

india_compliance/gst_india/doctype/gst_invoice_management_system/gst_invoice_management_system.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -684,14 +684,21 @@ class IMSAction {
684684
}
685685

686686
async download_ims_data() {
687-
await taxpayer_api.call({
687+
const { message } = await taxpayer_api.call({
688688
method: `${DOC_PATH}.download_invoices`,
689689
args: { company_gstin: this.frm.doc.company_gstin },
690690
});
691691

692-
frappe.show_alert({
693-
message: __("Downloading Invoices"),
694-
});
692+
if (message?.message) {
693+
frappe.show_alert({
694+
message: message.message,
695+
indicator: message?.indicator || "blue",
696+
});
697+
} else {
698+
frappe.show_alert({
699+
message: __("Downloading Invoices"),
700+
});
701+
}
695702
}
696703

697704
async get_ims_data() {

india_compliance/gst_india/doctype/gst_invoice_management_system/gst_invoice_management_system.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from frappe.model.document import Document
77
from frappe.query_builder.functions import IfNull
88
from frappe.utils import add_to_date, format_date
9+
from frappe.utils.background_jobs import is_job_enqueued
910

1011
from india_compliance.gst_india.api_classes.taxpayer_base import (
1112
TaxpayerBaseAPI,
@@ -248,9 +249,24 @@ def get_link_options(self, doctype, filters):
248249
def download_invoices(company_gstin):
249250
frappe.has_permission("GST Invoice Management System", "write", throw=True)
250251

252+
job_id = f"gst_ims:{company_gstin}"
253+
254+
if is_job_enqueued(job_id):
255+
return {
256+
"message": _(
257+
"A download job is already in progress for the GSTIN - {0}"
258+
).format(company_gstin),
259+
}
260+
251261
TaxpayerBaseAPI(company_gstin).validate_auth_token()
252262

253-
frappe.enqueue(download_ims_invoices, queue="long", gstin=company_gstin)
263+
frappe.enqueue(
264+
download_ims_invoices,
265+
queue="long",
266+
gstin=company_gstin,
267+
job_id=job_id,
268+
deduplicate=True,
269+
)
254270

255271

256272
@frappe.whitelist()

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: 12 additions & 0 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
)
@@ -133,6 +134,15 @@ def download_gstr(
133134
):
134135
frappe.has_permission("Purchase Reconciliation Tool", "write", throw=True)
135136

137+
job_id = f"purchase_reconciliation_tool:{company_gstin}:{return_type}"
138+
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),
144+
}
145+
136146
TaxpayerBaseAPI(company_gstin).validate_auth_token()
137147

138148
frappe.enqueue(
@@ -144,8 +154,10 @@ def download_gstr(
144154
force=force,
145155
gst_categories=gst_categories,
146156
queue="long",
157+
job_id=job_id,
147158
now=frappe.flags.in_test,
148159
timeout=1800,
160+
deduplicate=True,
149161
)
150162

151163
@frappe.whitelist()

0 commit comments

Comments
 (0)