diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 3e1af30ddd2..fb3b35b31bb 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -143,15 +143,20 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen textarea[key] = item[value]; }); } + console.log("Return value from GET to the rest of code"); return { label: label, value: item.value, id: item.key, disabled: item.disabled, - update: update, textarea: textarea, + update: update, + textarea: textarea, pbq: item.pbq, - type: item.type, qty: item.qty, discount: item.discount, + type: item.type, + qty: item.qty, + discount: item.discount, pricebasetype: item.pricebasetype, price_ht: item.price_ht, price_ttc: item.price_ttc, description : item.description, - ref_customer: item.ref_customer } + ref_customer: item.ref_customer, + tva_tx: item.tva_tx } })); } else { console.error("Error: Ajax url '.$url.($urloption ? '?'.$urloption : '').' has returned an empty page. Should be an empty json array."); @@ -173,6 +178,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen $("#'.$htmlnamejquery.'").attr("data-discount", ui.item.discount); $("#'.$htmlnamejquery.'").attr("data-description", ui.item.description); $("#'.$htmlnamejquery.'").attr("data-ref-customer", ui.item.ref_customer); + $("#'.$htmlnamejquery.'").attr("data-tvatx", ui.item.tva_tx); '; if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { $script .= ' diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index d16da640c7e..ba5c71c399b 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -952,14 +952,15 @@ if (!empty($usemargins) && $user->rights->margins->creer) { var discount = parseFloat($('option:selected', this).attr('data-discount')); if (isNaN(discount)) { discount = parseFloat(jQuery('#idprodfournprice').attr('data-discount'));} - var tva_tx = $('option:selected', this).data('tvatx'); /* FIX21543 */ + var tva_tx = parseFloat($('option:selected', this).attr('data-tvatx')); // When select is done from HTML select + if (isNaN(tva_tx)) { tva_tx = parseFloat(jQuery('#idprodfournprice').attr('data-tvatx'));} // When select is done from HTML input with autocomplete console.log("We find supplier price :"+up+" qty: "+qty+" tva_tx="+tva_tx+" discount: "+discount+" for product "+jQuery('#idprodfournprice').val()); jQuery("#price_ht").val(up); - /* $('#tva_tx option').removeAttr('selected').filter('[value='+tva_tx+']').prop('selected', true); */ - $('#tva_tx option').val(tva_tx); /* FIX21543 */ + /* $('#tva_tx option').removeAttr('selected').filter('[value='+tva_tx+']').prop('selected', true); */ + $('#tva_tx option').val(tva_tx); if (jQuery("#qty").val() < qty) { jQuery("#qty").val(qty);