mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug 797743 - Monetary amounts are occasionally rendered in fractions
If monetary is already in decimal, don't convert. If monetary is exact (x/y) then convert to its SCU. As a result, monetary amounts in an arbitrary precision will be displayed unchanged, e.g. US$0.1442, whereas exact monetary amounts will be displayed using the currency's SCU e.g. US$1/3 -> $0.33
This commit is contained in:
@@ -267,9 +267,13 @@
|
||||
(xaccPrintAmount datum (gnc-default-print-info #f)))
|
||||
|
||||
(define (gnc:default-html-gnc-monetary-renderer datum params)
|
||||
(xaccPrintAmount
|
||||
(gnc:gnc-monetary-amount datum)
|
||||
(gnc-commodity-print-info (gnc:gnc-monetary-commodity datum) #t)))
|
||||
(let* ((comm (gnc:gnc-monetary-commodity datum))
|
||||
(scu (gnc-commodity-get-fraction comm))
|
||||
(amount (gnc:gnc-monetary-amount datum))
|
||||
(amt-display (if (exact? amount)
|
||||
(gnc-numeric-convert amount scu GNC-HOW-RND-ROUND)
|
||||
amount)))
|
||||
(xaccPrintAmount amt-display (gnc-commodity-print-info comm #t))))
|
||||
|
||||
(define (gnc:default-html-number-renderer datum params)
|
||||
(xaccPrintAmount
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
(set-option! options "General" "Price Source" 'weighted-average)
|
||||
(let ((sxml (options->sxml portfolio-uuid options "'weighted-average")))
|
||||
(test-equal "portfolio: weighted-average"
|
||||
'("AAPL" "AAPL" "NASDAQ" "1.00" "$233.33" "$233 + 1/3")
|
||||
'("AAPL" "AAPL" "NASDAQ" "1.00" "$233.33" "$233.33")
|
||||
(sxml->table-row-col sxml 1 1 #f))))
|
||||
(teardown)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user