modify csv import
Deploy via Portainer / deploy (push) Successful in 0s

This commit is contained in:
2026-07-15 10:37:39 +02:00
parent 2ba1c39bfd
commit 8524f11ec8
3 changed files with 12 additions and 4 deletions
+10 -2
View File
@@ -103,7 +103,7 @@ def _parse_csv(text, cats):
for n, raw in enumerate(rows[start:], start=start + 1):
if not any(c.strip() for c in raw):
continue
c = (raw + [""] * 7)[:7]
c = (raw + [""] * 8)[:8]
dt = _date(c[0])
montant = _dec(c[6])
if dt is None:
@@ -111,8 +111,16 @@ def _parse_csv(text, cats):
if montant == 0:
erreurs.append(f"Ligne {n} : montant nul."); continue
cat = cats.get((c[2] or "").strip().lower())
grp = (c[7] or "").strip() # colonne « groupe » (ventilation), optionnelle
lignes.append(_row(dt, (c[1] or "").strip() or "(sans libellé)", montant,
_dec(c[4]), _regime(c[5]), cat, _activite(c[3]), "", n))
_dec(c[4]), _regime(c[5]), cat, _activite(c[3]),
grp, n, grp))
# n_parts pour l'aperçu : marquer « ventilée » les lignes d'un même groupe.
from collections import Counter
nb = Counter(l["groupe"] for l in lignes if l["groupe"])
for l in lignes:
if l["groupe"] and nb[l["groupe"]] > 1 and "ventilée" not in l["type"]:
l["type"] += " (ventilée)"
return lignes, erreurs, []