Month generation OK

This commit is contained in:
Grégory Soutadé 2010-06-23 20:30:42 +02:00
parent 7d1f9ee120
commit 271b3ef1e7
4 changed files with 21 additions and 16 deletions

View File

@ -161,7 +161,8 @@ void KissCount::GenerateMonth(int monthFrom, int yearFrom, int monthTo, int year
op = *it;
op.month = monthTo;
op.year = yearTo;
AddOperation(op);
op.id = AddOperation(op);
(*_user->_operations[yearTo])[monthTo].push_back(op);
}
}
_wxUI->GenerateMonth(monthTo, yearTo);

View File

@ -632,15 +632,15 @@ void Database::GenerateMonth(User* user, int monthFrom, int yearFrom, int monthT
for (it = user->_accounts.begin(); it != user->_accounts.end(); it++)
{
amount = 0.0;
req = _("SELECT SUM(amount) FROM operation WHERE") ;
req = _("SELECT amount FROM operation WHERE") ;
req += _(" account='") + it->id + _("'");
req += _(" AND year='") + wxString::Format(_("%d"), yearFrom) + _("'");
req += _(" AND month='") + wxString::Format(_("%d"), monthFrom) + _("'");
EXECUTE_SQL_QUERY(req, set, );
if (set.NextRow())
amount = set.GetDouble(_("amount"));
while (set.NextRow())
amount += set.GetDouble(_("amount"));
req = _("SELECT amount FROM account_amount WHERE") ;
req += _(" account='") + it->id + _("'");

View File

@ -223,10 +223,10 @@ void AccountPanel::LoadYear(int year, bool showMonth)
{
User* user = _kiss->GetUser();
int curMonth = -1;
std::map<unsigned int, std::vector<operation> >::iterator it;
wxDateTime curDate;
wxTreeItemId parentNode, curMonthNode;
//std::map<int, std::vector<int> > Database::GetAllOperations(User* user)
std::map<int, std::vector<int> > ops ;
std::vector<int>::iterator it;
if (user->_operations[year])
{
@ -237,19 +237,20 @@ void AccountPanel::LoadYear(int year, bool showMonth)
_curYear = year ;
_kiss->LoadYear(year);
ops = _kiss->GetAllOperations();
curDate.SetToCurrent();
parentNode = _tree.GetSelection();
for (it = user->_operations[year]->begin(); it != user->_operations[year]->end(); it++)
for (it = ops[year].begin(); it != ops[year].end(); it++)
{
if (curMonth == -1 || (year == curDate.GetYear() && (int)it->first <= curDate.GetMonth()))
if (curMonth == -1 || (year == curDate.GetYear() && *it <= curDate.GetMonth()))
{
curMonth = it->first;
curMonthNode = _tree.AppendItem(parentNode, months[it->first]);
curMonth = *it;
curMonthNode = _tree.AppendItem(parentNode, months[*it]);
}
else
_tree.AppendItem(parentNode, months[it->first]);
_tree.AppendItem(parentNode, months[*it]);
}
_tree.Expand(parentNode);
@ -945,7 +946,7 @@ void AccountPanel::GenerateMonth(int month, int year)
it != user->_operations[year]->end();
it++, i++)
{
if ((int)it->first >= month)
if ((int)it->first > month)
break;
}
years = _tree.InsertItem(years, i, monthString);

View File

@ -65,15 +65,18 @@ GenerateDialog::GenerateDialog(KissCount* kiss, wxUI *parent, int month, int yea
{
if (_monthFrom->GetString(i) == months[month])
{
toSelect = i+1;
toSelect = i;
break;
}
}
}
_monthFrom->Select(toSelect);
}
OnYearFromChange(event);
else
{
_yearFrom->Select(0);
OnYearFromChange(event);
}
for(i=2000; i<=2050; i++)
_yearTo->Append(wxString::Format(_("%d"), i));
@ -171,7 +174,7 @@ void GenerateDialog::OnOK(wxCommandEvent& event)
{
int monthFrom, yearFrom, monthTo, yearTo, i;
if (_yearFrom->GetString(_yearTo->GetCurrentSelection()) == _(""))
if (_yearFrom->GetString(_yearFrom->GetCurrentSelection()) == _(""))
{
monthFrom = -1;
yearFrom = -1;