gnucash maint: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Tue Dec 25 17:18:22 EST 2018


Updated	 via  https://github.com/Gnucash/gnucash/commit/d8be4e36 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/bcf5f7d7 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a5057e81 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/5ce280d5 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/6e8ac58d (commit)
	 via  https://github.com/Gnucash/gnucash/commit/f697eb2f (commit)
	 via  https://github.com/Gnucash/gnucash/commit/0850e004 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/01a0bc2b (commit)
	from  https://github.com/Gnucash/gnucash/commit/53680e61 (commit)



commit d8be4e36e55754160e56bba9b63863e0b4409592
Merge: 53680e6 bcf5f7d
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue Dec 25 14:17:47 2018 -0800

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


commit bcf5f7d751fe0ce85dde870194b8b3bb743a96c0
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Dec 17 07:52:20 2018 +0800

    [income-gst-statement] bugfix must not translate option names
    
    This bug would cause report crash for localized builds because the
    option names were localized and could never be retrieved from the
    options tree.

diff --git a/gnucash/report/standard-reports/income-gst-statement.scm b/gnucash/report/standard-reports/income-gst-statement.scm
index 28aaf7d..3e73ad3 100644
--- a/gnucash/report/standard-reports/income-gst-statement.scm
+++ b/gnucash/report/standard-reports/income-gst-statement.scm
@@ -147,8 +147,8 @@ for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
        (accounts-tax-paid      (filter (lambda (acc) (eq? (xaccAccountGetType acc) ACCT-TYPE-ASSET))     tax-accounts))
        (accounts-sales         (filter (lambda (acc) (eq? (xaccAccountGetType acc) ACCT-TYPE-INCOME))    accounts))
        (accounts-purchases     (filter (lambda (acc) (eq? (xaccAccountGetType acc) ACCT-TYPE-EXPENSE))   accounts))
-       (common-currency (and (opt-val gnc:pagename-general (_ "Common Currency"))             ; if a common currency was specified,
-                             (opt-val gnc:pagename-general (_ "Report's currency"))))         ; use it
+       (common-currency (and (opt-val gnc:pagename-general "Common Currency")             ; if a common currency was specified,
+                             (opt-val gnc:pagename-general "Report's currency")))         ; use it
        (split-date (lambda (s) (xaccTransGetDate (xaccSplitGetParent s))))
        (split-currency (lambda (s) (xaccAccountGetCommodity (xaccSplitGetAccount s))))
        (split-adder (lambda (split accountlist)

commit a5057e811621777018c9a979ab08e1d86cab321d
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Dec 17 11:36:06 2018 +0800

    [income-gst-statement] allow i10n and fix comments

diff --git a/gnucash/report/standard-reports/income-gst-statement.scm b/gnucash/report/standard-reports/income-gst-statement.scm
index 8535021..28aaf7d 100644
--- a/gnucash/report/standard-reports/income-gst-statement.scm
+++ b/gnucash/report/standard-reports/income-gst-statement.scm
@@ -193,13 +193,14 @@ for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
        (tax-payable (lambda (s) (myadd (tax-on-sales s) (myneg (tax-on-purchases s))))))
     (append
      ;; each column will be a vector
-     ;; (vector heading
+     ;; (vector heading                                      ;; string
      ;;         calculator-function                          ;; (calculator-function split) to obtain amount
-     ;;         reverse-column?                              ;; unused in GST report
+     ;;         reverse-column?                              ;; #t for income, #f for expense
      ;;         subtotal?                                    ;; #t - all columns need subtotals
      ;;         start-dual-column?                           ;; unused in GST report
      ;;         friendly-heading-fn                          ;; unused in GST report
-     (list (vector "TOTAL SALES"
+     ;; Translators: "TOTAL SALES" refer to Net Sales + GST/VAT on Sales
+     (list (vector (_ "TOTAL SALES")
                    total-sales
                    #t #t #f
                    (lambda (a) "")))
@@ -209,7 +210,7 @@ for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
                                     #t #t #f
                                     (lambda (a) "")))
               accounts-sales)
-         (list (vector "Net Sales"
+         (list (vector (_ "Net Sales")
                        sales-without-tax
                        #t #t #f
                        (lambda (a) ""))))
@@ -219,11 +220,12 @@ for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
                                     #t #t #f
                                     (lambda (a) "")))
               accounts-tax-collected)
-         (list (vector "Tax on Sales"
+         (list (vector (_ "Tax on Sales")
                        tax-on-sales
                        #t #t #f
                        (lambda (a) ""))))
-     (list (vector "TOTAL PURCHASES"
+     ;; Translators: "TOTAL PURCHASES" refer to Net Purchase + GST/VAT on Purchase
+     (list (vector (_ "TOTAL PURCHASES")
                    total-purchases
                    #f #t #f
                    (lambda (a) "")))
@@ -233,7 +235,7 @@ for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
                                     #f #t #f
                                     (lambda (a) "")))
               accounts-purchases)
-         (list (vector "Net Purchases"
+         (list (vector (_ "Net Purchases")
                        purchases-without-tax
                        #f #t #f
                        (lambda (a) ""))))
@@ -243,24 +245,27 @@ for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
                                     #f #t #f
                                     (lambda (a) "")))
               accounts-tax-paid)
