From c5c63cb68ec9820d4bb2bbb739328e9aa4832861 Mon Sep 17 00:00:00 2001 From: Colin Maudry Date: Sat, 4 Jul 2026 23:28:14 +0200 Subject: [PATCH] =?UTF-8?q?fix(abonnement):=20calcul=20du=20prix=20TTC=20r?= =?UTF-8?q?obuste=20(=C3=A9vite=20les=20artefacts=20flottants)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remplace le hack `str(int(prix_ht) * 1.2).replace('.0', '')` par `round(prix_ht * 1.2, 2)` formaté avec `:g`, qui gère correctement les prix qui ne multiplient pas proprement par 1.2 (ex: 24 -> 28.8 au lieu de 28.799999999999997). Le fichier src/pages/compte/abonnement.py contient le même bug mais n'est pas touché ici : sa copie de _plan_card sera supprimée à la tâche 4 du plan de refonte du tunnel d'abonnement. Co-Authored-By: Claude Sonnet 5 --- src/pages/a_propos/abonnement.py | 2 +- tests/test_abonnement_public.py | 47 ++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/pages/a_propos/abonnement.py b/src/pages/a_propos/abonnement.py index 69f00a3..ddf8a1a 100644 --- a/src/pages/a_propos/abonnement.py +++ b/src/pages/a_propos/abonnement.py @@ -32,7 +32,7 @@ def _plan_card(meta: dict, trial: int | None): html.H4(meta["label"], className="mb-1"), html.P( f"{meta['prix_ht']} € HT / mois " - f"({str(int(meta['prix_ht']) * 1.2).replace('.0', '')} € TTC)", + f"({round(meta['prix_ht'] * 1.2, 2):g} € TTC)", className="text-muted mb-3", ), html.P(meta["description"], className="mb-3"), diff --git a/tests/test_abonnement_public.py b/tests/test_abonnement_public.py index 62e8f0c..0f8a18b 100644 --- a/tests/test_abonnement_public.py +++ b/tests/test_abonnement_public.py @@ -60,3 +60,50 @@ def test_cgu_terms_trimmed_of_features_section(): assert "Fonctionnalités incluses" not in text assert "Résiliation" in text assert "Tarifs" in text + + +def test_plan_card_ttc_price_for_current_real_prices(): + from src.app import app # noqa: F401 + from src.pages.a_propos import abonnement as page + + simple = str( + page._plan_card( + { + "label": "Abonnement", + "prix_ht": 20, + "description": "desc", + }, + None, + ) + ) + assert "24 € TTC" in simple + + soutien = str( + page._plan_card( + { + "label": "Abonnement de soutien", + "prix_ht": 50, + "description": "desc", + }, + None, + ) + ) + assert "60 € TTC" in soutien + + +def test_plan_card_ttc_price_avoids_float_artifacts(): + from src.app import app # noqa: F401 + from src.pages.a_propos import abonnement as page + + text = str( + page._plan_card( + { + "label": "Abonnement non-rond", + "prix_ht": 24, + "description": "desc", + }, + None, + ) + ) + assert "28.8 € TTC" in text + assert "28.799999999999997" not in text