Fix a looooooooot of bugs
This commit is contained in:
parent
a6218ac1cc
commit
cedb13c3ec
|
@ -31,7 +31,7 @@ msgstr " - "
|
||||||
#: src/view/PreferencesPanel.cpp:679
|
#: src/view/PreferencesPanel.cpp:679
|
||||||
#: src/view/PreferencesPanel.cpp:725
|
#: src/view/PreferencesPanel.cpp:725
|
||||||
msgid " already exists"
|
msgid " already exists"
|
||||||
msgstr " existe déjà "
|
msgstr " existe déjà "
|
||||||
|
|
||||||
#: src/view/SearchPanel.cpp:222
|
#: src/view/SearchPanel.cpp:222
|
||||||
msgid " entries found"
|
msgid " entries found"
|
||||||
|
|
|
@ -161,6 +161,14 @@ wxString KissCount::AddAccount(Account& ac)
|
||||||
return ac.id;
|
return ac.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool sortAccounts(Account ac1, Account ac2)
|
||||||
|
{
|
||||||
|
if (ac1._default) return true;
|
||||||
|
if (ac2._default) return false;
|
||||||
|
|
||||||
|
return (ac1.name.Cmp(ac2.name) < 0);
|
||||||
|
}
|
||||||
|
|
||||||
void KissCount::UpdateAccount(Account& ac)
|
void KissCount::UpdateAccount(Account& ac)
|
||||||
{
|
{
|
||||||
std::vector<Account>::iterator it;
|
std::vector<Account>::iterator it;
|
||||||
|
@ -170,6 +178,9 @@ void KissCount::UpdateAccount(Account& ac)
|
||||||
for (i=0, it=_user->_accounts.begin(); it !=_user->_accounts.end(); it++, i++)
|
for (i=0, it=_user->_accounts.begin(); it !=_user->_accounts.end(); it++, i++)
|
||||||
if (it->id == ac.id)
|
if (it->id == ac.id)
|
||||||
_user->_accounts[i] = ac;
|
_user->_accounts[i] = ac;
|
||||||
|
|
||||||
|
if (ac._default)
|
||||||
|
std::sort(_user->_accounts.begin(), _user->_accounts.end(), sortAccounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KissCount::DeleteAccount(Account& ac)
|
void KissCount::DeleteAccount(Account& ac)
|
||||||
|
@ -389,7 +400,7 @@ std::vector<Operation>* KissCount::Search(wxString* description, wxDateTime* dat
|
||||||
return _db->Search(_user, description, dateFrom, dateTo, amountFrom, amountTo, categories, Fix, accounts, true);
|
return _db->Search(_user, description, dateFrom, dateTo, amountFrom, amountTo, categories, Fix, accounts, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KissCount::SearchPreviousOperation(Operation* res, wxString& description, int month, int year)
|
bool KissCount::SearchPreviousOperation(Operation* res, Operation& op, int month, int year)
|
||||||
{
|
{
|
||||||
std::vector<Operation>* operations;
|
std::vector<Operation>* operations;
|
||||||
wxDateTime* date ;
|
wxDateTime* date ;
|
||||||
|
@ -405,7 +416,7 @@ bool KissCount::SearchPreviousOperation(Operation* res, wxString& description, i
|
||||||
|
|
||||||
date = new wxDateTime(0, (wxDateTime::Month)month, year);
|
date = new wxDateTime(0, (wxDateTime::Month)month, year);
|
||||||
|
|
||||||
operations = _db->Search(_user, &description, date, NULL, NULL, NULL, v, BOTH, v, false);
|
operations = _db->Search(_user, &op.description, date, NULL, NULL, NULL, v, op.fix_cost ? FIX_OP : NON_FIX_OP, v, false);
|
||||||
|
|
||||||
delete date;
|
delete date;
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ public:
|
||||||
wxString* amountFrom, wxString* amountTo,
|
wxString* amountFrom, wxString* amountTo,
|
||||||
std::vector<wxString> categories, int Fix, std::vector<wxString> accounts);
|
std::vector<wxString> categories, int Fix, std::vector<wxString> accounts);
|
||||||
|
|
||||||
bool SearchPreviousOperation(Operation* res, wxString& description, int month, int year);
|
bool SearchPreviousOperation(Operation* res, Operation& op, int month, int year);
|
||||||
|
|
||||||
void GetStats(int monthFrom, int yearFrom, int monthTo, int yearTo,
|
void GetStats(int monthFrom, int yearFrom, int monthTo, int yearTo,
|
||||||
std::map<wxString, std::map<int, std::map<int, double> > >* accountAmounts,
|
std::map<wxString, std::map<int, std::map<int, double> > >* accountAmounts,
|
||||||
|
|
|
@ -51,7 +51,7 @@ Category User::GetCategory(wxString& catId)
|
||||||
cat.parent = wxT("0");
|
cat.parent = wxT("0");
|
||||||
cat.name = _("Unknown");
|
cat.name = _("Unknown");
|
||||||
cat.font = wxT("");
|
cat.font = wxT("");
|
||||||
cat.backcolor = wxColour(0xFF, 0xFF, 0xFF);
|
cat.backcolor = OWN_GREEN;
|
||||||
cat.forecolor = wxColour(0x00, 0x00, 0x00);
|
cat.forecolor = wxColour(0x00, 0x00, 0x00);
|
||||||
|
|
||||||
return cat;
|
return cat;
|
||||||
|
|
|
@ -42,7 +42,7 @@ END_EVENT_TABLE()
|
||||||
enum {GRID_ID};
|
enum {GRID_ID};
|
||||||
GridAccount::GridAccount(KissCount* kiss, wxWindow *parent, wxWindowID id) : wxGrid(parent, id), _fixCosts(0), _week1(0),
|
GridAccount::GridAccount(KissCount* kiss, wxWindow *parent, wxWindowID id) : wxGrid(parent, id), _fixCosts(0), _week1(0),
|
||||||
_week2(0), _week3(0), _week4(0), _kiss(kiss),
|
_week2(0), _week3(0), _week4(0), _kiss(kiss),
|
||||||
_curMonth(0), _curYear(0)
|
_loadOperations(false), _curMonth(0), _curYear(0)
|
||||||
{
|
{
|
||||||
wxBitmap deleteBitmap(wxT(DELETE_ICON));
|
wxBitmap deleteBitmap(wxT(DELETE_ICON));
|
||||||
wxBitmap checkedBitmap(wxT(CHECKED_ICON));
|
wxBitmap checkedBitmap(wxT(CHECKED_ICON));
|
||||||
|
@ -173,6 +173,7 @@ void GridAccount::LoadOperations(std::vector<Operation>* operations, bool canAdd
|
||||||
|
|
||||||
NULLop.id = wxT("");
|
NULLop.id = wxT("");
|
||||||
|
|
||||||
|
_loadOperations = true;
|
||||||
_operations = operations;
|
_operations = operations;
|
||||||
_canAddOperation = canAddOperation;
|
_canAddOperation = canAddOperation;
|
||||||
_curMonth = month;
|
_curMonth = month;
|
||||||
|
@ -215,41 +216,46 @@ void GridAccount::LoadOperations(std::vector<Operation>* operations, bool canAdd
|
||||||
AutoSizeColumn(ACCOUNT, false);
|
AutoSizeColumn(ACCOUNT, false);
|
||||||
AutoSizeColumn(DELETE, false);
|
AutoSizeColumn(DELETE, false);
|
||||||
AutoSizeColumn(CHECKED, false);
|
AutoSizeColumn(CHECKED, false);
|
||||||
|
|
||||||
|
_loadOperations = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GridAccount::InsertOperationWithWeek(User* user, Operation& op, int line, bool fix, int month, int year)
|
void GridAccount::ComputeWeeks()
|
||||||
{
|
{
|
||||||
std::vector<Operation>::iterator it;
|
std::vector<Operation>::iterator it;
|
||||||
int curLine, curWeek, week, i;
|
int curLine, curWeek, week, i;
|
||||||
|
|
||||||
|
for (it = _displayedOperations.begin(), curLine=0;
|
||||||
|
it != _displayedOperations.end();
|
||||||
|
it++, curLine++)
|
||||||
|
{
|
||||||
|
if (it->id.Length() && !it->fix_cost) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (it == _displayedOperations.end()) return;
|
||||||
|
|
||||||
|
ResetWeeks();
|
||||||
|
|
||||||
|
curWeek = wxDateTime(it->day+1, (wxDateTime::Month)it->month, it->year).GetWeekOfMonth();
|
||||||
|
it++;
|
||||||
|
for (i=1; it != _displayedOperations.end(); it++, curLine++)
|
||||||
|
{
|
||||||
|
if (!it->id.Length()) continue;
|
||||||
|
week = wxDateTime(it->day+1, (wxDateTime::Month)it->month, it->year).GetWeekOfMonth();
|
||||||
|
if (week != curWeek)
|
||||||
|
{
|
||||||
|
SetWeek(i++, curLine);
|
||||||
|
curWeek = week;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GridAccount::InsertOperationWithWeek(User* user, Operation& op, int line, bool fix, int month, int year)
|
||||||
|
{
|
||||||
InsertOperation(user, op, line, fix, month, year);
|
InsertOperation(user, op, line, fix, month, year);
|
||||||
|
|
||||||
if (op.id.Length() && !fix)
|
if (op.id.Length() && !fix)
|
||||||
{
|
ComputeWeeks();
|
||||||
for (it = _displayedOperations.begin(), curLine=0;
|
|
||||||
it != _displayedOperations.end();
|
|
||||||
it++, curLine++)
|
|
||||||
{
|
|
||||||
if (it->id.Length() && !it->fix_cost) break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (it == _displayedOperations.end()) return;
|
|
||||||
|
|
||||||
ResetWeeks();
|
|
||||||
|
|
||||||
curWeek = wxDateTime(it->day+1, (wxDateTime::Month)it->month, it->year).GetWeekOfMonth();
|
|
||||||
it++;
|
|
||||||
for (i=1; it != _displayedOperations.end(); it++, curLine++)
|
|
||||||
{
|
|
||||||
if (!it->id.Length()) continue;
|
|
||||||
week = wxDateTime(it->day+1, (wxDateTime::Month)it->month, it->year).GetWeekOfMonth();
|
|
||||||
if (week != curWeek)
|
|
||||||
{
|
|
||||||
SetWeek(i++, curLine);
|
|
||||||
curWeek = week;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GridAccount::InsertOperation(User* user, Operation& op, int line, bool fix, int month, int year)
|
void GridAccount::InsertOperation(User* user, Operation& op, int line, bool fix, int month, int year)
|
||||||
|
@ -358,15 +364,23 @@ void GridAccount::InsertOperation(User* user, Operation& op, int line, bool fix,
|
||||||
SetCellValue(line, DEBIT, wxString::Format(wxT("%.2lf"), amount));
|
SetCellValue(line, DEBIT, wxString::Format(wxT("%.2lf"), amount));
|
||||||
SetCellValue(line, CREDIT, wxString::Format(wxT("%.2lf"), amount));
|
SetCellValue(line, CREDIT, wxString::Format(wxT("%.2lf"), amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_loadOperations)
|
||||||
|
{
|
||||||
|
if (op.meta)
|
||||||
|
AutoSizeColumn(TREE, false);
|
||||||
|
AutoSizeColumn(CATEGORY, false);
|
||||||
|
AutoSizeColumn(ACCOUNT, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetCellEditor(line, DATE, new CalendarEditor(0, month, year));
|
SetCellEditor(line, DATE, new CalendarEditor(0, month, year));
|
||||||
if (!fix &&
|
if (curDate.GetMonth() == month &&
|
||||||
curDate.GetMonth() == month &&
|
|
||||||
curDate.GetYear() == year)
|
curDate.GetYear() == year)
|
||||||
{
|
{
|
||||||
SetCellValue(line, DATE, wxString::Format(wxT("%02d/%02d/%d"), curDate.GetDay(), month+1, year));
|
if (!fix)
|
||||||
|
SetCellValue(line, DATE, wxString::Format(wxT("%02d/%02d/%d"), curDate.GetDay(), month+1, year));
|
||||||
SetCellEditor(line, DATE, new CalendarEditor(curDate.GetDay()-1, month, year));
|
SetCellEditor(line, DATE, new CalendarEditor(curDate.GetDay()-1, month, year));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -444,31 +458,36 @@ void GridAccount::InsertIntoGrid(Operation& op)
|
||||||
int i, a;
|
int i, a;
|
||||||
User* user = _kiss->GetUser();
|
User* user = _kiss->GetUser();
|
||||||
|
|
||||||
for(i=0; i<(int)_displayedOperations.size(); i++)
|
// No previous fix operations
|
||||||
|
if (op.fix_cost && !_displayedOperations[1].id.Length())
|
||||||
|
i = 1;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (!_displayedOperations[i].id.Length()) continue;
|
for(i=0; i<(int)_displayedOperations.size(); i++)
|
||||||
if (_displayedOperations[i].parent.Length()) continue;
|
|
||||||
if ((_displayedOperations)[i].fix_cost && !op.fix_cost) continue;
|
|
||||||
if (!(_displayedOperations)[i].fix_cost && op.fix_cost) break;
|
|
||||||
if (user->_preferences[wxT("operation_order")] == wxT("ASC"))
|
|
||||||
{
|
{
|
||||||
if ((_displayedOperations)[i].day > op.day)
|
if (!_displayedOperations[i].id.Length()) continue;
|
||||||
break;
|
if (_displayedOperations[i].parent.Length()) continue;
|
||||||
|
if ((_displayedOperations)[i].fix_cost && !op.fix_cost) continue;
|
||||||
|
if (!(_displayedOperations)[i].fix_cost && op.fix_cost) break;
|
||||||
|
if (user->_preferences[wxT("operation_order")] == wxT("ASC"))
|
||||||
|
{
|
||||||
|
if ((_displayedOperations)[i].day > op.day)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((_displayedOperations)[i].day < op.day)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
if (i == (int)_displayedOperations.size() ||
|
||||||
else
|
i == _fixCosts)
|
||||||
{
|
i--;
|
||||||
if ((_displayedOperations)[i].day < op.day)
|
else if (!(_displayedOperations)[i].fix_cost && op.fix_cost)
|
||||||
break;
|
i --;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == (int)_displayedOperations.size() ||
|
|
||||||
i == _fixCosts)
|
|
||||||
i--;
|
|
||||||
else if (!(_displayedOperations)[i].fix_cost && op.fix_cost)
|
|
||||||
i --;
|
|
||||||
|
|
||||||
for (a=0; a<(int)_operations->size(); a++)
|
for (a=0; a<(int)_operations->size(); a++)
|
||||||
{
|
{
|
||||||
if ((*_operations)[a].fix_cost && !op.fix_cost) continue;
|
if ((*_operations)[a].fix_cost && !op.fix_cost) continue;
|
||||||
|
@ -484,6 +503,7 @@ void GridAccount::InsertIntoGrid(Operation& op)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (a < 0) a = 0;
|
||||||
_operations->insert(_operations->begin()+a, op);
|
_operations->insert(_operations->begin()+a, op);
|
||||||
|
|
||||||
InsertOperationWithWeek(user, (*_operations)[a], i, op.fix_cost, _curMonth, _curYear);
|
InsertOperationWithWeek(user, (*_operations)[a], i, op.fix_cost, _curMonth, _curYear);
|
||||||
|
@ -583,7 +603,7 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
||||||
User* user = _kiss->GetUser();
|
User* user = _kiss->GetUser();
|
||||||
int row = event.GetRow();
|
int row = event.GetRow();
|
||||||
int col = event.GetCol();
|
int col = event.GetCol();
|
||||||
Operation new_op, cur_op, op_tmp;
|
Operation new_op, cur_op, op_tmp, op_tmp2;
|
||||||
int op_complete = 6, i;
|
int op_complete = 6, i;
|
||||||
wxString value ;
|
wxString value ;
|
||||||
wxDateTime date;
|
wxDateTime date;
|
||||||
|
@ -614,7 +634,7 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
||||||
for (i=1, it=op.childs.begin(); it!=op.childs.end(); it++, i++)
|
for (i=1, it=op.childs.begin(); it!=op.childs.end(); it++, i++)
|
||||||
{
|
{
|
||||||
op2 = GetOperation(*it);
|
op2 = GetOperation(*it);
|
||||||
InsertOperation(user, op2, row+i, op2.fix_cost, _curMonth, _curYear);
|
InsertOperationWithWeek(user, op2, row+i, op2.fix_cost, _curMonth, _curYear);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -696,7 +716,8 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
||||||
(!GetCellValue(row, CATEGORY).Length() ||
|
(!GetCellValue(row, CATEGORY).Length() ||
|
||||||
!GetCellValue(row, ACCOUNT).Length()))
|
!GetCellValue(row, ACCOUNT).Length()))
|
||||||
{
|
{
|
||||||
if (_kiss->SearchPreviousOperation(&op_tmp, new_op.description, _curMonth, _curYear))
|
new_op.fix_cost = row <= _fixCosts;
|
||||||
|
if (_kiss->SearchPreviousOperation(&op_tmp, new_op, _curMonth, _curYear))
|
||||||
{
|
{
|
||||||
new_op.category = op_tmp.category;
|
new_op.category = op_tmp.category;
|
||||||
new_op.account = op_tmp.account;
|
new_op.account = op_tmp.account;
|
||||||
|
@ -752,6 +773,7 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
||||||
SET_ROW_COLOR(row2, color, user->GetCategory(op2.category).forecolor);
|
SET_ROW_COLOR(row2, color, user->GetCategory(op2.category).forecolor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
event.Skip();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -795,16 +817,26 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
||||||
_kiss->DeleteOperation(cur_op);
|
_kiss->DeleteOperation(cur_op);
|
||||||
_displayedOperations.erase(_displayedOperations.begin()+row);
|
_displayedOperations.erase(_displayedOperations.begin()+row);
|
||||||
|
|
||||||
if (cur_op.parent.Length() && op_tmp.childs.size() <= 1)
|
if (cur_op.parent.Length() && op_tmp.childs.size() < 2)
|
||||||
{
|
{
|
||||||
|
if (op_tmp.childs.size() == 1)
|
||||||
|
{
|
||||||
|
op_tmp2 = GetOperation(op_tmp.childs[0]);
|
||||||
|
op_tmp2.parent = wxT("");
|
||||||
|
UpdateOperation(op_tmp2);
|
||||||
|
row = GetDisplayedRow(op_tmp2.id);
|
||||||
|
_displayedOperations[row] = op_tmp2;
|
||||||
|
}
|
||||||
row = GetDisplayedRow(cur_op.parent);
|
row = GetDisplayedRow(cur_op.parent);
|
||||||
DeleteRows(row, 1);
|
DeleteRows(row, 1);
|
||||||
DeleteOperation(op_tmp);
|
DeleteOperation(op_tmp);
|
||||||
_kiss->DeleteOperation(op_tmp);
|
_kiss->DeleteOperation(op_tmp);
|
||||||
_displayedOperations.erase(_displayedOperations.begin()+row);
|
_displayedOperations.erase(_displayedOperations.begin()+row);
|
||||||
|
_fixCosts--;
|
||||||
}
|
}
|
||||||
|
_fixCosts--;
|
||||||
|
ComputeWeeks();
|
||||||
}
|
}
|
||||||
_fixCosts = _fixCosts--;
|
|
||||||
inModification = false ;
|
inModification = false ;
|
||||||
event.Skip();
|
event.Skip();
|
||||||
return ;
|
return ;
|
||||||
|
@ -896,12 +928,22 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
||||||
|
|
||||||
if (cur_op.parent.Length() && op_tmp.childs.size() <= 1)
|
if (cur_op.parent.Length() && op_tmp.childs.size() <= 1)
|
||||||
{
|
{
|
||||||
|
if (op_tmp.childs.size() == 1)
|
||||||
|
{
|
||||||
|
op_tmp2 = GetOperation(op_tmp.childs[0]);
|
||||||
|
op_tmp2.parent = wxT("");
|
||||||
|
UpdateOperation(op_tmp2);
|
||||||
|
row = GetDisplayedRow(op_tmp2.id);
|
||||||
|
_displayedOperations[row] = op_tmp2;
|
||||||
|
}
|
||||||
row = GetDisplayedRow(cur_op.parent);
|
row = GetDisplayedRow(cur_op.parent);
|
||||||
DeleteRows(row, 1);
|
DeleteRows(row, 1);
|
||||||
DeleteOperation(op_tmp);
|
DeleteOperation(op_tmp);
|
||||||
_kiss->DeleteOperation(op_tmp);
|
_kiss->DeleteOperation(op_tmp);
|
||||||
_displayedOperations.erase(_displayedOperations.begin()+row);
|
_displayedOperations.erase(_displayedOperations.begin()+row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ComputeWeeks();
|
||||||
}
|
}
|
||||||
inModification = false ;
|
inModification = false ;
|
||||||
event.Skip();
|
event.Skip();
|
||||||
|
@ -1354,4 +1396,6 @@ removeLastGroup:
|
||||||
|
|
||||||
UpdateOperation(op2);
|
UpdateOperation(op2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ComputeWeeks();
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,11 +64,13 @@ private:
|
||||||
KissCount* _kiss;
|
KissCount* _kiss;
|
||||||
wxString* _categories, *_accounts;
|
wxString* _categories, *_accounts;
|
||||||
std::vector<Operation>* _operations;
|
std::vector<Operation>* _operations;
|
||||||
bool _canAddOperation;
|
bool _canAddOperation, _loadOperations;
|
||||||
int _curMonth, _curYear;
|
int _curMonth, _curYear;
|
||||||
|
|
||||||
void SetWeek(int week, int line);
|
void SetWeek(int week, int line);
|
||||||
void ResetWeeks();
|
void ResetWeeks();
|
||||||
|
void ComputeWeeks();
|
||||||
|
|
||||||
void InsertIntoGrid(Operation& op);
|
void InsertIntoGrid(Operation& op);
|
||||||
void DeleteOperation(const Operation& op);
|
void DeleteOperation(const Operation& op);
|
||||||
void UpdateMeta(Operation& op);
|
void UpdateMeta(Operation& op);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user