|
|
|
@@ -21,7 +21,9 @@
|
|
|
|
|
|
|
|
|
|
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 {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)
|
|
|
|
|
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_SHOW(AccountPanel::OnShow)
|
|
|
|
|
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(UNGROUP_ID, AccountPanel::OnUnGroup)
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
@@ -119,7 +121,9 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, pare
|
|
|
|
|
chart->SetMinSize(// chart->GetSize()
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
@@ -138,7 +142,7 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, pare
|
|
|
|
|
hbox->Add(vbox2, 0, wxGROW|wxALL, 2);
|
|
|
|
|
vbox->Add(_statsGrid, 0, wxGROW);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
ChangeUser();
|
|
|
|
@@ -432,20 +436,22 @@ void AccountPanel::UpdateStats()
|
|
|
|
|
std::map<wxString, int>::iterator intIt;
|
|
|
|
|
std::vector<Account>::iterator accountIt;
|
|
|
|
|
unsigned int day;
|
|
|
|
|
bool checkMode = _checkCheckMode->IsChecked();
|
|
|
|
|
int mode;
|
|
|
|
|
std::map<wxString, double>* notChecked = NULL;
|
|
|
|
|
std::map<wxString, double>* virtuals = NULL;
|
|
|
|
|
Account account;
|
|
|
|
|
Operation op;
|
|
|
|
|
bool blocked_account ;
|
|
|
|
|
|
|
|
|
|
mode = _radioMode->GetSelection();
|
|
|
|
|
|
|
|
|
|
curCredit = curDebit = totalCredit = totalDebit = percents = 0.0;
|
|
|
|
|
|
|
|
|
|
if (checkMode)
|
|
|
|
|
{
|
|
|
|
|
if (mode == CHECK_MODE)
|
|
|
|
|
notChecked = _kiss->GetNotChecked(_curMonth, _curYear);
|
|
|
|
|
virtuals = _kiss->GetVirtualAmount(_curMonth, _curYear);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mode == REAL_MODE || mode == CHECK_MODE)
|
|
|
|
|
virtuals = _kiss->GetVirtualAmount(_curMonth, _curYear);
|
|
|
|
|
|
|
|
|
|
day = _calendar->GetDate().GetDay()-1;
|
|
|
|
|
|
|
|
|
@@ -457,7 +463,7 @@ void AccountPanel::UpdateStats()
|
|
|
|
|
curAccountAmount[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];
|
|
|
|
|
finalAccountAmount[doubleIt->first] += -(*virtuals)[doubleIt->first];
|
|
|
|
@@ -484,41 +490,119 @@ void AccountPanel::UpdateStats()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (op.amount >= 0)
|
|
|
|
|
|
|
|
|
|
switch(mode)
|
|
|
|
|
{
|
|
|
|
|
if (!op.transfert.Length() || (op._virtual && checkMode))
|
|
|
|
|
totalCredit += op.amount;
|
|
|
|
|
|
|
|
|
|
if (day >= op.day)
|
|
|
|
|
case VIRTUAL_MODE:
|
|
|
|
|
if (op.amount >= 0)
|
|
|
|
|
{
|
|
|
|
|
if (!op.transfert.Length() || (op._virtual && checkMode))
|
|
|
|
|
curCredit += op.amount;
|
|
|
|
|
if ((!checkMode || (checkMode && op.checked)) && !op._virtual)
|
|
|
|
|
curAccountAmount[op.account] += op.amount;
|
|
|
|
|
if (!op.transfert.Length())
|
|
|
|
|
totalCredit += op.amount;
|
|
|
|
|
|
|
|
|
|
if (day >= op.day)
|
|
|
|
|
{
|
|
|
|
|
if (!op.transfert.Length())
|
|
|
|
|
curCredit += op.amount;
|
|
|
|
|
curAccountAmount[op.account] += op.amount;
|
|
|
|
|
}
|
|
|
|
|
finalAccountAmount[op.account] += op.amount;
|
|
|
|
|
}
|
|
|
|
|
if ((!checkMode || (checkMode && 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)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!op.transfert.Length() || op._virtual)
|
|
|
|
|
curDebit += -op.amount;
|
|
|
|
|
if (!checkMode || (checkMode && op.checked && !op._virtual))
|
|
|
|
|
curAccountAmount[op.account] += op.amount;
|
|
|
|
|
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;
|
|
|
|
|
curAccountAmount[op.account] += op.amount;
|
|
|
|
|
}
|
|
|
|
|
finalAccountAmount[op.account] += op.amount;
|
|
|
|
|
}
|
|
|
|
|
if (!checkMode || (checkMode && op.checked && !op._virtual))
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -542,9 +626,11 @@ void AccountPanel::UpdateStats()
|
|
|
|
|
|
|
|
|
|
for (i=0, accountIt=user->_accounts.begin(); accountIt!=user->_accounts.end(); accountIt++, i++)
|
|
|
|
|
{
|
|
|
|
|
if (!checkMode || !notChecked)
|
|
|
|
|
if (mode != CHECK_MODE)
|
|
|
|
|
{
|
|
|
|
|
value = _accountsInitValues[accountIt->id];
|
|
|
|
|
if (mode == REAL_MODE)
|
|
|
|
|
value -= (*virtuals)[accountIt->id];
|
|
|
|
|
_accountsGrid->SetCellValue(i, ACCOUNT_INIT, wxString::Format(wxT("%.2lf"), value));
|
|
|
|
|
value = curAccountAmount[accountIt->id];
|
|
|
|
|
_accountsGrid->SetCellValue(i, ACCOUNT_CUR, wxString::Format(wxT("%.2lf"), value));
|
|
|
|
@@ -882,7 +968,7 @@ void AccountPanel::OnCalendarChange(wxCalendarEvent& event)
|
|
|
|
|
UpdateStats();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AccountPanel::OnCheckMode(wxCommandEvent& event)
|
|
|
|
|
void AccountPanel::OnModeChange(wxCommandEvent& event)
|
|
|
|
|
{
|
|
|
|
|
UpdateStats();
|
|
|
|
|
}
|
|
|
|
|