gnucash maint: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Mon Mar 29 04:55:08 EDT 2021


Updated	 via  https://github.com/Gnucash/gnucash/commit/26286e2f (commit)
	 via  https://github.com/Gnucash/gnucash/commit/11475819 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/c91f0c81 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a108c550 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/4e38b685 (commit)
	from  https://github.com/Gnucash/gnucash/commit/91c1181d (commit)



commit 26286e2f6e4a7f14a64fbb99cd5f136d616b6046
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Mar 29 16:44:28 2021 +0800

    [html-acct-table] Remove 'pre-adjusting balances option
    
    'pre-adjusting was formerly handled in html-acct-table.scm; 1b41d517
    removed this balance option due to being unused for nearly 20
    years. No need to test it anymore.

diff --git a/gnucash/report/test/test-report-html.scm b/gnucash/report/test/test-report-html.scm
index 7e5b75c7c..838dacaa5 100644
--- a/gnucash/report/test/test-report-html.scm
+++ b/gnucash/report/test/test-report-html.scm
@@ -885,14 +885,4 @@ HTML Document Title</title></head><body></body>\n\
             "Income" "Income-GBP" "Expenses" "Equity")
           (sxml->table-row-col sxml 1 #f 1))))
 
-    (let* ((table (gnc:make-html-table))
-           (acct-table (gnc:make-html-acct-table/env/accts
-                        '((balance-mode pre-adjusting)
-                          (display-tree-depth 9))
-                        accounts)))
-      (gnc:html-table-add-account-balances table acct-table '())
-      (let ((sxml (table->sxml table "basic - combo 3")))
-        (test-equal "gnc:make-html-acct-table/env/accts combo 3"
-          '("Root" "Asset" "Bank" "GBP Bank" "Wallet" "Liabilities"
-            "Income" "Income-GBP" "Expenses" "Equity")
-          (sxml->table-row-col sxml 1 #f 1))))))
+    ))

commit 114758190ed299d21d5ccad884cb2ca334b33dc7
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Mar 29 15:32:22 2021 +0800

    Bugfix: export-code for category-barchart reports would fail.
    
    This stems from trying to handle file-name when calling export code.
    
    Export code no longer require file-name, The export-code returns a
    string in the html-document object instead. Remove all file-name
    handling in reports. No backward compatibility issues because most
    users would not copy a GnuCash >=4.6 report code onto a <4.5
    installation.

diff --git a/gnucash/report/reports/locale-specific/de_DE/taxtxf.scm b/gnucash/report/reports/locale-specific/de_DE/taxtxf.scm
index 7048ee854..52ede83fe 100644
--- a/gnucash/report/reports/locale-specific/de_DE/taxtxf.scm
+++ b/gnucash/report/reports/locale-specific/de_DE/taxtxf.scm
@@ -456,8 +456,7 @@
 (define (generate-tax-or-txf report-name
                              report-description
                              report-obj
-                             tax-mode?
-                             file-name)
+                             tax-mode?)
 
   (define (get-option pagename optname)
     (gnc:option-value
@@ -861,14 +860,12 @@ Gehen Sie zu Bearbeiten -> Optionen Steuerbericht, um Konten entsprechend einzur
               (G_ "This report shows your Taxable Income and \
 Deductible Expenses.")
               report-obj
-              #t
-              #f))
+              #t))
  'export-types (list (cons (G_ "XML") 'txf))
- 'export-thunk (lambda (report-obj choice file-name)
+ 'export-thunk (lambda (report-obj choice)
                  (generate-tax-or-txf
                   (G_ "Taxable Income / Deductible Expenses")
                   (G_ "This page shows your Taxable Income and \
 Deductible Expenses.")
                   report-obj
-                  #f
-                  file-name)))
+                  #f)))
diff --git a/gnucash/report/reports/locale-specific/us/taxtxf.scm b/gnucash/report/reports/locale-specific/us/taxtxf.scm
index fd33f7d15..bc4107972 100644
--- a/gnucash/report/reports/locale-specific/us/taxtxf.scm
+++ b/gnucash/report/reports/locale-specific/us/taxtxf.scm
@@ -1663,8 +1663,7 @@
 (define (generate-tax-schedule report-name
                              report-description
                              report-obj
-                             tax-mode?
-                             file-name)
+                             tax-mode?)
 
   (define (get-option pagename optname)
     (gnc:option-value
@@ -3342,14 +3341,12 @@
               (G_ "This report shows transaction detail for your accounts \
 related to Income Taxes.")
               report-obj
-              #t
-              #f))
+              #t))
  'export-types (list (cons "TXF" 'txf))
