Reporting: weighted average price source

Charles Day cedayiv at gmail.com
Thu Jul 3 22:31:10 EDT 2008


For reports, does anyone know why the calculation for price source "weighted
average" uses the absolute value in its calculations? It seems to me that
this gives incorrect results.

In most cases the figures for the "value" and "amount" fields of splits are
either both negative or both positive, which makes the sign irrelevant.
Sometimes the "amount" is zero and the "value" is positive, such as in
capital gains. However there are some cases when "amount" could be zero
while "value" is negative and needs to stay negative, such as a return of
capital (see bug 538800).

I am inclined to change this code to take away the use of absolute value,
but wanted to check with everyone to see if there is some particular reason
that it needs to be this way.

Cheers,
Charles

>From src/report/report-system/commodity-utilities.scm, starting at line 558:

                  ;; Always use the absolute value here.
                  (share-amount (gnc-numeric-abs
                                 (xaccSplitGetAmount a)))
                  (value-amount (gnc-numeric-abs
                                 (xaccSplitGetValue a)))


More information about the gnucash-devel mailing list