Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 798461 - balance sheet shows positions with zero balances despite report options #1609

Merged
merged 1 commit into from
Apr 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions gnucash/report/html-acct-table.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,8 @@
(omit-bal . #f)))
(bal-sym (assq-ref bal-syms bal-method))
(comm-amt (get-val env bal-sym)))
(when (eq? zero-mode 'omit-balance)
(comm-amt 'remove-zeros #f #f))
(cond
((and (eq? zero-mode 'omit-balance)
(gnc-commodity-collector-allzero? comm-amt)) #f)
Expand Down
3 changes: 3 additions & 0 deletions gnucash/report/report-utilities.scm
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@
(total (if pair ((cadr pair) 'total #f) 0)))
(gnc:make-gnc-monetary c (if sign? (- total) total))))

(define (not-zero? l) (not (zero? ((cadr l) 'total #f))))

;; Dispatch function
(lambda (action commodity amount)
(case action
Expand All @@ -377,6 +379,7 @@
((reset) (set! commoditylist '()))
((getpair) (getpair commodity amount))
((getmonetary) (getmonetary commodity amount))
((remove-zeros) (set! commoditylist (filter not-zero? commoditylist)))
((list) commoditylist) ; this one is only for internal use
(else (gnc:warn "bad commodity-collector action: " action))))))

Expand Down
11 changes: 11 additions & 0 deletions gnucash/report/test/test-report-utilities.scm
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,17 @@
(coll-A 'add GBP -1)
(test-equal "gnc-commodity-collector does not round inappropriately"
'(("GBP" . 0))
(collector->list coll-A))

;; the following tests the remove-zeros action
(coll-A 'add USD 1)
(coll-A 'add EUR 0)
(test-equal "gnc-commodity-collector before remove-zeros"
'(("EUR" . 0) ("USD" . 1) ("GBP" . 0))
(collector->list coll-A))
(coll-A 'remove-zeros #f #f)
(test-equal "gnc-commodity-collector after remove-zeros"
'(("USD" . 1))
(collector->list coll-A)))
(teardown)))

Expand Down