Add new settings invoice_regenerate_allowed (#2071)

This commit is contained in:
Raphael Michel
2021-07-01 14:51:08 +02:00
committed by GitHub
parent 0c6971ff5f
commit 9089b630ed
9 changed files with 50 additions and 15 deletions

View File

@@ -1330,8 +1330,14 @@ class OrderInvoiceRegenerate(OrderView):
except Invoice.DoesNotExist:
messages.error(self.request, _('Unknown invoice.'))
else:
if not inv.event.settings.invoice_regenerate_allowed:
messages.error(self.request, _('Invoices may not be changed after they are created.'))
if inv.canceled:
messages.error(self.request, _('The invoice has already been canceled.'))
elif inv.sent_to_organizer:
messages.error(self.request, _('The invoice file has already been exported.'))
elif now().astimezone(self.request.event.timezone).date() - inv.date > timedelta(days=1):
messages.error(self.request, _('The invoice file is too old to be regenerated.'))
elif inv.shredded:
messages.error(self.request, _('The invoice has been cleaned of personal data.'))
else: