Month generation OK
This commit is contained in:
parent
7d1f9ee120
commit
271b3ef1e7
|
@ -161,7 +161,8 @@ void KissCount::GenerateMonth(int monthFrom, int yearFrom, int monthTo, int year
|
||||||
op = *it;
|
op = *it;
|
||||||
op.month = monthTo;
|
op.month = monthTo;
|
||||||
op.year = yearTo;
|
op.year = yearTo;
|
||||||
AddOperation(op);
|
op.id = AddOperation(op);
|
||||||
|
(*_user->_operations[yearTo])[monthTo].push_back(op);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_wxUI->GenerateMonth(monthTo, yearTo);
|
_wxUI->GenerateMonth(monthTo, yearTo);
|
||||||
|
|
|
@ -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++)
|
for (it = user->_accounts.begin(); it != user->_accounts.end(); it++)
|
||||||
{
|
{
|
||||||
amount = 0.0;
|
amount = 0.0;
|
||||||
req = _("SELECT SUM(amount) FROM operation WHERE") ;
|
req = _("SELECT amount FROM operation WHERE") ;
|
||||||
req += _(" account='") + it->id + _("'");
|
req += _(" account='") + it->id + _("'");
|
||||||
req += _(" AND year='") + wxString::Format(_("%d"), yearFrom) + _("'");
|
req += _(" AND year='") + wxString::Format(_("%d"), yearFrom) + _("'");
|
||||||
req += _(" AND month='") + wxString::Format(_("%d"), monthFrom) + _("'");
|
req += _(" AND month='") + wxString::Format(_("%d"), monthFrom) + _("'");
|
||||||
|
|
||||||
EXECUTE_SQL_QUERY(req, set, );
|
EXECUTE_SQL_QUERY(req, set, );
|
||||||
|
|
||||||
if (set.NextRow())
|
while (set.NextRow())
|
||||||
amount = set.GetDouble(_("amount"));
|
amount += set.GetDouble(_("amount"));
|
||||||
|
|
||||||
req = _("SELECT amount FROM account_amount WHERE") ;
|
req = _("SELECT amount FROM account_amount WHERE") ;
|
||||||
req += _(" account='") + it->id + _("'");
|
req += _(" account='") + it->id + _("'");
|
||||||
|
|
|
@ -223,10 +223,10 @@ void AccountPanel::LoadYear(int year, bool showMonth)
|
||||||
{
|
{
|
||||||
User* user = _kiss->GetUser();
|
User* user = _kiss->GetUser();
|
||||||
int curMonth = -1;
|
int curMonth = -1;
|
||||||
std::map<unsigned int, std::vector<operation> >::iterator it;
|
|
||||||
wxDateTime curDate;
|
wxDateTime curDate;
|
||||||
wxTreeItemId parentNode, curMonthNode;
|
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])
|
if (user->_operations[year])
|
||||||
{
|
{
|
||||||
|
@ -237,19 +237,20 @@ void AccountPanel::LoadYear(int year, bool showMonth)
|
||||||
|
|
||||||
_curYear = year ;
|
_curYear = year ;
|
||||||
_kiss->LoadYear(year);
|
_kiss->LoadYear(year);
|
||||||
|
ops = _kiss->GetAllOperations();
|
||||||
|
|
||||||
curDate.SetToCurrent();
|
curDate.SetToCurrent();
|
||||||
parentNode = _tree.GetSelection();
|
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;
|
curMonth = *it;
|
||||||
curMonthNode = _tree.AppendItem(parentNode, months[it->first]);
|
curMonthNode = _tree.AppendItem(parentNode, months[*it]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_tree.AppendItem(parentNode, months[it->first]);
|
_tree.AppendItem(parentNode, months[*it]);
|
||||||
}
|
}
|
||||||
|
|
||||||
_tree.Expand(parentNode);
|
_tree.Expand(parentNode);
|
||||||
|
@ -945,7 +946,7 @@ void AccountPanel::GenerateMonth(int month, int year)
|
||||||
it != user->_operations[year]->end();
|
it != user->_operations[year]->end();
|
||||||
it++, i++)
|
it++, i++)
|
||||||
{
|
{
|
||||||
if ((int)it->first >= month)
|
if ((int)it->first > month)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
years = _tree.InsertItem(years, i, monthString);
|
years = _tree.InsertItem(years, i, monthString);
|
||||||
|
|
|
@ -65,15 +65,18 @@ GenerateDialog::GenerateDialog(KissCount* kiss, wxUI *parent, int month, int yea
|
||||||
{
|
{
|
||||||
if (_monthFrom->GetString(i) == months[month])
|
if (_monthFrom->GetString(i) == months[month])
|
||||||
{
|
{
|
||||||
toSelect = i+1;
|
toSelect = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_monthFrom->Select(toSelect);
|
_monthFrom->Select(toSelect);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
OnYearFromChange(event);
|
{
|
||||||
|
_yearFrom->Select(0);
|
||||||
|
OnYearFromChange(event);
|
||||||
|
}
|
||||||
|
|
||||||
for(i=2000; i<=2050; i++)
|
for(i=2000; i<=2050; i++)
|
||||||
_yearTo->Append(wxString::Format(_("%d"), i));
|
_yearTo->Append(wxString::Format(_("%d"), i));
|
||||||
|
@ -171,7 +174,7 @@ void GenerateDialog::OnOK(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
int monthFrom, yearFrom, monthTo, yearTo, i;
|
int monthFrom, yearFrom, monthTo, yearTo, i;
|
||||||
|
|
||||||
if (_yearFrom->GetString(_yearTo->GetCurrentSelection()) == _(""))
|
if (_yearFrom->GetString(_yearFrom->GetCurrentSelection()) == _(""))
|
||||||
{
|
{
|
||||||
monthFrom = -1;
|
monthFrom = -1;
|
||||||
yearFrom = -1;
|
yearFrom = -1;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user