mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[commodity-utils] use scheme division instead of gnc-numeric
with small change to test due to increased precision
This commit is contained in:
parent
f2aacf94cc
commit
e111c5bb07
@ -306,14 +306,6 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
|
||||
pricelist))
|
||||
(earlier (and (not (null? earlierlist))
|
||||
(last earlierlist))))
|
||||
;; (if earlier
|
||||
;; (warn "earlier"
|
||||
;; (qof-print-date (car earlier))
|
||||
;; (gnc-numeric-to-double (cadr earlier))))
|
||||
;; (if later
|
||||
;; (warn "later"
|
||||
;; (qof-print-date (car later))
|
||||
;; (gnc-numeric-to-double (cadr later))))
|
||||
|
||||
(if (and earlier later)
|
||||
(if (< (abs (- date (car earlier)))
|
||||
@ -637,11 +629,8 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
|
||||
(map
|
||||
(lambda (e)
|
||||
(list (car e)
|
||||
(abs
|
||||
(gnc-numeric-div ((cdadr e) 'total #f)
|
||||
((caadr e) 'total #f)
|
||||
GNC-DENOM-AUTO
|
||||
(logior (GNC-DENOM-SIGFIGS 8) GNC-RND-ROUND)))))
|
||||
(abs (/ ((cdadr e) 'total #f)
|
||||
((caadr e) 'total #f)))))
|
||||
(gnc:get-exchange-totals report-commodity end-date)))
|
||||
|
||||
(define (gnc:make-exchange-cost-alist report-commodity end-date)
|
||||
@ -651,12 +640,10 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
|
||||
(map
|
||||
(lambda (e)
|
||||
(list (car e)
|
||||
(if (zero? ((caadr e) 'total #f)) 0
|
||||
(abs
|
||||
(gnc-numeric-div ((cdadr e) 'total #f)
|
||||
((caadr e) 'total #f)
|
||||
GNC-DENOM-AUTO
|
||||
(logior (GNC-DENOM-SIGFIGS 8) GNC-RND-ROUND))))))
|
||||
(if (zero? ((caadr e) 'total #f))
|
||||
0
|
||||
(abs (/ ((cdadr e) 'total #f)
|
||||
((caadr e) 'total #f))))))
|
||||
(gnc:get-exchange-cost-totals report-commodity end-date)))
|
||||
|
||||
|
||||
@ -718,10 +705,8 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
|
||||
(if (or (not pair)
|
||||
(zero? foreign-amount))
|
||||
0
|
||||
(gnc-numeric-mul foreign-amount
|
||||
(cadr pair)
|
||||
(gnc-commodity-get-fraction domestic)
|
||||
GNC-RND-ROUND)))))))))
|
||||
(* foreign-amount
|
||||
(cadr pair))))))))))
|
||||
|
||||
;; Helper for the gnc:exchange-by-pricalist* below. Exchange the
|
||||
;; <gnc:monetary> 'foreign' into the <gnc:commodity*> 'domestic' by
|
||||
@ -734,10 +719,8 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
|
||||
(gnc:make-gnc-monetary
|
||||
domestic
|
||||
(if price-value
|
||||
(gnc-numeric-mul (gnc:gnc-monetary-amount foreign)
|
||||
price-value
|
||||
(gnc-commodity-get-fraction domestic)
|
||||
GNC-RND-ROUND)
|
||||
(* (gnc:gnc-monetary-amount foreign)
|
||||
price-value)
|
||||
(begin
|
||||
(warn "gnc:exchange-by-pricevalue-helper: No price found for "
|
||||
(gnc:monetary->string foreign) " into "
|
||||
@ -758,10 +741,8 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
|
||||
domestic
|
||||
(if price
|
||||
(let ((result
|
||||
(gnc-numeric-mul (gnc:gnc-monetary-amount foreign)
|
||||
(gnc-price-get-value price)
|
||||
(gnc-commodity-get-fraction domestic)
|
||||
GNC-RND-ROUND)))
|
||||
(* (gnc:gnc-monetary-amount foreign)
|
||||
(gnc-price-get-value price))))
|
||||
(gnc-price-unref price)
|
||||
result)
|
||||
(begin
|
||||
|
@ -697,7 +697,7 @@
|
||||
(gnc-dmy2time64-neutral 20 02 2016)
|
||||
#f #f)))
|
||||
(test-equal "gnc:case-exchange-time-fn average-cost 20/02/2012"
|
||||
8073/100
|
||||
14127/175
|
||||
(gnc:gnc-monetary-amount
|
||||
(exchange-fn
|
||||
(gnc:make-gnc-monetary AAPL 1)
|
||||
|
Loading…
Reference in New Issue
Block a user