Bug 345655 - Rounding problems between checking and investment account
Summary: Rounding problems between checking and investment account
Status: RESOLVED FIXED
Alias: None
Product: kmymoney
Classification: Applications
Component: general (show other bugs)
Version: 4.7.1
Platform: openSUSE Linux
: NOR grave
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords: regression
: 346000 359471 (view as bug list)
Depends on: 303026
Blocks:
  Show dependency treegraph
 
Reported: 2015-03-29 13:18 UTC by Romain Henriet
Modified: 2018-03-28 08:00 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.0.0


Attachments
Exemple described in the bug report (7.72 KB, application/x-kmymoney)
2015-03-29 13:18 UTC, Romain Henriet
Details
test case rounding (8.22 KB, application/x-kmymoney)
2016-05-26 13:26 UTC, sven.keller
Details
Analysis of erroneous transaction (14.39 KB, application/octet-stream)
2016-05-29 07:07 UTC, Thomas Baumgart
Details
test Scenario as described (8.13 KB, application/x-kmymoney)
2016-05-29 09:10 UTC, sven.keller
Details
screenshot (12.63 KB, image/png)
2016-07-24 13:18 UTC, sven.keller
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Romain Henriet 2015-03-29 13:18:05 UTC
[A] If you sell shares which have a precision of eg 1/10000 towards a checking account where precision is 1/100 and repeat this operation several times. You finally get a total in the checking account that does not fit the sum of all operations. 
[B] You also have an error message when saving your file : "Consistency check result : shares set to value in split of transaction..."1. Create a new file containing a checking account (check_acc) and an investment account (invest_acc)
2. Create an investment (invest_share)
3. Add eg 100 shares of (invest_share) in (invest_acc)
4. Sell 12 shares of (invest_share) towards(check_acc)  value=1,5270
[C] Moreover, if you edit the transaction in the checking account, you get a window saying : "The total amount of this transaction is (eg) 15,12 while the sum of the splits is 15,12. The remaining 0,00 are unassigned..."
[D] Finally, selling shares without paying fees creates a transfer transaction in the checking account, but if you pay fees, this creates a deposit transaction.


Reproducible: Always

Steps to Reproduce:
1. Create a new file containing a checking account {check_acc} and an investment account {invest_acc}
2. Create an investment {invest_share}
3. Add eg 100 shares of {invest_share} in {invest_acc}
4. Sell 12 shares of {invest_share} towards {check_acc}  (value=1,5120, fee amount=1,00)
5. Save you file. You should get message box described in [B]
6. Sell 15 shares of {invest_share} towards {check_acc}  (value=1,5269, no fee)
7. Sell 15 shares of {invest_share} towards {check_acc}  (value=1,5269, no fee)
8. Save your file, you get [B] again
9. Open and watch ledgers for {check_acc}
10. There is a Deposit transaction with amount=17,14 and 2 Transfer transactions with amount=22,90, like said in [D]
11. You should receive a bank statement containing 17,14 + 22,90 + 2,90 = 62,94, but balance is 62,95 in kmymoney. Thus reconciliation won't work, as said in [A].
12. Now try to reconcile with a final balance of 62,95, like it appears in kmymoney. Clear the 3 transactions to have a difference of 0,00 and click on Finish. Kmymoney says there is a difference between the bank statement and the transactions marked as cleared !
13. Double clock the "Deposit invest" and simply click on the Enter button. There is now an error because of a missing assignment of 0,00...

Actual Results:  
I can't reconcile my account anymore without an error message.

Expected Results:  
Rounding values should be used in the checking account (precision of 1/100)

