diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 0c9e89b421b..fac5784aa6d 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -3857,6 +3857,7 @@ class Form
'tva_tx_formated' => price($objp->tva_tx, 0, $langs, 1, -1, 2),
'tva_tx' => price2num($objp->tva_tx),
'default_vat_code' => $objp->default_vat_code,
+ 'supplier_ref' => $objp->ref_fourn,
'discount' => $outdiscount,
'type' => $outtype,
'duration_value' => $outdurationvalue,
@@ -3896,6 +3897,7 @@ class Form
'tva_tx_formated' => price($objp->tva_tx),
'tva_tx' => price2num($objp->tva_tx),
'default_vat_code' => $objp->default_vat_code,
+ 'supplier_ref' => $objp->ref_fourn,
'discount' => $outdiscount,
'type' => $outtype,
'duration_value' => $outdurationvalue,
diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php
index 42a0139bdf5..e73404bd40c 100644
--- a/htdocs/core/lib/ajax.lib.php
+++ b/htdocs/core/lib/ajax.lib.php
@@ -162,18 +162,13 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen
price_ttc: item.price_ttc,
price_unit_ht: item.price_unit_ht,
price_unit_ht_locale: item.price_unit_ht_locale,
- ';
- if (isModEnabled('multicurrency')) {
- $script .= '
- multicurrency_code: item.multicurrency_code,
- multicurrency_unitprice: item.multicurrency_unitprice,
- ';
- }
- $script .= '
+ multicurrency_code: item.multicurrency_code,
+ multicurrency_unitprice: item.multicurrency_unitprice,
description : item.description,
ref_customer: item.ref_customer,
tva_tx: item.tva_tx,
- default_vat_code: item.default_vat_code
+ default_vat_code: item.default_vat_code,
+ supplier_ref: item.supplier_ref
}
}));
} else {
@@ -187,7 +182,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen
console.log("We will trigger change on input '.$htmlname.' because of the select definition of autocomplete code for input#search_'.$htmlname.'");
console.log("Selected id = "+ui.item.id+" - If this value is null, it means you select a record with key that is null so selection is not effective");
- console.log("Propagate before some properties retrieved by ajax into data-xxx properties of #'.$htmlnamejquery.' component");
+ console.log("Before, we propagate some properties, retrieved by the ajax of the get, into the data-xxx properties of the component #'.$htmlnamejquery.'");
//console.log(ui.item);
// For supplier price and customer when price by quantity is off
@@ -200,18 +195,16 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen
$("#'.$htmlnamejquery.'").attr("data-ref-customer", ui.item.ref_customer);
$("#'.$htmlnamejquery.'").attr("data-tvatx", ui.item.tva_tx);
$("#'.$htmlnamejquery.'").attr("data-default-vat-code", ui.item.default_vat_code);
- ';
- if (isModEnabled('multicurrency')) {
- $script .= '
+ $("#'.$htmlnamejquery.'").attr("data-supplier-ref", ui.item.supplier_ref); // supplier_ref of price
+
// For multi-currency values
$("#'.$htmlnamejquery.'").attr("data-multicurrency-code", ui.item.multicurrency_code);
$("#'.$htmlnamejquery.'").attr("data-multicurrency-unitprice", ui.item.multicurrency_unitprice);
';
- }
if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) {
$script .= '
// For customer price when PRODUIT_CUSTOMER_PRICES_BY_QTY is on
- console.log("PRODUIT_CUSTOMER_PRICES_BY_QTY is on, propagate also prices by quantity into data-pbqxxx properties");
+ console.log("PRODUIT_CUSTOMER_PRICES_BY_QTY is on, so we propagate also prices by quantity into data-pbqxxx properties");
$("#'.$htmlnamejquery.'").attr("data-pbq", ui.item.pbq);
$("#'.$htmlnamejquery.'").attr("data-pbqup", ui.item.price_ht);
$("#'.$htmlnamejquery.'").attr("data-pbqbase", ui.item.pricebasetype);
@@ -221,7 +214,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen
}
$script .= '
// A new value has been selected, we trigger the handlers on #htmlnamejquery
- console.log("Trigger changes on #'.$htmlnamejquery.'");
+ console.log("Now, we trigger changes on #'.$htmlnamejquery.'");
$("#'.$htmlnamejquery.'").val(ui.item.id).trigger("change"); // Select new value
// Complementary actions
diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php
index 7e782809106..b76af45f151 100644
--- a/htdocs/core/tpl/objectline_create.tpl.php
+++ b/htdocs/core/tpl/objectline_create.tpl.php
@@ -1101,14 +1101,21 @@ if (!empty($usemargins) && $user->hasRight('margins', 'creer')) {
var default_vat_code = $('option:selected', this).attr('data-default-vat-code'); // When select is done from HTML select
if (typeof default_vat_code === 'undefined') { default_vat_code = jQuery('#idprodfournprice').attr('data-default-vat-code');} // When select is done from HTML input with ajax autocomplete
+ var supplier_ref = $('option:selected', this).attr('data-supplier-ref'); // When select is done from HTML select
+ if (typeof supplier_ref === 'undefined') { supplier_ref = jQuery('#idprodfournprice').attr('data-supplier-ref'); } // When select is done from HTML input with ajax autocomplete
+
+ element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier' || $object->element == 'invoice_supplier_rec') && !$seller->tva_assuj) { ?>
+ if (tva_tx != .0) {
+ tva_tx = .0;
+ default_vat_code = null;
+ }
+
+
var stringforvatrateselection = tva_tx;
if (typeof default_vat_code != 'undefined' && default_vat_code != null && default_vat_code != '') {
stringforvatrateselection = stringforvatrateselection+' ('+default_vat_code+')';
}
- var supplier_ref = $('option:selected', this).attr('data-supplier-ref'); // When select is done from HTML select
- if (typeof supplier_ref === 'undefined') { supplier_ref = jQuery('#idprodfournprice').attr('data-supplier-ref');} // When select is done from HTML input with ajax autocomplete
-
var has_multicurrency_up = false;
multicurrency_code != $conf->currency) {
@@ -1192,13 +1199,19 @@ if (!empty($usemargins) && $user->hasRight('margins', 'creer')) {
var default_vat_code = $('option:selected', this).attr('data-default-vat-code'); // When select is done from HTML select
if (typeof default_vat_code === 'undefined') { default_vat_code = jQuery('#idprodfournprice').attr('data-default-vat-code');} // When select is done from HTML input with ajax autocomplete
+ var supplier_ref = $('option:selected', this).attr('data-supplier-ref'); // When select is done from HTML select
+ if (typeof supplier_ref === 'undefined') { supplier_ref = jQuery('#idprodfournprice').attr('data-supplier-ref'); } // When select is done from HTML input with ajax autocomplete
+
var stringforvatrateselection = tva_tx;
if (typeof default_vat_code != 'undefined' && default_vat_code != null && default_vat_code != '') {
stringforvatrateselection = stringforvatrateselection+' ('+default_vat_code+')';
}
- console.log("objectline_create.tpl We find data for price : tva_tx = "+tva_tx+", default_vat_code = "+default_vat_code+", stringforvatrateselection="+stringforvatrateselection+" for product id = "+jQuery('#idprodfournprice').val());
+ console.log("objectline_create.tpl We find data for price : tva_tx = "+tva_tx+", default_vat_code = "+default_vat_code+", supplier_ref = "+supplier_ref+", stringforvatrateselection="+stringforvatrateselection+" for product id = "+jQuery('#idprodfournprice').val());
+
+ // Set supplier_ref
+ $('#fourn_ref').val(supplier_ref);
// Set vat rate if field is an input box
$('#tva_tx').val(tva_tx);
// Set vat rate by selecting the combo