Ejemplo n.º 1
0
 /**
  * @param \Generated\Shared\Transfer\RefundTransfer $refundTransfer
  *
  * @return void
  */
 public function aggregate(RefundTransfer $refundTransfer)
 {
     $totals = $refundTransfer->getTotals();
     $groupedTaxTotals = $this->getGroupedTaxTotals($refundTransfer->getItems());
     $taxTotalAmount = $this->getTaxTotalAmount($groupedTaxTotals);
     $totals->setTaxTotals($groupedTaxTotals);
     $totals->setTaxTotalAmount($taxTotalAmount);
 }
Ejemplo n.º 2
0
 /**
  * @param \Generated\Shared\Transfer\RefundTransfer $refundTransfer
  *
  * @return void
  */
 public function aggregate(RefundTransfer $refundTransfer)
 {
     $discountTotal = 0;
     foreach ($refundTransfer->getItems() as $itemTransfer) {
         $discountTotal += $itemTransfer->getDiscountAmount();
     }
     $refundTransfer->getTotals()->setDiscountTotal($discountTotal);
 }
Ejemplo n.º 3
0
 /**
  * @param \Generated\Shared\Transfer\RefundTransfer $refundTransfer
  *
  * @return void
  */
 protected function setCanceledExpenseAmount(RefundTransfer $refundTransfer)
 {
     if ($refundTransfer->getExpenses()) {
         foreach ($refundTransfer->getExpenses() as $expenseTransfer) {
             $expenseTransfer->setCanceledAmount($expenseTransfer->getRefundableAmount());
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * @param \Generated\Shared\Transfer\RefundTransfer $refundTransfer
  *
  * @return void
  */
 public function aggregate(RefundTransfer $refundTransfer)
 {
     $refundTotals = $refundTransfer->getTotals();
     $subTotal = $refundTotals->getSubTotal();
     $discountTotal = $refundTotals->getDiscountTotal();
     $refundTotal = $subTotal - $discountTotal;
     $refundTotals->setRefundTotal($refundTotal);
 }
Ejemplo n.º 5
0
 /**
  * @param \Generated\Shared\Transfer\RefundTransfer $refundTransfer
  *
  * @return void
  */
 public function aggregate(RefundTransfer $refundTransfer)
 {
     $subTotal = 0;
     foreach ($refundTransfer->getItems() as $item) {
         $item->requireTotalGrossPrice();
         $subTotal += $item->getTotalGrossPrice();
     }
     $refundTransfer->getTotals()->setSubTotal($subTotal);
 }
Ejemplo n.º 6
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.º 7
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.º 8
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.º 9
0
 /**
  * @param \Orm\Zed\Refund\Persistence\PavRefund $refundEntity
  *
  * @return \Generated\Shared\Transfer\RefundTransfer
  */
 protected function convertToTransfer(PavRefund $refundEntity)
 {
     $refundTransfer = new RefundTransfer();
     $refundTransfer->fromArray($refundEntity->toArray(), true);
     foreach ($refundEntity->getRefundItems() as $refundItem) {
         $refundItemTransfer = new RefundItemTransfer();
         $refundItemTransfer->fromArray($refundItem->toArray(), true);
         $refundTransfer->addItem($refundItemTransfer);
     }
     return $refundTransfer;
 }
Ejemplo n.º 10
0
 /**
  * @param \Generated\Shared\Transfer\RefundTransfer $refundTransfer
  *
  * @return void
  */
 protected function updateExpenses(RefundTransfer $refundTransfer)
 {
     foreach ($refundTransfer->getExpenses() as $expenseTransfer) {
         $salesExpenseEntity = $this->getExpenseEntity($expenseTransfer);
         $salesExpenseEntity->setCanceledAmount($expenseTransfer->getCanceledAmount());
         $salesExpenseEntity->save();
     }
 }
Ejemplo n.º 11
0
 /**
  * @param \Generated\Shared\Transfer\OrderTransfer $order
  *
  * @return \Generated\Shared\Transfer\RefundTransfer
  */
 protected function createRefundTransfer(OrderTransfer $order)
 {
     $refund = new RefundTransfer();
     $refund->setFkSalesOrder($order->getIdSalesOrder());
     return $refund;
 }
Ejemplo n.º 12
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.º 13
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));
 }
 /**
  * @param \Generated\Shared\Transfer\RefundTransfer $refundTransfer
  *
  * @return void
  */
 protected function addTotalsTransfer(RefundTransfer $refundTransfer)
 {
     $totalsTransfer = new RefundTotalsTransfer();
     $refundTransfer->setTotals($totalsTransfer);
 }
Ejemplo n.º 15
0
 /**
  * @param \Generated\Shared\Transfer\RefundTransfer $refundTransfer
  *
  * @return void
  */
 public function aggregate(RefundTransfer $refundTransfer)
 {
     $refundItems = $refundTransfer->getItems();
     $groupedRefundItems = $this->groupItemsByName($refundItems);
     $refundTransfer->setGroupedItems(new \ArrayObject($groupedRefundItems));
 }
Ejemplo n.º 16
0
 /**
  * @param \Generated\Shared\Transfer\RefundTransfer $refundTransfer
  *
  * @return void
  */
 protected function setCanceledItemAmount(RefundTransfer $refundTransfer)
 {
     foreach ($refundTransfer->getItems() as $itemTransfer) {
         $itemTransfer->setCanceledAmount($itemTransfer->getRefundableAmount());
     }
 }
Ejemplo n.º 17
0
 /**
  * @param \Generated\Shared\Transfer\RefundTransfer $refundTransfer
  *
  * @return bool
  */
 protected function isCustomRefund(RefundTransfer $refundTransfer)
 {
     foreach ($refundTransfer->getItems() as $refundItem) {
         if ($refundItem->getFkSalesOrderItem() !== null) {
             return false;
         }
     }
     return true;
 }