From f136b269374ab88964906624b0eb450f5b969e18 Mon Sep 17 00:00:00 2001 From: Faheedkhan Date: Mon, 1 Sep 2025 14:22:11 +0300 Subject: [PATCH 1/2] gross profit loss---negative filter --- inventory/templatetags/custom_filters.py | 11 ++++++++++- .../dashboards/partials/financial_data_cards.html | 11 +++++++++-- templates/items/service/service_create.html | 2 +- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/inventory/templatetags/custom_filters.py b/inventory/templatetags/custom_filters.py index 72f5c9f8..f096dcf0 100644 --- a/inventory/templatetags/custom_filters.py +++ b/inventory/templatetags/custom_filters.py @@ -13,7 +13,16 @@ from django.db.models import Case, Value, When, IntegerField register = template.Library() - +@register.filter +def is_negative(value): + """ + Checks if the given value is a negative number. + """ + try: + return float(value) < 0 + except (ValueError, TypeError): + return False + @register.filter def get_percentage(value, total): try: diff --git a/templates/dashboards/partials/financial_data_cards.html b/templates/dashboards/partials/financial_data_cards.html index 373b5072..e3216c64 100644 --- a/templates/dashboards/partials/financial_data_cards.html +++ b/templates/dashboards/partials/financial_data_cards.html @@ -302,9 +302,16 @@

{% trans "Gross Profit" %}

-

+ + {% if gross_profit|is_negative %} +

{{ gross_profit|floatformat:2 }} -

+ + {% else %} +

+ {{ gross_profit|floatformat:2 }} +

+ {% endif %}
diff --git a/templates/items/service/service_create.html b/templates/items/service/service_create.html index c8ff00d9..8f4dd33e 100644 --- a/templates/items/service/service_create.html +++ b/templates/items/service/service_create.html @@ -11,7 +11,7 @@ {% endif %} {% endblock %} {% block content %} -
+
-- 2.39.5 From 9cfccf5f7e22549118ec5bd9a8bb7d9e72f84908 Mon Sep 17 00:00:00 2001 From: Faheedkhan Date: Mon, 1 Sep 2025 14:50:05 +0300 Subject: [PATCH 2/2] permissions --- inventory/models.py | 2 ++ templates/dashboards/partials/financial_data_cards.html | 1 + templates/users/user_list.html | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/inventory/models.py b/inventory/models.py index a3986995..4f9e8aa2 100644 --- a/inventory/models.py +++ b/inventory/models.py @@ -3190,6 +3190,7 @@ class CustomGroup(models.Model): "notes", "tasks", "activity", + "additionalservices" ], ) self.set_permissions( @@ -3305,6 +3306,7 @@ class CustomGroup(models.Model): "activity", "payment", "vendor", + "additionalservices", ], other_perms=[ "view_car", diff --git a/templates/dashboards/partials/financial_data_cards.html b/templates/dashboards/partials/financial_data_cards.html index e3216c64..2099124c 100644 --- a/templates/dashboards/partials/financial_data_cards.html +++ b/templates/dashboards/partials/financial_data_cards.html @@ -1,4 +1,5 @@ {% load i18n %} +{% load custom_filters %} {% if request.is_dealer or request.is_manager or request.is_accountant %}

{% blocktrans with start_date=start_date|date:"F j, Y" end_date=end_date|date:"F j, Y" %} diff --git a/templates/users/user_list.html b/templates/users/user_list.html index 98b9fef6..fa1eb263 100644 --- a/templates/users/user_list.html +++ b/templates/users/user_list.html @@ -20,7 +20,7 @@ - {% trans "Manage Groups" %} + {% trans "Manage Groups & Permissions" %}

{% endif %} -- 2.39.5