mirror of
https://github.com/pretix/pretix.git
synced 2026-05-06 15:24:02 +00:00
Allow to manually generate invoices like in c131ad8c
This commit is contained in:
@@ -184,6 +184,16 @@
|
||||
<br/>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if can_generate_invoice %}
|
||||
<br/>
|
||||
<form class="form-inline helper-display-inline" method="post"
|
||||
action="{% url "control:event.order.geninvoice" event=request.event.slug organizer=request.event.organizer.slug code=order.code %}">
|
||||
{% csrf_token %}
|
||||
<button class="btn btn-default btn-xs">
|
||||
{% trans "Generate invoice" %}
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</dd>
|
||||
{% elif can_generate_invoice %}
|
||||
<dt>{% trans "Invoices" %}</dt>
|
||||
|
||||
@@ -122,6 +122,12 @@ class OrderView(EventPermissionRequiredMixin, DetailView):
|
||||
ctx = super().get_context_data(**kwargs)
|
||||
ctx['can_generate_invoice'] = invoice_qualified(self.order) and (
|
||||
self.request.event.settings.invoice_generate in ('admin', 'user', 'paid', 'True')
|
||||
) and (
|
||||
not self.order.invoices.exists()
|
||||
or (
|
||||
self.order.status in (Order.STATUS_PAID, Order.STATUS_PENDING)
|
||||
and self.order.invoices.filter(is_cancellation=True).count() >= self.order.invoices.filter(is_cancellation=False).count()
|
||||
)
|
||||
)
|
||||
return ctx
|
||||
|
||||
@@ -738,9 +744,13 @@ class OrderInvoiceCreate(OrderView):
|
||||
permission = 'can_change_orders'
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
if self.request.event.settings.get('invoice_generate') not in ('admin', 'user', 'paid') or not invoice_qualified(self.order):
|
||||
has_inv = self.order.invoices.exists() and not (
|
||||
self.order.status in (Order.STATUS_PAID, Order.STATUS_PENDING)
|
||||
and self.order.invoices.filter(is_cancellation=True).count() >= self.order.invoices.filter(is_cancellation=False).count()
|
||||
)
|
||||
if self.request.event.settings.get('invoice_generate') not in ('admin', 'user', 'paid', 'True') or not invoice_qualified(self.order):
|
||||
messages.error(self.request, _('You cannot generate an invoice for this order.'))
|
||||
elif self.order.invoices.exists():
|
||||
elif has_inv:
|
||||
messages.error(self.request, _('An invoice for this order already exists.'))
|
||||
else:
|
||||
inv = generate_invoice(self.order)
|
||||
|
||||
Reference in New Issue
Block a user