From b4625d6222d14aca372d6bd2957f9ef23160f4e0 Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Mon, 4 Nov 2024 11:52:25 +0530 Subject: [PATCH] fix: cache filing preference and add function outline --- india_compliance/gst_india/api_classes/taxpayer_base.py | 3 ++- .../gst_india/doctype/gst_return_log/generate_gstr_1.py | 1 + india_compliance/gst_india/utils/gstin_info.py | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/india_compliance/gst_india/api_classes/taxpayer_base.py b/india_compliance/gst_india/api_classes/taxpayer_base.py index e000ab4d3..253306318 100644 --- a/india_compliance/gst_india/api_classes/taxpayer_base.py +++ b/india_compliance/gst_india/api_classes/taxpayer_base.py @@ -7,7 +7,7 @@ import frappe import frappe.utils -from frappe import _ +from frappe import _, request_cache from frappe.utils import add_to_date, cint, now_datetime from india_compliance.exceptions import ( @@ -465,6 +465,7 @@ def validate_auth_token(self): return + @request_cache def get_filing_preference(self, date=None): return self.get( action="GETPREF", params={"fy": self.get_fy(date)}, endpoint="returns" 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 ca211f797..85744ef3e 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 @@ -503,6 +503,7 @@ def generate_gstr1_data(self, filters, callback=None): # APIs Enabled status = self.get_return_status() + # filing_frequency = self.get_filing_frequency() & update this in filters if status == "Filed": gov_data_field = "filed" diff --git a/india_compliance/gst_india/utils/gstin_info.py b/india_compliance/gst_india/utils/gstin_info.py index 01e02611d..855e940d9 100644 --- a/india_compliance/gst_india/utils/gstin_info.py +++ b/india_compliance/gst_india/utils/gstin_info.py @@ -335,6 +335,14 @@ def get_gstr_1_return_status( return "Not Filed" +def get_filing_frequency(gstin, period): + # is not Q1-M1 ? => fetch if available from Q1-M1 + # if not, is it filed for the period or date has surpassed? => if not, then don't fetch and return nothing + + # if filed, then fetch from the filed data + pass + + def get_fy(period, year_increment=0): month, year = period[:2], period[2:] year = str(int(year) + year_increment)