示例#1
0
 /**
  * Create transaction
  *
  * @param \Model\Pas\SystemClientAccount $account
  * @param array $data
  * @return int|null
  */
 public function create(SystemClientAccountModel $account, array $data)
 {
     if (null == ($security = $this->getSecurity($data['symbol']))) {
         return null;
     }
     if (null == ($closingMethod = $this->getClosingMethod($data['closing_method']))) {
         return null;
     }
     if (null == ($transactionType = $this->getTransactionType($data['transaction_code']))) {
         return null;
     }
     $model = new TransactionModel();
     $model->loadFromArray($data);
     $model->setStatus('verified');
     $model->setAccountId($account->getId());
     $model->setSecurityId($security->getId());
     $model->setClosingMethodId($closingMethod->getId());
     $model->setTransactionTypeId($transactionType->getId());
     $id = $this->getRepository('Transaction')->save($model);
     if ($id && $model->isCreateLot()) {
         $data['transaction_id'] = $id;
         $this->collection[$data['tx_date']][] = $data;
     }
     if ($id) {
         // Update bill item fee collected
         $this->updateFeeCollected($account, $model);
     }
     return $id;
 }