Service/Account/Balance/Reset.php
private function queryDeleteByAssets($assetTypeIds, $dateFrom)
    {
        $tblAcc = $this->resource->getTableName(EAccount::ENTITY_NAME);
        $tblBal = $this->resource->getTableName(EBalance::ENTITY_NAME);
        $conn = $this->resource->getConnection();
        $quoted = $conn->quote($dateFrom);
        $in = '';
        foreach ($assetTypeIds as $id) {
            $in .= (int)$id . ',';
        }
        $in = substr($in, 0, strlen($in) - 1);
        $select = "SELECT " . EAccount::A_ID . " FROM $tblAcc";
        $select .= " WHERE " . EAccount::A_ASSET_TYPE_ID . " IN ($in)";
        $result = "DELETE FROM $tblBal WHERE " . EBalance::A_ACCOUNT_ID . " IN ($select)"
            . " AND (" . EBalance::A_DATE . ">$quoted)";
        return $result;
    }
private function queryDeleteByAssets($assetTypeIds, $dateFrom)
    {
        $tblAcc = $this->resource->getTableName(EAccount::ENTITY_NAME);
        $tblBal = $this->resource->getTableName(EBalance::ENTITY_NAME);
        $conn = $this->resource->getConnection();
        $quoted = $conn->quote($dateFrom);
        $in = '';
        foreach ($assetTypeIds as $id) {
            $in .= (int)$id . ',';
        }
        $in = substr($in, 0, strlen($in) - 1);
        $select = "SELECT " . EAccount::A_ID . " FROM $tblAcc";
        $select .= " WHERE " . EAccount::A_ASSET_TYPE_ID . " IN ($in)";
        $result = "DELETE FROM $tblBal WHERE " . EBalance::A_ACCOUNT_ID . " IN ($select)"
            . " AND (" . EBalance::A_DATE . ">$quoted)";
        return $result;
    }
Compose query to delete balances filtered by asset types and date.

@param int[] $assetTypeIds
@param string $dateFrom
@return string