[Kmymoney-devel] [Android Port] Help with computing the account balance

Eric Bonney mailinglists at vanhlebarsoftware.com
Fri Oct 5 17:48:20 UTC 2012


Hi Thomas:

Actually that was the function that I was looking at and referring to. I
tried looking at it but I'll be honest, I am struggling trying to figure
out just what exactly it is doing.

I see it takes in a String value currency, which I am assuming is the
constant defined somewhere for the currency denomination the user is using,
then it integer for precision and a boolean to for thousands. So I got all
that down. :)

I am guessing that you are controlling the precision of
accounts/transactions past two for things like stock prices and
transactions right? So since I am not implementing this type I can safely
"ignore" that, but need to keep it in the back of my mind for future
reference.

It looks like the meat of the actual function starts with the on line 145:
#if 1

and runs through line 161:
mpz_class right = (valueRef() - mpq_class(left)) * denom;

I am lost looking at this stuff, the rest of the function looks like it is
just string manipulation which is easy enough to replicate.

What is a mpz_class? What is actually going on with lines 152, 154, 160 and
161?

Thanks for the help Thomas!

-Eric

On Fri, Oct 5, 2012 at 1:15 PM, Thomas Baumgart <thb at net-bembel.de> wrote:

> Eric,
>
> On Thursday 04 October 2012 12:05:05 Eric Bonney wrote:
>
> > So after working with Martin and doing some testing of a build trying to
> > use EURO instead of USD a number of poor design choices have come to
> light.
> > I am trying to work through them and hopefully make the app more
> > international friendly in the process.
> >
> > One of the choices that I made early on was to do all of my calculations
> > based off the balanceFormatted column for accounts and splits. Well this
> > was all fine when all I was dealing with was USD based files, but it
> fails
> > miserably when trying to use something else.
> >
> > So I know that the balance column is a fraction which I am assuming is
> the
> > greatest common denominator of the actually value over 100??
> >
> > Example: value is $150.00 so the balance column is the GCD of 150/100?
> >
> > So, if that is correct, I believe I have found routines to help me
> > calculate the GCD properly, but my question is how do you then later take
> > this fraction and inflate it back to the correct value? I am trying to
> get
> > away from having my application rely on the balanceFormatted column as
> much
> > as possible because it is causing me headaches and if the balance column
> is
> > the best and more accurate column to be using then I want to.
> >
> > I have tried to look at the code to see where this but I can't see it. I
> > think I recall in the past when I asked about this, that it was actually
> > being handled by an outside library right? Does anyone have any
> suggestions
> > or pointers as to where I can look so that I can move my application
> into a
> > better design to work more closely the way KMM works with the data?
>
> That is actually handled using the MyMoneyMoney::formatMoney() method which
> you can find in kmymoney/mymoney/mymoneymoney.cpp. It nowadays relies on
> conversion routines found in libgmp. Alkimia (the outside library you talk
> about) is basically a C++ wrapper around the libgmp functionality with some
> extra features.
>
> Hope that helps.
>
> --
>
> Regards
>
> Thomas Baumgart
>
> GPG-FP: E55E D592 F45F 116B 8429   4F99 9C59 DB40 B75D D3BA
> -------------------------------------------------------------
> The beauty of standards is that there are so many to choose from.
> -------------------------------------------------------------
>
> _______________________________________________
> KMyMoney-devel mailing list
> KMyMoney-devel at kde.org
> https://mail.kde.org/mailman/listinfo/kmymoney-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kmymoney-devel/attachments/20121005/4b80ffb7/attachment-0001.html>


More information about the KMyMoney-devel mailing list