2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-30 04:26:44 +00:00

Enhance partStockLabel with ordering/building quantites

This commit is contained in:
Kálmán Rózsahegyi 2022-04-02 16:25:42 +02:00
parent bc4b66e7d3
commit ade5a81a1a

View File

@ -494,16 +494,42 @@ function duplicateBom(part_id, options={}) {
function partStockLabel(part, options={}) { function partStockLabel(part, options={}) {
if (part.in_stock) { if (part.in_stock) {
if (part.unallocated_stock) { // There IS stock available for this part
return `<span class='badge rounded-pill bg-success ${options.classes}'>{% trans "Available" %}: ${part.unallocated_stock}/${part.in_stock}</span>`;
// Is stock "low" (below the 'minimum_stock' quantity)?
if (part.minimum_stock && part.minimum_stock > part.in_stock) {
return `<span class='badge rounded-pill bg-warning ${options.classes}'>{% trans "Low stock" %}: ${part.in_stock}${part.units}</span>`;
} else if (part.unallocated_stock == 0) {
if (part.ordering) {
// There is no available stock, but stock is on order
return `<span class='badge rounded-pill bg-info ${options.classes}'>{% trans "On Order" %}: ${part.ordering}${part.units}</span>`;
} else if (part.building) {
// There is no available stock, but stock is being built
return `<span class='badge rounded-pill bg-info ${options.classes}'>{% trans "Building" %}: ${part.building}${part.units}</span>`;
} else { } else {
return `<span class='badge rounded-pill bg-warning ${options.classes}'>{% trans "Available" %}: ${part.unallocated_stock}/${part.in_stock}</span>`; // There is no available stock
return `<span class='badge rounded-pill bg-warning ${options.classes}'>{% trans "Available" %}: 0/${part.in_stock}${part.units}</span>`;
} }
} else { } else {
return `<span class='badge rounded-pill bg-success ${options.classes}'>{% trans "Available" %}: ${part.unallocated_stock}/${part.in_stock}${part.units}</span>`;
}
} else {
// There IS NO stock available for this part
if (part.ordering) {
// There is no stock, but stock is on order
return `<span class='badge rounded-pill bg-info ${options.classes}'>{% trans "On Order" %}: ${part.ordering}${part.units}</span>`;
} else if (part.building) {
// There is no stock, but stock is being built
return `<span class='badge rounded-pill bg-info ${options.classes}'>{% trans "Building" %}: ${part.building}${part.units}</span>`;
} else {
// There is no stock
return `<span class='badge rounded-pill bg-danger ${options.classes}'>{% trans "No Stock" %}</span>`; return `<span class='badge rounded-pill bg-danger ${options.classes}'>{% trans "No Stock" %}</span>`;
} }
} }
}
function makePartIcons(part) { function makePartIcons(part) {
/* Render a set of icons for the given part. /* Render a set of icons for the given part.