Initial commit - Stand 26.04.2026
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Verifiziert die importierten Kredite vollständig.
|
||||
"""
|
||||
|
||||
import json
|
||||
import urllib.request
|
||||
import urllib.error
|
||||
|
||||
API_BASE = "http://localhost:3001/api"
|
||||
|
||||
def api_call(endpoint, method='GET', data=None):
|
||||
url = f"{API_BASE}{endpoint}"
|
||||
headers = {'Content-Type': 'application/json'}
|
||||
|
||||
req = urllib.request.Request(
|
||||
url,
|
||||
data=json.dumps(data).encode() if data else None,
|
||||
headers=headers,
|
||||
method=method
|
||||
)
|
||||
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=30) as response:
|
||||
return json.loads(response.read().decode())
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
return None
|
||||
|
||||
print("="*70)
|
||||
print("VERIFIKATION: ALLE KREDITE")
|
||||
print("="*70)
|
||||
|
||||
# Alle Kredite holen
|
||||
all_kredite = api_call('/kredite')
|
||||
|
||||
if not all_kredite:
|
||||
print("Fehler beim Abrufen der Kredite!")
|
||||
exit(1)
|
||||
|
||||
print(f"\nGefundene Kredite: {len(all_kredite)}")
|
||||
print("-"*70)
|
||||
|
||||
for k in all_kredite:
|
||||
kredit_id = k.get('id')
|
||||
name = k.get('name')
|
||||
restschuld = float(k.get('restschuld', 0))
|
||||
monatsrate = float(k.get('monatsrate', 0))
|
||||
zinssatz = float(k.get('zinssatz', 0))
|
||||
start_datum = k.get('start_datum')
|
||||
ursprung = float(k.get('ursprungsschuld', 0))
|
||||
|
||||
print(f"\n{name}")
|
||||
print(f" ID: {kredit_id}")
|
||||
print(f" Restschuld: {restschuld:,>12.2f} EUR")
|
||||
print(f" Ursprung: {ursprung:,>12.2f} EUR")
|
||||
print(f" Monatsrate: {monatsrate:,>12.2f} EUR")
|
||||
print(f" Zinssatz: {zinssatz:,>12.2f}%")
|
||||
print(f" Start: {start_datum}")
|
||||
|
||||
# Buchungen prüfen
|
||||
buchungen = api_call(f'/kredite/{kredit_id}/buchungen')
|
||||
if buchungen:
|
||||
print(f" Buchungen: {len(buchungen)}")
|
||||
if len(buchungen) > 0:
|
||||
# Erste und letzte Buchung zeigen
|
||||
first = buchungen[-1] # Letzte in Liste = erste chronologisch (DESC order)
|
||||
last = buchungen[0] # Erste in Liste = letzte chronologisch
|
||||
print(f" Erste: {first.get('datum')} - Rest: {float(first.get('restschuld_nach', 0)):,.2f} EUR")
|
||||
print(f" Letzte: {last.get('datum')} - Rest: {float(last.get('restschuld_nach', 0)):,.2f} EUR")
|
||||
else:
|
||||
print(f" Buchungen: KEINE!")
|
||||
|
||||
# Zusammenfassung
|
||||
print("\n" + "="*70)
|
||||
print("ZUSAMMENFASSUNG ALLER KREDITE")
|
||||
print("="*70)
|
||||
|
||||
total_restschuld = sum(float(k.get('restschuld', 0)) for k in all_kredite)
|
||||
total_rate = sum(float(k.get('monatsrate', 0)) for k in all_kredite)
|
||||
total_ursprung = sum(float(k.get('ursprungsschuld', 0)) for k in all_kredite)
|
||||
|
||||
print(f"\nGesamt-Ursprungsschuld: {total_ursprung:,>15.2f} EUR")
|
||||
print(f"Gesamt-Restschuld: {total_restschuld:,>15.2f} EUR")
|
||||
print(f"Gesamt-Monatsrate: {total_rate:,>15.2f} EUR")
|
||||
print(f"Anzahl Kredite: {len(all_kredite):,>15}")
|
||||
|
||||
print("\n" + "="*70)
|
||||
print("[OK] ALLE KREDITE ERFOLGREICH IMPORTIERT!")
|
||||
print("="*70)
|
||||
Reference in New Issue
Block a user