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

feat: allow filing of Nil return for GSTR-1 #2906

Merged
merged 14 commits into from
Jan 11, 2025
Merged
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
18 changes: 10 additions & 8 deletions india_compliance/gst_india/api_classes/taxpayer_returns.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,19 @@ 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_return, otp=None):
data = {
"gstin": self.company_gstin,
"ret_period": return_period,
}

if is_nil_return:
data["isnil"] = "Y"

return self.post(
return_type=return_type,
return_period=return_period,
json={
"action": "RETNEWPTF",
"data": {
"gstin": self.company_gstin,
"ret_period": return_period,
}, # "isnil": "N" / "Y"
},
json={"action": "RETNEWPTF", "data": data},
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 flt, sbool

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 @@ -832,14 +832,23 @@ def process_upload_gstr1(self):

return response

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

is_nil_return = sbool(is_nil_return)

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

# Return Form already ready to be filed
if response.error and response.error.error_cd == "RET00003":
if response.error and response.error.error_cd == "RET00003" or is_nil_return:
set_gstr1_actions(
self,
"proceed_to_file",
response.get("reference_id"),
api.request_id,
status="Processed",
)
return self.fetch_and_compare_summary(api)

set_gstr1_actions(
Expand Down Expand Up @@ -872,13 +881,15 @@ def fetch_and_compare_summary(self, api, response=None):
response = {}

summary = api.get_gstr_1_data("RETSUM", self.return_period)
self.db_set("is_nil", summary.isnil == "Y")

if summary.error:
return

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 Expand Up @@ -940,7 +951,7 @@ def file_gstr1(self, pan, otp, force):
def get_amendment_data(self):
authenticated_summary = convert_to_internal_data_format(
self.get_json_for("authenticated_summary")
).get("summary")
).get("summary", {})
authenticated_summary = summarize_retsum_data(authenticated_summary.values())

non_amended_entries = {
Expand Down
67 changes: 56 additions & 11 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 @@ -170,8 +170,12 @@ frappe.ui.form.on(DOCTYPE, {
const only_books_data = error_log != undefined;
if (error_log) {
frappe.msgprint({
message: __("Error while preparing GSTR-1 data, please check {0} for more deatils.",
[`<a href='/app/error-log/${error_log}' class='variant-click'>error log</a>`]),
message: __(
"Error while preparing GSTR-1 data, please check {0} for more deatils.",
[
`<a href='/app/error-log/${error_log}' class='variant-click'>error log</a>`,
]
),
title: "GSTR-1 Download Failed",
indicator: "red",
});
Expand All @@ -195,6 +199,10 @@ frappe.ui.form.on(DOCTYPE, {

company_gstin: render_empty_state,

file_nil_gstr1(frm) {
frm.gstr1.render_form_actions();
},

month_or_quarter(frm) {
render_empty_state(frm);
},
Expand All @@ -221,6 +229,8 @@ frappe.ui.form.on(DOCTYPE, {
const data = frm.doc.__gst_data;
if (!data?.status) return;

frm.doc.file_nil_gstr1 = data.is_nil

// Toggle HTML fields
frm.refresh();

Expand Down Expand Up @@ -300,6 +310,7 @@ class GSTR1 {
}

this.set_output_gst_balances();
this.toggle_file_nil_gstr1();

// refresh tabs
this.TABS.forEach(_tab => {
Expand Down Expand Up @@ -356,6 +367,10 @@ class GSTR1 {
});
}

refresh_no_data_message() {
this.tabs.filed_tab.tabmanager.refresh_no_data_message();
}

// RENDER

render() {
Expand Down Expand Up @@ -477,14 +492,20 @@ class GSTR1 {
File: this.gstr1_action.file_gstr1_data,
};

// No need to upload if nil gstr1
const status =
this.frm.doc.file_nil_gstr1 && this.status == "Not Filed"
? "Uploaded"
: this.status;

let primary_button_label =
{
"Not Filed": "Upload",
Uploaded: "Proceed to File",
"Ready to File": "File",
}[this.status] || "Generate";
}[status] || "Generate";

if (this.status === "Ready to File") {
if (status === "Ready to File") {
this.frm.add_custom_button(__("Mark as Unfiled"), () => {
this.gstr1_action.mark_as_unfiled();
});
Expand Down Expand Up @@ -687,6 +708,16 @@ class GSTR1 {
else this.$wrapper.find(".filter-selector").hide();
}

toggle_file_nil_gstr1() {
if (!this.data || !is_gstr1_api_enabled()) return;

const has_records = this.data.books_summary?.some(row => row.no_of_records > 0);

if (!has_records && this.data.status != "Filed")
this.frm.set_df_property("file_nil_gstr1", "hidden", 0);
else this.frm.set_df_property("file_nil_gstr1", "hidden", 1);
}

async set_output_gst_balances() {
//Checks if gst-ledger-difference element is there and removes if already present
const gst_liability = await get_net_gst_liability(this.frm);
Expand Down Expand Up @@ -743,7 +774,7 @@ class GSTR1 {
args: { month_or_quarter, year, company },
});

if (!je_details || !je_details.data) return;
if (!je_details) return;

this.create_journal_entry_dialog(je_details);
}
Expand Down Expand Up @@ -878,6 +909,10 @@ class TabManager {
this.set_creation_time_string();
}

refresh_no_data_message() {
this.datatable.refresh(null, null, this.get_no_data_message());
}

refresh_view(view, category, filters) {
if (!category && view === "Detailed") return;

Expand Down Expand Up @@ -2114,7 +2149,10 @@ class FiledTab extends GSTR1_TabManager {

get_no_data_message() {
if (this.instance.data?.is_nil)
return __("You have filed a Nil GSTR-1 for this period");
if (this.status === "Filed")
return __("You have filed a Nil GSTR-1 for this period");
else
return __("You are filing a Nil GSTR-1 for this period");

return this.DEFAULT_NO_DATA_MESSAGE;
}
Expand Down Expand Up @@ -2645,11 +2683,18 @@ class GSTR1Action extends FileGSTR1Dialog {

proceed_to_file() {
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);
else this.check_action_status_with_retry(action);
});
this.frm.gstr1.data.is_nil = this.frm.doc.file_nil_gstr1;
this.frm.gstr1.refresh_no_data_message();

this.perform_gstr1_action(
action,
r => {
// already proceed to file
if (r.message) this.handle_proceed_to_file_response(r.message);
else this.check_action_status_with_retry(action);
},
{ is_nil_return: this.frm.doc.file_nil_gstr1 }
);
}

async mark_as_unfiled() {
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
3 changes: 3 additions & 0 deletions india_compliance/gst_india/doctype/gstr_1_beta/gstr_1_beta.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ def get_journal_entries(month_or_quarter, year, company):
.run(as_dict=True)
)

if not data:
return

return {"data": data, "posting_date": to_date}


Expand Down
3 changes: 1 addition & 2 deletions india_compliance/gst_india/utils/gstr_1/gstr_1_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ def download_gstr1_json_data(gstr1_log):

json_data.update(response)

if json_data.isnil == "Y":
gstr1_log.db_set("is_nil", 1)
gstr1_log.db_set("is_nil", json_data.isnil == "Y")

mapped_data = convert_to_internal_data_format(json_data)
gstr1_log.update_json_for(data_field, mapped_data, reset_reconcile=True)
Expand Down
Loading