From 6576b35c071c9b31af31c471b9a6a023cf567d31 Mon Sep 17 00:00:00 2001 From: bach Date: Mon, 7 Sep 2026 14:45:06 +0200 Subject: [PATCH] =?UTF-8?q?Badge=20sur=20les=20taux=20TVA=20non=20officiel?= =?UTF-8?q?s,=20=C3=A9cart=20positif=20en=20vert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Un point ambre discret (pas de texte -- la colonne TVA ne fait que 3,5% de large, à peine assez pour "12,64 %" lui-même) marque tout taux TVA qui ne tombe sur aucun des 5 taux officiels français (0, 2,1, 5,5, 10, 20 %, ±0,05 point comme dans les scripts de migration). Infobulle pour le détail. - Écart positif (répartition > Montant HT) passe au vert (--figli-positive), au lieu du rouge uniforme précédent -- même logique que la colonne Montant HT, qui distingue déjà positif/négatif. --- .../custom/figli_compta_ledger/css/home.css | 27 +++++++++++++++++-- .../custom/figli_compta_ledger/js/home.js | 16 +++++++++++ .../templates/figli-compta-home.html.twig | 6 ++--- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/web/modules/custom/figli_compta_ledger/css/home.css b/web/modules/custom/figli_compta_ledger/css/home.css index e7fff26..46bf0a5 100644 --- a/web/modules/custom/figli_compta_ledger/css/home.css +++ b/web/modules/custom/figli_compta_ledger/css/home.css @@ -292,12 +292,21 @@ html.gin--dark-mode #figli-home-app { font-weight: 700; } -/* Écart is called out by the Écart column itself (bold red, see - .figli-ecart below) -- no separate row-level treatment needed. */ +/* Écart is called out by the Écart column itself (bold, red or green + depending on sign -- see below) -- no separate row-level treatment + needed. Répartition > Montant HT (positive écart) means the accounts + were credited more than what's actually owed for this line, the same + "more money than expected" sense .figli-montant-positif already + marks green elsewhere; the reverse (negative) stays the usual + red/error color. */ #figli-home-app td.figli-ecart { color: var(--figli-error); font-weight: 700; } +#figli-home-app td.figli-ecart-positif { + color: var(--figli-positive); + font-weight: 700; +} /* Signalé rows: a thick amber accent bar on the left edge. */ #figli-home-app tr.figli-flag-row td:first-child { @@ -467,6 +476,20 @@ html.gin--dark-mode #figli-home-app { #figli-home-app .amount.figli-tva-col { width: 3.5%; } +/* Non-official TVA rate marker -- a plain dot rather than a text badge + (e.g. "non officiel"): the column is only ~3.5% wide, barely enough + for "12,64 %" itself, so anything wider than a few px would overflow + into the next column. Tooltip (title attribute in the twig template) + carries the actual explanation. */ +#figli-home-app .figli-tva-badge { + display: inline-block; + width: 6px; + height: 6px; + margin-left: 3px; + border-radius: 50%; + background: var(--figli-warning); + vertical-align: middle; +} #figli-home-app .amount.compte-col { width: 4.3%; white-space: nowrap; diff --git a/web/modules/custom/figli_compta_ledger/js/home.js b/web/modules/custom/figli_compta_ledger/js/home.js index af0d143..091beb1 100644 --- a/web/modules/custom/figli_compta_ledger/js/home.js +++ b/web/modules/custom/figli_compta_ledger/js/home.js @@ -26,6 +26,12 @@ // stores a plain rate (10), which style: 'percent' would otherwise // silently read as 1000%. const PCT = new Intl.NumberFormat('fr-FR', { minimumFractionDigits: 0, maximumFractionDigits: 2 }); + // Mirrors the $taux_officiels select in figli_compta_ledger_form_alter() + // and the $official list in figli_compta_ledger_update_8007()/_8008() -- + // same 0.05-point tolerance as those migration scripts, for the same + // "rounding through 2-decimal HT/TTC storage" reason. + const OFFICIAL_TVA_RATES = [0, 2.1, 5.5, 10, 20]; + const OFFICIAL_TVA_EPSILON = 0.05; const MONTHS = ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre']; const TYPE_LABELS = { entree: 'Entrée client', @@ -681,6 +687,16 @@ formatPct(v) { return v === null || v === undefined ? '' : PCT.format(v) + ' %'; }, + // Flags a TVA rate that isn't one of the 5 official French VAT + // rates -- either a genuinely blended/multi-rate invoice collapsed + // into one ligne_comptable, or a migrated line + // figli_compta_ledger_update_8007() left ambiguous rather than + // guess (see that function's docblock). Null (no TVA recorded at + // all) is never flagged -- nothing to question there. + isTvaOfficial(v) { + if (v === null || v === undefined) return true; + return OFFICIAL_TVA_RATES.some((o) => Math.abs(v - o) < OFFICIAL_TVA_EPSILON); + }, // Écart between this ouverture row's year and the previous year's // calculated closing balance -- restricted to whichever compte(s) // this specific row's répartition actually touches (ouverture lines diff --git a/web/modules/custom/figli_compta_ledger/templates/figli-compta-home.html.twig b/web/modules/custom/figli_compta_ledger/templates/figli-compta-home.html.twig index b156778..9d82e38 100644 --- a/web/modules/custom/figli_compta_ledger/templates/figli-compta-home.html.twig +++ b/web/modules/custom/figli_compta_ledger/templates/figli-compta-home.html.twig @@ -243,10 +243,10 @@ {{ formatEur(item.montant_ht) }} {{ formatEur(item.cotisation) }} - {{ formatPct(item.tva) }} + {{ formatPct(item.tva) }} {{ formatEur(item.montant_ttc) }} {{ item.parCompte[c] !== undefined ? formatEur(item.parCompte[c]) : '' }} - {{ item.hasError ? formatEur(item.ecart) : '' }} + {{ item.hasError ? formatEur(item.ecart) : '' }} @@ -324,7 +324,7 @@ {{ formatEur(item.montant_ht) }} {{ formatEur(item.montant_ttc) }} {{ item.parCompte[c] !== undefined ? formatEur(item.parCompte[c]) : '' }} - {{ item.hasError ? formatEur(item.ecart) : '' }} + {{ item.hasError ? formatEur(item.ecart) : '' }}