gnucash maint: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Wed Dec 2 18:11:51 EST 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/854c1178 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a8bed43d (commit)
	from  https://github.com/Gnucash/gnucash/commit/cc64f197 (commit)



commit 854c11782016a38fa34cec55d9fd7f2a0637b90e
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Dec 2 18:36:37 2020 +0800

    [trep-engine] move currency options into their own section
    
    tidier, also includes backward compatibility with saved-reports

diff --git a/gnucash/report/trep-engine.scm b/gnucash/report/trep-engine.scm
index 9dc469c45..0731f93a9 100644
--- a/gnucash/report/trep-engine.scm
+++ b/gnucash/report/trep-engine.scm
@@ -76,12 +76,15 @@
 ;;General
 (define optname-startdate (N_ "Start Date"))
 (define optname-enddate (N_ "End Date"))
-(define optname-price-source (N_ "Price Source"))
 (define optname-table-export (N_ "Table for Exporting"))
+(define optname-infobox-display (N_ "Add options summary"))
+
+;; Currency
+(define pagename-currency (N_ "Currency"))
+(define optname-price-source (N_ "Price Source"))
 (define optname-common-currency (N_ "Common Currency"))
 (define optname-orig-currency (N_ "Show original currency amount"))
 (define optname-currency (N_ "Report's currency"))
-(define optname-infobox-display (N_ "Add options summary"))
 
 ;;Filtering
 (define pagename-filter (N_ "Filter"))
@@ -537,25 +540,26 @@ Credit Card, and Income accounts."))
 
   (gnc:register-trep-option
    (gnc:make-complex-boolean-option
-    gnc:pagename-general optname-common-currency
-    "e" (G_ "Convert all transactions into a common currency.") #f
-    #f
+    pagename-currency optname-common-currency
+    "a" (G_ "Convert all transactions into a common currency.") #f #f
     (lambda (x)
       (gnc-option-db-set-option-selectable-by-name
-       options gnc:pagename-general optname-currency x)
+       options pagename-currency optname-currency x)
+      (gnc-option-db-set-option-selectable-by-name
+       options pagename-currency optname-orig-currency x)
       (gnc-option-db-set-option-selectable-by-name
-       options gnc:pagename-general optname-orig-currency x))))
+       options pagename-currency optname-price-source x))))
 
