Fix GetAllOperations bug and new user (GenerateMonth) bug
This commit is contained in:
+30
-9
@@ -606,7 +606,7 @@ void Database::DeleteCategory(User* user, Category category)
|
||||
|
||||
std::map<int, std::vector<int> > Database::GetAllOperations(User* user)
|
||||
{
|
||||
wxString req;
|
||||
wxString req, req2, reqUnion;
|
||||
wxSQLite3ResultSet set, set2;
|
||||
std::vector<Account>::iterator it;
|
||||
std::map<int, std::vector<int> > res;
|
||||
@@ -615,35 +615,56 @@ std::map<int, std::vector<int> > Database::GetAllOperations(User* user)
|
||||
if (!user->_accounts.empty())
|
||||
{
|
||||
it = user->_accounts.begin();
|
||||
req = wxT("SELECT DISTINCT year FROM operation WHERE account IN('") + it->id;
|
||||
req = wxT("SELECT DISTINCT year FROM account_amount WHERE account IN('") + it->id;
|
||||
it++;
|
||||
for (;it != user->_accounts.end(); it++)
|
||||
{
|
||||
req += wxT("', '") + it->id ;
|
||||
}
|
||||
req += wxT("')");
|
||||
req += wxT(" OR user='") + user->_id + wxT("'");
|
||||
req += wxT(" ORDER BY year ASC");
|
||||
|
||||
EXECUTE_SQL_QUERY(req, set, res);
|
||||
it = user->_accounts.begin();
|
||||
req2 = wxT("SELECT DISTINCT year FROM operation WHERE account IN('") + it->id;
|
||||
it++;
|
||||
for (;it != user->_accounts.end(); it++)
|
||||
{
|
||||
req2 += wxT("', '") + it->id ;
|
||||
}
|
||||
req2 += wxT("')");
|
||||
req2 += wxT(" OR user='") + user->_id + wxT("'");
|
||||
req2 += wxT(" ORDER BY year ASC");
|
||||
|
||||
reqUnion = req + wxT(" UNION ") + req2;
|
||||
EXECUTE_SQL_QUERY(reqUnion, set, res);
|
||||
|
||||
while (set.NextRow())
|
||||
{
|
||||
year = set.GetInt(wxT("year"));
|
||||
|
||||
it = user->_accounts.begin();
|
||||
req = wxT("SELECT DISTINCT month FROM operation WHERE (account IN('") + it->id;
|
||||
req = wxT("SELECT DISTINCT month FROM account_amount WHERE account IN('") + it->id;
|
||||
it++;
|
||||
for (;it != user->_accounts.end(); it++)
|
||||
{
|
||||
req += wxT("', '") + it->id ;
|
||||
}
|
||||
req += wxT("')");
|
||||
req += wxT(" OR user='") + user->_id + wxT("')");
|
||||
req += wxT(" AND year='") + set.GetAsString(wxT("year")) + wxT("'");
|
||||
req += wxT(" ORDER BY month ASC");
|
||||
|
||||
EXECUTE_SQL_QUERY(req, set2, res);
|
||||
it = user->_accounts.begin();
|
||||
req2 = wxT("SELECT DISTINCT month FROM operation WHERE (account IN('") + it->id;
|
||||
it++;
|
||||
for (;it != user->_accounts.end(); it++)
|
||||
{
|
||||
req2 += wxT("', '") + it->id ;
|
||||
}
|
||||
req2 += wxT("')");
|
||||
req2 += wxT(" OR user='") + user->_id + wxT("')");
|
||||
req2 += wxT(" AND year='") + set.GetAsString(wxT("year")) + wxT("'");
|
||||
req2 += wxT(" ORDER BY month ASC");
|
||||
|
||||
reqUnion = req + wxT(" UNION ") + req2;
|
||||
EXECUTE_SQL_QUERY(reqUnion, set2, res);
|
||||
|
||||
while (set2.NextRow())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user