[commodity-utilities] deprecate gnc:exchange-by-pricevalue-helper

This function is only used once, internally, and performs a sanity
check (if price-value ... ...) which is, never needed because the
price-value received has been sanitized to return a price, or 0 and
will never be #f. Inlining this function means we can skip this sanity
check.
This commit is contained in:
Christopher Lam 2019-03-14 09:02:30 +08:00
parent 9a0aaedc05
commit 0e60c77577
2 changed files with 8 additions and 5 deletions

View File

@ -773,6 +773,8 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
;; the <gnc:numeric> 'price-value'. Returns a <gnc:monetary>.
(define (gnc:exchange-by-pricevalue-helper
foreign domestic price-value)
(issue-deprecation-warning
"gnc:exchange-by-pricevalue-helper is deprecated. please inline function.")
(and (gnc:gnc-monetary? foreign)
(gnc:make-gnc-monetary
domestic
@ -875,10 +877,11 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
(or (gnc:exchange-by-euro foreign domestic date)
(gnc:exchange-if-same foreign domestic)
(and (pair? pricealist)
(gnc:exchange-by-pricevalue-helper
foreign domestic
(gnc:pricealist-lookup-nearest-in-time
pricealist (gnc:gnc-monetary-commodity foreign) date))))))
(gnc:make-gnc-monetary
domestic
(* (gnc:gnc-monetary-amount foreign)
(gnc:pricealist-lookup-nearest-in-time
pricealist (gnc:gnc-monetary-commodity foreign) date)))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Choosing exchange functions made easy -- get the right function by

View File

@ -57,7 +57,7 @@
(export gnc:exchange-by-euro)
(export gnc:exchange-if-same)
(export gnc:make-exchange-function)
(export gnc:exchange-by-pricevalue-helper)
(export gnc:exchange-by-pricevalue-helper) ;deprecated
(export gnc:exchange-by-pricedb-helper)
(export gnc:exchange-by-pricedb-latest )
(export gnc:exchange-by-pricedb-nearest)