/**
  * @param \Magento\Quote\Model\Quote\Item\AbstractItem $item
  * @param \Magento\SalesRule\Model\Rule $rule
  * @return \Magento\SalesRule\Model\Rule\Action\Discount\Data
  */
 protected function getDiscountData($item, $rule)
 {
     $qty = $this->validatorUtility->getItemQty($item, $rule);
     $discountCalculator = $this->calculatorFactory->create($rule->getSimpleAction());
     $qty = $discountCalculator->fixQuantity($qty, $rule);
     $discountData = $discountCalculator->calculate($rule, $item, $qty);
     $this->eventFix($discountData, $item, $rule, $qty);
     $this->validatorUtility->deltaRoundingFix($discountData, $item);
     /**
      * We can't use row total here because row total not include tax
      * Discount can be applied on price included tax
      */
     $this->validatorUtility->minFix($discountData, $item, $qty);
     return $discountData;
 }
Beispiel #2
0
 public function testMinFix()
 {
     $qty = 13;
     $amount = 10;
     $baseAmount = 12;
     $fixedAmount = 20;
     $fixedBaseAmount = 24;
     $this->getItemPrice();
     $this->getItemBasePrice();
     $this->item->setDiscountAmount($amount);
     $this->item->setBaseDiscountAmount($baseAmount);
     $discountData = $this->getMock('Magento\\SalesRule\\Model\\Rule\\Action\\Discount\\Data', [], [], '', false);
     $discountData->expects($this->atLeastOnce())->method('getAmount')->will($this->returnValue($amount));
     $discountData->expects($this->atLeastOnce())->method('getBaseAmount')->will($this->returnValue($baseAmount));
     $discountData->expects($this->once())->method('setAmount')->with($fixedAmount);
     $discountData->expects($this->once())->method('setBaseAmount')->with($fixedBaseAmount);
     $this->assertNull($this->utility->minFix($discountData, $this->item, $qty));
 }