diff --git a/src/pretix/api/serializers/event.py b/src/pretix/api/serializers/event.py index 527db52f4..6e9d2fb97 100644 --- a/src/pretix/api/serializers/event.py +++ b/src/pretix/api/serializers/event.py @@ -530,6 +530,7 @@ class EventSettingsSerializer(serializers.Serializer): 'invoice_address_beneficiary', 'invoice_name_required', 'invoice_address_not_asked_free', + 'invoice_show_payments', 'invoice_include_free', 'invoice_generate', 'invoice_numbers_consecutive', diff --git a/src/pretix/base/invoice.py b/src/pretix/base/invoice.py index 680f0f5c7..de6cec8da 100644 --- a/src/pretix/base/invoice.py +++ b/src/pretix/base/invoice.py @@ -28,7 +28,7 @@ from reportlab.platypus import ( ) from pretix.base.decimal import round_decimal -from pretix.base.models import Event, Invoice +from pretix.base.models import Event, Invoice, Order from pretix.base.signals import register_invoice_renderers from pretix.base.templatetags.money import money_filter @@ -559,6 +559,20 @@ class ClassicInvoiceRenderer(BaseReportlabInvoiceRenderer): ]) colwidths = [a * doc.width for a in (.65, .05, .30)] + if self.invoice.event.settings.invoice_show_payments and not self.invoice.is_cancellation and \ + self.invoice.order.status == Order.STATUS_PENDING: + pending_sum = self.invoice.order.pending_sum + if pending_sum != total: + tdata.append([pgettext('invoice', 'Received payments')] + (['', '', ''] if has_taxes else ['']) + [ + money_filter(pending_sum - total, self.invoice.event.currency) + ]) + tdata.append([pgettext('invoice', 'Outstanding payments')] + (['', '', ''] if has_taxes else ['']) + [ + money_filter(pending_sum, self.invoice.event.currency) + ]) + tstyledata += [ + ('FONTNAME', (0, len(tdata) - 3), (-1, len(tdata) - 3), self.font_bold), + ] + table = Table(tdata, colWidths=colwidths, repeatRows=1) table.setStyle(TableStyle(tstyledata)) story.append(table) diff --git a/src/pretix/base/settings.py b/src/pretix/base/settings.py index 11c494134..b2f880ebd 100644 --- a/src/pretix/base/settings.py +++ b/src/pretix/base/settings.py @@ -205,6 +205,17 @@ DEFAULTS = { help_text=_("This text will be shown above the invoice address form during checkout.") ) }, + 'invoice_show_payments': { + 'default': 'True', + 'type': bool, + 'form_class': forms.BooleanField, + 'serializer_class': serializers.BooleanField, + 'form_kwargs': dict( + label=_("Show paid amount on partially paid invoices"), + help_text=_("If an invoice has already been paid partially, this option will add the paid and pending " + "amount to the invoice."), + ) + }, 'invoice_include_free': { 'default': 'True', 'type': bool, diff --git a/src/pretix/control/forms/event.py b/src/pretix/control/forms/event.py index ebd42f470..26c371051 100644 --- a/src/pretix/control/forms/event.py +++ b/src/pretix/control/forms/event.py @@ -570,6 +570,7 @@ class InvoiceSettingsForm(SettingsForm): 'invoice_name_required', 'invoice_address_not_asked_free', 'invoice_include_free', + 'invoice_show_payments', 'invoice_generate', 'invoice_attendee_name', 'invoice_include_expire_date', diff --git a/src/pretix/control/templates/pretixcontrol/event/invoicing.html b/src/pretix/control/templates/pretixcontrol/event/invoicing.html index a36b60eeb..cb3d1a424 100644 --- a/src/pretix/control/templates/pretixcontrol/event/invoicing.html +++ b/src/pretix/control/templates/pretixcontrol/event/invoicing.html @@ -14,6 +14,7 @@ {% bootstrap_field form.invoice_email_attachment layout="control" %} {% bootstrap_field form.invoice_language layout="control" %} {% bootstrap_field form.invoice_include_free layout="control" %} + {% bootstrap_field form.invoice_show_payments layout="control" %} {% bootstrap_field form.invoice_numbers_consecutive layout="control" %} {% bootstrap_field form.invoice_numbers_prefix layout="control" %} {% bootstrap_field form.invoice_numbers_prefix_cancellations layout="control" %}