From f96fdc7d0a2838f1dc0ac7aaf592a23b6e5030ec Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Sun, 18 Jan 2015 21:04:39 +0100
Subject: [PATCH] Regression solved

---
 htdocs/compta/facture/class/facture.class.php |  4 +--
 htdocs/core/lib/price.lib.php                 |  4 ++-
 test/phpunit/PricesTest.php                   | 30 +++++++++----------
 3 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 278d8ca70e4..f28f4bdd348 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -2027,7 +2027,7 @@ class Facture extends CommonInvoice
 	 *      @param      int         $fk_prev_id         Previous situation line id reference
 	 *    	@return    	int             				<0 if KO, Id of line if OK
 	 */
-	function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_option=0, $situation_percent=0, $fk_prev_id='')
+	function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_option=0, $situation_percent=100, $fk_prev_id='')
 	{
 		global $mysoc, $conf, $langs;
 
@@ -2336,7 +2336,7 @@ class Facture extends CommonInvoice
 
 	/**
 	 * Update invoice line with percentage
-	 * 
+	 *
 	 * @param FactureLigne $line Invoice line
 	 * @param int $percent Percentage
 	 * @return void
diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php
index aa3a1e11a46..aac29ad5256 100644
--- a/htdocs/core/lib/price.lib.php
+++ b/htdocs/core/lib/price.lib.php
@@ -49,7 +49,7 @@
  *		@param	int		$type						0/1=Product/service
  *		@param  Societe	$seller						Thirdparty seller (we need $seller->country_id property). Provided only if seller is the supplier, otherwise $seller will be $mysoc.
  *		@param  array	$localtaxes_array			Array with localtaxes info (loaded by getLocalTaxesFromRate function).
- *		@param  float   $progress                   Situation invoices progress
+ *		@param  float   $progress                   Situation invoices progress (value from 0 to 100, 100 by default)
  *		@return result[ 0=total_ht,
  *						 1=total_vat,
  *						 2=total_ttc,
@@ -97,6 +97,8 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
 	if ($uselocaltax1_rate < 0) $uselocaltax1_rate=$seller->localtax1_assuj;
 	if ($uselocaltax2_rate < 0) $uselocaltax2_rate=$seller->localtax2_assuj;
 
+	dol_syslog('Price.lib::calcul_price_total qty='.$qty.' pu='.$pu.' remise_percent_ligne='.$remise_percent_ligne.' txtva='.$txtva.' uselocaltax1_rate='.$uselocaltax1_rate.' uselocaltax2_rate='.$uselocaltax2_rate.' remise_percent_global='.$remise_percent_global.' price_base_type='.$ice_base_type.' type='.$type.' progress='.$progress);
+
 	// Now we search localtaxes information ourself (rates and types).
 	$localtax1_type=0;
 	$localtax2_type=0;
diff --git a/test/phpunit/PricesTest.php b/test/phpunit/PricesTest.php
index c01a3701177..9b46f8cc1d6 100755
--- a/test/phpunit/PricesTest.php
+++ b/test/phpunit/PricesTest.php
@@ -1,20 +1,20 @@
 <?php
 /* Copyright (C) 2010 Laurent Destailleur  <eldy@users.sourceforge.net>
  *
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-* GNU General Public License for more details.
-*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  * or see http://www.gnu.org/
-*/
+ */
 
 /**
  *      \file       test/phpunit/PricesTest.php
@@ -215,9 +215,9 @@ class PricesTest extends PHPUnit_Framework_TestCase
         $newlocalobject=new Facture($this->savdb);
         $newlocalobject->fetch($invoiceid);
 
-        $this->assertEquals(2.48,$newlocalobject->total_ht);
-        $this->assertEquals(0.24,$newlocalobject->total_tva);
-        $this->assertEquals(2.72,$newlocalobject->total_ttc);
+        $this->assertEquals(2.48,$newlocalobject->total_ht, "testUpdatePrice test1");
+        $this->assertEquals(0.24,$newlocalobject->total_tva, "testUpdatePrice test2");
+        $this->assertEquals(2.72,$newlocalobject->total_ttc, "testUpdatePrice test3");
 
 
         // Two lines of 1.24 give 2.48 HT and 2.73 TTC with global vat rounding mode
@@ -231,7 +231,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
         $newlocalobject=new Facture($this->savdb);
         $newlocalobject->fetch($invoiceid);
 
-        $this->assertEquals(2.48,$newlocalobject->total_ht);
+        $this->assertEquals(2.48,$newlocalobject->total_ht, "testUpdatePrice test4");
         //$this->assertEquals(0.25,$newlocalobject->total_tva);
         //$this->assertEquals(2.73,$newlocalobject->total_ttc);
     }
-- 
GitLab