From e117089be57a88a671f47a110e92770ed1f60d82 Mon Sep 17 00:00:00 2001 From: bach Date: Mon, 7 Sep 2026 12:18:58 +0200 Subject: [PATCH] =?UTF-8?q?Renomme=20HT/TTC,=20r=C3=A9duit=20leur=20largeu?= =?UTF-8?q?r,=20ajoute=20une=20colonne=20TVA=20au=20grand=20livre?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit HT/TTC passent de "Montant HT"/"Montant TTC" à "HT"/"TTC" (5% de large au lieu de 6,2%), avec une nouvelle colonne TVA entre les deux (3,5%, affichée en %, arrondie à 2 décimales -- les lignes migrées portent parfois un taux rétro-calculé à 4 décimales, voir figli_compta_ledger_update_8005()). field_tva était déjà exposé sans changement de requête JSON:API (pas de sparse fieldset ici). Piège de spécificité CSS : .amount:not(.compte-col) (déjà en place pour Écart) compte comme 2 classes à cause de :not(), donc un simple .figli-ht-col à une classe perdait systématiquement contre elle -- recombiné en .amount.figli-ht-col pour égaler/dépasser sa spécificité. --- .../custom/figli_compta_ledger/css/home.css | 16 ++++++++++++++ .../custom/figli_compta_ledger/js/home.js | 12 +++++++++++ .../templates/figli-compta-home.html.twig | 21 +++++++++++-------- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/web/modules/custom/figli_compta_ledger/css/home.css b/web/modules/custom/figli_compta_ledger/css/home.css index fcd0174..eed4eb8 100644 --- a/web/modules/custom/figli_compta_ledger/css/home.css +++ b/web/modules/custom/figli_compta_ledger/css/home.css @@ -444,6 +444,22 @@ html.gin--dark-mode #figli-home-app { width: 6.2%; white-space: nowrap; } +/* HT/TTC narrower than the general .amount rule above (still used by + Écart) -- shorter header text (HT/TTC vs. the old Montant HT/Montant + TTC) and TVA splitting the row between them means neither needs as + much room. TVA itself narrower still: "12,64 %" is the longest + realistic value (see figli_compta_ledger_update_8005()'s docblock on + backfilled non-round rates), well short of an 8-figure amount. + `.amount` doubled up in the selector (not just .figli-ht-col alone): + :not(.compte-col) in the rule above counts toward specificity same as + a real class, so a single-class selector here would lose to it. */ +#figli-home-app .amount.figli-ht-col, +#figli-home-app .amount.figli-ttc-col { + width: 5%; +} +#figli-home-app .amount.figli-tva-col { + width: 3.5%; +} #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 0f50d00..6084ec3 100644 --- a/web/modules/custom/figli_compta_ledger/js/home.js +++ b/web/modules/custom/figli_compta_ledger/js/home.js @@ -22,6 +22,10 @@ const API_BASE = '/jsonapi/node/ligne_comptable'; const EUR = new Intl.NumberFormat('fr-FR', { style: 'currency', currency: 'EUR' }); + // Not style: 'percent' -- that expects a fraction (0.10) and field_tva + // 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 }); const MONTHS = ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre']; const TYPE_LABELS = { entree: 'Entrée client', @@ -365,6 +369,7 @@ facture: attrs.field_numero_facture || null, libelle: attrs.field_notes || attrs.title, montant_ht: montantHt, + tva: attrs.field_tva !== null && attrs.field_tva !== undefined ? parseFloat(attrs.field_tva) : null, montant_ttc: attrs.field_montant_ttc !== null && attrs.field_montant_ttc !== undefined ? parseFloat(attrs.field_montant_ttc) : null, parCompte, somme, @@ -668,6 +673,13 @@ formatEur(v) { return v === null || v === undefined ? '' : EUR.format(v); }, + // Historical lines can carry a backfilled, non-round rate (e.g. + // 12.6414 -- see figli_compta_ledger_update_8005()'s docblock for + // why); rounded to 2 decimals for display, same as every amount + // column here, rather than showing the full stored precision. + formatPct(v) { + return v === null || v === undefined ? '' : PCT.format(v) + ' %'; + }, // É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 24ba261..8de72aa 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 @@ -128,21 +128,22 @@ Facture Libellé / Détail Signalement - Montant HT - Montant TTC + HT + TVA + TTC {{ c }} Écart - + Chargement des mois précédents… - + Chargement des mois suivants… @@ -258,8 +260,9 @@ Solde {{ currentYear || '…' }} (créditeur / débiteur) chargement… - {{ currentYearTotals ? formatEur(currentYearTotals.montant_ht) : '' }} - {{ currentYearTotals ? formatEur(currentYearTotals.montant_ttc) : '' }} + {{ currentYearTotals ? formatEur(currentYearTotals.montant_ht) : '' }} + + {{ currentYearTotals ? formatEur(currentYearTotals.montant_ttc) : '' }} {{ currentYearTotals && currentYearTotals.par_compte[c] !== undefined ? formatEur(currentYearTotals.par_compte[c]) : '' }} {{ currentYearTotals ? formatEur(currentYearTotals.ecart) : '' }}