mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Purchase history graph fix (#5421)
* Fix debug messages * Fix bug in purchase history chart - Use new pack_quantity_native attribute
This commit is contained in:
parent
a1d2782137
commit
86ca0b27a4
@ -292,7 +292,7 @@ function loadBomPricingChart(options={}) {
|
||||
var part = options.part;
|
||||
|
||||
if (!part) {
|
||||
console.error('No part provided to loadPurchasePriceHistoryTable');
|
||||
console.error('No part provided to loadBomPricingChart');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -434,7 +434,7 @@ function loadPartSupplierPricingTable(options={}) {
|
||||
var part = options.part;
|
||||
|
||||
if (!part) {
|
||||
console.error('No part provided to loadPurchasePriceHistoryTable');
|
||||
console.error('No part provided to loadPartSupplierPricingTable');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -764,7 +764,21 @@ function loadPurchasePriceHistoryTable(options={}) {
|
||||
data = data.sort((a, b) => (a.order_detail.complete_date - b.order_detail.complete_date));
|
||||
|
||||
var graphLabels = Array.from(data, (x) => (`${x.order_detail.reference} - ${x.order_detail.complete_date}`));
|
||||
var graphValues = Array.from(data, (x) => (x.purchase_price / x.supplier_part_detail.pack_size));
|
||||
var graphValues = Array.from(data, (x) => {
|
||||
let pp = x.purchase_price;
|
||||
|
||||
let div = 1.0;
|
||||
|
||||
if (x.supplier_part_detail) {
|
||||
div = parseFloat(x.supplier_part_detail.pack_quantity_native);
|
||||
|
||||
if (isNaN(div) || !isFinite(div)) {
|
||||
div = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
return pp / div;
|
||||
});
|
||||
|
||||
if (chart) {
|
||||
chart.destroy();
|
||||
|
Loading…
Reference in New Issue
Block a user