public function getLastDate(Request\GetLastDate $request)
 {
     $result = new Response\GetLastDate();
     $assetTypeId = $request->getAssetTypeId();
     $assetTypeCode = $request->getAssetTypeCode();
     if (is_null($assetTypeId)) {
         $assetTypeId = $this->_repoTypeAsset->getIdByCode($assetTypeCode);
     }
     /* get the maximal date for balance */
     $balanceMaxDate = $this->_repoBalance->getMaxDate($assetTypeId);
     if ($balanceMaxDate) {
         /* there is balance data */
         $dayBefore = $this->_toolPeriod->getPeriodPrev($balanceMaxDate, IPeriod::TYPE_DAY);
         $result->setData([Response\GetLastDate::LAST_DATE => $dayBefore]);
         $result->markSucceed();
     } else {
         /* there is no balance data yet, get transaction with minimal date */
         $transactionMinDate = $this->_repoTransaction->getMinDateApplied($assetTypeId);
         if ($transactionMinDate) {
             $period = $this->_toolPeriod->getPeriodCurrent($transactionMinDate);
             $dayBefore = $this->_toolPeriod->getPeriodPrev($period, IPeriod::TYPE_DAY);
             $result->setData([Response\GetLastDate::LAST_DATE => $dayBefore]);
             $result->markSucceed();
         }
     }
     return $result;
 }