gnucash maint: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Thu Feb 6 07:38:15 EST 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/7f794bb2 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/e523d528 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/4f624087 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/b0b6f2c6 (commit)
	from  https://github.com/Gnucash/gnucash/commit/a0fb7d3b (commit)



commit 7f794bb26b9c336b0489c202a1ee305bf66e68be
Merge: e523d5280 4f624087e
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu Feb 6 20:37:43 2020 +0800

    Merge branch 'maint-fix-budget-totals' into maint


commit e523d52802ce85432534b19e451cd5fa02cab15d
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Feb 5 17:07:18 2020 +0800

    [eguile-gnc] show error after stacktrace
    
    ... which makes the error more visible
    and reuse gnc:html-string-sanitize

diff --git a/gnucash/report/report-system/eguile-gnc.scm b/gnucash/report/report-system/eguile-gnc.scm
index 76a48b04c..4a033bc04 100644
--- a/gnucash/report/report-system/eguile-gnc.scm
+++ b/gnucash/report/report-system/eguile-gnc.scm
@@ -87,6 +87,7 @@
 (use-modules (ice-9 rdelim))      ; for read-line
 (use-modules (ice-9 local-eval))  ; for the-environment
 (use-modules (gnucash app-utils)) ; for _
+(use-modules (gnucash utilities)) ; for gnc:html-string-sanitize
 
 (define-public (string-substitute-alist str sub-alist)
   (with-output-to-string
@@ -98,15 +99,6 @@
               c)))
        str))))
 
