feat: carte répartition par type de jour dans le rapport
This commit is contained in:
@@ -4,6 +4,7 @@ import sqlalchemy as sa
|
|||||||
from app import db
|
from app import db
|
||||||
from app.models import WorkEntry
|
from app.models import WorkEntry
|
||||||
from app.business.travel_calc import compute_km_for_entry, compute_co2_grams, compute_frais_reels
|
from app.business.travel_calc import compute_km_for_entry, compute_co2_grams, compute_frais_reels
|
||||||
|
from app.business.time_calc import count_day_types
|
||||||
from app.config_loader import get_vehicles, get_journeys, get_bareme
|
from app.config_loader import get_vehicles, get_journeys, get_bareme
|
||||||
|
|
||||||
bp = Blueprint("reports", __name__, url_prefix="/reports")
|
bp = Blueprint("reports", __name__, url_prefix="/reports")
|
||||||
@@ -39,6 +40,8 @@ def index():
|
|||||||
electric = vehicle.get("fuel") == "electric"
|
electric = vehicle.get("fuel") == "electric"
|
||||||
frais_reels[vehicle_id] = round(compute_frais_reels(km, tranches, electric=electric), 2)
|
frais_reels[vehicle_id] = round(compute_frais_reels(km, tranches, electric=electric), 2)
|
||||||
|
|
||||||
|
day_type_counts = count_day_types(entries)
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"reports.html",
|
"reports.html",
|
||||||
year=year,
|
year=year,
|
||||||
@@ -46,4 +49,5 @@ def index():
|
|||||||
total_co2_kg=round(total_co2 / 1000, 2),
|
total_co2_kg=round(total_co2 / 1000, 2),
|
||||||
frais_reels=frais_reels,
|
frais_reels=frais_reels,
|
||||||
vehicles=vehicles,
|
vehicles=vehicles,
|
||||||
|
day_type_counts=day_type_counts,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -59,4 +59,23 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Répartition par type de jour -->
|
||||||
|
<div class="card card-amber">
|
||||||
|
<p class="card-label">Répartition {{ year }}</p>
|
||||||
|
{% if day_type_counts %}
|
||||||
|
<div class="space-y-2 mt-1">
|
||||||
|
{% for day_type, count in day_type_counts.items() %}
|
||||||
|
<div class="flex items-baseline justify-between">
|
||||||
|
<span class="text-xs" style="color:#8A8278;">{{ day_type | day_type_fr }}</span>
|
||||||
|
<span class="font-data font-semibold text-sm" style="color:var(--ink);">
|
||||||
|
{{ count }}<span class="font-normal text-xs ml-1" style="color:#9A9288;">j</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<p class="text-sm" style="color:#9A9288;">Aucune entrée pour {{ year }}.</p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user