Ejemplo n.º 1
0
 /**
  * prepare data of action to storage on transactions
  * the array that returned from function $action->getData('transaction_data')
  * will be setted to transaction model
  * 
  * @return Magestore_RewardPoints_Model_Action_Interface
  */
 public function prepareTransaction()
 {
     $order = $this->getData('action_object');
     $transactionData = array('status' => Magestore_RewardPoints_Model_Transaction::STATUS_COMPLETED, 'order_id' => $order->getId(), 'order_increment_id' => $order->getIncrementId(), 'order_base_amount' => $order->getBaseGrandTotal(), 'order_amount' => $order->getGrandTotal(), 'base_discount' => $order->getRewardpointsBaseDiscount(), 'discount' => $order->getRewardpointsDiscount(), 'store_id' => $order->getStoreId());
     // Check all earning transaction is holding
     $earningTransactions = Mage::getResourceModel('rewardpoints/transaction_collection')->addFieldToFilter('action', 'earning_invoice')->addFieldToFilter('order_id', $order->getId());
     $holdingAll = true;
     foreach ($earningTransactions as $transaction) {
         if ($transaction->getStatus() != Magestore_RewardPoints_Model_Transaction::STATUS_ON_HOLD) {
             $holdingAll = false;
             break;
         }
     }
     if ($holdingAll) {
         $transactionData['status'] = Magestore_RewardPoints_Model_Transaction::STATUS_ON_HOLD;
     } else {
         // Complete holding transaction before refund
         foreach ($earningTransactions as $transaction) {
             if ($transaction->getStatus() != Magestore_RewardPoints_Model_Transaction::STATUS_ON_HOLD) {
                 continue;
             }
             try {
                 $transaction->completeTransaction();
             } catch (Exception $e) {
                 Mage::logException($e);
             }
         }
     }
     $this->setData('transaction_data', $transactionData);
     return parent::prepareTransaction();
 }
Ejemplo n.º 2
0
 /**
  * prepare data of action to storage on transactions
  * the array that returned from function $action->getData('transaction_data')
  * will be setted to transaction model
  * 
  * @return Magestore_RewardPoints_Model_Action_Interface
  */
 public function prepareTransaction()
 {
     $creditmemo = $this->getData('action_object');
     $order = $creditmemo->getOrder();
     $transactionData = array('status' => Magestore_RewardPoints_Model_Transaction::STATUS_COMPLETED, 'order_id' => $order->getId(), 'order_increment_id' => $order->getIncrementId(), 'order_base_amount' => $order->getBaseGrandTotal(), 'order_amount' => $order->getGrandTotal(), 'base_discount' => $creditmemo->getRewardpointsBaseDiscount(), 'discount' => $creditmemo->getRewardpointsDiscount(), 'store_id' => $order->getStoreId(), 'extra_content' => $creditmemo->getIncrementId());
     // Set expire time for current transaction
     $expireDays = (int) Mage::getStoreConfig(Magestore_RewardPoints_Helper_Calculation_Earning::XML_PATH_EARNING_EXPIRE, $order->getStoreId());
     $transactionData['expiration_date'] = $this->getExpirationDate($expireDays);
     $this->setData('transaction_data', $transactionData);
     return parent::prepareTransaction();
 }
Ejemplo n.º 3
0
 /**
  * prepare data of action to storage on transactions
  * the array that returned from function $action->getData('transaction_data')
  * will be setted to transaction model
  * 
  * @return Magestore_RewardPoints_Model_Action_Interface
  */
 public function prepareTransaction()
 {
     $order = $this->getData('action_object');
     $transactionData = array('status' => Magestore_RewardPoints_Model_Transaction::STATUS_COMPLETED, 'order_id' => $order->getId(), 'order_increment_id' => $order->getIncrementId(), 'order_base_amount' => $order->getBaseGrandTotal(), 'order_amount' => $order->getGrandTotal(), 'base_discount' => $order->getRewardpointsBaseDiscount(), 'discount' => $order->getRewardpointsDiscount(), 'store_id' => $order->getStoreId());
     $this->setData('transaction_data', $transactionData);
     return parent::prepareTransaction();
 }
Ejemplo n.º 4
0
 /**
  * prepare data of action to storage on transactions
  * the array that returned from function $action->getData('transaction_data')
  * will be setted to transaction model
  * 
  * @return Magestore_RewardPoints_Model_Action_Interface
  */
 public function prepareTransaction()
 {
     $invoice = $this->getData('action_object');
     if ($invoice instanceof Mage_Sales_Model_Order_Invoice) {
         $order = $invoice->getOrder();
     } else {
         $order = $invoice;
     }
     $transactionData = array('status' => Magestore_RewardPoints_Model_Transaction::STATUS_COMPLETED, 'order_id' => $order->getId(), 'order_increment_id' => $order->getIncrementId(), 'order_base_amount' => $order->getBaseGrandTotal(), 'order_amount' => $order->getGrandTotal(), 'base_discount' => $invoice->getRewardpointsBaseDiscount(), 'discount' => $invoice->getRewardpointsDiscount(), 'store_id' => $order->getStoreId());
     // Check if transaction need to hold
     $holdDays = (int) Mage::getStoreConfig(Magestore_RewardPoints_Helper_Calculation_Earning::XML_PATH_HOLDING_DAYS, $order->getStoreId());
     if ($holdDays > 0) {
         $transactionData['status'] = Magestore_RewardPoints_Model_Transaction::STATUS_ON_HOLD;
     }
     // Set expire time for current transaction
     $expireDays = (int) Mage::getStoreConfig(Magestore_RewardPoints_Helper_Calculation_Earning::XML_PATH_EARNING_EXPIRE, $order->getStoreId());
     $transactionData['expiration_date'] = $this->getExpirationDate($expireDays);
     // Set invoice id for current earning
     if ($invoice instanceof Mage_Sales_Model_Order_Invoice) {
         $transactionData['extra_content'] = $invoice->getIncrementId();
     }
     $this->setData('transaction_data', $transactionData);
     return parent::prepareTransaction();
 }
Ejemplo n.º 5
0
 /**
  * prepare data of action to storage on transactions
  * the array that returned from function $action->getData('transaction_data')
  * will be setted to transaction model
  * 
  * @return Magestore_RewardPoints_Model_Action_Interface
  */
 public function prepareTransaction()
 {
     $transactionData = array('status' => Magestore_RewardPoints_Model_Transaction::STATUS_COMPLETED);
     if ($user = Mage::getSingleton('admin/session')->getUser()) {
         $transactionData['extra_content'] = $user->getUsername();
     }
     $actionObject = $this->getData('action_object');
     if (is_object($actionObject) && $actionObject->getExpirationDay() && $this->getPointAmount() > 0) {
         $transactionData['expiration_date'] = $this->getExpirationDate($actionObject->getExpirationDay());
     }
     $this->setData('transaction_data', $transactionData);
     return parent::prepareTransaction();
 }