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

Alvaro Soliverez asoliverez at kde.org
Sun Sep 5 20:49:13 CEST 2010


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.

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

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.

Code-wise, it should not be a very long patch, but it will take you
through the internals of reports. How it calculates the values and how
it renders the charts.

Keep in mind that the order and logic of the methods to each stuff is
nor arbitrary. It has been ironed out through many months of debugging
and fixing so it fits most use cases without errors. It is not
immediately apparent, though. Therefore, ask when in doubt. I had to
take over reports when the original developer went MIA, so I had
almost no one to ask from. I can certainly relate to how you may feel
when looking at the code.

Regards,
Alvaro

On Sun, Sep 5, 2010 at 3:13 PM, Bernd Gonsior
<bernd.gonsior at googlemail.com> wrote:
> Alvaro Soliverez schrieb am 01.08.2010 22:44:
>> I took a look at your question again, and now I see that the bug is
>> not clear enough.
>>
>> The problem is not to hide the whole chart if the report comes up
>> empty. That's seldom the case and it's not a problem.
>>
>> The actual intent of the bug is the following:
>>
>> - you have an investment.
>> - that investment has prices, but not every day (eg. non-business day,
>> and days you didn't get a price for)
>> - the chart should only display those data points which you actually
>> have a price for
>>
>>
>> Issues:
>> - the engine will always return a price, even if there is no actual
>> price. To avoid that, you have to query in a way that will not return
>> a price unless there actually exists one
>> - KReportChartView has to handle the situation correctly
>>
>> From this point of view, it makes no sense to have a report-wide
>> property to check whether there is data or not. You are counting on
>> the report having data, just not for every point in time.
>>
>> Regards,
>> Alvaro
>
> Hello Alvaro,
>
> please excuse me for answering so late, but i was very busy during the last
> weeks.
>
> To check, whether i understood the task this time, i attached a patch which
> produces debug-output explaining what the patch is doing. To avoid too much of
> such output, i also attached a small kmymoney file which only contains a few
> investments. For testing i created the report:
> 'Favorite Reports -> 2009: Investment Price Graph'.
>
> The way i found is something i would not recommend to implement because i had
> to access the application-core (MyMoneyFile) directly to get the dates were
> prices really do exist. From my point of view the application-core should not
> always implicitly return a price for a date (as you wrote above), it should be
> possible to set this behavior explicitly by usage of a flag, another method or
> the like.
>
> But the main question is:
> Does the patch principally do what it is supposed to do?
>
> Regards, Bernd
>


More information about the KMyMoney-devel mailing list