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

Thomas Baumgart thb at net-bembel.de
Fri Oct 5 17:15:09 UTC 2012


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.
-------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 225 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kmymoney-devel/attachments/20121005/969973ad/attachment.sig>


More information about the KMyMoney-devel mailing list