This commit is contained in:
2010-06-03 18:28:38 +02:00
parent 33a4f206a8
commit aef7c2b61a
8 changed files with 204 additions and 15 deletions

View File

@@ -153,7 +153,7 @@ void AccountPanel::ChangeUser()
{
User* user = _kiss->GetUser();
int curYear = -1;
std::map<unsigned int, std::map<unsigned int, std::list<operation> >* >::iterator it;
std::map<unsigned int, std::map<unsigned int, std::vector<operation> >* >::iterator it;
wxDateTime curDate;
curDate.SetToCurrent();
@@ -172,7 +172,7 @@ void AccountPanel::LoadYear(int year)
{
User* user = _kiss->GetUser();
int curMonth = -1;
std::map<unsigned int, std::list<operation> >::iterator it;
std::map<unsigned int, std::vector<operation> >::iterator it;
wxDateTime curDate;
wxTreeItemId parentNode, curMonthNode;
@@ -217,8 +217,8 @@ void AccountPanel::LoadYear(int year)
void AccountPanel::ShowMonth(int year, int month)
{
std::list<operation> operations;
std::list<operation>::iterator it;
std::vector<operation> operations;
std::vector<operation>::iterator it;
_fixCosts = 0;
int curLine = 0;
User* user = _kiss->GetUser();
@@ -385,7 +385,7 @@ void AccountPanel::UpdateStats()
{
int i;
User* user = _kiss->GetUser();
std::list<operation>::iterator it;
std::vector<operation>::iterator it;
double curCredit, curDebit, totalCredit, totalDebit, remains, value;
wxDateTime curDate;
std::map<wxString, double> curAccountAmount, finalAccountAmount;
@@ -459,27 +459,108 @@ void AccountPanel::OnOperationModified(wxGridEvent& event)
{
User* user = _kiss->GetUser();
int row = event.GetRow()-1;
struct operation new_op, cur_op;
int op_complete = 5;
wxString value ;
wxDateTime date;
bool need_insertion = false;
if (event.GetCol() == DEBIT)
_grid->SetCellValue(event.GetRow(), CREDIT, _(""));
else if (event.GetCol() == CREDIT)
_grid->SetCellValue(event.GetRow(), DEBIT, _(""));
value = _grid->GetCellValue(event.GetRow(), DESCRIPTION);
if (value != _(""))
{
new_op.description = value;
op_complete--;
}
value = _grid->GetCellValue(event.GetRow(), DATE);
if (value != _(""))
{
date.ParseFormat(value, _("%d/%m/%Y"));
new_op.day = date.GetDay()-1;
new_op.month = date.GetMonth();
new_op.year = date.GetYear();
op_complete--;
}
value = _grid->GetCellValue(event.GetRow(), DEBIT);
if (value != _(""))
{
value.ToDouble(&new_op.amount);
new_op.amount *= -1.0;
op_complete--;
}
value = _grid->GetCellValue(event.GetRow(), CREDIT);
if (value != _(""))
{
value.ToDouble(&new_op.amount);
op_complete--;
}
value = _grid->GetCellValue(event.GetRow(), CATEGORY);
if (value != _(""))
{
new_op.category = user->GetCategoryId(value);
op_complete--;
}
value = _grid->GetCellValue(event.GetRow(), ACCOUNT);
if (value != _(""))
{
new_op.account = user->GetAccountId(value);
op_complete--;
}
// Modify a fix operation
if (row < _fixCosts)
{
std::cout << "Fix modified\n";
cur_op = (*_curOperations)[row] ;
new_op.id = cur_op.id;
if (cur_op.day != new_op.day)
{
need_insertion = true;
_grid->DeleteRows(row, 1);
_curOperations->erase(_curOperations->begin()+row);
}
else
(*_curOperations)[row] = new_op;
_kiss->UpdateOperation(new_op);
}
// Add a fixCost
else if (row == _fixCosts)
{
std::cout << "Fix added\n";
if (op_complete) return ;
need_insertion = true;
}
// Modify an operation
else if (row <= user->GetOperationsNumber(_curMonth, _curYear))
{
row--;
std::cout << "Op modified\n";
row--;
cur_op = (*_curOperations)[row] ;
new_op.id = cur_op.id;
if (cur_op.day != new_op.day)
{
need_insertion = true;
_grid->DeleteRows(row+1, 1);
_curOperations->erase(_curOperations->begin()+row);
}
else
(*_curOperations)[row] = new_op;
_kiss->UpdateOperation(new_op);
}
// Add an operation
else
{
row--;
std::cout << "Op added\n";
if (op_complete) return ;
need_insertion = true;
}
UpdateStats();
}

View File

@@ -50,7 +50,7 @@ private:
PiePlot* _pie;
double *_categoriesValues;
std::map<wxString, int> _categoriesIndexes, _accountsIndexes;
std::list<operation>* _curOperations;
std::vector<operation>* _curOperations;
int _curMonth, _curYear;
wxString* _categories, *_accounts;
std::map<wxString, double> _accountsInitValues;