-;; This is needed for displaying error messages -- note that it assumes that
-;; the output is HTML, which is a pity, because otherwise this module is
-;; non-specific -- it is designed to output a mixture of Guile and any other
-;; sort of text.  Oh well.
-(define-public (escape-html s1)
-  (string-substitute-alist s1 '((#\< . "<")
-                                (#\> . ">")
-                                (#\& . "&"))))
-
 ;; regexps used to find start and end of code segments
 (define startre (and (defined? 'make-regexp) (make-regexp "<\\?scm(:d)?[[:space:]]")))
 (define endre   (and (defined? 'make-regexp) (make-regexp "(^|[[:space:]])\\?>")))
@@ -203,11 +195,12 @@
     (display (_ "An error occurred when processing the template:"))
     (display "<br/><pre>")
     (display
-     (escape-html
+     (gnc:html-string-sanitize
       (with-output-to-string
         (lambda ()
-          (display-error #f (current-output-port) subr message args rest)
-          (display-backtrace error-stack (current-output-port))))))
+          (display-backtrace error-stack (current-output-port))
+          (newline)
+          (display-error #f (current-output-port) subr message args rest)))))
     (display "</pre><br/>"))
 
   (define (pre-unwind-handler key . rest)

commit 4f624087e1e0c521aca46254633b3ae1ad7d5d78
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Wed Feb 5 16:02:44 2020 +0100

    Budget Treeview - reshuffle totals logic
    
    The rearranged switch statements case on row_type rather than
    account type. This gives better isolation of the account types
    vs row_types in the conditions inside each case.

diff --git a/gnucash/gnome/gnc-budget-view.c b/gnucash/gnome/gnc-budget-view.c
index 76ef3904e..7b44c294a 100644
--- a/gnucash/gnome/gnc-budget-view.c
+++ b/gnucash/gnome/gnc-budget-view.c
@@ -1188,74 +1188,71 @@ totals_col_source (GtkTreeViewColumn *col, GtkCellRenderer *cell,
 
     for (i = 0; i < num_top_accounts; ++i)
     {
+        GNCAccountType acctype;
+
         account  = gnc_account_nth_child (priv->rootAcct, i);
         currency = gnc_account_get_currency_or_parent (account);
+        acctype = xaccAccountGetType (account);
 
         if (gnc_using_unreversed_budgets(gnc_account_get_book(account)))
         {  /* using book with unreversed-budgets feature. This will be
               the default in 4.x after budget scrubbing*/
             neg = gnc_reverse_balance (account);
-            switch (xaccAccountGetType (account))
+
+            switch (row_type)
             {
-            case ACCT_TYPE_ASSET:
-                if (row_type != TOTALS_TYPE_ASSET_LIAB_EQ &&
-                    row_type != TOTALS_TYPE_REMAINDER)
-                    continue;
-                if (row_type == TOTALS_TYPE_REMAINDER)
-                    neg = !neg;
-                break;
-            case ACCT_TYPE_LIABILITY:
-            case ACCT_TYPE_EQUITY:
-                if (row_type != TOTALS_TYPE_ASSET_LIAB_EQ &&
-                    row_type != TOTALS_TYPE_REMAINDER)
-                    continue;
-                if (row_type == TOTALS_TYPE_ASSET_LIAB_EQ)
+                case TOTALS_TYPE_ASSET_LIAB_EQ:
+                    if ((acctype == ACCT_TYPE_LIABILITY) ||
+                        (acctype == ACCT_TYPE_EQUITY))
+                        neg = !neg;
+                    else if (acctype != ACCT_TYPE_ASSET)
+                        continue;
+                    break;
+                case TOTALS_TYPE_EXPENSES:
+                    if (acctype != ACCT_TYPE_EXPENSE)
+                        continue;
+                    break;
+                case TOTALS_TYPE_INCOME:
+                    if (acctype != ACCT_TYPE_INCOME)
+                        continue;
                     neg = !neg;
-                break;
-            case ACCT_TYPE_INCOME:
-                if (row_type != TOTALS_TYPE_INCOME &&
-                    row_type != TOTALS_TYPE_REMAINDER)
-                    continue;
-                neg = !neg;
-                break;
-            case ACCT_TYPE_EXPENSE:
-                if ((row_type != TOTALS_TYPE_EXPENSES) &&
-                    (row_type != TOTALS_TYPE_REMAINDER))
-                    continue;
-                if (row_type == TOTALS_TYPE_REMAINDER)
-                    neg = !neg;
-                break;
-            default:
-                continue;       /* skip other types... */
+                    break;
+                case TOTALS_TYPE_REMAINDER:
+                    if ((acctype == ACCT_TYPE_ASSET) ||
+                        (acctype == ACCT_TYPE_INCOME) ||
+                        (acctype == ACCT_TYPE_EXPENSE))
+                        neg = !neg;
+                    break;
+                default:
+                    continue;       /* don't count if unexpected total row type is passed in... */
             }
         }
         else
         {   /* this section is for backward compatibility, to be
                removed when unreversed-budgets are mandatory */
-            switch (xaccAccountGetType (account))
+            neg = FALSE;
+
+            switch (row_type)
             {
-            case ACCT_TYPE_ASSET:
-            case ACCT_TYPE_LIABILITY:
-            case ACCT_TYPE_EQUITY:
-                if (row_type != TOTALS_TYPE_ASSET_LIAB_EQ &&
-                    row_type != TOTALS_TYPE_REMAINDER)
-                    continue;
-                neg = (row_type != TOTALS_TYPE_ASSET_LIAB_EQ);
-                break;
-            case ACCT_TYPE_INCOME:
-                if (row_type != TOTALS_TYPE_INCOME &&
-                    row_type != TOTALS_TYPE_REMAINDER)
-                    continue;
-                neg = FALSE;
-                break;
-            case ACCT_TYPE_EXPENSE:
-                if ((row_type != TOTALS_TYPE_EXPENSES) &&
-                    (row_type != TOTALS_TYPE_REMAINDER))
-                    continue;
-                neg = (row_type == TOTALS_TYPE_REMAINDER);
-                break;
-            default:
-                continue;       /* skip other types... */
+                case TOTALS_TYPE_ASSET_LIAB_EQ:
+                    if ((acctype != ACCT_TYPE_ASSET) &&
+                        (acctype != ACCT_TYPE_LIABILITY) &&
+                        (acctype != ACCT_TYPE_EQUITY))
+                        continue;
+                    break;
+                case TOTALS_TYPE_EXPENSES:
+                    if (acctype != ACCT_TYPE_EXPENSE)
+                        continue;
+                    break;
+                case TOTALS_TYPE_INCOME:
+                    if (acctype != ACCT_TYPE_INCOME)
+                        continue;
+                    break;
+                case TOTALS_TYPE_REMAINDER:
+                    neg = (acctype != ACCT_TYPE_INCOME);
+                    break;
+                default:
+                    continue;       /* don't count if unexpected total row type is passed in... */
             }
         }
         // find the total for this account

commit b0b6f2c6eb65b4521a17fa8c99267989e0b9f0b6
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Feb 5 00:20:17 2020 +0800

    fix budget totals for unreversed budgets books

diff --git a/gnucash/gnome/gnc-budget-view.c b/gnucash/gnome/gnc-budget-view.c
index 0345303f0..76ef3904e 100644
--- a/gnucash/gnome/gnc-budget-view.c
+++ b/gnucash/gnome/gnc-budget-view.c
@@ -1190,33 +1190,73 @@ totals_col_source (GtkTreeViewColumn *col, GtkCellRenderer *cell,
     {
         account  = gnc_account_nth_child (priv->rootAcct, i);
         currency = gnc_account_get_currency_or_parent (account);
-        neg = FALSE;
 
-        switch (xaccAccountGetType (account))
-        {
-        case ACCT_TYPE_ASSET:
-        case ACCT_TYPE_LIABILITY:
-        case ACCT_TYPE_EQUITY:
-            if (row_type != TOTALS_TYPE_ASSET_LIAB_EQ &&
-                row_type != TOTALS_TYPE_REMAINDER)
-                continue;
-            neg = (row_type != TOTALS_TYPE_ASSET_LIAB_EQ);
-            break;
-        case ACCT_TYPE_INCOME:
-            if (row_type != TOTALS_TYPE_INCOME &&
-                row_type != TOTALS_TYPE_REMAINDER)
-                continue;
-            neg = (row_type == TOTALS_TYPE_ASSET_LIAB_EQ);
-            break;
-        case ACCT_TYPE_EXPENSE:
-            if ((row_type != TOTALS_TYPE_EXPENSES) &&
-                (row_type != TOTALS_TYPE_REMAINDER))
-                continue;
-            neg = (row_type == TOTALS_TYPE_REMAINDER ||
-                   row_type == TOTALS_TYPE_ASSET_LIAB_EQ);
-            break;
-        default:
-            continue;
+        if (gnc_using_unreversed_budgets(gnc_account_get_book(account)))
+        {  /* using book with unreversed-budgets feature. This will be
+              the default in 4.x after budget scrubbing*/
+            neg = gnc_reverse_balance (account);
+            switch (xaccAccountGetType (account))
+            {
+            case ACCT_TYPE_ASSET:
+                if (row_type != TOTALS_TYPE_ASSET_LIAB_EQ &&
+                    row_type != TOTALS_TYPE_REMAINDER)
+                    continue;
+                if (row_type == TOTALS_TYPE_REMAINDER)
+                    neg = !neg;
+                break;
+            case ACCT_TYPE_LIABILITY:
+            case ACCT_TYPE_EQUITY:
+                if (row_type != TOTALS_TYPE_ASSET_LIAB_EQ &&
+                    row_type != TOTALS_TYPE_REMAINDER)
+                    continue;
+                if (row_type == TOTALS_TYPE_ASSET_LIAB_EQ)
+                    neg = !neg;
+                break;
+            case ACCT_TYPE_INCOME:
+                if (row_type != TOTALS_TYPE_INCOME &&
+                    row_type != TOTALS_TYPE_REMAINDER)
+                    continue;
+                neg = !neg;
+                break;
+            case ACCT_TYPE_EXPENSE:
+                if ((row_type != TOTALS_TYPE_EXPENSES) &&
+                    (row_type != TOTALS_TYPE_REMAINDER))
+                    continue;
+                if (row_type == TOTALS_TYPE_REMAINDER)
+                    neg = !neg;
+                break;
+            default:
+                continue;       /* skip other types... */
+            }
+        }
+        else
+        {   /* this section is for backward compatibility, to be
+               removed when unreversed-budgets are mandatory */
+            switch (xaccAccountGetType (account))
+            {
+            case ACCT_TYPE_ASSET:
+            case ACCT_TYPE_LIABILITY:
+            case ACCT_TYPE_EQUITY:
+                if (row_type != TOTALS_TYPE_ASSET_LIAB_EQ &&
+                    row_type != TOTALS_TYPE_REMAINDER)
+                    continue;
+                neg = (row_type != TOTALS_TYPE_ASSET_LIAB_EQ);
+                break;
+            case ACCT_TYPE_INCOME:
+                if (row_type != TOTALS_TYPE_INCOME &&
+                    row_type != TOTALS_TYPE_REMAINDER)
+                    continue;
+                neg = FALSE;
+                break;
+            case ACCT_TYPE_EXPENSE:
+                if ((row_type != TOTALS_TYPE_EXPENSES) &&
+                    (row_type != TOTALS_TYPE_REMAINDER))
+                    continue;
+                neg = (row_type == TOTALS_TYPE_REMAINDER);
+                break;
+            default:
+                continue;       /* skip other types... */
+            }
         }
         // find the total for this account
 



Summary of changes:
 gnucash/gnome/gnc-budget-view.c             | 89 ++++++++++++++++++++---------
 gnucash/report/report-system/eguile-gnc.scm | 17 ++----
 2 files changed, 68 insertions(+), 38 deletions(-)



More information about the gnucash-changes mailing list