예제 #1
0
 /**
  * @param array $data
  * @return id|null
  */
 public function process(array $data)
 {
     if (null == ($securityType = $this->securityTypeRepo->findOneByName($data['security_type']))) {
         // Add error
         return null;
     }
     $model = new SecurityModel();
     $model->setSymbol($data['symbol']);
     $model->setName(addslashes($data['description']));
     $model->setSecurityTypeId($securityType->getId());
     return $this->securityRepo->save($model);
 }
예제 #2
0
파일: Lot.php 프로젝트: junjinZ/wealthbot
 /**
  * @param SystemClientAccountModel $account
  * @param SecurityModel $security
  * @param array $data
  * @return mixed
  */
 public function process(SystemClientAccountModel $account, SecurityModel $security, array $data)
 {
     $model = new LotModel();
     $model->setSymbol($data['symbol']);
     $model->setTransactionCode($data['transaction_code']);
     $model->setInitialLotId(null);
     $model->setQuantity($data['qty']);
     $model->setStatus(WealthbotLot::LOT_INITIAL);
     $model->setDate($data['tx_date']);
     $model->setWasClosed(false);
     $model->setAmount($data['net_amount']);
     $model->setCostBasis($data['gross_amount']);
     $model->setRealizedGain(null);
     $model->setSecurityId($security->getId());
     $model->setClientSystemAccountId($account->getId());
     $model->setWasRebalancerDiff(false);
     $class = Factory::make($model->isBuy() ? 'Buy' : 'Sell');
     // Create new lot
     return $class->create($model);
 }
예제 #3
0
 /**
  * @param Security $model
  * @return mixed
  */
 public function save(Security $model)
 {
     $result = $this->findOneBySymbol($model->getSymbol());
     return $result ? $this->update($result->getId(), $model) : $this->insert($model);
 }