diff --git a/india_compliance/gst_india/api_classes/taxpayer_returns.py b/india_compliance/gst_india/api_classes/taxpayer_returns.py index fb0df061bb..064414e351 100644 --- a/india_compliance/gst_india/api_classes/taxpayer_returns.py +++ b/india_compliance/gst_india/api_classes/taxpayer_returns.py @@ -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, @@ -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, diff --git a/india_compliance/gst_india/doctype/gst_return_log/generate_gstr_1.py b/india_compliance/gst_india/doctype/gst_return_log/generate_gstr_1.py index e62a22490c..fd98d09852 100644 --- a/india_compliance/gst_india/doctype/gst_return_log/generate_gstr_1.py +++ b/india_compliance/gst_india/doctype/gst_return_log/generate_gstr_1.py @@ -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 @@ -747,7 +747,7 @@ 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 @@ -755,8 +755,14 @@ def upload_gstr1(self, json_data, 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"}) @@ -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": @@ -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) @@ -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) diff --git a/india_compliance/gst_india/doctype/gstr_1_beta/gstr_1_beta.js b/india_compliance/gst_india/doctype/gstr_1_beta/gstr_1_beta.js index 272e0ddc00..6e5be4335a 100644 --- a/india_compliance/gst_india/doctype/gstr_1_beta/gstr_1_beta.js +++ b/india_compliance/gst_india/doctype/gstr_1_beta/gstr_1_beta.js @@ -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 @@ -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() { @@ -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(); }, }); } diff --git a/india_compliance/gst_india/doctype/gstr_1_beta/gstr_1_beta.json b/india_compliance/gst_india/doctype/gstr_1_beta/gstr_1_beta.json index ee26f09558..3aec4f6c73 100644 --- a/india_compliance/gst_india/doctype/gstr_1_beta/gstr_1_beta.json +++ b/india_compliance/gst_india/doctype/gstr_1_beta/gstr_1_beta.json @@ -7,6 +7,7 @@ "field_order": [ "form", "company", + "file_nil_gstr1", "column_break_ejve", "company_gstin", "column_break_ldkv", @@ -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",