From 7e41063b427dea30c8f5ed03171020b00d0b674a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Mon, 26 Jul 2010 21:03:22 +0200 Subject: [PATCH] Fix a bug in search (absolute amounts) and remove automatic dating for new fix operation --- src/model/Database.cpp | 8 ++++---- src/view/GridAccount.cpp | 8 +++++--- src/view/SearchPanel.cpp | 4 ++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/model/Database.cpp b/src/model/Database.cpp index 7a0ffe5..c7777ab 100644 --- a/src/model/Database.cpp +++ b/src/model/Database.cpp @@ -953,13 +953,13 @@ std::vector* Database::Search(User* user, wxString* description, wxDa if (amountFrom) { if (firstCond) req += wxT(" AND ") ; else firstCond = true; - req += wxT("amount >= '") + *amountFrom + wxT("'"); + req += wxT("ABS(amount) >= ") + *amountFrom; } if (amountTo) { if (firstCond) req += wxT(" AND ") ; else firstCond = true; - req += wxT("amount <= '") + *amountTo + wxT("'"); + req += wxT("ABS(amount) <= ") + *amountTo; } if (categories.size()) @@ -1025,13 +1025,13 @@ std::vector* Database::Search(User* user, wxString* description, wxDa if (dateFrom && (int)op.year == dateFrom->GetYear() && - (int)op.month < dateFrom->GetMonth() && + (int)op.month <= dateFrom->GetMonth() && (int)op.day < dateFrom->GetDay()-1) continue; if (dateTo && (int)op.year == dateTo->GetYear() && - (int)op.month > dateTo->GetMonth() && + (int)op.month >= dateTo->GetMonth() && (int)op.day > dateTo->GetDay()-1) continue; diff --git a/src/view/GridAccount.cpp b/src/view/GridAccount.cpp index 471bd97..078c901 100644 --- a/src/view/GridAccount.cpp +++ b/src/view/GridAccount.cpp @@ -160,7 +160,8 @@ void GridAccount::InsertOperation(User* user, Operation* op, int line, bool fix, else { SetCellEditor(line, DATE, new CalendarEditor(0, curMonth, curYear)); - if (curDate.GetMonth() == curMonth && + if (!fix && + curDate.GetMonth() == curMonth && curDate.GetYear() == curYear) { SetCellValue(line, DATE, wxString::Format(wxT("%02d/%02d/%d"), curDate.GetDay(), curMonth+1, curYear)); @@ -171,8 +172,9 @@ void GridAccount::InsertOperation(User* user, Operation* op, int line, bool fix, if (fix) SET_ROW_COLOR(line, OWN_YELLOW) - else - SET_ROW_COLOR(line, OWN_GREEN); + else + SET_ROW_COLOR(line, OWN_GREEN); + SetReadOnly(line, CHECKED, true); SetReadOnly(line, DELETE, true); } diff --git a/src/view/SearchPanel.cpp b/src/view/SearchPanel.cpp index 5f5b752..5590068 100644 --- a/src/view/SearchPanel.cpp +++ b/src/view/SearchPanel.cpp @@ -139,6 +139,8 @@ void SearchPanel::OnButtonSearch(wxCommandEvent& event) delete amountFrom; return; } + + if (af < 0) af *= -1; } if (_amountTo->GetLineText(0) != wxT("")) @@ -152,6 +154,8 @@ void SearchPanel::OnButtonSearch(wxCommandEvent& event) delete amountTo; return; } + + if (at < 0) at *= -1; } if (amountFrom && amountTo && af > at)