forked from CGM_Public/pretix_original
New invoice generation setting: User request but paid only (#4740)
This commit is contained in:
@@ -602,7 +602,7 @@ class EventOrderViewSet(OrderViewSetMixin, viewsets.ModelViewSet):
|
||||
order.status in (Order.STATUS_PAID, Order.STATUS_PENDING)
|
||||
and order.invoices.filter(is_cancellation=True).count() >= 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(order):
|
||||
if self.request.event.settings.get('invoice_generate') not in ('admin', 'user', 'paid', 'user_paid', 'True') or not invoice_qualified(order):
|
||||
return Response(
|
||||
{'detail': _('You cannot generate an invoice for this order.')},
|
||||
status=status.HTTP_400_BAD_REQUEST
|
||||
|
||||
@@ -1040,6 +1040,7 @@ DEFAULTS = {
|
||||
('False', _('Do not generate invoices')),
|
||||
('admin', _('Only manually in admin panel')),
|
||||
('user', _('Automatically on user request')),
|
||||
('user_paid', _('Automatically on user request for paid orders')),
|
||||
('True', _('Automatically for all created orders')),
|
||||
('paid', _('Automatically on payment or when required by payment method')),
|
||||
),
|
||||
@@ -1052,6 +1053,7 @@ DEFAULTS = {
|
||||
('paid', _('Automatically after payment or when required by payment method')),
|
||||
('True', _('Automatically before payment for all created orders')),
|
||||
('user', _('Automatically on user request')),
|
||||
('user_paid', _('Automatically on user request for paid orders')),
|
||||
('admin', _('Only manually in admin panel')),
|
||||
),
|
||||
help_text=_("Invoices will never be automatically generated for free orders.")
|
||||
|
||||
@@ -479,7 +479,7 @@ 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 (
|
||||
self.request.event.settings.invoice_generate in ('admin', 'user', 'paid', 'True')
|
||||
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 (
|
||||
not self.order.invoices.exists()
|
||||
or self.order.invoices.filter(is_cancellation=True).count() >= self.order.invoices.filter(is_cancellation=False).count()
|
||||
@@ -1584,7 +1584,7 @@ class OrderInvoiceCreate(OrderView):
|
||||
order.status in (Order.STATUS_PAID, Order.STATUS_PENDING)
|
||||
and order.invoices.filter(is_cancellation=True).count() >= 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(order):
|
||||
if self.request.event.settings.get('invoice_generate') not in ('admin', 'user', 'paid', 'user_paid', 'True') or not invoice_qualified(order):
|
||||
messages.error(self.request, _('You cannot generate an invoice for this order.'))
|
||||
elif has_inv:
|
||||
messages.error(self.request, _('An invoice for this order already exists.'))
|
||||
|
||||
@@ -710,7 +710,7 @@ def can_generate_invoice(event, order, ignore_payments=False):
|
||||
and (
|
||||
event.settings.get('invoice_generate') in ('user', 'True')
|
||||
or (
|
||||
event.settings.get('invoice_generate') == 'paid'
|
||||
event.settings.get('invoice_generate') in ('paid', 'user_paid')
|
||||
and order.status == Order.STATUS_PAID
|
||||
)
|
||||
) and (
|
||||
|
||||
Reference in New Issue
Block a user