diff --git a/analysis/settings.py b/analysis/settings.py
new file mode 100644
index 00000000..5ea5fadf
--- /dev/null
+++ b/analysis/settings.py
@@ -0,0 +1,12 @@
+"""
+Author: Michel Peltriaux
+Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
+Contact: michel.peltriaux@sgdnord.rlp.de
+Created on: 19.10.21
+
+"""
+
+import datetime
+
+# Defines the date of the legal publishing of the LKompVzVo
+LKOMPVZVO_PUBLISH_DATE = datetime.date.fromisoformat("2018-06-16")
diff --git a/analysis/templates/analysis/reports/detail.html b/analysis/templates/analysis/reports/detail.html
index f90acdaf..42322418 100644
--- a/analysis/templates/analysis/reports/detail.html
+++ b/analysis/templates/analysis/reports/detail.html
@@ -12,6 +12,6 @@
{% include 'analysis/reports/includes/intervention/card_intervention.html' %}
{% include 'analysis/reports/includes/compensation/card_compensation.html' %}
{% include 'analysis/reports/includes/card_eco_account.html' %}
- {% include 'analysis/reports/includes/card_old_interventions.html' %}
+ {% include 'analysis/reports/includes/old_intervention/card_old_interventions.html' %}
{% endblock %}
\ No newline at end of file
diff --git a/analysis/templates/analysis/reports/includes/old_intervention/amount.html b/analysis/templates/analysis/reports/includes/old_intervention/amount.html
new file mode 100644
index 00000000..5ab45a93
--- /dev/null
+++ b/analysis/templates/analysis/reports/includes/old_intervention/amount.html
@@ -0,0 +1,30 @@
+{% load i18n fontawesome_5 ksp_filters %}
+
+
- {% include 'form/table/generic_table_form_body.html' %}
+ {% include 'analysis/reports/includes/old_intervention/amount.html' %}
diff --git a/analysis/utils/report.py b/analysis/utils/report.py
index ce5d895a..12d0a46c 100644
--- a/analysis/utils/report.py
+++ b/analysis/utils/report.py
@@ -8,6 +8,7 @@ Created on: 18.10.21
from django.contrib.gis.db.models.functions import NumGeometries
from django.db.models import Count, Sum, Q
+from analysis.settings import LKOMPVZVO_PUBLISH_DATE
from codelist.models import KonovaCode
from codelist.settings import CODELIST_LAW_ID
from compensation.models import Compensation, Payment, EcoAccountDeduction
@@ -23,6 +24,7 @@ class TimespanReport:
queryset_checked = Intervention.objects.none()
queryset_recorded = Intervention.objects.none()
+
# Law related
law_sum = -1
law_sum_checked = -1
@@ -43,6 +45,7 @@ class TimespanReport:
def __init__(self, id: str):
self.queryset = Intervention.objects.filter(
responsible__conservation_office__id=id,
+ legal__registration_date__gt=LKOMPVZVO_PUBLISH_DATE,
deleted=None,
)
self.queryset_checked = self.queryset.filter(
@@ -157,6 +160,7 @@ class TimespanReport:
def __init__(self, id: str):
self.queryset = Compensation.objects.filter(
intervention__responsible__conservation_office__id=id,
+ intervention__legal__registration_date__gt=LKOMPVZVO_PUBLISH_DATE,
deleted=None,
)
self.queryset_checked = self.queryset.filter(
@@ -261,7 +265,26 @@ class TimespanReport:
intervention__checked__isnull=False,
)
+ class OldInterventionReport:
+ queryset = Compensation.objects.none()
+ queryset_checked = Compensation.objects.none()
+ queryset_recorded = Compensation.objects.none()
+
+ def __init__(self, id: str):
+ self.queryset = Intervention.objects.filter(
+ legal__registration_date__lte=LKOMPVZVO_PUBLISH_DATE,
+ responsible__conservation_office__id=id,
+ deleted=None,
+ )
+ self.queryset_checked = self.queryset.filter(
+ checked__isnull=False
+ )
+ self.queryset_recorded = self.queryset.filter(
+ recorded__isnull=False
+ )
+
def __init__(self, office_id: str):
self.office_id = office_id
self.intervention_report = self.InterventionReport(self.office_id)
self.compensation_report = self.CompensationReport(self.office_id)
+ self.old_intervention_report = self.OldInterventionReport(self.office_id)
diff --git a/analysis/views.py b/analysis/views.py
index 43dd061b..b7699719 100644
--- a/analysis/views.py
+++ b/analysis/views.py
@@ -31,23 +31,19 @@ def index_reports_view(request: HttpRequest):
def detail_report_view(request: HttpRequest, id: str):
+ """ Renders the detailed report for a conservation office
+
+ Args:
+ request (HttpRequest): The incoming request
+ id (str): The conservation_office KonovaCode id
+
+ Returns:
+
+ """
cons_office = get_object_or_404(
KonovaCode,
id=id,
)
- cons_interventions = Intervention.objects.filter(
- responsible__conservation_office__id=id,
- deleted=None,
- )
- cons_comps = Compensation.objects.filter(
- intervention__in=cons_interventions,
- deleted=None,
- )
- cons_eco_account = EcoAccount.objects.filter(
- responsible__conservation_office__id=id,
- deleted=None,
- )
-
report = TimespanReport(id)
template = "analysis/reports/detail.html"