diff --git a/VERSION b/VERSION index 921648e..8056afa 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.3.135 \ No newline at end of file +1.3.136 \ No newline at end of file diff --git a/app/services/economic_service.py b/app/services/economic_service.py index 5ebbbbf..0cf3d7e 100644 --- a/app/services/economic_service.py +++ b/app/services/economic_service.py @@ -450,9 +450,18 @@ class EconomicService: List of invoice records with lines from the last year """ try: - # Calculate date 1 year ago - one_year_ago = (datetime.now() - timedelta(days=365)).strftime('%Y-%m-%d') - logger.info(f"📅 Fetching invoices from {one_year_ago} onwards (1 year filter)") + # Calculate first day of the month 12 months ago + now = datetime.now() + # Go back 12 months + if now.month > 12: + start_month = now.month - 12 + start_year = now.year + else: + start_month = 12 - (12 - now.month) + start_year = now.year - 1 + + start_date = datetime(start_year, start_month, 1).strftime('%Y-%m-%d') + logger.info(f"📅 Fetching invoices from {start_date} onwards (12 months from 1st of month)") async with aiohttp.ClientSession() as session: # Try multiple endpoints to find invoices @@ -483,7 +492,7 @@ class EconomicService: params={ "pagesize": 1000, "skippages": page, - "filter": f"date$gte:{one_year_ago}" + "filter": f"date$gte:{start_date}" }, headers=self._get_headers() ) as response: