mirror of
https://github.com/pretix/pretix.git
synced 2026-05-07 15:34:02 +00:00
Optionally allow to automatically reissue an invoice after a data change
This commit is contained in:
@@ -531,6 +531,7 @@ class EventSettingsSerializer(serializers.Serializer):
|
||||
'invoice_name_required',
|
||||
'invoice_address_not_asked_free',
|
||||
'invoice_show_payments',
|
||||
'invoice_reissue_after_modify',
|
||||
'invoice_include_free',
|
||||
'invoice_generate',
|
||||
'invoice_numbers_consecutive',
|
||||
|
||||
@@ -443,6 +443,18 @@ DEFAULTS = {
|
||||
help_text=_("Invoices will never be automatically generated for free orders.")
|
||||
)
|
||||
},
|
||||
'invoice_reissue_after_modify': {
|
||||
'default': 'False',
|
||||
'type': bool,
|
||||
'form_class': forms.BooleanField,
|
||||
'serializer_class': serializers.BooleanField,
|
||||
'form_kwargs': dict(
|
||||
label=_("Automatically cancel and reissue invoice on address changes"),
|
||||
help_text=_("If customers change their invoice address on an existing order, the invoice will "
|
||||
"automatically be canceled and a new invoice will be issued. This setting does not affect "
|
||||
"changes made through the backend."),
|
||||
)
|
||||
},
|
||||
'invoice_generate_sales_channels': {
|
||||
'default': json.dumps(['web']),
|
||||
'type': list
|
||||
|
||||
@@ -571,6 +571,7 @@ class InvoiceSettingsForm(SettingsForm):
|
||||
'invoice_address_not_asked_free',
|
||||
'invoice_include_free',
|
||||
'invoice_show_payments',
|
||||
'invoice_reissue_after_modify',
|
||||
'invoice_generate',
|
||||
'invoice_attendee_name',
|
||||
'invoice_include_expire_date',
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
{% 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_reissue_after_modify 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" %}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
{% csrf_token %}
|
||||
<div class="panel-group" id="questions_accordion">
|
||||
{% if invoice_address_asked or event.settings.invoice_name_required %}
|
||||
{% if invoice_address_asked and not request.GET.generate_invoice == "true" %}
|
||||
{% if invoice_address_asked and not request.GET.generate_invoice == "true" and not event.settings.invoice_reissue_after_modify %}
|
||||
<div class="alert alert-info">
|
||||
{% blocktrans trimmed %}
|
||||
Modifying your invoice address will not automatically generate a new invoice.
|
||||
|
||||
@@ -27,7 +27,8 @@ from pretix.base.models.orders import (
|
||||
)
|
||||
from pretix.base.payment import PaymentException
|
||||
from pretix.base.services.invoices import (
|
||||
generate_invoice, invoice_pdf, invoice_pdf_task, invoice_qualified,
|
||||
generate_cancellation, generate_invoice, invoice_pdf, invoice_pdf_task,
|
||||
invoice_qualified,
|
||||
)
|
||||
from pretix.base.services.mail import SendMailException
|
||||
from pretix.base.services.orders import (
|
||||
@@ -669,6 +670,19 @@ class OrderModify(EventViewMixin, OrderDetailMixin, OrderQuestionsViewMixin, Tem
|
||||
'invoice': i.pk
|
||||
})
|
||||
messages.success(self.request, _('The invoice has been generated.'))
|
||||
elif self.request.event.settings.invoice_reissue_after_modify:
|
||||
if self.invoice_form.changed_data:
|
||||
inv = self.order.invoices.last()
|
||||
if inv and not inv.canceled and not inv.shredded:
|
||||
c = generate_cancellation(inv)
|
||||
if self.order.status != Order.STATUS_CANCELED:
|
||||
inv = generate_invoice(self.order)
|
||||
else:
|
||||
inv = c
|
||||
self.order.log_action('pretix.event.order.invoice.reissued', data={
|
||||
'invoice': inv.pk
|
||||
})
|
||||
messages.success(self.request, _('The invoice has been reissued.'))
|
||||
|
||||
invalidate_cache.apply_async(kwargs={'event': self.request.event.pk, 'order': self.order.pk})
|
||||
CachedTicket.objects.filter(order_position__order=self.order).delete()
|
||||
|
||||
Reference in New Issue
Block a user