Commit 7a0149bc by Damien Moulard

always compute products qty not covered & days covered

parent 73da7a2c
Pipeline #1282 passed with stage
in 1 minute 48 seconds
...@@ -1252,25 +1252,21 @@ function _compute_product_data(product) { ...@@ -1252,25 +1252,21 @@ function _compute_product_data(product) {
} }
/* Coverage related data */ /* Coverage related data */
if (order_doc.coverage_days !== null) { const coverage_days = (order_doc.coverage_days !== null) ? order_doc.coverage_days : 0;
let qty_not_covered = 0; let qty_not_covered = 0;
let days_covered = 0; let days_covered = 0;
if (product.daily_conso !== 0) {
qty_not_covered = product.daily_conso * order_doc.coverage_days - product.qty_available - product.incoming_qty - purchase_qty;
qty_not_covered = -Math.ceil(qty_not_covered); // round up, so if a value is not fully covered display it
qty_not_covered = (qty_not_covered > 0) ? 0 : qty_not_covered; // only display qty not covered (neg value)
days_covered = (product.qty_available + product.incoming_qty + purchase_qty) / product.daily_conso; if (product.daily_conso !== 0) {
days_covered = Math.floor(days_covered); qty_not_covered = product.daily_conso * coverage_days - product.qty_available - product.incoming_qty - purchase_qty;
} qty_not_covered = -Math.ceil(qty_not_covered); // round up: display values that are not fully covered
qty_not_covered = (qty_not_covered > 0) ? 0 : qty_not_covered; // only display qty not covered (neg value)
item.qty_not_covered = qty_not_covered; days_covered = (product.qty_available + product.incoming_qty + purchase_qty) / product.daily_conso;
item.days_covered = days_covered; days_covered = Math.floor(days_covered);
} else {
item.qty_not_covered = 'X';
item.days_covered = 'X';
} }
item.qty_not_covered = qty_not_covered;
item.days_covered = days_covered;
return item; return item;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment