Ergänzungen Startparameter
This commit is contained in:
parent
47e8845517
commit
828cc5dbe1
1 changed files with 47 additions and 3 deletions
|
|
@ -6,6 +6,7 @@ from urllib.request import urlopen
|
|||
from fints.client import FinTS3PinTanClient
|
||||
import csv
|
||||
import json
|
||||
import sys
|
||||
|
||||
# --------------------------------------------------
|
||||
# Konfiguration laden
|
||||
|
|
@ -65,8 +66,43 @@ base_dir = Path.home() / "Transaktionen"
|
|||
if not base_dir.exists():
|
||||
base_dir = Path(__file__).parent / "Transaktionen"
|
||||
|
||||
# --------------------------------------------------
|
||||
# Kalenderwoche bestimmen
|
||||
# --------------------------------------------------
|
||||
|
||||
if len(sys.argv) == 3:
|
||||
|
||||
year = int(sys.argv[1])
|
||||
week = int(sys.argv[2])
|
||||
|
||||
else:
|
||||
|
||||
year, week, _ = datetime.now().isocalendar()
|
||||
|
||||
# Montag der Kalenderwoche
|
||||
|
||||
start_date = datetime.strptime(
|
||||
f"{year}-W{week:02d}-1",
|
||||
"%G-W%V-%u"
|
||||
).date()
|
||||
|
||||
# Sonntag der Kalenderwoche
|
||||
|
||||
end_date = start_date + timedelta(days=6)
|
||||
today = date.today()
|
||||
|
||||
if end_date > today:
|
||||
end_date = today
|
||||
|
||||
if start_date > today:
|
||||
|
||||
print(
|
||||
"Die angeforderte Kalenderwoche liegt "
|
||||
"vollständig in der Zukunft."
|
||||
)
|
||||
|
||||
sys.exit(1)
|
||||
|
||||
year_dir = base_dir / str(year)
|
||||
csv_dir = year_dir / "csv"
|
||||
json_dir = year_dir / "json"
|
||||
|
|
@ -108,8 +144,16 @@ with client:
|
|||
|
||||
transactions = client.get_transactions(
|
||||
account,
|
||||
start_date=date.today() - timedelta(days=7),
|
||||
end_date=date.today()
|
||||
start_date=start_date,
|
||||
end_date=end_date
|
||||
)
|
||||
|
||||
print(
|
||||
f"Lade Transaktionen für KW{week:02d}/{year}"
|
||||
)
|
||||
|
||||
print(
|
||||
f"Zeitraum: {start_date} bis {end_date}"
|
||||
)
|
||||
|
||||
for transaction in transactions:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue