Bug 797982 - exchange rates' decimal places

use gnc:html-make-rates-table instead of gnc:html-make-exchangerates
to show effective exchange rate or price used
This commit is contained in:
Christopher Lam 2020-10-19 22:29:59 +08:00
parent 4ff3355f02
commit 89c0baee9b
8 changed files with 28 additions and 20 deletions

View File

@ -315,6 +315,7 @@
(gnc:get-current-account-tree-depth) (gnc:get-current-account-tree-depth)
depth-limit)) depth-limit))
;; exchange rates calculation parameters ;; exchange rates calculation parameters
(price-fn (gnc:case-price-fn price-source report-commodity to-date))
(exchange-fn (gnc:case-exchange-fn price-source report-commodity to-date))) (exchange-fn (gnc:case-exchange-fn price-source report-commodity to-date)))
(gnc:html-document-set-title! (gnc:html-document-set-title!
@ -441,8 +442,8 @@
;; add currency information ;; add currency information
(when show-rates? (when show-rates?
(gnc:html-document-add-object! (gnc:html-document-add-object!
doc (gnc:html-make-exchangerates doc (gnc:html-make-rates-table
report-commodity exchange-fn report-commodity price-fn
(gnc:accounts-and-all-descendants accounts)))))) (gnc:accounts-and-all-descendants accounts))))))
(gnc:report-finished) (gnc:report-finished)

View File

@ -343,6 +343,7 @@
(tree-depth (if (eq? depth-limit 'all) (tree-depth (if (eq? depth-limit 'all)
(gnc:get-current-account-tree-depth) (gnc:get-current-account-tree-depth)
depth-limit)) depth-limit))
(price-fn (gnc:case-price-fn price-source report-commodity reportdate))
;; exchange rates calculation parameters ;; exchange rates calculation parameters
(exchange-fn (exchange-fn
(gnc:case-exchange-fn price-source report-commodity reportdate))) (gnc:case-exchange-fn price-source report-commodity reportdate)))
@ -550,7 +551,7 @@
(gnc:report-percent-done 90) (gnc:report-percent-done 90)
(when show-rates? (when show-rates?
(gnc:html-document-add-object! (gnc:html-document-add-object!
doc (gnc:html-make-exchangerates report-commodity exchange-fn accounts))) doc (gnc:html-make-rates-table report-commodity price-fn accounts)))
(gnc:report-percent-done 100))) (gnc:report-percent-done 100)))

View File

@ -355,7 +355,8 @@
;; exchange rates calculation parameters ;; exchange rates calculation parameters
(exchange-fn (exchange-fn
(gnc:case-exchange-fn price-source report-commodity date-t64)) (gnc:case-exchange-fn price-source report-commodity date-t64))
)
(price-fn (gnc:case-price-fn price-source report-commodity date-t64)))
(define (add-subtotal-line table pos-label neg-label signed-balance) (define (add-subtotal-line table pos-label neg-label signed-balance)
(let* ((neg? (and signed-balance neg-label (let* ((neg? (and signed-balance neg-label
@ -808,8 +809,7 @@
(if show-rates? (if show-rates?
(gnc:html-document-add-object! (gnc:html-document-add-object!
doc ;;(gnc:html-markup-p) doc ;;(gnc:html-markup-p)
(gnc:html-make-exchangerates (gnc:html-make-rates-table report-commodity price-fn accounts)))
report-commodity exchange-fn accounts)))
(gnc:report-percent-done 100))))) (gnc:report-percent-done 100)))))
(gnc:report-finished) (gnc:report-finished)

View File

@ -401,7 +401,8 @@
;; exchange rates calculation parameters ;; exchange rates calculation parameters
(exchange-fn (exchange-fn
(gnc:case-exchange-fn price-source report-commodity date-t64)) (gnc:case-exchange-fn price-source report-commodity date-t64))
)
(price-fn (gnc:case-price-fn price-source report-commodity date-t64)))
(define (add-subtotal-line table pos-label neg-label signed-balance) (define (add-subtotal-line table pos-label neg-label signed-balance)
(let* ((neg? (and signed-balance neg-label (let* ((neg? (and signed-balance neg-label
@ -595,7 +596,7 @@
(gnc:report-percent-done 90) (gnc:report-percent-done 90)
(when show-rates? (when show-rates?
(gnc:html-document-add-object! (gnc:html-document-add-object!
doc (gnc:html-make-exchangerates report-commodity exchange-fn accounts))) doc (gnc:html-make-rates-table report-commodity price-fn accounts)))
(gnc:report-percent-done 100)))) (gnc:report-percent-done 100))))
(gnc:report-finished) (gnc:report-finished)

View File

@ -149,6 +149,8 @@
(exchange-fn (gnc:case-exchange-fn (exchange-fn (gnc:case-exchange-fn
price-source report-currency to-date-t64)) price-source report-currency to-date-t64))
(price-fn (gnc:case-price-fn price-source report-currency to-date-t64))
(doc (gnc:make-html-document)) (doc (gnc:make-html-document))
(table (gnc:make-html-table)) (table (gnc:make-html-table))
@ -321,8 +323,8 @@
(if show-rates? (if show-rates?
(gnc:html-document-add-object! (gnc:html-document-add-object!
doc ;;(gnc:html-markup-p doc ;;(gnc:html-markup-p
(gnc:html-make-exchangerates (gnc:html-make-rates-table
report-currency exchange-fn accounts)))))) report-currency price-fn accounts))))))
;; error condition: no accounts specified ;; error condition: no accounts specified

