Пример #1
0
 /**
  * Updates a transaction record
  *
  * @param Model_Core_Transaction $transaction
  * @return bool
  */
 public function updateTransaction(Model_Core_Transaction $transaction)
 {
     // Firstly we need to see if this already exists
     $select = $this->select();
     $select->where('ID = ?', $transaction->getId());
     $row = $this->fetchRow($select);
     // There should only be a single transaction with the given id
     if (count($row) == 1) {
         $data = array('PreviousID' => $transaction->getPreviousId(), 'EnquiryID' => $transaction->getEnquiryId(), 'Amount' => $transaction->getAmount(), 'StatusID' => $transaction->getStatusId(), 'InvoiceID' => $transaction->getInvoiceId(), 'CreditNoteID' => $transaction->getCreditNoteId(), 'InsuranceNetAmount' => $transaction->getInsuranceNetAmount(), 'TransactionDate' => $transaction->getTransactionDate());
         $where = $this->_db->quoteInto('ID = ?', $transaction->getId());
         $this->update($data, $where);
         return true;
     }
     Application_Core_Logger::log("Can't update transaction claim in table {$this->_name}", 'error');
     return false;
 }
 /**
  * Cancels a transaction
  *
  * @param \DateTime $transactionAt
  * @return null|int
  */
 protected function cancelTransaction($transactionAt)
 {
     $monthNo = $transactionAt->format('m');
     $year = $transactionAt->format('Y');
     $this->transData = $this->transaction->getLatestTransactionByTermId($this->termId, $monthNo, $year);
     if ($this->transData) {
         if ($this->transData->getInvoiceID() > 0) {
             $this->transactionAmount += $this->transData->getAmount();
         }
         $this->transData->setStatusId($this->transStatusCancelled);
         $this->transaction->updateTransaction($this->transData);
         $previousId = $this->transData->getId();
         $this->tsData = $this->transactionSupport->getTransactionSupport($previousId);
         $this->tsData->setTransDate($transactionAt->format('Y-m-d'))->setBand($this->band);
         $this->transactionSupport->updateTransactionSupport($this->tsData);
         return $previousId;
     }
     return null;
 }