private function _calculateBalances() { $req = new BalanceCalcRequest(); $req->setData(BalanceCalcRequest::ASSET_TYPE_ID, $this->typeAssetId); $req->setData(BalanceCalcRequest::DATE_TO, self::DATA_DATE_BALANCE_UP_TO); $resp = $this->_callBalance->calc($req); $this->assertTrue($resp->isSucceed()); $this->_logger->debug("Balances are calculated up to '" . $req->getData(BalanceCalcRequest::DATE_TO) . "'."); }
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; }