View File

@ -280,7 +280,9 @@
(end-exchange-fn (end-exchange-fn
(gnc:case-exchange-fn (gnc:case-exchange-fn
price-source report-commodity end-date)) price-source report-commodity end-date))
)
(start-price-fn (gnc:case-price-fn price-source report-commodity start-date))
(end-price-fn (gnc:case-price-fn price-source report-commodity end-date)))
(define (unrealized-gains-at-date book-balance exchange-fn date) (define (unrealized-gains-at-date book-balance exchange-fn date)
(define cost-fn (define cost-fn
@ -496,10 +498,10 @@
(headers (list (headers (list
(qof-print-date start-date-printable) (qof-print-date start-date-printable)
(qof-print-date end-date))) (qof-print-date end-date)))
(then (gnc:html-make-exchangerates (then (gnc:html-make-rates-table
report-commodity start-exchange-fn accounts)) report-commodity start-price-fn accounts))
(now (gnc:html-make-exchangerates (now (gnc:html-make-rates-table
report-commodity end-exchange-fn accounts))) report-commodity end-price-fn accounts)))
(gnc:html-table-set-col-headers! curr-tbl headers) (gnc:html-table-set-col-headers! curr-tbl headers)
(gnc:html-table-set-style! (gnc:html-table-set-style!
curr-tbl "table" 'attribute '("border" "1")) curr-tbl "table" 'attribute '("border" "1"))

View File

@ -382,7 +382,7 @@
;; exchange rates calculation parameters ;; exchange rates calculation parameters
(exchange-fn (exchange-fn
(gnc:case-exchange-fn price-source report-commodity end-date)) (gnc:case-exchange-fn price-source report-commodity end-date))
) (price-fn (gnc:case-price-fn price-source report-commodity end-date)))
;; Wrapper to call gnc:html-table-add-labeled-amount-line! ;; Wrapper to call gnc:html-table-add-labeled-amount-line!
;; with the proper arguments. ;; with the proper arguments.
@ -561,8 +561,8 @@
(gnc:report-percent-done 90) (gnc:report-percent-done 90)
(when show-rates? (when show-rates?
(gnc:html-document-add-object! (gnc:html-document-add-object!
doc (gnc:html-make-exchangerates doc (gnc:html-make-rates-table
report-commodity exchange-fn accounts))) report-commodity price-fn accounts)))
(gnc:report-percent-done 100))) (gnc:report-percent-done 100)))
(gnc:report-finished) (gnc:report-finished)

View File

@ -401,6 +401,7 @@
;; exchange rates calculation parameters ;; exchange rates calculation parameters
(exchange-fn (exchange-fn
(gnc:case-exchange-fn price-source report-commodity end-date)) (gnc:case-exchange-fn price-source report-commodity end-date))
(price-fn (gnc:case-price-fn price-source report-commodity end-date))
(period-for (string-append " " (G_ "for Period")))) (period-for (string-append " " (G_ "for Period"))))
(gnc:html-document-set-title! (gnc:html-document-set-title!
@ -894,8 +895,8 @@
(if show-rates? (if show-rates?
(gnc:html-document-add-object! (gnc:html-document-add-object!
doc doc
(gnc:html-make-exchangerates (gnc:html-make-rates-table
report-commodity exchange-fn accounts))) report-commodity price-fn accounts)))
(gnc:report-percent-done 100))) (gnc:report-percent-done 100)))
(gnc:report-finished) (gnc:report-finished)