From 50ca7825695cebdb957fef7841f7a26974be19c9 Mon Sep 17 00:00:00 2001 From: FreneticScribbler Date: Wed, 18 Mar 2020 18:09:45 +0000 Subject: [PATCH] Start reworking invoice things --- RIGS/finance.py | 4 +- RIGS/models.py | 1 + RIGS/templates/event_detail.html | 136 +----------------- RIGS/templates/event_invoice.html | 100 ------------- RIGS/templates/event_table.html | 11 +- RIGS/templates/invoice_detail.html | 113 +++------------ RIGS/templates/invoice_list.html | 83 +++++------ RIGS/templates/invoice_list_active.html | 6 +- RIGS/templates/invoice_list_archive.html | 20 +-- RIGS/templates/invoice_list_waiting.html | 90 ++++++++++++ RIGS/templates/partials/auth_details.html | 52 +++++++ RIGS/templates/partials/event_details.html | 82 +++++++++++ .../partials/event_table_colour.html | 9 ++ RIGS/templates/payment_form.html | 74 +++++----- RIGS/urls.py | 3 + 15 files changed, 350 insertions(+), 434 deletions(-) delete mode 100644 RIGS/templates/event_invoice.html create mode 100644 RIGS/templates/invoice_list_waiting.html create mode 100644 RIGS/templates/partials/auth_details.html create mode 100644 RIGS/templates/partials/event_details.html create mode 100644 RIGS/templates/partials/event_table_colour.html diff --git a/RIGS/finance.py b/RIGS/finance.py index 38d8b883..2c458c82 100644 --- a/RIGS/finance.py +++ b/RIGS/finance.py @@ -51,6 +51,7 @@ class InvoiceIndex(generic.ListView): class InvoiceDetail(generic.DetailView): model = models.Invoice + template_name = 'invoice_detail.html' class InvoicePrint(generic.View): @@ -155,7 +156,7 @@ class InvoiceArchive(generic.ListView): class InvoiceWaiting(generic.ListView): model = models.Event paginate_by = 25 - template_name = 'event_invoice.html' + template_name = 'invoice_list_waiting.html' def get_context_data(self, **kwargs): context = super(InvoiceWaiting, self).get_context_data(**kwargs) @@ -203,6 +204,7 @@ class InvoiceEvent(generic.View): class PaymentCreate(generic.CreateView): model = models.Payment fields = ['invoice', 'date', 'amount', 'method'] + template_name = 'payment_form.html' def get_initial(self): initial = super(generic.CreateView, self).get_initial() diff --git a/RIGS/models.py b/RIGS/models.py index e7f0d689..dd6f2cfc 100644 --- a/RIGS/models.py +++ b/RIGS/models.py @@ -499,6 +499,7 @@ class EventAuthorisation(models.Model, RevisionMixin): return str("N%05d" % self.event.pk + ' (requested by ' + self.sent_by.initials + ')') +@reversion.register(follow=['payment_set']) class Invoice(models.Model): event = models.OneToOneField('Event', on_delete=models.CASCADE) invoice_date = models.DateField(auto_now_add=True) diff --git a/RIGS/templates/event_detail.html b/RIGS/templates/event_detail.html index edf6d5d8..a1401912 100644 --- a/RIGS/templates/event_detail.html +++ b/RIGS/templates/event_detail.html @@ -70,143 +70,11 @@ {% endif %}
-
-
Event Info
-
-
-
Event Venue
-
- {% if object.venue %} - - {{ object.venue }} - - {% endif %} -
- - {% if event.is_rig %} -
Event MIC
-
- {% if event.mic and perms.RIGS.view_profile %} - - {{ event.mic.name }} - - {% else %} - {{ event.mic.name }} - {% endif %} -
- {% endif %} - -
Status
-
{{ event.get_status_display }}
- -
 
- - {% if event.is_rig %} -
Crew Meet
-
{{ event.meet_at|date:"D d M Y H:i"|default:"TBC" }}
- - -
Access From
-
{{ event.access_at|date:"D d M Y H:i"|default:"TBC" }}
- {% endif %} - -
Event Starts
-
{{ event.start_date|date:"D d M Y" }} {{ event.start_time|date:"H:i" }}
- -
Event Ends
-
{{ event.end_date|date:"D d M Y" }} {{ event.end_time|date:"H:i" }}
- -
 
- -
Event Description
-
{{ event.description|linebreaksbr }}
- -
 
