mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 05:22:16 +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
|
||||
|
||||
|
||||
26
RIGS/migrations/0018_auto_20150130_0016.py
Normal file
26
RIGS/migrations/0018_auto_20150130_0016.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('RIGS', '0017_auto_20150129_2041'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='invoice',
|
||||
name='void',
|
||||
field=models.BooleanField(default=False),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='payment',
|
||||
name='method',
|
||||
field=models.CharField(max_length=2, choices=[(b'C', b'Cash'), (b'I', b'Internal'), (b'E', b'External'),
|
||||
(b'SU', b'SU Core')]),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
||||
@@ -15,6 +15,10 @@
|
||||
class="glyphicon glyphicon-print"></span></a>
|
||||
<a href="{% url 'event_duplicate' event.pk %}" class="btn btn-default" title="Duplicate Rig"><span
|
||||
class="glyphicon glyphicon-duplicate"></span></a>
|
||||
{% if perms.RIGS.add_invoice %}
|
||||
<a href="{% url 'invoice_event' event.pk %}" class="btn btn-default" title="Duplicate Rig"><span
|
||||
class="glyphicon glyphicon-gbp"></span></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -121,6 +125,10 @@
|
||||
class="glyphicon glyphicon-print"></span></a>
|
||||
<a href="{% url 'event_duplicate' event.pk %}" class="btn btn-default" title="Duplicate Rig"><span
|
||||
class="glyphicon glyphicon-duplicate"></span></a>
|
||||
{% if perms.RIGS.add_invoice %}
|
||||
<a href="{% url 'invoice_event' event.pk %}" class="btn btn-default" title="Duplicate Rig"><span
|
||||
class="glyphicon glyphicon-gbp"></span></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12">
|
||||
@@ -145,6 +153,10 @@
|
||||
class="glyphicon glyphicon-print"></span></a>
|
||||
<a href="{% url 'event_duplicate' event.pk %}" class="btn btn-default" title="Duplicate Rig"><span
|
||||
class="glyphicon glyphicon-duplicate"></span></a>
|
||||
{% if perms.RIGS.add_invoice %}
|
||||
<a href="{% url 'invoice_event' event.pk %}" class="btn btn-default" title="Duplicate Rig"><span
|
||||
class="glyphicon glyphicon-gbp"></span></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div>Last edited at {{ object.last_edited_at|date:"SHORT_DATETIME_FORMAT" }}
|
||||
by {{ object.last_edited_by.name }}.
|
||||
|
||||
70
RIGS/templates/RIGS/event_invoice.html
Normal file
70
RIGS/templates/RIGS/event_invoice.html
Normal file
@@ -0,0 +1,70 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load paginator from filters %}
|
||||
|
||||
{% block title %}Events for Invoice{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-sm-12">
|
||||
<h2>Events for Invoice</h2>
|
||||
{% if is_paginated %}
|
||||
<div class="col-md-6 col-md-offset-6 col-sm-12 text-right">
|
||||
{% paginator %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<table class="table table-responsive table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="hiddenx-xs">#</th>
|
||||
<th>Date</th>
|
||||
<th>Event</th>
|
||||
<th>Client</th>
|
||||
<th>Cost</th>
|
||||
<th class="hidden-xs">MIC</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for object in object_list %}
|
||||
<tr class="
|
||||
{% if event.cancelled %}
|
||||
active
|
||||
{% elif event.confirmed and event.mic or not event.is_rig %}
|
||||
{# interpreated as (booked and mic) or is non rig #}
|
||||
success
|
||||
{% elif event.mic %}
|
||||
warning
|
||||
{% else %}
|
||||
danger
|
||||
{% endif %}
|
||||
">
|
||||
<td class="hidden-xs">N{{ object.pk|stringformat:"05d" }}</td>
|
||||
<td>{{ object.end_date }}</td>
|
||||
<td>{{ object.name }}</td>
|
||||
<td>
|
||||
{% if object.organisation %}
|
||||
{{ object.organisation.name }}
|
||||
{% else %}
|
||||
{{ object.person.name }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ object.sum_total|floatformat:2 }}</td>
|
||||
<td class="text-center">
|
||||
{{ object.mic.initials }}<br/>
|
||||
<img src="{{ object.mic.profile_picture }}" class="event-mic-photo"/>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<a href="{% url 'invoice_event' object.pk %}" class="btn btn-default">
|
||||
<span class="glyphicon glyphicon-pencil"></span>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% if is_paginated %}
|
||||
<div class="col-md-6 col-md-offset-6 col-sm-12 text-right">
|
||||
{% paginator %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -4,7 +4,17 @@
|
||||
|
||||
{% block content %}
|
||||
<div class="col-sm-12">
|
||||
<h2>Invoice {{ object.pk }}</h2>
|
||||
<div class="row">
|
||||
<div class="col-sm-8">
|
||||
<h2>Invoice {{ object.pk }}</h2>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-4 text-right">
|
||||
<a href="{% url 'invoice_void' object.pk %}" class="btn btn-default" title="Void Invoice">
|
||||
<span class="glyphicon glyphicon-text-background"></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load paginator from filters %}
|
||||
|
||||
{% block title %}Active Invoices{% endblock %}
|
||||
{% block title %}Invoices{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-sm-12">
|
||||
<h2>Active Invoices</h2>
|
||||
<h2>Invoices</h2>
|
||||
{% if is_paginated %}
|
||||
<div class="col-md-6 col-md-offset-6 col-sm-12 text-right">
|
||||
{% paginator %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<table class="table table-responsive table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -17,8 +23,8 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for object in object_list %}
|
||||
<tr>
|
||||
<td>{{ object.pk }}</td>
|
||||
<tr class="{% if object.void %}danger{% elif object.balance == 0 %}success{% endif %}">
|
||||
<td>{{ object.pk }}</td>
|
||||
<td>{{ object.event }}</td>
|
||||
<td>{{ object.invoice_date }}</td>
|
||||
<td>{{ object.balance|floatformat:2 }}</td>
|
||||
@@ -31,5 +37,10 @@
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% if is_paginated %}
|
||||
<div class="col-md-6 col-md-offset-6 col-sm-12 text-right">
|
||||
{% paginator %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
12
RIGS/urls.py
12
RIGS/urls.py
@@ -77,10 +77,22 @@ urlpatterns = patterns('',
|
||||
url(r'^event/archive/$', login_required()(rigboard.EventArchive.as_view()),
|
||||
name='event_archive'),
|
||||
|
||||
|
||||
# Finance
|
||||
url(r'^invoice/$',
|
||||
permission_required_with_403('RIGS.view_invoice')(finance.InvoiceIndex.as_view()),
|
||||
name='invoice_list'),
|
||||
url(r'^invoice/archive/$',
|
||||
permission_required_with_403('RIGS.view_invoice')(finance.InvoiceArchive.as_view()),
|
||||
name='invoice_archive'),
|
||||
url(r'^invoice/waiting/$',
|
||||
permission_required_with_403('RIGS.add_invoice')(finance.InvoiceWaiting.as_view()),
|
||||
name='invoice_waiting'),
|
||||
|
||||
url(r'^event/(?P<pk>\d+)/invoice/$',
|
||||
permission_required_with_403('RIGS.add_invoice')(finance.InvoiceEvent.as_view()),
|
||||
name='invoice_event'),
|
||||
|
||||
url(r'^invoice/(?P<pk>\d+)/$',
|
||||
permission_required_with_403('RIGS.view_invoice')(finance.InvoiceDetail.as_view()),
|
||||
name='invoice_detail'),
|
||||
|
||||
Reference in New Issue
Block a user