-  (gnc:options-add-price-source!
-   options gnc:pagename-general optname-price-source "e5" 'pricedb-nearest)
+  (gnc:register-trep-option
+   (gnc:make-simple-boolean-option
+    pagename-currency optname-orig-currency
+    "b" (G_ "Also show original currency amounts") #f))
 
   (gnc:options-add-currency!
-   options gnc:pagename-general optname-currency "f")
+   options pagename-currency optname-currency "c")
 
-  (gnc:register-trep-option
-   (gnc:make-simple-boolean-option
-    gnc:pagename-general optname-orig-currency
-    "f1" (G_ "Also show original currency amounts") #f))
+  (gnc:options-add-price-source!
+   options pagename-currency optname-price-source "d" 'pricedb-nearest)
 
   (gnc:register-trep-option
    (gnc:make-simple-boolean-option
@@ -1084,10 +1088,10 @@ be excluded from periodic reporting.")
           (cons 'link (opt-val gnc:pagename-display (N_ "Link")))
           (cons 'amount-single (eq? amount-setting 'single))
           (cons 'amount-double (eq? amount-setting 'double))
-          (cons 'common-currency (opt-val gnc:pagename-general optname-common-currency))
+          (cons 'common-currency (opt-val pagename-currency optname-common-currency))
           (cons 'amount-original-currency
-                (and (opt-val gnc:pagename-general optname-common-currency)
-                     (opt-val gnc:pagename-general optname-orig-currency)))
+                (and (opt-val pagename-currency optname-common-currency)
+                     (opt-val pagename-currency optname-orig-currency)))
           (cons 'indenting (opt-val pagename-sorting optname-indenting))
           (cons 'subtotals-only
                 (and (opt-val pagename-sorting optname-show-subtotals-only)
@@ -1154,8 +1158,8 @@ be excluded from periodic reporting.")
     (define exchange-fn
       (if (column-uses? 'common-currency)
           (gnc:case-exchange-time-fn
-           (opt-val gnc:pagename-general optname-price-source)
-           (opt-val gnc:pagename-general optname-currency)
+           (opt-val pagename-currency optname-price-source)
+           (opt-val pagename-currency optname-currency)
            (gnc:accounts-get-commodities c_account_1 #f) enddate #f #f)
           gnc:exchange-by-pricedb-nearest))
 
@@ -1300,7 +1304,7 @@ be excluded from periodic reporting.")
                                          (xaccSplitGetAmount s))))
            (split-currency (compose xaccAccountGetCommodity xaccSplitGetAccount))
            (row-currency (lambda (s) (if (column-uses? 'common-currency)
-                                         (opt-val gnc:pagename-general optname-currency)
+                                         (opt-val pagename-currency optname-currency)
                                          (split-currency s))))
            (friendly-debit (lambda (a) (gnc-account-get-debit-string (xaccAccountGetType a))))
            (friendly-credit (lambda (a) (gnc-account-get-credit-string (xaccAccountGetType a))))
@@ -1310,7 +1314,7 @@ be excluded from periodic reporting.")
                                 (if (column-uses? 'common-currency)
                                     (format #f " (~a)"
                                             (gnc-commodity-get-mnemonic
-                                             (opt-val gnc:pagename-general
+                                             (opt-val pagename-currency
                                                       optname-currency)))
                                     ""))))
            ;; For conversion to row-currency. Use midday as the
diff --git a/libgnucash/app-utils/options.scm b/libgnucash/app-utils/options.scm
index 5c008e108..f5fe006ba 100644
--- a/libgnucash/app-utils/options.scm
+++ b/libgnucash/app-utils/options.scm
@@ -1681,6 +1681,10 @@ the option '~a'."))
       ("Void Transactions" "Filter" "Void Transactions")
       ("Account Substring" "Filter" "Account Name Filter")
       ("Enable links" #f "Enable Links")
+      ;; trep-engine: moved currency options to own tab
+      ("Common Currency" "Currency" "Common Currency")
+      ("Show original currency amount" "Currency" "Show original currency amount")
+      ("Report's currency" "Currency" "Report's currency")
       ;; new-owner-report.scm, renamed Oct 2020 to differentiate with
       ;; Document Links:
       ("Links" #f "Transaction Links")
@@ -1708,7 +1712,7 @@ the option '~a'."))
                  (and name-match
                       (let ((new-section (car name-match))
                             (new-name (cadr name-match)))
-                        (gnc:debug
+                        (gnc:warn
                          (format #f "option ~a/~a has been renamed to ~a/~a\n"
                                  section name new-section new-name))
                         (cond

commit a8bed43dcbb93fa11962894eb23a2abd6cd97e9b
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Dec 2 07:41:12 2020 +0800

    Bug 798036 - Transaction Report should offer price source

diff --git a/gnucash/report/trep-engine.scm b/gnucash/report/trep-engine.scm
index 5e6d5fe0e..9dc469c45 100644
--- a/gnucash/report/trep-engine.scm
+++ b/gnucash/report/trep-engine.scm
@@ -76,6 +76,7 @@
 ;;General
 (define optname-startdate (N_ "Start Date"))
 (define optname-enddate (N_ "End Date"))
+(define optname-price-source (N_ "Price Source"))
 (define optname-table-export (N_ "Table for Exporting"))
 (define optname-common-currency (N_ "Common Currency"))
 (define optname-orig-currency (N_ "Show original currency amount"))
@@ -545,6 +546,9 @@ Credit Card, and Income accounts."))
       (gnc-option-db-set-option-selectable-by-name
        options gnc:pagename-general optname-orig-currency x))))
 
+  (gnc:options-add-price-source!
+   options gnc:pagename-general optname-price-source "e5" 'pricedb-nearest)
+
   (gnc:options-add-currency!
    options gnc:pagename-general optname-currency "f")
 
@@ -1051,7 +1055,7 @@ be excluded from periodic reporting.")
 ;; Here comes the big function that builds the whole table.
 
 (define (make-split-table splits options custom-calculated-cells
-                          begindate)
+                          begindate enddate c_account_1)
 
   (define (opt-val section name)
     (let ((option (gnc:lookup-option options section name)))
@@ -1145,7 +1149,15 @@ be excluded from periodic reporting.")
           (gnc-reverse-balance acc)))
 
     (define (column-uses? param)
-      (cdr (assq param used-columns)))
+      (assq-ref used-columns param))
+
+    (define exchange-fn
+      (if (column-uses? 'common-currency)
+          (gnc:case-exchange-time-fn
+           (opt-val gnc:pagename-general optname-price-source)
+           (opt-val gnc:pagename-general optname-currency)
+           (gnc:accounts-get-commodities c_account_1 #f) enddate #f #f)
+          gnc:exchange-by-pricedb-nearest))
 
     (define left-columns
       (let* ((add-if (lambda (pred? . items) (if pred? items '())))
@@ -1306,7 +1318,7 @@ be excluded from periodic reporting.")
            ;; Otherwise it uses midnight which will likely match a
            ;; price on the previous day
            (converted-amount (lambda (s)
-                               (gnc:exchange-by-pricedb-nearest
+                               (exchange-fn
                                 (gnc:make-gnc-monetary (split-currency s)
                                                        (split-amount s))
                                 (row-currency s)
@@ -2223,7 +2235,7 @@ warning will be removed in GnuCash 5.0"))
        (else
         (let-values (((table grid csvlist)
                       (make-split-table splits options custom-calculated-cells
-                                        begindate)))
+                                        begindate enddate c_account_1)))
 
           (gnc:html-document-set-title! document report-title)
 



Summary of changes:
 gnucash/report/trep-engine.scm   | 56 ++++++++++++++++++++++++++--------------
 libgnucash/app-utils/options.scm |  6 ++++-
 2 files changed, 41 insertions(+), 21 deletions(-)



More information about the gnucash-changes mailing list