Commit a325f466 by François C.

#1495 add percent adjustment to compute needed products

parent 5e8434ac
Pipeline #1663 passed with stage
in 1 minute 32 seconds
...@@ -197,6 +197,23 @@ ...@@ -197,6 +197,23 @@
border-radius: 3px; border-radius: 3px;
} }
#coverage_form > div {
display:inline-block;
float:left;
}
#coverage_form .input-wrapper {
margin-right: 3px;
}
#coverage_days_input, #percent_adjust_input {
display: block;
}
#coverage_days_input {
margin-bottom: 3px;
}
/* -- Table */ /* -- Table */
#products_table_filter{ #products_table_filter{
text-align: right !important; text-align: right !important;
......
...@@ -189,7 +189,14 @@ function add_product() { ...@@ -189,7 +189,14 @@ function add_product() {
* Set the computed qty for the first supplier only. * Set the computed qty for the first supplier only.
*/ */
function compute_products_coverage_qties() { function compute_products_coverage_qties() {
const pc_adjust = $('#percent_adjust_input').val();
let coeff = 1;
if (!isNaN(parseFloat(pc_adjust))) {
coeff = (1 + parseFloat(pc_adjust) /100);
}
if (order_doc.coverage_days != null) { if (order_doc.coverage_days != null) {
order_doc.coeff = coeff;
for (const [ for (const [
key, key,
product product
...@@ -202,12 +209,16 @@ function compute_products_coverage_qties() { ...@@ -202,12 +209,16 @@ function compute_products_coverage_qties() {
const incoming_qty = product.incoming_qty; const incoming_qty = product.incoming_qty;
const daily_conso = product.daily_conso; const daily_conso = product.daily_conso;
purchase_qty_for_coverage = order_doc.coverage_days * daily_conso - stock - incoming_qty; purchase_qty_for_coverage = order_doc.coverage_days * daily_conso - stock - incoming_qty;
purchase_qty_for_coverage = (purchase_qty_for_coverage < 0) ? 0 : purchase_qty_for_coverage; purchase_qty_for_coverage = (purchase_qty_for_coverage < 0) ? 0 : purchase_qty_for_coverage;
// Reduce to nb of packages to purchase // Reduce to nb of packages to purchase
purchase_package_qty_for_coverage = purchase_qty_for_coverage / product.suppliersinfo[0].package_qty; purchase_package_qty_for_coverage = purchase_qty_for_coverage / product.suppliersinfo[0].package_qty;
if (order_doc.coeff != 1) {
purchase_package_qty_for_coverage *= order_doc.coeff;
}
// Round up to unit for all products // Round up to unit for all products
purchase_package_qty_for_coverage = Math.ceil(purchase_package_qty_for_coverage); purchase_package_qty_for_coverage = Math.ceil(purchase_package_qty_for_coverage);
...@@ -1885,6 +1896,10 @@ function update_main_screen(params) { ...@@ -1885,6 +1896,10 @@ function update_main_screen(params) {
$("#coverage_days_input").val(''); $("#coverage_days_input").val('');
} }
if (order_doc.coeff && order_doc.coeff != 1) {
$("#percent_adjust_input").val(-Math.ceil((1 - order_doc.coeff) * 100));
}
if (order_doc.stats_date_period !== undefined && order_doc.stats_date_period !== null) { if (order_doc.stats_date_period !== undefined && order_doc.stats_date_period !== null) {
$("#stats_date_period_select").val(order_doc.stats_date_period); $("#stats_date_period_select").val(order_doc.stats_date_period);
} else { } else {
......
...@@ -93,8 +93,13 @@ ...@@ -93,8 +93,13 @@
</select> </select>
</form> </form>
<form action="javascript:;" id="coverage_form" class="order_form_item"> <form action="javascript:;" id="coverage_form" class="order_form_item">
<div class="input-wrapper">
<input type="number" name="coverage_days" id="coverage_days_input" placeholder="Nb jours de couverture" min="1"> <input type="number" name="coverage_days" id="coverage_days_input" placeholder="Nb jours de couverture" min="1">
<input type="number" name="percent_adjustement" id="percent_adjust_input" placeholder="ajustement en % (+ ou -)">
</div>
<div>
<button type="submit" class='btn--primary'>Calculer les besoins</button> <i class='main fa fa-info-circle fa-lg'></i> <button type="submit" class='btn--primary'>Calculer les besoins</button> <i class='main fa fa-info-circle fa-lg'></i>
</div>
</form> </form>
</div> </div>
......
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