First pass for imports (with OFX imports)

This commit is contained in:
2011-03-20 19:08:24 +01:00
parent d2f23fd6a0
commit 6da33cbe35
17 changed files with 992 additions and 48 deletions
+29 -22
View File
@@ -39,8 +39,6 @@ BEGIN_EVENT_TABLE(GridAccount, wxGrid)
EVT_GRID_CELL_LEFT_CLICK(GridAccount::OnCellLeftClick )
END_EVENT_TABLE()
enum {TREE, DESCRIPTION, OP_DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, OP_DELETE, CHECKED, NUMBER_COLS_OPS};
enum {GRID_ID};
GridAccount::GridAccount(KissCount* kiss, wxWindow *parent, wxWindowID id,
@@ -201,9 +199,11 @@ void GridAccount::LoadOperations(std::vector<Operation>* operations, int month,
_displayedOperations.clear();
_displayedOperations.push_back(NULLop); // Header
_fixCosts = 0;
it = _operations->begin();
if (GetNumberRows () > 1)
DeleteRows(1, GetNumberRows ()-1);
if (_canAddOperation)
{
for (;it != _operations->end() && it->fix_cost; it++)
@@ -331,7 +331,13 @@ void GridAccount::InsertOperation(User* user, Operation& op, int line, bool fix,
SetCellEditor(line, CREDIT, new wxGridCellFloatEditor(wxID_ANY, 2));
wxGridCellChoiceEditor* accountEditor = new wxGridCellChoiceEditor(user->GetAccountsNumber(), _accounts, false);
SetCellEditor(line, ACCOUNT, accountEditor);
wxGridCellChoiceEditor* categoryEditor = new wxGridCellChoiceEditor(user->GetCategoriesNumber()-1, _categories+1, false);
wxGridCellChoiceEditor* categoryEditor ;
if (_canAddOperation)
categoryEditor = new wxGridCellChoiceEditor(user->GetCategoriesNumber()-1, _categories+1, false);
else
categoryEditor = new wxGridCellChoiceEditor(user->GetCategoriesNumber(), _categories, false);
SetCellEditor(line, CATEGORY, categoryEditor);
if (fix)
@@ -669,7 +675,7 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
Category cat ;
// Avoid recursives calls
if (inModification) return;
if (inModification || _loadOperations) return;
inModification = true ;
@@ -722,6 +728,23 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
op_complete--;
}
if (col == DESCRIPTION &&
(!GetCellValue(row, CATEGORY).Length() ||
!GetCellValue(row, ACCOUNT).Length() ||
!_canAddOperation))
{
if (_kiss->SearchPreviousOperation(&op_tmp, new_op, new_op.month, new_op.year, _canAddOperation))
{
new_op.category = op_tmp.category;
new_op.account = op_tmp.account;
SetCellValue(row, CATEGORY, wxGetTranslation(user->GetCategoryName(new_op.category)));
SetCellValue(row, ACCOUNT, user->GetAccountName(new_op.account));
op_complete -= 2;
col = CATEGORY;
new_op.fix_cost = (new_op.category == user->GetCategoryId(wxT("Fix")));
}
}
value = GetCellValue(row, DEBIT);
if (value.Length())
{
@@ -753,7 +776,6 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
pEditor->DecRef();
}
value = GetCellValue(row, CATEGORY);
if (value.Length())
{
@@ -775,21 +797,6 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
new_op.checked = false;
op_complete--;
if (col == DESCRIPTION &&
(!GetCellValue(row, CATEGORY).Length() ||
!GetCellValue(row, ACCOUNT).Length()))
{
new_op.fix_cost = row <= _fixCosts;
if (_kiss->SearchPreviousOperation(&op_tmp, new_op, _curMonth, _curYear))
{
new_op.category = op_tmp.category;
new_op.account = op_tmp.account;
SetCellValue(row, CATEGORY, wxGetTranslation(user->GetCategoryName(new_op.category)));
SetCellValue(row, ACCOUNT, user->GetAccountName(new_op.account));
op_complete -= 2;
}
}
cur_op = (_displayedOperations)[row] ;
if (col == CHECKED || col == CATEGORY)
@@ -1539,7 +1546,7 @@ void GridAccount::MassUpdate(std::vector<int>& rows, updateOperationFunc func, v
}
}
DeleteRows(1, GetNumberRows()-1);
ClearGrid();
LoadOperations(_operations, 0, 0);
+2
View File
@@ -36,6 +36,8 @@
class KissCount;
enum {TREE, DESCRIPTION, OP_DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, OP_DELETE, CHECKED, NUMBER_COLS_OPS};
typedef void (*updateOperationFunc)(Operation* op, void** params);
class GridAccount : public wxGrid