fix: Adjust date filter to 1st of month 12 months back

v1.3.136:
- Changed filter from 365 days to exactly 12 months
- Uses 1st day of the month 12 months ago
- Example: Jan 27, 2026 -> fetches from Feb 1, 2025
This commit is contained in:
Christian 2026-01-27 07:09:50 +01:00
parent 180933948f
commit 86ad68c362
2 changed files with 14 additions and 5 deletions

View File

@ -1 +1 @@
1.3.135 1.3.136

View File

@ -450,9 +450,18 @@ class EconomicService:
List of invoice records with lines from the last year List of invoice records with lines from the last year
""" """
try: try:
# Calculate date 1 year ago # Calculate first day of the month 12 months ago
one_year_ago = (datetime.now() - timedelta(days=365)).strftime('%Y-%m-%d') now = datetime.now()
logger.info(f"📅 Fetching invoices from {one_year_ago} onwards (1 year filter)") # 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: async with aiohttp.ClientSession() as session:
# Try multiple endpoints to find invoices # Try multiple endpoints to find invoices
@ -483,7 +492,7 @@ class EconomicService:
params={ params={
"pagesize": 1000, "pagesize": 1000,
"skippages": page, "skippages": page,
"filter": f"date$gte:{one_year_ago}" "filter": f"date$gte:{start_date}"
}, },
headers=self._get_headers() headers=self._get_headers()
) as response: ) as response: