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

totals like in #1666

This commit is contained in:
Matthias 2021-06-17 00:50:10 +02:00
parent 9386332de1
commit bbe7edbf82

View File

@ -199,6 +199,7 @@ $("#so-lines-table").inventreeTable({
detailFormatter: showFulfilledSubTable, detailFormatter: showFulfilledSubTable,
{% endif %} {% endif %}
{% endif %} {% endif %}
showFooter: true,
columns: [ columns: [
{ {
field: 'pk', field: 'pk',
@ -217,7 +218,10 @@ $("#so-lines-table").inventreeTable({
} else { } else {
return '-'; return '-';
} }
} },
footerFormatter: function() {
return '{% trans "Total" %}'
},
}, },
{ {
sortable: true, sortable: true,
@ -228,6 +232,13 @@ $("#so-lines-table").inventreeTable({
sortable: true, sortable: true,
field: 'quantity', field: 'quantity',
title: '{% trans "Quantity" %}', title: '{% trans "Quantity" %}',
footerFormatter: function(data) {
return data.map(function (row) {
return +row['quantity']
}).reduce(function (sum, i) {
return sum + i
}, 0)
},
}, },
{ {
sortable: true, sortable: true,
@ -237,6 +248,26 @@ $("#so-lines-table").inventreeTable({
return row.sale_price_string || row.sale_price; return row.sale_price_string || row.sale_price;
} }
}, },
{
sortable: true,
title: '{% trans "Total price" %}',
formatter: function(value, row) {
var total = row.sale_price * row.quantity;
var formatter = new Intl.NumberFormat('en-US', {style: 'currency', currency: row.sale_price_currency});
return formatter.format(total)
},
footerFormatter: function(data) {
var total = data.map(function (row) {
return +row['sale_price']*row['quantity']
}).reduce(function (sum, i) {
return sum + i
}, 0)
var currency = (data.slice(-1)[0] && data.slice(-1)[0].sale_price_currency) || 'USD';
var formatter = new Intl.NumberFormat('en-US', {style: 'currency', currency: currency});
return formatter.format(total)
}
},
{ {
field: 'allocated', field: 'allocated',
{% if order.status == SalesOrderStatus.PENDING %} {% if order.status == SalesOrderStatus.PENDING %}