gnucash stable: [trep-engine] bugfix sorting/show-account-description was not working
Christopher Lam
clam at code.gnucash.org
Thu May 2 01:09:17 EDT 2024
Updated via https://github.com/Gnucash/gnucash/commit/2c6f1509 (commit)
from https://github.com/Gnucash/gnucash/commit/926250af (commit)
commit 2c6f15090a5f22b5129a74f3581d2758690a45e1
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Thu May 2 07:04:32 2024 +0800
[trep-engine] bugfix sorting/show-account-description was not working
also fix display code - omit " " if code is empty.
diff --git a/gnucash/report/reports/standard/test/test-transaction.scm b/gnucash/report/reports/standard/test/test-transaction.scm
index 214d554895..69ea922bfb 100644
--- a/gnucash/report/reports/standard/test/test-transaction.scm
+++ b/gnucash/report/reports/standard/test/test-transaction.scm
@@ -141,6 +141,10 @@
(set-option! options "Display" "Amount" 'single)
options))
+ ;; to test Sorting/Show Account Description
+ (xaccAccountSetDescription income "Salaries etc")
+ (xaccAccountSetCode expense "EXP-001")
+
;; This will make all accounts use default currency (I think depends on locale)
(for-each
(lambda(pair)
@@ -788,7 +792,8 @@
(set-option! options "Sorting" "Secondary Key" 'date)
(set-option! options "Sorting" "Secondary Subtotal for Date Key" 'quarterly)
(set-option! options "Sorting" "Show Informal Debit/Credit Headers" #t)
- (set-option! options "Sorting" "Show Account Description" #t)
+ (set-option! options "Sorting" "Show Account Description" #f)
+ (set-option! options "Sorting" "Show Account Code" #f)
(let* ((sxml (options->sxml options "sorting=date, friendly headers")))
(test-equal "expense acc friendly headers"
'("Expenses" "Expense" "Rebate")
@@ -797,6 +802,16 @@
'("Income" "Charge" "Income")
(get-row-col sxml 91 #f)))
+ (set-option! options "Sorting" "Show Account Description" #t)
+ (set-option! options "Sorting" "Show Account Code" #t)
+ (let* ((sxml (options->sxml options "sorting=date, friendly headers with acct desc/code")))
+ (test-equal "expense acc friendly headers"
+ '("EXP-001 Expenses" "Expense" "Rebate")
+ (get-row-col sxml 69 #f))
+ (test-equal "income acc friendly headers"
+ '("Income: Salaries etc" "Charge" "Income")
+ (get-row-col sxml 91 #f)))
+
(set-option! options "Accounts" "Accounts" (list bank))
(set-option! options "Display" "Grand Total" #f)
(set-option! options "Sorting" "Show subtotals only (hide transactional data)" #t)
diff --git a/gnucash/report/trep-engine.scm b/gnucash/report/trep-engine.scm
index 8115a4c876..548115a7df 100644
--- a/gnucash/report/trep-engine.scm
+++ b/gnucash/report/trep-engine.scm
@@ -1749,8 +1749,10 @@ be excluded from periodic reporting.")
(with-output-to-string
(lambda ()
(when show-account-code?
- (display (xaccAccountGetCode account))
- (display " "))
+ (let ((code (xaccAccountGetCode account)))
+ (unless (string-null? code)
+ (display code)
+ (display " "))))
(when show-account-name?
(display
(if show-account-full-name?
@@ -1768,17 +1770,10 @@ be excluded from periodic reporting.")
(name (account-namestring account
(report-uses? 'sort-account-code)
#t
- (report-uses? 'sort-account-full-name)))
- (description (if (and (report-uses? 'sort-account-description)
- (not (string-null?
- (xaccAccountGetDescription account))))
- (string-append ": " (xaccAccountGetDescription account))
- "")))
- (if (and anchor? (report-uses? 'links)
- (pair? account)) ;html anchor for 2-split transactions only
- (gnc:make-html-text
- (gnc:html-markup-anchor (gnc:account-anchor-text account) name)
- description)
+ (report-uses? 'sort-account-full-name))))
+ (if (and (report-uses? 'sort-account-description)
+ (not (string-null? (xaccAccountGetDescription account))))
+ (string-append name ": " (xaccAccountGetDescription account))
name)))
;; generic renderer. retrieve renderer-fn which should return a str
Summary of changes:
.../reports/standard/test/test-transaction.scm | 17 ++++++++++++++++-
gnucash/report/trep-engine.scm | 21 ++++++++-------------
2 files changed, 24 insertions(+), 14 deletions(-)
More information about the gnucash-changes
mailing list