From a37cbec002f8d2b01049865f36d6dde24e945cce Mon Sep 17 00:00:00 2001 From: Fran Cubero Date: Thu, 9 Jan 2025 13:19:11 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20dual=20RBS=20lines=20repre?= =?UTF-8?q?sentation=20in=20pdf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../giscedata_facturacio_report.py | 30 +++++++++++-------- .../invoice_details_td_bo_social_2023.mako | 18 +++++++---- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/giscedata_facturacio_comer_som/giscedata_facturacio_report.py b/giscedata_facturacio_comer_som/giscedata_facturacio_report.py index 311c6cf86..84c62e5a6 100644 --- a/giscedata_facturacio_comer_som/giscedata_facturacio_report.py +++ b/giscedata_facturacio_comer_som/giscedata_facturacio_report.py @@ -3266,28 +3266,32 @@ def get_sub_component_invoice_details_td_excess_power_quarterhours(self, fact, p return data def get_sub_component_invoice_details_td_bo_social_2023_data(self, fact, pol): - days = 0.0 - price_per_day = 0.0 - subtotal = 0.0 visible = False - iva = "" - + rbs_price_per_days = {} + rbs_lines = [] for l in fact.linia_ids: # noqa: E741 if l.tipus in "altres" and l.invoice_line_id.product_id.code == "RBS": - days += l.quantity - price_per_day = l.price_unit - subtotal += l.price_subtotal - iva = get_iva_line(l) + if l.price_unit not in rbs_price_per_days: + line = { + "days": l.quantity, + "price_per_day": l.price_unit, + "subtotal": l.price_subtotal, + "iva": get_iva_line(l), + } + rbs_price_per_days[l.price_unit] = line + rbs_lines.append(line) + else: + line = rbs_price_per_days[l.price_unit] + line["days"] += l.quantity + line["subtotal"] += l.price_subtotal visible = True data = { "is_visible": visible, "number_of_columns": len(self.get_matrix_show_periods(pol)) + 1, - "days": days, - "price_per_day": price_per_day, - "subtotal": subtotal, "iva_column": has_iva_column(fact), - "iva": iva, + "lines": rbs_lines, + "header_multi": len(rbs_lines), } return data diff --git a/giscedata_facturacio_comer_som/report/components/invoice_details_td_bo_social_2023/invoice_details_td_bo_social_2023.mako b/giscedata_facturacio_comer_som/report/components/invoice_details_td_bo_social_2023/invoice_details_td_bo_social_2023.mako index d7cc324e3..457ad302a 100644 --- a/giscedata_facturacio_comer_som/report/components/invoice_details_td_bo_social_2023/invoice_details_td_bo_social_2023.mako +++ b/giscedata_facturacio_comer_som/report/components/invoice_details_td_bo_social_2023/invoice_details_td_bo_social_2023.mako @@ -2,13 +2,19 @@ %if bs.is_visible: <% import locale +first_pass = True %> - - ${_(u"Bo social")} - ${_(u"%s dies x %s €/dia") % (int(bs.days), locale.str(locale.atof(formatLang(bs.price_per_day, digits=6))))} - ${_(u"%s €") % formatLang(bs.subtotal)} - % if bs.iva_column: - ${_(u"%s") % (bs.iva) } +% for l in bs.lines: + + % if first_pass: + ${_(u"Bo social")} + <%first_pass = False%> % endif + ${_(u"%s dies x %s €/dia") % (int(l['days']), locale.str(locale.atof(formatLang(l['price_per_day'], digits=6))))} + ${_(u"%s €") % formatLang(l['subtotal'])} + % if bs.iva_column: + ${_(u"%s") % (l['iva']) } + % endif +% endfor %endif