[Kmymoney-devel] question on report "Investment Price Graph"

Bernd Gonsior bernd.gonsior at googlemail.com
Thu Sep 9 21:18:12 CEST 2010

Alvaro Soliverez schrieb am 05.09.2010 20:49: 
> Hello Berndt,
> please submit this through reviewboard.
> There is a method to have the price return only when an actual value
>  exists. MyMoneyFile->price() has a boolean as its last argument, to do
>  exactly that. It only returns a value if the price exists for that exact
>  date.

Yes, i saw this method - but because it's description is:
"... If no price information is available, 1.0 will be returned as price."
i did not use it.

Indeed this method returns a MyMoneyPrice-object with a price-value of "1" (as
double). This can not be used as a criterion whether there is a price for a
given date or not. But some debugging revealed that there is another criterion
which could be used for that decision. In case that there is a price, the date
of the the MyMoneyPrice-object is valid. In case that there is no price, the
date of the MyMoneyPrice-object is not set, so QDate::isValid() can be used to

I would recommend to change the description to this:
"... If no price information is available,
 the date of the returned MyMoneyPrice-object is invalid."

> Also, I guess that should change your patch a lot.

You are right.

> There is a design problem in your patch. That is, kreportchartview is
> an abstraction layer, and as such, it should have as little knowledge
> about the internals of kmymoney as possible. So, the most logic should
> take place in pivottable and reportaccount, which are the
> logic-intensive classes of reports.
> ReportAccount is the one responsible for calculating the prices.
> Adding a parameter to the appropriate so that it can pass it on to
> MyMoneyFile->price() to decide whether fetching prices for the exact
> date or not, and adding a config option that pivottable can invoke to
> do just that, is the easiest way. So, we reuse the existing methods to
> calculate value, so that the behaviour changes if a config flag is
> set. (in this case, for some investment reports)

> Then, on kreportchartview you only have to skip the data point if the
> value is 0 for that date.

I would prefer to make a decision whether to do some action or not based on a
semantically applicable variable, not based on a special value
(here: price == 0). I do not know, whether it is possible, that under some
circumstances a price-value of "0" could exist. From my point of view
introducing a special variable for that case into the existing data structure
would have caused more trouble than accessing MyMoneyFile direct. So i
accessed MyMoneyFile directly from kreportchartview.

But because the solution "use price-value 0 as decision-criterion in
kreportchartview" is requested i did it that way now - it's OK.

The patch is submitted to reviewboard. It still contains a lot of debug
messages which hopefully will make that patch a bit 'self-explanatory'. They
have to be removed after review.

Regards, Bernd

More information about the KMyMoney-devel mailing list