Skip to content

Commit

Permalink
[trep-engine] bugfix sorting/show-account-description was not working
Browse files Browse the repository at this point in the history
also fix display code - omit " " if code is empty.
  • Loading branch information
christopherlam committed May 2, 2024
1 parent 926250a commit 2c6f150
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
17 changes: 16 additions & 1 deletion gnucash/report/reports/standard/test/test-transaction.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand All @@ -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)
Expand Down
21 changes: 8 additions & 13 deletions gnucash/report/trep-engine.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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
Expand Down

0 comments on commit 2c6f150

Please sign in to comment.