feat: compute_frais_reels supporte la majoration +20% électrique

This commit is contained in:
2026-03-11 20:04:47 +01:00
parent d9ad854ede
commit 0362836a63
2 changed files with 30 additions and 11 deletions

View File

@@ -16,10 +16,16 @@ JOURNEYS = {
"velo_seul": {"distances": {"velo": 24}},
}
TRANCHES_CV3 = [
{"km_max": 5000, "taux": 0.529, "forfait": 0},
{"km_max": 20000, "taux": 0.316, "forfait": 1065},
{"km_max": 0, "taux": 0.370, "forfait": 0},
]
TRANCHES_CV5 = [
{"km_max": 3000, "taux": 0.548, "forfait": 0},
{"km_max": 6000, "taux": 0.316, "forfait": 699},
{"km_max": 0, "taux": 0.364, "forfait": 0},
{"km_max": 5000, "taux": 0.636, "forfait": 0},
{"km_max": 20000, "taux": 0.357, "forfait": 1395},
{"km_max": 0, "taux": 0.427, "forfait": 0},
]
@@ -61,14 +67,24 @@ def test_compute_co2_velo():
def test_frais_reels_tranche1():
result = compute_frais_reels(2000, TRANCHES_CV5)
assert abs(result - 1096.0) < 0.01
assert abs(result - 1272.0) < 0.01 # 2000 × 0.636
def test_frais_reels_tranche2():
result = compute_frais_reels(4000, TRANCHES_CV5)
assert abs(result - 1963.0) < 0.01
result = compute_frais_reels(10000, TRANCHES_CV5)
assert abs(result - 4965.0) < 0.01 # 10000 × 0.357 + 1395
def test_frais_reels_tranche3():
result = compute_frais_reels(7000, TRANCHES_CV5)
assert abs(result - 2548.0) < 0.01
result = compute_frais_reels(25000, TRANCHES_CV5)
assert abs(result - 10675.0) < 0.01 # 25000 × 0.427
def test_frais_reels_electrique_majoration_20_pct():
result = compute_frais_reels(2000, TRANCHES_CV3, electric=True)
assert abs(result - 1269.6) < 0.01 # 2000 × 0.529 × 1.2
def test_frais_reels_non_electrique_sans_majoration():
result = compute_frais_reels(2000, TRANCHES_CV3, electric=False)
assert abs(result - 1058.0) < 0.01 # 2000 × 0.529