feat: get_bareme par CV individuel, majoration électrique dans reports

This commit is contained in:
2026-03-11 20:06:54 +01:00
parent 0362836a63
commit 51673f4959
2 changed files with 10 additions and 7 deletions

View File

@@ -26,14 +26,16 @@ def journey_has_motor(journey_profile_id: str | None) -> bool:
def get_bareme(year: int, cv: int) -> list[dict]:
bareme = current_app.config.get("TOML", {}).get("bareme_kilometrique", {})
year_data = bareme.get(str(year), {})
if cv <= 5:
if cv <= 3:
key = "cv_3"
elif cv == 4:
key = "cv_4"
elif cv == 5:
key = "cv_5"
elif cv <= 7:
key = "cv_6_7"
elif cv <= 9:
key = "cv_8_9"
elif cv == 6:
key = "cv_6"
else:
key = "cv_10_11"
key = "cv_7plus"
return year_data.get(key, {}).get("tranches", [])

View File

@@ -36,7 +36,8 @@ def index():
cv = vehicle.get("cv")
if cv:
tranches = get_bareme(year, cv)
frais_reels[vehicle_id] = round(compute_frais_reels(km, tranches), 2)
electric = vehicle.get("fuel") == "electric"
frais_reels[vehicle_id] = round(compute_frais_reels(km, tranches, electric=electric), 2)
return render_template(
"reports.html",