gnucash maint: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Sat Apr 25 17:47:27 EDT 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/63232f38 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/e0e7cf7d (commit)
	from  https://github.com/Gnucash/gnucash/commit/31daba15 (commit)



commit 63232f388f15e4a895bfa75e71c781e4cb96b696
Merge: 31daba151 e0e7cf7df
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Apr 25 14:40:57 2020 -0700

    Merge Jean Laroche's 'Fix-3-SX-Problems' into maint
    
    https://github.com/Gnucash/gnucash/pull/690


commit e0e7cf7dfb0d34ca8cbbb891474b614bca2fe081
Author: jean <you at example.com>
Date:   Mon Apr 13 14:02:03 2020 -0700

    Fix 3 problems with the scheduled transactions calculations
    
    This fixes 3 bugs:
    - Set a monthly recurrence on the 10th with a start date on the 20th of this month.
    The editor correctly shows the next occurrence to be on the 10th of the following month.
    The schedule transaction summary dialog incorrectly shows the next occurrence to be on the 10th of this month
    (before the start date!)
    - Set a monthly recurrence on the 19th, with a start date on the 20th of this month. The editor's
    calendar marks incorrectly show the next occurrence to be on the 19th of this month (before the start date).
    - Set a monthly recurrence on the 18th, with a start date on the 20th and an end date on the 17 of the following
    month. The calendar should show no mark, but fails to erase the marks that were present.

diff --git a/gnucash/gnome-utils/gnc-dense-cal.c b/gnucash/gnome-utils/gnc-dense-cal.c
index 9bd6a872d..ebef9f24d 100644
--- a/gnucash/gnome-utils/gnc-dense-cal.c
+++ b/gnucash/gnome-utils/gnc-dense-cal.c
@@ -1939,10 +1939,13 @@ gdc_model_added_cb(GncDenseCalModel *model, guint added_tag, gpointer user_data)
 static void
 gdc_model_update_cb(GncDenseCalModel *model, guint update_tag, gpointer user_data)
 {
-    GncDenseCal *cal = GNC_DENSE_CAL(user_data);
-    g_debug("gdc_model_update_cb update for tag [%d]\n", update_tag);
-    gdc_mark_remove(cal, update_tag, FALSE);
-    gdc_add_tag_markings(cal, update_tag);
+    GncDenseCal *cal = GNC_DENSE_CAL (user_data);
+    gint num_marks = 0;
+    g_debug ("gdc_model_update_cb update for tag [%d]\n", update_tag);
+    num_marks = gnc_dense_cal_model_get_instance_count (cal->model, update_tag);
+    // We need to redraw if there are no mark, to ensure they're all erased.
+    gdc_mark_remove (cal, update_tag, num_marks==0);
+    gdc_add_tag_markings (cal, update_tag);
 
 }
 
diff --git a/gnucash/gnome/dialog-sx-editor.c b/gnucash/gnome/dialog-sx-editor.c
index ff6704cae..acfca97d0 100644
--- a/gnucash/gnome/dialog-sx-editor.c
+++ b/gnucash/gnome/dialog-sx-editor.c
@@ -1598,7 +1598,6 @@ gnc_sxed_update_cal(GncSxEditorDialog *sxed)
     g_date_clear(&start_date, 1);
 
     gnc_frequency_save_to_recurrence(sxed->gncfreq, &recurrences, &start_date);
-    g_date_subtract_days(&start_date, 1);
     recurrenceListNextInstance(recurrences, &start_date, &first_date);
 
     /* Deal with the fact that this SX may have been run before [the
@@ -1609,10 +1608,10 @@ gnc_sxed_update_cal(GncSxEditorDialog *sxed)
         last_sx_inst = xaccSchedXactionGetLastOccurDate(sxed->sx);
         if (g_date_valid(last_sx_inst)
             && g_date_valid(&first_date)
-            && g_date_compare(last_sx_inst, &first_date) != 0)
+            && g_date_compare(last_sx_inst, &first_date) > 0)
         {
             /* last occurrence will be passed as initial date to update store
-             * later on as well */
+             * later on as well, but only if it's past first_date */
             start_date = *last_sx_inst;
             recurrenceListNextInstance(recurrences, &start_date, &first_date);
         }
diff --git a/gnucash/register/ledger-core/gnc-ledger-display2.c b/gnucash/register/ledger-core/gnc-ledger-display2.c
index 6df238c9b..cfedaec60 100644
--- a/gnucash/register/ledger-core/gnc-ledger-display2.c
+++ b/gnucash/register/ledger-core/gnc-ledger-display2.c
@@ -809,7 +809,6 @@ gnc_ledger_display2_internal (Account *lead_account, Query *q,
 
     ld->use_double_line_default = use_double_line;
 
-    // JEAN: add mismatched_commodities
     ld->model = gnc_tree_model_split_reg_new (reg_type, style, use_double_line, is_template, mismatched_commodities);
 
     gnc_tree_model_split_reg_set_data (ld->model, ld, gnc_ledger_display2_parent);
diff --git a/libgnucash/engine/SchedXaction.c b/libgnucash/engine/SchedXaction.c
index fc4ae0e9b..fac52bc9e 100644
--- a/libgnucash/engine/SchedXaction.c
+++ b/libgnucash/engine/SchedXaction.c
@@ -931,13 +931,13 @@ xaccSchedXactionGetNextInstance (const SchedXaction *sx, SXTmpStateData *tsd)
      * we're at the beginning. We want to pretend prev_occur is the day before
      * the start_date in case the start_date is today so that the SX will fire
      * today. If start_date isn't valid either then the SX will fire anyway, no
-     * harm done.
+     * harm done. prev_occur cannot be before start_date either.
      */
-    if (! g_date_valid( &prev_occur ) && g_date_valid(&sx->start_date))
+    if (g_date_valid (&sx->start_date) && (!g_date_valid ( &prev_occur ) || g_date_compare (&prev_occur, &sx->start_date)<0))
     {
         /* We must be at the beginning. */
         prev_occur = sx->start_date;
-        g_date_subtract_days( &prev_occur, 1 );
+        g_date_subtract_days (&prev_occur, 1 );
     }
 
     recurrenceListNextInstance(sx->schedule, &prev_occur, &next_occur);



Summary of changes:
 gnucash/gnome-utils/gnc-dense-cal.c                | 11 +++++++----
 gnucash/gnome/dialog-sx-editor.c                   |  5 ++---
 gnucash/register/ledger-core/gnc-ledger-display2.c |  1 -
 libgnucash/engine/SchedXaction.c                   |  6 +++---
 4 files changed, 12 insertions(+), 11 deletions(-)



More information about the gnucash-changes mailing list