40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
import urllib.request
|
|
import json
|
|
|
|
kredit_id = '4ad8826f-ecb4-443d-aef6-ce9162e5f078'
|
|
|
|
# Berechne korrekte Restschuld fuer Forderung
|
|
# Start: 7000
|
|
# Zahlungen von Niki: +3400 (erhoeht die Forderung)
|
|
# Auslagen (Rene gibt Geld): -505 (verringert die Forderung)
|
|
# Erwartet: 7000 - 2895 = 4105
|
|
|
|
correct_restschuld = 4105.00
|
|
|
|
print("=" * 60)
|
|
print("KORREKTUR: Restschuld fuer Niki Forderung")
|
|
print("=" * 60)
|
|
|
|
# Update Restschuld
|
|
url = f'http://localhost:3001/api/kredite/{kredit_id}'
|
|
data = json.dumps({
|
|
'restschuld': correct_restschuld,
|
|
'notizen': 'Korrigierte Forderung - Rene bekommt Geld von Niki'
|
|
}).encode()
|
|
|
|
req = urllib.request.Request(url, data=data, headers={'Content-Type': 'application/json'}, method='PUT')
|
|
|
|
try:
|
|
with urllib.request.urlopen(req) as response:
|
|
result = json.loads(response.read().decode())
|
|
print(f"[OK] Restschuld aktualisiert: {result['restschuld']} EUR")
|
|
print(f"[OK] Richtung: {result.get('richtung', 'N/A')}")
|
|
except Exception as e:
|
|
print(f"[ERR] Fehler beim Update: {e}")
|
|
|
|
print("\n" + "=" * 60)
|
|
print("KORREKTUR ABGESCHLOSSEN")
|
|
print("=" * 60)
|
|
print(f"\nKorrigierte Restschuld: {correct_restschuld} EUR")
|
|
print("Berechnung: 7000 (Start) - 2895 (Netto-Zahlungen) = 4105 EUR")
|