Example #1
0
 public function calculateValue()
 {
     $model = new PortfolioTwrValueModel();
     $model->setDate($this->getCurDate()->format('Y-m-d'));
     $model->setClientId($this->getKey());
     $model->setNetValue(Functions::calculateTodayTwr($this->getSumTodayClientValue(), $this->getSumYesterdayClientNetCashFlow(), $this->getSumYesterdayClientValue()));
     $model->setGrossValue(Functions::calculateTodayTwr($this->getSumTodayClientValue(), $this->getSumYesterdayClientGrossCashFlow(), $this->getSumYesterdayClientValue()));
     // Save portfolio value
     return $model->getNetValue() && $model->getGrossValue() ? $this->valueRepo->save($model) : null;
 }
 /**
  * @param PortfolioTwrValue $model
  * @return mixed
  */
 public function save(PortfolioTwrValue $model)
 {
     $result = $this->fpdo->from($this->table)->where('date = DATE(?)', $model->getDate())->where('client_id', $model->getClientId())->limit(1)->fetch('id');
     return $result ? $this->update($result, $model) : $this->insert($model);
 }