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 19ca6da62..1f187a30c 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 @@ -645,7 +645,7 @@ def get_books_gstr1_data(self, filters, aggregate=False): return books_data from_date, to_date = get_gstr_1_from_and_to_date( - filters.month_or_quarter, filters.year, filters.is_quarterly + filters.month_or_quarter, filters.year ) _filters = frappe._dict( diff --git a/india_compliance/gst_india/doctype/gstr_1_beta/gstr_1_beta.py b/india_compliance/gst_india/doctype/gstr_1_beta/gstr_1_beta.py index 34c7f6df6..ff56ba212 100644 --- a/india_compliance/gst_india/doctype/gstr_1_beta/gstr_1_beta.py +++ b/india_compliance/gst_india/doctype/gstr_1_beta/gstr_1_beta.py @@ -329,9 +329,7 @@ def get_net_gst_liability(company, company_gstin, month_or_quarter, year, is_qua frappe.has_permission("GSTR-1 Beta", throw=True) - from_date, to_date = get_gstr_1_from_and_to_date( - month_or_quarter, year, is_quarterly - ) + from_date, to_date = get_gstr_1_from_and_to_date(month_or_quarter, year) filters = frappe._dict( { @@ -387,25 +385,17 @@ def get_period(month_or_quarter: str, year: str) -> str: return f"{month_number}{year}" -def get_gstr_1_from_and_to_date( - month_or_quarter: str, year: str, is_quarterly: str -) -> tuple: +def get_gstr_1_from_and_to_date(month_or_quarter: str, year: str) -> tuple: """ Returns the from and to date for the given month or quarter and year This is used to filter the data for the given period in Books """ - if is_quarterly == "Quarterly": - month_index = MONTH.index(month_or_quarter) + start_month = end_month = MONTH.index(month_or_quarter) + 1 + if start_month % 3 == 0: + start_month -= 2 - start_month = month_index // 3 * 3 + 1 - end_month = start_month + 2 - - from_date = getdate(f"{year}-{start_month}-01") - to_date = get_last_day(f"{year}-{end_month}-01") - else: - # Monthly (default) - from_date = getdate(f"{year}-{month_or_quarter}-01") - to_date = get_last_day(from_date) + from_date = getdate(f"{year}-{start_month}-01") + to_date = get_last_day(f"{year}-{end_month}-01") return from_date, to_date diff --git a/india_compliance/patches/v15/update_return_logs_with_filing_preference.py b/india_compliance/patches/v15/update_return_logs_with_filing_preference.py index 33f0cfdbd..166ad5e44 100644 --- a/india_compliance/patches/v15/update_return_logs_with_filing_preference.py +++ b/india_compliance/patches/v15/update_return_logs_with_filing_preference.py @@ -10,6 +10,7 @@ def patch_filing_preference(gstin): "filing_preference": ["is", "not set"], "gstin": gstin, "return_period": ["!=", "ALL"], + "return_type": "GSTR1", }, fields=["name", "return_period", "gstin"], )