Simplify the onboardinf flow components 3
This commit is contained in:
@@ -161,20 +161,12 @@ class DateAlignmentService:
|
||||
Data for current month is not available until the following month.
|
||||
"""
|
||||
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
|
||||
last_available_month = now.replace(day=1) - timedelta(days=1)
|
||||
|
||||
# Return the last day of the last available 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)
|
||||
# Data up to the previous month is available
|
||||
# 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 next_month - timedelta(days=1)
|
||||
return last_day_of_previous_month
|
||||
|
||||
def _validate_final_range(self, aligned_range: AlignedDateRange) -> None:
|
||||
"""Validate the final aligned date range."""
|
||||
|
||||
Reference in New Issue
Block a user