forked from CGM_Public/pretix_original
Compare commits
1 Commits
invoice-us
...
i18n-field
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e06c9225fa |
@@ -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', 'user_paid', 'True') or not invoice_qualified(order):
|
||||
if self.request.event.settings.get('invoice_generate') not in ('admin', '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
|
||||
|
||||
@@ -222,6 +222,12 @@ class RelativeDateTimeWidget(forms.MultiWidget):
|
||||
def get_context(self, name, value, attrs):
|
||||
ctx = super().get_context(name, value, attrs)
|
||||
ctx['required'] = self.status_choices[0][0] == 'unset'
|
||||
|
||||
ctx['rendered_subwidgets'] = [
|
||||
self._render(w['template_name'], {**ctx, 'widget': w})
|
||||
for w in ctx['widget']['subwidgets']
|
||||
]
|
||||
|
||||
return ctx
|
||||
|
||||
|
||||
|
||||
@@ -1040,7 +1040,6 @@ 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')),
|
||||
),
|
||||
@@ -1053,7 +1052,6 @@ 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.")
|
||||
|
||||
@@ -11,10 +11,9 @@
|
||||
{% if selopt.value == "absolute" %}
|
||||
{% include widget.subwidgets.1.template_name with widget=widget.subwidgets.1 %}
|
||||
{% elif selopt.value == "relative" %}
|
||||
{% include widget.subwidgets.2.template_name with widget=widget.subwidgets.2 %}
|
||||
{% trans "days" %}
|
||||
{% include widget.subwidgets.4.template_name with widget=widget.subwidgets.4 %}
|
||||
{% include widget.subwidgets.3.template_name with widget=widget.subwidgets.3 %}
|
||||
{% blocktrans trimmed with number=rendered_subwidgets.2 relation=rendered_subwidgets.4 relation_to=rendered_subwidgets.3 %}
|
||||
{{ number }} days {{ relation }} {{ relation_to }}
|
||||
{% endblocktrans %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
@@ -11,17 +11,13 @@
|
||||
{% if selopt.value == "absolute" %}
|
||||
{% include widget.subwidgets.1.template_name with widget=widget.subwidgets.1 %}
|
||||
{% elif selopt.value == "relative_minutes" %}
|
||||
{% include widget.subwidgets.5.template_name with widget=widget.subwidgets.5 %}
|
||||
{% trans "minutes" %}
|
||||
{% include widget.subwidgets.7.template_name with widget=widget.subwidgets.7 %}
|
||||
{% include widget.subwidgets.3.template_name with widget=widget.subwidgets.3 %}
|
||||
{% blocktrans trimmed with number=rendered_subwidgets.5 relation=rendered_subwidgets.7 relation_to=rendered_subwidgets.3 %}
|
||||
{{ number }} minutes {{ relation }} {{ relation_to }}
|
||||
{% endblocktrans %}
|
||||
{% elif selopt.value == "relative" %}
|
||||
{% include widget.subwidgets.2.template_name with widget=widget.subwidgets.2 %}
|
||||
{% trans "days" %}
|
||||
{% include widget.subwidgets.8.template_name with widget=widget.subwidgets.8 %}
|
||||
{% include widget.subwidgets.6.template_name with widget=widget.subwidgets.6 %}
|
||||
{% trans "at" %}
|
||||
{% include widget.subwidgets.4.template_name with widget=widget.subwidgets.4 %}
|
||||
{% blocktrans trimmed with number=rendered_subwidgets.2 relation=rendered_subwidgets.8 relation_to=rendered_subwidgets.6 time_of_day=rendered_subwidgets.4 %}
|
||||
{{ number }} days {{ relation }} {{ relation_to }} at {{ time_of_day }}
|
||||
{% endblocktrans %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
@@ -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', 'user_paid', 'True')
|
||||
self.request.event.settings.invoice_generate in ('admin', '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', 'user_paid', 'True') or not invoice_qualified(order):
|
||||
if self.request.event.settings.get('invoice_generate') not in ('admin', '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') in ('paid', 'user_paid')
|
||||
event.settings.get('invoice_generate') == 'paid'
|
||||
and order.status == Order.STATUS_PAID
|
||||
)
|
||||
) and (
|
||||
|
||||
@@ -874,21 +874,6 @@ class OrdersTest(BaseOrdersTest):
|
||||
{}, follow=True)
|
||||
assert 'alert-danger' in response.content.decode()
|
||||
|
||||
def test_invoice_create_onlypaid(self):
|
||||
self.event.settings.set('invoice_generate', 'user_paid')
|
||||
response = self.client.post(
|
||||
'/%s/%s/order/%s/%s/invoice' % (self.orga.slug, self.event.slug, self.order.code, self.order.secret),
|
||||
{}, follow=True)
|
||||
assert 'alert-danger' in response.content.decode()
|
||||
self.order.status = Order.STATUS_PAID
|
||||
self.order.save()
|
||||
response = self.client.post(
|
||||
'/%s/%s/order/%s/%s/invoice' % (self.orga.slug, self.event.slug, self.order.code, self.order.secret),
|
||||
{}, follow=True)
|
||||
assert 'alert-success' in response.content.decode()
|
||||
with scopes_disabled():
|
||||
assert self.order.invoices.exists()
|
||||
|
||||
def test_invoice_create_duplicate(self):
|
||||
self.event.settings.set('invoice_generate', 'user')
|
||||
with scopes_disabled():
|
||||
|
||||
Reference in New Issue
Block a user