fix: default missing period.default_to to today
This commit is contained in:
@@ -370,8 +370,10 @@ class Config:
|
||||
def get_default_date_range(cls) -> str:
|
||||
from_env = os.getenv("DEFAULT_FROM_DATE", "").strip()
|
||||
to_env = os.getenv("DEFAULT_TO_DATE", "").strip()
|
||||
if from_env and to_env:
|
||||
return f"{from_env}--{to_env}"
|
||||
today_str = date.today().isoformat()
|
||||
|
||||
if from_env:
|
||||
return f"{from_env}--{to_env or today_str}"
|
||||
|
||||
if (
|
||||
cls._app
|
||||
@@ -386,17 +388,12 @@ class Config:
|
||||
)
|
||||
return f"{nf}--{nt}"
|
||||
|
||||
if cls._app and cls._app.period_default_from and cls._app.period_default_to:
|
||||
return f"{cls._app.period_default_from}--{cls._app.period_default_to}"
|
||||
if cls._app and cls._app.period_default_from:
|
||||
default_to = cls._app.period_default_to or today_str
|
||||
return f"{cls._app.period_default_from}--{default_to}"
|
||||
|
||||
today = date.today()
|
||||
start = today.replace(day=1)
|
||||
if today.month == 12:
|
||||
next_month = today.replace(year=today.year + 1, month=1, day=1)
|
||||
else:
|
||||
next_month = today.replace(month=today.month + 1, day=1)
|
||||
end = next_month - timedelta(days=1)
|
||||
return f"{start.isoformat()}--{end.isoformat()}"
|
||||
start = date.today().replace(day=1)
|
||||
return f"{start.isoformat()}--{today_str}"
|
||||
|
||||
@classmethod
|
||||
def validate(cls) -> None:
|
||||
|
||||
Reference in New Issue
Block a user