/**
  * @return \Generated\Shared\Transfer\OrderTransfer
  */
 protected function getOrderTransferWithRefundedItem()
 {
     $orderTransfer = new OrderTransfer();
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setRefundableAmount(0);
     $itemTransfer->setIdSalesOrderItem(1);
     $orderTransfer->addItem($itemTransfer);
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setRefundableAmount(100);
     $itemTransfer->setIdSalesOrderItem(2);
     $orderTransfer->addItem($itemTransfer);
     $expenseTransfer = new ExpenseTransfer();
     $expenseTransfer->setRefundableAmount(10);
     $orderTransfer->addExpense($expenseTransfer);
     return $orderTransfer;
 }
 /**
  * @return \Generated\Shared\Transfer\QuoteTransfer
  */
 protected function createQuoteTransfer()
 {
     $quoteTransfer = new QuoteTransfer();
     $shipmentMethodTransfer = new ShipmentMethodTransfer();
     $shipmentMethodTransfer->setName('DummyShipment');
     $shipmentTransfer = new ShipmentTransfer();
     $shipmentTransfer->setMethod($shipmentMethodTransfer);
     $quoteTransfer->setShipment($shipmentTransfer);
     $expenseTransfer = new ExpenseTransfer();
     $expenseTransfer->setName($shipmentMethodTransfer->getName());
     $expenseTransfer->setType(ShipmentConstants::SHIPMENT_EXPENSE_TYPE);
     $quoteTransfer->addExpense($expenseTransfer);
     return $quoteTransfer;
 }
 /**
  * @param \Orm\Zed\Sales\Persistence\SpySalesExpense $salesOrderExpenseEntity
  * @param \Generated\Shared\Transfer\ExpenseTransfer $expenseTransfer
  *
  * @return void
  */
 protected function hydrateOrderExpenseEntity(SpySalesExpense $salesOrderExpenseEntity, ExpenseTransfer $expenseTransfer)
 {
     $salesOrderExpenseEntity->fromArray($expenseTransfer->toArray());
     $salesOrderExpenseEntity->setGrossPrice($expenseTransfer->getUnitGrossPrice());
 }
Exemple #4
0
 /**
  * @param \Generated\Shared\Transfer\ExpenseTransfer $expenseTransfer
  *
  * @return \Orm\Zed\Sales\Persistence\SpySalesExpense
  */
 protected function getExpenseEntity(ExpenseTransfer $expenseTransfer)
 {
     $salesExpenseEntity = $this->salesQueryContainer->querySalesExpense()->findOneByIdSalesExpense($expenseTransfer->getIdSalesExpense());
     return $salesExpenseEntity;
 }
Exemple #5
0
 /**
  * @return void
  */
 public function testSaveRefundShouldSetCanceledAmountOnOrderExpenseEntities()
 {
     $salesExpenseEntityMock = $this->getSalesExpenseEntityMock();
     $salesExpenseQueryMock = $this->getMockBuilder(SpySalesExpenseQuery::class)->setMethods(['findOneByIdSalesExpense'])->getMock();
     $salesExpenseQueryMock->method('findOneByIdSalesExpense')->willReturn($salesExpenseEntityMock);
     $salesQueryContainerMock = $this->getSalesQueryContainerMock();
     $salesQueryContainerMock->method('querySalesExpense')->willReturn($salesExpenseQueryMock);
     $refundEntity = $this->getRefundEntity(0);
     $refundSaver = $this->getRefundSaverMock($refundEntity, $salesQueryContainerMock);
     $refundTransfer = new RefundTransfer();
     $refundTransfer->setAmount(100);
     $expenseTransfer = new ExpenseTransfer();
     $expenseTransfer->setRefundableAmount(100);
     $refundTransfer->addExpense($expenseTransfer);
     $this->assertTrue($refundSaver->saveRefund($refundTransfer));
 }
Exemple #6
0
 /**
  * @param \Orm\Zed\Sales\Persistence\SpySalesOrder $orderEntity
  * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer
  *
  * @return void
  */
 protected function hydrateExpensesToOrderTransfer(SpySalesOrder $orderEntity, OrderTransfer $orderTransfer)
 {
     foreach ($orderEntity->getExpenses() as $expenseEntity) {
         $expenseTransfer = new ExpenseTransfer();
         $expenseTransfer->fromArray($expenseEntity->toArray(), true);
         $expenseTransfer->setUnitGrossPrice($expenseEntity->getGrossPrice());
         $orderTransfer->addExpense($expenseTransfer);
     }
 }