-         (list (vector "Tax on Purchases"
+         (list (vector (_ "Tax on Purchases")
                        tax-on-purchases
                        #f #t #f
                        (lambda (a) ""))))
      (if (opt-val gnc:pagename-display (N_ "Remittance amount"))
-         (list (vector "Remittance"
+         ;; Translators: "Remittance" refer to TOTAL SALES - TOTAL PURCHASES in GST Report
+         (list (vector (_ "Remittance")
                        bank-remittance
                        #f #t #f
                        (lambda (a) "")))
          '())
      (if (opt-val gnc:pagename-display (N_ "Net Income"))
-         (list (vector "Net Income"
+         ;; Translators: "Net Income" refer to Net Sales - Net Purchases in GST Report
+         (list (vector (_ "Net Income")
                        net-income
                        #f #t #f
                        (lambda (a) "")))
          '())
      (if (opt-val gnc:pagename-display (N_ "Tax payable"))
-         (list (vector "Tax Payable"
+         ;; Translators: "Tax Payable" refer to the difference GST Sales - GST Purchases
+         (list (vector (_ "Tax Payable")
                        tax-payable
                        #f #t #f
                        (lambda (a) "")))

commit 5ce280d5ef93257fc09ceb8c126a338e59810957
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Dec 3 15:27:35 2018 +0800

    [net-charts] use srfi-1 map
    
    This function was created manually and could be simplified by using
    srfi-1 map, similar to category-barchart.scm. Much more readable.

diff --git a/gnucash/report/standard-reports/net-charts.scm b/gnucash/report/standard-reports/net-charts.scm
index 33b2c92..12e1008 100644
--- a/gnucash/report/standard-reports/net-charts.scm
+++ b/gnucash/report/standard-reports/net-charts.scm
@@ -287,21 +287,10 @@
         ;;              (list acc2 bal0 bal1 bal2 ...) ...)
         ;; whereby list of balances are gnc-monetary objects
         ;; output: (list <mon-coll0> <mon-coll1> <mon-coll2>)
-        (define list-of-collectors
-          (let loop ((n (length dates)) (result '()))
-            (if (zero? n) result
-                (loop (1- n) (cons (gnc:make-commodity-collector) result)))))
-        (let loop ((lst lst))
-          (when (pair? lst)
-            (let innerloop ((list-of-collectors list-of-collectors)
-                            (list-of-balances (cdar lst)))
-              (when (pair? list-of-balances)
-                ((car list-of-collectors) 'add
-                 (gnc:gnc-monetary-commodity (car list-of-balances))
-                 (gnc:gnc-monetary-amount (car list-of-balances)))
-                (innerloop (cdr list-of-collectors) (cdr list-of-balances))))
-            (loop (cdr lst))))
-        list-of-collectors)
+        (define (call thunk) (thunk))
+        (if (null? lst)
+            (map call (make-list (length dates) gnc:make-commodity-collector))
+            (apply map gnc:monetaries-add (map cdr lst))))
 
       (let loop ((dates dates)
                  (acct-balances (acc-balances->list-of-balances filtered-account-balances))

commit 6e8ac58d93e029609185b6475ab7364a8fbb4fd8
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Dec 4 22:15:54 2018 +0800

    [report-utilities] introduce gnc:monetaries-add and gnc:monetary+
    
    utility functions to add any number of monetaries
    
    1. gnc:monetaries-add
       input: monetaries...
       output: commodity-collector
    
    2. gnc:monetary+
       input: monetaries...
       output: monetary, assuming 1 commodity only

diff --git a/gnucash/report/report-system/report-system.scm b/gnucash/report/report-system/report-system.scm
index ab45ea2..5d068f5 100644
--- a/gnucash/report/report-system/report-system.scm
+++ b/gnucash/report/report-system/report-system.scm
@@ -719,6 +719,8 @@
 (export gnc:report-finished)
 (export gnc:accounts-count-splits)
 (export gnc-commodity-collector-allzero?)
+(export gnc:monetary+)
+(export gnc:monetaries-add)
 (export gnc:account-get-trans-type-balance-interval)
 (export gnc:account-get-trans-type-balance-interval-with-closing)
 (export gnc:account-get-total-flow)
diff --git a/gnucash/report/report-system/report-utilities.scm b/gnucash/report/report-system/report-utilities.scm
index e2fa050..206c8e3 100644
--- a/gnucash/report/report-system/report-utilities.scm
+++ b/gnucash/report/report-system/report-utilities.scm
@@ -383,6 +383,26 @@ construct gnc:make-gnc-monetary and use gnc:monetary->string instead.")
          (map gnc:gnc-monetary-amount
               (collector 'format gnc:make-gnc-monetary #f))))
 
+;; add any number of gnc-monetary objects into a commodity-collector
+;; usage: (gnc:monetaries-add monetary1 monetary2 ...)
+;; output: a commodity-collector object
+(define (gnc:monetaries-add . monetaries)
+  (let ((coll (gnc:make-commodity-collector)))
+    (for-each
+     (lambda (mon)
+       (coll 'add (gnc:gnc-monetary-commodity mon) (gnc:gnc-monetary-amount mon)))
+     monetaries)
+    coll))
+
+;; special case for gnc:monetaries-add whereby only 1 currency is expected
+;; usage: (gnc:monetaries-add monetary1 monetary2 ...)
+;; output: a monetary object
+(define (gnc:monetary+ . monetaries)
+  (let ((coll (apply gnc:monetaries-add monetaries)))
+    (if (= 1 (gnc-commodity-collector-commodity-count coll))
+        (car (coll 'format gnc:make-gnc-monetary #f))
+        (throw "gnc:monetary+ expects 1 currency " (gnc:strify monetaries)))))
+
 ;; 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.
diff --git a/gnucash/report/report-system/test/test-report-utilities.scm b/gnucash/report/report-system/test/test-report-utilities.scm
index f8d5241..2ad33af 100644
--- a/gnucash/report/report-system/test/test-report-utilities.scm
+++ b/gnucash/report/report-system/test/test-report-utilities.scm
@@ -21,6 +21,7 @@
   (test-gnc:monetary->string)
   (test-commodity-collector)
   (test-get-account-balances)
+  (test-monetary-adders)
   (test-end "report-utilities"))
 
 (define (NDayDelta t64 n)
@@ -472,3 +473,45 @@
           (collector->list
            (gnc:get-assoc-account-balances-total account-balances)))))
     (teardown)))
+
+(define (test-monetary-adders)
+  (define (monetary->pair mon)
+    (let ((comm (gnc:gnc-monetary-commodity mon))
+          (amt (gnc:gnc-monetary-amount mon)))
+      (cons (gnc-commodity-get-mnemonic comm) amt)))
+  (let* ((book (gnc-get-current-book))
+         (comm-table (gnc-commodity-table-get-table book))
+         (USD (gnc-commodity-table-lookup comm-table "CURRENCY" "USD"))
+         (GBP (gnc-commodity-table-lookup comm-table "CURRENCY" "GBP"))
+         (EUR (gnc-commodity-table-lookup comm-table "CURRENCY" "EUR"))
+         (usd10 (gnc:make-gnc-monetary USD 10))
+         (usd8 (gnc:make-gnc-monetary USD 8))
+         (gbp10 (gnc:make-gnc-monetary GBP 10))
+         (gbp8 (gnc:make-gnc-monetary GBP 8))
+         (eur10 (gnc:make-gnc-monetary EUR 10))
+         (eur8 (gnc:make-gnc-monetary EUR 8)))
+
+    (test-equal "gnc:monetaries-add 1 currency"
+      '(("USD" . 20))
+      (collector->list
+       (gnc:monetaries-add usd10 usd10)))
+
+    (test-equal "gnc:monetaries-add 2 currencies"
+      '(("GBP" . 8) ("USD" . 10))
+      (collector->list
+       (gnc:monetaries-add usd10 gbp8)))
+
+    (test-equal "gnc:monetaries-add 3 currencies"
+      '(("EUR" . 8) ("GBP" . 8) ("USD" . 20))
+      (collector->list
+       (gnc:monetaries-add usd10 gbp8 eur8 usd10)))
+
+    (test-equal "gnc:monetary+ with 1 currency succeeds"
+      '("USD" . 28)
+      (monetary->pair
+       (gnc:monetary+ usd10 usd10 usd8)))
+
+    (test-error
+     "gnc:monetary+ with >1 currency fails"
+     #t
+     (gnc:monetary+ usd10 usd10 eur8))))
diff --git a/gnucash/report/standard-reports/cashflow-barchart.scm b/gnucash/report/standard-reports/cashflow-barchart.scm
index 7666e23..f5c873c 100644
--- a/gnucash/report/standard-reports/cashflow-barchart.scm
+++ b/gnucash/report/standard-reports/cashflow-barchart.scm
@@ -241,21 +241,6 @@
              collector report-currency exchange-fn)
             )
 
-          ;; Add two or more gnc-monetary objects
-          (define (monetary+ a . blist)
-            (if (null? blist)
-                a
-                (let ((b (apply monetary+ blist)))
-                  (if (and (gnc:gnc-monetary? a) (gnc:gnc-monetary? b))
-                      (let ((same-currency? (gnc-commodity-equal (gnc:gnc-monetary-commodity a) (gnc:gnc-monetary-commodity b)))
-                            (amount (gnc-numeric-add (gnc:gnc-monetary-amount a) (gnc:gnc-monetary-amount b) GNC-DENOM-AUTO GNC-RND-ROUND)))
-                        (if same-currency?
-                            (gnc:make-gnc-monetary (gnc:gnc-monetary-commodity a) amount)
-                            (warn "incompatible currencies in monetary+: " a b)))
-                      (warn "wrong arguments for monetary+: " a b)))
-                )
-            )
-
           ;; Convert gnc:monetary to number (used to generate data for the chart)
           (define (monetary->double monetary)
             (gnc-numeric-to-double (gnc:gnc-monetary-amount monetary))
@@ -279,7 +264,7 @@
                     (money-out-collector (cdr (assq 'money-out-collector result)))
                     (money-in (sum-collector money-in-collector))
                     (money-out (sum-collector money-out-collector))
-                    (money-net (monetary+ money-in (gnc:monetary-neg money-out)))
+                    (money-net (gnc:monetary+ money-in (gnc:monetary-neg money-out)))
                     )
                (set! in-list (cons money-in in-list))
                (set! out-list (cons money-out out-list))
@@ -291,18 +276,18 @@
           (if show-in?
               (begin
                 (set! in-list (reverse in-list))
-                (set! total-in (apply monetary+ in-list))
+                (set! total-in (apply gnc:monetary+ in-list))
                 ))
           (if show-out?
               (begin
                 (set! out-list (reverse out-list))
-                (set! total-out (apply monetary+ out-list))
+                (set! total-out (apply gnc:monetary+ out-list))
 		))
 
           (if show-net?
               (begin
                 (set! net-list (reverse net-list))
-                (set! total-net (apply monetary+ net-list))
+                (set! total-net (apply gnc:monetary+ net-list))
                 ))
           (gnc:report-percent-done 90)
 
diff --git a/gnucash/report/standard-reports/category-barchart.scm b/gnucash/report/standard-reports/category-barchart.scm
index 10181ae..9365ae5 100644
--- a/gnucash/report/standard-reports/category-barchart.scm
+++ b/gnucash/report/standard-reports/category-barchart.scm
@@ -341,21 +341,6 @@ developing over time"))
                   c report-currency
                   (lambda (a b) (exchange-fn a b date)))))))
 
-          (define (monetaries-add . monetaries)
-            (let ((coll (gnc:make-commodity-collector)))
-              (for-each
-               (lambda (mon)
-                 (coll 'add (gnc:gnc-monetary-commodity mon) (gnc:gnc-monetary-amount mon)))
-               monetaries)
-              coll))
-
-          ;; Special case for monetaries-add whereby only 1 currency is expected
-          (define (monetary+ . monetaries)
-            (let ((coll (apply monetaries-add monetaries)))
-              (if (= 1 (gnc-commodity-collector-commodity-count coll))
-                  (car (coll 'format gnc:make-gnc-monetary #f))
-                  (gnc:warn "monetary+ expects 1 currency " (gnc:strify monetaries)))))
-
           (define (collector-minus a b)
             (let ((coll (gnc:make-commodity-collector)))
               (coll 'merge a #f)
@@ -396,7 +381,7 @@ developing over time"))
                                          (member (car entry) accountslist))
                                        account-balances-alist))
                    (selected-monetaries (map cdr selected-balances))
-                   (list-of-mon-collectors (apply map monetaries-add selected-monetaries)))
+                   (list-of-mon-collectors (apply map gnc:monetaries-add selected-monetaries)))
               (let loop ((list-of-mon-collectors list-of-mon-collectors)
                          (dates-list dates-list)
                          (result '()))
@@ -494,7 +479,7 @@ developing over time"))
                           (filter (lambda (l)
                                     (not (zero?
                                           (gnc:gnc-monetary-amount
-                                           (apply monetary+ (cadr l))))))
+                                           (apply gnc:monetary+ (cadr l))))))
                                   (traverse-accounts 1 topl-accounts))
                           (cond
                            ((eq? sort-method 'acct-code)
@@ -511,8 +496,8 @@ developing over time"))
                                              xaccAccountGetName) (car b)))))
                            (else
                             (lambda (a b)
-                              (> (gnc:gnc-monetary-amount (apply monetary+ (cadr a)))
-                                 (gnc:gnc-monetary-amount (apply monetary+ (cadr b)))))))))
+                              (> (gnc:gnc-monetary-amount (apply gnc:monetary+ (cadr a)))
+                                 (gnc:gnc-monetary-amount (apply gnc:monetary+ (cadr b)))))))))
           ;; Or rather sort by total amount?
           ;;(< (apply + (cadr a))
           ;;   (apply + (cadr b))))))
