From ec34d23bfc36dbe60a46e6d05435a4a19fc7b5ea Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 21 Apr 2022 23:58:12 +1000 Subject: [PATCH] Update javascript rendering in BOM table --- InvenTree/templates/js/translated/bom.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/InvenTree/templates/js/translated/bom.js b/InvenTree/templates/js/translated/bom.js index 7ae922788f..0d27a5e028 100644 --- a/InvenTree/templates/js/translated/bom.js +++ b/InvenTree/templates/js/translated/bom.js @@ -807,22 +807,23 @@ function loadBomTable(table, options={}) { var url = `/part/${row.sub_part_detail.pk}/?display=part-stock`; // Calculate total "available" (unallocated) quantity - var total = row.available_stock; + var base_stock = row.available_stock; + var substitute_stock = row.available_substitute_stock || 0; + var variant_stock = row.allow_variants ? (row.available_variant_stock || 0) : 0; + + var available_stock = base_stock + substitute_stock + variant_stock; - total += (row.available_substitute_stock || 0); - total += (row.available_variant_stock || 0); + var text = `${available_stock}`; - var text = `${total}`; - - if (total <= 0) { + if (available_stock <= 0) { text = `{% trans "No Stock Available" %}`; } else { var extra = ''; - if (row.available_substitute_stock && row.available_variant_stock) { + if ((substitute_stock > 0) && (variant_stock > 0)) { extra = '{% trans "Includes variant and substitute stock" %}'; - } else if (row.available_variant_stock) { + } else if (variant_stock > 0) { extra = '{% trans "Includes variant stock" %}'; - } else if (row.available_substitute_stock) { + } else if (substitute_stock > 0) { extra = '{% trans "Includes substitute stock" %}'; }