from flask import current_app def get_vehicles(): return current_app.config.get("TOML", {}).get("vehicles", {}) def get_motor_vehicles(): """Retourne uniquement les véhicules de type 'moteur'.""" return {k: v for k, v in get_vehicles().items() if v.get("type") == "moteur"} def get_journeys(): return current_app.config.get("TOML", {}).get("journeys", {}) def journey_has_motor(journey_profile_id: str | None) -> bool: """Retourne True si le profil de trajet inclut un véhicule à moteur.""" if not journey_profile_id: return False journeys = get_journeys() profile = journeys.get(journey_profile_id, {}) return "moteur" in profile.get("distances", {}) 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 <= 3: key = "cv_3" elif cv == 4: key = "cv_4" elif cv == 5: key = "cv_5" elif cv == 6: key = "cv_6" else: key = "cv_7plus" return year_data.get(key, {}).get("tranches", []) def day_types_without_journey(): return {"TT", "MALADE", "CONGE", "RTT", "FERIE"}