wip
This commit is contained in:
parent
1f50e15d39
commit
045992b69e
5
init.sql
5
init.sql
|
@ -13,8 +13,9 @@ INSERT INTO default_preference ("type", "name", "value") VALUES ("category", "na
|
||||||
INSERT INTO user ("id", "name", "password") VALUES ("0", "Greg", "da39a3ee5e6b4b0d3255bfef95601890afd80709");
|
INSERT INTO user ("id", "name", "password") VALUES ("0", "Greg", "da39a3ee5e6b4b0d3255bfef95601890afd80709");
|
||||||
INSERT INTO account ("id", "user", "name", "number", "shared", "default_account") VALUES ("0", "0", "Compte Courant", "000" , "0", "1");
|
INSERT INTO account ("id", "user", "name", "number", "shared", "default_account") VALUES ("0", "0", "Compte Courant", "000" , "0", "1");
|
||||||
INSERT INTO account_amount("id", "account", "year", "month", "amount") VALUES("0", "0", "2010", "0", "1000");
|
INSERT INTO account_amount("id", "account", "year", "month", "amount") VALUES("0", "0", "2010", "0", "1000");
|
||||||
INSERT INTO operation ("id", "user", "account", "year", "month", "day", "amount", "description", "category", "fix_cost") VALUES ("0", "0", "0", "2010", "0", "0", "1234", "Opé 1", "0", "1");
|
INSERT INTO operation ("id", "user", "account", "year", "month", "day", "amount", "description", "category", "fix_cost") VALUES ("0", "0", "0", "2010", "4", "0", "1234", "Opé 1", "0", "1");
|
||||||
INSERT INTO operation ("id", "user", "account", "year", "month", "day", "amount", "description", "category", "fix_cost") VALUES ("1", "0", "0", "2010", "0", "1", "5678", "Opé 2", "1", "0");
|
INSERT INTO operation ("id", "user", "account", "year", "month", "day", "amount", "description", "category", "fix_cost") VALUES ("1", "0", "0", "2010", "4", "1", "-56", "Opé 2", "1", "0");
|
||||||
|
INSERT INTO operation ("id", "user", "account", "year", "month", "day", "amount", "description", "category", "fix_cost") VALUES ("2", "0", "0", "2010", "4", "29", "-2056", "Opé 3", "2", "0");
|
||||||
INSERT INTO preference ("user", "type", "name", "value") VALUES ("0", "category", "name", "Fixe");
|
INSERT INTO preference ("user", "type", "name", "value") VALUES ("0", "category", "name", "Fixe");
|
||||||
INSERT INTO preference ("user", "type", "name", "value") VALUES ("0", "category", "name", "Courses");
|
INSERT INTO preference ("user", "type", "name", "value") VALUES ("0", "category", "name", "Courses");
|
||||||
INSERT INTO preference ("user", "type", "name", "value") VALUES ("0", "category", "name", "Loisirs");
|
INSERT INTO preference ("user", "type", "name", "value") VALUES ("0", "category", "name", "Loisirs");
|
||||||
|
|
|
@ -5,11 +5,13 @@ static wxString colsName[] = {_("Description"), _("Date"), _("Debit"), _("Credit
|
||||||
AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _kiss(kiss), _wxUI(parent), _tree(this, -1)
|
AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _kiss(kiss), _wxUI(parent), _tree(this, -1)
|
||||||
{
|
{
|
||||||
wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
|
wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
|
||||||
wxChartPanel* chart ;
|
wxChartPanel* chart ;
|
||||||
int i ;
|
int i ;
|
||||||
User* user = _kiss->GetUser();
|
User* user = _kiss->GetUser();
|
||||||
std::map<wxString, Account>::iterator accountIt;
|
std::map<wxString, Account>::iterator accountIt;
|
||||||
std::map<wxString, wxString>::iterator it;
|
std::map<wxString, wxString>::iterator it;
|
||||||
|
DEFAULT_FONT(font);
|
||||||
wxColour categoryColors[] = {wxColour(0x00, 0x45, 0x86),
|
wxColour categoryColors[] = {wxColour(0x00, 0x45, 0x86),
|
||||||
wxColour(0xFF, 0x3E, 0x0E),
|
wxColour(0xFF, 0x3E, 0x0E),
|
||||||
wxColour(0xFF, 0xD3, 0x20),
|
wxColour(0xFF, 0xD3, 0x20),
|
||||||
|
@ -49,7 +51,7 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)),
|
||||||
|
|
||||||
_categoriesValues = new double[user->GetCategoriesNumber()+1];
|
_categoriesValues = new double[user->GetCategoriesNumber()+1];
|
||||||
for(i=0; i<user->GetCategoriesNumber()+1; i++)
|
for(i=0; i<user->GetCategoriesNumber()+1; i++)
|
||||||
_categoriesValues[i] = 1.0;
|
_categoriesValues[i] = 0.0;
|
||||||
|
|
||||||
_dataset->AddSerie(_("Serie 1"), _categoriesValues, user->GetCategoriesNumber()+1);
|
_dataset->AddSerie(_("Serie 1"), _categoriesValues, user->GetCategoriesNumber()+1);
|
||||||
_dataset->SetRenderer(new CategoryRenderer(*colorScheme));
|
_dataset->SetRenderer(new CategoryRenderer(*colorScheme));
|
||||||
|
@ -62,15 +64,46 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)),
|
||||||
_grid->CreateGrid(1, NUMBER_COLS);
|
_grid->CreateGrid(1, NUMBER_COLS);
|
||||||
_grid->SetColLabelSize(0);
|
_grid->SetColLabelSize(0);
|
||||||
_grid->SetRowLabelSize(0);
|
_grid->SetRowLabelSize(0);
|
||||||
|
|
||||||
|
_statsGrid = new wxGrid(this, -1);
|
||||||
|
_statsGrid->CreateGrid(user->GetCategoriesNumber()+1+6, 2);
|
||||||
|
_statsGrid->SetColLabelSize(0);
|
||||||
|
_statsGrid->SetRowLabelSize(0);
|
||||||
|
_statsGrid->EnableEditing(false);
|
||||||
|
|
||||||
|
_statsGrid->SetDefaultCellFont(font);
|
||||||
|
|
||||||
|
_statsGrid->SetCellValue(TOTAL_CREDIT, 0, _("Total Credit"));
|
||||||
|
_statsGrid->SetCellValue(TOTAL_DEBIT, 0, _("Total Debit"));
|
||||||
|
|
||||||
|
_statsGrid->AutoSizeColumn(0, false);
|
||||||
|
|
||||||
|
for(i=0; i<user->GetCategoriesNumber()+1; i++)
|
||||||
|
_statsGrid->SetCellValue(CATS_STATS+i, 0, _categories[i]);
|
||||||
|
|
||||||
|
font.SetWeight(wxFONTWEIGHT_BOLD);
|
||||||
|
_statsGrid->SetCellFont(CUR_CREDIT, 0, font);
|
||||||
|
_statsGrid->SetCellFont(CUR_DEBIT, 0, font);
|
||||||
|
_statsGrid->SetCellFont(REMAINS, 0, font);
|
||||||
|
_statsGrid->SetCellFont(REMAINS, 1, font);
|
||||||
|
|
||||||
|
_statsGrid->SetCellValue(CUR_CREDIT, 0, _("Cur Credit"));
|
||||||
|
_statsGrid->SetCellValue(CUR_DEBIT, 0, _("Cur Debit"));
|
||||||
|
_statsGrid->SetCellValue(REMAINS, 0, _("Remains"));
|
||||||
|
|
||||||
chart = new wxChartPanel(this);
|
chart = new wxChartPanel(this);
|
||||||
chart->SetChart(new Chart(_pie, _("Cost repartition")));
|
chart->SetChart(new Chart(_pie, _("Cost repartition")));
|
||||||
chart->Fit();
|
chart->Fit();
|
||||||
chart->Layout();
|
chart->Layout();
|
||||||
chart->SetMinSize(// chart->GetSize()
|
chart->SetMinSize(// chart->GetSize()
|
||||||
wxSize(200,500));
|
wxSize(200,250));
|
||||||
hbox->Add(&_tree, 0);
|
hbox->Add(&_tree, 0);
|
||||||
hbox->Add(_grid, 0);
|
hbox->Add(_grid, 0);
|
||||||
hbox->Add(chart, 0);
|
vbox->Add(_statsGrid, 0);
|
||||||
|
vbox->Add(-1, 10);
|
||||||
|
vbox->Add(chart, 0);
|
||||||
|
hbox->Add(-1, 10);
|
||||||
|
hbox->Add(vbox, 0);
|
||||||
|
|
||||||
ChangeUser();
|
ChangeUser();
|
||||||
|
|
||||||
|
@ -158,7 +191,7 @@ void AccountPanel::ShowMonth(int year, int month)
|
||||||
int fixCosts = 0;
|
int fixCosts = 0;
|
||||||
int curLine = 0;
|
int curLine = 0;
|
||||||
User* user = _kiss->GetUser();
|
User* user = _kiss->GetUser();
|
||||||
wxFont font(DEFAULT_FONT_SIZE, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, DEFAULT_FONT);
|
DEFAULT_FONT(font);
|
||||||
std::map<wxString, wxString>::iterator categoryIt;
|
std::map<wxString, wxString>::iterator categoryIt;
|
||||||
wxGridCellChoiceEditor* categoryEditor, *accountEditor;
|
wxGridCellChoiceEditor* categoryEditor, *accountEditor;
|
||||||
int i;
|
int i;
|
||||||
|
@ -206,7 +239,7 @@ struct operation {
|
||||||
enum {DESCRIPTION, DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, VIEW, NUMBER_COLS};
|
enum {DESCRIPTION, DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, VIEW, NUMBER_COLS};
|
||||||
} ;
|
} ;
|
||||||
*/
|
*/
|
||||||
while (it->fix_cost)
|
for (;it->fix_cost && it != _curOperations->end(); it++)
|
||||||
{
|
{
|
||||||
_grid->AppendRows();
|
_grid->AppendRows();
|
||||||
curLine++;
|
curLine++;
|
||||||
|
@ -226,7 +259,6 @@ enum {DESCRIPTION, DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, VIEW, NUMBER_COLS};
|
||||||
accountEditor = new wxGridCellChoiceEditor(user->_accounts.size()+1, _accounts, false);
|
accountEditor = new wxGridCellChoiceEditor(user->_accounts.size()+1, _accounts, false);
|
||||||
_grid->SetCellEditor(curLine, ACCOUNT, accountEditor);
|
_grid->SetCellEditor(curLine, ACCOUNT, accountEditor);
|
||||||
_grid->SetCellValue(curLine, ACCOUNT, user->GetAccountName(it->account));
|
_grid->SetCellValue(curLine, ACCOUNT, user->GetAccountName(it->account));
|
||||||
it++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_grid->AppendRows();
|
_grid->AppendRows();
|
||||||
|
@ -241,7 +273,7 @@ enum {DESCRIPTION, DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, VIEW, NUMBER_COLS};
|
||||||
|
|
||||||
_grid->_fixCosts = ++fixCosts;
|
_grid->_fixCosts = ++fixCosts;
|
||||||
|
|
||||||
for (; it != _curOperations->begin(); it++)
|
for (; it != _curOperations->end(); it++)
|
||||||
{
|
{
|
||||||
_grid->AppendRows();
|
_grid->AppendRows();
|
||||||
curLine++;
|
curLine++;
|
||||||
|
@ -260,7 +292,6 @@ enum {DESCRIPTION, DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, VIEW, NUMBER_COLS};
|
||||||
accountEditor = new wxGridCellChoiceEditor(user->_accounts.size()+1, _accounts, false);
|
accountEditor = new wxGridCellChoiceEditor(user->_accounts.size()+1, _accounts, false);
|
||||||
_grid->SetCellEditor(curLine, ACCOUNT, accountEditor);
|
_grid->SetCellEditor(curLine, ACCOUNT, accountEditor);
|
||||||
_grid->SetCellValue(curLine, ACCOUNT, user->GetAccountName(it->account));
|
_grid->SetCellValue(curLine, ACCOUNT, user->GetAccountName(it->account));
|
||||||
it++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_grid->AppendRows();
|
_grid->AppendRows();
|
||||||
|
@ -276,31 +307,55 @@ enum {DESCRIPTION, DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, VIEW, NUMBER_COLS};
|
||||||
_grid->AutoSizeColumn(CATEGORY, false);
|
_grid->AutoSizeColumn(CATEGORY, false);
|
||||||
_grid->AutoSizeColumn(ACCOUNT, false);
|
_grid->AutoSizeColumn(ACCOUNT, false);
|
||||||
|
|
||||||
UpdateChart();
|
UpdateStats();
|
||||||
|
|
||||||
Fit();
|
Fit();
|
||||||
SetMinSize(GetSize());
|
SetMinSize(GetSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountPanel::UpdateChart()
|
void AccountPanel::UpdateStats()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
User* user = _kiss->GetUser();
|
User* user = _kiss->GetUser();
|
||||||
std::list<operation>::iterator it;
|
std::list<operation>::iterator it;
|
||||||
|
double curCredit, curDebit, totalCredit, totalDebit, remains;
|
||||||
|
wxDateTime curDate;
|
||||||
|
|
||||||
//_dataset->BeginUpdate();
|
curDate.SetToCurrent();
|
||||||
for (i=0; i<user->GetCategoriesNumber(); i++)
|
|
||||||
|
curCredit = curDebit = totalCredit = totalDebit = 0.0;
|
||||||
|
|
||||||
|
for (i=0; i<user->GetCategoriesNumber()+1; i++)
|
||||||
_categoriesValues[i] = 0.0;
|
_categoriesValues[i] = 0.0;
|
||||||
|
|
||||||
// _categoriesValues[0] += 1.0;
|
|
||||||
// _categoriesValues[1] += 2.0;
|
|
||||||
// _categoriesValues[2] += 3.0;
|
|
||||||
for (it=_curOperations->begin(); it!=_curOperations->end(); it++)
|
for (it=_curOperations->begin(); it!=_curOperations->end(); it++)
|
||||||
{
|
{
|
||||||
if (it->amount > 0)
|
if (it->amount > 0)
|
||||||
_categoriesValues[_categoriesIndexes[user->GetCategoryName(it->category)]] += it->amount ;
|
{
|
||||||
//std::cout << _categoriesValues[_categoriesIndexes[it->category]] << "\n";
|
if (curDate.GetDay() >= it->day && curDate.GetMonth() >= (int)it->month && curDate.GetYear() >= (int)it->year)
|
||||||
|
curCredit += it->amount;
|
||||||
|
totalCredit += it->amount;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_categoriesValues[_categoriesIndexes[user->GetCategoryName(it->category)]] += -it->amount ;
|
||||||
|
if (curDate.GetDay() >= it->day && curDate.GetMonth() >= (int)it->month && curDate.GetYear() >= (int)it->year)
|
||||||
|
curDebit += -it->amount;
|
||||||
|
totalDebit += -it->amount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//_dataset->EndUpdate();
|
|
||||||
|
remains = totalCredit - totalDebit;
|
||||||
|
_statsGrid->SetCellValue(CUR_CREDIT, 1, wxString::Format(wxT("%.2lf"), curCredit));
|
||||||
|
_statsGrid->SetCellValue(CUR_DEBIT, 1, wxString::Format(wxT("%.2lf"), curDebit));
|
||||||
|
_statsGrid->SetCellValue(TOTAL_CREDIT, 1, wxString::Format(wxT("%.2lf"), totalCredit));
|
||||||
|
_statsGrid->SetCellValue(TOTAL_DEBIT, 1, wxString::Format(wxT("%.2lf"), totalDebit));
|
||||||
|
|
||||||
|
_statsGrid->SetCellTextColour(REMAINS, 1, (remains >= 0) ? wxColor(0x00, 0xFF, 0x00) : wxColor(0xFF, 0x00, 0x00));
|
||||||
|
_statsGrid->SetCellValue(REMAINS, 1, wxString::Format(wxT("%.2lf"), remains));
|
||||||
|
|
||||||
|
for(i=0; i<user->GetCategoriesNumber()+1; i++)
|
||||||
|
_statsGrid->SetCellValue(CATS_STATS+i, 1, wxString::Format(wxT("%.2lf"), _categoriesValues[i]));
|
||||||
|
|
||||||
_pie->DatasetChanged(_dataset);
|
_pie->DatasetChanged(_dataset);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,12 @@
|
||||||
#define OWN_YELLOW wxColour(0xFF, 0xFF, 0x99)
|
#define OWN_YELLOW wxColour(0xFF, 0xFF, 0x99)
|
||||||
#define OWN_GREEN wxColour(0x3D, 0xEB, 0x3D)
|
#define OWN_GREEN wxColour(0x3D, 0xEB, 0x3D)
|
||||||
|
|
||||||
#define DEFAULT_FONT _("Liberation Sans")
|
#define DEFAULT_FONT_NAME _("Liberation Sans")
|
||||||
#define DEFAULT_FONT_SIZE 12
|
#define DEFAULT_FONT_SIZE 12
|
||||||
|
#define DEFAULT_FONT(font_name) wxFont font_name(DEFAULT_FONT_SIZE, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, DEFAULT_FONT_NAME);
|
||||||
|
|
||||||
enum {DESCRIPTION, DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, VIEW, NUMBER_COLS};
|
enum {DESCRIPTION, DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, VIEW, NUMBER_COLS};
|
||||||
|
enum {CUR_CREDIT, CUR_DEBIT, TOTAL_CREDIT, TOTAL_DEBIT, REMAINS, STATS_ROW, CATS_STATS};
|
||||||
|
|
||||||
#include <controller/KissCount.h>
|
#include <controller/KissCount.h>
|
||||||
#include "wxUI.h"
|
#include "wxUI.h"
|
||||||
|
@ -39,6 +41,7 @@ private:
|
||||||
wxUI* _wxUI;
|
wxUI* _wxUI;
|
||||||
wxTreeCtrl _tree;
|
wxTreeCtrl _tree;
|
||||||
GridAccount* _grid;
|
GridAccount* _grid;
|
||||||
|
wxGrid *_statsGrid;
|
||||||
PiePlot* _pie;
|
PiePlot* _pie;
|
||||||
double *_categoriesValues;
|
double *_categoriesValues;
|
||||||
std::map<wxString, int> _categoriesIndexes;
|
std::map<wxString, int> _categoriesIndexes;
|
||||||
|
@ -47,7 +50,7 @@ private:
|
||||||
wxString* _categories, *_accounts;
|
wxString* _categories, *_accounts;
|
||||||
CategorySimpleDataset* _dataset;
|
CategorySimpleDataset* _dataset;
|
||||||
|
|
||||||
void UpdateChart();
|
void UpdateStats();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user