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

Display both 'allocated' and 'fulfilled' quantity values in salesorder table

This commit is contained in:
Oliver 2021-11-26 23:30:34 +11:00
parent 8aed68a1d1
commit 0b997dc784
2 changed files with 59 additions and 35 deletions

View File

@ -553,7 +553,6 @@ class SOLineItemSerializer(InvenTreeModelSerializer):
quantity = InvenTreeDecimalField() quantity = InvenTreeDecimalField()
allocated = serializers.FloatField(source='allocated_quantity', read_only=True) allocated = serializers.FloatField(source='allocated_quantity', read_only=True)
fulfilled = serializers.FloatField(source='fulfilled_quantity', read_only=True)
shipped = InvenTreeDecimalField(read_only=True) shipped = InvenTreeDecimalField(read_only=True)
@ -576,7 +575,6 @@ class SOLineItemSerializer(InvenTreeModelSerializer):
'allocated', 'allocated',
'allocations', 'allocations',
'quantity', 'quantity',
'fulfilled',
'reference', 'reference',
'notes', 'notes',
'order', 'order',

View File

@ -1918,7 +1918,7 @@ function loadSalesOrderLineItemTable(table, options={}) {
*/ */
{ {
sortable: true, sortable: true,
sortName: 'part__name', sortName: 'part_detail.name',
field: 'part', field: 'part',
title: '{% trans "Part" %}', title: '{% trans "Part" %}',
switchable: false, switchable: false,
@ -2015,24 +2015,22 @@ function loadSalesOrderLineItemTable(table, options={}) {
}, },
}, },
); );
}
columns.push( columns.push(
{ {
field: 'allocated', field: 'allocated',
title: pending ? '{% trans "Allocated" %}' : '{% trans "Fulfilled" %}', title: '{% trans "Allocated" %}',
switchable: false, switchable: false,
sortable: true,
formatter: function(value, row, index, field) { formatter: function(value, row, index, field) {
return makeProgressBar(row.allocated, row.quantity, {
var quantity = pending ? row.allocated : row.fulfilled;
return makeProgressBar(quantity, row.quantity, {
id: `order-line-progress-${row.pk}`, id: `order-line-progress-${row.pk}`,
}); });
}, },
sorter: function(valA, valB, rowA, rowB) { sorter: function(valA, valB, rowA, rowB) {
var A = pending ? rowA.allocated : rowA.fulfilled; var A = rowA.allocated;
var B = pending ? rowB.allocated : rowB.fulfilled; var B = rowB.allocated;
if (A == 0 && B == 0) { if (A == 0 && B == 0) {
return (rowA.quantity > rowB.quantity) ? 1 : -1; return (rowA.quantity > rowB.quantity) ? 1 : -1;
@ -2044,11 +2042,39 @@ function loadSalesOrderLineItemTable(table, options={}) {
return (progressA < progressB) ? 1 : -1; return (progressA < progressB) ? 1 : -1;
} }
}, },
);
}
columns.push({
field: 'shipped',
title: '{% trans "Shipped" %}',
switchable: false,
sortable: true,
formatter: function(value, row) {
return makeProgressBar(row.shipped, row.quantity, {
id: `order-line-shipped-${row.pk}`
});
},
sorter: function(valA, valB, rowA, rowB) {
var A = rowA.shipped;
var B = rowB.shipped;
if (A == 0 && B == 0) {
return (rowA.quantity > rowB.quantity) ? 1 : -1;
}
var progressA = parseFloat(A) / rowA.quantity;
var progressB = parseFloat(B) / rowB.quantity;
return (progressA < progressB) ? 1 : -1;
}
});
columns.push(
{ {
field: 'notes', field: 'notes',
title: '{% trans "Notes" %}', title: '{% trans "Notes" %}',
}, });
);
if (pending) { if (pending) {
columns.push({ columns.push({
@ -2230,7 +2256,7 @@ function loadSalesOrderLineItemTable(table, options={}) {
$(table).inventreeTable({ $(table).inventreeTable({
onPostBody: setupCallbacks, onPostBody: setupCallbacks,
name: 'salesorderlineitems', name: 'salesorderlineitems',
sidePagination: 'server', sidePagination: 'client',
formatNoMatches: function() { formatNoMatches: function() {
return '{% trans "No matching line items" %}'; return '{% trans "No matching line items" %}';
}, },
@ -2246,7 +2272,7 @@ function loadSalesOrderLineItemTable(table, options={}) {
// Order is pending // Order is pending
return row.allocated > 0; return row.allocated > 0;
} else { } else {
return row.fulfilled > 0; return row.shipped > 0;
} }
}, },
detailFormatter: function(index, row, element) { detailFormatter: function(index, row, element) {