feat: Extend invoice filter to 13 months for yearly items

v1.3.137:
- Changed from 12 to 13 months lookback
- Ensures yearly billed items are visible
- Example: Jan 27, 2026 -> fetches from Jan 1, 2025
This commit is contained in:
Christian 2026-01-27 07:10:25 +01:00
parent 86ad68c362
commit 1bf04d45b1
2 changed files with 8 additions and 7 deletions

View File

@ -1 +1 @@
1.3.136 1.3.137

View File

@ -450,18 +450,19 @@ 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 first day of the month 12 months ago # Calculate first day of the month 13 months ago (for yearly billed items)
now = datetime.now() now = datetime.now()
# Go back 12 months # Go back 13 months
if now.month > 12: months_back = 13
start_month = now.month - 12 if now.month > months_back:
start_month = now.month - months_back
start_year = now.year start_year = now.year
else: else:
start_month = 12 - (12 - now.month) start_month = 12 - (months_back - now.month)
start_year = now.year - 1 start_year = now.year - 1
start_date = datetime(start_year, start_month, 1).strftime('%Y-%m-%d') 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)") logger.info(f"📅 Fetching invoices from {start_date} onwards (13 months for yearly billed items)")
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
# Try multiple endpoints to find invoices # Try multiple endpoints to find invoices