diff --git a/inventory/__pycache__/views.cpython-311.pyc b/inventory/__pycache__/views.cpython-311.pyc index 5e9e0822..38d47dd9 100644 Binary files a/inventory/__pycache__/views.cpython-311.pyc and b/inventory/__pycache__/views.cpython-311.pyc differ diff --git a/inventory/templatetags/__pycache__/custom_filters.cpython-311.pyc b/inventory/templatetags/__pycache__/custom_filters.cpython-311.pyc index a6cb025f..9c078ef4 100644 Binary files a/inventory/templatetags/__pycache__/custom_filters.cpython-311.pyc and b/inventory/templatetags/__pycache__/custom_filters.cpython-311.pyc differ diff --git a/inventory/templatetags/custom_filters.py b/inventory/templatetags/custom_filters.py index 93e3ff05..69570a5c 100644 --- a/inventory/templatetags/custom_filters.py +++ b/inventory/templatetags/custom_filters.py @@ -2,6 +2,7 @@ from random import randint from django import template from calendar import month_abbr from django.urls import reverse +from django.utils.formats import number_format from django_ledger.io.io_core import get_localdate,validate_activity from django.conf import settings from django.utils.translation import get_language @@ -352,4 +353,10 @@ def date_picker(context, nav_url=None, date_picker_id=None): @register.filter def splitlines(value): """Splits text into lines""" - return value.splitlines() \ No newline at end of file + return value.splitlines() + +@register.filter(name='currency_format') +def currency_format(value): + if not value: + value = 0.00 + return number_format(value, decimal_pos=2, use_l10n=True, force_grouping=True) \ No newline at end of file diff --git a/inventory/views.py b/inventory/views.py index 08f9fd8f..ccbd3e2f 100644 --- a/inventory/views.py +++ b/inventory/views.py @@ -1280,15 +1280,14 @@ class CustomerDetailView(LoginRequiredMixin, DetailView): dealer = get_user_type(self.request) entity = dealer.entity context = super().get_context_data(**kwargs) - # customer = f"{context['customer'].first_name} {context['customer'].middle_name} {context['customer'].last_name}" - # context["estimates"] = entity.get_estimates().filter( - # customer__customer_name=name - # ) + estimates = entity.get_estimates().filter(customer=self.object) invoices = entity.get_invoices().filter(customer=self.object) + # txs = entity. transactions(customer=self.object) total = estimates.count() + invoices.count() context["estimates"] = estimates context["invoices"] = invoices + # context["txs"] = txs context["total"] = total @@ -2632,6 +2631,7 @@ def account_delete(request, pk): # Sales list +@login_required def sales_list_view(request): dealer = get_user_type(request) entity = dealer.entity diff --git a/templates/customers/note_form.html b/templates/customers/note_form.html index 19cd30fe..6e829d3c 100644 --- a/templates/customers/note_form.html +++ b/templates/customers/note_form.html @@ -1,11 +1,7 @@ {% load i18n static crispy_forms_filters %} - -
\ No newline at end of file + + \ No newline at end of file diff --git a/templates/customers/view_customer.html b/templates/customers/view_customer.html index cb3ad776..c6bcd194 100644 --- a/templates/customers/view_customer.html +++ b/templates/customers/view_customer.html @@ -1,5 +1,5 @@ {% extends "base.html" %} -{% load i18n static crispy_forms_filters%} +{% load i18n static crispy_forms_filters custom_filters%} {% block title %}{{ _("View Customer") }}{% endblock title %} @@ -41,7 +41,7 @@{{ customer.created|timesince}}