Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply percentage discount on price with taxes #1379

Merged
merged 1 commit into from
Apr 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/lib/Thelia/Coupon/Type/PercentageCouponTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function setFieldsValue($effects)
*/
public function getCartItemDiscount(CartItem $cartItem)
{
return $cartItem->getQuantity() * $cartItem->getPrice() * ($this->percentage / 100);
return $cartItem->getQuantity() * $cartItem->getRealTaxedPrice($this->facade->getDeliveryCountry()) * ($this->percentage / 100);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Thelia\Condition\Implementation\MatchForTotalAmount;
use Thelia\Condition\Operators;
use Thelia\Coupon\FacadeInterface;
use Thelia\Model\CountryQuery;
use Thelia\Model\CurrencyQuery;

/**
Expand Down Expand Up @@ -49,6 +50,10 @@ public function generateFacadeStub($cartTotalPrice = 400, $checkoutCurrency = 'E
->disableOriginalConstructor()
->getMock();

$defaultCountry = CountryQuery::create()
->filterByByDefault(1)
->findOne();

$currencies = CurrencyQuery::create();
$currencies = $currencies->find();
$stubFacade->expects($this->any())
Expand All @@ -59,6 +64,10 @@ public function generateFacadeStub($cartTotalPrice = 400, $checkoutCurrency = 'E
->method('getCartTotalPrice')
->will($this->returnValue($cartTotalPrice));

$stubFacade->expects($this->any())
->method('getDeliveryCountry')
->will($this->returnValue($defaultCountry));

$stubFacade->expects($this->any())
->method('getCheckoutCurrency')
->will($this->returnValue($checkoutCurrency));
Expand Down Expand Up @@ -141,7 +150,7 @@ public function generateMatchingCart(\PHPUnit_Framework_MockObject_MockObject $s
;
$cartItem1Stub
->expects($this->any())
->method('getPrice')
->method('getRealTaxedPrice')
->will($this->returnValue(100))
;

Expand All @@ -161,7 +170,7 @@ public function generateMatchingCart(\PHPUnit_Framework_MockObject_MockObject $s
;
$cartItem2Stub
->expects($this->any())
->method('getPrice')
->method('getRealTaxedPrice')
->will($this->returnValue(150))
;

Expand Down Expand Up @@ -224,7 +233,7 @@ public function generateNoMatchingCart(\PHPUnit_Framework_MockObject_MockObject
;
$cartItem1Stub
->expects($this->any())
->method('getPrice')
->method('getRealTaxedPrice')
->will($this->returnValue(100))
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Thelia\Condition\Operators;
use Thelia\Coupon\FacadeInterface;
use Thelia\Model\Category;
use Thelia\Model\CountryQuery;
use Thelia\Model\CurrencyQuery;
use Thelia\Model\Product;

Expand Down Expand Up @@ -51,6 +52,10 @@ public function generateFacadeStub($cartTotalPrice = 400, $checkoutCurrency = 'E
->disableOriginalConstructor()
->getMock();

$defaultCountry = CountryQuery::create()
->filterByByDefault(1)
->findOne();

$currencies = CurrencyQuery::create();
$currencies = $currencies->find();
$stubFacade->expects($this->any())
Expand All @@ -61,6 +66,10 @@ public function generateFacadeStub($cartTotalPrice = 400, $checkoutCurrency = 'E
->method('getCartTotalPrice')
->will($this->returnValue($cartTotalPrice));

$stubFacade->expects($this->any())
->method('getDeliveryCountry')
->will($this->returnValue($defaultCountry));

$stubFacade->expects($this->any())
->method('getCheckoutCurrency')
->will($this->returnValue($checkoutCurrency));
Expand Down Expand Up @@ -116,7 +125,7 @@ public function generateMatchingCart(\PHPUnit_Framework_MockObject_MockObject $s
;
$cartItem1Stub
->expects($this->any())
->method('getPrice')
->method('getRealTaxedPrice')
->will($this->returnValue(100))
;

Expand All @@ -136,7 +145,7 @@ public function generateMatchingCart(\PHPUnit_Framework_MockObject_MockObject $s
;
$cartItem2Stub
->expects($this->any())
->method('getPrice')
->method('getRealTaxedPrice')
->will($this->returnValue(200))
;

Expand Down Expand Up @@ -176,7 +185,7 @@ public function generateNoMatchingCart(\PHPUnit_Framework_MockObject_MockObject

$cartItem2Stub
->expects($this->any())
->method('getPrice')
->method('getRealTaxedPrice')
->will($this->returnValue(200000))
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Thelia\Condition\Implementation\MatchForTotalAmount;
use Thelia\Condition\Operators;
use Thelia\Coupon\FacadeInterface;
use Thelia\Model\CountryQuery;
use Thelia\Model\CurrencyQuery;
use Thelia\Model\Product;

Expand Down Expand Up @@ -50,6 +51,10 @@ public function generateFacadeStub($cartTotalPrice = 400, $checkoutCurrency = 'E
->disableOriginalConstructor()
->getMock();

$defaultCountry = CountryQuery::create()
->filterByByDefault(1)
->findOne();

$currencies = CurrencyQuery::create();
$currencies = $currencies->find();
$stubFacade->expects($this->any())
Expand All @@ -60,6 +65,10 @@ public function generateFacadeStub($cartTotalPrice = 400, $checkoutCurrency = 'E
->method('getCartTotalPrice')
->will($this->returnValue($cartTotalPrice));

$stubFacade->expects($this->any())
->method('getDeliveryCountry')
->will($this->returnValue($defaultCountry));

$stubFacade->expects($this->any())
->method('getCheckoutCurrency')
->will($this->returnValue($checkoutCurrency));
Expand Down Expand Up @@ -107,7 +116,7 @@ public function generateMatchingCart(\PHPUnit_Framework_MockObject_MockObject $s
;
$cartItem1Stub
->expects($this->any())
->method('getPrice')
->method('getRealTaxedPrice')
->will($this->returnValue(100))

;
Expand All @@ -128,7 +137,7 @@ public function generateMatchingCart(\PHPUnit_Framework_MockObject_MockObject $s
;
$cartItem2Stub
->expects($this->any())
->method('getPrice')
->method('getRealTaxedPrice')
->will($this->returnValue(150))

;
Expand Down Expand Up @@ -172,7 +181,7 @@ public function generateNoMatchingCart(\PHPUnit_Framework_MockObject_MockObject
;
$cartItem2Stub
->expects($this->any())
->method('getPrice')
->method('getRealTaxedPrice')
->will($this->returnValue(11000))
;

Expand Down