Skip to content

Commit

Permalink
fix: add description and remove progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanket322 committed May 22, 2024
1 parent 9c3341c commit 1afb698
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ const ReturnType = {
GSTR2B: "GSTR2b",
};

let last_year = frappe.datetime.add_months(frappe.datetime.get_today(),-12)
let fiscal_year = erpnext.utils.get_fiscal_year(last_year, true)
let fiscal_start = frappe.datetime.str_to_user(fiscal_year[1], null, frappe.datetime.get_user_date_fmt())
let fiscal_end = frappe.datetime.str_to_user(fiscal_year[2], null, frappe.datetime.get_user_date_fmt())


function remove_gstr2b_alert(alert) {
if (alert.length === 0) return;
$(alert).remove();
Expand Down Expand Up @@ -143,9 +149,14 @@ frappe.ui.form.on("Purchase Reconciliation Tool", {

purchase_period(frm) {
fetch_date_range(frm, "purchase");
let description = frm.doc.purchase_period == "Last Fiscal Year" ? fiscal_start +' to '+ fiscal_end : ""
frm.get_field("purchase_period").set_description(description);
},

async inward_supply_period(frm) {
let description = frm.doc.inward_supply_period == "Last Fiscal Year" ? fiscal_start +' to '+ fiscal_end : ""
frm.get_field("inward_supply_period").set_description(description);

await fetch_date_range(
frm,
"inward_supply",
Expand Down
25 changes: 25 additions & 0 deletions india_compliance/gst_india/utils/gstr_2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def download_gstr_2a(gstin, return_periods, otp=None, gst_categories=None):
total_expected_requests = len(return_periods) * len(ACTIONS)
requests_made = 0
queued_message = False
flag = True
settings = frappe.get_cached_doc("GST Settings")

return_type = ReturnType.GSTR2A
Expand Down Expand Up @@ -121,15 +122,21 @@ def download_gstr_2a(gstin, return_periods, otp=None, gst_categories=None):
json_data[action.lower()] = data

save_gstr_2a(gstin, return_period, json_data)
if return_period == return_periods[-1]:
flag = False

if queued_message:
show_queued_message()

if flag:
end_transaction_progress(return_periods[-1])


def download_gstr_2b(gstin, return_periods, otp=None):
total_expected_requests = len(return_periods)
requests_made = 0
queued_message = False
flag = True

api = GSTR2bAPI(gstin)
for return_period in return_periods:
Expand Down Expand Up @@ -179,10 +186,28 @@ def download_gstr_2b(gstin, return_periods, otp=None):
continue # skip first response if file_count is greater than 1

save_gstr_2b(gstin, return_period, response)
if return_period == return_periods[-1]:
flag = False

if queued_message:
show_queued_message()

if flag:
end_transaction_progress(return_periods[-1])


def end_transaction_progress(return_period):
frappe.publish_realtime(
"update_transactions_progress",
{
"current_progress": 100,
"return_period": return_period,
"is_last_period": True,
},
user=frappe.session.user,
doctype="Purchase Reconciliation Tool",
)


def save_gstr_2a(gstin, return_period, json_data):
return_type = ReturnType.GSTR2A
Expand Down

0 comments on commit 1afb698

Please sign in to comment.