diff --git a/ChangeLog b/ChangeLog index 5879e5a..4c97cec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,11 @@ -v0.2_dev (20/12/10) +v0.2_dev (06/01/2011) ** User ** Better use of sizers (so better interface!) ** Dev ** Use a factory to create panels (prepare for plug-in) + +** Bugs ** + Bug on GenerateMonth with different years diff --git a/src/model/User.h b/src/model/User.h index 3e9b689..509186d 100644 --- a/src/model/User.h +++ b/src/model/User.h @@ -51,14 +51,19 @@ public: wxString GetCategoryName(wxString& catId); wxString GetCategoryId(wxString& catName); const wxFont GetCategoryFont(wxString& catId); + Account GetAccount(const wxString& accountId); wxString GetAccountName(const wxString& accountId); wxString GetAccountId(wxString& accountName); + int GetCategoriesNumber(); int GetAccountsNumber(); int GetOperationsNumber(int month, int year); + wxLanguage GetLanguage(); + void LinkOrUnlinkOperation(Operation& op); + void Group(const Operation& op); bool Group(std::vector* ops, const Operation& op); void UnGroup(const Operation& op); diff --git a/src/view/StatsPanel.cpp b/src/view/StatsPanel.cpp index 8468a4a..0a5a650 100644 --- a/src/view/StatsPanel.cpp +++ b/src/view/StatsPanel.cpp @@ -54,10 +54,12 @@ StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent), _yearTo->Append(wxString::Format(wxT("%d"), it->first)); } - _monthFrom->Select(0); - _monthTo->Select(11); + if (i) i--; + _yearFrom->Select(i); _yearTo->Select(i); + _monthFrom->Select(0); + _monthTo->Select(11); wxStaticText* label = new wxStaticText(this, wxID_ANY, _("From")); hbox->Add(label, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5); @@ -163,12 +165,11 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT std::map > > accountAmounts; std::map categories; std::map > operations; - std::map >::iterator accountIdIt2; + std::vector::iterator accountIt; std::map::iterator categoriesIt; - std::map > >::iterator accountIdIt; std::map >::iterator accountYearIt; double total; - int size, i, a, b, percents, account, nbDays; + int account, size, i, a, b, percents, nbDays; double *amounts; wxString value; User* user = _kiss->GetUser(); @@ -204,10 +205,10 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT dataset->AddSerie((double *) amounts, nbDays); delete[] amounts; - for (account = 0, i = 0, accountIdIt2 = operations.begin(); accountIdIt2 != operations.end(); - accountIdIt2++, i++, account++) + for (account = 0, i = 0, accountIt = user->_accounts.begin(); accountIt != user->_accounts.end(); + account++, accountIt++, i++) { - if (!((wxCheckListBox*)_account)->IsChecked(account)) + if (!_account->IsChecked(account)) { i-- ; continue; @@ -218,11 +219,11 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT for (a=0; afirst][a]; + amounts[a*2+1] = operations[accountIt->id][a]; } dataset->AddSerie((double *) amounts, nbDays); // set serie names to be displayed on legend - dataset->SetSerieName(i+1, user->GetAccountName(accountIdIt2->first)); + dataset->SetSerieName(i+1, user->GetAccountName(accountIt->id)); delete[] amounts; } } @@ -245,34 +246,34 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT dataset->AddSerie((double *) amounts, size); delete[] amounts; - for (account = 0, i = 0, accountIdIt = accountAmounts.begin(); accountIdIt != accountAmounts.end(); - accountIdIt++, i++, account++) + for (account = 0, i = 0, accountIt = user->_accounts.begin(); accountIt != user->_accounts.end(); + account++, accountIt++, i++) { - if (!((wxCheckListBox*)_account)->IsChecked(account)) + if (!_account->IsChecked(account)) { i-- ; continue; } - size = accountAmounts[accountIdIt->first].size(); + size = accountAmounts[accountIt->id].size(); amounts = new double[size*12*2]; size = 0; - for(a = 0, accountYearIt = accountAmounts[accountIdIt->first].begin(); - accountYearIt != accountAmounts[accountIdIt->first].end(); + for(a = 0, accountYearIt = accountAmounts[accountIt->id].begin(); + accountYearIt != accountAmounts[accountIt->id].end(); accountYearIt++, a++) { for(b = 0; b<12; b++) { - if (!accountAmounts[accountIdIt->first][accountYearIt->first].count(b)) + if (!accountAmounts[accountIt->id][accountYearIt->first].count(b)) continue; amounts[size*2+0] = a*12+b; - amounts[size*2+1] = accountAmounts[accountIdIt->first][accountYearIt->first][b]; + amounts[size*2+1] = accountAmounts[accountIt->id][accountYearIt->first][b]; size++; } } dataset->AddSerie((double *) amounts, size); // set serie names to be displayed on legend - dataset->SetSerieName(i+1, user->GetAccountName(accountIdIt->first)); + dataset->SetSerieName(i+1, user->GetAccountName(accountIt->id)); delete[] amounts; } } @@ -351,7 +352,7 @@ void StatsPanel::OnRangeChange(wxCommandEvent& event) monthTo = _monthTo->GetCurrentSelection(); _yearTo->GetStringSelection().ToLong(&yearTo); - if (yearTo > yearFrom || + if (yearTo < yearFrom || (yearFrom == yearTo && monthFrom > monthTo)) { wxMessageBox(_("Invalide date range"), _("KissCount"), wxICON_ERROR | wxOK);