diff --git a/VERSION b/VERSION index 67067fa..cde317c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.3.137 \ No newline at end of file +1.3.138 \ No newline at end of file diff --git a/app/services/economic_service.py b/app/services/economic_service.py index 07c097b..09ece98 100644 --- a/app/services/economic_service.py +++ b/app/services/economic_service.py @@ -451,17 +451,9 @@ class EconomicService: """ try: # Calculate first day of the month 13 months ago (for yearly billed items) + from dateutil.relativedelta import relativedelta now = datetime.now() - # Go back 13 months - months_back = 13 - if now.month > months_back: - start_month = now.month - months_back - start_year = now.year - else: - start_month = 12 - (months_back - now.month) - start_year = now.year - 1 - - start_date = datetime(start_year, start_month, 1).strftime('%Y-%m-%d') + start_date = (now - relativedelta(months=13)).replace(day=1).strftime('%Y-%m-%d') logger.info(f"📅 Fetching invoices from {start_date} onwards (13 months for yearly billed items)") async with aiohttp.ClientSession() as session: diff --git a/requirements.txt b/requirements.txt index b85f036..3ccb257 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,6 +5,7 @@ pydantic==2.10.3 pydantic-settings==2.6.1 python-dotenv==1.0.1 python-multipart==0.0.17 +python-dateutil==2.8.2 jinja2==3.1.4 aiohttp==3.10.10 msal==1.31.1