From df25a1cebf9e4d900ca85628df4011ed28723d8f Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Mon, 20 Mar 2023 16:46:28 +0100 Subject: [PATCH] Invoice renderer: Line break on very large amounts --- src/pretix/base/invoice.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/pretix/base/invoice.py b/src/pretix/base/invoice.py index 57de17cb6..19b02b3e7 100644 --- a/src/pretix/base/invoice.py +++ b/src/pretix/base/invoice.py @@ -148,6 +148,7 @@ class BaseReportlabInvoiceRenderer(BaseInvoiceRenderer): """ stylesheet = StyleSheet1() stylesheet.add(ParagraphStyle(name='Normal', fontName=self.font_regular, fontSize=10, leading=12)) + stylesheet.add(ParagraphStyle(name='NormalRight', fontName=self.font_regular, fontSize=10, leading=12, alignment=TA_RIGHT)) stylesheet.add(ParagraphStyle(name='BoldInverseCenter', fontName=self.font_bold, fontSize=10, leading=12, textColor=colors.white, alignment=TA_CENTER)) stylesheet.add(ParagraphStyle(name='InvoiceFrom', parent=stylesheet['Normal'])) @@ -610,8 +611,8 @@ class ClassicInvoiceRenderer(BaseReportlabInvoiceRenderer): ), str(len(lines)), localize(tax_rate) + " %", - money_filter(net_value * len(lines), self.invoice.event.currency), - money_filter(gross_value * len(lines), self.invoice.event.currency), + Paragraph(money_filter(net_value * len(lines), self.invoice.event.currency).replace('\xa0', ' '), self.stylesheet['NormalRight']), + Paragraph(money_filter(gross_value * len(lines), self.invoice.event.currency).replace('\xa0', ' '), self.stylesheet['NormalRight']), )) else: if len(lines) > 1: @@ -625,7 +626,7 @@ class ClassicInvoiceRenderer(BaseReportlabInvoiceRenderer): self.stylesheet['Normal'] ), str(len(lines)), - money_filter(gross_value * len(lines), self.invoice.event.currency), + Paragraph(money_filter(gross_value * len(lines), self.invoice.event.currency).replace('\xa0', ' '), self.stylesheet['NormalRight']), )) taxvalue_map[tax_rate, tax_name] += (gross_value - net_value) * len(lines) grossvalue_map[tax_rate, tax_name] += gross_value * len(lines) @@ -633,12 +634,14 @@ class ClassicInvoiceRenderer(BaseReportlabInvoiceRenderer): if has_taxes: tdata.append([ - pgettext('invoice', 'Invoice total'), '', '', '', money_filter(total, self.invoice.event.currency) + pgettext('invoice', 'Invoice total'), '', '', '', + money_filter(total, self.invoice.event.currency) ]) colwidths = [a * doc.width for a in (.50, .05, .15, .15, .15)] else: tdata.append([ - pgettext('invoice', 'Invoice total'), '', money_filter(total, self.invoice.event.currency) + pgettext('invoice', 'Invoice total'), '', + money_filter(total, self.invoice.event.currency) ]) colwidths = [a * doc.width for a in (.65, .20, .15)]