mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-26 18:02:18 +00:00
Added the ability to invoice an event
This commit is contained in:
@@ -3,6 +3,7 @@ from django.http import Http404, HttpResponseRedirect
|
||||
from django.views import generic
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.contrib import messages
|
||||
import datetime
|
||||
|
||||
from RIGS import models
|
||||
|
||||
@@ -25,7 +26,7 @@ class InvoiceDetail(generic.DetailView):
|
||||
|
||||
|
||||
class InvoiceVoid(generic.View):
|
||||
def get(self, request, *args, **kwargs):
|
||||
def get(self, *args, **kwargs):
|
||||
pk = kwargs.get('pk')
|
||||
object = get_object_or_404(models.Invoice, pk=pk)
|
||||
object.void = not object.void
|
||||
@@ -36,6 +37,35 @@ class InvoiceVoid(generic.View):
|
||||
return HttpResponseRedirect(reverse_lazy('invoice_detail', kwargs={'pk': object.pk}))
|
||||
|
||||
|
||||
class InvoiceArchive(generic.ListView):
|
||||
model = models.Invoice
|
||||
paginate_by = 25
|
||||
|
||||
|
||||
class InvoiceWaiting(generic.ListView):
|
||||
model = models.Event
|
||||
paginate_by = 25
|
||||
template_name = 'RIGS/event_invoice.html'
|
||||
|
||||
def get_queryset(self):
|
||||
events = self.model.objects.filter(is_rig=True, end_date__lt=datetime.date.today(),
|
||||
invoice__isnull=True).select_related('person', 'organisation', 'venue',
|
||||
'mic') # @todo find a way to select items
|
||||
return events
|
||||
|
||||
|
||||
class InvoiceEvent(generic.View):
|
||||
def get(self, *args, **kwargs):
|
||||
epk = kwargs.get('pk')
|
||||
event = models.Event.objects.get(pk=epk)
|
||||
invoice, created = models.Invoice.objects.get_or_create(event=event)
|
||||
|
||||
if created:
|
||||
invoice.invoice_date = datetime.date.today()
|
||||
|
||||
return HttpResponseRedirect(reverse_lazy('invoice_detail', kwargs={'pk': invoice.pk}))
|
||||
|
||||
|
||||
class PaymentCreate(generic.CreateView):
|
||||
model = models.Payment
|
||||
|
||||
|
||||
Reference in New Issue
Block a user