summaryrefslogtreecommitdiff
path: root/postgresqleu
diff options
context:
space:
mode:
Diffstat (limited to 'postgresqleu')
-rw-r--r--postgresqleu/confreg/forms.py4
-rw-r--r--postgresqleu/confreg/views.py25
2 files changed, 27 insertions, 2 deletions
diff --git a/postgresqleu/confreg/forms.py b/postgresqleu/confreg/forms.py
index e8d331df..476db09f 100644
--- a/postgresqleu/confreg/forms.py
+++ b/postgresqleu/confreg/forms.py
@@ -366,7 +366,8 @@ class PrepaidCreateForm(forms.Form):
regtype = forms.ModelChoiceField(queryset=RegistrationType.objects.all())
count = forms.IntegerField(min_value=1, max_value=100)
buyer = forms.ModelChoiceField(queryset=User.objects.all().order_by('username'), help_text="Pick the user who bought the batch. If he/she is not registered, pick your own userid")
- buyername = forms.CharField(max_length=100,help_text="Display name of the user who bought the batch. Internal use only.")
+ buyername = forms.CharField(max_length=100,help_text="Display name of the user who bought the batch. Internal use and copied to invoice")
+ invoice = forms.BooleanField(help_text="Automatically create invoice template for these vouchers. Note that the vouchers are created immediately, not at payment time!", required=False)
confirm = forms.BooleanField(help_text="Confirm that the chosen registration type and count are correct (there is no undo past this point, the vouchers will be created!")
def __init__(self, *args, **kwargs):
@@ -386,6 +387,7 @@ class PrepaidCreateForm(forms.Form):
del self.fields['buyer']
del self.fields['buyername']
del self.fields['confirm']
+ del self.fields['invoice']
class EmailSendForm(forms.Form):
ids = forms.CharField(label="List of id's", widget=forms.widgets.HiddenInput())
diff --git a/postgresqleu/confreg/views.py b/postgresqleu/confreg/views.py
index 4c4e6185..08d67b01 100644
--- a/postgresqleu/confreg/views.py
+++ b/postgresqleu/confreg/views.py
@@ -27,6 +27,7 @@ from models import get_status_string
from regtypes import confirm_special_reg_type
from postgresqleu.util.decorators import user_passes_test_or_error, ssl_required
+from postgresqleu.invoices.models import Invoice, InvoicePaymentMethod, InvoiceRow
from postgresqleu.invoices.util import InvoiceManager, InvoicePresentationWrapper
from postgresqleu.invoices.models import InvoiceProcessor
from postgresqleu.mailqueue.util import send_mail
@@ -771,6 +772,7 @@ def createvouchers(request):
conference = Conference.objects.get(pk=form.data['conference'])
regtype = RegistrationType.objects.get(pk=form.data['regtype'], conference=conference)
+ regcount = int(form.data['count'])
buyer = User.objects.get(pk=form.data['buyer'])
buyername = form.data['buyername']
@@ -780,11 +782,32 @@ def createvouchers(request):
buyername=buyername)
batch.save()
- for n in range(0, int(form.data['count'])):
+ for n in range(0, regcount):
v = PrepaidVoucher(conference=conference,
vouchervalue=base64.b64encode(os.urandom(37)).rstrip('='),
batch=batch)
v.save()
+
+ if form.data.has_key('invoice') and form.data['invoice']:
+ invoice = Invoice(recipient_user=buyer,
+ recipient_email=buyer.email,
+ recipient_name=buyername,
+ title='Prepaid vouchers for %s' % conference.conferencename,
+ invoicedate=datetime.now(),
+ duedate=datetime.now(),
+ finalized=False,
+ total_amount=-1,
+ bankinfo=False,
+ accounting_account=settings.ACCOUNTING_CONFREG_ACCOUNT,
+ accounting_object = conference.accounting_object,
+ )
+ invoice.save()
+ invoice.invoicerow_set.add(InvoiceRow(invoice=invoice,
+ rowtext='Voucher for "%s"' % regtype.regtype,
+ rowcount=regcount,
+ rowamount=regtype.cost))
+ invoice.allowedmethods = InvoicePaymentMethod.objects.filter(auto=True)
+ invoice.save()
return HttpResponseRedirect('%s/' % batch.id)
# Else fall through to re-render
else: