Exemplo n.º 1
0
 /**
  * @param \Model\Pas\SystemClientAccount $account
  * @return \Model\Pas\ClientPortfolio|null
  */
 protected function getPortfolio(SystemClientAccountModel $account)
 {
     if (null == ($portfolio = $this->clientPortfolioRepo->findOneByClientId($account->getClientId()))) {
         //$this->bugTracker->addError("Client portfolio by client id [{$clientId}] not found.");
     }
     return $portfolio;
 }
Exemplo n.º 2
0
 /**
  * @param SystemClientAccountModel $account
  * @param array $data
  */
 public function process(SystemClientAccountModel $account, array $data)
 {
     $lots = $this->lotRepo->findAllClosedBy(array('date' => $data['close_date'], 'quantity' => $data['shares_sold'], 'account_id' => $account->getId()));
     foreach ($lots as $lot) {
         $realizedGain = (int) $lot->getRealizedGain();
         $realizedGainST = (int) $data['st_gain_loss'];
         $realizedGainLT = (int) $data['lt_gain_loss'];
         if ($realizedGain < 0) {
             $status = $realizedGainST == abs($realizedGain) ? DocumentRealizedRepo::STATUS_MATCH : DocumentRealizedRepo::STATUS_NOT_MATCH;
         } else {
             $status = $realizedGainLT == abs($realizedGain) ? DocumentRealizedRepo::STATUS_MATCH : DocumentRealizedRepo::STATUS_NOT_MATCH;
         }
         $this->docRelizedRepo->changeStatusById($data['_id'], $status);
     }
 }
Exemplo n.º 3
0
 /**
  * @param SystemClientAccountModel $account
  * @param array $data
  */
 public function process(SystemClientAccountModel $account, array $data)
 {
     foreach ($data as $row) {
         if (null == ($security = $this->securityRepo->findOneBySymbol($row['symbol']))) {
             $this->docUnrealizedRepo->changeStatusById($row['_id'], DocumentBaseRepo::STATUS_NOT_POSTED);
             continue;
         }
         $lot = $this->lotRepo->findOneBy(array('status' => WealthbotLot::LOT_INITIAL, 'quantity' => $row['current_qty'], 'security_id' => $security->getId(), 'client_system_account_id' => $account->getId()));
         if (null == $lot) {
             $this->docUnrealizedRepo->changeStatusById($row['_id'], DocumentBaseRepo::STATUS_NOT_POSTED);
             continue;
         }
         $this->docUnrealizedRepo->update($row['_id'], array('status' => DocumentBaseRepo::STATUS_POSTED, 'lot_date' => $lot->getDate(), 'lot_amount' => $lot->getAmount(), 'lot_quantity' => $lot->getQuantity()));
     }
 }
Exemplo n.º 4
0
 /**
  * @param SystemClientAccountModel $account
  */
 public function calculatePeriod(SystemClientAccountModel $account)
 {
     $curDate = $this->getCurDate();
     $last1Year = $this->getModifyDate('-1 year');
     $last3Year = $this->getModifyDate('-3 year');
     $actualTwr = new Actual();
     // NET
     $model = new AccountTwrPeriodModel();
     $model->setNetMtd($actualTwr->rule(new AccountActualNetRule($account->getAccountNumber(), Util::firstDayOf('month', $curDate), $curDate)));
     $model->setNetQtd($actualTwr->rule(new AccountActualNetRule($account->getAccountNumber(), Util::firstDayOf('quarter', $curDate), $curDate)));
     $model->setNetYtd($actualTwr->rule(new AccountActualNetRule($account->getAccountNumber(), Util::firstDayOf('year', $curDate), $curDate)));
     $model->setNetYr1($actualTwr->rule(new AccountActualNetRule($account->getAccountNumber(), $last1Year, $curDate)));
     $model->setNetYr3($actualTwr->rule(new AccountActualNetRule($account->getAccountNumber(), $last3Year, $curDate)));
     $model->setNetSinceInception($actualTwr->rule(new AccountActualNetRule($account->getAccountNumber(), $account->getPerformanceInceptionAsDateTime())));
     // GROSS
     $model->setGrossMtd($actualTwr->rule(new AccountActualGrossRule($account->getAccountNumber(), Util::firstDayOf('month', $curDate), $curDate)));
     $model->setGrossQtd($actualTwr->rule(new AccountActualGrossRule($account->getAccountNumber(), Util::firstDayOf('quarter', $curDate), $curDate)));
     $model->setGrossYtd($actualTwr->rule(new AccountActualGrossRule($account->getAccountNumber(), Util::firstDayOf('year', $curDate), $curDate)));
     $model->setGrossYr1($actualTwr->rule(new AccountActualGrossRule($account->getAccountNumber(), $last1Year, $curDate)));
     $model->setGrossYr3($actualTwr->rule(new AccountActualGrossRule($account->getAccountNumber(), $last3Year, $curDate)));
     $model->setGrossSinceInception($actualTwr->rule(new AccountActualGrossRule($account->getAccountNumber(), $account->getPerformanceInceptionAsDateTime())));
     $model->setAccountNumber($account->getAccountNumber());
     // Save
     $this->periodRepo->save($model);
 }
Exemplo n.º 5
0
 /**
  * @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);
 }
Exemplo n.º 6
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;
 }