gnucash maint: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Mon Jan 9 00:33:05 EST 2023


Updated	 via  https://github.com/Gnucash/gnucash/commit/f081a206 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/afc32af5 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/5af82139 (commit)
	from  https://github.com/Gnucash/gnucash/commit/5e8de30b (commit)



commit f081a2066eeda6817f9b8e99d30b1e4449edb9a6
Merge: 5e8de30b0 afc32af52
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Jan 9 13:32:29 2023 +0800

    Merge branch 'maint-progress' into maint #1493


commit afc32af52171feec031947bb5b070c96d5521f01
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Jan 8 23:54:03 2023 +0800

    [balsheet-pnl] move out of experimental into regular menu
    
    After 4 years it can finally graduate. Also remove FOOTER-TEXT
    warning.

diff --git a/gnucash/report/reports/standard/balsheet-pnl.scm b/gnucash/report/reports/standard/balsheet-pnl.scm
index 2c082a7b0..e1f5d2b44 100644
--- a/gnucash/report/reports/standard/balsheet-pnl.scm
+++ b/gnucash/report/reports/standard/balsheet-pnl.scm
@@ -47,13 +47,6 @@
   (split-balance-with-closing col-datum-get-split-balance-with-closing)
   (split-value-balance col-datum-get-split-value-balance))
 
-(define FOOTER-TEXT
-  (gnc:make-html-text
-   (G_ "WARNING: Foreign currency conversions, and unrealized gains
-calculations are not confirmed correct. This report may be modified
-without notice. Bug reports are very welcome at
-https://bugs.gnucash.org/")))
-
 ;; define all option's names and help text so that they are properly
 
 (define optname-startdate (N_ "Start Date"))
@@ -1285,9 +1278,6 @@ also show overall period profit & loss."))
       (gnc:html-document-add-object!
        doc multicol-table))
 
-    (gnc:html-document-add-object!
-     doc FOOTER-TEXT)
-
     (gnc:report-finished)
     ;; (gnc:html-document-set-style-text!
     ;;  doc " table, td{ border-width: 1px; border-style:solid; border-color: lightgray; border-collapse: collapse}")
@@ -1300,7 +1290,7 @@ also show overall period profit & loss."))
  'version 1
  'name balsheet-reportname
  'report-guid "065d5d5a77ba11e8b31e83ada73c5eea"
- 'menu-path (list gnc:menuname-experimental)
+ 'menu-path (list gnc:menuname-asset-liability)
  'options-generator (lambda () (multicol-report-options-generator 'balsheet))
  'renderer (lambda (rpt) (multicol-report-renderer rpt 'balsheet)))
 
@@ -1308,7 +1298,7 @@ also show overall period profit & loss."))
  'version 1
  'name pnl-reportname
  'report-guid "0e94fd0277ba11e8825d43e27232c9d4"
- 'menu-path (list gnc:menuname-experimental)
+ 'menu-path (list gnc:menuname-income-expense)
  'options-generator (lambda () (multicol-report-options-generator 'pnl))
  'renderer (lambda (rpt) (multicol-report-renderer rpt 'pnl)))
 

commit 5af8213951e3a9c9806187d215bc9f00118118b2
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Jan 8 23:03:15 2023 +0800

    [balsheet-pnl] generate exchange-fn for each date separately
    
    and cache its result

diff --git a/gnucash/report/reports/standard/balsheet-pnl.scm b/gnucash/report/reports/standard/balsheet-pnl.scm
index a1d1aaa66..2c082a7b0 100644
--- a/gnucash/report/reports/standard/balsheet-pnl.scm
+++ b/gnucash/report/reports/standard/balsheet-pnl.scm
@@ -769,11 +769,17 @@ also show overall period profit & loss."))
               (cons acc (map col-datum-get-split-balance-with-closing cols-data))))
            accounts-cols-data))
 
-         (exchange-fn (and common-currency
-                           (gnc:case-exchange-time-fn
-                            price-source common-currency
-                            (map xaccAccountGetCommodity accounts) enddate
-                            #f #f)))
+         ;; generate an exchange-fn for date, and cache its result.
+         (get-date-exchange-fn
+          (let ((h (make-hash-table)))
+            (lambda (date)
+              (or (hashv-ref h date)
+                  (let ((exchangefn (gnc:case-exchange-time-fn
+                                     price-source common-currency
+                                     (map xaccAccountGetCommodity accounts)
+                                     date #f #f)))
+                    (hashv-set! h date exchangefn)
+                    exchangefn)))))
 
          ;; from col-idx, find effective date to retrieve pricedb
          ;; entry or to limit transactions to calculate average-cost
@@ -799,9 +805,9 @@ also show overall period profit & loss."))
                        (gnc:gnc-monetary-commodity monetary)
                        common-currency))
                  (has-price? (gnc:gnc-monetary-commodity monetary))
-                 (exchange-fn
-                  monetary common-currency
-                  (col-idx->price-date col-idx)))))
+                 (let* ((col-date (col-idx->price-date col-idx))
+                        (exchange-fn (get-date-exchange-fn col-date)))
+                   (exchange-fn monetary common-currency col-date)))))
 
          ;; the following function generates an gnc:html-text object
          ;; to dump exchange rate for a particular column. From the



Summary of changes:
 gnucash/report/reports/standard/balsheet-pnl.scm | 36 +++++++++++-------------
 1 file changed, 16 insertions(+), 20 deletions(-)



More information about the gnucash-changes mailing list