Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function resolve(OrderItemInterface $item)
 {
     if (null === ($subject = $item->getSubject()) && $item->hasSubjectIdentity()) {
         $subject = $this->getResolver($item)->resolve($item);
         $item->setSubject($subject);
         return $subject;
     }
     return null;
 }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
0
 public function setUp()
 {
     $this->item = new OrderItem();
     $this->item->setDesignation('Test order item 1')->setReference('TEST-ITEM-1')->setNetPrice(10)->setTaxName('Tax 1')->setTaxRate(0.2)->setWeight(100)->setQuantity(1)->addChild($this->getTestChildItemOne())->addAdjustment($this->getTestItemAdjustmentOne());
 }