diff --git a/InvenTree/part/templates/part/part_base.html b/InvenTree/part/templates/part/part_base.html
index e45620798e..56a96c60ed 100644
--- a/InvenTree/part/templates/part/part_base.html
+++ b/InvenTree/part/templates/part/part_base.html
@@ -211,44 +211,18 @@
{% if part.component %}
{% if required_build_order_quantity > 0 %}
- |
- {% trans "Required for Build Orders" %} |
- {% decimal required_build_order_quantity %} |
-
-
- |
+ |
{% trans "Allocated to Build Orders" %} |
-
- {% decimal allocated_build_order_quantity %}
- {% if allocated_build_order_quantity < required_build_order_quantity %}
-
- {% else %}
-
- {% endif %}
- |
+ {% progress_bar allocated_build_order_quantity required_build_order_quantity id='build-order-allocated' max_width='150px' %} |
{% endif %}
{% endif %}
{% if part.salable %}
{% if required_sales_order_quantity > 0 %}
- |
- {% trans "Required for Sales Orders" %} |
-
- {% decimal required_sales_order_quantity %}
- |
-
-
- |
+ |
{% trans "Allocated to Sales Orders" %} |
-
- {% decimal allocated_sales_order_quantity %}
- {% if allocated_sales_order_quantity < required_sales_order_quantity %}
-
- {% else %}
-
- {% endif %}
- |
+ {% progress_bar allocated_sales_order_quantity required_sales_order_quantity id='sales-order-allocated' max_width='150px' %} |
{% endif %}
{% endif %}
diff --git a/InvenTree/part/templatetags/inventree_extras.py b/InvenTree/part/templatetags/inventree_extras.py
index dc93e00efa..08fa8ce583 100644
--- a/InvenTree/part/templatetags/inventree_extras.py
+++ b/InvenTree/part/templatetags/inventree_extras.py
@@ -352,21 +352,24 @@ def visible_global_settings(*args, **kwargs):
@register.simple_tag()
-def progress_bar(val, max, *args, **kwargs):
+def progress_bar(val, max_val, *args, **kwargs):
"""
Render a progress bar element
"""
item_id = kwargs.get('id', 'progress-bar')
- if val > max:
+ val = InvenTree.helpers.normalize(val)
+ max_val = InvenTree.helpers.normalize(max_val)
+
+ if val > max_val:
style = 'progress-bar-over'
- elif val < max:
+ elif val < max_val:
style = 'progress-bar-under'
else:
style = ''
- percent = float(val / max) * 100
+ percent = float(val / max_val) * 100
if percent > 100:
percent = 100
@@ -383,7 +386,7 @@ def progress_bar(val, max, *args, **kwargs):
html = f"""
-
{val} / {max}
+
{val} / {max_val}
"""