mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 21:25:42 +00:00 
			
		
		
		
	Build order table improvements:
- Display tick / cross badge for stock availability in build order table - Correctly order available quantity
This commit is contained in:
		| @@ -1031,6 +1031,23 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { | ||||
|         return row.required; | ||||
|     } | ||||
|  | ||||
|     function availableQuantity(row) { | ||||
|  | ||||
|         // Base stock | ||||
|         var available = row.available_stock; | ||||
|  | ||||
|         // Substitute stock | ||||
|         available += (row.available_substitute_stock || 0); | ||||
|  | ||||
|         // Variant stock | ||||
|         if (row.allow_variants) { | ||||
|             available += (row.available_variant_stock || 0); | ||||
|         } | ||||
|  | ||||
|         return available; | ||||
|  | ||||
|     } | ||||
|  | ||||
|     function sumAllocations(row) { | ||||
|         // Calculat total allocations for a given row | ||||
|         if (!row.allocations) { | ||||
| @@ -1429,12 +1446,13 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { | ||||
|                     var url = `/part/${row.sub_part_detail.pk}/?display=part-stock`; | ||||
|  | ||||
|                     // Calculate total "available" (unallocated) quantity | ||||
|                     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; | ||||
|                     var available_stock = availableQuantity(row); | ||||
|              | ||||
|                     var required = requiredQuantity(row); | ||||
|  | ||||
|                     var text = `${available_stock}`; | ||||
|  | ||||
|                     if (available_stock <= 0) { | ||||
| @@ -1453,9 +1471,19 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { | ||||
|                             text += `<span title='${extra}' class='fas fa-info-circle float-right icon-blue'></span>`; | ||||
|                         } | ||||
|                     } | ||||
|  | ||||
|                     if (available_stock < required) { | ||||
|                         text += `<span class='fas fa-times-circle icon-red float-right' title='{% trans "Insufficient stock available" %}'></span>`; | ||||
|                     } else { | ||||
|                         text += `<span class='fas fa-check-circle icon-green float-right' title='{% trans "Sufficient stock available" %}'></span>`; | ||||
|                     } | ||||
|          | ||||
|                     return renderLink(text, url); | ||||
|                 } | ||||
|                 }, | ||||
|                 sorter: function(valA, valB, rowA, rowB) { | ||||
|  | ||||
|                     return availableQuantity(rowA) > availableQuantity(rowB) ? 1 : -1; | ||||
|                 }, | ||||
|             }, | ||||
|             { | ||||
|                 field: 'allocated', | ||||
|   | ||||
		Reference in New Issue
	
	Block a user