[average-balance] show monetaries instead of numbers in data table

instead of numbers, show monetary amounts, rounded to SCU
This commit is contained in:
Christopher Lam 2019-10-09 20:42:26 +08:00
parent ef3bc616b2
commit 662d29d664
2 changed files with 18 additions and 10 deletions

View File

@ -486,7 +486,8 @@
;; make a table (optionally)
(gnc:report-percent-done 80)
(if show-table?
(let ((table (gnc:make-html-table)))
(let ((table (gnc:make-html-table))
(scu (gnc-commodity-get-fraction report-currency)))
(gnc:html-table-set-col-headers!
table columns)
(for-each
@ -498,7 +499,14 @@
(list "date-cell" "date-cell"
"number-cell" "number-cell" "number-cell"
"number-cell" "number-cell" "number-cell")
row)))
(cons* (car row)
(cadr row)
(map
(lambda (amt)
(gnc:make-gnc-monetary
report-currency
(gnc-numeric-convert amt scu GNC-RND-ROUND)))
(cddr row))))))
data)
(gnc:html-document-add-object! document table))))

View File

@ -67,35 +67,35 @@
(let* ((options (default-testing-options))
(sxml (options->sxml options "default")))
(test-equal "averages"
'("0.00" "50.00" "100.00" "150.00" "200.00" "200.00")
'("$0.00" "$50.00" "$100.00" "$150.00" "$200.00" "$200.00")
(get-row-col sxml #f 3))
(test-equal "maximums"
'("0.00" "100.00" "100.00" "200.00" "200.00" "200.00")
'("$0.00" "$100.00" "$100.00" "$200.00" "$200.00" "$200.00")
(get-row-col sxml #f 4))
(test-equal "minimums"
'("0.00" "0.00" "100.00" "100.00" "200.00" "200.00")
'("$0.00" "$0.00" "$100.00" "$100.00" "$200.00" "$200.00")
(get-row-col sxml #f 5))
(test-equal "net"
'("0.00" "100.00" "0.00" "100.00" "0.00" "0.00")
'("$0.00" "$100.00" "$0.00" "$100.00" "$0.00" "$0.00")
(get-row-col sxml #f 8)))
(env-transfer env 15 03 1979 bank bank2 25)
(let* ((options (default-testing-options))
(sxml (options->sxml options "include-internal")))
(test-equal "gains-include-internal"
'("0.00" "100.00" "25.00" "100.00" "0.00" "0.00")
'("$0.00" "$100.00" "$25.00" "$100.00" "$0.00" "$0.00")
(get-row-col sxml #f 6))
(test-equal "loss-include-internal"
'("0.00" "0.00" "25.00" "0.00" "0.00" "0.00")
'("$0.00" "$0.00" "$25.00" "$0.00" "$0.00" "$0.00")
(get-row-col sxml #f 7)))
(let* ((options (default-testing-options)))
(set-option! options "Accounts" "Exclude transactions between selected accounts" #t)
(let ((sxml (options->sxml options "exclude-internal")))
(test-equal "gain-exclude-internal"
'("0.00" "100.00" "0.00" "100.00" "0.00" "0.00")
'("$0.00" "$100.00" "$0.00" "$100.00" "$0.00" "$0.00")
(get-row-col sxml #f 6))
(test-equal "loss-exclude-internal"
'("0.00" "0.00" "0.00" "0.00" "0.00" "0.00")
'("$0.00" "$0.00" "$0.00" "$0.00" "$0.00" "$0.00")
(get-row-col sxml #f 7))))
(teardown)))