Esempio n. 1
0
 /**
  * Create the weee ("FPT") totals summary
  *
  * @return $this
  */
 public function initTotals()
 {
     /** @var $items \Magento\Sales\Model\Order\Item[] */
     $items = $this->getSource()->getAllItems();
     $store = $this->getSource()->getStore();
     $weeeTotal = $this->weeeData->getTotalAmounts($items, $store);
     $weeeBaseTotal = $this->weeeData->getBaseTotalAmounts($items, $store);
     if ($weeeTotal) {
         // Add our total information to the set of other totals
         $total = new \Magento\Framework\DataObject(['code' => $this->getNameInLayout(), 'label' => __('FPT'), 'value' => $weeeTotal, 'base_value' => $weeeBaseTotal]);
         if ($this->getBeforeCondition()) {
             $this->getParentBlock()->addTotalBefore($total, $this->getBeforeCondition());
         } else {
             $this->getParentBlock()->addTotal($total, $this->getAfterCondition());
         }
     }
     return $this;
 }
Esempio n. 2
0
 public function testGetBaseTotalAmounts()
 {
     $item1BaseWeee = 4;
     $item2BaseWeee = 3;
     $expected = $item1BaseWeee + $item2BaseWeee;
     $itemProductSimple1 = $this->getMock('\\Magento\\Quote\\Model\\Quote\\Item', ['getBaseWeeeTaxAppliedRowAmount'], [], '', false);
     $itemProductSimple2 = $this->getMock('\\Magento\\Quote\\Model\\Quote\\Item', ['getBaseWeeeTaxAppliedRowAmount'], [], '', false);
     $items = [$itemProductSimple1, $itemProductSimple2];
     $itemProductSimple1->expects($this->any())->method('getBaseWeeeTaxAppliedRowAmount')->willReturn($item1BaseWeee);
     $itemProductSimple2->expects($this->any())->method('getBaseWeeeTaxAppliedRowAmount')->willReturn($item2BaseWeee);
     $this->assertEquals($expected, $this->helperData->getBaseTotalAmounts($items));
 }