Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: GSTR-1 Automation enhancements #2686

Open
wants to merge 1 commit into
base: gstr-1-automation
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -682,10 +682,10 @@ def normalize_data(data):


class FileGSTR1:
def reset_gstr1(self):
# reset called after proceed to file
verify_request_in_progress(self)
def reset_gstr1(self, force):
verify_request_in_progress(self, force)

# reset called after proceed to file
self.db_set({"filing_status": "Not Filed"})

api = GSTR1API(self)
Expand Down Expand Up @@ -721,11 +721,11 @@ def process_reset_gstr1(self):

return response

def upload_gstr1(self, json_data):
def upload_gstr1(self, json_data, force):
if not json_data:
return

verify_request_in_progress(self)
verify_request_in_progress(self, force)

keys = {category.value for category in GovJsonKey}
if all(key not in json_data for key in keys):
Expand Down Expand Up @@ -782,8 +782,8 @@ def process_upload_gstr1(self):

return response

def proceed_to_file_gstr1(self):
verify_request_in_progress(self)
def proceed_to_file_gstr1(self, force):
verify_request_in_progress(self, force)

api = GSTR1API(self)
response = api.proceed_to_file("GSTR1", self.return_period)
Expand Down Expand Up @@ -854,8 +854,8 @@ def fetch_and_compare_summary(self, api, response=None):

return response

def file_gstr1(self, pan, otp):
verify_request_in_progress(self)
def file_gstr1(self, pan, otp, force):
verify_request_in_progress(self, force)

summary = self.get_json_for("authenticated_summary")
api = GSTR1API(self)
Expand All @@ -879,8 +879,6 @@ def file_gstr1(self, pan, otp):

self.remove_json_for("upload_error")

# TODO: 2nd phase Accounting Entry.

return response

def get_amendment_data(self):
Expand Down Expand Up @@ -915,7 +913,10 @@ def get_amendment_data(self):
}


def verify_request_in_progress(return_log):
def verify_request_in_progress(return_log, force):
if force == "true":
return

for row in return_log.actions:
if not row.status:
frappe.throw(
Expand Down
47 changes: 34 additions & 13 deletions india_compliance/gst_india/doctype/gstr_1_beta/gstr_1_beta.js
Original file line number Diff line number Diff line change
Expand Up @@ -2224,8 +2224,8 @@ class FileGSTR1Dialog {
this.filing_dialog = null;
}

file_gstr1_data() {
if (this.is_request_in_progress()) return;
async file_gstr1_data() {
if (await this.is_request_in_progress()) return;

// TODO: EVC Generation, Resend, and Filing
this.filing_dialog = new frappe.ui.Dialog({
Expand Down Expand Up @@ -2465,8 +2465,8 @@ class GSTR1Action extends FileGSTR1Dialog {
});
}

upload_gstr1_data() {
if (this.is_request_in_progress()) return;
async upload_gstr1_data() {
if (await this.is_request_in_progress()) return;

const action = "upload";

Expand All @@ -2480,8 +2480,8 @@ class GSTR1Action extends FileGSTR1Dialog {
});
}

reset_gstr1_data() {
if (this.is_request_in_progress()) return;
async reset_gstr1_data() {
if (await this.is_request_in_progress()) return;

const action = "reset";

Expand All @@ -2507,8 +2507,8 @@ class GSTR1Action extends FileGSTR1Dialog {
});
}

previous_action_handler() {
if (this.is_request_in_progress()) return;
async previous_action_handler() {
if (await this.is_request_in_progress()) return;

const { company, company_gstin, month_or_quarter, year } = this.frm.doc;
const filters = {
Expand Down Expand Up @@ -2559,6 +2559,7 @@ class GSTR1Action extends FileGSTR1Dialog {
...this.defaults,
...additional_args,
action: `${action}_gstr1`,
force: this.frm.force_action ? this.frm.force_action : false,
};

taxpayer_api.call({
Expand Down Expand Up @@ -2695,15 +2696,35 @@ class GSTR1Action extends FileGSTR1Dialog {

is_request_in_progress() {
let in_progress = this.frm.__action_performed;

if (!in_progress) return false;
else if (in_progress == "proceed_to_file") in_progress = "upload";

frappe.show_alert({
message: __('Already ' + in_progress + 'ing'),
indicator: "red",
const in_progress_action = in_progress.charAt(0).toUpperCase() + in_progress.slice(1)

return new Promise((resolve) => {
const d = frappe.msgprint({
message: __(`<b>${in_progress_action} is in progress. Do you still want to continue?<b>`),
indicator: "red",
title: __("Process in Progress"),
primary_action: {
label: __("Yes"),
action: () => {
this.toggle_actions(true, in_progress);
this.frm.force_action = true;
resolve(false);
d.hide();
},
},
secondary_action: {
label: __("No"),
action: () => {
resolve(true)
d.hide();
},
}
});
});

return true;
}

toggle_actions(show, action) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def on_generate(self, filters=None):
@frappe.whitelist()
@otp_handler
def handle_gstr1_action(action, month_or_quarter, year, company_gstin, **kwargs):
frappe.has_permission("GSTR-1 Beta", "write", throw=True)
frappe.has_permission("GST Return Log", "write", throw=True)

gstr_1_log = frappe.get_doc(
"GST Return Log",
Expand All @@ -197,6 +197,8 @@ def handle_gstr1_action(action, month_or_quarter, year, company_gstin, **kwargs)
@frappe.whitelist()
@otp_handler
def process_gstr1_request(month_or_quarter, year, company_gstin, action):
frappe.has_permission("GST Return Log", "write", throw=True)

gstr_1_log = frappe.get_doc(
"GST Return Log",
f"GSTR1-{get_period(month_or_quarter, year)}-{company_gstin}",
Expand Down
Loading