When creating the sell transaction in the investment account, why not adding a split field with a category of eg "Rounding error", which contains the difference between the rounded value and the exact value. It could use the 1/10000 precision. 
This way, no money would be lost in space and there would not be problems between accounts with different precisions.
It could be edited by the user in case his bank doesn't have the same rounding rules as kmymoney's ones.
Comment 1 Romain Henriet 2015-03-29 13:18:48 UTC
Created attachment 91803 [details]
Exemple described in the bug report
Comment 2 Ian Neal 2015-04-08 22:01:57 UTC
*** Bug 346000 has been marked as a duplicate of this bug. ***
Comment 3 Ian Neal 2015-04-08 22:06:58 UTC
Confirming as I also have the problem on git master as of 29th March. I also had the consistency check errors.
I think this is a regression as I am sure I didn't have the same issue in February on an older version of the git master.
Comment 4 Ian Neal 2015-04-30 23:37:16 UTC
Backing out the patch from Bug 303026 fixes the rounding problem for me.
Comment 5 Romain Henriet 2015-05-01 12:05:20 UTC
I confirm that patch from bug 303026 is to blame !
Comment 6 Ian Neal 2015-05-24 00:18:50 UTC
Flagging as a regression
Comment 7 Romain Henriet 2015-12-19 08:58:25 UTC
Will patch from bug 303026 be reverted ? Difference between kmymoney's reconciled value and my bank's value is growing slowly...
Comment 8 sven.keller 2016-05-25 10:11:35 UTC
Hello
is anybody working on that issue? I sued to work with Kmymoney for quite a while and I noticed this bug some time ago. Actually I expected the community to fix such a obvious issue more rapidely.
This bug is really annoying and actually makes KMM useless with investment accounts :-(

BR Sven
Comment 9 Jack 2016-05-25 16:05:34 UTC
As I understand it, all current developer time is going to the conversion to KDE Frameworks.  This issue is unlikely to be addressed until after that is complete.  

In addition, while this may certainly be annoying, if does not make KMM useless.  I track several investment accounts in KMM, with multiple brokers, and it works just fine for me.  Remember, nobody is being paid to work on KMM.  (You may also want to be careful about your choice of words, as "sued" has a particular legal implication in English, definitely in the US.)
Comment 10 allan 2016-05-25 16:16:47 UTC
(In reply to Jack from comment #9)
> As I understand it, all current developer time is going to the conversion to
> KDE Frameworks.  This issue is unlikely to be addressed until after that is
> complete.  
> 
> In addition, while this may certainly be annoying, if does not make KMM
> useless.  I track several investment accounts in KMM, with multiple brokers,
> and it works just fine for me.  Remember, nobody is being paid to work on
> KMM. 

>  (You may also want to be careful about your choice of words, as "sued"
> has a particular legal implication in English, definitely in the US.)

I took that to be a typo for 'used'.
Comment 11 sven.keller 2016-05-25 18:04:38 UTC
Hi Jack,
first sorry for the typo and for being that impatient. It supposed to be "used" and of course not "sued"!
I can understand that reworking towards the new framework takes resources.

I found two issues pointing to rounding problems in the data base. this seems to match better with my experience. However I wonder how one can work with investments not having problems with rounding? Actually I would not even have figured out if I wasn't syncing my investment with my current account. There I download a transaction let's say 100.00 €. unfortunately I cannot directly download the transactions from my depot(no clue how to connect it to internet banking is it was possible). Therefore I add a stock transaction manually using my receipt from the bank e.g.
1stock for 99.9956€
The resulting payment shown in the depot is 100.00€ (correctly rounded)
When I try to match now the manual transaction with the downloaded I get an error that they do not match because 100.00€ != 100.00€
You may say OK, delete the downloaded transaction and all is fine. But internally it seems not to round the umbers since sooner or later the account does not match anymore since the hidden digits sum up to >1ct.
For me this really makes using kmm a nightmare at the moment. 
Can u confirm that this is the same bug? Or do you have an idea how to work around?
I'd really appreciate any help here.
Comment 12 Jack 2016-05-25 19:13:58 UTC
First, sorry I didn't recognize that as a typo. :-)
Second, I'm going to have to review the details of this bug in more detail to be sure I really understand what is happening before I make any recommendations.  I do agree that there are issues with rounding, especially with investment accounts and securities that are tracked at many decimal places.  

For now, there are a few things you might do.  First, can you create a test kmy file that shows the issue?  Just the investment and the checking accounts, for example.  Will the mismatch happen even if you manually enter the bank transaction at exactly 100?  If so you could send the file, so someone can look to see what is happening.  You can also do that yourself.  A .kmy file is just a gzipped xml file.  (Always make a backup!)  If you can find the various transactions in the file, you can see how KMM is exactly recording the amounts.  The other option is that you could see if you can create an anonymized file, and post that, if it still shows the problem.

Separately, even if you cannot directly map  your KMM account to your online investment account, see if your broker lets you download the transactions - hopefully as OFX or possible QIF.  KMM can import either of those.  You can work separately to see if you actually can do a direct connect to your broker.

One other thing to check is the default precision set in KMM.  Select the Settings/Configure KMyMoney menu item, and on the General view, the Global tab, what is the Price precision set to?  Mine is set to 4 digits.  I'm not certain, but I think that may affect the precision to which things are rounded (but not necessarily displayed).  I certainly agree that if it is saying that 100 != 100 (I use dollars not pounds, but I don't think that should matter) then something is amiss.
Comment 13 sven.keller 2016-05-26 13:26:59 UTC
Created attachment 99202 [details]
test case rounding

Thanks for your support. 
please find a test case in the file.
3 scenarios:
stock A: visible mismatch between broker and current account
Stock B: can match two transactions
Stock C: invisible mismatch 

Hope that helps for further investigation.
Comment 14 Thomas Baumgart 2016-05-29 07:07:05 UTC
Created attachment 99235 [details]
Analysis of erroneous transaction

Thanks for the file that demonstrates the problem very well. Due to *not* rounding the value of the third split, the transaction becomes unbalanced (sum of all splits must be zero for that). The attached spreadsheet shows the transaction in its XML format as well the broken down fields. The one with the yellow background is the source and the one with the red background is causing the problem.

Now I wonder how you entered this transaction into KMyMoney. Can you describe this in detailed steps so that we can reproduce the problem? I have a gut feeling that the rounding was removed due to some other problem. I want to make sure to not introduce a regression, but git will certainly help us to find out, once we have located the spot in the source.
Comment 15 sven.keller 2016-05-29 09:09:28 UTC
Hi Thomas,
I'm not sure in which order I did enter the date for the example. Tehrefore I try to reproduce the scenarios:
the numbers stay same:
Name "Stock B"
amount = 0,649
price/share = 157,689
refund commission -2,44 (used wrong German term provision)
Sum automatically filled: 99,90
(However actual value (w/o rouding) 99,900161)
-----------
Scenario A:
1.) I entered the data in the Invest account:
2.) entering transaction in check account:
(investment transaction already shown here)
category investment
amount 99,90
--------------
3.) I match the two transactions 
"KMM has matched the transaction (result above)"
4.) seems(!) to have matched correctly now
5.) modified Note in check account Scenario A
--> exclamation mark has missing assignment 0,00
##########
Scenario B:
1.) enter check account
2.) enter invest account
3.) save:
  * Anzahl Anteile auf Wert der Split-Buchung „T000000000000000019“ gesetzt.
