Add Real mode
This commit is contained in:
parent
4cb57641d8
commit
8792ac2a8e
|
@ -1,4 +1,4 @@
|
||||||
v0.2_dev (15/02/2011)
|
v0.2_dev (19/02/2011)
|
||||||
|
|
||||||
** User **
|
** User **
|
||||||
Better use of sizers (so better interface!)
|
Better use of sizers (so better interface!)
|
||||||
|
@ -11,6 +11,7 @@ v0.2_dev (15/02/2011)
|
||||||
Add virtual accounts
|
Add virtual accounts
|
||||||
Searchs aren't case sensitive enough
|
Searchs aren't case sensitive enough
|
||||||
Default categories in native language (even if switching language at runtime)
|
Default categories in native language (even if switching language at runtime)
|
||||||
|
Add Real mode
|
||||||
|
|
||||||
** Dev **
|
** Dev **
|
||||||
Use a factory to create panels (prepare for plug-in)
|
Use a factory to create panels (prepare for plug-in)
|
||||||
|
|
2
TODO
2
TODO
|
@ -6,6 +6,8 @@ Using tabulation to navigate throw interface (Search Panel)
|
||||||
Can type a letter with a comboboxes
|
Can type a letter with a comboboxes
|
||||||
Windows version
|
Windows version
|
||||||
Need packaging (.deb)
|
Need packaging (.deb)
|
||||||
|
Real mode
|
||||||
|
Choosing accounts & categories position
|
||||||
|
|
||||||
Cool for 0.2:
|
Cool for 0.2:
|
||||||
Database auto saving at startup
|
Database auto saving at startup
|
||||||
|
|
|
@ -21,7 +21,9 @@
|
||||||
|
|
||||||
enum {ACCOUNT_NUMBER, ACCOUNT_NAME, ACCOUNT_INIT, ACCOUNT_CUR, ACCOUNT_FINAL, NUMBER_COLS_ACCOUNTS};
|
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};
|
||||||
enum {CALENDAR_TREE_ID=1, OPS_GRID_ID, CALENDAR_ID, ACCOUNTS_GRID_ID, MENU_GENERATE_ID, MENU_DELETE_ID, CHECK_MODE_ID, GROUP_ID, UNGROUP_ID};
|
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};
|
||||||
|
|
||||||
|
enum {VIRTUAL_MODE=0, REAL_MODE, CHECK_MODE};
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(AccountPanel, wxPanel)
|
BEGIN_EVENT_TABLE(AccountPanel, wxPanel)
|
||||||
EVT_GRID_CMD_CELL_CHANGE(OPS_GRID_ID, AccountPanel::OnOperationModified)
|
EVT_GRID_CMD_CELL_CHANGE(OPS_GRID_ID, AccountPanel::OnOperationModified)
|
||||||
|
@ -33,7 +35,7 @@ EVT_MENU(MENU_GENERATE_ID, AccountPanel::OnMenuGenerate)
|
||||||
EVT_MENU(MENU_DELETE_ID, AccountPanel::OnMenuDelete)
|
EVT_MENU(MENU_DELETE_ID, AccountPanel::OnMenuDelete)
|
||||||
EVT_SHOW(AccountPanel::OnShow)
|
EVT_SHOW(AccountPanel::OnShow)
|
||||||
EVT_CALENDAR_SEL_CHANGED(CALENDAR_ID, AccountPanel::OnCalendarChange)
|
EVT_CALENDAR_SEL_CHANGED(CALENDAR_ID, AccountPanel::OnCalendarChange)
|
||||||
EVT_CHECKBOX(CHECK_MODE_ID, AccountPanel::OnCheckMode)
|
EVT_RADIOBOX(DISPLAY_MODE_ID, AccountPanel::OnModeChange)
|
||||||
EVT_BUTTON(GROUP_ID, AccountPanel::OnGroup)
|
EVT_BUTTON(GROUP_ID, AccountPanel::OnGroup)
|
||||||
EVT_BUTTON(UNGROUP_ID, AccountPanel::OnUnGroup)
|
EVT_BUTTON(UNGROUP_ID, AccountPanel::OnUnGroup)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
@ -119,7 +121,9 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, pare
|
||||||
chart->SetMinSize(// chart->GetSize()
|
chart->SetMinSize(// chart->GetSize()
|
||||||
wxSize(200,250));
|
wxSize(200,250));
|
||||||
|
|
||||||
_checkCheckMode = new wxCheckBox(this, CHECK_MODE_ID, _("Check mode"));
|
wxString modes[3] = {_("Virtual"), _("Real"), _("Check")};
|
||||||
|
_radioMode = new wxRadioBox(this, DISPLAY_MODE_ID, _("Mode"), wxDefaultPosition, wxDefaultSize,
|
||||||
|
3, modes);
|
||||||
|
|
||||||
_tree.SetIndent(5);
|
_tree.SetIndent(5);
|
||||||
|
|
||||||
|
@ -138,7 +142,7 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, pare
|
||||||
hbox->Add(vbox2, 0, wxGROW|wxALL, 2);
|
hbox->Add(vbox2, 0, wxGROW|wxALL, 2);
|
||||||
vbox->Add(_statsGrid, 0, wxGROW);
|
vbox->Add(_statsGrid, 0, wxGROW);
|
||||||
vbox->Add(chart, 0, wxALIGN_CENTER_HORIZONTAL|wxUP, 10);
|
vbox->Add(chart, 0, wxALIGN_CENTER_HORIZONTAL|wxUP, 10);
|
||||||
vbox->Add(_checkCheckMode, 0, wxALIGN_CENTER_HORIZONTAL|wxUP, 10);
|
vbox->Add(_radioMode, 0, wxALIGN_CENTER_HORIZONTAL|wxUP, 10);
|
||||||
hbox->Add(vbox, 0, wxGROW|wxALL, 2);
|
hbox->Add(vbox, 0, wxGROW|wxALL, 2);
|
||||||
|
|
||||||
ChangeUser();
|
ChangeUser();
|
||||||
|
@ -432,20 +436,22 @@ void AccountPanel::UpdateStats()
|
||||||
std::map<wxString, int>::iterator intIt;
|
std::map<wxString, int>::iterator intIt;
|
||||||
std::vector<Account>::iterator accountIt;
|
std::vector<Account>::iterator accountIt;
|
||||||
unsigned int day;
|
unsigned int day;
|
||||||
bool checkMode = _checkCheckMode->IsChecked();
|
int mode;
|
||||||
std::map<wxString, double>* notChecked = NULL;
|
std::map<wxString, double>* notChecked = NULL;
|
||||||
std::map<wxString, double>* virtuals = NULL;
|
std::map<wxString, double>* virtuals = NULL;
|
||||||
Account account;
|
Account account;
|
||||||
Operation op;
|
Operation op;
|
||||||
bool blocked_account ;
|
bool blocked_account ;
|
||||||
|
|
||||||
|
mode = _radioMode->GetSelection();
|
||||||
|
|
||||||
curCredit = curDebit = totalCredit = totalDebit = percents = 0.0;
|
curCredit = curDebit = totalCredit = totalDebit = percents = 0.0;
|
||||||
|
|
||||||
if (checkMode)
|
if (mode == CHECK_MODE)
|
||||||
{
|
|
||||||
notChecked = _kiss->GetNotChecked(_curMonth, _curYear);
|
notChecked = _kiss->GetNotChecked(_curMonth, _curYear);
|
||||||
|
|
||||||
|
if (mode == REAL_MODE || mode == CHECK_MODE)
|
||||||
virtuals = _kiss->GetVirtualAmount(_curMonth, _curYear);
|
virtuals = _kiss->GetVirtualAmount(_curMonth, _curYear);
|
||||||
}
|
|
||||||
|
|
||||||
day = _calendar->GetDate().GetDay()-1;
|
day = _calendar->GetDate().GetDay()-1;
|
||||||
|
|
||||||
|
@ -457,7 +463,7 @@ void AccountPanel::UpdateStats()
|
||||||
curAccountAmount[doubleIt->first] = _accountsInitValues[doubleIt->first];
|
curAccountAmount[doubleIt->first] = _accountsInitValues[doubleIt->first];
|
||||||
finalAccountAmount[doubleIt->first] = _accountsInitValues[doubleIt->first];
|
finalAccountAmount[doubleIt->first] = _accountsInitValues[doubleIt->first];
|
||||||
|
|
||||||
if (virtuals)
|
if (mode == REAL_MODE || mode == CHECK_MODE)
|
||||||
{
|
{
|
||||||
curAccountAmount[doubleIt->first] += -(*virtuals)[doubleIt->first];
|
curAccountAmount[doubleIt->first] += -(*virtuals)[doubleIt->first];
|
||||||
finalAccountAmount[doubleIt->first] += -(*virtuals)[doubleIt->first];
|
finalAccountAmount[doubleIt->first] += -(*virtuals)[doubleIt->first];
|
||||||
|
@ -484,19 +490,21 @@ void AccountPanel::UpdateStats()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
switch(mode)
|
||||||
|
{
|
||||||
|
case VIRTUAL_MODE:
|
||||||
if (op.amount >= 0)
|
if (op.amount >= 0)
|
||||||
{
|
{
|
||||||
if (!op.transfert.Length() || (op._virtual && checkMode))
|
if (!op.transfert.Length())
|
||||||
totalCredit += op.amount;
|
totalCredit += op.amount;
|
||||||
|
|
||||||
if (day >= op.day)
|
if (day >= op.day)
|
||||||
{
|
{
|
||||||
if (!op.transfert.Length() || (op._virtual && checkMode))
|
if (!op.transfert.Length())
|
||||||
curCredit += op.amount;
|
curCredit += op.amount;
|
||||||
if ((!checkMode || (checkMode && op.checked)) && !op._virtual)
|
|
||||||
curAccountAmount[op.account] += op.amount;
|
curAccountAmount[op.account] += op.amount;
|
||||||
}
|
}
|
||||||
if ((!checkMode || (checkMode && op.checked)) && !op._virtual)
|
|
||||||
finalAccountAmount[op.account] += op.amount;
|
finalAccountAmount[op.account] += op.amount;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -514,12 +522,88 @@ void AccountPanel::UpdateStats()
|
||||||
{
|
{
|
||||||
if (!op.transfert.Length() || op._virtual)
|
if (!op.transfert.Length() || op._virtual)
|
||||||
curDebit += -op.amount;
|
curDebit += -op.amount;
|
||||||
if (!checkMode || (checkMode && op.checked && !op._virtual))
|
|
||||||
curAccountAmount[op.account] += op.amount;
|
curAccountAmount[op.account] += op.amount;
|
||||||
}
|
}
|
||||||
if (!checkMode || (checkMode && op.checked && !op._virtual))
|
|
||||||
finalAccountAmount[op.account] += op.amount;
|
finalAccountAmount[op.account] += op.amount;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case REAL_MODE:
|
||||||
|
if (op.amount >= 0)
|
||||||
|
{
|
||||||
|
if (!op.transfert.Length())
|
||||||
|
totalCredit += op.amount;
|
||||||
|
|
||||||
|
if (day >= op.day)
|
||||||
|
{
|
||||||
|
if (!op.transfert.Length())
|
||||||
|
curCredit += op.amount;
|
||||||
|
if (!op._virtual)
|
||||||
|
curAccountAmount[op.account] += op.amount;
|
||||||
|
}
|
||||||
|
if (!op._virtual)
|
||||||
|
finalAccountAmount[op.account] += op.amount;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!op.transfert.Length())
|
||||||
|
_categoriesValues[_categoriesIndexes[user->GetCategoryName(op.category)]] += -op.amount ;
|
||||||
|
|
||||||
|
if (!op.transfert.Length() && !op._virtual)
|
||||||
|
totalDebit += -op.amount;
|
||||||
|
|
||||||
|
if (blocked_account)
|
||||||
|
op.amount = -op.amount;
|
||||||
|
|
||||||
|
if (day >= op.day)
|
||||||
|
{
|
||||||
|
if (!op.transfert.Length() && !op._virtual)
|
||||||
|
curDebit += -op.amount;
|
||||||
|
if (!op._virtual)
|
||||||
|
curAccountAmount[op.account] += op.amount;
|
||||||
|
}
|
||||||
|
if (!op._virtual)
|
||||||
|
finalAccountAmount[op.account] += op.amount;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CHECK_MODE:
|
||||||
|
if (op.amount >= 0)
|
||||||
|
{
|
||||||
|
if (!op.transfert.Length() && !op._virtual)
|
||||||
|
totalCredit += op.amount;
|
||||||
|
|
||||||
|
if (day >= op.day)
|
||||||
|
{
|
||||||
|
if (!op.transfert.Length() && !op._virtual)
|
||||||
|
curCredit += op.amount;
|
||||||
|
if (op.checked && !op._virtual)
|
||||||
|
curAccountAmount[op.account] += op.amount;
|
||||||
|
}
|
||||||
|
if (op.checked && !op._virtual)
|
||||||
|
finalAccountAmount[op.account] += op.amount;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!op.transfert.Length())
|
||||||
|
_categoriesValues[_categoriesIndexes[user->GetCategoryName(op.category)]] += -op.amount ;
|
||||||
|
|
||||||
|
if (!op.transfert.Length() && !op._virtual)
|
||||||
|
totalDebit += -op.amount;
|
||||||
|
|
||||||
|
if (blocked_account)
|
||||||
|
op.amount = -op.amount;
|
||||||
|
|
||||||
|
if (day >= op.day)
|
||||||
|
{
|
||||||
|
if (!op.transfert.Length() && !op._virtual)
|
||||||
|
curDebit += -op.amount;
|
||||||
|
if (op.checked && !op._virtual)
|
||||||
|
curAccountAmount[op.account] += op.amount;
|
||||||
|
}
|
||||||
|
if (op.checked && !op._virtual)
|
||||||
|
finalAccountAmount[op.account] += op.amount;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
remains = totalCredit - totalDebit;
|
remains = totalCredit - totalDebit;
|
||||||
|
@ -542,9 +626,11 @@ void AccountPanel::UpdateStats()
|
||||||
|
|
||||||
for (i=0, accountIt=user->_accounts.begin(); accountIt!=user->_accounts.end(); accountIt++, i++)
|
for (i=0, accountIt=user->_accounts.begin(); accountIt!=user->_accounts.end(); accountIt++, i++)
|
||||||
{
|
{
|
||||||
if (!checkMode || !notChecked)
|
if (mode != CHECK_MODE)
|
||||||
{
|
{
|
||||||
value = _accountsInitValues[accountIt->id];
|
value = _accountsInitValues[accountIt->id];
|
||||||
|
if (mode == REAL_MODE)
|
||||||
|
value -= (*virtuals)[accountIt->id];
|
||||||
_accountsGrid->SetCellValue(i, ACCOUNT_INIT, wxString::Format(wxT("%.2lf"), value));
|
_accountsGrid->SetCellValue(i, ACCOUNT_INIT, wxString::Format(wxT("%.2lf"), value));
|
||||||
value = curAccountAmount[accountIt->id];
|
value = curAccountAmount[accountIt->id];
|
||||||
_accountsGrid->SetCellValue(i, ACCOUNT_CUR, wxString::Format(wxT("%.2lf"), value));
|
_accountsGrid->SetCellValue(i, ACCOUNT_CUR, wxString::Format(wxT("%.2lf"), value));
|
||||||
|
@ -882,7 +968,7 @@ void AccountPanel::OnCalendarChange(wxCalendarEvent& event)
|
||||||
UpdateStats();
|
UpdateStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountPanel::OnCheckMode(wxCommandEvent& event)
|
void AccountPanel::OnModeChange(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
UpdateStats();
|
UpdateStats();
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <wx/treectrl.h>
|
#include <wx/treectrl.h>
|
||||||
#include <wx/pie/pieplot.h>
|
#include <wx/pie/pieplot.h>
|
||||||
#include <wx/chartpanel.h>
|
#include <wx/chartpanel.h>
|
||||||
|
#include <wx/radiobox.h>
|
||||||
#include "grid/CalendarEditor.h"
|
#include "grid/CalendarEditor.h"
|
||||||
#include "grid/wxGridCellBitmapRenderer.h"
|
#include "grid/wxGridCellBitmapRenderer.h"
|
||||||
|
|
||||||
|
@ -58,7 +59,7 @@ public:
|
||||||
void OnMenuGenerate(wxCommandEvent& event);
|
void OnMenuGenerate(wxCommandEvent& event);
|
||||||
void OnMenuDelete(wxCommandEvent& event);
|
void OnMenuDelete(wxCommandEvent& event);
|
||||||
void OnCalendarChange(wxCalendarEvent& event);
|
void OnCalendarChange(wxCalendarEvent& event);
|
||||||
void OnCheckMode(wxCommandEvent& event);
|
void OnModeChange(wxCommandEvent& event);
|
||||||
void OnGroup(wxCommandEvent& event);
|
void OnGroup(wxCommandEvent& event);
|
||||||
void OnUnGroup(wxCommandEvent& event);
|
void OnUnGroup(wxCommandEvent& event);
|
||||||
|
|
||||||
|
@ -71,7 +72,7 @@ private:
|
||||||
wxGrid *_statsGrid, *_accountsGrid;
|
wxGrid *_statsGrid, *_accountsGrid;
|
||||||
PiePlot* _pie;
|
PiePlot* _pie;
|
||||||
double *_categoriesValues;
|
double *_categoriesValues;
|
||||||
wxCheckBox *_checkCheckMode;
|
wxRadioBox *_radioMode;
|
||||||
std::map<wxString, int> _categoriesIndexes;
|
std::map<wxString, int> _categoriesIndexes;
|
||||||
std::vector<Operation>* _curOperations;
|
std::vector<Operation>* _curOperations;
|
||||||
wxString* _categories, *_accounts;
|
wxString* _categories, *_accounts;
|
||||||
|
|
|
@ -774,7 +774,7 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
||||||
{
|
{
|
||||||
new_op.category = op_tmp.category;
|
new_op.category = op_tmp.category;
|
||||||
new_op.account = op_tmp.account;
|
new_op.account = op_tmp.account;
|
||||||
SetCellValue(row, CATEGORY, user->GetCategoryName(new_op.category));
|
SetCellValue(row, CATEGORY, wxGetTranslation(user->GetCategoryName(new_op.category)));
|
||||||
SetCellValue(row, ACCOUNT, user->GetAccountName(new_op.account));
|
SetCellValue(row, ACCOUNT, user->GetAccountName(new_op.account));
|
||||||
op_complete -= 2;
|
op_complete -= 2;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user