Skip to content

Commit

Permalink
feat: allow filing of Nil return for GSTR-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanket322 committed Dec 26, 2024
1 parent 5f227b2 commit 08c7591
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 15 deletions.
5 changes: 3 additions & 2 deletions india_compliance/gst_india/api_classes/taxpayer_returns.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_return_status(self, return_period, reference_id, otp=None):
otp=otp,
)

def proceed_to_file(self, return_type, return_period, otp=None):
def proceed_to_file(self, return_type, return_period, is_nil_rated, otp=None):
return self.post(
return_type=return_type,
return_period=return_period,
Expand All @@ -46,7 +46,8 @@ def proceed_to_file(self, return_type, return_period, otp=None):
"data": {
"gstin": self.company_gstin,
"ret_period": return_period,
}, # "isnil": "N" / "Y"
"isnil": "Y" if is_nil_rated else "N",
},
},
endpoint="returns/gstrptf",
otp=otp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import frappe
from frappe import _, unscrub
from frappe.utils import flt
from frappe.utils import cint, flt

from india_compliance.gst_india.api_classes.taxpayer_returns import GSTR1API
from india_compliance.gst_india.utils.gstr_1 import GovJsonKey, GSTR1_SubCategory
Expand Down Expand Up @@ -747,16 +747,22 @@ def process_reset_gstr1(self):

return response

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

verify_request_in_progress(self, force)

keys = {category.value for category in GovJsonKey}
if all(key not in json_data for key in keys):
frappe.msgprint(_("No data to upload"), indicator="red")
return
if not cint(is_nil_rated):
frappe.msgprint(
_("No data to upload. To file Nil Return, mark the checkbox."),
indicator="red",
)
return

return "upload nil return gstr1"

# upload data after proceed to file
self.db_set({"filing_status": "Not Filed"})
Expand Down Expand Up @@ -812,11 +818,11 @@ def process_upload_gstr1(self):

return response

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

api = GSTR1API(self)
response = api.proceed_to_file("GSTR1", self.return_period)
response = api.proceed_to_file("GSTR1", self.return_period, is_nil_rated)

# Return Form already ready to be filed
if response.error and response.error.error_cd == "RET00003":
Expand All @@ -843,6 +849,10 @@ def process_proceed_to_file_gstr1(self):
if response.get("status_cd") == "IP":
return response

if response.error and response.error.error_cd == "RET13510":
# here it is giving status code as 0
response.status_cd = "P"

doc.db_set({"status": status_code_map.get(response.get("status_cd"))})

return self.fetch_and_compare_summary(api, response)
Expand All @@ -858,7 +868,7 @@ def fetch_and_compare_summary(self, api, response=None):
self.update_json_for("authenticated_summary", summary)

mapped_summary = self.get_json_for("books_summary")
gov_summary = convert_to_internal_data_format(summary).get("summary")
gov_summary = convert_to_internal_data_format(summary).get("summary", {})
gov_summary = summarize_retsum_data(gov_summary.values())

differing_categories = get_differing_categories(mapped_summary, gov_summary)
Expand Down
33 changes: 28 additions & 5 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 @@ -2570,24 +2570,39 @@ class GSTR1Action extends FileGSTR1Dialog {
r.message.pending_actions.forEach(request_type =>
this.check_action_status_with_retry(request_type, 0, true)
);

this.check_for_nil_rated();
});
}

check_for_nil_rated() {
const data = this.frm.doc.__gst_data;
if (Object.keys(data.unfiled).length == 1 && data.status == "Not Filed") {
this.frm.set_df_property("file_nil_gstr1", "hidden", 0)
}
}

async upload_gstr1_data() {
const action = "upload";
if (await this.is_request_in_progress(action)) return;

const upload = () => {
frappe.show_alert(__("Uploading data to GSTN"));
this.perform_gstr1_action(action, response => {
// No data to upload
if (response._server_messages && response._server_messages.length) {
if(response._server_messages){
this.toggle_actions(true);
return;
}
if (response.message == "upload nil reated gstr1"){
frappe.show_alert(__("Proceeding to file Nil Rated GSTR-1"));
this.proceed_to_file();
return;
}

frappe.show_alert(__("Uploading data to GSTN"));
this.check_action_status_with_retry(action);
});
},
{ is_nil_rated : this.frm.doc.file_nil_gstr1 });
};

// has draft invoices
Expand Down Expand Up @@ -2625,9 +2640,15 @@ class GSTR1Action extends FileGSTR1Dialog {
const action = "proceed_to_file";
this.perform_gstr1_action(action, r => {
// already proceed to file
if (r.message) this.handle_proceed_to_file_response(r.message);
if (r.message){
this.toggle_actions(true);
this.handle_proceed_to_file_response(r.message);
this.check_for_nil_rated();
}
else this.check_action_status_with_retry(action);
});
// TODO: this.check_for_nil_rated should also go after else condition
},
{ is_nil_rated : this.frm.doc.file_nil_gstr1 });
}

async mark_as_unfiled() {
Expand All @@ -2646,8 +2667,10 @@ class GSTR1Action extends FileGSTR1Dialog {
args: { filters: filters, force: this.frm.__action_performed == undefined },
callback: () => {
this.frm.gstr1.status = "Not Filed";
this.frm.doc.__gst_data.status = "Not Filed";
this.frm.refresh();
this.frm.gstr1.refresh_data();
this.check_for_nil_rated();
},
});
}
Expand Down
10 changes: 9 additions & 1 deletion india_compliance/gst_india/doctype/gstr_1_beta/gstr_1_beta.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"field_order": [
"form",
"company",
"file_nil_gstr1",
"column_break_ejve",
"company_gstin",
"column_break_ldkv",
Expand Down Expand Up @@ -81,13 +82,20 @@
"fieldtype": "Select",
"label": "Month/Quarter",
"reqd": 1
},
{
"default": "0",
"fieldname": "file_nil_gstr1",
"fieldtype": "Check",
"hidden": 1,
"label": "File Nil GSTR-1"
}
],
"hide_toolbar": 1,
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2024-05-27 19:30:01.074149",
"modified": "2024-12-26 12:43:21.979607",
"modified_by": "Administrator",
"module": "GST India",
"name": "GSTR-1 Beta",
Expand Down

0 comments on commit 08c7591

Please sign in to comment.