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:
parent
86ad68c362
commit
1bf04d45b1
@ -450,18 +450,19 @@ class EconomicService:
|
||||
List of invoice records with lines from the last year
|
||||
"""
|
||||
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()
|
||||
# Go back 12 months
|
||||
if now.month > 12:
|
||||
start_month = now.month - 12
|
||||
# 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 - (12 - now.month)
|
||||
start_month = 12 - (months_back - 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)")
|
||||
logger.info(f"📅 Fetching invoices from {start_date} onwards (13 months for yearly billed items)")
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
# Try multiple endpoints to find invoices
|
||||
|
||||
Loading…
Reference in New Issue
Block a user