gnucash maint: [new-owner-report] for payment rows, hide empty invoice rows

Christopher Lam clam at code.gnucash.org
Wed Jan 13 08:46:19 EST 2021


Updated	 via  https://github.com/Gnucash/gnucash/commit/08d50374 (commit)
	from  https://github.com/Gnucash/gnucash/commit/e138818a (commit)



commit 08d50374c8dca9a489ca40a10958f6f99f729261
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Jan 13 21:38:16 2021 +0800

    [new-owner-report] for payment rows, hide empty invoice rows
    
    Whereby a payment covers multiple invoices, the Description column
    shows all invoice payment split memos. If memos were empty, it'd show
    multiple empty rows.
    
    This commit modifies this behaviour to skip adding <br/> into the
    Description column whereby the invoice posting split memo is empty.
    This change applies only for payment's description cells.
    
    splits->desc is also used for invoice->payments RHS list to handle
    non-document splits, and this must not skip empty memos because
    non-document splits will dump both memos and amounts.

diff --git a/gnucash/report/reports/standard/new-owner-report.scm b/gnucash/report/reports/standard/new-owner-report.scm
index 7301309e9..f22f70a07 100644
--- a/gnucash/report/reports/standard/new-owner-report.scm
+++ b/gnucash/report/reports/standard/new-owner-report.scm
@@ -301,14 +301,16 @@
 
 ;; input: list of html-text elements
 ;; output: a cell with html-text interleaved with <br> tags
-(define (list->cell lst)
+(define* (list->cell lst #:optional skip-empty?)
   (let lp ((lst lst) (result '()))
     (match lst
       (() (apply gnc:make-html-text result))
+      (("" . rest) (=> fail) (if skip-empty? (lp rest result) (fail)))
       ((elt . rest) (lp rest (cons* elt (gnc:html-markup-br) result))))))
 
-(define (splits->desc splits)
-  (list->cell (map (compose gnc:html-string-sanitize xaccSplitGetMemo) splits)))
+(define* (splits->desc splits #:optional skip-empty?)
+  (list->cell (map (compose gnc:html-string-sanitize xaccSplitGetMemo) splits)
+              skip-empty?))
 
 (define (make-aging-table splits to-date payable? date-type currency)
   (let ((table (gnc:make-html-table))
@@ -849,7 +851,7 @@
          table odd-row? used-columns date #f
          (split->reference split)
          (split->type-str split payable?)
-         (splits->desc (xaccTransGetAPARAcctSplitList txn #t))
+         (splits->desc (xaccTransGetAPARAcctSplitList txn #t) #t)
          #f currency (+ total value)
          (and (>= orig-value 0) (amount->anchor split orig-value))
          (and (< orig-value 0) (amount->anchor split (- orig-value)))



Summary of changes:
 gnucash/report/reports/standard/new-owner-report.scm | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)



More information about the gnucash-changes mailing list