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 @@