- -
Based On
-
- {% if object.based_on %} - - {% if object.based_on.is_rig %}N{{ object.based_on.pk|stringformat:"05d" }}{% else %} - {{ object.based_on.pk }}{% endif %} - {{ object.based_on.name }} {% if object.based_on.mic %}by {{ object.based_on.mic.name }}{% endif %} - - {% endif %} -
- - {% if event.dry_hire %} -
Checked In By
-
{{ object.checked_in_by.name }}
- {% endif %} - - {% if event.is_rig %} -
Collected By
-
{{ object.collector }}
- {% endif %} - - {% if event.is_rig and not event.internal and perms.RIGS.view_event %} -
 
-
PO
-
{{ object.purchase_order }}
- {% endif %} -
-
-
+ {% include 'partials/event_details.html' %}
{% if event.is_rig and event.internal and perms.RIGS.view_event %}
-
-
Client Authorisation
-
-
-
Authorisation Request
-
{{ object.auth_request_to|yesno:"Yes,No" }}
- -
By
-
{{ object.auth_request_by }}
- -
At
-
{{ object.auth_request_at|date:"D d M Y H:i"|default:"" }}
- -
To
-
{{ object.auth_request_to }}
-
-
 
-
-
Authorised
-
{{ object.authorised|yesno:"Yes,No" }}
- -
Authorised by
-
- {% if object.authorisation %} - {{ object.authorisation.name }} - ({{ object.authorisation.email }}) - {% endif %} -
- -
Authorised at
-
{{ object.authorisation.last_edited_at|date:"D d M Y H:i" }}
- -
Authorised amount
-
- {% if object.authorisation %} - £ {{ object.authorisation.amount|floatformat:"2" }} - {% endif %} -
- -
Requested by
-
{{ object.authorisation.sent_by }}
-
-
-
+ { include 'partials/auth_details.html' %}
{% endif %} {% if not request.is_ajax and perms.RIGS.view_event %} diff --git a/RIGS/templates/event_invoice.html b/RIGS/templates/event_invoice.html deleted file mode 100644 index a315286f..00000000 --- a/RIGS/templates/event_invoice.html +++ /dev/null @@ -1,100 +0,0 @@ -{% extends 'base_rigs.html' %} -{% load paginator from filters %} -{% load static %} - -{% block title %}Events for Invoice{% endblock %} - -{% block js %} - - -{% endblock %} - -{% block content %} -
-

Events for Invoice ({{count}} Events, £ {{ total|floatformat:2 }})

-

These events have happened, but paperwork has not yet been sent to treasury

- {% if is_paginated %} -
- {% paginator %} -
- {% endif %} -
- - - - - - - - - - - - - - {% for object in object_list %} - - - - - - - - - - {% endfor %} - -
Event #Start DateEvent NameClientCostMIC
N{{ object.pk|stringformat:"05d" }}
- {{ object.get_status_display }}
{{ object.start_date }} - {{ object.name }} - {% if object.is_rig and perms.RIGS.view_event and object.authorised %} - - {% endif %} - - {{ object.organisation.name }} -
- {{ object.internal|yesno:'Internal,External' }} -
- {{ object.sum_total|floatformat:2 }} -
- {% if not object.internal %}{{ object.purchase_order }}{% endif %} -
- {% if object.mic %} - {{ object.mic.initials }}
- - {% else %} - - {% endif %} -
- - - -
-
- {% if is_paginated %} -
- {% paginator %} -
- {% endif %} -
-{% endblock %} diff --git a/RIGS/templates/event_table.html b/RIGS/templates/event_table.html index 6deba94d..e6485b2d 100644 --- a/RIGS/templates/event_table.html +++ b/RIGS/templates/event_table.html @@ -10,16 +10,7 @@ {% for event in events %} - + {{ event.pk }} diff --git a/RIGS/templates/invoice_detail.html b/RIGS/templates/invoice_detail.html index 956dbd04..4824326a 100644 --- a/RIGS/templates/invoice_detail.html +++ b/RIGS/templates/invoice_detail.html @@ -11,15 +11,15 @@
@@ -29,7 +29,9 @@
-
Invoice Details
+
Invoice Details + {% if object.void %}(VOID){% elif object.is_closed %}(PAID){% else %}(OUTSTANDING){% endif %} +
{% if object.event.organisation %} {{ object.event.organisation.name }}
@@ -42,81 +44,13 @@
-
-
Event Details - {% if object.void %}(VOID){% elif object.is_closed %}(PAID){% else %}(OUTSTANDING){% endif %} - -
-
-
-
Event Number
-
N{{ object.event.pk|stringformat:"05d" }}
- -
Event
-
{{ object.event.name }}
- -
Event Venue
-
{{ object.event.venue }}
- -
Event MIC
-
{{ object.event.mic.name }}
- -
Event Starts
-
{{ object.event.start_date|date:"d M Y" }} {{ object.event.start_time|date:"H:i" }}
- -
Event Ends
-
{{ object.event.end_date|date:"d M Y" }} {{ object.event.end_time|date:"H:i" }}
- -
Status
-
{{ object.event.get_status_display }}
- - {% if object.event.dry_hire %} -
 