@@ -597,7 +582,7 @@ developing over time"))
                  (let* ((start (take all-data (1- max-slices)))
                         (finish (drop all-data (1- max-slices)))
                         (other-sum (map
-                                    (lambda (l) (apply monetary+ l))
+                                    (lambda (l) (apply gnc:monetary+ l))
                                     (apply zip (map cadr finish)))))
                    (set! all-data
                      (append start
@@ -758,7 +743,7 @@ developing over time"))
                             (sumrow
                              (lambda (row)
                                (if (not (null? row))
-                                   (monetary+ (car row) (sumrow (cdr row)))
+                                   (gnc:monetary+ (car row) (sumrow (cdr row)))
                                    (gnc:make-gnc-monetary report-currency 0)))))
                          (gnc:html-table-append-column!
                           table
diff --git a/gnucash/report/standard-reports/income-gst-statement.scm b/gnucash/report/standard-reports/income-gst-statement.scm
index 6aa289a..8535021 100644
--- a/gnucash/report/standard-reports/income-gst-statement.scm
+++ b/gnucash/report/standard-reports/income-gst-statement.scm
@@ -139,15 +139,7 @@ for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
           (gnc:option-value option)
           (gnc:error "gnc:lookup-option error: " section "/" name))))
   (letrec*
-      ((monetary+ (lambda (a b)
-                    (if (and (gnc:gnc-monetary? a) (gnc:gnc-monetary? b))
-                        (let ((same-currency? (gnc-commodity-equal (gnc:gnc-monetary-commodity a) (gnc:gnc-monetary-commodity b)))
-                              (amount (+ (gnc:gnc-monetary-amount a) (gnc:gnc-monetary-amount b))))
-                          (if same-currency?
-                              (gnc:make-gnc-monetary (gnc:gnc-monetary-commodity a) amount)
-                              (gnc:error "incompatible currencies in monetary+: " a b)))
-                        (gnc:error "wrong arguments for monetary+: " a b))))
-       (myadd (lambda (X Y) (if X (if Y (monetary+ X Y) X) Y)))               ; custom adder which understands #f values
+      ((myadd (lambda (X Y) (if X (if Y (gnc:monetary+ X Y) X) Y)))           ; custom monetary adder which understands #f
        (myneg (lambda (X) (and X (gnc:monetary-neg X))))                      ; custom monetary negator which understands #f
        (accounts (opt-val gnc:pagename-accounts "Accounts"))
        (tax-accounts (opt-val gnc:pagename-accounts "Tax Accounts"))
diff --git a/gnucash/report/standard-reports/net-charts.scm b/gnucash/report/standard-reports/net-charts.scm
index ca8ecb3..33b2c92 100644
--- a/gnucash/report/standard-reports/net-charts.scm
+++ b/gnucash/report/standard-reports/net-charts.scm
@@ -248,16 +248,6 @@
        c report-currency
        (lambda (a b) (exchange-fn a b date))))
 
-    ;; Add two gnc-monetary objects in the same currency.
-    (define (monetary+ a b)
-      (if (and (gnc:gnc-monetary? a) (gnc:gnc-monetary? b))
-          (let ((same-currency? (gnc-commodity-equal (gnc:gnc-monetary-commodity a) (gnc:gnc-monetary-commodity b)))
-                (amount (+ (gnc:gnc-monetary-amount a) (gnc:gnc-monetary-amount b))))
-            (if same-currency?
-                (gnc:make-gnc-monetary (gnc:gnc-monetary-commodity a) amount)
-                (warn "incompatible currencies in monetary+: " a b)))
-          (warn "wrong arguments for monetary+: " a b)))
-
     ;; gets an account alist balances
     ;; output: (list acc bal0 bal1 bal2 ...)
     (define (account->balancelist account)
@@ -358,7 +348,7 @@
                                   dates-list #f))
             (dummy (gnc:report-percent-done 80))
 
-            (difference-balances (map monetary+ minuend-balances subtrahend-balances))
+            (difference-balances (map gnc:monetary+ minuend-balances subtrahend-balances))
 
             (dates-list (if inc-exp?
                             (list-head dates-list (1- (length dates-list)))

commit f697eb2f01daa7259c88d9e36e0b4222a8a98c91
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Dec 5 15:37:07 2018 +0800

    [transaction] convert nested if/then/else -> cond
    
    This nested if/then/else snippet is more suited to (cond) syntax.

diff --git a/gnucash/report/standard-reports/transaction.scm b/gnucash/report/standard-reports/transaction.scm
index b7823e3..f6e9492 100644
--- a/gnucash/report/standard-reports/transaction.scm
+++ b/gnucash/report/standard-reports/transaction.scm
@@ -1389,38 +1389,42 @@ be excluded from periodic reporting.")
                 (reverse result)
                 (let* ((mon (retrieve-commodity (car columns) commodity))
                        (this-column (and mon (gnc:gnc-monetary-amount mon))))
-                  (if (car merge-list)
-                      ;; We're merging. If a subtotal exists, send to next loop iteration.
-                      (loop #t
-                            this-column
+                  (cond
+
+                   ;; We're merging. If a subtotal exists, send to next loop iteration.
+                   ((car merge-list)
+                    (loop #t
+                          this-column
+                          (cdr columns)
+                          (cdr merge-list)
+                          result))
+
+                   ;; We're completing merge. Display debit-credit in correct column.
+                   (merging?
+                    (let* ((sum (and (or last-column this-column)
+                                     (- (or last-column 0) (or this-column 0))))
+                           (sum-table-cell (and sum (gnc:make-html-table-cell/markup
+                                                     "total-number-cell"
+                                                     (gnc:make-gnc-monetary
+                                                      commodity (abs sum)))))
+                           (debit-col (and sum (positive? sum) sum-table-cell))
+                           (credit-col (and sum (not (positive? sum)) sum-table-cell)))
+                      (loop #f
+                            #f
                             (cdr columns)
                             (cdr merge-list)
-                            result)
-                      (begin
-                        (if merging?
-                            ;; We're completing merge. Display debit-credit in correct column.
-                            (let* ((sum (and (or last-column this-column)
-                                             (- (or last-column 0) (or this-column 0))))
-                                   (sum-table-cell (and sum (gnc:make-html-table-cell/markup
-                                                             "total-number-cell"
-                                                             (gnc:make-gnc-monetary
-                                                              commodity (abs sum)))))
-                                   (debit-col (and sum (positive? sum) sum-table-cell))
-                                   (credit-col (and sum (not (positive? sum)) sum-table-cell)))
-                              (loop #f
-                                    #f
-                                    (cdr columns)
-                                    (cdr merge-list)
-                                    (cons* (or credit-col "")
-                                           (or debit-col "")
-                                           result)))
-                            ;; Default; not merging nor completed merge. Just add amount to result.
-                            (loop #f
-                                  #f
-                                  (cdr columns)
-                                  (cdr merge-list)
-                                  (cons (gnc:make-html-table-cell/markup "total-number-cell" mon)
-                                        result)))))))))
+                            (cons* (or credit-col "")
+                                   (or debit-col "")
+                                   result))))
+
+                   ;; Not merging nor completed merge. Just add amount to result.
+                   (else
+                    (loop #f
+                          #f
+                          (cdr columns)
+                          (cdr merge-list)
+                          (cons (gnc:make-html-table-cell/markup "total-number-cell" mon)
+                                result))))))))
 
         ;; take the first column of each commodity, add onto the subtotal grid
         (set! grid (grid-add grid row col

commit 0850e004e2ec55b526810d3d391656efbc4e9916
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Nov 6 07:23:08 2018 +0800

    [welcome-to-gnucash] update (format), use #f for destination
    
    Old format calls without destination would trigger a guile-deprecated
    warning. Simple amendment.

diff --git a/gnucash/report/utility-reports/welcome-to-gnucash.scm b/gnucash/report/utility-reports/welcome-to-gnucash.scm
index c75b4c7..79b8d5a 100644
--- a/gnucash/report/utility-reports/welcome-to-gnucash.scm
+++ b/gnucash/report/utility-reports/welcome-to-gnucash.scm
@@ -91,9 +91,12 @@
     (gnc:html-document-add-object! 
      doc
      (gnc:make-html-text 
-      (gnc:html-markup-h2 (format (_ "Welcome to GnuCash ~a !") gnc:version))
-      (gnc:html-markup-p (format
-       (_ "GnuCash ~a has lots of nice features. Here are a few.") gnc:version))))
+      (gnc:html-markup-h2
+       (format #f (_ "Welcome to GnuCash ~a !")
+               gnc:version))
+      (gnc:html-markup-p
+       (format #f (_ "GnuCash ~a has lots of nice features. Here are a few.")
+               gnc:version))))
     doc))
 
 (gnc:define-report 

commit 01a0bc2bb2c70a081c0af05e4eac0085eb1c8c51
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Nov 6 07:45:35 2018 +0800

    Invoice: Remove H1 title and superflous option.
    
    Release Note: Printing the title twice is silly, so remove the option
    and the H1 display of the title. Note that the remaining title is in
    a div named "invoice-title" so it can be styled with CSS as the user
    pleases from the Report Options Layout tab.

diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index e3f78b2..6c7d0bd 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -268,11 +268,6 @@ for styling the invoice. Please see the exported report for the CSS class names.
 
   (gnc:register-inv-option
    (gnc:make-simple-boolean-option
-    (N_ "Display") (N_ "Title")
-    "a" (N_ "Display invoice title and invoice ID?") #t))
-
-  (gnc:register-inv-option
-   (gnc:make-simple-boolean-option
     (N_ "Display") (N_ "Due Date")
     "c" (N_ "Display due date?") #t))
 
@@ -826,17 +821,14 @@ for styling the invoice. Please see the exported report for the CSS class names.
                                                         (qof-print-date (current-time))))))
                (layout-lookup (lambda (loc) (cdr (assq (opt-val "Layout" loc) layout-lookup-table)))))
 
