Service/Account/Balance/LastDate.php
public function exec($request)
    {
        assert($request instanceof ARequest);
        $result = new AResponse();

        /** define local working data */
        $accountId = $request->getAccountId();
        $assetTypeId = $request->getAssetTypeId();
        $assetTypeCode = $request->getAssetTypeCode();
        $lastDate = null;

        /** validate pre-processing conditions */
        if (
            is_null($assetTypeId) &&
            !empty($assetTypeCode)
        ) {
            $assetTypeId = $this->daoTypeAsset->getIdByCode($assetTypeCode);
        }

        /** perform processing */
        if (!empty($accountId)) {
            /* prefer to get by account */
            $lastDate = $this->getBalanceMaxDateByAccId($accountId);
            if (!$lastDate) {
                /* balances are empty for the account, get transaction with minimal date */
                $transMinDate = $this->getTranMinDateByAccId($accountId);
                if ($transMinDate) {
                    $period = $this->hlpPeriod->getPeriodCurrent($transMinDate);
                    $lastDate = $this->hlpPeriod->getPeriodPrev($period, HPeriod::TYPE_DAY);
                }
            }
        } else if (!empty($assetTypeId)) {
            /* or get by assetType */
            $lastDate = $this->getBalanceMaxDateByAssetType($assetTypeId);
            if (!$lastDate) {
                /* there is no balance data yet, get transaction with minimal date */
                $transMinDate = $this->getTranMinDateByAssetType($assetTypeId);
                if ($transMinDate) {
                    $period = $this->hlpPeriod->getPeriodCurrent($transMinDate);
                    $lastDate = $this->hlpPeriod->getPeriodPrev($period, HPeriod::TYPE_DAY);
                }
            }
        }

        /** compose result */
        if ($lastDate) {
            $result->setLastDate($lastDate);
            $result->markSucceed();
        }
        return $result;
    }
public function exec($request)
    {
        assert($request instanceof ARequest);
        $result = new AResponse();

        /** define local working data */
        $accountId = $request->getAccountId();
        $assetTypeId = $request->getAssetTypeId();
        $assetTypeCode = $request->getAssetTypeCode();
        $lastDate = null;

        /** validate pre-processing conditions */
        if (
            is_null($assetTypeId) &&
            !empty($assetTypeCode)
        ) {
            $assetTypeId = $this->daoTypeAsset->getIdByCode($assetTypeCode);
        }

        /** perform processing */
        if (!empty($accountId)) {
            /* prefer to get by account */
            $lastDate = $this->getBalanceMaxDateByAccId($accountId);
            if (!$lastDate) {
                /* balances are empty for the account, get transaction with minimal date */
                $transMinDate = $this->getTranMinDateByAccId($accountId);
                if ($transMinDate) {
                    $period = $this->hlpPeriod->getPeriodCurrent($transMinDate);
                    $lastDate = $this->hlpPeriod->getPeriodPrev($period, HPeriod::TYPE_DAY);
                }
            }
        } else if (!empty($assetTypeId)) {
            /* or get by assetType */
            $lastDate = $this->getBalanceMaxDateByAssetType($assetTypeId);
            if (!$lastDate) {
                /* there is no balance data yet, get transaction with minimal date */
                $transMinDate = $this->getTranMinDateByAssetType($assetTypeId);
                if ($transMinDate) {
                    $period = $this->hlpPeriod->getPeriodCurrent($transMinDate);
                    $lastDate = $this->hlpPeriod->getPeriodPrev($period, HPeriod::TYPE_DAY);
                }
            }
        }

        /** compose result */
        if ($lastDate) {
            $result->setLastDate($lastDate);
            $result->markSucceed();
        }
        return $result;
    }
Get the last date for the balance (by asset type or by account).

@param \Praxigento\Accounting\Api\Service\Account\Balance\LastDate\Request $request
@return \Praxigento\Accounting\Api\Service\Account\Balance\LastDate\Response
@throws \Exception