From f26601e83641f9f3252e79b54ff0289c47081bbf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Sep 2021 13:17:00 +0200 Subject: [PATCH] FIX autocalculation of the supplier price in main currency. --- htdocs/product/fournisseurs.php | 40 ++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 01a09a21335..5b82cd3687d 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -623,7 +623,7 @@ if ($id > 0 || $ref) { // Currency print ''.$langs->trans("Currency").''; print ''; - $currencycodetouse = GETPOST('multicurrency_code') ?GETPOST('multicurrency_code') : (isset($object->fourn_multicurrency_code) ? $object->fourn_multicurrency_code : ''); + $currencycodetouse = GETPOST('multicurrency_code') ? GETPOST('multicurrency_code') : (isset($object->fourn_multicurrency_code) ? $object->fourn_multicurrency_code : ''); if (empty($currencycodetouse) && $object->fourn_multicurrency_tx == 1) { $currencycodetouse = $conf->currency; } @@ -635,7 +635,7 @@ if ($id > 0 || $ref) { // Currency price qty min print ''.$langs->trans("PriceQtyMinCurrency").''; - $pricesupplierincurrencytouse = (GETPOST('multicurrency_price') ?GETPOST('multicurrency_price') : (isset($object->fourn_multicurrency_price) ? $object->fourn_multicurrency_price : '')); + $pricesupplierincurrencytouse = (GETPOST('multicurrency_price') ? GETPOST('multicurrency_price') : (isset($object->fourn_multicurrency_price) ? $object->fourn_multicurrency_price : '')); print ''; print ' '; print $form->selectPriceBaseType((GETPOST('multicurrency_price_base_type') ?GETPOST('multicurrency_price_base_type') : 'HT'), "multicurrency_price_base_type"); // We keep 'HT' here, multicurrency_price_base_type is not yet supported for supplier prices @@ -651,43 +651,45 @@ if ($id > 0 || $ref) { print ''; $currencies = array(); - $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'multicurrency WHERE entity = '.$conf->entity; + $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'multicurrency WHERE entity = '.((int) $conf->entity); $resql = $db->query($sql); if ($resql) { $currency = new MultiCurrency($db); while ($obj = $db->fetch_object($resql)) { $currency->fetch($obj->rowid); - $currencies[$currency->code] = $currency->rate->rate; + $currencies[$currency->code] = ((float) $currency->rate->rate); } } $currencies = json_encode($currencies); print <<