-          (gnc:html-document-set-title! document invoice-title)
-
           (gnc:html-document-set-style-text! document (opt-val "Layout" "CSS"))
 
           (let ((main-table (gnc:make-html-table)))
 
-            (if (opt-val "Display" "Title")
-                (gnc:html-table-append-row! main-table
-                                            (gnc:make-html-table-cell/size
-                                             1 2 (gnc:make-html-div/markup
-                                                  "invoice-title" invoice-title))))
+            (gnc:html-table-append-row! main-table
+                                        (gnc:make-html-table-cell/size
+                                         1 2 (gnc:make-html-div/markup
+                                              "invoice-title" invoice-title)))
 
             (gnc:html-table-append-row! main-table
                                         (list (layout-lookup "Row 1 Left")



Summary of changes:
 gnucash/report/business-reports/invoice.scm        | 16 ++----
 gnucash/report/report-system/report-system.scm     |  2 +
 gnucash/report/report-system/report-utilities.scm  | 20 +++++++
 .../report-system/test/test-report-utilities.scm   | 43 +++++++++++++++
 .../report/standard-reports/cashflow-barchart.scm  | 23 ++------
 .../report/standard-reports/category-barchart.scm  | 27 ++-------
 .../standard-reports/income-gst-statement.scm      | 41 +++++++-------
 gnucash/report/standard-reports/net-charts.scm     | 31 ++---------
 gnucash/report/standard-reports/transaction.scm    | 64 ++++++++++++----------
 .../report/utility-reports/welcome-to-gnucash.scm  |  9 ++-
 10 files changed, 143 insertions(+), 133 deletions(-)



More information about the gnucash-changes mailing list