Bug 411015 - Investment doesn't show correct value after switching investments
Summary: Investment doesn't show correct value after switching investments
Status: RESOLVED FIXED
Alias: None
Product: kmymoney
Classification: Applications
Component: general (show other bugs)
Version: git (master)
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-17 16:21 UTC by Ian Neal
Modified: 2019-10-13 11:04 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 5.0.8


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ian Neal 2019-08-17 16:21:33 UTC
SUMMARY


STEPS TO REPRODUCE
1. Have an investment account with shares in both stock A and stock B
2. Buy some more shares in stock A
3. Check values of stock A and stock B in investments page
4. Edit buy so they are in stock B rather than stock A
5. Check values of stock A and stock B again in investments page

OBSERVED RESULT
Values have not changed

EXPECTED RESULT
Values have changed to reflect the edited buy

WORKAROUND
Close and reopen kmymoney and values show correctly

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Fedora 29
(available in About System)
KDE Plasma Version: 5.14.5.1-1
KDE Frameworks Version: 5.58
Qt Version: 5.11.3

ADDITIONAL INFORMATION
Comment 1 Jack 2019-08-18 18:08:16 UTC
This sounds possibly related to https://bugs.kde.org/show_bug.cgi?id=404753 (about the display not updating in a report after editing multiple transactions to change the memo field.)  Does the correct value show if you switch to some different view (say reports or payees) and then back to the investments view?  Or change the ledger to a different account and then back?
Comment 2 Ian Neal 2019-08-19 19:39:34 UTC
(In reply to Jack from comment #1)
> This sounds possibly related to https://bugs.kde.org/show_bug.cgi?id=404753
> (about the display not updating in a report after editing multiple
> transactions to change the memo field.)  Does the correct value show if you
> switch to some different view (say reports or payees) and then back to the
> investments view?  Or change the ledger to a different account and then back?

So done some more testing. After editing the buy from stock A to stock B, the value of stock B is increased correctly, it is stock A which does not get correctly reduced.

Say stock A has £2 of shares and stock B has £10 of shares.
A buy of £1 of stock A shares is done.
Stock A now shows £3 in the investment page and the ledger page.
Stock B shows as having £10 in both the investment and ledger pages.
Edit the buy of stock A to be for stock B.
Stock A still shows as £3 in both pages (incorrectly).
Stock B shows the correct £11 in both pages (correctly).

Switching to other pages, accounts, ledgers, etc makes no difference to the values reported. The only thing that seems to update the values is restarting kmymoney.
Comment 3 Jack 2019-08-19 20:02:51 UTC
It may not help any, but I would stick to number of shares in this discussion.  If you talk value, you have to consider that it is (should be?) calculated using the most recent price for each stock, which is not necessarily the price used in the buy transaction.
Comment 4 Ian Neal 2019-08-19 20:06:56 UTC
(In reply to Jack from comment #3)
> It may not help any, but I would stick to number of shares in this
> discussion.  If you talk value, you have to consider that it is (should be?)
> calculated using the most recent price for each stock, which is not
> necessarily the price used in the buy transaction.

All shares are priced at £1 each and that does not change.
Comment 5 Thomas Baumgart 2019-10-13 11:04:20 UTC
Git commit 1d9158e172c6636f992ee9ca05e7a0b67b6b00c5 by Thomas Baumgart.
Committed on 13/10/2019 at 10:55.
Pushed by tbaumgart into branch '5.0'.

Changing the security of a transaction does not update balance

When the security of an investment transaction (e.g. buy) is changed
from security A to security B, the balance of security A does not get
updated. This causes to display false values.

This change fixes the problem by first removing the split referencing
security A from the list of transactions and then updating the balance.
FIXED-IN: 5.0.8

M  +7    -11   kmymoney/mymoney/storage/mymoneystoragemgr.cpp

https://commits.kde.org/kmymoney/1d9158e172c6636f992ee9ca05e7a0b67b6b00c5