-
Checked In By
-
{{ object.checked_in_by.name }}
- {% endif %} - -
 
- -
Authorised
-
{{ object.event.authorised|yesno:"Yes,No" }}
- -
Authorised by
-
- {% if object.event.authorised %} - {{ object.event.authorisation.name }} - ({{ object.event.authorisation.email }}) - {% endif %} -
- - {% if object.event.internal %} - {# internal #} -
Uni ID
-
{{ object.event.authorisation.uni_id }}
- -
Account code
-
{{ object.event.authorisation.account_code }}
- {% else %} -
PO
-
{{ object.event.purchase_order }}
- {% endif %} - -
Authorised at
-
{{ object.event.authorisation.last_edited_at }}
- -
Authorised amount
-
- {% if object.event.authorised %} - £ {{ object.event.authorisation.amount|floatformat:"2" }} - {% endif %} -
- -
Authorisation request sent by
-
{{ object.authorisation.sent_by }}
-
-
-
+ {% include 'partials/event_details.html' %}
+ {% if object.event.internal %} +
+ {% include 'partials/auth_details.html' %} +
+ {% endif %}
@@ -132,22 +66,21 @@
- - - - - - + + {% for payment in object.payment_set.all %} - + {% endfor %} @@ -171,7 +104,7 @@ + {% include 'partials/last_edited.html' with target="invoice_history" %} - {% endblock %} diff --git a/RIGS/templates/invoice_list.html b/RIGS/templates/invoice_list.html index d4351c04..47349be6 100644 --- a/RIGS/templates/invoice_list.html +++ b/RIGS/templates/invoice_list.html @@ -1,5 +1,6 @@ {% extends 'base_rigs.html' %} {% load paginator from filters %} +{% load static %} {% block title %}Invoices{% endblock %} @@ -7,67 +8,51 @@

{% block heading %}Invoices{% endblock %}

{% block description %}{% endblock %} - {% if is_paginated %} -
- {% paginator %} -
- {% endif %} {% block search %}{% endblock %}
DateAmountMethod
Date + Amount + Method + +
{{ payment.date }}{{ payment.date }} {{ payment.amount|floatformat:2 }} {{ payment.get_method_display }} - +
- - - - - - - - - - + + + + + + + + + + - {% for object in object_list %} - - - + + - - - + + @@ -76,9 +61,9 @@
Invoice #EventClientEvent DateInvoice DateBalance
Invoice #EventClientEvent DateInvoice DateBalance
{{ object.pk }}
- {% if object.void %}(VOID){% elif object.is_closed %}(PAID){% else %}(O/S){% endif %}
N{{ object.event.pk|stringformat:"05d" }}: {{ object.event.name }}
- {{ object.event.get_status_display }}{% if not object.event.mic %}, No MIC{% endif %} + {% for invoice in invoice_list %} +
{{ invoice.pk }}
+ {% if invoice.void %}(VOID){% elif invoice.is_closed %}(PAID){% else %}(O/S){% endif %}
N{{ invoice.event.pk|stringformat:"05d" }}: {{ invoice.event.name }}
+ {{ invoice.event.get_status_display }}{% if not invoice.event.mic %}, No MIC{% endif %}
{% if object.event.organisation %} - {{ object.event.organisation.name }} + {% if invoice.event.organisation %} + {{ invoice.event.organisation.name }}
- {{ object.event.internal|yesno:'Internal,External' }} - {% else %} - {{ object.event.person.name }} + {{ invoice.event.internal|yesno:'Internal,External' }} + {% elif invoice.event.person %} + {{ invoice.event.person.name }}
- External + Individual {% endif %}
{{ object.event.start_date }}{{ object.invoice_date }}{{ invoice.event.start_date }}{{ invoice.invoice_date }} - {{ object.balance|floatformat:2 }} + {{ invoice.balance|floatformat:2 }} + {% if not invoice.event.internal %}
- {{ object.event.purchase_order }} + {{ invoice.event.purchase_order }} + {% endif %}
- - + +
{% if is_paginated %} -
- {% paginator %} -
+
+ {% paginator %} +
{% endif %}
{% endblock %} diff --git a/RIGS/templates/invoice_list_active.html b/RIGS/templates/invoice_list_active.html index 23bfc768..4a9c03aa 100644 --- a/RIGS/templates/invoice_list_active.html +++ b/RIGS/templates/invoice_list_active.html @@ -1,13 +1,13 @@ -{% extends 'RIGS/invoice_list.html' %} +{% extends 'invoice_list.html' %} {% block title %} Outstanding Invoices {% endblock %} {% block heading %} -Outstanding Invoices ({{ count }} Events, £ {{ total|floatformat:2 }}) +Outstanding Invoices ({{ count }} Events, £{{ total|floatformat:2 }}) {% endblock %} {% block description %}

Paperwork for these events has been sent to treasury, but the full balance has not yet appeared on a ledger

-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/RIGS/templates/invoice_list_archive.html b/RIGS/templates/invoice_list_archive.html index f0335f2f..32585657 100644 --- a/RIGS/templates/invoice_list_archive.html +++ b/RIGS/templates/invoice_list_archive.html @@ -1,4 +1,4 @@ -{% extends 'RIGS/invoice_list.html' %} +{% extends 'invoice_list.html' %} {% block title %} Invoice Archive @@ -13,12 +13,12 @@ All Invoices {% endblock %} {% block search %} -
-
-
- -
-
-
-{% endblock %} \ No newline at end of file +
+
+
+ +
+
+
+{% endblock %} diff --git a/RIGS/templates/invoice_list_waiting.html b/RIGS/templates/invoice_list_waiting.html new file mode 100644 index 00000000..81cda4e3 --- /dev/null +++ b/RIGS/templates/invoice_list_waiting.html @@ -0,0 +1,90 @@ +{% extends 'base_rigs.html' %} +{% load paginator from filters %} +{% load static %} + +{% block title %}Events for Invoice{% endblock %} + +{% block js %} + + +{% endblock %} + +{% block content %} +
+

Events for Invoice ({{count}} Events, £{{ total|floatformat:2 }})

+

These events have happened, but paperwork has not yet been sent to treasury

+
+ + + + + + + + + + + + + + {% for event in object_list %} + + + + + + + + + + {% endfor %} + +
Event #Start DateEvent NameClientCostMIC
N{{ event.pk|stringformat:"05d" }}
+ {{ event.get_status_display }}
{{ event.start_date }} + {{ event.name }} + {% if event.is_rig and perms.RIGS.view_event and event.authorised %} + + {% endif %} + + {% if event.organisation %} + {{ event.organisation.name }} +
+ {{ event.internal|yesno:'Internal,External' }} + {% elif event.person %} + {{ event.person.name }} +
+ Individual + {% else %} + + {% endif %} +
+ {{ event.sum_total|floatformat:2 }} +
+ {% if not event.internal %}{{ event.purchase_order }}{% endif %} +
+ {% if event.mic %} + {{ event.mic.initials }}
+ + {% else %} + + {% endif %} +
+ + Paperwork Sent + +
+
+ {% if is_paginated %} +
+ {% paginator %} +
+ {% endif %} +
+{% endblock %} diff --git a/RIGS/templates/partials/auth_details.html b/RIGS/templates/partials/auth_details.html new file mode 100644 index 00000000..fbc07d11 --- /dev/null +++ b/RIGS/templates/partials/auth_details.html @@ -0,0 +1,52 @@ +
+
Client Authorisation
+
+
+
Authorisation Request
+
{{ object.auth_request_to|yesno:"Yes,No" }}
+ +
By
+
{{ object.auth_request_by }}
+ +
At
+
{{ object.auth_request_at|date:"D d M Y H:i"|default:"" }}
+ +
To
+
{{ object.auth_request_to }}
+
+
 
+
+
Authorised
+
{{ object.authorised|yesno:"Yes,No" }}
+ +
Authorised by
+
+ {% if object.authorisation %} + {{ object.authorisation.name }} + ({{ object.authorisation.email }}) + {% endif %} +
+ +
Authorised at
+
{{ object.authorisation.last_edited_at|date:"D d M Y H:i" }}
+ +
Authorised amount
+
+ {% if object.authorisation %} + £ {{ object.authorisation.amount|floatformat:"2" }} + {% endif %} +
+ +
Requested by
+
{{ object.authorisation.sent_by }}
+
+
+
diff --git a/RIGS/templates/partials/event_details.html b/RIGS/templates/partials/event_details.html new file mode 100644 index 00000000..5815646d --- /dev/null +++ b/RIGS/templates/partials/event_details.html @@ -0,0 +1,82 @@ +
+
Event Info
+
+
+
Event Venue
+
+ {% if object.venue %} + + {{ object.venue }} + + {% endif %} +
+ + {% if event.is_rig %} +
Event MIC
+
+ {% if event.mic and perms.RIGS.view_profile %} + + {{ event.mic.name }} + + {% else %} + {{ event.mic.name }} + {% endif %} +
+ {% endif %} + +
Status
+
{{ event.get_status_display }}
+ +
 
+ + {% if event.is_rig %} +
Crew Meet
+
{{ event.meet_at|date:"D d M Y H:i"|default:"TBC" }}
+ + +
Access From
+
{{ event.access_at|date:"D d M Y H:i"|default:"TBC" }}
+ {% endif %} + +
Event Starts
+
{{ event.start_date|date:"D d M Y" }} {{ event.start_time|date:"H:i" }}
+ +
Event Ends
+
{{ event.end_date|date:"D d M Y" }} {{ event.end_time|date:"H:i" }}
+ +
 
+ +
Event Description
+
{{ event.description|linebreaksbr }}
+ +
 
+ +
Based On
+
+ {% if object.based_on %} + + {% if object.based_on.is_rig %}N{{ object.based_on.pk|stringformat:"05d" }}{% else %} + {{ object.based_on.pk }}{% endif %} + {{ object.based_on.name }} {% if object.based_on.mic %}by {{ object.based_on.mic.name }}{% endif %} + + {% endif %} +
+ + {% if event.dry_hire %} +
Checked In By
+
{{ object.checked_in_by.name }}
+ {% endif %} + + {% if event.is_rig %} +
Collected By
+
{{ object.collector }}
+ {% endif %} + + {% if event.is_rig and not event.internal and perms.RIGS.view_event %} +
 
+
PO
+
{{ object.purchase_order }}
+ {% endif %} +
+
+
diff --git a/RIGS/templates/partials/event_table_colour.html b/RIGS/templates/partials/event_table_colour.html new file mode 100644 index 00000000..c0c92050 --- /dev/null +++ b/RIGS/templates/partials/event_table_colour.html @@ -0,0 +1,9 @@ +class="{% if event.cancelled %} + text-muted table-secondary + {% elif event.authorised and event.risk_assessment_edit_url and event.mic %} + table-success + {% elif not event.is_rig %} + table-info + {% else %} + table-warning + {% endif %}" diff --git a/RIGS/templates/payment_form.html b/RIGS/templates/payment_form.html index 13f4a694..30f5d1b9 100644 --- a/RIGS/templates/payment_form.html +++ b/RIGS/templates/payment_form.html @@ -4,48 +4,48 @@ {% block title %}Add Payment{% endblock %} {% block content %} -
-
-
{% csrf_token %} - +
+
+ + {% csrf_token %} + -
- {% include 'form_errors.html' %} -
- - -
- {% render_field form.date class+="form-control" %} -
+
+ {% include 'form_errors.html' %} +
+ +
+ {% render_field form.date class+="form-control" %}
+
-
- - -
-
-
£
- {% render_field form.amount class+="form-control" %} +
+ +
+
+
+ £
-
-
-
- - -
- {% render_field form.method class+="form-control" %} -
-
-
-
- + {% render_field form.amount class+="form-control" %}
- -
+
+ +
+ {% render_field form.method class+="form-control" %} +
+
+
+
+ +
+
+
+
-{% endblock %} \ No newline at end of file +
+{% endblock %} diff --git a/RIGS/urls.py b/RIGS/urls.py index d4df5b44..55d0cd79 100644 --- a/RIGS/urls.py +++ b/RIGS/urls.py @@ -105,6 +105,9 @@ urlpatterns = [ name='invoice_void'), path('invoice//delete/', permission_required_with_403('RIGS.change_invoice')(finance.InvoiceDelete.as_view()), name='invoice_delete'), + path('invoice/(/history/', permission_required_with_403('RIGS.view_invoice')(versioning.VersionHistory.as_view()), + name='invoice_history', kwargs={'model': models.Invoice}), + path('payment/create/', permission_required_with_403('RIGS.add_payment')(finance.PaymentCreate.as_view()), name='payment_create'), path('payment//delete/', permission_required_with_403('RIGS.add_payment')(finance.PaymentDelete.as_view()),