Ejemplo n.º 1
0
 public function testCancel()
 {
     $this->orderItemFactoryMock->expects($this->once())->method('create')->willReturn($this->orderItemMock);
     $this->orderItemMock->expects($this->once())->method('load')->with(1)->willReturnSelf();
     $this->orderItemMock->expects($this->once())->method('getQtyInvoiced')->willReturn(1);
     $this->orderItemMock->expects($this->once())->method('getTaxInvoiced')->willReturn(1);
     $this->orderItemMock->expects($this->once())->method('getBaseTaxInvoiced')->willReturn(1);
     $this->orderItemMock->expects($this->once())->method('getDiscountTaxCompensationInvoiced')->willReturn(1);
     $this->orderItemMock->expects($this->once())->method('getBaseDiscountTaxCompensationInvoiced')->willReturn(1);
     $this->orderItemMock->expects($this->once())->method('getDiscountInvoiced')->willReturn(1);
     $this->orderItemMock->expects($this->once())->method('getBaseDiscountInvoiced')->willReturn(1);
     $this->orderItemMock->expects($this->once())->method('getRowInvoiced')->willReturn(1);
     $this->orderItemMock->expects($this->once())->method('getBaseRowInvoiced')->willReturn(1);
     $this->orderItemMock->expects($this->once())->method('setQtyInvoiced')->with(0)->willReturnSelf();
     $this->orderItemMock->expects($this->once())->method('setTaxInvoiced')->with(0)->willReturnSelf();
     $this->orderItemMock->expects($this->once())->method('setBaseTaxInvoiced')->with(0)->willReturnSelf();
     $this->orderItemMock->expects($this->once())->method('setDiscountTaxCompensationInvoiced')->with(0)->willReturnSelf();
     $this->orderItemMock->expects($this->once())->method('setBaseDiscountTaxCompensationInvoiced')->with(0)->willReturnSelf();
     $this->orderItemMock->expects($this->once())->method('setDiscountInvoiced')->with(0)->willReturnSelf();
     $this->orderItemMock->expects($this->once())->method('setBaseDiscountInvoiced')->with(0)->willReturnSelf();
     $this->orderItemMock->expects($this->once())->method('setRowInvoiced')->with(0)->willReturnSelf();
     $this->orderItemMock->expects($this->once())->method('setBaseRowInvoiced')->with(0)->willReturnSelf();
     $this->item->setData(['order_item_id' => 1, 'qty' => 1, 'tax_amount' => 1, 'base_tax_amount' => 1, 'discount_tax_compensation_amount' => 1, 'base_discount_tax_compensation_amount' => 1, 'discount_amount' => 1, 'base_discount_amount' => 1, 'row_total' => 1, 'base_row_total' => 1]);
     $this->assertEquals($this->item->cancel(), $this->item);
 }
Ejemplo n.º 2
0
 /**
  * Retrieve order item instance
  *
  * @return \Magento\Sales\Model\Order\Item
  */
 public function getOrderItem()
 {
     if ($this->_orderItem === null) {
         if ($this->getCreditmemo()) {
             $this->_orderItem = $this->getCreditmemo()->getOrder()->getItemById($this->getOrderItemId());
         } else {
             $this->_orderItem = $this->_orderItemFactory->create()->load($this->getOrderItemId());
         }
     }
     return $this->_orderItem;
 }
Ejemplo n.º 3
0
 /**
  * Retrieve order item instance
  *
  * @return \Magento\Sales\Model\Order\Item
  */
 public function getOrderItem()
 {
     if (null === $this->_orderItem) {
         if ($this->getShipment()) {
             $this->_orderItem = $this->getShipment()->getOrder()->getItemById($this->getOrderItemId());
         } else {
             $this->_orderItem = $this->_orderItemFactory->create()->load($this->getOrderItemId());
         }
     }
     return $this->_orderItem;
 }
Ejemplo n.º 4
0
 /**
  * Convert quote item to order item
  *
  * @param   \Magento\Sales\Model\Quote\Item\AbstractItem $item
  * @return  \Magento\Sales\Model\Order\Item
  */
 public function itemToOrderItem(\Magento\Sales\Model\Quote\Item\AbstractItem $item)
 {
     $orderItem = $this->_orderItemFactory->create()->setStoreId($item->getStoreId())->setQuoteItemId($item->getId())->setQuoteParentItemId($item->getParentItemId())->setProductId($item->getProductId())->setProductType($item->getProductType())->setQtyBackordered($item->getBackorders())->setProduct($item->getProduct())->setBaseOriginalPrice($item->getBaseOriginalPrice());
     $options = $item->getProductOrderOptions();
     if (!$options) {
         $options = $item->getProduct()->getTypeInstance()->getOrderOptions($item->getProduct());
     }
     $orderItem->setProductOptions($options);
     $this->_objectCopyService->copyFieldsetToTarget('sales_convert_quote_item', 'to_order_item', $item, $orderItem);
     if ($item->getParentItem()) {
         $orderItem->setQtyOrdered($orderItem->getQtyOrdered() * $item->getParentItem()->getQty());
     }
     if (!$item->getNoDiscount()) {
         $this->_objectCopyService->copyFieldsetToTarget('sales_convert_quote_item', 'to_order_item_discount', $item, $orderItem);
     }
     return $orderItem;
 }
Ejemplo n.º 5
0
 /**
  * Create and return new order item based on payment item data and $itemInfo
  * for initial payment
  *
  * @param \Magento\Framework\Object $itemInfo
  * @return \Magento\Sales\Model\Order\Item
  */
 protected function _getInitialItem($itemInfo)
 {
     $price = $itemInfo->getPrice() ? $itemInfo->getPrice() : $this->getInitAmount();
     $shippingAmount = $itemInfo->getShippingAmount() ? $itemInfo->getShippingAmount() : 0;
     $taxAmount = $itemInfo->getTaxAmount() ? $itemInfo->getTaxAmount() : 0;
     $item = $this->_orderItemFactory->create()->setStoreId($this->getStoreId())->setProductType(\Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL)->setIsVirtual(1)->setSku('initial_fee')->setName(__('Recurring Payment Initial Fee'))->setDescription('')->setWeight(0)->setQtyOrdered(1)->setPrice($price)->setOriginalPrice($price)->setBasePrice($price)->setBaseOriginalPrice($price)->setRowTotal($price)->setBaseRowTotal($price)->setTaxAmount($taxAmount)->setShippingAmount($shippingAmount);
     $option = array('label' => __('Payment type'), 'value' => __('Initial period payment'));
     $this->_addAdditionalOptionToItem($item, $option);
     return $item;
 }
Ejemplo n.º 6
0
 /**
  * Retrieve order item instance
  *
  * @return \Magento\Sales\Model\Order\Item
  */
 public function getOrderItem()
 {
     if (is_null($this->_orderItem)) {
         if ($this->getInvoice()) {
             $this->_orderItem = $this->getInvoice()->getOrder()->getItemById($this->getOrderItemId());
         } else {
             $this->_orderItem = $this->_orderItemFactory->create()->load($this->getOrderItemId());
         }
     }
     return $this->_orderItem;
 }