public function calc(Request\Calc $request) { $result = new Response\Calc(); $assetTypeId = $request->getAssetTypeId(); $dateTo = $request->getDateTo(); /* get the last balance date */ $reqLastDate = new Request\GetLastDate(); $reqLastDate->setData(Request\GetLastDate::ASSET_TYPE_ID, $assetTypeId); $respLastDate = $this->getLastDate($reqLastDate); $lastDate = $respLastDate->getLastDate(); $balances = $this->_repoMod->getBalancesOnDate($assetTypeId, $lastDate); /* get transactions for period */ $dtFrom = $this->_toolPeriod->getTimestampFrom($lastDate, IPeriod::TYPE_DAY); $dtTo = $this->_toolPeriod->getTimestampTo($dateTo, IPeriod::TYPE_DAY); $trans = $this->_repoMod->getTransactionsForPeriod($assetTypeId, $dtFrom, $dtTo); $updates = $this->_subCalcSimple->calcBalances($balances, $trans); $this->_repoMod->updateBalances($updates); $result->markSucceed(); return $result; }