Commit 310ce8a3 by François C.

Ticket 2473 : If a product stock value is 0 and sales average value is 0, set 1 package to order

parent afe5a5e8
Pipeline #1889 passed with stage
in 1 minute 29 seconds
...@@ -191,15 +191,22 @@ function add_product() { ...@@ -191,15 +191,22 @@ function add_product() {
return 0; return 0;
} }
function compute_purchase_qty_for_coverage(product, coeff, stock, incoming_qty, daily_conso, days) { function compute_purchase_qty_for_coverage(product, coeff, stock, incoming_qty, daily_conso, days) {
let purchase_qty_for_coverage = null; let purchase_qty_for_coverage = 0,
purchase_qty_for_coverage = days * daily_conso - stock - incoming_qty + product.minimal_stock; purchase_package_qty_for_coverage = 0;
purchase_qty_for_coverage = (purchase_qty_for_coverage < 0) ? 0 : purchase_qty_for_coverage;
// Reduce to nb of packages to purchase if (stock == 0 && daily_conso == 0) {
purchase_package_qty_for_coverage = purchase_qty_for_coverage / product.suppliersinfo[0].package_qty; purchase_package_qty_for_coverage = 1;
if (coeff != 1) { } else {
purchase_package_qty_for_coverage *= coeff; purchase_qty_for_coverage = days * daily_conso - stock - incoming_qty + product.minimal_stock;
purchase_qty_for_coverage = (purchase_qty_for_coverage < 0) ? 0 : purchase_qty_for_coverage;
// Reduce to nb of packages to purchase
purchase_package_qty_for_coverage = purchase_qty_for_coverage / product.suppliersinfo[0].package_qty;
if (coeff != 1) {
purchase_package_qty_for_coverage *= coeff;
}
} }
// return Round up to unit for all products // return Round up to unit for all products
return Math.ceil(purchase_package_qty_for_coverage); return Math.ceil(purchase_package_qty_for_coverage);
......
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