From 44b3647689d7d85610b0038e6bfa53a4bb3ead52 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Mon, 17 Nov 2025 17:09:06 +0100 Subject: [PATCH] Accounting report: Allow subclasses to skip tables (#5616) --- .../plugins/reports/accountingreport.py | 72 ++++++++++--------- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/src/pretix/plugins/reports/accountingreport.py b/src/pretix/plugins/reports/accountingreport.py index 0cef646636..1c9d34ebf0 100644 --- a/src/pretix/plugins/reports/accountingreport.py +++ b/src/pretix/plugins/reports/accountingreport.py @@ -858,50 +858,58 @@ class ReportExporter(ReportlabExportMixin, BaseExporter): for c in currencies: c_head = f" [{c}]" if len(currencies) > 1 else "" - story += [ - Spacer(0, 3 * mm), - FontFallbackParagraph(_("Orders") + c_head, style_h2), - Spacer(0, 3 * mm), - *self._table_transactions(form_data, c), - ] + s = self._table_transactions(form_data, c) + if s: + story += [ + Spacer(0, 3 * mm), + FontFallbackParagraph(_("Orders") + c_head, style_h2), + Spacer(0, 3 * mm), + *s + ] for c in currencies: c_head = f" [{c}]" if len(currencies) > 1 else "" - story += [ - Spacer(0, 8 * mm), - FontFallbackParagraph(_("Payments") + c_head, style_h2), - Spacer(0, 3 * mm), - *self._table_payments(form_data, c), - ] + s = self._table_payments(form_data, c) + if s: + story += [ + Spacer(0, 8 * mm), + FontFallbackParagraph(_("Payments") + c_head, style_h2), + Spacer(0, 3 * mm), + *s + ] for c in currencies: c_head = f" [{c}]" if len(currencies) > 1 else "" - story += [ - Spacer(0, 8 * mm), - KeepTogether( - [ - FontFallbackParagraph(_("Open items") + c_head, style_h2), - Spacer(0, 3 * mm), - *self._table_open_items(form_data, c), - ] - ), - ] + s = self._table_open_items(form_data, c) + if s: + story += [ + Spacer(0, 8 * mm), + KeepTogether( + [ + FontFallbackParagraph(_("Open items") + c_head, style_h2), + Spacer(0, 3 * mm), + *s + ] + ), + ] if ( self.is_multievent and self.events.count() == self.organizer.events.count() ): for c in currencies: c_head = f" [{c}]" if len(currencies) > 1 else "" - story += [ - Spacer(0, 8 * mm), - KeepTogether( - [ - FontFallbackParagraph(_("Gift cards") + c_head, style_h2), - Spacer(0, 3 * mm), - *self._table_gift_cards(form_data, c), - ] - ), - ] + s = self._table_gift_cards(form_data, c) + if s: + story += [ + Spacer(0, 8 * mm), + KeepTogether( + [ + FontFallbackParagraph(_("Gift cards") + c_head, style_h2), + Spacer(0, 3 * mm), + *s, + ] + ), + ] doc.build(story, canvasmaker=self.canvas_class(doc)) f.seek(0)