Fix test for es
This commit is contained in:
parent
f3ea694b97
commit
208ac31bf8
@ -40,8 +40,8 @@
|
||||
* @param float $pu Unit price (HT or TTC selon price_base_type)
|
||||
* @param float $remise_percent_ligne Discount for line
|
||||
* @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 $uselocaltax2_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 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 string $price_base_type HT=Unit price parameter is HT, TTC=Unit price parameter is TTC
|
||||
* @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);
|
||||
}
|
||||
// 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;
|
||||
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_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.= " FROM ".MAIN_DB_PREFIX."c_tva as cv";
|
||||
|
||||
@ -139,7 +139,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
|
||||
/*
|
||||
* Country France
|
||||
*/
|
||||
|
||||
|
||||
// qty=1, unit_price=1.24, discount_line=0, vat_rate=10, price_base_type='HT' (method we provide value)
|
||||
$mysoc->country_code='FR';
|
||||
$mysoc->country_id=1;
|
||||
@ -148,11 +148,11 @@ class PricesTest extends PHPUnit_Framework_TestCase
|
||||
// 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(1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0, 0, 0, 0, 0, 0),$result1,'Test1 FR');
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Country Spain
|
||||
*/
|
||||
|
||||
|
||||
// 10 * 10 HT - 0% discount with 10% vat, seller not using localtax1, not localtax2 (method we provide value)
|
||||
$mysoc->country_code='ES';
|
||||
$mysoc->country_id=4;
|
||||
@ -172,9 +172,9 @@ class PricesTest extends PHPUnit_Framework_TestCase
|
||||
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)
|
||||
$this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0),$result2,'Test2 ES');
|
||||
|
||||
|
||||
// --------------------------------------------------------
|
||||
|
||||
|
||||
// 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (method we provide value)
|
||||
$mysoc->country_code='ES';
|
||||
$mysoc->country_id=4;
|
||||
@ -184,7 +184,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
|
||||
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)
|
||||
$this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0),$result2,'Test3 ES');
|
||||
|
||||
|
||||
// 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_id=4;
|
||||
@ -194,19 +194,19 @@ class PricesTest extends PHPUnit_Framework_TestCase
|
||||
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)
|
||||
$this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0),$result2,'Test4 ES');
|
||||
|
||||
|
||||
// --------------------------------------------------------
|
||||
|
||||
// 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_id=4;
|
||||
$mysoc->localtax1_assuj=0;
|
||||
$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)
|
||||
$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_id=4;
|
||||
$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);
|
||||
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)
|
||||
$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_id=4;
|
||||
$mysoc->localtax1_assuj=0;
|
||||
$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";
|
||||
// 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)
|
||||
$mysoc->country_code='ES';
|
||||
@ -235,13 +235,13 @@ class PricesTest extends PHPUnit_Framework_TestCase
|
||||
$mysoc->localtax2_assuj=1;
|
||||
$result2=calcul_price_total(10, -10, 0, 10, -1, -1, 0, 'HT', 0, 0);
|
||||
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');
|
||||
|
||||
|
||||
/*
|
||||
* Country Côte d'Ivoire
|
||||
* Country Côte d'Ivoire
|
||||
*/
|
||||
|
||||
|
||||
// 10 * 10 HT - 0% discount with 18% vat, seller using localtax1 type 2, not localtax2 (method we provide value)
|
||||
$mysoc->country_code='CI';
|
||||
$mysoc->country_id=21;
|
||||
@ -253,7 +253,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
|
||||
print __METHOD__." result3=".join(', ',$result3)."\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)
|
||||
$this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0),$result3,'Test9 CI');
|
||||
|
||||
|
||||
// 10 * 10 HT - 0% discount with 18% vat, seller using localtax1 type 2, not localtax2 (other method autodetect)
|
||||
$mysoc->country_code='CI';
|
||||
$mysoc->country_id=21;
|
||||
@ -263,7 +263,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
|
||||
print __METHOD__." result3=".join(', ',$result3)."\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)
|
||||
$this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0),$result3,'Test10 CI');
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user