- 'export-thunk (lambda (report-obj choice file-name)
+ 'export-thunk (lambda* (report-obj choice)
                  (generate-tax-schedule
                   (G_ "Taxable Income/Deductible Expenses")
                   (G_ "This page shows transaction detail for relevant \
 Income Tax accounts.")
                   report-obj
-                  #f
-                  file-name)))
+                  #f)))
diff --git a/gnucash/report/reports/standard/category-barchart.scm b/gnucash/report/reports/standard/category-barchart.scm
index db79626f8..5b5f11e72 100644
--- a/gnucash/report/reports/standard/category-barchart.scm
+++ b/gnucash/report/reports/standard/category-barchart.scm
@@ -692,7 +692,7 @@ developing over time"))
      'menu-tip menutip
      'options-generator (lambda () (options-generator account-types inc-exp?))
      'export-types '(("CSV" . csv))
-     'export-thunk (lambda (report-obj export-type filename)
+     'export-thunk (lambda (report-obj export-type)
                      (category-barchart-renderer
                       report-obj reportname uuid account-types inc-exp? reverse-bal?
                       export-type))
diff --git a/gnucash/report/reports/standard/income-gst-statement.scm b/gnucash/report/reports/standard/income-gst-statement.scm
index 712e7338a..fe26844ba 100644
--- a/gnucash/report/reports/standard/income-gst-statement.scm
+++ b/gnucash/report/reports/standard/income-gst-statement.scm
@@ -70,7 +70,7 @@ accounts may be tagged with *EUGOODS* in the account description."))
    (gnc:html-markup-p
     (G_ "This message will be removed when tax accounts are specified."))))
 
