feat: get_bareme par CV individuel, majoration électrique dans reports
This commit is contained in:
@@ -26,14 +26,16 @@ def journey_has_motor(journey_profile_id: str | None) -> bool:
|
|||||||
def get_bareme(year: int, cv: int) -> list[dict]:
|
def get_bareme(year: int, cv: int) -> list[dict]:
|
||||||
bareme = current_app.config.get("TOML", {}).get("bareme_kilometrique", {})
|
bareme = current_app.config.get("TOML", {}).get("bareme_kilometrique", {})
|
||||||
year_data = bareme.get(str(year), {})
|
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"
|
key = "cv_5"
|
||||||
elif cv <= 7:
|
elif cv == 6:
|
||||||
key = "cv_6_7"
|
key = "cv_6"
|
||||||
elif cv <= 9:
|
|
||||||
key = "cv_8_9"
|
|
||||||
else:
|
else:
|
||||||
key = "cv_10_11"
|
key = "cv_7plus"
|
||||||
return year_data.get(key, {}).get("tranches", [])
|
return year_data.get(key, {}).get("tranches", [])
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ def index():
|
|||||||
cv = vehicle.get("cv")
|
cv = vehicle.get("cv")
|
||||||
if cv:
|
if cv:
|
||||||
tranches = get_bareme(year, 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(
|
return render_template(
|
||||||
"reports.html",
|
"reports.html",
|
||||||
|
|||||||
Reference in New Issue
Block a user