Mod to advanced-portfolio report

Matt Martin matt.martin@ieee.org
Sun, 06 Oct 2002 16:53:08 -0700


This is a multi-part message in MIME format.
--------------050301030208050807050402
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

All,

The new advanced-portfolio report ROCKS!
However, it seems to give wrong numbers if I have transactions dealing 
with more than one security.
This happens, for instance, when my paycheck is distributed to several 
IRA funds.
Right now it seems to add the money which goes into all other funds in 
one transaction as coming out of the fund of interest.
This makes my %return on investment happily positive but incorrect.

I think I have a fix for my circumstance, but not sure if it will break 
something else.
It only adds the "money in" or "money out" amounts if handling a 
specific split buying/selling the commodity of interest,
not for all splits in a transaction containing that commodity. Hope that 
makes sense...

Now my net ROI appears correct and very,very negative. :(

Patch is attached.

Regards.

-- 

 Matt Martin
matt.martin@ieee.org
600 West Grove Parkway  #1042,Tempe, AZ, 85283
Visit my homepage at http://matthewmartin.org


--------------050301030208050807050402
Content-Type: text/plain;
 name="mgm_advrepfix.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="mgm_advrepfix.patch"

--- gnucash/src/report/standard-reports/advanced-portfolio.scm	Tue Oct  1 13:48:27 2002
+++ /usr/local/share/gnucash/guile-modules/gnucash/report/advanced-portfolio.scm	Sun Oct  6 16:38:17 2002
@@ -158,11 +158,13 @@
                                                                             (* (gnc:numeric-to-double (gnc:split-get-amount s)) 
                                                                                (gnc:date-year-delta 
                                                                                  (car (gnc:transaction-get-date-posted parent))
-                                                                                 (current-time))))) )
+                                                                                 (current-time))))) 
+						    (cond 
+						     ((gnc:numeric-negative-p (gnc:split-get-value s))
+						     (moneyoutcoll 'add currency (gnc:numeric-neg (gnc:split-get-value s))))
+						     (else (moneyincoll 'add currency (gnc:numeric-neg (gnc:split-get-value s))))))
                              ((split-account-type? s 'expense) (brokeragecoll 'add currency (gnc:split-get-value s)))
                              ((split-account-type? s 'income)  (dividendcoll 'add currency (gnc:split-get-value s)))
-                             ((gnc:numeric-negative-p (gnc:split-get-value s)) (moneyincoll 'add currency (gnc:split-get-value s)))
-                             (else (moneyoutcoll 'add currency (gnc:split-get-value s)))
                            )
                          )
                          (gnc:transaction-get-splits parent)

--------------050301030208050807050402--