-(define* (gst-statement-renderer rpt #:optional export-type file-name)
+(define* (gst-statement-renderer rpt #:optional export-type)
   (define (opt-val section name)
     (gnc:option-value
      (gnc:lookup-option (gnc:report-options rpt) section name)))
@@ -83,10 +83,6 @@ accounts may be tagged with *EUGOODS* in the account description."))
      #:custom-source-accounts sales-purch-accounts
      #:custom-split-filter gst-custom-split-filter
      #:export-type export-type))
-  (when file-name
-    (issue-deprecation-warning "gst-statement-renderer filename is \
-obsolete, and not supported for exports. please set html-document \
-export-string instead. this warning will be removed in GnuCash 5.0"))
   (when (null? (opt-val "Accounts" "Tax Accounts"))
     (gnc:html-document-add-object! document TAX-SETUP-DESC))
   document)
diff --git a/gnucash/report/reports/standard/net-charts.scm b/gnucash/report/reports/standard/net-charts.scm
index 1d765bb54..62ad4c6dd 100644
--- a/gnucash/report/reports/standard/net-charts.scm
+++ b/gnucash/report/reports/standard/net-charts.scm
@@ -487,7 +487,7 @@
  'options-generator (lambda () (options-generator #f #f))
  'renderer (lambda (report-obj) (net-renderer report-obj #f #f #f))
  'export-types '(("CSV" . csv))
- 'export-thunk (lambda (report-obj export-type filename)
+ 'export-thunk (lambda (report-obj export-type)
                  (net-renderer report-obj #f #f export-type)))
 
 (gnc:define-report
@@ -499,7 +499,7 @@
  'options-generator (lambda () (options-generator #t #f))
  'renderer (lambda (report-obj) (net-renderer report-obj #t #f #f))
  'export-types '(("CSV" . csv))
- 'export-thunk (lambda (report-obj export-type filename)
+ 'export-thunk (lambda (report-obj export-type)
                  (net-renderer report-obj #t #f export-type)))
 
 (gnc:define-report
@@ -510,7 +510,7 @@
  'options-generator (lambda () (options-generator #f #t))
  'renderer (lambda (report-obj) (net-renderer report-obj #f #t #f))
  'export-types '(("CSV" . csv))
- 'export-thunk (lambda (report-obj export-type filename)
+ 'export-thunk (lambda (report-obj export-type)
                  (net-renderer report-obj #f #t export-type)))
 
 ;; Not sure if a line chart makes sense for Income & Expense
@@ -524,5 +524,5 @@
  'options-generator (lambda () (options-generator #t #t))
  'renderer (lambda (report-obj) (net-renderer report-obj #t #t #f))
  'export-types '(("CSV" . csv))
- 'export-thunk (lambda (report-obj export-type filename)
+ 'export-thunk (lambda (report-obj export-type)
                  (net-renderer report-obj #t #t export-type)))
diff --git a/gnucash/report/test/test-report.scm b/gnucash/report/test/test-report.scm
index 80a24ef49..26074c3bf 100644
--- a/gnucash/report/test/test-report.scm
+++ b/gnucash/report/test/test-report.scm
@@ -160,7 +160,7 @@
    'report-guid test-uuid
    'options-generator gnc:new-options
    'export-types (list (cons "text" 'txt))
-   'export-thunk (lambda (report-obj export-type file-name)
+   'export-thunk (lambda (report-obj export-type)
                    "exported-string")
    'renderer (lambda (obj)
                (let ((options (gnc:report-options obj)))
@@ -177,7 +177,7 @@
       (gnc:report-export-types report))
     (test-equal "gnc:report-export-thunk"
       "exported-string"
-      ((gnc:report-export-thunk report) report 'csv "/tmp/file.txt"))
+      ((gnc:report-export-thunk report) report 'csv))
     (test-equal "gnc:report-menu-name"
       "basic report"
       (gnc:report-menu-name report))

commit c91f0c81f8e627e8c4a1066a1c49e8b88d50bb46
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Mar 29 14:03:09 2021 +0800

    [gnucash-cli] improve discoverability of export-type
    
    Formerly, selecting --export-type EXT would dump the cryptic "Report
    REPORTNAME has no export code". Modify to hint the user on acceptable
    reports with export-code.

diff --git a/gnucash/report/report-core.scm b/gnucash/report/report-core.scm
index f61d1a716..c310d0159 100644
--- a/gnucash/report/report-core.scm
+++ b/gnucash/report/report-core.scm
@@ -32,6 +32,7 @@
 (use-modules (ice-9 match))
 (use-modules (srfi srfi-1))
 (use-modules (srfi srfi-9))
+(use-modules (srfi srfi-26))
 (use-modules (gnucash report report-register-hooks))
 (use-modules (gnucash report html-style-sheet))
 (use-modules (gnucash report html-document))
@@ -811,6 +812,17 @@ not found.")))
 ;; gnucash-cli helper and exported functions
 ;;
 
+(define (show-selected-reports pred? port)
+  (for-each
+   (lambda (template)
+     (format port "* ~a ~a\n"
+             (if (gnc:report-template-parent-type template) "C" " ")
+             (gnc:report-template-name template)))
+   (sort (hash-fold (lambda (k v p) (if (pred? v) (cons v p) p)) '()
+                    *gnc:_report-templates_*)
+         (lambda (a b) (gnc:string-locale<? (gnc:report-template-name a)
+                                            (gnc:report-template-name b))))))
+
 (define (stderr-log tmpl . args)
   (apply format (current-error-port) tmpl args)
   #f)
@@ -825,7 +837,11 @@ not found.")))
          (export-types (gnc:report-template-export-types template)))
 
     (cond
-     ((not export-thunk) (stderr-log "Report ~s has no export code\n" report))
+     ((not export-thunk)
+      (stderr-log "Only the following reports have export code:\n")
+      (show-selected-reports (cut gnc:report-template-export-thunk <>)
+                             (current-error-port))
+      (stderr-log "Use -R show to describe report\n"))
      ((not export-types) (stderr-log "Report ~s has no export-types\n" report))
      ((not (assoc export-type export-types))
       (stderr-log "Export-type disallowed: ~a. Allowed types: ~a\n"
@@ -846,17 +862,7 @@ not found.")))
        '() *gnc:_report-templates_*)))
 
 (define-public (gnc:cmdline-report-list port)
-  (for-each
-   (lambda (template)
-     (format port "* ~a ~a\n"
-             (if (gnc:report-template-parent-type template) "C" " ")
-             (gnc:report-template-name template)))
-   (sort (hash-fold
-          (lambda (k v p) (if (gnc:report-template-in-menu? v) (cons v p) p))
-          '() *gnc:_report-templates_*)
-         (lambda (a b)
-           (gnc:string-locale<? (gnc:report-template-name a)
-                                (gnc:report-template-name b))))))
+  (show-selected-reports gnc:report-template-in-menu? port))
 
 (define-public (gnc:cmdline-report-show report port)
   (let ((templates (reportname->templates report)))

commit a108c5501daadfc6ac6e69496ed49d66e08db587
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Mar 29 10:17:53 2021 +0800

    [html-acct-table] deprecate unused functions

diff --git a/gnucash/report/html-acct-table.scm b/gnucash/report/html-acct-table.scm
index e384eca0d..29d554379 100644
--- a/gnucash/report/html-acct-table.scm
+++ b/gnucash/report/html-acct-table.scm
@@ -506,9 +506,11 @@
 
 ;; some useful predicates to export
 (define (gnc:account-code-less-p a b)
+  (issue-deprecation-warning "gnc:account-code-less-p is unused.")
   (gnc:string-locale<? (xaccAccountGetCode a)
                        (xaccAccountGetCode b)))
 (define (gnc:account-name-less-p a b)
+  (issue-deprecation-warning "gnc:account-name-less-p is unused.")
   (gnc:string-locale<? (xaccAccountGetName a)
                        (xaccAccountGetName b)))
 (define (gnc:account-path-less-p a b)

commit 4e38b685e27589d0d4346cd2d5caf5a762f97877
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Mar 29 10:17:11 2021 +0800

    [html-acct-table] remove dead code
    
    The parameters account-less-p, column-header, account-name,
    logical-depth, label-cols in html-table-add-account-balances are
    unused in code.
    
    The removal of the parameter handling will not cause crash in a custom
    report.

diff --git a/gnucash/report/html-acct-table.scm b/gnucash/report/html-acct-table.scm
index 02b851b38..e384eca0d 100644
--- a/gnucash/report/html-acct-table.scm
+++ b/gnucash/report/html-acct-table.scm
@@ -120,15 +120,6 @@
 ;;         accounts displayed. this is merely a convenience.  the
 ;;         default initial-indent is 0.
 ;; 
-;;     account-less-p: binary_predicate #t #f
-;; 
-;;         used for sorting accounts, below each parent account, into
-;;         the order in which they will be displayed.  the function
-;;         must take two Account arguments and represent a total
-;;         ordering on Account-space.  #t means to use the default
-;;         sorting function.  #f means to perform no sorting.  the
-;;         default sorting function is gnc:account-code-less-p.
-;; 
 ;;     start-date: time64
 ;; 
 ;;         the starting date of the reporting period over which to
@@ -188,17 +179,6 @@
 ;;         the html-acct-table object without crashing.  Just don't
 ;;         count on meaningful report-comm-{account|recursive}-bal
 ;;         values (they'll also be #f).]
-;;
-;;     column-header: html-table-header-cell #f #t
-;; 
-;;          the table column header cell (TH tag) with which to head
-;;          the columns containing the account tree.  if supplied, the
-;;          header cell may contain style information.  if #f, no
-;;          column header cell will be used.  if #t, a default header
-;;          cell (reading "Account") will be used.  the colspan of any
-;;          header cell will be automatically set appropriately. this
-;;          is for convenience only; gnc:html-acct-table does not use
-;;          this data.
 ;; 
 ;;     account-label-mode: 'name 'anchor
 ;; 
@@ -278,12 +258,6 @@
 ;;         the name of the account is "Assets:Current Assets:Cash",
 ;;         the value will be "Assets:Current Assets:Cash".
 ;; 
-;;     account-name: string
-;; 
-;;         the "basename" of the account in the current row. i.e., if
-;;         the name of the account is "Assets:Current Assets:Cash",
-;;         the value will be "Cash".
-;; 
 ;;     account-code: string
 ;; 
 ;;         the account of the account in the current row, as returned
@@ -310,14 +284,6 @@
 ;;         unlike in gnc:html-build-acct-table, the first level of
 ;;         accounts is level 0.
 ;; 
-;;     logical-depth: integer
-;; 
-;;         the depth at which the account in the current row resides
-;;         in the effective account tree.  this is the depth the
-;;         account tree when ignoring unselected parent accounts.
-;;         note that this may differ from account-depth when a
-;;         selected account has an unselected ancestor.
-;; 
 ;;     display-depth: integer
 ;; 
 ;;         the depth at which the account in the current row resides
@@ -339,13 +305,6 @@
 ;; 
 ;;         the number of columns in which account labels were placed.
 ;; 
-;;     label-cols: integer
-;; 
-;;         the number of columns in the group of account columns to
-;;         which a row was assigned.  also one more than the maximum
-;;         column depth at which rows were positioned in the
-;;         table.
-;; 
 ;;     account-cols: integer
 ;; 
 ;;         the number of columns in the group of account columns.  if
@@ -588,8 +547,6 @@
                         (and (number? lim) lim)))
 	 (limit-behavior (or (get-val env 'depth-limit-behavior) 'summarize))
 	 (indent (or (get-val env 'initial-indent) 0))
-	 (less-p (let ((pred (get-val env 'account-less-p)))
-		   (if (eq? pred #t) gnc:account-code-less-p pred)))
 	 (start-date (get-val env 'start-date))
 	 (end-date (or (get-val env 'end-date)
 		       (gnc:get-today)))
@@ -599,13 +556,8 @@
          ;; someone was thinking price-source?
 	 (exchange-fn (get-val env 'exchange-fn))
          (get-balance-fn (get-val env 'get-balance-fn))
-	 (column-header (let ((cell (get-val env 'column-header)))
-			  (if (eq? cell #t)
-			      (gnc:make-html-table-cell "Account name")
-			      cell)))
 	 (subtotal-mode (get-val env 'parent-account-subtotal-mode))
-	 (zero-mode (let ((mode (get-val env 'zero-balance-mode)))
-		      (if (boolean? mode) 'show-leaf-acct mode)))
+	 (zero-mode (get-val env 'zero-balance-mode))
 	 (label-mode (or (get-val env 'account-label-mode) 'anchor))
 	 (balance-mode (or (get-val env 'balance-mode) 'post-closing))
 	 (closing-pattern (or (get-val env 'closing-pattern)
@@ -697,7 +649,7 @@
            (gnc:accounts-and-all-descendants (list account)))
           this-collector))
 
-      (let lp ((accounts (if less-p (sort accts less-p) accts))
+      (let lp ((accounts accts)
                (row-added? #f)
                (disp-depth (if (integer? depth-limit)
                                (min (1- depth-limit) logi-depth)
@@ -727,7 +679,6 @@
                   (cons*
                    (list 'initial-indent indent)
                    (list 'account acct)
-                   (list 'account-name (xaccAccountGetName acct))
                    (list 'account-code (xaccAccountGetCode acct))
                    (list 'account-type (xaccAccountGetType acct))
                    (list 'account-type-string (xaccAccountGetTypeStr
@@ -995,13 +946,10 @@
 		  (acct (get-val env 'account))
 		  (children (get-val env 'account-children))
 		  (label (get-val env 'account-label))
-		  (acct-name (get-val env 'account-name)) ;; for diagnostics...
 		  (report-commodity  (get-val env 'report-commodity))
 		  (exchange-fn (get-val env 'exchange-fn))
 		  (account-cols (get-val env 'account-cols))
 		  (logical-cols (get-val env 'logical-cols))
-		  (label-cols (get-val env 'label-cols))
-		  (logical-depth (get-val env 'logical-depth))
 		  (display-depth (get-val env 'display-depth))
 		  (display-tree-depth (get-val env 'display-tree-depth))
 		  (subtotal-mode (get-val env 'subtotal-mode))
@@ -1029,10 +977,7 @@
                          ((not (null? children)) parent-acct-bal-mode)
                          (else 'immediate-bal)))
 
-                  (zero-mode (let ((mode (get-val env 'zero-balance-display-mode)))
-                               (if (boolean? mode)
-                                   'show-balance
-                                   mode)))
+                  (zero-mode (get-val env 'zero-balance-display-mode))
 
                   (amt (and-let* ((bal-syms '((immediate-bal . account-bal)
                                               (recursive-bal . recursive-bal)



Summary of changes:
 gnucash/report/html-acct-table.scm                 | 63 ++--------------------
 gnucash/report/report-core.scm                     | 30 ++++++-----
 .../reports/locale-specific/de_DE/taxtxf.scm       | 11 ++--
 .../report/reports/locale-specific/us/taxtxf.scm   | 11 ++--
 .../report/reports/standard/category-barchart.scm  |  2 +-
 .../reports/standard/income-gst-statement.scm      |  6 +--
 gnucash/report/reports/standard/net-charts.scm     |  8 +--
 gnucash/report/test/test-report-html.scm           | 12 +----
 gnucash/report/test/test-report.scm                |  4 +-
 9 files changed, 40 insertions(+), 107 deletions(-)



More information about the gnucash-changes mailing list