Tier price is calculated wrong
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 Thanks for reporting. Please, format this issue according to the Issue reporting guidelines.
I think it's better return round( 100 - ((100 / $this->priceInfo->getPrice(FinalPrice::PRICE_CODE)->getValue())
- $amount->getValue()) );
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...
Indeed, ceil rounded up. In any case it had to use floor that makes it downward. Round but also you can set the accuracy.
sorry my mistake
@bkristl is this issue solved now?
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.