Improve rendering of pricing in sale order table

This commit is contained in:
Oliver 2021-10-24 19:39:48 +11:00
parent 5f6e67086f
commit bc596c1f20

View File

@ -885,8 +885,7 @@ function loadPurchaseOrderLineItemTable(table, options={}) {
{
field: 'total_price',
sortable: true,
field: 'total_price',
title: '{% trans "Total price" %}',
title: '{% trans "Total Price" %}',
formatter: function(value, row) {
var total = row.purchase_price * row.quantity;
var formatter = new Intl.NumberFormat('en-US', {style: 'currency', currency: row.purchase_price_currency});
@ -1436,7 +1435,7 @@ function loadSalesOrderLineItemTable(table, options={}) {
sortable: true,
field: 'reference',
title: '{% trans "Reference" %}',
switchable: false,
switchable: true,
},
{
sortable: true,
@ -1456,14 +1455,6 @@ function loadSalesOrderLineItemTable(table, options={}) {
field: 'sale_price',
title: '{% trans "Unit Price" %}',
formatter: function(value, row) {
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',
{
@ -1472,7 +1463,23 @@ function loadSalesOrderLineItemTable(table, options={}) {
}
);
return formatter.format(total);
return formatter.format(row.sale_price);
}
},
{
field: 'total_price',
sortable: true,
title: '{% trans "Total Price" %}',
formatter: function(value, row) {
var formatter = new Intl.NumberFormat(
'en-US',
{
style: 'currency',
currency: row.sale_price_currency
}
);
return formatter.format(row.sale_price * row.quantity);
},
footerFormatter: function(data) {
var total = data.map(function(row) {
@ -1544,6 +1551,7 @@ function loadSalesOrderLineItemTable(table, options={}) {
if (pending) {
columns.push({
field: 'buttons',
switchable: false,
formatter: function(value, row, index, field) {
var html = `<div class='btn-group float-right' role='group'>`;