From 1dc965c78a72b4bcd323a2605a4db822d7a35ac3 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Wed, 9 Apr 2025 20:37:49 +0200 Subject: [PATCH] bugfixing --- app/utils/helper.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/app/utils/helper.py b/app/utils/helper.py index 715b8cc..30e140a 100644 --- a/app/utils/helper.py +++ b/app/utils/helper.py @@ -79,7 +79,7 @@ def load_latest_json(directory: str, find=True): print(f"Error loading JSON file: {e}") return [] - +''' def get_last_completed_quarter(): today = datetime.today() year = today.year @@ -92,4 +92,20 @@ def get_last_completed_quarter(): if current_quarter == 1: return 4, year - 1 else: - return current_quarter - 1, year \ No newline at end of file + return current_quarter - 1, year +''' + +def get_last_completed_quarter(): + today = datetime.today() + year = today.year + month = today.month + # Calculate the current quarter (1 to 4) + current_quarter = (month - 1) // 3 + 1 + + # Determine the quarter that is two quarters ago. + target_quarter = current_quarter - 2 + if target_quarter < 1: + target_quarter += 4 + year -= 1 + + return target_quarter, year \ No newline at end of file