diff --git a/core/lib/Thelia/Coupon/BaseFacade.php b/core/lib/Thelia/Coupon/BaseFacade.php index 4e7e7de13..b9bf65204 100644 --- a/core/lib/Thelia/Coupon/BaseFacade.php +++ b/core/lib/Thelia/Coupon/BaseFacade.php @@ -125,6 +125,12 @@ class BaseFacade implements FacadeInterface } + public function getCartTotalTaxPrice() + { + $taxCountry = $this->getContainer()->get('thelia.taxEngine')->getDeliveryCountry(); + return $this->getCart()->getTaxedAmount($taxCountry); + } + /** * Return the Checkout currency EUR|USD * diff --git a/core/lib/Thelia/Coupon/FacadeInterface.php b/core/lib/Thelia/Coupon/FacadeInterface.php index 9e93115d0..1b2d01a5b 100644 --- a/core/lib/Thelia/Coupon/FacadeInterface.php +++ b/core/lib/Thelia/Coupon/FacadeInterface.php @@ -83,6 +83,13 @@ interface FacadeInterface */ public function getCartTotalPrice(); + /** + * Return Product total tax price + * + * @return float + */ + public function getCartTotalTaxPrice(); + /** * Return the Checkout currency EUR|USD * diff --git a/core/lib/Thelia/Coupon/Type/RemoveXPercent.php b/core/lib/Thelia/Coupon/Type/RemoveXPercent.php index 01ee7f0eb..cc04dc787 100644 --- a/core/lib/Thelia/Coupon/Type/RemoveXPercent.php +++ b/core/lib/Thelia/Coupon/Type/RemoveXPercent.php @@ -103,10 +103,9 @@ class RemoveXPercent extends CouponAbstract 'Percentage must be inferior to 100' ); } - $taxCountry = $this->facade->getContainer()->get('thelia.taxEngine')->getDeliveryCountry(); - $basePrice = $this->facade->getCart()->getTaxedAmount($taxCountry); - return round($basePrice * $this->percentage/100, 2); + + return round($this->facade->getCartTotalTaxPrice() * $this->percentage/100, 2); } /** diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php index 0c3a8b2be..c5a9d033e 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php @@ -63,14 +63,15 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $currencies = CurrencyQuery::create(); - $currencies = $currencies->find(); + + + $currencies = CurrencyQuery::create()->find(); $stubFacade->expects($this->any()) ->method('getAvailableCurrencies') ->will($this->returnValue($currencies)); $stubFacade->expects($this->any()) - ->method('getCartTotalPrice') + ->method('getCartTotalTaxPrice') ->will($this->returnValue($cartTotalPrice)); $stubFacade->expects($this->any())