Arrondi URSSAF/TVA/VFL a l'euro + CFP + fix montant popup + fix categorie favori
Deploy via Portainer / deploy (push) Successful in 0s

This commit is contained in:
2026-07-15 11:32:19 +02:00
parent 8524f11ec8
commit cd5605819a
9 changed files with 83 additions and 25 deletions
+4 -1
View File
@@ -99,6 +99,8 @@ def _parse_csv(text, cats):
delim = ";" if text.count(";") >= text.count(",") else ","
rows = list(csv.reader(io.StringIO(text), delimiter=delim))
lignes, erreurs = [], []
# Résolution par numéro de compte PCG (favori Indy) OU par nom (CSV manuel).
compte_map = {c.compte_pcg: c for c in Categorie.objects.all() if c.compte_pcg}
start = 1 if rows and rows[0] and rows[0][0].strip().lower() == "date" else 0
for n, raw in enumerate(rows[start:], start=start + 1):
if not any(c.strip() for c in raw):
@@ -110,7 +112,8 @@ def _parse_csv(text, cats):
erreurs.append(f"Ligne {n} : date invalide « {c[0]} »."); continue
if montant == 0:
erreurs.append(f"Ligne {n} : montant nul."); continue
cat = cats.get((c[2] or "").strip().lower())
val = (c[2] or "").strip()
cat = compte_map.get(val) or cats.get(val.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]),