Aufgeräumt
This commit is contained in:
parent
828cc5dbe1
commit
d6e6f01329
2 changed files with 67 additions and 33 deletions
|
|
@ -7,6 +7,27 @@ from fints.client import FinTS3PinTanClient
|
|||
import csv
|
||||
import json
|
||||
import sys
|
||||
import logging
|
||||
import platform
|
||||
from pathlib import Path
|
||||
|
||||
if platform.system() == "Windows":
|
||||
log_dir = Path(__file__).parent / "logs"
|
||||
else:
|
||||
log_dir = Path.home() / "logs"
|
||||
|
||||
log_dir.mkdir(exist_ok=True)
|
||||
|
||||
log_file = log_dir / "ing.log"
|
||||
|
||||
logging.basicConfig(
|
||||
filename=log_file,
|
||||
level=logging.INFO,
|
||||
format="%(asctime)s [%(levelname)s] %(message)s",
|
||||
force=True
|
||||
)
|
||||
|
||||
logging.info("[transactions] === Scriptstart ===")
|
||||
|
||||
# --------------------------------------------------
|
||||
# Konfiguration laden
|
||||
|
|
@ -95,10 +116,10 @@ if end_date > today:
|
|||
end_date = today
|
||||
|
||||
if start_date > today:
|
||||
|
||||
print(
|
||||
"Die angeforderte Kalenderwoche liegt "
|
||||
"vollständig in der Zukunft."
|
||||
logging.error(
|
||||
"[transactions] Die angeforderte "
|
||||
"Kalenderwoche liegt vollständig "
|
||||
"in der Zukunft."
|
||||
)
|
||||
|
||||
sys.exit(1)
|
||||
|
|
@ -148,12 +169,12 @@ with client:
|
|||
end_date=end_date
|
||||
)
|
||||
|
||||
print(
|
||||
f"Lade Transaktionen für KW{week:02d}/{year}"
|
||||
logging.info(
|
||||
f"[transactions] Lade Transaktionen für KW{week:02d}/{year}"
|
||||
)
|
||||
|
||||
print(
|
||||
f"Zeitraum: {start_date} bis {end_date}"
|
||||
logging.info(
|
||||
f"[transactions] Zeitraum: {start_date} bis {end_date}"
|
||||
)
|
||||
|
||||
for transaction in transactions:
|
||||
|
|
@ -258,8 +279,17 @@ urlopen(
|
|||
# Erfolgsmeldung
|
||||
# --------------------------------------------------
|
||||
|
||||
print(f"CSV erstellt : {CSV_FILE}")
|
||||
print(f"JSON erstellt: {JSON_FILE}")
|
||||
print(f"Transaktionen: {transaction_count}")
|
||||
print(f"Wochensumme : {week_sum:.2f} EUR")
|
||||
print(f"Ausgaben : {week_expenses:.2f} EUR")
|
||||
logging.info(
|
||||
f"[transactions] Export abgeschlossen | "
|
||||
f"Transaktionen={transaction_count} | "
|
||||
f"Wochensumme={week_sum:.2f} EUR | "
|
||||
f"Ausgaben={week_expenses:.2f} EUR"
|
||||
)
|
||||
|
||||
logging.info(
|
||||
f"[transactions] CSV={CSV_FILE}"
|
||||
)
|
||||
|
||||
logging.info(
|
||||
f"[transactions] JSON={JSON_FILE}"
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue