Simplify the onboardinf flow components 3

This commit is contained in:
Urtzi Alfaro
2025-09-08 21:52:56 +02:00
parent c8b1a941f8
commit a8f6e9d593

View File

@@ -161,20 +161,12 @@ class DateAlignmentService:
Data for current month is not available until the following month. Data for current month is not available until the following month.
""" """
now = datetime.now(timezone.utc) now = datetime.now(timezone.utc)
if now.day == 1:
# If it's the first day of the month, data up to previous month should be available
last_available_month = now.replace(day=1) - timedelta(days=1)
else:
# Data up to the previous month is available # Data up to the previous month is available
last_available_month = now.replace(day=1) - timedelta(days=1) # Go to first day of current month, then subtract 1 day to get last day of previous month
last_day_of_previous_month = now.replace(day=1, hour=0, minute=0, second=0, microsecond=0) - timedelta(days=1)
# Return the last day of the last available month return last_day_of_previous_month
if last_available_month.month == 12:
next_month = last_available_month.replace(year=last_available_month.year + 1, month=1)
else:
next_month = last_available_month.replace(month=last_available_month.month + 1)
return next_month - timedelta(days=1)
def _validate_final_range(self, aligned_range: AlignedDateRange) -> None: def _validate_final_range(self, aligned_range: AlignedDateRange) -> None:
"""Validate the final aligned date range.""" """Validate the final aligned date range."""