Ejemplo n.º 1
0
 /**
  * @param Creditmemo $dataObject
  * @return bool|\Magento\Sales\Model\Order\Creditmemo
  */
 public function getModel(Creditmemo $dataObject)
 {
     $this->creditmemoLoader->setOrderId($dataObject->getOrderId());
     $this->creditmemoLoader->setCreditmemoId($dataObject->getEntityId());
     $items = [];
     foreach ($dataObject->getItems() as $item) {
         $items[$item->getOrderItemId()] = ['qty' => $item->getQty()];
     }
     $creditmemo = ['items' => $items, 'shipping_amount' => $dataObject->getShippingAmount(), 'adjustment_positive' => $dataObject->getAdjustmentPositive(), 'adjustment_negative' => $dataObject->getAdjustmentNegative()];
     $this->creditmemoLoader->setCreditmemo($creditmemo);
     $this->creditmemoLoader->setInvoiceId($dataObject->getInvoiceId());
     return $this->creditmemoLoader->load();
 }
Ejemplo n.º 2
0
 /**
  * Cancel a creditmemo: substract its totals from the payment
  *
  * @param Creditmemo $creditmemo
  * @return $this
  */
 public function cancelCreditmemo($creditmemo)
 {
     $this->_updateTotals(array('amount_refunded' => -1 * $creditmemo->getGrandTotal(), 'base_amount_refunded' => -1 * $creditmemo->getBaseGrandTotal(), 'shipping_refunded' => -1 * $creditmemo->getShippingAmount(), 'base_shipping_refunded' => -1 * $creditmemo->getBaseShippingAmount()));
     $this->_eventManager->dispatch('sales_order_payment_cancel_creditmemo', array('payment' => $this, 'creditmemo' => $creditmemo));
     return $this;
 }
 /**
  * Initialize creditmemo state based on requested parameters
  *
  * @param Creditmemo $creditmemo
  * @param array $data
  * @return void
  */
 protected function initData($creditmemo, $data)
 {
     if (isset($data['shipping_amount'])) {
         $creditmemo->setBaseShippingAmount((double) $data['shipping_amount']);
     }
     if (isset($data['adjustment_positive'])) {
         $creditmemo->setAdjustmentPositive($data['adjustment_positive']);
     }
     if (isset($data['adjustment_negative'])) {
         $creditmemo->setAdjustmentNegative($data['adjustment_negative']);
     }
 }