* Mögliches Problem mit Investitionen/Währungen
  * Für die Investition 'Test invest' ist am Eröffnungsdatum '2015-03-01' kein Wert festgesetzt.
    Bitte geben die den Wert der Investition am Tag der Eröffnung an.

Beendet: 1 Problem behoben. 1 Problem noch vorhanden.
4.) back to check acount and matching: 
-->failure
value of split transactions for check in conflict: (-99,90, -99,90)
############
Scenario C:
1.) enter invest account
2.) save 
--> error missing assignment of 0,00
3.) enter check account
4.) match
--> transaction matched, but exclamation mark persists (missing assignment of 0,00)
############

As you could see, it is not so easy to see a straight forward behaviour which is easily repeadable.
However I tried my best. please find the matching file below.
Thanks Sven
Comment 16 sven.keller 2016-05-29 09:10:23 UTC
Created attachment 99237 [details]
test Scenario as described
Comment 17 Thomas Baumgart 2016-05-30 18:11:57 UTC
I just created https://git.reviewboard.kde.org/r/128061/ . It would be nice, if you someone can test it against git master.
Comment 18 allan 2016-05-30 20:12:07 UTC
Referring back to comments #3, #4,  #5, and https://bugs.kde.org/show_bug.cgi?id=303026, does that issue now need revisiting?
Comment 19 Thomas Baumgart 2016-06-01 11:27:35 UTC
Allan, good point. The modification is almost identical, though it differs a bit. The rounding problem caught in https://bugs.kde.org/show_bug.cgi?id=303026 could still happen. Can you please comment on reviewboard so that we can think of how to deal with the situation? It would be nice if you can provide me with a testcase (probably just different values) that fails.
Comment 20 Thomas Baumgart 2016-06-13 12:11:11 UTC
Git commit 88040d6c3f43ee6781911087dd12801e890fd8b1 by Thomas Baumgart.
Committed on 13/06/2016 at 12:07.
Pushed by tbaumgart into branch 'master'.

