diff --git a/project/templates/project/components/dashboard/consommation.html b/project/templates/project/components/dashboard/consommation.html
index b64a17ef2..a1351f5fb 100644
--- a/project/templates/project/components/dashboard/consommation.html
+++ b/project/templates/project/components/dashboard/consommation.html
@@ -139,38 +139,7 @@
Calcul
Données brutes, sans calcul
Données
-
-
-
-
-
-
- Consommation d'espace annuelle sur le territoire par destination (en ha)
-
-
-
- Destination |
- {% for year in project.years %}
- {{ year }} |
- {% endfor %}
- Total |
-
-
-
- {% for determinant_name, data in data_determinant.items %}
-
- {{ determinant_name }} |
- {% for year, val in data.items %}
- +{{ val|floatformat:1 }} |
- {% endfor %}
-
- {% endfor %}
-
-
-
-
-
-
+ {{ determinant_data_table }}
diff --git a/project/views/report.py b/project/views/report.py
index 6393c3054..6d5fffec0 100644
--- a/project/views/report.py
+++ b/project/views/report.py
@@ -34,6 +34,9 @@
from public_data.domain.impermeabilisation.difference.ImperSolTableMapper import (
ImperSolTableMapper,
)
+from public_data.infra.consommation.progression.table.ConsoByDeterminantTableMapper import (
+ ConsoByDeterminantTableMapper,
+)
from public_data.infra.consommation.progression.table.ConsoComparisonTableMapper import (
ConsoComparisonMapper,
)
@@ -171,7 +174,15 @@ def get_context_data(self, **kwargs):
"population_conso_comparison_chart": charts.PopulationConsoComparisonChart(project),
# data tables
"annual_conso_data_table": annual_conso_data_table,
- "data_determinant": add_total_line_column(det_chart.get_series()),
+ "determinant_data_table": ConsoByDeterminantTableMapper.map(
+ consommation_progression=PublicDataContainer.consommation_progression_service()
+ .get_by_land(
+ land=project.land_proxy,
+ start_date=int(project.analyse_start_date),
+ end_date=int(project.analyse_end_date),
+ )
+ .consommation
+ ),
"comparison_table": ConsoComparisonMapper.map(
consommation_progression=PublicDataContainer.consommation_progression_service().get_by_lands(
lands=project.comparison_lands_and_self_land(),
diff --git a/public_data/infra/consommation/progression/table/ConsoByDeterminantTableMapper.py b/public_data/infra/consommation/progression/table/ConsoByDeterminantTableMapper.py
new file mode 100644
index 000000000..9345170c6
--- /dev/null
+++ b/public_data/infra/consommation/progression/table/ConsoByDeterminantTableMapper.py
@@ -0,0 +1,44 @@
+from django.template.loader import render_to_string
+
+from public_data.domain.consommation.entity import ConsommationCollection
+
+
+class ConsoByDeterminantTableMapper:
+ @staticmethod
+ def map(consommation_progression: list[ConsommationCollection]):
+ category_to_attr = {
+ "Habitat": "habitat",
+ "Activité": "activite",
+ "Mixte": "mixte",
+ "Route": "route",
+ "Ferré": "ferre",
+ "Inconnu": "non_reseigne",
+ "Total": "total",
+ }
+
+ headers = ["Destination"] + [str(conso.year) for conso in consommation_progression] + ["Total"]
+
+ data = []
+ for category in category_to_attr:
+ category_values = [getattr(conso, category_to_attr[category]) for conso in consommation_progression]
+ category_total = sum(category_values)
+ # On arrondit ensuite pour ne pas fausser le total
+ category_values_rounded = [round(value, 2) for value in category_values]
+ category_total_rounded = round(category_total, 2)
+ data.append([category] + category_values_rounded + [category_total_rounded])
+
+ return render_to_string(
+ "public_data/partials/conso_by_determinant_table.html",
+ {
+ "headers": headers,
+ "data": data,
+ },
+ )
+
+ return render_to_string(
+ "public_data/partials/conso_by_determinant_table.html",
+ {
+ "headers": headers,
+ "data": data,
+ },
+ )
diff --git a/public_data/templates/public_data/partials/conso_by_determinant_table.html b/public_data/templates/public_data/partials/conso_by_determinant_table.html
new file mode 100644
index 000000000..1ba98cfc3
--- /dev/null
+++ b/public_data/templates/public_data/partials/conso_by_determinant_table.html
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+ Consommation d'espaces NAF sur le territoire par an et par destination (en ha)
+
+
+
+ {% for header in headers %}
+
+ {{ header }}
+ |
+ {% endfor %}
+
+
+
+ {% for row in data %}
+
+ {% for cell in row %}
+
+ {{ cell }}
+ |
+ {% endfor %}
+
+ {% endfor %}
+
+
+
+
+
+