From ac9f67ee15ce48963ba0b96004907ad77ade1f81 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Mon, 26 Jan 2026 08:57:35 +0100 Subject: [PATCH] Improve backend UI if not qualified for invoice --- .../control/templates/pretixcontrol/order/index.html | 2 +- src/pretix/control/views/orders.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pretix/control/templates/pretixcontrol/order/index.html b/src/pretix/control/templates/pretixcontrol/order/index.html index 2a1cada254..9ae065d0ad 100644 --- a/src/pretix/control/templates/pretixcontrol/order/index.html +++ b/src/pretix/control/templates/pretixcontrol/order/index.html @@ -353,7 +353,7 @@ data-toggle="tooltip" title="{% trans 'Generate a cancellation document for this invoice and create a new invoice with a new invoice number.' %}" {% endif %}> - {% if order.status == "c" %} + {% if order.status == "c" or not invoice_qualified %} {% trans "Generate cancellation" %} {% else %} {% trans "Cancel and reissue" %} diff --git a/src/pretix/control/views/orders.py b/src/pretix/control/views/orders.py index 27371a058e..77fe326849 100644 --- a/src/pretix/control/views/orders.py +++ b/src/pretix/control/views/orders.py @@ -509,9 +509,10 @@ class OrderView(EventPermissionRequiredMixin, DetailView): def get_context_data(self, **kwargs): ctx = super().get_context_data(**kwargs) - ctx['can_generate_invoice'] = invoice_qualified(self.order) and ( + ctx['invoice_qualified'] = invoice_qualified(self.order) + ctx['can_generate_invoice'] = ctx['invoice_qualified'] and ( self.request.event.settings.invoice_generate in ('admin', 'user', 'paid', 'user_paid', 'True') - ) and self.order.status in (Order.STATUS_PAID, Order.STATUS_PENDING) and ( + ) and ( not self.order.invoices.exists() or self.order.invoices.filter(is_cancellation=True).count() >= self.order.invoices.filter(is_cancellation=False).count() ) @@ -1744,12 +1745,13 @@ class OrderInvoiceReissue(OrderView): c = generate_cancellation(inv) if invoice_qualified(order): inv = generate_invoice(order) + messages.success(self.request, _('The invoice has been reissued.')) else: inv = c + messages.success(self.request, _('The invoice has been canceled.')) order.log_action('pretix.event.order.invoice.reissued', user=self.request.user, data={ 'invoice': inv.pk }) - messages.success(self.request, _('The invoice has been reissued.')) return redirect(self.get_order_url()) def get(self, *args, **kwargs): # NOQA