only get current year by default

This commit is contained in:
Jan Bader
2026-04-12 20:59:06 +02:00
parent 0ad9567cdc
commit 395998de88
2 changed files with 11 additions and 0 deletions

View File

@@ -1,7 +1,9 @@
import html import html
import logging import logging
import os
import re import re
import time import time
from datetime import datetime
from pathlib import Path from pathlib import Path
from playwright.sync_api import sync_playwright, Page, BrowserContext from playwright.sync_api import sync_playwright, Page, BrowserContext
@@ -369,6 +371,11 @@ def download_all_invoices() -> list[Path]:
years = get_year_options(page) years = get_year_options(page)
if not years: if not years:
years = ["all"] years = ["all"]
else:
download_all_years = os.getenv("DOWNLOAD_ALL_YEARS", "").lower() in ("1", "true", "yes", "y")
if not download_all_years:
current_year = str(datetime.now().year)
years = [current_year] if current_year in years else years[:1]
logger.info("Group '%s' - years: %s", group["label"], years) logger.info("Group '%s' - years: %s", group["label"], years)
for year in years: for year in years:

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import argparse import argparse
import logging import logging
import os
import sys import sys
from config import Config from config import Config
@@ -16,6 +17,7 @@ def main():
parser.add_argument("--document-type", help="Document type to select") parser.add_argument("--document-type", help="Document type to select")
parser.add_argument("--company", help="Company name to fill") parser.add_argument("--company", help="Company name to fill")
parser.add_argument("--notes", help="Notes to fill on invoices") parser.add_argument("--notes", help="Notes to fill on invoices")
parser.add_argument("--all-years", action="store_true", help="Download invoices for all years")
parser.add_argument("--verbose", "-v", action="store_true", help="Verbose logging") parser.add_argument("--verbose", "-v", action="store_true", help="Verbose logging")
args = parser.parse_args() args = parser.parse_args()
@@ -39,6 +41,8 @@ def main():
Config.INVOICE_COMPANY = args.company Config.INVOICE_COMPANY = args.company
if args.notes: if args.notes:
Config.INVOICE_NOTES = args.notes Config.INVOICE_NOTES = args.notes
if args.all_years:
os.environ["DOWNLOAD_ALL_YEARS"] = "true"
try: try:
Config.validate() Config.validate()