Reduce the precision of shares and values

The problem described in bug 345655 is caused by a fractional part of the
splits value that is larger than the fractional part of the accounts currency.
This leads to the effect, that amounts are displayed with correctly
but the underlying amount used for calculations is not equal to the
amount displayed. This will end up in KMyMoney presenting the user
strange messages like 'Unassigned value of 0.00' which do not make
sense. The difference is in reality between 0 and 0.01, e.g. 0.008.
FIXED-IN: 4.8.0
REVIEW: 128061

M  +32   -7    kmymoney/mymoney/mymoneyfile.cpp
M  +5    -0    kmymoney/mymoney/mymoneyfile.h
M  +127  -0    kmymoney/mymoney/mymoneyfiletest.cpp
M  +1    -0    kmymoney/mymoney/mymoneyfiletest.h

http://commits.kde.org/kmymoney/88040d6c3f43ee6781911087dd12801e890fd8b1
Comment 21 Thomas Baumgart 2016-06-13 12:29:59 UTC
*** Bug 359471 has been marked as a duplicate of this bug. ***
Comment 22 Cristian Oneț 2016-06-13 13:30:14 UTC
Git commit dd5bfdd80e64ec30ac10b13c6a0dd7aa818bd1d2 by Cristian Oneț, on behalf of Thomas Baumgart.
Committed on 13/06/2016 at 13:22.
Pushed by conet into branch 'frameworks'.

Reduce the precision of shares and values

The problem described in bug 345655 is caused by a fractional part of the
splits value that is larger than the fractional part of the accounts currency.
This leads to the effect, that amounts are displayed with correctly
but the underlying amount used for calculations is not equal to the
amount displayed. This will end up in KMyMoney presenting the user
strange messages like 'Unassigned value of 0.00' which do not make
sense. The difference is in reality between 0 and 0.01, e.g. 0.008.
FIXED-IN: 4.8.0
REVIEW: 128061

M  +32   -7    kmymoney/mymoney/mymoneyfile.cpp
M  +5    -0    kmymoney/mymoney/mymoneyfile.h
M  +127  -0    kmymoney/mymoney/mymoneyfiletest.cpp
M  +1    -0    kmymoney/mymoney/mymoneyfiletest.h

http://commits.kde.org/kmymoney/dd5bfdd80e64ec30ac10b13c6a0dd7aa818bd1d2
Comment 23 allan 2016-06-13 16:57:28 UTC
It looks to me that https://bugs.kde.org/show_bug.cgi?id=303026 still shows its problem.  See comment #18.  A new manually created copy of its sell transaction still objects if a fee of 12.95 is entered.
Comment 24 allan 2016-06-17 11:16:21 UTC
I know you are all up to your eyebrows, and doing fantastic work

I've just reopened this to ensure it is not overlooked, as there is still, I think, an outstanding issue.  https://bugs.kde.org/show_bug.cgi?id=345655#c23.
Comment 25 sven.keller 2016-07-24 07:24:08 UTC
Hi Folks,
eventually I got the RPM package provided by Opensuse. 
I can confirm, for my "productive" file it is not working as expected.
Great work! Thanks a lot for the effort!

