From efc61be1a469303ebd2f1deecebb0c9bc1e82e7c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sun, 26 Aug 2012 18:27:15 +0200 Subject: [PATCH] Fix: Rounding at wrong place --- htdocs/fourn/class/fournisseur.product.class.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index a3150e4df2a..02b6b92ab9e 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -153,17 +153,17 @@ class ProductFournisseur extends Product if (empty($buyprice)) $buyprice=0; if (empty($charges)) $charges=0; if (empty($availability)) $availability=0; - $buyprice=price2num($buyprice); - $charges=price2num($charges); - $qty=price2num($qty); - - $error=0; - - if ($price_base_type == 'TTC') + if ($price_base_type == 'TTC') { $ttx = get_default_tva($fourn,$mysoc,$this->id); $buyprice = $buyprice/(1+($ttx/100)); } + $buyprice=price2num($buyprice,'MU'); + $charges=price2num($charges,'MU'); + $qty=price2num($qty); + + $error=0; + $unitBuyPrice = price2num($buyprice/$qty,'MU'); $unitCharges = price2num($charges/$qty,'MU'); @@ -185,6 +185,7 @@ class ProductFournisseur extends Product $sql.= " charges = ".($charges != ''?price2num($charges):"null"); $sql.= " WHERE rowid = ".$this->product_fourn_price_id; + dol_syslog(get_class($this).'::update_buyprice sql='.$sql); $resql = $this->db->query($sql); if ($resql) { @@ -204,6 +205,7 @@ class ProductFournisseur extends Product // Delete price for this quantity $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; $sql.= " WHERE rowid = ".$this->product_fourn_price_id; + dol_syslog(get_class($this).'::update_buyprice sql='.$sql); $resql=$this->db->query($sql); if ($resql) { -- GitLab