Add "non fix" category to statistics (sum of all non fix categories)
This commit is contained in:
parent
33a2cd1f0c
commit
6fae41b4e8
|
@ -17,6 +17,7 @@ v0.2 (28/05/2011)
|
|||
Add Import Panel, OFX and Grisbi imports
|
||||
Add update next months
|
||||
Change charts and real/virtual mode position
|
||||
Add "non fix" category to statistics (sum of all non fix categories)
|
||||
|
||||
** Dev **
|
||||
Use a factory to create panels (prepare for plug-in)
|
||||
|
|
1
TODO
1
TODO
|
@ -5,7 +5,6 @@ Auto completion (already up into wxwidgets 2.9)
|
|||
Using tabulation to navigate throw interface (Search Panel)
|
||||
Can type a letter with a comboboxes
|
||||
Windows version
|
||||
Real mode
|
||||
Choosing accounts & categories position
|
||||
|
||||
Cool for 0.2:
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "AccountPanel.h"
|
||||
|
||||
enum {ACCOUNT_NUMBER, ACCOUNT_NAME, ACCOUNT_INIT, ACCOUNT_CUR, ACCOUNT_FINAL, NUMBER_COLS_ACCOUNTS};
|
||||
enum {CUR_CREDIT, CUR_DEBIT, TOTAL_CREDIT, TOTAL_DEBIT, REMAINS, STATS_ROW, CATS_STATS};
|
||||
enum {CUR_CREDIT, CUR_DEBIT, TOTAL_CREDIT, TOTAL_DEBIT, REMAINS, STATS_ROW, CATS_STATS, NON_FIX};
|
||||
enum {CALENDAR_TREE_ID=1, OPS_GRID_ID, CALENDAR_ID, ACCOUNTS_GRID_ID, MENU_GENERATE_ID, MENU_DELETE_ID, DISPLAY_MODE_ID, GROUP_ID, UNGROUP_ID, UPDATE_NEXT_MONTHS_ID};
|
||||
|
||||
enum {VIRTUAL_MODE=0, REAL_MODE, CHECK_MODE};
|
||||
|
@ -188,12 +188,12 @@ wxString AccountPanel::GetToolTip()
|
|||
void AccountPanel::InitStatsGrid(User* user)
|
||||
{
|
||||
int i;
|
||||
|
||||
int nb_categories = user->GetCategoriesNumber();
|
||||
DEFAULT_FONT(font);
|
||||
|
||||
if (!_statsGrid->GetNumberRows())
|
||||
{
|
||||
_statsGrid->CreateGrid(user->GetCategoriesNumber()+6, 2);
|
||||
_statsGrid->CreateGrid(nb_categories+CATS_STATS, 2); // Headers + blank + categories + non fix
|
||||
_statsGrid->SetColLabelSize(0);
|
||||
_statsGrid->SetRowLabelSize(0);
|
||||
_statsGrid->EnableEditing(false);
|
||||
|
@ -201,7 +201,7 @@ void AccountPanel::InitStatsGrid(User* user)
|
|||
else
|
||||
{
|
||||
_statsGrid->DeleteRows(0, _statsGrid->GetNumberRows());
|
||||
_statsGrid->InsertRows(0, user->GetCategoriesNumber()+6);
|
||||
_statsGrid->InsertRows(0, nb_categories+CATS_STATS);
|
||||
}
|
||||
|
||||
_statsGrid->SetDefaultCellFont(font);
|
||||
|
@ -209,7 +209,7 @@ void AccountPanel::InitStatsGrid(User* user)
|
|||
_statsGrid->SetCellValue(TOTAL_CREDIT, 0, _("Total Credit"));
|
||||
_statsGrid->SetCellValue(TOTAL_DEBIT, 0, _("Total Debit"));
|
||||
|
||||
for(i=0; i<user->GetCategoriesNumber(); i++)
|
||||
for(i=0; i<nb_categories; i++)
|
||||
{
|
||||
_statsGrid->SetCellValue(CATS_STATS+i, 0, _categories[i]);
|
||||
_statsGrid->SetCellAlignment(CATS_STATS+i, 1, wxALIGN_RIGHT, wxALIGN_CENTRE);
|
||||
|
@ -225,12 +225,14 @@ void AccountPanel::InitStatsGrid(User* user)
|
|||
_statsGrid->SetCellValue(CUR_CREDIT, 0, _("Cur Credit"));
|
||||
_statsGrid->SetCellValue(CUR_DEBIT, 0, _("Cur Debit"));
|
||||
_statsGrid->SetCellValue(REMAINS, 0, _("Remains"));
|
||||
_statsGrid->SetCellValue(NON_FIX, 0, _("Non fix"));
|
||||
|
||||
_statsGrid->SetCellAlignment(CUR_DEBIT, 1, wxALIGN_RIGHT, wxALIGN_CENTRE);
|
||||
_statsGrid->SetCellAlignment(CUR_CREDIT, 1, wxALIGN_RIGHT, wxALIGN_CENTRE);
|
||||
_statsGrid->SetCellAlignment(TOTAL_DEBIT, 1, wxALIGN_RIGHT, wxALIGN_CENTRE);
|
||||
_statsGrid->SetCellAlignment(TOTAL_CREDIT, 1, wxALIGN_RIGHT, wxALIGN_CENTRE);
|
||||
_statsGrid->SetCellAlignment(REMAINS, 1, wxALIGN_RIGHT, wxALIGN_CENTRE);
|
||||
_statsGrid->SetCellAlignment(NON_FIX, 1, wxALIGN_RIGHT, wxALIGN_CENTRE);
|
||||
}
|
||||
|
||||
void AccountPanel::ChangeUser()
|
||||
|
@ -627,9 +629,19 @@ void AccountPanel::UpdateStats()
|
|||
percents = ((double) (_categoriesValues[i]*100))/totalDebit;
|
||||
else
|
||||
percents = 0.0;
|
||||
if (i)
|
||||
_statsGrid->SetCellValue(CATS_STATS+i+1, 1, wxString::Format(wxT("%.2lf (%02d %%)"), _categoriesValues[i], (int)percents));
|
||||
else
|
||||
_statsGrid->SetCellValue(CATS_STATS+i, 1, wxString::Format(wxT("%.2lf (%02d %%)"), _categoriesValues[i], (int)percents));
|
||||
}
|
||||
|
||||
value = totalDebit - _categoriesValues[0];
|
||||
if (totalDebit != 0)
|
||||
percents = ((double) (value*100))/totalDebit;
|
||||
else
|
||||
percents = 0.0;
|
||||
_statsGrid->SetCellValue(NON_FIX, 1, wxString::Format(wxT("%.2lf (%02d %%)"), value, (int)percents));
|
||||
|
||||
for (i=0, accountIt=user->_accounts.begin(); accountIt!=user->_accounts.end(); accountIt++, i++)
|
||||
{
|
||||
if (mode != CHECK_MODE)
|
||||
|
|
|
@ -92,7 +92,7 @@ StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent),
|
|||
|
||||
_statsGrid = new wxGrid(this, wxID_ANY);
|
||||
|
||||
_statsGrid->CreateGrid(user->GetCategoriesNumber(), 2);
|
||||
_statsGrid->CreateGrid(user->GetCategoriesNumber()+1, 2);
|
||||
_statsGrid->SetColLabelSize(0);
|
||||
_statsGrid->SetRowLabelSize(0);
|
||||
_statsGrid->EnableEditing(false);
|
||||
|
@ -101,10 +101,21 @@ StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent),
|
|||
_statsGrid->AutoSizeColumn(0, true);
|
||||
|
||||
for(i=0; i<user->GetCategoriesNumber(); i++)
|
||||
{
|
||||
if (i)
|
||||
{
|
||||
_statsGrid->SetCellValue(i+1, 0, _categories[i]);
|
||||
_statsGrid->SetCellAlignment(i+1, 1, wxALIGN_RIGHT, wxALIGN_CENTRE);
|
||||
}
|
||||
else
|
||||
{
|
||||
_statsGrid->SetCellValue(i, 0, _categories[i]);
|
||||
_statsGrid->SetCellAlignment(i, 1, wxALIGN_RIGHT, wxALIGN_CENTRE);
|
||||
}
|
||||
}
|
||||
|
||||
_statsGrid->SetCellValue(1, 0, _("Non fix"));
|
||||
_statsGrid->SetCellAlignment(1, 1, wxALIGN_RIGHT, wxALIGN_CENTRE);
|
||||
|
||||
_vbox2->Add(_account, 0, wxGROW|wxALL, 5);
|
||||
_vbox2->Add(_statsGrid, 0, wxALIGN_CENTER_HORIZONTAL|wxGROW|wxALL, 5);
|
||||
|
@ -127,11 +138,11 @@ StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent),
|
|||
|
||||
_pie->SetLegend(new Legend(wxBOTTOM, wxCENTER));
|
||||
|
||||
wxChartPanel* chart = new wxChartPanel(this);
|
||||
chart->SetChart(new Chart(_pie, _("Cost repartition")));
|
||||
chart->Fit();
|
||||
chart->Layout();
|
||||
chart->SetMinSize(// chart->GetSize()
|
||||
_chartCategories = new wxChartPanel(this);
|
||||
_chartCategories->SetChart(new Chart(_pie, _("Cost repartition")));
|
||||
_chartCategories->Fit();
|
||||
_chartCategories->Layout();
|
||||
_chartCategories->SetMinSize(// chart->GetSize()
|
||||
wxSize(200,250));
|
||||
|
||||
vbox->Add(hbox, 0, wxALIGN_CENTER_VERTICAL|wxGROW|wxALL, 5);
|
||||
|
@ -140,8 +151,6 @@ StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent),
|
|||
wxCommandEvent event ;
|
||||
OnRangeChange(event);
|
||||
|
||||
_hbox2->Add(chart, 0, wxGROW|wxALL, 10);
|
||||
|
||||
Fit();
|
||||
}
|
||||
|
||||
|
@ -171,7 +180,7 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT
|
|||
std::vector<Account>::iterator accountIt;
|
||||
std::map<wxString, double>::iterator categoriesIt;
|
||||
std::map<int, std::map<int, double> >::iterator accountYearIt;
|
||||
double total;
|
||||
double total, non_fix;
|
||||
int account, size, i, a, b, percents, nbDays;
|
||||
double *amounts;
|
||||
wxString value;
|
||||
|
@ -183,6 +192,7 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT
|
|||
{
|
||||
_hbox2->Detach(_chart);
|
||||
_hbox2->Detach(_vbox2);
|
||||
_hbox2->Detach(_chartCategories);
|
||||
delete _chart;
|
||||
}
|
||||
|
||||
|
@ -335,7 +345,7 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT
|
|||
for(categoriesIt = categories.begin(); categoriesIt != categories.end(); categoriesIt++)
|
||||
total += categoriesIt->second;
|
||||
|
||||
for(categoriesIt = categories.begin(); categoriesIt != categories.end(); categoriesIt++)
|
||||
for(i=0, categoriesIt = categories.begin(); categoriesIt != categories.end(); categoriesIt++, i++)
|
||||
{
|
||||
_categoriesValues[_categoriesIndexes[categoriesIt->first]] = categoriesIt->second;
|
||||
if (total)
|
||||
|
@ -343,15 +353,28 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT
|
|||
else
|
||||
percents = 0;
|
||||
value = wxString::Format(wxT("%0.2lf (%02d%%)"), categoriesIt->second, percents);
|
||||
if (i)
|
||||
_statsGrid->SetCellValue(_categoriesIndexes[categoriesIt->first]+1, 1, value);
|
||||
else
|
||||
_statsGrid->SetCellValue(_categoriesIndexes[categoriesIt->first], 1, value);
|
||||
}
|
||||
|
||||
non_fix = total - _categoriesValues[0];
|
||||
|
||||
if (total)
|
||||
percents = ((double) (non_fix*100))/total;
|
||||
else
|
||||
percents = 0;
|
||||
value = wxString::Format(wxT("%0.2lf (%02d%%)"), non_fix, percents);
|
||||
_statsGrid->SetCellValue(1, 1, value);
|
||||
|
||||
_statsGrid->AutoSizeColumn(0, true);
|
||||
_statsGrid->AutoSizeColumn(1, true);
|
||||
|
||||
_pie->DatasetChanged(_dataset);
|
||||
|
||||
_hbox2->Add(_vbox2, 0, wxGROW|wxALL, 5);
|
||||
_hbox2->Add(_chartCategories, 0, wxGROW|wxALL, 10);
|
||||
|
||||
Layout();
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ private:
|
|||
wxString* _categories;
|
||||
std::map<wxString, int> _categoriesIndexes;
|
||||
wxBoxSizer *_hbox2, *_vbox2;
|
||||
wxChartPanel* _chart;
|
||||
wxChartPanel* _chart, *_chartCategories;
|
||||
wxCheckListBox* _account;
|
||||
|
||||
void UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearTo);
|
||||
|
|
Loading…
Reference in New Issue
Block a user