mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-23 09:26:27 -06:00
Add new price source - 'nearest before report date'
Add new price source - 'nearest before report date' will ignore prices *after* report date. Will be useful to fix bug 743753.
This commit is contained in:
parent
5957b3c256
commit
2ba930713a
@ -741,6 +741,18 @@
|
|||||||
(gnc:gnc-monetary-commodity foreign)
|
(gnc:gnc-monetary-commodity foreign)
|
||||||
domestic (time64CanonicalDayTime date))))))
|
domestic (time64CanonicalDayTime date))))))
|
||||||
|
|
||||||
|
(define (gnc:exchange-by-pricedb-nearest-before foreign domestic date)
|
||||||
|
(and (gnc:gnc-monetary? foreign) date
|
||||||
|
(or (gnc:exchange-by-euro foreign domestic date)
|
||||||
|
(gnc:exchange-if-same foreign domestic)
|
||||||
|
(gnc:make-gnc-monetary
|
||||||
|
domestic
|
||||||
|
(gnc-pricedb-convert-balance-nearest-before-price-t64
|
||||||
|
(gnc-pricedb-get-db (gnc-get-current-book))
|
||||||
|
(gnc:gnc-monetary-amount foreign)
|
||||||
|
(gnc:gnc-monetary-commodity foreign)
|
||||||
|
domestic (time64CanonicalDayTime date))))))
|
||||||
|
|
||||||
;; Exchange by the nearest price from pricelist. This function takes
|
;; Exchange by the nearest price from pricelist. This function takes
|
||||||
;; the <gnc-monetary> 'foreign' amount, the <gnc:commodity*>
|
;; the <gnc-monetary> 'foreign' amount, the <gnc:commodity*>
|
||||||
;; 'domestic' commodity, a <gnc:time64> 'date' and the
|
;; 'domestic' commodity, a <gnc:time64> 'date' and the
|
||||||
@ -783,6 +795,7 @@
|
|||||||
(gnc:make-exchange-alist
|
(gnc:make-exchange-alist
|
||||||
report-currency to-date-tp)))
|
report-currency to-date-tp)))
|
||||||
((pricedb-latest) gnc:exchange-by-pricedb-latest)
|
((pricedb-latest) gnc:exchange-by-pricedb-latest)
|
||||||
|
((pricedb-before) (cut gnc:exchange-by-pricedb-nearest-before <> <> to-date-tp))
|
||||||
((pricedb-nearest) (lambda (foreign domestic)
|
((pricedb-nearest) (lambda (foreign domestic)
|
||||||
(gnc:exchange-by-pricedb-nearest
|
(gnc:exchange-by-pricedb-nearest
|
||||||
foreign domestic to-date-tp)))
|
foreign domestic to-date-tp)))
|
||||||
@ -805,6 +818,8 @@
|
|||||||
(case source
|
(case source
|
||||||
((pricedb-nearest) (cut gnc-pricedb-get-nearest-price pdb <> target-curr
|
((pricedb-nearest) (cut gnc-pricedb-get-nearest-price pdb <> target-curr
|
||||||
(time64CanonicalDayTime date)))
|
(time64CanonicalDayTime date)))
|
||||||
|
((pricedb-before) (cut gnc-pricedb-get-nearest-before-price pdb <> target-curr
|
||||||
|
(time64CanonicalDayTime date)))
|
||||||
((pricedb-latest) (cut gnc-pricedb-get-latest-price pdb <> target-curr))
|
((pricedb-latest) (cut gnc-pricedb-get-latest-price pdb <> target-curr))
|
||||||
(else
|
(else
|
||||||
(lambda (commodity)
|
(lambda (commodity)
|
||||||
@ -848,6 +863,7 @@
|
|||||||
(lambda (foreign domestic date)
|
(lambda (foreign domestic date)
|
||||||
(gnc:exchange-by-pricealist-nearest
|
(gnc:exchange-by-pricealist-nearest
|
||||||
pricealist foreign domestic date))))
|
pricealist foreign domestic date))))
|
||||||
|
((pricedb-before) gnc:exchange-by-pricedb-nearest-before)
|
||||||
((pricedb-latest) (lambda (foreign domestic date)
|
((pricedb-latest) (lambda (foreign domestic date)
|
||||||
(gnc:exchange-by-pricedb-latest foreign domestic)))
|
(gnc:exchange-by-pricedb-latest foreign domestic)))
|
||||||
((pricedb-nearest) gnc:exchange-by-pricedb-nearest)
|
((pricedb-nearest) gnc:exchange-by-pricedb-nearest)
|
||||||
|
@ -144,6 +144,7 @@
|
|||||||
(list (vector 'average-cost (N_ "Average cost of purchases by volume-weighted"))
|
(list (vector 'average-cost (N_ "Average cost of purchases by volume-weighted"))
|
||||||
(vector 'weighted-average (N_ "Weighted average of all past currency transactions"))
|
(vector 'weighted-average (N_ "Weighted average of all past currency transactions"))
|
||||||
(vector 'pricedb-latest (N_ "Most recent"))
|
(vector 'pricedb-latest (N_ "Most recent"))
|
||||||
|
(vector 'pricedb-before (N_ "Nearest before report date"))
|
||||||
(vector 'pricedb-nearest (N_ "Nearest to report date"))))))
|
(vector 'pricedb-nearest (N_ "Nearest to report date"))))))
|
||||||
|
|
||||||
;; The width- and height- options for charts
|
;; The width- and height- options for charts
|
||||||
|
Loading…
Reference in New Issue
Block a user