Ejemplo n.º 1
0
 /**
  * @param \Generated\Shared\Transfer\RefundTransfer $refundTransfer
  *
  * @return void
  */
 protected function calculateRefundableExpenseAmount(RefundTransfer $refundTransfer)
 {
     if ($refundTransfer->getExpenses()) {
         foreach ($refundTransfer->getExpenses() as $expenseTransfer) {
             $refundTransfer->setAmount($refundTransfer->getAmount() + $expenseTransfer->getRefundableAmount());
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * @return void
  */
 public function testCalculateRefundShouldIncludeExpenseWhenLastItemOfOrderShouldBeRefunded()
 {
     $refundCalculationPlugin = new ExpenseRefundCalculator();
     $orderTransfer = $this->getOrderTransferWithRefundedItem();
     $salesOrderItems = [$this->getSalesOrderItemTwo()];
     $refundTransfer = new RefundTransfer();
     $refundTransfer->setAmount(0);
     $refundCalculationPlugin->calculateRefund($refundTransfer, $orderTransfer, $salesOrderItems);
     $this->assertSame(10, $refundTransfer->getAmount());
 }
Ejemplo n.º 3
0
 /**
  * @return void
  */
 public function testCalculateRefundForOrderWithoutAlreadyRefundedItems()
 {
     $refundCalculationPlugin = new ItemRefundCalculator();
     $orderTransfer = $this->getOrderTransferWithoutRefundedItems();
     $salesOrderItems = [$this->getSalesOrderItemOne()];
     $refundTransfer = new RefundTransfer();
     $refundTransfer->setAmount(0);
     $refundCalculationPlugin->calculateRefund($refundTransfer, $orderTransfer, $salesOrderItems);
     $this->assertSame(100, $refundTransfer->getAmount());
 }
Ejemplo n.º 4
0
 /**
  * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem[] $salesOrderItems
  * @param \Orm\Zed\Sales\Persistence\SpySalesOrder $salesOrderEntity
  *
  * @return \Generated\Shared\Transfer\RefundTransfer
  */
 public function calculateRefund(array $salesOrderItems, SpySalesOrder $salesOrderEntity)
 {
     $orderTransfer = $this->getOrderTransfer($salesOrderEntity);
     $refundTransfer = new RefundTransfer();
     $refundTransfer->setAmount(0);
     $refundTransfer->setFkSalesOrder($orderTransfer->getIdSalesOrder());
     foreach ($this->refundCalculatorPlugins as $refundCalculatorPlugin) {
         $refundTransfer = $refundCalculatorPlugin->calculateRefund($refundTransfer, $orderTransfer, $salesOrderItems);
     }
     return $refundTransfer;
 }
Ejemplo n.º 5
0
 /**
  * @param \Generated\Shared\Transfer\RefundTransfer $refundTransfer
  *
  * @return void
  */
 protected function calculateRefundableItemAmount(RefundTransfer $refundTransfer)
 {
     foreach ($refundTransfer->getItems() as $itemTransfer) {
         $refundTransfer->setAmount($refundTransfer->getAmount() + $itemTransfer->getRefundableAmount());
     }
 }
Ejemplo n.º 6
0
 /**
  * @return void
  */
 public function ccRefundAction()
 {
     $payment = new PayonePaymentTransfer();
     $payment->setTransactionId(PayoneApiConstants::TEST_TRANSACTION_ID);
     $payment->setPaymentMethod(PayoneApiConstants::PAYMENT_METHOD_CREDITCARD_PSEUDO);
     $refund = new RefundTransfer();
     $refund->setPayment($payment);
     $refund->setAmount(-100);
     $refund->setUseCustomerdata(PayoneApiConstants::USE_CUSTOMER_DATA_YES);
     $refund->setNarrativeText('Test narrative');
     //        echo '<pre>' . var_dump($refund) . '</pre>';die;
     $result = $this->getFacade()->refundPayment($refund);
     dump($result);
     die;
 }
Ejemplo n.º 7
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));
 }