From d2f5ee65ae7753e82324bd4cfe8eff0eec9abe11 Mon Sep 17 00:00:00 2001 From: lvessiller-opendsi Date: Tue, 19 Nov 2024 13:21:31 +0100 Subject: [PATCH] FIX Takepos barcode rule with float qty (#31916) * FIX Takepos barcode rule with float qty * Replace floatval by cast in float and GETPOSTINT by GETPOSTFLOAT for qty * Keep last test condition on barcode value --- htdocs/takepos/ajax/ajax.php | 2 +- htdocs/takepos/index.php | 2 +- htdocs/takepos/invoice.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index de2abef6a10..1ebadc6541d 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -249,7 +249,7 @@ if ($action == 'getProducts' && $user->hasRight('takepos', 'run')) { 'label' => $obj->label, 'tosell' => $obj->tosell, 'tobuy' => $obj->tobuy, - 'barcode' => $obj->barcode, + 'barcode' => $term, // there is only one product matches the barcode rule and so the term is considered as the barcode of this product 'price' => empty($objProd->multiprices[$pricelevel]) ? $obj->price : $objProd->multiprices[$pricelevel], 'price_ttc' => empty($objProd->multiprices_ttc[$pricelevel]) ? $obj->price_ttc : $objProd->multiprices_ttc[$pricelevel], 'object' => 'product', diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 156a78f59df..62a1d45ce34 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -817,7 +817,7 @@ function Search2(keyCodeForEnter, moreorless) { console.log("There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0]['rowid']); ChangeThirdparty(data[0]['rowid']); } - else if ($('#search').val() == data[0]['barcode'] && 'product' == data[0]['object']) { + else if ('product' == data[0]['object'] && $('#search').val() == data[0]['barcode']) { console.log("There is only 1 answer and we found search on a barcode, so we add the product in basket, qty="+data[0]['qty']); ClickProduct(0, data[0]['qty']); } diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 72056dbda4c..8f3259b46c0 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -648,7 +648,7 @@ if (empty($reshook)) { $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0); - $qty = GETPOSTISSET('qty') ? GETPOSTINT('qty') : 1; + $qty = GETPOSTISSET('qty') ? GETPOSTFLOAT('qty') : 1; $price = $datapriceofproduct['pu_ht']; $price_ttc = $datapriceofproduct['pu_ttc']; //$price_min = $datapriceofproduct['price_min'];