Commit ae99c34c by Alexis Aoun

refactor et renommage de variable

parent 476540af
...@@ -95,24 +95,28 @@ function select_product_from_bc(barcode) { ...@@ -95,24 +95,28 @@ function select_product_from_bc(barcode) {
}); });
} }
if(scannedProduct.rule == 'weight') if(foundProduct.data !== null){
foundProduct.data.product_qty = scannedProduct.qty; if(scannedProduct.rule === 'weight'){
foundProduct.data.product_qty = scannedProduct.qty;
else if(scannedProduct.rule == 'price_to_weight'){ }
openModal($('#templates #modal_confirm_price_to_weight').html(), price_to_weight_is_wrong, 'Non', false, true, price_to_weight_confirmed_callback(foundProduct, scannedProduct));
setupPopUpBtnStyle(scannedProduct);
}
else if(scannedProduct.rule === 'price_to_weight'){
openModal($('#templates #modal_confirm_price_to_weight').html(), price_to_weight_is_wrong, 'Non', false, true, price_to_weight_confirmed_callback(foundProduct, scannedProduct));
setupPopUpBtnStyle(scannedProduct);
}
if(foundProduct.data !== null && !(scannedProduct.rule == 'price_to_weight')){ if(scannedProduct.rule !== 'price_to_weight'){
if(scannedProduct.rule == 'weight') if(scannedProduct.rule === 'weight'){
editProductInfo(foundProduct.data, foundProduct.data.product_qty); editProductInfo(foundProduct.data, foundProduct.data.product_qty);
else }
setLineEdition(foundProduct.data); else{
setLineEdition(foundProduct.data);
}
if (foundProduct.place === 'to_process') { if (foundProduct.place === 'to_process') {
let row = table_to_process.row($('#'+foundProduct.data.product_id[0])); let row = table_to_process.row($('#'+foundProduct.data.product_id[0]));
remove_from_toProcess(row, foundProduct.data); remove_from_toProcess(row, foundProduct.data);
}
} }
} }
} }
...@@ -170,21 +174,21 @@ function update_distant_orders() { ...@@ -170,21 +174,21 @@ function update_distant_orders() {
}); });
} }
//TODO not the cleanest way to manage the callback, needs improvement function price_to_weight_confirmed_callback (foundProduct, scannedProduct){
//TODO too much repeating code, needs refactor
function price_to_weight_confirmed_callback (found, p){
return function price_to_weight_confirmed(){ return function price_to_weight_confirmed(){
if(priceToWeightIsCorrect) if(priceToWeightIsCorrect){
found.data.product_qty = p.qty; foundProduct.data.product_qty = scannedProduct.qty;
else }
found.data.product_qty = Number((p.value/document.getElementById("new_price_to_weight").value).toFixed(3)); else{
//TODO il n'y a aucun controle sur l'input à corriger
if (found.data !== null) { foundProduct.data.product_qty = Number((scannedProduct.value/document.getElementById("new_price_to_weight").value).toFixed(3));
editProductInfo(found.data, found.data.product_qty); }
if (found.place === 'to_process') {
let row = table_to_process.row($('#'+found.data.product_id[0])); if (foundProduct.data !== null) {
remove_from_toProcess(row, found.data); editProductInfo(foundProduct.data, foundProduct.data.product_qty);
if (foundProduct.place === 'to_process') {
let row = table_to_process.row($('#'+foundProduct.data.product_id[0]));
remove_from_toProcess(row, foundProduct.data);
} }
resetPopUpButtons(); resetPopUpButtons();
} }
......
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