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; }