Feature request from barbarich-p, posted on GitHub Oct 26, 2015
Hello,
I found a bug on discount calculation.
File app/code/Magento/SalesRule/Model/RulesApplier.php Line 143
$qty = $this->validatorUtility->getItemQty($item, $rule);
deeper -
public function getItemQty($item, $rule)
{
$qty = $item->getTotalQty();
$discountQty = $rule->getDiscountQty();
return $discountQty ? min($qty, $discountQty) : $qty;
}
Line 157 - $this->validatorUtility->minFix($discountData, $item, $qty);
go deeper -
File app/code/Magento/SalesRule/Model/Utility.php
$discountAmount = min($itemDiscountAmount + $discountData->getAmount(), $itemPrice * $qty);
As a result, if some rule with field DiscountQty is applied after a rule without this field, the second one redefines the discount of the first one.
I wrote a blog post with more details about the issue here - https://blog.amasty.com/little-known-discount-issue-in-magento-and-how-to-fix-it/
This bug comes from Magento 1, and also you can reproduce this issue at all Magento 1.4 + versions