However one question remains (but perhaps not related to this bug)
I double checked and corrected all my investment transactions and the (visible) amount of the account also matches the amount downloaded from the bank.
However it is marked in red as if it would not match?
Is there a way to check where a potential mismatch might be?

Cheers

Sven
Comment 26 sven.keller 2016-07-24 08:38:05 UTC
I meant it IS WORKING! :-)
Sorry for the typo!
unfortunately I cannot edit my comment anymore :-(
Comment 27 allan 2016-07-24 10:28:12 UTC
(In reply to sven.keller from comment #25)
> Hi Folks,
> eventually I got the RPM package provided by Opensuse. 
> I can confirm, for my "productive" file it is not working as expected.
> Great work! Thanks a lot for the effort!
> 
> However one question remains (but perhaps not related to this bug)
> I double checked and corrected all my investment transactions and the
> (visible) amount of the account also matches the amount downloaded from the
> bank.
> However it is marked in red as if it would not match?
> Is there a way to check where a potential mismatch might be?
> 
> Cheers
> 
> Sven

Can you be a bit more precise?  Is it just the date field?  If you hover the pointer, does that produce a clue?  Might it be that the opening date for the account is after the transaction date?  If so, edit the account's opening date to match the oldest likely transaction.
Comment 28 allan 2016-07-24 10:30:33 UTC
Actually, if the answer to the previous comment does not resolve the issue, it would be as well to open a new bug, as your problem is not to do with rounding.
Comment 29 sven.keller 2016-07-24 11:47:42 UTC
@Allan I agree it may not be related to this rouding issue. 
I just like to clarify how I could give more details wether is is a different bug or part of this one.

I don't really get the point of your question?
Where should I hover the pointer above? 
The opening date and the date of the first transaction match.
Also the balance on the right column of the ledgers is same as "balance" underneath, "cleared" and "online statement balance" whereas the latter is marked with red background instead yellowish as it supposed to be. So I assume the system detected a mismatch.
However during save action I do not get an error or warning related to this. 
How can I help you given more helpful details?
Comment 30 allan 2016-07-24 12:43:18 UTC
I made an assumption that it could be the date field that was red. Obviously now that's not the issue.  So, I'm missing something.

Are you able to attach a screen-shot to the bug?

Allan 

In Settings/Configure KMM/Colors, a negative value may be set to show as red.  Might that explain?
Comment 31 sven.keller 2016-07-24 13:18:57 UTC
Created attachment 100268 [details]
screenshot

there it is..
I reconciled the account but when I want to finish it tells me:
"you are about to finish the reconciliation of this account with a difference between your bank statement and the transactions marked as cleared. are you sure..."
Comment 32 allan 2016-07-24 14:00:00 UTC
Ah, we're on reconciliation.  It is indicating a discrepancy with cleared transactions.  Uncleared transactions will be excluded from reconciliation.

So, in that account, click Not marked in the status (top right).  Make sure all those transactions are cleared.

It might help in any further difficulty to just reconcile part of the account, into smaller chunks , if that helps to show where the problem lies.

Allan
Comment 33 Jack 2016-07-24 14:12:15 UTC
(In reply to sven.keller from comment #31)
I do not know exactly what that particular error message is in tended to say.  I get it fairly often, with no apparent issued with the account.  As Alan said, review everything in the account since the previous reconciliation to assure the correct status of all transactions.  However, given the same account balance, cleared balance, and online balance, it is possible there really are not any problems, other than the spurious error message.

Make lots of backups!
Comment 34 sven.keller 2016-07-24 14:47:01 UTC
As you recommended I filtered "not  marked " elements and got an empty list. This however comes with no surprise since I manually reconciled all entries while searching for the "odd one" causing the rounding problem. 
So I finished reconciliation and got the report without issues (apart from the red bar at the botom...
perhaps you could tell me how I can find those 4 entries (balance, online statement, balance below the table and cleared) in the xml to see if there is a mismatch?
Comment 35 Thomas Baumgart 2016-07-24 14:54:44 UTC
Here's some diagnostic instructions that you should run on your data file (I assume it is a standard KMyMoney file).

We need to figure out the account id of the account in question. Here's how to do that. First we uncompress the data and store that in its own file which we use for further analysis.
% zcat xxx.kmy > xxx.xml
% grep '<ACCOUNT ' xxx.xml | grep 'Giro'

Replace xxx with your filename. Single quotes and spaces are important here. As argument to grep use part of the name of your account. Here I get something like the following line (you may see more entries - pick the one that is your account):

  <ACCOUNT currency="EUR" description="" parentaccount="AStd::Asset" opened="2016-01-01" number="111406" lastmodified="2016-07-24" type="1" id="A000001" lastreconciled="2016-05-25" institution="I000001" name="1200 Giro RaiBa">

The id in which we are interested of my example account is A000001. That is what you need from your file.

Next we try to extract some data from your file. Depending on the order of the attributes stored in the file, some arguments might be different for you. Here's a line from my file so that you can check if they are identical:

% grep 'SPLIT ' xxx.xml | head -n 1
    <SPLIT payee="" reconcileflag="2" shares="64133/50" reconciledate="2016-01-04" action="" bankid="" account="A000001" number="" value="64133/50" memo="" id="S0001"/>

If the attributes for you are in the same order then things should work as explained here. Otherwise you will have to play with the -f argument of the first cut command. 

Replace the # signs after the A with the id determiined above. The argument for the -d of the second cut command  single quote, double quote, single quote.  

% grep 'SPLIT ' xxx.xml | grep A###### | cut -d= -f4 | cut -d'"' -f2 | cut -d/ -f2 | sort | uniq

This should give a short list (mine as sample here):

1
10
100
2
20
25
4
5
50

These are the denominators of the shares which I am interested in. Next we need the same for the online balances. That is a lot easier.

% grep lastStatementBalance xxx.xml | cut -d= -f 3 | cut -d/ -f2 | sort | uniq

Here is my output (don't worry about the trailing double quote here)

100"
2"
20"
25"
50"


Can you post your lists here? Once done, you can get rid of xxx.xml again.
Comment 36 sven.keller 2016-07-24 15:13:17 UTC
kraxel@kerbos:~/> grep 'SPLIT' MyMoney-nopgp_delete-me.kmy.uncompressed |grep A000217  | cut -d= -f4 | cut -d'"' -f2 | cut -d/ -f2 | sort | uniq
1
10
100
100000
1000000
12500
125000
2
20
2000
2000000
25
25000
250000
31250
4
40000
5
50
5000
50000
500000
62500
&quot;2008-09-16&quot; memo
&quot;2008-09-30&quot; memo
&quot;2008-12-30&quot; memo
&quot;2009-02-02&quot; memo
&quot;2009-05-04&quot; memo
&quot;2009-07-01&quot; memo
&quot;2009-08-14&quot; memo
&quot;2009-08-31&quot; memo
&quot;2009-09-01&quot; memo
&quot;2009-09-15&quot; memo
&quot;2009-11-02&quot; memo
&quot;2009-12-01&quot; memo
&quot;2010-01-22&quot; memo
&quot;2010-02-16&quot; memo
&quot;2010-02-22&quot; memo
&quot;2010-03-31&quot; memo



kraxel@kerbos:~/> grep lastStatementBalance  MyMoney-nopgp_delete-me.kmy.uncompressed | cut  -d= -f 3 | cut -d/ -f2 | sort | uniq
1"
10"
100"
20"
25"
4"
50"
Comment 37 Thomas Baumgart 2016-07-24 16:18:22 UTC
Ah, what I somewhat expected and what probably leads to the problems you encounter. Those denominators > 100 represent a value with a higher precision than 2 decimal digits (I expect the account being a checking account and with EUR as currency this would be 2 decimal digits) Example: 1/100 and 11/1000 are both shown as 0,01 but in fact the latter is 0,011. So KMyMoney tells you that the values are different which they are but you will not see it on screen.

Using a bit more grep magic on the xml file one can get the transaction ID of such a transaction.  If you run

% grep -B 20 '62500' xxx.xml | grep -B 20 'SPLIT '

it should show you 20 lines before the split with a denominator of 62500. We are interested in the starting TRANSACTION tag for this split and its attribute id, which is a T followed by an 18 digit number. If you don't see it, increase the value of 20.

You can use that id directly in KMyMoney's 'Edit/Find transaction' dialog as the text to search. What happens to the splits of this transaction if you start editing it and enter it w/o changes or with slight changes e.g. in the memo field? Does the precision get adjusted to two digits?
Comment 38 sven.keller 2016-07-24 18:39:23 UTC
fur the purpose of "mocking away the rounding error" I used more digits. I reversed it for this transaction to the actual values and the rounding seems to be OK.
The precision of this transaction also changed in the xml to xxx/100 
But it does not change the red bar in the ledger.

ps: there are likely more transactions like this for the same reason, but I could not find another "62500".
Comment 39 Thomas Baumgart 2016-07-24 20:55:07 UTC
OK, so editing transactions solves the problem on a per-transaction basis (which was implemented by the fix). In order to resolve the problem with the red background for the online balance you need to edit all transaction with a denominator > 100  (seems you have some of those according to the list you provided) and not only the one with 62500 which I picked randomly from your list..
Comment 40 Jack 2016-07-24 23:23:22 UTC
This has actually been instructive for me - that reconciliation error I have seen has always been in investment accounts, and I certainly have increased precision in many of the equities.  Now I'll have to watch for it to happen again, and see if I actually do have similar rounding problems that have simply never been large enough to be obvious in any of the visible transaction amounts.
Comment 41 NSLW 2017-04-01 06:19:11 UTC
Git commit c6e31c96a03ad5a7ec5e3695bbfa8336181ab81c by Łukasz Wojniłowicz.
Committed on 01/04/2017 at 06:16.
Pushed by wojnilowicz into branch 'master'.

Fix rounding problem with investments

Patch introduces rounding rules per security for fixing bug #372163. It
seems that this broker always rounds amounts down while my broker rounds
amounts depending on the outlying digit, so it couldn't work for both of
us without rules.

Rounding is done in InvestTransactionEditor because it has all needed
informations at hand.

No rounding of shares is done in InvestTransactionEditor::setupPrice.
Transaction from bug #372163 looks as follows:
brokerage:
shares = 1,009 ; value = 1,009
investment:
shares = -1 ; value = 1,009

InvestTransactionEditor::setupPrice causes brokerage to look as follows:
shares = 1,01 ; value = 1,009
As we can see shares and value diverge, which is unacceptable here.

Patch makes assumption that transaction has only single split of
stock/mutual fund/bond.
Related: bug 357784, bug 365177, bug 372163
FIXED-IN:5.0

Differential Revision: https://phabricator.kde.org/D5187

Signed-off-by: Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>

M  +32   -15   kmymoney/dialogs/investtransactioneditor.cpp
M  +31   -0    kmymoney/kmymoneyutils.cpp
M  +22   -0    kmymoney/kmymoneyutils.h
M  +39   -0    kmymoney/mymoney/mymoneysecurity.cpp
M  +27   -8    kmymoney/mymoney/mymoneysecurity.h
M  +1    -0    kmymoney/mymoney/storage/mymoneydbdef.cpp
M  +3    -0    kmymoney/mymoney/storage/mymoneystoragesql.cpp
M  +4    -3    kmymoney/widgets/transaction.cpp
M  +11   -0    kmymoney/wizards/newinvestmentwizard/kinvestmentdetailswizardpage.cpp
M  +104  -90   kmymoney/wizards/newinvestmentwizard/kinvestmentdetailswizardpagedecl.ui
M  +2    -0    kmymoney/wizards/newinvestmentwizard/knewinvestmentwizard.cpp

https://commits.kde.org/kmymoney/c6e31c96a03ad5a7ec5e3695bbfa8336181ab81c