2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-17 12:35:46 +00:00

total_price for orders (#4447)

* Adds unit test for counting queries on PurchaseOrderList API endpoint

- We will work to make this queryset more efficient

* PEP fixes

* Add 'total_price' fields to SalesOrder and PurchaseOrder models

* PurchaseOrder list API now has constant query count

* Data migration for updating existing PurchaseOrder and SalesOrder instances

- Calculate total_price for any existing order
- Will fail if exchange rates are not available

* Add total_price_currency to API serializers

* Render total_price in SalesOrder table

* Add ability to filter both lists by total_price field

* Update total_price whenever an order is updated

* Update total price whenever a lineitem is saved or deleted

* Add query-counting unit test for SalesOrder list API

* Calling refresh_from_db inside a save() method is *not* a good idea
This commit is contained in:
Oliver
2023-03-05 22:22:18 +11:00
committed by GitHub
parent c0f405243a
commit 5ba75c868d
12 changed files with 406 additions and 37 deletions

View File

@ -2155,9 +2155,11 @@ function loadPurchaseOrderTable(table, options) {
field: 'total_price',
title: '{% trans "Total Cost" %}',
switchable: true,
sortable: false,
sortable: true,
formatter: function(value, row) {
return formatCurrency(value);
return formatCurrency(value, {
currency: row.total_price_currency,
});
},
},
{
@ -2979,6 +2981,17 @@ function loadSalesOrderTable(table, options) {
field: 'line_items',
title: '{% trans "Items" %}'
},
{
field: 'total_price',
title: '{% trans "Total Cost" %}',
switchable: true,
sortable: true,
formatter: function(value, row) {
return formatCurrency(value, {
currency: row.total_price_currency,
});
}
}
],
});
}