From f779b81719d86ba6082389dff26e96d3a6e03437 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Thu, 16 May 2019 18:25:58 +0800 Subject: [PATCH] [balsheet-pnl] unrealized-gain calculator bugfix The unrealized-gain calculator was flawed. The fixed function is copied from balance-sheet.scm and adapted to balsheet-pnl.scm vars. This fixed function matches unrealized-gains amounts from balance-sheet.scm --- .../report/standard-reports/balsheet-pnl.scm | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/gnucash/report/standard-reports/balsheet-pnl.scm b/gnucash/report/standard-reports/balsheet-pnl.scm index 08cb0d2a6e..44795c88d2 100644 --- a/gnucash/report/standard-reports/balsheet-pnl.scm +++ b/gnucash/report/standard-reports/balsheet-pnl.scm @@ -937,13 +937,16 @@ also show overall period profit & loss.")) (else (list-ref report-dates col-idx)))) (asset-liability-balance (list-ref asset-liability-balances col-idx)) - (latest (monetaries->exchanged - asset-liability-balance - common-currency price-source date)) - (avg-cost (monetaries->exchanged - asset-liability-balance - common-currency 'average-cost date))) - (gnc:monetary+ latest (gnc:monetary-neg avg-cost)))))) + (asset-liability-basis + (gnc:accounts-get-comm-total-assets + (append asset-accounts liability-accounts) + (lambda (acc) + (gnc:account-get-comm-value-at-date acc date #f)))) + (unrealized (gnc:make-commodity-collector))) + (unrealized 'merge asset-liability-basis #f) + (unrealized 'minusmerge asset-liability-balance #f) + (monetaries->exchanged + unrealized common-currency price-source date))))) (retained-earnings-fn (lambda (col-idx) (let* ((date (case price-source