Aufgeräumt
This commit is contained in:
parent
828cc5dbe1
commit
d6e6f01329
2 changed files with 67 additions and 33 deletions
|
|
@ -24,7 +24,7 @@ else:
|
||||||
|
|
||||||
log_dir.mkdir(exist_ok=True)
|
log_dir.mkdir(exist_ok=True)
|
||||||
|
|
||||||
log_file = log_dir / "categorize_transactions.log"
|
log_file = log_dir / "ing.log"
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
filename=log_file,
|
filename=log_file,
|
||||||
|
|
@ -32,7 +32,9 @@ logging.basicConfig(
|
||||||
format="%(asctime)s [%(levelname)s] %(message)s",
|
format="%(asctime)s [%(levelname)s] %(message)s",
|
||||||
)
|
)
|
||||||
|
|
||||||
logging.info("=== Scriptstart ===")
|
logging.info(
|
||||||
|
"[categorize] === Scriptstart ==="
|
||||||
|
)
|
||||||
|
|
||||||
# --------------------------------------------------
|
# --------------------------------------------------
|
||||||
# Kalenderwoche bestimmen
|
# Kalenderwoche bestimmen
|
||||||
|
|
@ -109,7 +111,7 @@ excel_file = (
|
||||||
|
|
||||||
if not source_json.exists():
|
if not source_json.exists():
|
||||||
logging.error(
|
logging.error(
|
||||||
f"Transaktionsdatei nicht gefunden: {source_json}"
|
f"[categorize] Transaktionsdatei nicht gefunden: {source_json}"
|
||||||
)
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
@ -462,10 +464,10 @@ with open(summary_file, "w", encoding="utf-8") as outfile:
|
||||||
# Ausgabe
|
# Ausgabe
|
||||||
# --------------------------------------------------
|
# --------------------------------------------------
|
||||||
|
|
||||||
logging.info(f"Jahr : {year}")
|
logging.info(f"[categorize] Jahr : {year}")
|
||||||
logging.info(f"Kalenderwoche : {week}")
|
logging.info(f"[categorize] Kalenderwoche : {week}")
|
||||||
logging.info(
|
logging.info(
|
||||||
f"Transaktionen : {len(categorized_transactions)}"
|
f"[categorize] Transaktionen : {len(categorized_transactions)}"
|
||||||
)
|
)
|
||||||
|
|
||||||
logging.info("----------------------------------------")
|
logging.info("----------------------------------------")
|
||||||
|
|
@ -474,16 +476,16 @@ logging.info("----------------------------------------")
|
||||||
|
|
||||||
for category, values in sorted(category_totals.items()):
|
for category, values in sorted(category_totals.items()):
|
||||||
logging.info(
|
logging.info(
|
||||||
f"Kategorie={category}; "
|
f"[categorize] Kategorie={category}; "
|
||||||
f"Einnahmen={values['income']:.2f}; "
|
f"[categorize] Einnahmen={values['income']:.2f}; "
|
||||||
f"Ausgaben={values['expenses']:.2f}; "
|
f"[categorize] Ausgaben={values['expenses']:.2f}; "
|
||||||
f"Saldo={values['saldo']:.2f}"
|
f"[categorize] Saldo={values['saldo']:.2f}"
|
||||||
)
|
)
|
||||||
|
|
||||||
logging.info(f"CSV : {csv_file}")
|
logging.info(f"[categorize] CSV : {csv_file}")
|
||||||
logging.info(f"JSON : {json_file}")
|
logging.info(f"[categorize] JSON : {json_file}")
|
||||||
logging.info(f"Summary : {summary_file}")
|
logging.info(f"[categorize] Summary : {summary_file}")
|
||||||
logging.info(f"Excel : {excel_file}")
|
logging.info(f"[categorize] Excel : {excel_file}")
|
||||||
|
|
||||||
# --------------------------------------------------
|
# --------------------------------------------------
|
||||||
# Synchronisation
|
# Synchronisation
|
||||||
|
|
@ -503,11 +505,11 @@ if which("rclone"):
|
||||||
check=True
|
check=True
|
||||||
)
|
)
|
||||||
|
|
||||||
logging.info("Excel nach Nextcloud synchronisiert.")
|
logging.info("[categorize] Excel nach Nextcloud synchronisiert.")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
logging.error(f"rclone Fehler: {e}")
|
logging.error(f"[categorize] rclone Fehler: {e}")
|
||||||
|
|
||||||
elif platform.system() == "Windows":
|
elif platform.system() == "Windows":
|
||||||
|
|
||||||
|
|
@ -536,18 +538,20 @@ elif platform.system() == "Windows":
|
||||||
)
|
)
|
||||||
|
|
||||||
logging.info(
|
logging.info(
|
||||||
f"Nextcloud-Synchronisation erfolgreich: {target_file}"
|
f"[categorize] Nextcloud-Synchronisation erfolgreich: {target_file}"
|
||||||
)
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
logging.error(
|
logging.error(
|
||||||
f"Nextcloud-Kopie fehlgeschlagen: {e}"
|
f"[categorize] Nextcloud-Kopie fehlgeschlagen: {e}"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|
||||||
logging.warning(
|
logging.warning(
|
||||||
"Keine Synchronisationsmethode gefunden."
|
"[categorize] Keine Synchronisationsmethode gefunden."
|
||||||
)
|
)
|
||||||
|
|
||||||
logging.info("=== Scriptende ===")
|
logging.info(
|
||||||
|
"[categorize] === Scriptende ==="
|
||||||
|
)
|
||||||
|
|
@ -7,6 +7,27 @@ from fints.client import FinTS3PinTanClient
|
||||||
import csv
|
import csv
|
||||||
import json
|
import json
|
||||||
import sys
|
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
|
# Konfiguration laden
|
||||||
|
|
@ -95,10 +116,10 @@ if end_date > today:
|
||||||
end_date = today
|
end_date = today
|
||||||
|
|
||||||
if start_date > today:
|
if start_date > today:
|
||||||
|
logging.error(
|
||||||
print(
|
"[transactions] Die angeforderte "
|
||||||
"Die angeforderte Kalenderwoche liegt "
|
"Kalenderwoche liegt vollständig "
|
||||||
"vollständig in der Zukunft."
|
"in der Zukunft."
|
||||||
)
|
)
|
||||||
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
@ -148,12 +169,12 @@ with client:
|
||||||
end_date=end_date
|
end_date=end_date
|
||||||
)
|
)
|
||||||
|
|
||||||
print(
|
logging.info(
|
||||||
f"Lade Transaktionen für KW{week:02d}/{year}"
|
f"[transactions] Lade Transaktionen für KW{week:02d}/{year}"
|
||||||
)
|
)
|
||||||
|
|
||||||
print(
|
logging.info(
|
||||||
f"Zeitraum: {start_date} bis {end_date}"
|
f"[transactions] Zeitraum: {start_date} bis {end_date}"
|
||||||
)
|
)
|
||||||
|
|
||||||
for transaction in transactions:
|
for transaction in transactions:
|
||||||
|
|
@ -258,8 +279,17 @@ urlopen(
|
||||||
# Erfolgsmeldung
|
# Erfolgsmeldung
|
||||||
# --------------------------------------------------
|
# --------------------------------------------------
|
||||||
|
|
||||||
print(f"CSV erstellt : {CSV_FILE}")
|
logging.info(
|
||||||
print(f"JSON erstellt: {JSON_FILE}")
|
f"[transactions] Export abgeschlossen | "
|
||||||
print(f"Transaktionen: {transaction_count}")
|
f"Transaktionen={transaction_count} | "
|
||||||
print(f"Wochensumme : {week_sum:.2f} EUR")
|
f"Wochensumme={week_sum:.2f} EUR | "
|
||||||
print(f"Ausgaben : {week_expenses:.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