#26 Annual conservation report
* enhancements for report2excel functionality * improvements for report2html layout +
This commit is contained in:
parent
9c523a0a0c
commit
c7b22592de
@ -31,6 +31,6 @@
|
||||
{% include 'analysis/reports/includes/intervention/card_intervention.html' %}
|
||||
{% include 'analysis/reports/includes/compensation/card_compensation.html' %}
|
||||
{% include 'analysis/reports/includes/eco_account/card_eco_account.html' %}
|
||||
{% include 'analysis/reports/includes/old_intervention/card_old_interventions.html' %}
|
||||
{% include 'analysis/reports/includes/old_data/card_old_interventions.html' %}
|
||||
</div>
|
||||
{% endblock %}
|
@ -2,10 +2,6 @@
|
||||
|
||||
<h3>{% trans 'Amount' %}</h3>
|
||||
<strong>
|
||||
{% blocktrans %}
|
||||
Checked = Has been checked by the registration office according to LKompVzVo
|
||||
{% endblocktrans %}
|
||||
<br>
|
||||
{% blocktrans %}
|
||||
Recorded = Has been checked and published by the conservation office
|
||||
{% endblocktrans %}
|
||||
@ -14,18 +10,14 @@
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">{% trans 'Before' %} LKompVzVo</th>
|
||||
<th scope="col">{% trans 'After' %} LKompVzVo</th>
|
||||
<th scope="col">{% fa5_icon 'bookmark' %} {% trans 'Recorded' %}</th>
|
||||
<th scope="col" class="w-25">{% trans 'Total' %}</th>
|
||||
<th scope="col" class="w-25">{% fa5_icon 'bookmark' %} {% trans 'Recorded' %}</th>
|
||||
<th scope="col">{% trans 'Total' %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{{report.eco_account_report.queryset_old_count|default_if_zero:"-"}}</td>
|
||||
<td>{{report.eco_account_report.queryset_count|default_if_zero:"-"}}</td>
|
||||
<td>{{report.eco_account_report.queryset_recorded_count|default_if_zero:"-"}}</td>
|
||||
<td>{{report.eco_account_report.queryset_total_count|default_if_zero:"-"}}</td>
|
||||
<td>{{report.eco_account_report.queryset_count|default_if_zero:"-"}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -0,0 +1,40 @@
|
||||
{% load i18n fontawesome_5 ksp_filters %}
|
||||
|
||||
<h3>{% trans 'Amount' %}</h3>
|
||||
<strong>
|
||||
{% blocktrans %}
|
||||
Checked = Has been checked by the registration office according to LKompVzVo
|
||||
{% endblocktrans %}
|
||||
<br>
|
||||
{% blocktrans %}
|
||||
Recorded = Has been checked and published by the conservation office
|
||||
{% endblocktrans %}
|
||||
</strong>
|
||||
<div class="table-container">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="w-25">{% fa5_icon 'star' %} {% trans 'Type' %}</th>
|
||||
<th scope="col">{% fa5_icon 'bookmark' %} {% trans 'Recorded' %}</th>
|
||||
<th scope="col">{% trans 'Total' %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{% trans 'Intervention' %}</td>
|
||||
<td>{{report.old_data_report.queryset_intervention_recorded_count|default_if_zero:"-"}}</td>
|
||||
<td>{{report.old_data_report.queryset_intervention_count|default_if_zero:"-"}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans 'Compensation' %}</td>
|
||||
<td>{{report.old_data_report.queryset_comps_recorded_count|default_if_zero:"-"}}</td>
|
||||
<td>{{report.old_data_report.queryset_comps_count|default_if_zero:"-"}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans 'Eco-account' %}</td>
|
||||
<td>{{report.old_data_report.queryset_acc_recorded_count|default_if_zero:"-"}}</td>
|
||||
<td>{{report.old_data_report.queryset_acc_count|default_if_zero:"-"}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
@ -16,7 +16,7 @@
|
||||
</div>
|
||||
<div id="oldInterventionBody" class="collapse" aria-labelledby="oldIntervention">
|
||||
<div class="card-body">
|
||||
{% include 'analysis/reports/includes/old_intervention/amount.html' %}
|
||||
{% include 'analysis/reports/includes/old_data/amount.html' %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -1,30 +0,0 @@
|
||||
{% load i18n fontawesome_5 ksp_filters %}
|
||||
|
||||
<h3>{% trans 'Amount' %}</h3>
|
||||
<strong>
|
||||
{% blocktrans %}
|
||||
Checked = Has been checked by the registration office according to LKompVzVo
|
||||
{% endblocktrans %}
|
||||
<br>
|
||||
{% blocktrans %}
|
||||
Recorded = Has been checked and published by the conservation office
|
||||
{% endblocktrans %}
|
||||
</strong>
|
||||
<div class="table-container">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">{% fa5_icon 'star' %} {% trans 'Checked' %}</th>
|
||||
<th scope="col">{% fa5_icon 'bookmark' %} {% trans 'Recorded' %}</th>
|
||||
<th scope="col" class="w-25">{% trans 'Total' %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{{report.old_intervention_report.queryset_checked_count|default_if_zero:"-"}}</td>
|
||||
<td>{{report.old_intervention_report.queryset_recorded_count|default_if_zero:"-"}}</td>
|
||||
<td>{{report.old_intervention_report.queryset_count|default_if_zero:"-"}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
@ -47,28 +47,30 @@ class TempExcelFile:
|
||||
Returns:
|
||||
|
||||
"""
|
||||
ws = self._workbook.active
|
||||
# Always activate sheet protection
|
||||
ws.protection.sheet = True
|
||||
ws.protection.enable()
|
||||
_rows = ws.iter_rows(start_row)
|
||||
for row in _rows:
|
||||
for cell in row:
|
||||
val = cell.value
|
||||
if val in self._template_map:
|
||||
attr = self._template_map[val]
|
||||
# If keyword '_iter' can be found inside the placeholder value it's an iterable and we
|
||||
# need to process it differently
|
||||
if isinstance(attr, dict):
|
||||
# Read the iterable object and related attributes from the dict
|
||||
_iter_obj = attr.get("iterable", None)
|
||||
_attrs = attr.get("attrs", [])
|
||||
self._add_cells_from_iterable(ws, cell, _iter_obj, _attrs)
|
||||
# Since the sheet length did change now, we need to rerun this function starting with the new
|
||||
# row counter
|
||||
self._replace_template_placeholders(start_row=cell.row + len(_iter_obj))
|
||||
else:
|
||||
cell.value = attr
|
||||
sheets = self._workbook.worksheets
|
||||
for sheet in sheets:
|
||||
ws = sheet
|
||||
# Always activate sheet protection
|
||||
ws.protection.sheet = True
|
||||
ws.protection.enable()
|
||||
_rows = ws.iter_rows(start_row)
|
||||
for row in _rows:
|
||||
for cell in row:
|
||||
val = cell.value
|
||||
if val in self._template_map:
|
||||
attr = self._template_map[val]
|
||||
# If keyword '_iter' can be found inside the placeholder value it's an iterable and we
|
||||
# need to process it differently
|
||||
if isinstance(attr, dict):
|
||||
# Read the iterable object and related attributes from the dict
|
||||
_iter_obj = attr.get("iterable", None)
|
||||
_attrs = attr.get("attrs", [])
|
||||
self._add_cells_from_iterable(ws, cell, _iter_obj, _attrs)
|
||||
# Since the sheet length did change now, we need to rerun this function starting with the new
|
||||
# row counter
|
||||
self._replace_template_placeholders(start_row=cell.row + len(_iter_obj))
|
||||
else:
|
||||
cell.value = attr
|
||||
self._workbook.save(self._file.name)
|
||||
self._file.seek(0)
|
||||
self.stream = self._file.read()
|
||||
|
Binary file not shown.
@ -379,14 +379,10 @@ class TimespanReport:
|
||||
self.queryset_registration_office_other_recorded_count = self.queryset_registration_office_other_recorded.count()
|
||||
|
||||
class EcoAccountReport:
|
||||
queryset_total = EcoAccount.objects.none()
|
||||
queryset = EcoAccount.objects.none()
|
||||
queryset_recorded = EcoAccount.objects.none()
|
||||
queryset_old = EcoAccount.objects.none()
|
||||
queryset_total_count = -1
|
||||
queryset_count = -1
|
||||
queryset_recorded_count = -1
|
||||
queryset_old_count = -1
|
||||
|
||||
queryset_deductions = EcoAccountDeduction.objects.none()
|
||||
queryset_deductions_recorded = EcoAccountDeduction.objects.none()
|
||||
@ -401,23 +397,15 @@ class TimespanReport:
|
||||
|
||||
def __init__(self, id: str, date_from: str, date_to: str):
|
||||
# First fetch all eco account for this office
|
||||
self.queryset_total = EcoAccount.objects.filter(
|
||||
self.queryset = EcoAccount.objects.filter(
|
||||
responsible__conservation_office__id=id,
|
||||
deleted=None,
|
||||
created__timestamp__gte=date_from,
|
||||
created__timestamp__lte=date_to,
|
||||
)
|
||||
self.queryset_recorded = self.queryset_total.filter(
|
||||
self.queryset_recorded = self.queryset.filter(
|
||||
recorded__isnull=False
|
||||
)
|
||||
# Then fetch the old ones (pre-LKompVzVo)
|
||||
self.queryset_old = self.queryset_total.filter(
|
||||
recorded__timestamp__lte=LKOMPVZVO_PUBLISH_DATE,
|
||||
)
|
||||
# Then fetch the default queryset with the new ones (post-LKompVzVo)
|
||||
self.queryset = self.queryset_total.filter(
|
||||
recorded__timestamp__gte=LKOMPVZVO_PUBLISH_DATE,
|
||||
)
|
||||
# Fetch all related deductions
|
||||
self.queryset_deductions = EcoAccountDeduction.objects.filter(
|
||||
account__id__in=self.queryset.values_list("id")
|
||||
@ -427,15 +415,29 @@ class TimespanReport:
|
||||
intervention__recorded__isnull=False
|
||||
)
|
||||
|
||||
self.queryset_total_count = self.queryset_total.count()
|
||||
self.queryset_count = self.queryset.count()
|
||||
self.queryset_old_count = self.queryset_old.count()
|
||||
self.queryset_recorded = self.queryset_recorded.count()
|
||||
self.queryset_recorded_count = self.queryset_recorded.count()
|
||||
self.queryset_deductions_count = self.queryset_deductions.count()
|
||||
self.queryset_deductions_recorded_count = self.queryset_deductions_recorded.count()
|
||||
self.queryset_has_deductions_count = self.queryset_has_deductions.count()
|
||||
|
||||
self._create_report()
|
||||
self._define_excel_map()
|
||||
|
||||
def _define_excel_map(self):
|
||||
""" Define the excel map, which holds values for each placeholder used in the template
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
self.excel_map = {
|
||||
"acc_total": self.queryset_count,
|
||||
"acc_recorded": self.queryset_recorded_count,
|
||||
"acc_deduc_recorded": self.queryset_deductions_recorded_count,
|
||||
"acc_deduc_surface_recorded": self.recorded_deductions_sq_m,
|
||||
"acc_deduc_total": self.queryset_deductions_count,
|
||||
"acc_deduc_surface_total": self.deductions_sq_m,
|
||||
}
|
||||
|
||||
def _create_report(self):
|
||||
""" Creates all report information
|
||||
@ -453,32 +455,76 @@ class TimespanReport:
|
||||
sum=Sum("surface")
|
||||
)["sum"] or 0
|
||||
|
||||
class OldInterventionReport:
|
||||
queryset = Compensation.objects.none()
|
||||
queryset_checked = Compensation.objects.none()
|
||||
queryset_recorded = Compensation.objects.none()
|
||||
class OldDataReport:
|
||||
"""
|
||||
Evaluates 'old data' (registered (zugelassen) before 16.06.2018)
|
||||
"""
|
||||
queryset_intervention = Intervention.objects.none()
|
||||
queryset_intervention_recorded = Intervention.objects.none()
|
||||
queryset_intervention_count = -1
|
||||
queryset_intervention_recorded_count = -1
|
||||
|
||||
queryset_count = -1
|
||||
queryset_checked_count = -1
|
||||
queryset_recorded_count = -1
|
||||
queryset_comps = Compensation.objects.none()
|
||||
queryset_comps_recorded = Compensation.objects.none()
|
||||
queryset_comps_count = -1
|
||||
queryset_comps_recorded_count = -1
|
||||
|
||||
queryset_acc = EcoAccount.objects.none()
|
||||
queryset_acc_recorded = EcoAccount.objects.none()
|
||||
queryset_acc_count = -1
|
||||
queryset_acc_recorded_count = -1
|
||||
|
||||
def __init__(self, id: str, date_from: str, date_to: str):
|
||||
self.queryset = Intervention.objects.filter(
|
||||
self.queryset_intervention = Intervention.objects.filter(
|
||||
legal__registration_date__lte=LKOMPVZVO_PUBLISH_DATE,
|
||||
responsible__conservation_office__id=id,
|
||||
deleted=None,
|
||||
created__timestamp__gte=date_from,
|
||||
created__timestamp__lte=date_to,
|
||||
)
|
||||
self.queryset_checked = self.queryset.filter(
|
||||
checked__isnull=False
|
||||
)
|
||||
self.queryset_recorded = self.queryset.filter(
|
||||
self.queryset_intervention_recorded = self.queryset_intervention.filter(
|
||||
recorded__isnull=False
|
||||
)
|
||||
self.queryset_count = self.queryset.count()
|
||||
self.queryset_checked = self.queryset_checked.count()
|
||||
self.queryset_recorded = self.queryset_recorded.count()
|
||||
self.queryset_intervention_count = self.queryset_intervention.count()
|
||||
self.queryset_intervention_recorded_count = self.queryset_intervention_recorded.count()
|
||||
|
||||
self.queryset_comps = Compensation.objects.filter(
|
||||
intervention__in=self.queryset_intervention
|
||||
)
|
||||
self.queryset_comps_recorded = Compensation.objects.filter(
|
||||
intervention__in=self.queryset_intervention_recorded,
|
||||
)
|
||||
self.queryset_comps_count = self.queryset_comps.count()
|
||||
self.queryset_comps_recorded_count = self.queryset_comps_recorded.count()
|
||||
|
||||
self.queryset_acc = EcoAccount.objects.filter(
|
||||
#legal__registration_date__lte=LKOMPVZVO_PUBLISH_DATE,
|
||||
responsible__conservation_office__id=id,
|
||||
deleted=None,
|
||||
created__timestamp__gte=date_from,
|
||||
created__timestamp__lte=date_to,
|
||||
)
|
||||
self.queryset_acc_recorded = self.queryset_acc.filter(
|
||||
recorded__isnull=False,
|
||||
)
|
||||
self.queryset_acc_count = self.queryset_acc.count()
|
||||
self.queryset_acc_recorded_count = self.queryset_acc_recorded.count()
|
||||
self._define_excel_map()
|
||||
|
||||
def _define_excel_map(self):
|
||||
""" Define the excel map, which holds values for each placeholder used in the template
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
self.excel_map = {
|
||||
"old_i_recorded": self.queryset_intervention_recorded_count,
|
||||
"old_i_total": self.queryset_intervention_count,
|
||||
"old_c_recorded": self.queryset_comps_recorded_count,
|
||||
"old_c_total": self.queryset_comps_count,
|
||||
"old_ea_recorded": self.queryset_acc_recorded_count,
|
||||
"old_ea_total": self.queryset_acc_count,
|
||||
}
|
||||
|
||||
def __init__(self, office_id: str, date_from: str, date_to: str):
|
||||
self.office_id = office_id
|
||||
@ -488,7 +534,7 @@ class TimespanReport:
|
||||
self.intervention_report = self.InterventionReport(self.office_id, date_from, date_to)
|
||||
self.compensation_report = self.CompensationReport(self.office_id, date_from, date_to)
|
||||
self.eco_account_report = self.EcoAccountReport(self.office_id, date_from, date_to)
|
||||
self.old_intervention_report = self.OldInterventionReport(self.office_id, date_from, date_to)
|
||||
self.old_data_report = self.OldDataReport(self.office_id, date_from, date_to)
|
||||
|
||||
# Build excel map
|
||||
self.excel_map = {
|
||||
@ -497,3 +543,5 @@ class TimespanReport:
|
||||
}
|
||||
self.excel_map.update(self.intervention_report.excel_map)
|
||||
self.excel_map.update(self.compensation_report.excel_map)
|
||||
self.excel_map.update(self.eco_account_report.excel_map)
|
||||
self.excel_map.update(self.old_data_report.excel_map)
|
||||
|
@ -77,7 +77,7 @@ msgstr "bis"
|
||||
#: analysis/templates/analysis/reports/includes/compensation/amount.html:3
|
||||
#: analysis/templates/analysis/reports/includes/eco_account/amount.html:3
|
||||
#: analysis/templates/analysis/reports/includes/intervention/amount.html:3
|
||||
#: analysis/templates/analysis/reports/includes/old_intervention/amount.html:3
|
||||
#: analysis/templates/analysis/reports/includes/old_data/amount.html:3
|
||||
#: compensation/forms/modalForms.py:351
|
||||
#: compensation/templates/compensation/detail/eco_account/includes/deductions.html:34
|
||||
#: intervention/templates/intervention/detail/includes/deductions.html:31
|
||||
@ -87,7 +87,7 @@ msgstr "Menge"
|
||||
#: analysis/templates/analysis/reports/includes/compensation/amount.html:5
|
||||
#: analysis/templates/analysis/reports/includes/eco_account/amount.html:5
|
||||
#: analysis/templates/analysis/reports/includes/intervention/amount.html:5
|
||||
#: analysis/templates/analysis/reports/includes/old_intervention/amount.html:5
|
||||
#: analysis/templates/analysis/reports/includes/old_data/amount.html:5
|
||||
msgid ""
|
||||
"\n"
|
||||
" Checked = Has been checked by the registration office according to "
|
||||
@ -101,7 +101,7 @@ msgstr ""
|
||||
#: analysis/templates/analysis/reports/includes/compensation/amount.html:9
|
||||
#: analysis/templates/analysis/reports/includes/eco_account/amount.html:9
|
||||
#: analysis/templates/analysis/reports/includes/intervention/amount.html:9
|
||||
#: analysis/templates/analysis/reports/includes/old_intervention/amount.html:9
|
||||
#: analysis/templates/analysis/reports/includes/old_data/amount.html:9
|
||||
msgid ""
|
||||
"\n"
|
||||
" Recorded = Has been checked and published by the conservation office\n"
|
||||
@ -120,7 +120,7 @@ msgstr "Zuständigkeitsbereich"
|
||||
#: analysis/templates/analysis/reports/includes/intervention/amount.html:17
|
||||
#: analysis/templates/analysis/reports/includes/intervention/compensated_by.html:8
|
||||
#: analysis/templates/analysis/reports/includes/intervention/laws.html:17
|
||||
#: analysis/templates/analysis/reports/includes/old_intervention/amount.html:17
|
||||
#: analysis/templates/analysis/reports/includes/old_data/amount.html:17
|
||||
#: compensation/tables.py:35
|
||||
#: compensation/templates/compensation/detail/compensation/view.html:43
|
||||
#: intervention/tables.py:33
|
||||
@ -135,7 +135,7 @@ msgstr "Geprüft"
|
||||
#: analysis/templates/analysis/reports/includes/intervention/amount.html:18
|
||||
#: analysis/templates/analysis/reports/includes/intervention/compensated_by.html:9
|
||||
#: analysis/templates/analysis/reports/includes/intervention/laws.html:20
|
||||
#: analysis/templates/analysis/reports/includes/old_intervention/amount.html:18
|
||||
#: analysis/templates/analysis/reports/includes/old_data/amount.html:18
|
||||
#: compensation/tables.py:41 compensation/tables.py:181
|
||||
#: compensation/templates/compensation/detail/compensation/view.html:57
|
||||
#: compensation/templates/compensation/detail/eco_account/includes/deductions.html:31
|
||||
@ -159,7 +159,7 @@ msgstr "Einzelflächen"
|
||||
#: analysis/templates/analysis/reports/includes/intervention/compensated_by.html:10
|
||||
#: analysis/templates/analysis/reports/includes/intervention/laws.html:23
|
||||
#: analysis/templates/analysis/reports/includes/intervention/laws.html:43
|
||||
#: analysis/templates/analysis/reports/includes/old_intervention/amount.html:19
|
||||
#: analysis/templates/analysis/reports/includes/old_data/amount.html:19
|
||||
#: konova/templates/konova/home.html:23 konova/templates/konova/home.html:61
|
||||
#: konova/templates/konova/home.html:100
|
||||
msgid "Total"
|
||||
@ -185,7 +185,7 @@ msgid "Compensations"
|
||||
msgstr "Kompensationen"
|
||||
|
||||
#: analysis/templates/analysis/reports/includes/eco_account/amount.html:17
|
||||
#: analysis/templates/analysis/reports/includes/old_intervention/card_old_interventions.html:13
|
||||
#: analysis/templates/analysis/reports/includes/old_data/card_old_interventions.html:13
|
||||
msgid "Before"
|
||||
msgstr "Vor"
|
||||
|
||||
@ -265,7 +265,7 @@ msgstr ""
|
||||
msgid "Law"
|
||||
msgstr "Gesetz"
|
||||
|
||||
#: analysis/templates/analysis/reports/includes/old_intervention/card_old_interventions.html:11
|
||||
#: analysis/templates/analysis/reports/includes/old_data/card_old_interventions.html:11
|
||||
msgid "Old interventions"
|
||||
msgstr "Altfälle"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user