TP->T64: gnucash/report/standard-reports/price-scatter.scm

This commit is contained in:
Christopher Lam 2017-11-21 06:50:52 +08:00
parent bca83e8480
commit b2eb687c37

View File

@ -140,14 +140,14 @@
(gnc:make-gnc-monetary c n))) (gnc:make-gnc-monetary c n)))
(let* ((to-date-tp (gnc:timepair-end-day-time (let* ((to-date (gnc:time64-end-day-time
(gnc:date-option-absolute-time (gnc:date-option-absolute-time
(get-option gnc:pagename-general (get-option gnc:pagename-general
optname-to-date)))) optname-to-date))))
(from-date-tp (gnc:timepair-start-day-time (from-date (gnc:time64-start-day-time
(gnc:date-option-absolute-time (gnc:date-option-absolute-time
(get-option gnc:pagename-general (get-option gnc:pagename-general
optname-from-date)))) optname-from-date))))
(interval (get-option gnc:pagename-general optname-stepsize)) (interval (get-option gnc:pagename-general optname-stepsize))
(report-title (get-option gnc:pagename-general (report-title (get-option gnc:pagename-general
gnc:optname-reportname)) gnc:optname-reportname))
@ -168,9 +168,9 @@
optname-price-source)) optname-price-source))
(dates-list (gnc:make-date-list (dates-list (gnc:make-date-list
(gnc:timepair-end-day-time from-date-tp) (gnc:time64-end-day-time from-date)
(gnc:timepair-end-day-time to-date-tp) (gnc:time64-end-day-time to-date)
(gnc:deltasym-to-delta interval))) (gnc:deltasym-to-delta interval)))
(document (gnc:make-html-document)) (document (gnc:make-html-document))
(chart (gnc:make-html-scatter)) (chart (gnc:make-html-scatter))
@ -200,8 +200,8 @@
" - " " - "
(sprintf #f (sprintf #f
(_ "%s to %s") (_ "%s to %s")
(gnc-print-date from-date-tp) (qof-print-date from-date)
(gnc-print-date to-date-tp)))) (qof-print-date to-date))))
(gnc:html-scatter-set-width! chart width) (gnc:html-scatter-set-width! chart width)
(gnc:html-scatter-set-height! chart height) (gnc:html-scatter-set-height! chart height)
(gnc:html-scatter-set-marker! chart (gnc:html-scatter-set-marker! chart
@ -241,15 +241,15 @@
(case price-source (case price-source
((actual-transactions) ((actual-transactions)
(gnc:get-commodity-inst-prices (gnc:get-commodity-inst-prices
currency-accounts to-date-tp currency-accounts to-date
price-commodity report-currency)) price-commodity report-currency))
((weighted-average) ((weighted-average)
(gnc:get-commodity-totalavg-prices (gnc:get-commodity-totalavg-prices
currency-accounts to-date-tp currency-accounts to-date
price-commodity report-currency)) price-commodity report-currency))
((pricedb) ((pricedb)
(map (lambda (p) (map (lambda (p)
(list (gnc-price-get-time p) (list (gnc-price-get-time64 p)
(gnc-price-get-value p))) (gnc-price-get-value p)))
(gnc-pricedb-get-prices (gnc-pricedb-get-prices
(gnc-pricedb-get-db (gnc-get-current-book)) (gnc-pricedb-get-db (gnc-get-current-book))
@ -259,13 +259,13 @@
(set! data (filter (set! data (filter
(lambda (x) (lambda (x)
(and (and
(gnc:timepair-ge to-date-tp (first x)) (>= to-date (first x))
(gnc:timepair-ge (first x) from-date-tp))) (>= (first x) from-date)))
data)) data))
;; some output ;; some output
;;(warn "data" (map (lambda (x) (list ;;(warn "data" (map (lambda (x) (list
;; (gnc-print-date (car x)) ;; (qof-print-date x)
;; (gnc-numeric-to-double (second x)))) ;; (gnc-numeric-to-double (second x))))
;; data)) ;; data))
@ -285,8 +285,8 @@
(set! data (set! data
(map (lambda (x) (map (lambda (x)
(list (list
(/ (- (car (first x)) (/ (- (first x)
(car from-date-tp)) from-date)
;; FIXME: These hard-coded values are more ;; FIXME: These hard-coded values are more
;; or less totally bogus. OTOH this whole ;; or less totally bogus. OTOH this whole
;; scaling thing is totally bogus as well, ;; scaling thing is totally bogus as well,