From 39b24325d92b080ef69e4f18e7f5d03d398deafe Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Thu, 16 Aug 2018 11:22:44 +0100 Subject: [PATCH] Bug 796725 - 4 of 6 Date Posted options fail to return matching transactions. gnc_date_edit_get_date returns the time64 value set to 00:00:00 for the day entered so for the LTE and GT options gnc_date_edit_get_date_end needs to be used for 23:59:59. For finding transactions on the date, the use of QOF_DATE_MATCH_DAY needs to be used. --- gnucash/gnome-search/search-date.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/gnucash/gnome-search/search-date.c b/gnucash/gnome-search/search-date.c index 9523c3f25e..02d9573ecb 100644 --- a/gnucash/gnome-search/search-date.c +++ b/gnucash/gnome-search/search-date.c @@ -178,10 +178,23 @@ gncs_validate (GNCSearchCoreType *fe) return valid; } +static void +gnc_search_date_set_date_from_edit (GNCSearchDate *fe, GNCDateEdit *de) +{ + /* The gnc_date_edit_get_date function returns a value set to the + * start of the day 00:00:00, use gnc_date_edit_get_date_end to get + * value for day end 23:59:59 for LessThanEqual and GreaterThan */ + + if (fe->how == QOF_COMPARE_LTE || fe->how == QOF_COMPARE_GT) + fe->tt = gnc_date_edit_get_date_end (de); + else + fe->tt = gnc_date_edit_get_date (de); +} + static void date_changed (GNCDateEdit *date_edit, GNCSearchDate *fe) { - fe->tt = gnc_date_edit_get_date (date_edit); + gnc_search_date_set_date_from_edit (fe, date_edit); } static GtkWidget * @@ -272,9 +285,12 @@ static QofQueryPredData* gncs_get_predicate (GNCSearchCoreType *fe) /* Make sure we actually use the currently-entered date */ priv = _PRIVATE(fi); if (priv->entry) - fi->tt = gnc_date_edit_get_date (GNC_DATE_EDIT (priv->entry)); + gnc_search_date_set_date_from_edit (fi, GNC_DATE_EDIT (priv->entry)); - return qof_query_date_predicate (fi->how, QOF_DATE_MATCH_NORMAL, fi->tt); + if (fi->how == QOF_COMPARE_EQUAL || fi->how == QOF_COMPARE_NEQ) + return qof_query_date_predicate (fi->how, QOF_DATE_MATCH_DAY, fi->tt); + else + return qof_query_date_predicate (fi->how, QOF_DATE_MATCH_NORMAL, fi->tt); } static GNCSearchCoreType *gncs_clone(GNCSearchCoreType *fe)