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 int $id * @param PortfolioTwrValue $model * @return bool */ public function update($id, PortfolioTwrValue $model) { return $this->fpdo->update($this->table, array('net_value' => $model->getNetValue(), 'gross_value' => $model->getGrossValue()), $id)->execute(); }