gnucash maint: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Mon Oct 29 16:23:45 EDT 2018


Updated	 via  https://github.com/Gnucash/gnucash/commit/263c5a40 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/b59e2096 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/d0bbb5a2 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/0fc84ddb (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a603ea33 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a8326001 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/f1e8de68 (commit)
	from  https://github.com/Gnucash/gnucash/commit/105ea8e9 (commit)



commit 263c5a40ea88cdc974fc45af2e1674decf431c34
Merge: 105ea8e b59e209
Author: John Ralls <jralls at ceridwen.us>
Date:   Mon Oct 29 13:06:25 2018 -0700

    Merge Chris Lam's 'maint-scheme-progress' into maint.


commit b59e2096182f0356ee97a850b35399f131461383
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Oct 20 13:33:24 2018 +0800

    [test-extras] gnc-pricedb-create skips if commodity = currency

diff --git a/libgnucash/engine/test/test-extras.scm b/libgnucash/engine/test/test-extras.scm
index d671e9e..44de727 100644
--- a/libgnucash/engine/test/test-extras.scm
+++ b/libgnucash/engine/test/test-extras.scm
@@ -142,20 +142,20 @@
     txn))
 
 (define (gnc-pricedb-create currency commodity time64 value)
-  ;; I think adding pricedb for a DMY date will clobber any existing
-  ;; pricedb entry for that date.
-  (let ((price (gnc-price-create (gnc-get-current-book)))
-        (pricedb (gnc-pricedb-get-db (gnc-get-current-book))))
-    (gnc-price-begin-edit price)
-    (gnc-price-set-commodity price commodity)
-    (gnc-price-set-currency price currency)
-    (gnc-price-set-time64 price time64)
-    (gnc-price-set-source price PRICE-SOURCE-XFER-DLG-VAL)
-    (gnc-price-set-source-string price "test-price")
-    (gnc-price-set-typestr price "test")
-    (gnc-price-set-value price value)
-    (gnc-price-commit-edit price)
-    (gnc-pricedb-add-price pricedb price)))
+  ;; does not check for pre-existing pricedb data on date
+  (unless (gnc-commodity-equiv currency commodity)
+    (let ((price (gnc-price-create (gnc-get-current-book)))
+          (pricedb (gnc-pricedb-get-db (gnc-get-current-book))))
+      (gnc-price-begin-edit price)
+      (gnc-price-set-commodity price commodity)
+      (gnc-price-set-currency price currency)
+      (gnc-price-set-time64 price time64)
+      (gnc-price-set-source price PRICE-SOURCE-XFER-DLG-VAL)
+      (gnc-price-set-source-string price "test-price")
+      (gnc-price-set-typestr price "test")
+      (gnc-price-set-value price value)
+      (gnc-price-commit-edit price)
+      (gnc-pricedb-add-price pricedb price))))
 
 ;; When creating stock transactions always put the stock account and the number
 ;; of shares second, using negative numbers for a sale. e.g., to buy 100 shares

