gnucash maint: Multiple changes pushed

Robert Fewell bobit at code.gnucash.org
Fri May 17 06:12:39 EDT 2019


Updated	 via  https://github.com/Gnucash/gnucash/commit/416b79d3 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/037f5ed5 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/5ad3cd0d (commit)
	 via  https://github.com/Gnucash/gnucash/commit/fade13f8 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/36574f08 (commit)
	from  https://github.com/Gnucash/gnucash/commit/e3fb593e (commit)



commit 416b79d304f5efc8fdbffa393205e9a5eaccc461
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Fri May 17 10:56:56 2019 +0100

    Reformat source files gnc-accounting-period.*
    
    Change tabs to white space and some other white space changes.

diff --git a/libgnucash/app-utils/gnc-accounting-period.c b/libgnucash/app-utils/gnc-accounting-period.c
index 2c50aebbf..bdeb06610 100644
--- a/libgnucash/app-utils/gnc-accounting-period.c
+++ b/libgnucash/app-utils/gnc-accounting-period.c
@@ -50,14 +50,14 @@
 #include "gnc-ui-util.h"
 
 static time64 gnc_accounting_period_start_time64 (GncAccountingPeriod which,
-						   const GDate *fy_end,
-						   const GDate *contains);
+                                                  const GDate *fy_end,
+                                                  const GDate *contains);
 static time64 gnc_accounting_period_end_time64 (GncAccountingPeriod which,
-						 const GDate *fy_end,
-						 const GDate *contains);
+                                                const GDate *fy_end,
+                                                const GDate *contains);
 
 static time64
-lookup_start_date_option(GDate *fy_end)
+lookup_start_date_option (GDate *fy_end)
 {
     time64 time;
     int which;
@@ -67,8 +67,8 @@ lookup_start_date_option(GDate *fy_end)
                                         (GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_START_DATE));
     else
     {
-        which = gnc_prefs_get_int(GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_START_PERIOD);
-        time = gnc_accounting_period_start_time64(which, fy_end, NULL);
+        which = gnc_prefs_get_int (GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_START_PERIOD);
+        time = gnc_accounting_period_start_time64 (which, fy_end, NULL);
     }
     /* we will need the balance of the last transaction before the start
        date, so subtract 1 from start date */
@@ -78,7 +78,7 @@ lookup_start_date_option(GDate *fy_end)
 }
 
 static time64
-lookup_end_date_option(GDate *fy_end)
+lookup_end_date_option (GDate *fy_end)
 {
     time64 time;
     int which;
@@ -88,8 +88,8 @@ lookup_end_date_option(GDate *fy_end)
                                       (GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_END_DATE));
     else
     {
-        which = gnc_prefs_get_int(GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_END_PERIOD);
-        time = gnc_accounting_period_end_time64(which, fy_end, NULL);
+        which = gnc_prefs_get_int (GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_END_PERIOD);
+        time = gnc_accounting_period_end_time64 (which, fy_end, NULL);
     }
     if (time == 0)
         time = -1;
@@ -97,38 +97,36 @@ lookup_end_date_option(GDate *fy_end)
 }
 
 static GDate *
-get_fy_end(void)
+get_fy_end (void)
 {
     QofBook *book;
     GDate *date = NULL;
 
     book = gnc_get_current_book();
-    qof_instance_get (QOF_INSTANCE (book),
-		      "fy-end", &date,
-		      NULL);
+    qof_instance_get (QOF_INSTANCE (book), "fy-end", &date, NULL);
     return date;
 }
 
 time64
-gnc_accounting_period_fiscal_start(void)
+gnc_accounting_period_fiscal_start (void)
 {
     time64 t;
     GDate *fy_end = get_fy_end();
-    t = lookup_start_date_option(fy_end);
+    t = lookup_start_date_option (fy_end);
     if (fy_end)
-        g_date_free(fy_end);
+        g_date_free (fy_end);
     return t;
 }
 
 time64
