* Update meta operation when a child is modified

* Add (or discover) a bug
This commit is contained in:
Grégory Soutadé 2010-10-16 21:16:03 +02:00
parent f2dcfcb356
commit 5b5637f53a
2 changed files with 78 additions and 3 deletions

11
TODO
View File

@ -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

View File

@ -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<wxString>::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();