Badge sur les taux TVA non officiels, écart positif en vert

- 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.
This commit is contained in:
2026-09-07 14:45:06 +02:00
parent 0baa03855b
commit 6576b35c07
3 changed files with 44 additions and 5 deletions
@@ -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