コード例 #1
0
ファイル: Position.php プロジェクト: junjinZ/wealthbot
 /**
  * @param string $date
  */
 protected function calculateClientPortfolioValue($date)
 {
     $clientAccountValues = $this->clientAccountValueRepo->getAllSumByDate($date);
     foreach ($clientAccountValues as $clientAccountValue) {
         $model = new ClientPortfolioValueModel();
         $model->setClientPortfolioId($clientAccountValue->getClientPortfolioId());
         $model->setTotalValue($clientAccountValue->getTotalValue());
         $model->setTotalInSecurities($clientAccountValue->getTotalInSecurities());
         $model->setTotalCashInAccounts($clientAccountValue->getTotalCashInAccount());
         $model->setTotalCashInMoneyMarket($clientAccountValue->getTotalCashInMoneyMarket());
         $model->setSasCash($clientAccountValue->getSasCash());
         $model->setCashBuffer($clientAccountValue->getCashBuffer());
         $model->setBillingCash($clientAccountValue->getBillingCash());
         $model->setDate($date);
         // Save client portfolio value
         $this->clientPortfolioValueRepo->save($model);
     }
 }
コード例 #2
0
 /**
  * Save
  *
  * @param ClientPortfolioValue $model
  * @return int|bool
  */
 public function save(ClientPortfolioValue $model)
 {
     $result = $this->fpdo->from($this->table)->where('client_portfolio_id', $model->getClientPortfolioId())->where('date = DATE(?)', $model->getDate())->limit(1)->fetch('id');
     return $result ? $this->update($result, $model) : $this->insert($model);
 }