Skip to content

Commit e1d85c9

Browse files
committed
MAGETWO-72280: [Backport] Tier price saving percentage wrong when VAT is included in price #8833 2.1.x
1 parent 54e2592 commit e1d85c9

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

app/code/Magento/Bundle/Pricing/Price/TierPrice.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Bundle\Pricing\Price;
88

99
use Magento\Catalog\Pricing\Price\RegularPrice;
10+
use Magento\Framework\Pricing\Amount\AmountInterface;
1011

1112
/**
1213
* Bundle tier prices model
@@ -89,4 +90,13 @@ public function isPercentageDiscount()
8990
{
9091
return true;
9192
}
93+
94+
/**
95+
* @param AmountInterface $amount
96+
* @return float
97+
*/
98+
public function getSavePercent(AmountInterface $amount)
99+
{
100+
return round($amount->getBaseAmount());
101+
}
92102
}

app/code/Magento/Bundle/Test/Unit/Pricing/Price/TierPriceTest.php

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -181,27 +181,11 @@ public function providerForGetterTierPriceList()
181181
/**
182182
* @dataProvider providerForTestGetSavePercent
183183
*/
184-
public function testGetSavePercent($baseAmount, $tierPrice, $savePercent)
184+
public function testGetSavePercent($baseAmount, $savePercent)
185185
{
186186
/** @var \Magento\Framework\Pricing\Amount\AmountInterface|\PHPUnit_Framework_MockObject_MockObject $amount */
187187
$amount = $this->getMockForAbstractClass('Magento\Framework\Pricing\Amount\AmountInterface');
188-
$amount->expects($this->any())
189-
->method('getValue')
190-
->will($this->returnValue($tierPrice));
191-
192-
$priceAmount = $this->getMockForAbstractClass('Magento\Framework\Pricing\Amount\AmountInterface');
193-
$priceAmount->expects($this->any())
194-
->method('getValue')
195-
->will($this->returnValue($baseAmount));
196-
197-
$price = $this->getMock('Magento\Framework\Pricing\Price\PriceInterface');
198-
$price->expects($this->any())
199-
->method('getAmount')
200-
->will($this->returnValue($priceAmount));
201-
202-
$this->priceInfo->expects($this->any())
203-
->method('getPrice')
204-
->will($this->returnValue($price));
188+
$amount->expects($this->once())->method('getBaseAmount')->willReturn($baseAmount);
205189

206190
$this->assertEquals($savePercent, $this->model->getSavePercent($amount));
207191
}
@@ -212,8 +196,10 @@ public function testGetSavePercent($baseAmount, $tierPrice, $savePercent)
212196
public function providerForTestGetSavePercent()
213197
{
214198
return [
215-
'no fraction' => [9.0000, 8.1, 10],
216-
'lower half' => [9.1234, 8.3, 9],
199+
'no fraction' => [10.0000, 10],
200+
'lower half' => [10.1234, 10],
201+
'half way' => [10.5000, 11],
202+
'upper half' => [10.6789, 11],
217203
];
218204
}
219205
}

0 commit comments

Comments
 (0)