Skip to content

Commit

Permalink
fix: field to check if redownload is useful
Browse files Browse the repository at this point in the history
  • Loading branch information
vorasmit committed Nov 29, 2024
1 parent c9c82b2 commit e1b0107
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"return_period",
"last_updated_on",
"data_not_found",
"dont_redownload",
"request_id",
"request_time"
],
Expand Down Expand Up @@ -64,11 +65,17 @@
"fieldtype": "Datetime",
"hidden": 1,
"label": "Request Time"
},
{
"default": "0",
"fieldname": "dont_redownload",
"fieldtype": "Check",
"label": "Redownload not Required"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-03-29 11:54:43.449587",
"modified": "2024-11-29 15:06:33.113355",
"modified_by": "Administrator",
"module": "GST India",
"name": "GSTR Import Log",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,9 @@ def download_gstr(
return_type = ReturnType(return_type)

periods = BaseUtil.get_periods(date_range, return_type)
if not force:
periods = get_periods_to_download(company_gstin, return_type, periods)
periods = get_periods_to_download(
company_gstin, return_type, periods, download_all=not force
)

if not periods:
return
Expand All @@ -467,12 +468,23 @@ def download_gstr(
return download_gstr_2b(company_gstin, periods)


def get_periods_to_download(company_gstin, return_type, periods):
def get_periods_to_download(company_gstin, return_type, periods, download_all=False):
# check if redownload is useful
dont_redownload = get_import_history(
company_gstin, return_type, periods, fields=("return_period", "dont_redownload")
)
dont_redownload = [
log.return_period for log in dont_redownload if log.dont_redownload
]

periods = [period for period in periods if period not in dont_redownload]

if download_all:
return periods

# get missing periods
existing_periods = get_import_history(
company_gstin,
return_type,
periods,
pluck="return_period",
company_gstin, return_type, periods, pluck="return_period"
)

return [period for period in periods if period not in existing_periods]
Expand Down

0 comments on commit e1b0107

Please sign in to comment.