From 5b5637f53a90aec2f67c3f958cc60f55556affec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Sat, 16 Oct 2010 21:16:03 +0200 Subject: [PATCH] * Update meta operation when a child is modified * Add (or discover) a bug --- TODO | 11 +++++- src/view/grid/GridAccount.cpp | 70 ++++++++++++++++++++++++++++++++++- 2 files changed, 78 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index 5357021..5878689 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,6 @@ Version 0.1 Statistics (need to add months/years label on graph) -Multiples operations into one (operation fusion) Auto completion (already up into wxwidgets 2.9) Using tabulation to navigate throw interface (Search Panel) Improve Scrolled Windows and widgets placement @@ -17,17 +16,25 @@ Database auto saving at startup Use caches for created panels (avoid destroying/creating panels for nothing) Add search function to web view + =============================================================== Next version More translations -Formulas Import/Export module Printing (maybe in html) Refactor web view code + =============================================================== Will not be implemented Copy and paste Undo/redo + + +=============================================================== +BUGS + +When we broke a transfert into a meta operation and re create it, +it's not taken in account by UpdateStats \ No newline at end of file diff --git a/src/view/grid/GridAccount.cpp b/src/view/grid/GridAccount.cpp index be1b53e..67fa197 100644 --- a/src/view/grid/GridAccount.cpp +++ b/src/view/grid/GridAccount.cpp @@ -344,7 +344,7 @@ void GridAccount::InsertOperation(User* user, Operation& op, int line, bool fix, } SET_ROW_COLOR(line, color, cat.forecolor); - if (cat.font.Length()) + if (op.category.Length() && cat.font.Length()) { font = user->GetCategoryFont(cat.id); SET_ROW_FONT(line, font); @@ -584,6 +584,9 @@ void GridAccount::OnOperationModified(wxGridEvent& event) wxGridCellTreeButtonRenderer* treeRenderer; std::vector::iterator it; Operation op, op2; + double amount; + wxFont font; + Category cat ; // Avoid recursives calls if (inModification) return; @@ -937,6 +940,71 @@ void GridAccount::OnOperationModified(wxGridEvent& event) if (need_insertion) InsertIntoGrid(new_op); + if (new_op.parent.Length()) + { + row = GetDisplayedRow(new_op.parent); + + new_op = _displayedOperations[row]; + + UpdateMeta(new_op); + + _displayedOperations[row] = new_op; + + cat = user->GetCategory(new_op.category); + + if (new_op.category.Length()) + color = cat.backcolor; + else + color = OWN_GREEN; + + if (new_op.checked) + { + r = ((color.Red()*1.5) >= 0xFF) ? 0xFF : color.Red()*1.5 ; + g = ((color.Green()*1.5) >= 0xFF) ? 0xFF : color.Green()*1.5 ; + b = ((color.Blue()*1.5) >= 0xFF) ? 0xFF : color.Blue()*1.5 ; + color.Set(r, g, b, color.Alpha()); + SetCellValue(row, CHECKED, wxT("1")); + } + else + SetCellValue(row, CHECKED, wxT("0")); + + + SET_ROW_COLOR(row, color, cat.forecolor); + + if (new_op.category.Length() && cat.font.Length()) + { + font = user->GetCategoryFont(cat.id); + SET_ROW_FONT(row, font); + } + + if (!_displayedOperations[row].amount) + { + amount = 0; + for(it=new_op.childs.begin(); it!=new_op.childs.end(); it++) + { + op2 = GetOperation(*it); + if (op2.amount > 0) + amount += op2.amount; + } + + SetCellValue(row, DEBIT, wxString::Format(wxT("%.2lf"), amount)); + SetCellValue(row, CREDIT, wxString::Format(wxT("%.2lf"), amount)); + } + else + { + if (_displayedOperations[row].amount < 0) + { + SetCellValue(row, DEBIT, wxString::Format(wxT("%.2lf"), -new_op.amount)); + SetCellValue(row, CREDIT, wxT("")); + } + else + { + SetCellValue(row, DEBIT, wxT("")); + SetCellValue(row, CREDIT, wxString::Format(wxT("%.2lf"), new_op.amount)); + } + } + } + inModification = false ; event.Skip();