fix: Fix month calculation bug in date filter

v1.3.138:
- Fixed ValueError: month must be in 1..12
- Use python-dateutil for proper month arithmetic
- Uses relativedelta for correct 13 month calculation
This commit is contained in:
Christian 2026-01-27 07:14:40 +01:00
parent 1bf04d45b1
commit e0909d4586
3 changed files with 4 additions and 11 deletions

View File

@ -1 +1 @@
1.3.137
1.3.138

View File

@ -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:

View File

@ -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