diff --git a/RIGS/hs.py b/RIGS/hs.py index 72719ec7..33fa5d80 100644 --- a/RIGS/hs.py +++ b/RIGS/hs.py @@ -82,7 +82,7 @@ class EventRiskAssessmentList(generic.ListView): template_name = 'hs_object_list.html' def get_queryset(self): - return self.model.objects.order_by('reviewed_at').select_related('event') + return self.model.objects.exclude(event__status=models.Event.CANCELLED).order_by('reviewed_at').select_related('event') def get_context_data(self, **kwargs): context = super(EventRiskAssessmentList, self).get_context_data(**kwargs) @@ -187,6 +187,9 @@ class EventChecklistList(generic.ListView): model = models.EventChecklist template_name = 'hs_object_list.html' + def get_queryset(self): + return self.model.objects.exclude(event__status=models.Event.CANCELLED).order_by('reviewed_at').select_related('event') + def get_context_data(self, **kwargs): context = super(EventChecklistList, self).get_context_data(**kwargs) context['title'] = 'Event Checklist' @@ -215,7 +218,7 @@ class HSList(generic.ListView): template_name = 'hs_list.html' def get_queryset(self): - return models.Event.objects.all().order_by('-start_date').select_related('riskassessment').prefetch_related('checklists') + return models.Event.objects.all().exclude(status=models.Event.CANCELLED).order_by('-start_date').select_related('riskassessment').prefetch_related('checklists') def get_context_data(self, **kwargs): context = super(HSList, self).get_context_data(**kwargs) diff --git a/RIGS/models.py b/RIGS/models.py index 76e43c66..5d2b821b 100644 --- a/RIGS/models.py +++ b/RIGS/models.py @@ -370,6 +370,9 @@ class Event(models.Model, RevisionMixin): @property def vat(self): + # No VAT is owed on internal transfers + if self.internal: + return 0 return Decimal(self.sum_total * self.vat_rate.rate).quantize(Decimal('.01')) """ diff --git a/RIGS/templates/event_checklist_detail.html b/RIGS/templates/event_checklist_detail.html index 8c5a34d0..f868e4f5 100644 --- a/RIGS/templates/event_checklist_detail.html +++ b/RIGS/templates/event_checklist_detail.html @@ -8,7 +8,7 @@
{% button 'edit' url='ec_edit' pk=object.pk %} - {% button 'view' url='event_detail' pk=object.pk text="Event" %} + {% button 'view' url='event_detail' pk=object.event.pk text="Event" %} {% include 'partials/review_status.html' with perm=perms.RIGS.review_eventchecklist review='ec_review' %}
diff --git a/RIGS/templates/event_print_page.xml b/RIGS/templates/event_print_page.xml index e8495af2..b3d7ecfa 100644 --- a/RIGS/templates/event_print_page.xml +++ b/RIGS/templates/event_print_page.xml @@ -190,19 +190,21 @@ {% endif %} - £ {{ item.cost|floatformat:2 }} + £{{ item.cost|floatformat:2 }} {{ item.quantity }} - £ {{ item.total_cost|floatformat:2 }} + £{{ item.total_cost|floatformat:2 }} {% endfor %} + {% if object.vat > 0 %} - {% if quote %}VAT Registration Number: 170734807{% endif %} - Total (ex. VAT) + {% if quote %}VAT Registration Number: 170734807 + Total (ex. VAT){% endif %} £ {{ object.sum_total|floatformat:2 }} + {% endif %} {% if quote %} @@ -211,8 +213,10 @@ {% endif %} + {% if object.vat > 0 %} VAT @ {{ object.vat_rate.as_percent|floatformat:2 }}% - £ {{ object.vat|floatformat:2 }} + £{{ object.vat|floatformat:2 }} + {% endif %} @@ -224,7 +228,7 @@ {% if invoice %} Total - £ {{ object.total|floatformat:2 }} + £{{ object.total|floatformat:2 }} {% else %} @@ -233,7 +237,7 @@ - £ {{ object.total|floatformat:2 }} + £{{ object.total|floatformat:2 }} {% endif %} @@ -267,7 +271,7 @@ {{ payment.get_method_display }} {{ payment.date }} - £ {{ payment.amount|floatformat:2 }} + £{{ payment.amount|floatformat:2 }} {% endfor %} @@ -275,18 +279,18 @@ Payment Total - £ {{ object.invoice.payment_total|floatformat:2 }} + £{{ object.invoice.payment_total|floatformat:2 }} - Balance (ex. VAT) + Balance {% if object.vat > 0 %}(ex. VAT){% endif %} - £ {{ object.invoice.balance|floatformat:2 }} + £{{ object.invoice.balance|floatformat:2 }} @@ -316,7 +320,7 @@ General Enquires and 24 Hour Emergency Contact: 0115 84 68720 - {% else %} + {% elif object.vat > 0 %} VAT Registration Number: 170734807 diff --git a/RIGS/templates/hs_list.html b/RIGS/templates/hs_list.html index 0a11b99b..221eecd2 100644 --- a/RIGS/templates/hs_list.html +++ b/RIGS/templates/hs_list.html @@ -4,10 +4,11 @@ {% block content %}
- +
+ @@ -16,7 +17,8 @@ {% for event in object_list %} - + + - + - + {% if edit %}
EventMIC Dates RA Checklists
{{ event }}{{ event }}
{{ event.get_status_display }}
{% if event.mic is not None %}{% else %}{% endif %}{{ event.mic }}{% if event.mic is not None %}{% else %}{%endif%} {{ event.start_date|date:"D d/m/Y" }} diff --git a/RIGS/templates/hs_object_list.html b/RIGS/templates/hs_object_list.html index c9029a02..c3ebaf4d 100644 --- a/RIGS/templates/hs_object_list.html +++ b/RIGS/templates/hs_object_list.html @@ -15,7 +15,7 @@
- +
@@ -32,7 +32,7 @@ {% for object in object_list %} {# General #} - + {% for field in object_list.0.fieldz %} {% endfor %} diff --git a/RIGS/templates/item_row.html b/RIGS/templates/item_row.html index fa4cf7ca..b71facd8 100644 --- a/RIGS/templates/item_row.html +++ b/RIGS/templates/item_row.html @@ -6,11 +6,11 @@ {% if perms.RIGS.view_event %} - + {% endif %} {% if perms.RIGS.view_event %} - + {% endif %} {% if edit %} + - - + + + {% if object.vat > 0 or not object.pk %} {% if not object.pk %} {% endif %} - + - + + {% endif %} {% endif %}
Event
{{ object.event }}{{ object.event }}
{{ object.event.get_status_display }}
{{ object|get_field:field }} £ {{item.cost|floatformat:2}}£{{item.cost|floatformat:2}}{{item.quantity}}£ {{item.total_cost|floatformat:2}}£{{item.total_cost|floatformat:2}} diff --git a/RIGS/templates/partials/item_table.html b/RIGS/templates/partials/item_table.html index 305ca335..50be6b84 100644 --- a/RIGS/templates/partials/item_table.html +++ b/RIGS/templates/partials/item_table.html @@ -27,12 +27,13 @@ {% endfor %} {% if auth or perms.RIGS.view_event %} -
Total (ex. VAT)£ {{object.sum_total|default:0|floatformat:2}}Total {% if object.vat > 0 or not object.pk %}(ex. VAT){% endif %}£{{object.sum_total|default:0|floatformat:2}}
VAT @ @@ -41,12 +42,13 @@ VAT @ {{object.vat_rate.as_percent|floatformat|default:"TBD"}}%£ {{object.vat|default:0|floatformat:2}}£{{object.vat|default:0|floatformat:2}}
Total£ {{object.total|default:0|floatformat:2}}£{{object.total|default:0|floatformat:2}}
@@ -59,9 +61,9 @@
£ £ £ £
diff --git a/assets/converters.py b/assets/converters.py new file mode 100644 index 00000000..da55d2e6 --- /dev/null +++ b/assets/converters.py @@ -0,0 +1,8 @@ +class AssetIDConverter: # Forces lowercase to uppercase + regex = '[^/]+' + + def to_python(self, value): + return str(value).upper() + + def to_url(self, value): + return str(value).upper() diff --git a/assets/urls.py b/assets/urls.py index 468a2421..4ec111c1 100644 --- a/assets/urls.py +++ b/assets/urls.py @@ -1,22 +1,24 @@ from django.contrib.auth.decorators import login_required -from django.urls import path +from django.urls import path, register_converter from django.views.decorators.clickjacking import xframe_options_exempt from PyRIGS.decorators import has_oembed, permission_required_with_403 from PyRIGS.views import OEmbedView -from assets import views +from . import views, converters + +register_converter(converters.AssetIDConverter, 'asset') urlpatterns = [ path('', login_required(views.AssetList.as_view()), name='asset_index'), path('asset/list/', login_required(views.AssetList.as_view()), name='asset_list'), - path('asset/id//', has_oembed(oembed_view="asset_oembed")(views.AssetDetail.as_view()), name='asset_detail'), + path('asset/id//', has_oembed(oembed_view="asset_oembed")(views.AssetDetail.as_view()), name='asset_detail'), path('asset/create/', permission_required_with_403('assets.add_asset') (views.AssetCreate.as_view()), name='asset_create'), - path('asset/id//edit/', permission_required_with_403('assets.change_asset') + path('asset/id//edit/', permission_required_with_403('assets.change_asset') (views.AssetEdit.as_view()), name='asset_update'), - path('asset/id//duplicate/', permission_required_with_403('assets.add_asset') + path('asset/id//duplicate/', permission_required_with_403('assets.add_asset') (views.AssetDuplicate.as_view()), name='asset_duplicate'), - path('asset/id//label', login_required(views.GenerateLabel.as_view()), name='generate_label'), + path('asset/id//label', login_required(views.GenerateLabel.as_view()), name='generate_label'), path('cabletype/list/', login_required(views.CableTypeList.as_view()), name='cable_type_list'), path('cabletype/create/', permission_required_with_403('assets.add_cable_type')(views.CableTypeCreate.as_view()), name='cable_type_create'), diff --git a/assets/views.py b/assets/views.py index 6acee29d..261d9753 100644 --- a/assets/views.py +++ b/assets/views.py @@ -48,9 +48,9 @@ class AssetList(LoginRequiredMixin, generic.ListView): queryset = self.model.objects.all() elif len(query_string) >= 3: queryset = self.model.objects.filter( - Q(asset_id__exact=query_string) | Q(description__icontains=query_string) | Q(serial_number__exact=query_string)) + Q(asset_id__exact=query_string.upper()) | Q(description__icontains=query_string) | Q(serial_number__exact=query_string)) else: - queryset = self.model.objects.filter(Q(asset_id__exact=query_string)) + queryset = self.model.objects.filter(Q(asset_id__exact=query_string.upper())) if form.cleaned_data['category']: queryset = queryset.filter(category__in=form.cleaned_data['category']) diff --git a/templates/base_ajax.html b/templates/base_ajax.html index 49e9ddd6..435b7607 100644 --- a/templates/base_ajax.html +++ b/templates/base_ajax.html @@ -1,7 +1,7 @@