Beispiel #1
0
 /**
  * @inheritdoc
  */
 public function buildOrderItemAmounts(OrderItemInterface $item, AmountsInterface $amounts = null)
 {
     if (null === $amounts) {
         $amounts = new Amounts();
     }
     if ($item->hasChildren()) {
         $itemAmounts = new Amounts();
         $children = $item->getChildren()->toArray();
         foreach ($children as $child) {
             $this->buildOrderItemAmounts($child, $itemAmounts);
         }
         $itemAmounts->multiply($item->getQuantity());
         $amounts->merge($itemAmounts);
     } else {
         $amount = new Amount($this->mode == self::MODE_NET ? $this->round($item->getNetPrice()) : $item->getNetPrice(), $item->getTaxRate(), $item->getTaxName());
         $amount->multiply($item->getQuantity());
         $amounts->add($amount);
     }
     // TODO Percent adjustment applied to children if any
     return $amounts;
 }
Beispiel #2
0
 /**
  * @covers ::__constructor
  */
 public function testConstructor()
 {
     $total = new Amounts();
     $this->assertEquals(0, count($total->all()));
 }