gnucash maint: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Sat Nov 23 09:55:32 EST 2019


Updated	 via  https://github.com/Gnucash/gnucash/commit/287b857a (commit)
	 via  https://github.com/Gnucash/gnucash/commit/729bf5ae (commit)
	 via  https://github.com/Gnucash/gnucash/commit/101cc916 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/68b0abdf (commit)
	from  https://github.com/Gnucash/gnucash/commit/17d39388 (commit)



commit 287b857a1839d37408bcabfe650d07a365b1096a
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Nov 23 22:32:19 2019 +0800

    [html-style-info] deprecate font-face/size/color
    
    Only 'font-color was demonstrated in hello-world.scm, and these were
    never used in practice.

diff --git a/gnucash/report/report-system/html-document.scm b/gnucash/report/report-system/html-document.scm
index a9c6b162d..3744eb79a 100644
--- a/gnucash/report/report-system/html-document.scm
+++ b/gnucash/report/report-system/html-document.scm
@@ -268,6 +268,8 @@
         ;;       as a call to this function just like any other tag, passing face/size/color as attributes.
         (if (or face size color)
             (begin
+              (issue-deprecation-warning
+               "this section is unreachable in code")
               (push "<font ")
               (if face
                   (begin
diff --git a/gnucash/report/report-system/html-style-info.scm b/gnucash/report/report-system/html-style-info.scm
index 38c166da8..f57653c40 100644
--- a/gnucash/report/report-system/html-style-info.scm
+++ b/gnucash/report/report-system/html-style-info.scm
@@ -36,12 +36,12 @@
 ;;  tag         : string for start tag
 ;;  attributes  : hash of attribute to value (unsafe!)
 ;;  attribute   : single attribute-value pair in a list 
-;;  font-face   : string for <font face="">
-;;  font-size   : string for <font size="">
-;;  font-color  : color (a valid HTML color spec)
+;;  font-face   : string for <font face=""> (deprecate)
+;;  font-size   : string for <font size=""> (deprecate)
+;;  font-color  : color (a valid HTML color spec) (deprecate)
 ;;  closing-font-tag: private data (computed from font-face,
 ;;                                  font-size, font-color)
-;;                    don't set directly, please!
+;;                    don't set directly, please! (deprecate)
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 
@@ -77,6 +77,7 @@
 
       ((field value . rest)
        (when (memq field '(font-size font-face font-color))
+         (issue-deprecation-warning "font-face/size/color deprecated.")
          (gnc:html-markup-style-info-set-closing-font-tag! style (and value #t)))
        ((record-modifier <html-markup-style-info> field) style value)
        (loop rest))
@@ -96,40 +97,55 @@
   (record-modifier <html-markup-style-info> 'attributes))
 
 (define gnc:html-markup-style-info-font-face
+  ;; deprecated
   (record-accessor <html-markup-style-info> 'font-face))
 
 (define gnc:html-markup-style-info-set-font-face-internal!
+  ;; deprecated
   (record-modifier <html-markup-style-info> 'font-face))
 
 (define (gnc:html-markup-style-info-set-font-face! record value)
+  (issue-deprecation-warning
+   "gnc:html-markup-style-info-set-font-face! is unused")
   (gnc:html-markup-style-info-set-closing-font-tag! record value)
   (gnc:html-markup-style-info-set-font-face-internal! record value))
 
 (define gnc:html-markup-style-info-font-size
+  ;; deprecated
   (record-accessor <html-markup-style-info> 'font-size))
 
 (define gnc:html-markup-style-info-set-font-size-internal!
+  ;; deprecated
   (record-modifier <html-markup-style-info> 'font-size))
 
 (define (gnc:html-markup-style-info-set-font-size! record value)
+  (issue-deprecation-warning
+   "gnc:html-markup-style-info-set-font-size! is unused")
   (gnc:html-markup-style-info-set-closing-font-tag! record value)
   (gnc:html-markup-style-info-set-font-size-internal! record value))
 
 (define gnc:html-markup-style-info-font-color
+  ;; deprecated
   (record-accessor <html-markup-style-info> 'font-color))
 
 (define gnc:html-markup-style-info-set-font-color-internal!
+  ;; deprecated
   (record-modifier <html-markup-style-info> 'font-color))
 
 (define (gnc:html-markup-style-info-set-font-color! record value)
+  (issue-deprecation-warning
+   "gnc:html-markup-style-info-set-font-color! is unused")
   (begin
     (gnc:html-markup-style-info-set-closing-font-tag!
      record (not (eq? value #f)))
     (gnc:html-markup-style-info-set-font-color-internal! record value)))
 
 (define gnc:html-markup-style-info-closing-font-tag
+  ;; deprecated
   (record-accessor <html-markup-style-info> 'closing-font-tag?))
+
 (define gnc:html-markup-style-info-set-closing-font-tag!
+  ;; deprecated
   (record-modifier <html-markup-style-info> 'closing-font-tag?))
 
 (define gnc:html-markup-style-info-inheritable? 
diff --git a/gnucash/report/report-system/report-system.scm b/gnucash/report/report-system/report-system.scm
index 4a80105f0..a351038b0 100644
--- a/gnucash/report/report-system/report-system.scm
+++ b/gnucash/report/report-system/report-system.scm
@@ -430,17 +430,17 @@
 (export gnc:html-markup-style-info-set-tag!)
 (export gnc:html-markup-style-info-attributes)
 (export gnc:html-markup-style-info-set-attributes!)
-(export gnc:html-markup-style-info-font-face)
-(export gnc:html-markup-style-info-set-font-face-internal!)
-(export gnc:html-markup-style-info-set-font-face!)
-(export gnc:html-markup-style-info-font-size)
-(export gnc:html-markup-style-info-set-font-size-internal!)
-(export gnc:html-markup-style-info-set-font-size!)
-(export gnc:html-markup-style-info-font-color)
-(export gnc:html-markup-style-info-set-font-color-internal!)
-(export gnc:html-markup-style-info-set-font-color!)
-(export gnc:html-markup-style-info-closing-font-tag)
-(export gnc:html-markup-style-info-set-closing-font-tag!)
+(export gnc:html-markup-style-info-font-face)               ;deprecated
+(export gnc:html-markup-style-info-set-font-face-internal!) ;deprecated
+(export gnc:html-markup-style-info-set-font-face!)          ;deprecated
+(export gnc:html-markup-style-info-font-size)               ;deprecated
+(export gnc:html-markup-style-info-set-font-size-internal!) ;deprecated
+(export gnc:html-markup-style-info-set-font-size!)          ;deprecated
+(export gnc:html-markup-style-info-font-color)              ;deprecated
+(export gnc:html-markup-style-info-set-font-color-internal!) ;deprecated
+(export gnc:html-markup-style-info-set-font-color!)          ;deprecated
+(export gnc:html-markup-style-info-closing-font-tag)         ;deprecated
+(export gnc:html-markup-style-info-set-closing-font-tag!)    ;deprecated
 (export gnc:html-markup-style-info-inheritable?)
 (export gnc:html-markup-style-info-set-inheritable?!)
 (export gnc:html-markup-style-info-set-attribute!)

commit 729bf5ae6aa17a3ef9ec416cb0134c2b94f7ace1
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Nov 23 22:28:33 2019 +0800

    [hello-world] remove 'Text Color' option - will be deprecated
    
    ... because deleting an option does not cause crash in saved-reports.

diff --git a/gnucash/report/utility-reports/hello-world.scm b/gnucash/report/utility-reports/hello-world.scm
index b947cbddc..18d7a5562 100644
--- a/gnucash/report/utility-reports/hello-world.scm
+++ b/gnucash/report/utility-reports/hello-world.scm
@@ -153,13 +153,6 @@
       (list #xf6 #xff #xdb #xff)
       255
       #f))
-    (add-option
-     (gnc:make-color-option
-      (N_ "Hello, World!") (N_ "Text Color")
-      "f" (N_ "This is a color option.")
-      (list #x00 #x00 #x00 #xff)
-      255
-      #f))
     
     ;; This is an account list option. The user can select one
     ;; or (possibly) more accounts from the list of accounts
@@ -247,7 +240,6 @@ option like this.")
                          (op-value "Hello, World!" "Combo Date Option")))
         (num-val      (op-value "Hello, World!" "Number Option"))
         (bg-color-op  (get-op   "Hello, World!" "Background Color"))
-        (txt-color-op (get-op   "Hello, World!" "Text Color"))
         (accounts     (op-value "Hello Again"   "An account list option"))
         (list-val     (op-value "Hello Again"   "A list option"))
         (crash-val    (op-value "Testing"       "Crash the report"))
@@ -304,8 +296,7 @@ option like this.")
       
       (gnc:html-document-set-style!
        document "body" 
-       'attribute (list "bgcolor" (gnc:color-option->html bg-color-op))
-       'font-color (gnc:color-option->html txt-color-op))
+       'attribute (list "bgcolor" (gnc:color-option->html bg-color-op)))
       
       ;; the title of the report will be rendered by the 
       ;; selected style sheet.  All we have to do is set it in the

commit 101cc91698279a661ca89310f4a404ee211faf14
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Nov 22 23:38:22 2019 +0800

    [reports] use new api gnc:account-accumulate-at-dates
    
    queries xaccSplitGetNoclosingBalance (which is a pointer dereference)
    instead of a more complex conditional-based snippet for split->amount,
    should be faster.
    
    The category-barchart change will choose the appropriate split->elt
    function according to the account type. This is more efficient than
    the old split->amount function which includes a conditional.
    
    Note we don't need to test for account being income/expense:
    asset/liability accounts do not have Closing transactions. Therefore
    we can use xaccSplitGetNoclosingBalance for splits from any account
    type.

diff --git a/gnucash/report/standard-reports/category-barchart.scm b/gnucash/report/standard-reports/category-barchart.scm
index c217a138c..b477ad282 100644
--- a/gnucash/report/standard-reports/category-barchart.scm
+++ b/gnucash/report/standard-reports/category-barchart.scm
@@ -355,18 +355,19 @@ developing over time"))
           (define account-balances-alist
             (map
              (lambda (acc)
-               (let ((ignore-closing? (not (gnc:account-is-inc-exp? acc))))
+               (let* ((comm (xaccAccountGetCommodity acc))
+                      (split->elt (if (reverse-balance? acc)
+                                      (lambda (s)
+                                        (gnc:make-gnc-monetary
+                                         comm (- (xaccSplitGetNoclosingBalance s))))
+                                      (lambda (s)
+                                        (gnc:make-gnc-monetary
+                                         comm (xaccSplitGetNoclosingBalance s))))))
                  (cons acc
-                       (map
-                        (if (reverse-balance? acc) gnc:monetary-neg identity)
-                        (gnc:account-get-balances-at-dates
-                         acc dates-list
-                         #:split->amount
-                         (lambda (s)
-                           (and (or ignore-closing?
-                                    (not (xaccTransGetIsClosingTxn
-                                          (xaccSplitGetParent s))))
-                                (xaccSplitGetAmount s))))))))
+                       (gnc:account-accumulate-at-dates
+                        acc dates-list
+                        #:split->elt split->elt
+                        #:nosplit->elt (gnc:make-gnc-monetary comm 0)))))
              ;; all selected accounts (of report-specific type), *and*
              ;; their descendants (of any type) need to be scanned.
              (gnc:accounts-and-all-descendants accounts)))
diff --git a/gnucash/report/standard-reports/net-charts.scm b/gnucash/report/standard-reports/net-charts.scm
index 396103b2d..c3ce5cb03 100644
--- a/gnucash/report/standard-reports/net-charts.scm
+++ b/gnucash/report/standard-reports/net-charts.scm
@@ -251,16 +251,14 @@
     ;; gets an account alist balances
     ;; output: (list acc bal0 bal1 bal2 ...)
     (define (account->balancelist account)
-      (let ((ignore-closing? (not (gnc:account-is-inc-exp? account))))
+      (let ((comm (xaccAccountGetCommodity account)))
         (cons account
-              (gnc:account-get-balances-at-dates
+              (gnc:account-accumulate-at-dates
                account dates-list
-               #:split->amount
-               (lambda (s)
-                 (and (or ignore-closing?
-                          (not (xaccTransGetIsClosingTxn
-                                (xaccSplitGetParent s))))
-                      (xaccSplitGetAmount s)))))))
+               #:split->elt (lambda (s)
+                              (gnc:make-gnc-monetary
+                               comm (xaccSplitGetNoclosingBalance s)))
+               #:nosplit->elt (gnc:make-gnc-monetary comm 0)))))
 
     ;; This calculates the balances for all the 'account-balances' for
     ;; each element of the list 'dates'. Uses the collector->monetary

commit 68b0abdfa6a51f317159167bb9259d4a45290afc
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Nov 22 23:28:33 2019 +0800

    [report-utilities] gnc:account-accumulate-at-dates: specify default elt
    
    if acc has no splits before report-date, the nosplit->elt will specify
    the default value to be inserted in the result list.
    
    e.g. consider:
    
    dates are (date1 date2 date3 date4 date5)
    account has splits starting after date2:
    
    (gnc:account-accumulate-at-dates account dates
     #:split->elt (const 'yea) #:nosplit->elt 'nay)
    
    results in '(nay nay yea yea yea)

diff --git a/gnucash/report/report-system/report-utilities.scm b/gnucash/report/report-system/report-utilities.scm
index cd909c97e..20cf23c15 100644
--- a/gnucash/report/report-system/report-utilities.scm
+++ b/gnucash/report/report-system/report-utilities.scm
@@ -483,6 +483,8 @@ flawed. see report-utilities.scm. please update reports.")
 ;; of split->elt results along the way at dates specified in dates.
 ;; in: acc   - account
 ;;     dates - a list of time64 -- it will be sorted
+;;     nosplit->elt - if report-dates occur *before* earliest split, the
+;;                    result list will be padded with this value
 ;;     split->date - an unary lambda. result to compare with dates list.
 ;;     split->elt - an unary lambda. it will be called successfully for each
 ;;                  split in the account until the last date. the result
@@ -490,14 +492,16 @@ flawed. see report-utilities.scm. please update reports.")
 ;;                  xaccSplitGetBalance makes it similar to
 ;;                  gnc:account-get-balances-at-dates.
 ;; out: (list elt0 elt1 ...), each entry is the result of split->elt
+;;      or nosplit->elt
 (define* (gnc:account-accumulate-at-dates
           acc dates #:key
+          (nosplit->elt #f)
           (split->date (compose xaccTransGetDate xaccSplitGetParent))
           (split->elt xaccSplitGetBalance))
   (let lp ((splits (xaccAccountGetSplitList acc))
            (dates (sort dates <))
            (result '())
-           (last-result #f))
+           (last-result nosplit->elt))
     (match dates
 
       ;; end of dates. job done!
diff --git a/gnucash/report/report-system/test/test-report-utilities.scm b/gnucash/report/report-system/test/test-report-utilities.scm
index adf648a36..b0f12da76 100644
--- a/gnucash/report/report-system/test/test-report-utilities.scm
+++ b/gnucash/report/report-system/test/test-report-utilities.scm
@@ -709,6 +709,14 @@
         '(#f #f #f 10)
         (gnc:account-accumulate-at-dates bank3 dates))
 
+      (test-equal "1 txn in late slot, tests #:nosplit->elt"
+        '(x x x 10)
+        (gnc:account-accumulate-at-dates bank3 dates #:nosplit->elt 'x))
+
+      (test-equal "1 txn in late slot, tests #:split->elt"
+        '(#f #f #f y)
+        (gnc:account-accumulate-at-dates bank3 dates #:split->elt (const 'y)))
+
       (test-equal "1 txn in early slot"
         '(#f 10 10 10)
         (gnc:account-accumulate-at-dates bank4 dates)))



Summary of changes:
 gnucash/report/report-system/html-document.scm     |  2 ++
 gnucash/report/report-system/html-style-info.scm   | 24 ++++++++++++++++++----
 gnucash/report/report-system/report-system.scm     | 22 ++++++++++----------
 gnucash/report/report-system/report-utilities.scm  |  6 +++++-
 .../report-system/test/test-report-utilities.scm   |  8 ++++++++
 .../report/standard-reports/category-barchart.scm  | 23 +++++++++++----------
 gnucash/report/standard-reports/net-charts.scm     | 14 ++++++-------
 gnucash/report/utility-reports/hello-world.scm     | 11 +---------
 8 files changed, 65 insertions(+), 45 deletions(-)



More information about the gnucash-changes mailing list