gross profit loss---negative filter
This commit is contained in:
parent
f8a8897838
commit
f136b26937
@ -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:
|
||||
|
||||
@ -302,9 +302,16 @@
|
||||
<div class="card h-100 shadow-sm border-0">
|
||||
<div class="card-body p-4">
|
||||
<p class="text-uppercase text-muted fw-bold small mb-1">{% trans "Gross Profit" %}</p>
|
||||
<h4 class="fw-bolder text-success mb-3">
|
||||
|
||||
{% if gross_profit|is_negative %}
|
||||
<h4 class="fw-bolder text-danger mb-3">
|
||||
{{ gross_profit|floatformat:2 }}<span class="icon-saudi_riyal"></span>
|
||||
</h4>
|
||||
</h4>
|
||||
{% else %}
|
||||
<h4 class="fw-bolder text-success mb-3">
|
||||
{{ gross_profit|floatformat:2 }}<span class="icon-saudi_riyal"></span>
|
||||
</h4>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<main class="d-flex align-items-center justify-content-center min-vh-100 py-5">
|
||||
<main class="d-flex align-items-center justify-content-center min-vh-80 py-5">
|
||||
<div class="col-12 col-sm-10 col-md-8 col-lg-6 col-xl-5">
|
||||
<div class="card shadow-lg border-0 rounded-4 overflow-hidden animate__animated animate__fadeInUp">
|
||||
<div class="card-header bg-gradient py-4 border-0 rounded-top-4">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user