Skip to content

Commit ddda861

Browse files
karm1000mergify[bot]
authored andcommitted
fix(purchase-reco): give job_id argument to frappe.enqueue
(cherry picked from commit c7135ae)
1 parent 8100fe1 commit ddda861

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

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
@@ -53,6 +53,7 @@
5353
save_gstr_2a,
5454
save_gstr_2b,
5555
)
56+
from india_compliance.utils import get_hash
5657

5758
STATUS_MAP = {
5859
"Accept": "Reconciled",
@@ -135,6 +136,16 @@ def download_gstr(
135136

136137
TaxpayerBaseAPI(company_gstin).validate_auth_token()
137138

139+
job_id = get_hash(
140+
{
141+
"company_gstin": company_gstin,
142+
"date_range": date_range,
143+
"return_type": return_type,
144+
"return_period": return_period,
145+
"gst_categories": gst_categories,
146+
}
147+
)
148+
138149
frappe.enqueue(
139150
download_gstr,
140151
company_gstin=company_gstin,
@@ -144,6 +155,7 @@ def download_gstr(
144155
force=force,
145156
gst_categories=gst_categories,
146157
queue="long",
158+
job_id=job_id,
147159
now=frappe.flags.in_test,
148160
timeout=1800,
149161
)

india_compliance/utils/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import hashlib
2+
import json
3+
4+
5+
def get_hash(data: list | dict | str) -> str:
6+
if isinstance(data, dict | list):
7+
data = json.dumps(data, sort_keys=True)
8+
9+
if isinstance(data, str):
10+
data = data.encode()
11+
12+
return hashlib.sha256(data).hexdigest()

0 commit comments

Comments
 (0)