Fix test for es

This commit is contained in:
Laurent Destailleur 2015-04-22 17:39:09 +02:00
parent f3ea694b97
commit 208ac31bf8
2 changed files with 29 additions and 29 deletions

View File

@ -40,8 +40,8 @@
* @param float $pu Unit price (HT or TTC selon price_base_type) * @param float $pu Unit price (HT or TTC selon price_base_type)
* @param float $remise_percent_ligne Discount for line * @param float $remise_percent_ligne Discount for line
* @param float $txtva 0=do not apply standard tax, Vat rate=apply * @param float $txtva 0=do not apply standard tax, Vat rate=apply
* @param float $uselocaltax1_rate 0=do not use this localtax, >0=apply, -1=autodetect according to seller * @param float $uselocaltax1_rate 0=do not use this localtax, >0=apply and get value from localtaxes_array (or database if empty), -1=autodetect according to seller if we must apply, get value from localtaxes_array (or database if empty)
* @param float $uselocaltax2_rate 0=do not use this localtax, >0=apply, -1=autodetect according to seller * @param float $uselocaltax2_rate 0=do not use this localtax, >0=apply and get value from localtaxes_array (or database if empty), -1=autodetect according to seller if we must apply, get value from localtaxes_array (or database if empty)
* @param float $remise_percent_global 0 * @param float $remise_percent_global 0
* @param string $price_base_type HT=Unit price parameter is HT, TTC=Unit price parameter is TTC * @param string $price_base_type HT=Unit price parameter is HT, TTC=Unit price parameter is TTC
* @param int $info_bits Miscellaneous informations on line * @param int $info_bits Miscellaneous informations on line
@ -90,7 +90,7 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
dol_syslog("calcul_price_total Warning: function is called with parameter localtaxes_array that is missing", LOG_WARNING); dol_syslog("calcul_price_total Warning: function is called with parameter localtaxes_array that is missing", LOG_WARNING);
} }
// Too verbose. Enable for debug only // Too verbose. Enable for debug only
//dol_syslog("calcul_price_total qty=".$qty." pu=".$pu." remiserpercent_ligne=".$remise_percent_ligne." txtva=".$txtva." uselocaltax1_rate=".$uselocaltax1_rate." uselocaltax2_rate=".$uselocaltax2_rate); //dol_syslog("Price.lib::calcul_price_total qty=".$qty." pu=".$pu." remiserpercent_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);
$countryid=$seller->country_id; $countryid=$seller->country_id;
if ($uselocaltax1_rate < 0) $uselocaltax1_rate=$seller->localtax1_assuj; if ($uselocaltax1_rate < 0) $uselocaltax1_rate=$seller->localtax1_assuj;
@ -109,7 +109,7 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
$localtax2_type = $localtaxes_array[2]; $localtax2_type = $localtaxes_array[2];
$localtax2_rate = $localtaxes_array[3]; $localtax2_rate = $localtaxes_array[3];
} }
else else // deprecated method. values and type for localtaxes must be provided by caller and loade with getLocalTaxesFromRate
{ {
$sql = "SELECT taux, localtax1, localtax2, localtax1_type, localtax2_type"; $sql = "SELECT taux, localtax1, localtax2, localtax1_type, localtax2_type";
$sql.= " FROM ".MAIN_DB_PREFIX."c_tva as cv"; $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as cv";

View File

@ -197,16 +197,16 @@ class PricesTest extends PHPUnit_Framework_TestCase
// -------------------------------------------------------- // --------------------------------------------------------
// 10 * 10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 19% localtax2 type 5 (method we provide value) // 10 * 10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 21% localtax2 type 5 (method we provide value)
$mysoc->country_code='ES'; $mysoc->country_code='ES';
$mysoc->country_id=4; $mysoc->country_id=4;
$mysoc->localtax1_assuj=0; $mysoc->localtax1_assuj=0;
$mysoc->localtax2_assuj=1; $mysoc->localtax2_assuj=1;
$result2=calcul_price_total(10, 10, 0, 10, 0, -19, 0, 'HT', 0, 0); $result2=calcul_price_total(10, 10, 0, 10, 0, -1, 0, 'HT', 0, 0);
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19),$result2,'Test5 ES'); $this->assertEquals(array(100, 10, 89, 10, 1, 8.9, 100, 10, 89, 0, -21, 0, -2.10, 0, 0, -21),$result2,'Test5 ES');
// 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (other method autodetect) // 10 * 10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 21% localtax2 type 5 (other method autodetect)
$mysoc->country_code='ES'; $mysoc->country_code='ES';
$mysoc->country_id=4; $mysoc->country_id=4;
$mysoc->localtax1_assuj=0; $mysoc->localtax1_assuj=0;
@ -214,19 +214,19 @@ class PricesTest extends PHPUnit_Framework_TestCase
$result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0);
print __METHOD__." result2=".join(', ',$result2)."\n"; print __METHOD__." result2=".join(', ',$result2)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19),$result2,'Test6 ES'); $this->assertEquals(array(100, 10, 89, 10, 1, 8.9, 100, 10, 89, 0, -21, 0, -2.10, 0, 0, -21),$result2,'Test6 ES');
// -------------------------------------------------------- // --------------------------------------------------------
// Credit Note: 10 * -10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 19% localtax2 type 5 (method we provide value) // Credit Note: 10 * -10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 21% localtax2 type 5 (method we provide value)
$mysoc->country_code='ES'; $mysoc->country_code='ES';
$mysoc->country_id=4; $mysoc->country_id=4;
$mysoc->localtax1_assuj=0; $mysoc->localtax1_assuj=0;
$mysoc->localtax2_assuj=1; $mysoc->localtax2_assuj=1;
$result2=calcul_price_total(10, -10, 0, 10, 0, 19, 0, 'HT', 0, 0); $result2=calcul_price_total(10, -10, 0, 10, 0, 1, 0, 'HT', 0, 0);
print __METHOD__." result2=".join(', ',$result2)."\n"; print __METHOD__." result2=".join(', ',$result2)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(-100, -10, -91, -10, -1, -9.1, -100, -10,- 91, 0, 19, 0, 1.90, 0, 0, 19),$result2,'Test7 ES'); $this->assertEquals(array(-100, -10, -89, -10, -1, -8.9, -100, -10, -89, 0, 21, 0, 2.1, 0, 0, 21),$result2,'Test7 ES');
// Credit Note: 10 * -10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (other method autodetect) // Credit Note: 10 * -10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (other method autodetect)
$mysoc->country_code='ES'; $mysoc->country_code='ES';
@ -235,7 +235,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$mysoc->localtax2_assuj=1; $mysoc->localtax2_assuj=1;
$result2=calcul_price_total(10, -10, 0, 10, -1, -1, 0, 'HT', 0, 0); $result2=calcul_price_total(10, -10, 0, 10, -1, -1, 0, 'HT', 0, 0);
print __METHOD__." result2=".join(', ',$result2)."\n"; print __METHOD__." result2=".join(', ',$result2)."\n";
$this->assertEquals(array(-100, -10, -91, -10, -1, -9.1, -100, -10,- 91, 0, 19, 0, 1.90, 0, 0, 19),$result2,'Test8 ES'); $this->assertEquals(array(-100, -10, -89, -10, -1, -8.9, -100, -10, -89, 0, 21, 0, 2.1, 0, 0, 21),$result2,'Test8 ES');
/* /*