Bug 798747 - Crash in Investment Portfolio report

add support for pricedb-before in portfolio reports
This commit is contained in:
Christopher Lam 2023-02-05 17:25:52 +08:00
parent 68cd8cfa2c
commit 9c87585d4e
2 changed files with 15 additions and 0 deletions

View File

@ -1026,6 +1026,11 @@ by preventing negative stock balances.<br/>")
(lambda (foreign domestic date)
(find-price (gnc-pricedb-lookup-latest-any-currency pricedb foreign)
domestic)))
((pricedb-before)
(lambda (foreign domestic date)
(find-price (gnc-pricedb-lookup-nearest-before-any-currency-t64
pricedb foreign (time64CanonicalDayTime date))
domestic)))
((pricedb-nearest)
(lambda (foreign domestic date)
(find-price (gnc-pricedb-lookup-nearest-in-time-any-currency-t64

View File

@ -229,6 +229,16 @@
(cons #f (gnc-numeric-zero)))))
(if price (gnc-price-list-destroy price))
fn)))
((pricedb-before)
(lambda (foreign date)
(let ((price (gnc-pricedb-lookup-nearest-before-any-currency-t64
pricedb foreign (time64CanonicalDayTime date))))
(cond
((null? price) (cons #f 0))
(else (let ((p (car price)))
(gnc-price-ref p)
(gnc-price-list-destroy price)
(cons p (gnc-price-get-value p))))))))
((pricedb-nearest)
(lambda (foreign date)
(let* ((price