diff --git a/analysis/utils/excel/excel_report.xlsx b/analysis/utils/excel/excel_report.xlsx index e69d327..4383fbe 100644 Binary files a/analysis/utils/excel/excel_report.xlsx and b/analysis/utils/excel/excel_report.xlsx differ diff --git a/analysis/utils/report.py b/analysis/utils/report.py index fb5656f..d3341a1 100644 --- a/analysis/utils/report.py +++ b/analysis/utils/report.py @@ -57,6 +57,8 @@ class TimespanReport: deduction_sum_checked = -1 deduction_sum_recorded = -1 + excel_map = {} + def __init__(self, id: str, date_from: str, date_to: str): self.queryset = Intervention.objects.filter( responsible__conservation_office__id=id, @@ -76,6 +78,40 @@ class TimespanReport: self.queryset_recorded_count = self.queryset_recorded.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 = { + "i_checked": self.queryset_checked_count, + "i_recorded": self.queryset_recorded_count, + "i_total": self.queryset_count, + "i_compensations_checked": self.compensation_sum_checked, + "i_compensations_recorded": self.compensation_sum_recorded, + "i_compensations_total": self.compensation_sum, + "i_payments_recorded": self.payment_sum_recorded, + "i_payments_checked": self.payment_sum_checked, + "i_payments_total": self.payment_sum, + "i_deductions_recorded": self.deduction_sum_recorded, + "i_deductions_checked": self.deduction_sum_checked, + "i_deductions_total": self.deduction_sum, + "i_laws_iter": { + "iterable": self.evaluated_laws, + "attrs": [ + "short_name", + "num_checked", + "num_recorded", + "num", + ] + }, + "i_laws_checked": self.law_sum_checked, + "i_laws_recorded": self.law_sum_recorded, + "i_laws_total": self.law_sum, + } def _create_report(self): """ Creates all report information @@ -167,17 +203,17 @@ class TimespanReport: queryset_registration_office_tbp = Compensation.objects.none() queryset_registration_office_tbp_checked = Compensation.objects.none() queryset_registration_office_tbp_recorded = Compensation.objects.none() - queryset_registration_office_tbp = -1 - queryset_registration_office_tbp_checked = -1 - queryset_registration_office_tbp_recorded = -1 + queryset_registration_office_tbp_count = -1 + queryset_registration_office_tbp_checked_count = -1 + queryset_registration_office_tbp_recorded_count = -1 num_single_surfaces_total_tbp = -1 queryset_registration_office_other = Compensation.objects.none() queryset_registration_office_other_checked = Compensation.objects.none() queryset_registration_office_other_recorded = Compensation.objects.none() - queryset_registration_office_other = -1 - queryset_registration_office_other_checked = -1 - queryset_registration_office_other_recorded = -1 + queryset_registration_office_other_count = -1 + queryset_registration_office_other_checked_count = -1 + queryset_registration_office_other_recorded_count = -1 num_single_surfaces_total_other = -1 num_single_surfaces_total = -1 @@ -210,6 +246,32 @@ class TimespanReport: self.queryset_recorded_count = self.queryset_recorded.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 = { + "c_unb_checked": self.queryset_registration_office_unb_checked_count, + "c_unb_recorded": self.queryset_registration_office_unb_recorded_count, + "c_unb": self.queryset_registration_office_unb_count, + "c_surfaces_unb": self.num_single_surfaces_total_unb, + "c_tbp_checked": self.queryset_registration_office_tbp_checked_count, + "c_tbp_recorded": self.queryset_registration_office_tbp_recorded_count, + "c_tbp": self.queryset_registration_office_tbp_count, + "c_surfaces_tbp": self.num_single_surfaces_total_tbp, + "c_other_checked": self.queryset_registration_office_other_checked_count, + "c_other_recorded": self.queryset_registration_office_other_recorded_count, + "c_other": self.queryset_registration_office_other_count, + "c_surfaces_other": self.num_single_surfaces_total_other, + "c_checked": self.queryset_checked_count, + "c_recorded": self.queryset_recorded_count, + "c_total": self.queryset_count, + "c_surfaces": self.num_single_surfaces_total, + } def _create_report(self): """ Creates all report information @@ -432,28 +494,6 @@ class TimespanReport: self.excel_map = { "date_from": date_from.strftime(DEFAULT_DATE_FORMAT), "date_to": date_to.strftime(DEFAULT_DATE_FORMAT), - "i_checked": self.intervention_report.queryset_checked_count, - "i_recorded": self.intervention_report.queryset_recorded_count, - "i_total": self.intervention_report.queryset_count, - "i_compensations_checked": self.intervention_report.compensation_sum_checked, - "i_compensations_recorded": self.intervention_report.compensation_sum_recorded, - "i_compensations_total": self.intervention_report.compensation_sum, - "i_payments_recorded": self.intervention_report.payment_sum_recorded, - "i_payments_checked": self.intervention_report.payment_sum_checked, - "i_payments_total": self.intervention_report.payment_sum, - "i_deductions_recorded": self.intervention_report.deduction_sum_recorded, - "i_deductions_checked": self.intervention_report.deduction_sum_checked, - "i_deductions_total": self.intervention_report.deduction_sum, - "i_laws_iter": { - "iterable": self.intervention_report.evaluated_laws, - "attrs": [ - "short_name", - "num_checked", - "num_recorded", - "num", - ] - }, - "i_laws_checked": self.intervention_report.law_sum_checked, - "i_laws_recorded": self.intervention_report.law_sum_recorded, - "i_laws_total": self.intervention_report.law_sum, } + self.excel_map.update(self.intervention_report.excel_map) + self.excel_map.update(self.compensation_report.excel_map)