commit d0bbb5a2a800ed612f64a82062eb3946a432ec74
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu Oct 18 14:10:36 2018 +0800

    [report-utilities] deprecate gnc:account-get-balance-at-date.
    
    I think (gnc:account-get-balance-at-date) is flawed. It is actually
    unused, so, it should be safe to remove. It needs to be deprecated.
    Reports use xaccAccountGetBalanceAsOfDate instead, which does not
    retrieve sub-acct balances.
    
    I think this (gnc:account-get-balance-at-date) is flawed in sub-acct handling.
    Consider account structure:
    Assets [USD] - bal=$0
       Bank [USD] - bal=$100
       Broker [USD] - bal=$200
          Cash [USD] - bal=$800
          Funds [FUND] - bal=3 FUND @ $1000 each = $3000
    
    - Calling (gnc:account-get-balance-at-date BANK TODAY #f) returns 100
    - Calling (gnc:account-get-balance-at-date BROKER TODAY #f) returns 200
    - Calling (gnc:account-get-balance-at-date BROKER TODAY #t) returns 1000
      this is because although it counts all subaccounts bal $200 + $800 + 3FUND,
      it retrieves the parent account commodity USD $1000 only.

diff --git a/gnucash/report/report-system/report-utilities.scm b/gnucash/report/report-system/report-utilities.scm
index f01a97a..7b3f803 100644
--- a/gnucash/report/report-system/report-utilities.scm
+++ b/gnucash/report/report-system/report-utilities.scm
@@ -386,7 +386,22 @@ construct gnc:make-gnc-monetary and use gnc:monetary->string instead.")
 ;; get the account balance at the specified date. if include-children?
 ;; is true, the balances of all children (not just direct children)
 ;; are included in the calculation.
+;; I think this (gnc:account-get-balance-at-date) is flawed in sub-acct handling.
+;; Consider account structure:
+;; Assets [USD] - bal=$0
+;;    Bank [USD] - bal=$100
+;;    Broker [USD] - bal=$200
+;;       Cash [USD] - bal=$800
+;;       Funds [FUND] - bal=3 FUND @ $1000 each = $3000
+;; - Calling (gnc:account-get-balance-at-date BANK TODAY #f) returns 100
+;; - Calling (gnc:account-get-balance-at-date BROKER TODAY #f) returns 200
+;; - Calling (gnc:account-get-balance-at-date BROKER TODAY #t) returns 1000
+;;   this is because although it counts all subaccounts bal $200 + $800 + 3FUND,
+;;   it retrieves the parent account commodity USD $1000 only.
+;; It needs to be deprecated.
 (define (gnc:account-get-balance-at-date account date include-children?)
+  (issue-deprecation-warning "this gnc:account-get-balance-at-date function is \
+flawed. see report-utilities.scm. please update reports.")
   (let ((collector (gnc:account-get-comm-balance-at-date
                     account date include-children?)))
     (cadr (collector 'getpair (xaccAccountGetCommodity account) #f))))

commit 0fc84ddbcb6bfca3de8bc0f84bcc4d49ff02164a
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Oct 17 01:20:52 2018 +0800

    Bug 796914 - Customer Summary is giving error
    
    Bugfix. div/0 was not producing an error previously. This is probably
    caused by changes to gnc_numeric_div.

diff --git a/gnucash/report/business-reports/customer-summary.scm b/gnucash/report/business-reports/customer-summary.scm
index f6e05c5..139ef6d 100644
--- a/gnucash/report/business-reports/customer-summary.scm
+++ b/gnucash/report/business-reports/customer-summary.scm
@@ -650,8 +650,8 @@
     (gnc:html-markup-br))))
 
 (define (markup-percent profit sales)
-  (let ((m (gnc-numeric-div profit sales 1000 GNC-HOW-RND-ROUND)))
-    (* 100 (gnc-numeric-to-double m))))
+  (if (zero? sales) 0
+      (* 100 (gnc-numeric-div profit sales 1000 GNC-HOW-RND-ROUND))))
 
 (define (query-split-value sub-query toplevel-query)
   (let ((splits (qof-query-run-subquery sub-query toplevel-query))

commit a603ea338011c89cf06358f3f47230879797c6f6
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Oct 8 00:23:14 2018 +0800

    [invoice] bugfix img url must have file:/// prefix

diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index 690534b..44b5c83 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -675,7 +675,8 @@ for styling the invoice. Please see the exported report for the CSS class names.
 (define (make-img img-url)
   ;; just an image
   (gnc:make-html-text
-   (gnc:html-markup-img img-url)))
+   (gnc:html-markup-img
+    (make-file-url img-url))))
 
 (define (make-client-table owner orders options)
   (define (opt-val section name)

commit a8326001822c796b207ac448ee79cbf31ebfa555
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Sep 26 21:46:29 2018 +0800

    [test-transaction] test for display/enable links? feature

diff --git a/gnucash/report/standard-reports/test/test-transaction.scm b/gnucash/report/standard-reports/test/test-transaction.scm
index 08be14d..755aba2 100644
--- a/gnucash/report/standard-reports/test/test-transaction.scm
+++ b/gnucash/report/standard-reports/test/test-transaction.scm
@@ -472,6 +472,16 @@
              (length ((sxpath '(// (table 1) // (tr -1) // td)) sxml))
              1)))
 
+      (set-option! options "Display" "Enable links" #f)
+      (let ((sxml (options->sxml options "disable hyperlinks")))
+        (test-assert "no anchor when disabling hyperlinks"
+          (zero? (length ((sxpath '(// a // *text*)) sxml)))))
+
+      (set-option! options "Display" "Enable links" #t)
+      (let ((sxml (options->sxml options "enable hyperlinks")))
+        (test-assert "anchors exist when enabling hyperlinks"
+          (positive? (length ((sxpath '(// a // *text*)) sxml)))))
+
       (set-option! options "Display" "Amount" 'none)
       (let ((sxml (options->sxml options "no columns")))
         (test-assert "all display columns off, without amount nor subtotals, there should be 0 column"

commit f1e8de6886efd05013edacf41cdd3cc5d78cd93c
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Sep 26 17:46:47 2018 +0800

    [transaction] add option Display/Enable links to toggle hyperlinks
    
    This option is often requested.

diff --git a/gnucash/report/standard-reports/transaction.scm b/gnucash/report/standard-reports/transaction.scm
index dbe2df6..b7823e3 100644
--- a/gnucash/report/standard-reports/transaction.scm
+++ b/gnucash/report/standard-reports/transaction.scm
@@ -844,7 +844,7 @@ be excluded from periodic reporting.")
         (disp-accname? #t)
         (disp-other-accname? #f)
         (detail-is-single? #t)
-        (amount-is-single? #t))
+        (amount-value 'single))
 
     (define (apply-selectable-by-name-display-options)
       (gnc-option-db-set-option-selectable-by-name
@@ -857,11 +857,15 @@ be excluded from periodic reporting.")
 
       (gnc-option-db-set-option-selectable-by-name
        options gnc:pagename-display (N_ "Sign Reverses")
-       amount-is-single?)
+       (eq? amount-value 'single))
 
       (gnc-option-db-set-option-selectable-by-name
        options gnc:pagename-display optname-grid
-       amount-is-single?)
+       (eq? amount-value 'single))
+
+      (gnc-option-db-set-option-selectable-by-name
+       options gnc:pagename-display "Enable links"
+       (not (eq? amount-value 'none)))
 
       (gnc-option-db-set-option-selectable-by-name
        options gnc:pagename-display (N_ "Use Full Other Account Name")
@@ -960,17 +964,22 @@ be excluded from periodic reporting.")
      (gnc:make-multichoice-callback-option
       gnc:pagename-display (N_ "Amount")
       "m" (_ "Display the amount?")
-      'single
+      amount-value
       (list
        (vector 'none   (_ "None") (_ "No amount display."))
        (vector 'single (_ "Single") (_ "Single Column Display."))
        (vector 'double (_ "Double") (_ "Two Column Display.")))
       #f
       (lambda (x)
-        (set! amount-is-single? (eq? x 'single))
+        (set! amount-value x)
         (apply-selectable-by-name-display-options))))
 
     (gnc:register-trep-option
+     (gnc:make-simple-boolean-option
+      gnc:pagename-display (N_ "Enable links")
+      "m2" (_ "Enable hyperlinks in amounts.") #t))
+
+    (gnc:register-trep-option
      (gnc:make-multichoice-option
       gnc:pagename-display (N_ "Sign Reverses")
       "m1" (_ "Reverse amount display for certain account types.")
@@ -1056,6 +1065,7 @@ be excluded from periodic reporting.")
          (work-done 0)
          (table (gnc:make-html-table))
          (used-columns (build-columns-used))
+         (opt-use-links? (opt-val gnc:pagename-display "Enable links"))
          (account-types-to-reverse
           (keylist-get-info sign-reverse-list
                             (opt-val gnc:pagename-display (N_ "Sign Reverses"))
@@ -1472,7 +1482,8 @@ be excluded from periodic reporting.")
                                    (not (string-null? (xaccAccountGetDescription account))))
                               (string-append ": " (xaccAccountGetDescription account))
                               "")))
-        (if (and anchor? (not (null? account))) ;html anchor for 2-split transactions only
+        (if (and anchor? opt-use-links?
+                 (not (null? account))) ;html anchor for 2-split transactions only
             (gnc:make-html-text
              (gnc:html-markup-anchor (gnc:account-anchor-text account) name)
              description)
@@ -1532,17 +1543,21 @@ be excluded from periodic reporting.")
                     split transaction-row?))
                  left-columns)
             (map (lambda (cell)
-                   (let ((cell-monetary (vector-ref cell 0))
-                         (reverse? (and (vector-ref cell 1)
-                                        reversible-account?)))
-                     (and cell-monetary
+                   (let* ((cell-monetary (vector-ref cell 0))
+                          (reverse? (and (vector-ref cell 1)
+                                         reversible-account?))
+                          (cell-content (and cell-monetary
+                                             (if reverse?
+                                                 (gnc:monetary-neg cell-monetary)
+                                                 cell-monetary))))
+                     (and cell-content
                           (gnc:make-html-table-cell/markup
                            "number-cell"
-                           (gnc:html-transaction-anchor
-                            (xaccSplitGetParent split)
-                            (if reverse?
-                                (gnc:monetary-neg cell-monetary)
-                                cell-monetary))))))
+                           (if opt-use-links?
+                               (gnc:html-transaction-anchor
+                                (xaccSplitGetParent split)
+                                cell-content)
+                               cell-content)))))
                  cells))))
 
         (map (lambda (cell)



Summary of changes:
 .../report/business-reports/customer-summary.scm   |  4 +-
 gnucash/report/business-reports/invoice.scm        |  3 +-
 .../standard-reports/test/test-transaction.scm     | 10 +++++
 gnucash/report/standard-reports/transaction.scm    | 45 ++++++++++++++--------
 libgnucash/engine/test/test-extras.scm             | 28 +++++++-------
 5 files changed, 58 insertions(+), 32 deletions(-)



More information about the gnucash-changes mailing list