-gnc_accounting_period_fiscal_end(void)
+gnc_accounting_period_fiscal_end (void)
 {
     time64 t;
     GDate *fy_end = get_fy_end();
 
-    t = lookup_end_date_option(fy_end);
+    t = lookup_end_date_option (fy_end);
     if (fy_end)
-        g_date_free(fy_end);
+        g_date_free (fy_end);
     return t;
 }
 
@@ -141,9 +139,9 @@ gnc_accounting_period_start_gdate (GncAccountingPeriod which,
 
     if (contains)
     {
-        date = g_date_new_dmy(g_date_get_day(contains),
-                              g_date_get_month(contains),
-                              g_date_get_year(contains));
+        date = g_date_new_dmy (g_date_get_day (contains),
+                               g_date_get_month (contains),
+                               g_date_get_year (contains));
     }
     else
     {
@@ -154,8 +152,8 @@ gnc_accounting_period_start_gdate (GncAccountingPeriod which,
     switch (which)
     {
     default:
-        g_message("Undefined relative time constant %d", which);
-        g_date_free(date);
+        g_message ("Undefined relative time constant %d", which);
+        g_date_free (date);
         return NULL;
 
     case GNC_ACCOUNTING_PERIOD_TODAY:
@@ -163,47 +161,47 @@ gnc_accounting_period_start_gdate (GncAccountingPeriod which,
         break;
 
     case GNC_ACCOUNTING_PERIOD_MONTH:
-        gnc_gdate_set_month_start(date);
+        gnc_gdate_set_month_start (date);
         break;
 
     case GNC_ACCOUNTING_PERIOD_MONTH_PREV:
-        gnc_gdate_set_prev_month_start(date);
+        gnc_gdate_set_prev_month_start (date);
         break;
 
     case GNC_ACCOUNTING_PERIOD_QUARTER:
-        gnc_gdate_set_quarter_start(date);
+        gnc_gdate_set_quarter_start (date);
         break;
 
     case GNC_ACCOUNTING_PERIOD_QUARTER_PREV:
-        gnc_gdate_set_prev_quarter_start(date);
+        gnc_gdate_set_prev_quarter_start (date);
         break;
 
     case GNC_ACCOUNTING_PERIOD_CYEAR:
-        gnc_gdate_set_year_start(date);
+        gnc_gdate_set_year_start (date);
         break;
 
     case GNC_ACCOUNTING_PERIOD_CYEAR_PREV:
-        gnc_gdate_set_prev_year_start(date);
+        gnc_gdate_set_prev_year_start (date);
         break;
 
     case GNC_ACCOUNTING_PERIOD_FYEAR:
         if (fy_end == NULL)
         {
-            g_message("Request for fisal year value but no fiscal year end value provided.");
-            g_date_free(date);
+            g_message ("Request for fisal year value but no fiscal year end value provided.");
+            g_date_free (date);
             return NULL;
         }
-        gnc_gdate_set_fiscal_year_start(date, fy_end);
+        gnc_gdate_set_fiscal_year_start (date, fy_end);
         break;
 
     case GNC_ACCOUNTING_PERIOD_FYEAR_PREV:
         if (fy_end == NULL)
         {
-            g_message("Request for fisal year value but no fiscal year end value provided.");
-            g_date_free(date);
+            g_message ("Request for fisal year value but no fiscal year end value provided.");
+            g_date_free (date);
             return NULL;
         }
-        gnc_gdate_set_prev_fiscal_year_start(date, fy_end);
+        gnc_gdate_set_prev_fiscal_year_start (date, fy_end);
         break;
     }
     return date;
@@ -211,18 +209,18 @@ gnc_accounting_period_start_gdate (GncAccountingPeriod which,
 
 static time64
 gnc_accounting_period_start_time64 (GncAccountingPeriod which,
-                                   const GDate *fy_end,
-                                   const GDate *contains)
+                                    const GDate *fy_end,
+                                    const GDate *contains)
 {
     GDate *date;
     time64 secs;
 
-    date = gnc_accounting_period_start_gdate(which, fy_end, contains);
+    date = gnc_accounting_period_start_gdate (which, fy_end, contains);
     if (!date)
         return 0;
 
-    secs = gnc_time64_get_day_start_gdate(date);
-    g_date_free(date);
+    secs = gnc_time64_get_day_start_gdate (date);
+    g_date_free (date);
     return secs;
 }
 
@@ -235,9 +233,9 @@ gnc_accounting_period_end_gdate (GncAccountingPeriod which,
 
     if (contains)
     {
-        date = g_date_new_dmy(g_date_get_day(contains),
-                              g_date_get_month(contains),
-                              g_date_get_year(contains));
+        date = g_date_new_dmy (g_date_get_day (contains),
+                               g_date_get_month (contains),
+                               g_date_get_year (contains));
     }
     else
     {
@@ -248,8 +246,8 @@ gnc_accounting_period_end_gdate (GncAccountingPeriod which,
     switch (which)
     {
     default:
-        g_message("Undefined relative time constant %d", which);
-        g_date_free(date);
+        g_message ("Undefined relative time constant %d", which);
+        g_date_free (date);
         return 0;
 
     case GNC_ACCOUNTING_PERIOD_TODAY:
@@ -257,47 +255,47 @@ gnc_accounting_period_end_gdate (GncAccountingPeriod which,
         break;
 
     case GNC_ACCOUNTING_PERIOD_MONTH:
-        gnc_gdate_set_month_end(date);
+        gnc_gdate_set_month_end (date);
         break;
 
     case GNC_ACCOUNTING_PERIOD_MONTH_PREV:
-        gnc_gdate_set_prev_month_end(date);
+        gnc_gdate_set_prev_month_end (date);
         break;
 
     case GNC_ACCOUNTING_PERIOD_QUARTER:
-        gnc_gdate_set_quarter_end(date);
+        gnc_gdate_set_quarter_end (date);
         break;
 
     case GNC_ACCOUNTING_PERIOD_QUARTER_PREV:
-        gnc_gdate_set_prev_quarter_end(date);
+        gnc_gdate_set_prev_quarter_end (date);
         break;
 
     case GNC_ACCOUNTING_PERIOD_CYEAR:
-        gnc_gdate_set_year_end(date);
+        gnc_gdate_set_year_end (date);
         break;
 
     case GNC_ACCOUNTING_PERIOD_CYEAR_PREV:
-        gnc_gdate_set_prev_year_end(date);
+        gnc_gdate_set_prev_year_end (date);
         break;
 
     case GNC_ACCOUNTING_PERIOD_FYEAR:
         if (fy_end == NULL)
         {
-            g_message("Request for fisal year value but no fiscal year end value provided.");
-            g_date_free(date);
+            g_message ("Request for fisal year value but no fiscal year end value provided.");
+            g_date_free (date);
             return 0;
         }
-        gnc_gdate_set_fiscal_year_end(date, fy_end);
+        gnc_gdate_set_fiscal_year_end (date, fy_end);
         break;
 
     case GNC_ACCOUNTING_PERIOD_FYEAR_PREV:
         if (fy_end == NULL)
         {
-            g_message("Request for fisal year value but no fiscal year end value provided.");
-            g_date_free(date);
+            g_message ("Request for fisal year value but no fiscal year end value provided.");
+            g_date_free (date);
             return 0;
         }
-        gnc_gdate_set_prev_fiscal_year_end(date, fy_end);
+        gnc_gdate_set_prev_fiscal_year_end (date, fy_end);
         break;
     }
 
@@ -306,18 +304,18 @@ gnc_accounting_period_end_gdate (GncAccountingPeriod which,
 
 static time64
 gnc_accounting_period_end_time64 (GncAccountingPeriod which,
-                                 const GDate *fy_end,
-                                 const GDate *contains)
+                                  const GDate *fy_end,
+                                  const GDate *contains)
 {
     GDate *date;
     time64 secs;
 
-    date = gnc_accounting_period_end_gdate(which, fy_end, contains);
+    date = gnc_accounting_period_end_gdate (which, fy_end, contains);
     if (!date)
         return 0;
 
-    secs = gnc_time64_get_day_end_gdate(date);
-    g_date_free(date);
+    secs = gnc_time64_get_day_end_gdate (date);
+    g_date_free (date);
     return secs ;
 }
 
diff --git a/libgnucash/app-utils/gnc-accounting-period.h b/libgnucash/app-utils/gnc-accounting-period.h
index 7c7649ef8..835d03b9c 100644
--- a/libgnucash/app-utils/gnc-accounting-period.h
+++ b/libgnucash/app-utils/gnc-accounting-period.h
@@ -92,8 +92,9 @@ typedef enum
  *  @return The starting day of the specified time interval, as a
  *  GDate. */
 GDate *gnc_accounting_period_start_gdate (GncAccountingPeriod which,
-        const GDate *fy_end,
-        const GDate *contains);
+                                          const GDate *fy_end,
+                                          const GDate *contains);
+
 /** This function returns the ending date for an accounting period.
  *  The date will be computed based upon the type of accounting
  *  interval requested, an optional fiscal year end value, and an
@@ -119,8 +120,8 @@ GDate *gnc_accounting_period_end_gdate (GncAccountingPeriod which,
 
 /* Get the fiscal accounting period from the preferences and return
    the start and end times. */
-time64 gnc_accounting_period_fiscal_start(void);
-time64 gnc_accounting_period_fiscal_end(void);
+time64 gnc_accounting_period_fiscal_start (void);
+time64 gnc_accounting_period_fiscal_end (void);
 
 /** @} */
 

commit 037f5ed5be12549330e71ffd9a61b90a5cf7f759
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Fri May 17 10:39:53 2019 +0100

    Bug 797089 - Wrong time for accounting period end date
    
    In the Preferences/Accounting Period, there is an option to specify
    absolute dates but the end date was being set to start of day instead
    of end of day, changed this.

diff --git a/libgnucash/app-utils/gnc-accounting-period.c b/libgnucash/app-utils/gnc-accounting-period.c
index eb6d2d915..2c50aebbf 100644
--- a/libgnucash/app-utils/gnc-accounting-period.c
+++ b/libgnucash/app-utils/gnc-accounting-period.c
@@ -63,7 +63,8 @@ lookup_start_date_option(GDate *fy_end)
     int which;
 
     if (gnc_prefs_get_bool (GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_START_CHOICE_ABS))
-        time = gnc_prefs_get_int64 (GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_START_DATE);
+        time = gnc_time64_get_day_start (gnc_prefs_get_int64
+                                        (GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_START_DATE));
     else
     {
         which = gnc_prefs_get_int(GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_START_PERIOD);
@@ -83,7 +84,8 @@ lookup_end_date_option(GDate *fy_end)
     int which;
 
     if (gnc_prefs_get_bool (GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_END_CHOICE_ABS))
-        time = gnc_prefs_get_int64 (GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_END_DATE);
+        time = gnc_time64_get_day_end (gnc_prefs_get_int64
+                                      (GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_END_DATE));
     else
     {
         which = gnc_prefs_get_int(GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_END_PERIOD);

commit 5ad3cd0d607f20d3e5d2c8d85d20120018eb67cc
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Wed May 15 17:55:09 2019 +0100

    Deleting TaxTable entries can crash application
    
    Change the switch statement to include GNC_AMT_TYPE_VALUE to return a
    value for row_text[1] and change default to set it to NULL

diff --git a/gnucash/gnome-utils/dialog-tax-table.c b/gnucash/gnome-utils/dialog-tax-table.c
index 7e9d204d9..16971e330 100644
--- a/gnucash/gnome-utils/dialog-tax-table.c
+++ b/gnucash/gnome-utils/dialog-tax-table.c
@@ -377,12 +377,15 @@ tax_table_entries_refresh (TaxTableWindow *ttw)
                                  xaccPrintAmount (amount,
                                                   gnc_default_print_info (FALSE)));
             break;
-        default:
+        case GNC_AMT_TYPE_VALUE:
             row_text[1] =
                 g_strdup_printf ("%s",
                                  xaccPrintAmount (amount,
                                                   gnc_default_print_info (TRUE)));
             break;
+         default:
+             row_text[1] = NULL;
+             break;
         }
 
         gtk_list_store_prepend(store, &iter);

commit fade13f81368e56d3484676450c09f30ee60fa7a
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Wed May 15 16:09:27 2019 +0100

    Setup some default sorting for the TaxTable entries

diff --git a/gnucash/gnome-utils/dialog-tax-table.c b/gnucash/gnome-utils/dialog-tax-table.c
index 833c26846..7e9d204d9 100644
--- a/gnucash/gnome-utils/dialog-tax-table.c
+++ b/gnucash/gnome-utils/dialog-tax-table.c
@@ -730,11 +730,18 @@ gnc_ui_tax_table_window_new (GtkWindow *parent, QofBook *book)
     gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
     g_object_unref(store);
 
+    /* default sort order */
+    gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(store),
+                                          TAX_TABLE_COL_NAME,
+                                          GTK_SORT_ASCENDING);
+
     renderer = gtk_cell_renderer_text_new();
     column = gtk_tree_view_column_new_with_attributes("", renderer,
              "text", TAX_TABLE_COL_NAME,
              NULL);
+    g_object_set (G_OBJECT(column), "reorderable", TRUE, NULL);
     gtk_tree_view_append_column(view, column);
+    gtk_tree_view_column_set_sort_column_id (column, TAX_TABLE_COL_NAME);
 
     selection = gtk_tree_view_get_selection(view);
     g_signal_connect(selection, "changed",
@@ -747,11 +754,18 @@ gnc_ui_tax_table_window_new (GtkWindow *parent, QofBook *book)
     gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
     g_object_unref(store);
 
+    /* default sort order */
+    gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(store),
+                                          TAX_ENTRY_COL_NAME,
+                                          GTK_SORT_ASCENDING);
+
     renderer = gtk_cell_renderer_text_new();
     column = gtk_tree_view_column_new_with_attributes("", renderer,
              "text", TAX_ENTRY_COL_NAME,
              NULL);
+    g_object_set (G_OBJECT(column), "reorderable", TRUE, NULL);
     gtk_tree_view_append_column(view, column);
+    gtk_tree_view_column_set_sort_column_id (column, TAX_ENTRY_COL_NAME);
 
     selection = gtk_tree_view_get_selection(view);
     g_signal_connect(selection, "changed",

commit 36574f08fb1ed9543de84cb481e0799b0ad7515c
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Wed May 15 16:08:53 2019 +0100

    After editing the TaxTables the selection has moved

diff --git a/gnucash/gnome-utils/dialog-tax-table.c b/gnucash/gnome-utils/dialog-tax-table.c
index 67e607535..833c26846 100644
--- a/gnucash/gnome-utils/dialog-tax-table.c
+++ b/gnucash/gnome-utils/dialog-tax-table.c
@@ -426,6 +426,7 @@ tax_table_window_refresh (TaxTableWindow *ttw)
     GtkTreePath *path;
     GtkTreeSelection *selection;
     GtkTreeRowReference *reference = NULL;
+    GncTaxTable *saved_current_table = ttw->current_table;
 
     g_return_if_fail (ttw);
     view = GTK_TREE_VIEW (ttw->names_view);
@@ -454,7 +455,8 @@ tax_table_window_refresh (TaxTableWindow *ttw)
                            TAX_TABLE_COL_NAME, gncTaxTableGetName (table),
                            TAX_TABLE_COL_POINTER, table,
                            -1);
-        if (table == ttw->current_table)
+
+        if (table == saved_current_table)
         {
             path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
             reference = gtk_tree_row_reference_new(GTK_TREE_MODEL(store), path);



Summary of changes:
 gnucash/gnome-utils/dialog-tax-table.c       |  23 ++++-
 libgnucash/app-utils/gnc-accounting-period.c | 132 +++++++++++++--------------
 libgnucash/app-utils/gnc-accounting-period.h |   9 +-
 3 files changed, 92 insertions(+), 72 deletions(-)



More information about the gnucash-changes mailing list