Skip to content

Commit

Permalink
Bug 798747 - Crash in Investment Portfolio report
Browse files Browse the repository at this point in the history
add support for pricedb-before in portfolio reports
  • Loading branch information
christopherlam committed Feb 5, 2023
1 parent 68cd8cf commit 9c87585
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions gnucash/report/reports/standard/advanced-portfolio.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions gnucash/report/reports/standard/portfolio.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9c87585

Please sign in to comment.