magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Tier price is calculated wrong

Open bkristl opened this issue 10 years ago • 7 comments

This is for magento version 2.1.1

The tier price is calculated wrong. In file Magento\Catalog\Pricing\Price\TierPrice.php Now is calculated:

public function getSavePercent(AmountInterface $amount) { return ceil( 100 - ((100 / $this->priceInfo->getPrice(FinalPrice::PRICE_CODE)->getValue()) * $amount->getBaseAmount()) ); }

But to get right percentage we must calculated:

public function getSavePercent(AmountInterface $amount) {

return ceil( 100 - ((100 / $this->priceInfo->getPrice(FinalPrice::PRICE_CODE)->getValue()) * $amount->getValue()) );

}

Why: Beacuse in first example if i simplify is calculated: 100 - FINAL PRICE (price with tax) / TIER PRICE (tier price WITHOUT tax) * 100

in second example is calculated:

100 - FINAL PRICE (price with tax) / TIER PRICE (tier price WITH tax) * 100

bkristl avatar Sep 06 '16 15:09 bkristl

@bkristl Thanks for reporting. Please, format this issue according to the Issue reporting guidelines.

andimov avatar Sep 07 '16 11:09 andimov

I think it's better return round( 100 - ((100 / $this->priceInfo->getPrice(FinalPrice::PRICE_CODE)->getValue())

  • $amount->getValue()) );

jamematen avatar Sep 08 '16 08:09 jamematen

it can not be with round... For example if we got 15.5% then will be rounded up so we get 16%. It is better that we show smaller percentage then bigger. Because if customer is going calculated...

bkristl avatar Sep 08 '16 09:09 bkristl

Indeed, ceil rounded up. In any case it had to use floor that makes it downward. Round but also you can set the accuracy.

jamematen avatar Sep 08 '16 09:09 jamematen

sorry my mistake

bkristl avatar Sep 08 '16 11:09 bkristl

@bkristl is this issue solved now?

veloraven avatar Sep 13 '16 07:09 veloraven

According to contributor guide, tickets without response for two weeks should be closed. If this issue still reproducible please feel free to create the new one: format new issue according to the Issue reporting guidelines: with steps to reproduce, actual result and expected result and specify Magento version.

veloraven avatar Sep 28 '16 09:09 veloraven