Version: unspecified OS: Linux A stock account containing a stock split cannot be closed even if its balance is zero and it is not referenced in any other account. The problem does not always occur, but one case where it does is when transactions are entered after th stock split was defined. Reproducible: Didn't try Steps to Reproduce: 1. Create an investment ABC 2. Create a Buy of 1 share on 02/01/2010 for EUR 100 Create a Split of 1/5 on 02/02/2010 Create a Sell of 5 shares on 02/03/2010 for EUR 95 3. Go to Accounts and check that you can close ABC (do not close) 4. Create a Buy of 1 share of ABC on 01/31/2010 for EUR 95 Create a Sell of 5 shares on 02/03/2010 for EUR 100 5. Go to Accounts and try to close ABC Actual Results: The accounts list shows a zero balance for ABC, yet it cannot be closed. Expected Results: It should be possible to close the stock.
This is reproducible, but I was able to close stock accounts in a new KMM session that I was unable to close before.
There is nothing in the code that checks for splits before allowing to close an account. We would need a test file or an anonymized file to check what's really going on.
Alvaro, > There is nothing in the code that checks for splits before allowing to close an > account. Thanks for looking into this. Did you try my example? > We would need a test file or an anonymized file to check what's really going > on. I will try to prepare this. Jan
Created attachment 47799 [details] example KMY file
I tried my example in a new KMY file and was able to reproduce the problem. However, after leaving and re-entering KMM, I was able to close it. So, I backed up the file (see attachment above), added a new BUY and SELL as in the example of comment #1, and again the "Close account" option for ABC was grayed out.
Since this operation is not a pure stock split but a reshuffling after a Merger/Acquisition, I have replaced the Split by consecutive Remove/Add Shares operations.
The only place I can find where the investment_delete action is enabled is on slotUpdateActions() if (!d->m_selectedInvestment.id().isEmpty()) { action("investment_edit")->setEnabled(true); action("investment_delete")->setEnabled(!file->isReferenced(d->m_selectedInvestment)); I'll check the test file later.
Alvaro, > The only place I can find where the investment_delete action is enabled is on > slotUpdateActions() Thanks for your help. I have not installed the source code, but am more and more tempted to do so. It would certainly help save your time. As I mentioned on the bulletin, I got rid of the issue by replacing the "Split Shares" by a "Remove Shares" of the old quantity, followed by an "Add Shares" of the new quantity. This does allow me to close the stock account, and it is probably a better way of representing a share reshuffle after a company merger anyway. In fact, I probably should have closed the old stock and created a new one on top of that. Jan
Sorry, the previous message was not meant for you but as a reference for other developers more skilled in the working of the file engine. There is no need for you to dive into the code, although you are welcome to do so if you want to. The problem seems to be somewhere deep down in an area of the code of the code which I'm not really familiar with, other than by hearsay, so I added the comment to help triaging the bug for the right guys.
The problem seems to be somewhere in the split transaction. I used the test file and entered a new split for ABC stock. After entering this split, the balance is miscalculated starting with the first split. Therefore, the balance is not zero, and the account can't be closed.
SVN commit 1140640 by tbaumgart: Simply adjusting the account balance by the share value does not work in case of stock splits. So the balance will always be recalculated for stock accounts. BUG: 240914 M +30 -15 mymoneyseqaccessmgr.cpp M +6 -0 mymoneyseqaccessmgr.h WebSVN link: http://websvn.kde.org/?view=rev&revision=1140640