Support specifying an autocancel time for reg transfer invoices
authorMagnus Hagander <magnus@hagander.net>
Thu, 17 Oct 2024 16:18:19 +0000 (18:18 +0200)
committerMagnus Hagander <magnus@hagander.net>
Thu, 17 Oct 2024 16:18:19 +0000 (18:18 +0200)
And default it to the autocancel for the conference, but allow the admin
creating the invoice to override if needed.

postgresqleu/confreg/forms.py
postgresqleu/confreg/views.py

index 79bde8aa7a277f8dca595670f78c1828d77af091..cd376222aac400d8ead9b10ae3aff862a60df98a 100644 (file)
@@ -914,11 +914,14 @@ class TransferRegForm(forms.Form):
     invoice_name = forms.CharField(required=False, label="Invoice recipient name", help_text="Name of the recipient of the invoice")
     invoice_email = forms.EmailField(required=False, label="Invoice recipient email", help_text="E-mail to send the invoice to")
     invoice_address = forms.CharField(widget=MonospaceTextarea, required=False)
+    invoice_autocancel = forms.IntegerField(required=False, label="Invoice autocancel hours", help_text="Automatically cancel invoice after this many hours",
+                                            validators=[django.core.validators.MinValueValidator(0)])
     confirm = forms.BooleanField(help_text="Confirm that you want to transfer the registration with the given steps!", required=False)
 
     def __init__(self, conference, *args, **kwargs):
         self.conference = conference
         super(TransferRegForm, self).__init__(*args, **kwargs)
+        self.initial['invoice_autocancel'] = conference.invoice_autocancel_hours
         self.fields['transfer_from'].queryset = ConferenceRegistration.objects.select_related('conference').filter(conference=conference, payconfirmedat__isnull=False, canceledat__isnull=True, transfer_from_reg__isnull=True)
         self.fields['transfer_to'].queryset = ConferenceRegistration.objects.select_related('conference').filter(conference=conference, payconfirmedat__isnull=True, canceledat__isnull=True, bulkpayment__isnull=True)
         if not ('transfer_from' in self.data and 'transfer_to' in self.data):
index 417295541c7a080156b66abc9a45434c9ea94614..b274fdf3ee08575687e86b5a04df374e2642fbf7 100644 (file)
@@ -4560,6 +4560,7 @@ def transfer_reg(request, urlname):
                         processorid=rtp.pk,
                         accounting_account=settings.ACCOUNTING_CONFREG_ACCOUNT,
                         accounting_object=conference.accounting_object,
+                        canceltime=get_invoice_autocancel(form.cleaned_data['invoice_autocancel']),
                         paymentmethods=conference.paymentmethods.all(),
                     )
                     rtp.invoice.save()