fix: Datumsspalten mit Uhrzeit werden auch ohne passendes Format erkannt

Der Revolut-Export führt "2026-01-06 23:11:14" in der Datumsspalte. Wählte man
im Dropdown JJJJ-MM-TT, scheiterte das Parsen an der Uhrzeit – jede Zeile hatte
kein Datum und galt als ungültig ("137 Zeilen erkannt, 0 werden gebucht"),
obwohl die Auswahl richtig aussah.

- parse_date schneidet eine überzählige Uhrzeit ab und kommt auch damit klar,
  wenn das Format eine Uhrzeit erwartet, der Wert aber keine hat (ISO-T ebenso)
- Dropdown um die Varianten mit Uhrzeit ergänzt, damit die Bank-Vorlagen ihren
  echten Eintrag zeigen statt eines leeren Feldes
- Test: reines Datumsformat auf Datei mit Uhrzeit -> alle Zeilen erkannt, 84 grün

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Guido
2026-08-21 08:02:18 +02:00
co-authored by Claude Opus 4.8
parent e69be7f3d5
commit d97e08e913
3 changed files with 49 additions and 1 deletions
+21
View File
@@ -268,3 +268,24 @@ def test_reconciliation_detects_wrong_amount(admin):
assert mm["payee"] == "Premium Abo-Gebühr"
assert mm["expected_cents"] == -1099 # laut Kontostand-Spalte
assert mm["actual_cents"] == 0 # ohne Gebührenspalte erkannt
def test_date_format_tolerates_time(admin):
"""Wählt man ein reines Datumsformat, obwohl die Spalte eine Uhrzeit enthält,
werden die Zeilen trotzdem erkannt (früher: alles ungültig)."""
acc = _account(admin, name="Datum Zeit", currency="CHF")
nur_datum = json.dumps({
"date": 3, "amount": 5, "payee": 4, "fee": 6, "currency": 7, "state": 8, "balance": 9,
})
res = admin.post(
"/api/imports/preview",
files={"file": ("r.csv", io.BytesIO(REVOLUT_DE_CSV.encode("utf-8")), "text/csv")},
data={
"account_id": str(acc["id"]), "delimiter": ",", "decimal_sep": ".",
"date_format": "%Y-%m-%d", # ohne Uhrzeit, Datei hat aber welche
"encoding": "utf-8", "has_header": "true", "skip_rows": "0",
"amount_mode": "signed", "column_map": nur_datum,
},
).json()
assert all(r["date"] for r in res["rows"]), "Datum trotz Uhrzeit erkannt"
assert res["reconciliation"]["ok"] is True