Bug 397824

Summary: Limit in number of securities
Product: [Applications] kmymoney Reporter: stephanesp <stephane_1802>
Component: translationAssignee: KMyMoney Devel Mailing List <kmymoney-devel>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 4.8.0   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In: 5.0.2
Sentry Crash Report:

Description stephanesp 2018-08-24 08:27:10 UTC
I have 50 securities (Visible in Investments => Securities). They are all well-defined with unique trading symbol, etc...
When I try to add a 51st securities through one investment account, using a new (unused) trading symbol, an existing one is automatically reallocated (wrongly) to this new one, as if to ensure a maximum number of securities at 50.
Comment 1 Thomas Baumgart 2018-08-24 12:49:33 UTC
There is no such limit by design. We need to track down what is happening. Can you provide an anonymous version of your file (see https://docs.kde.org/stable4/en/extragear-office/kmymoney/details.formats.anonymous.html for details on how to create it). Please verify that the problem persists when using this anonymous version. Thanks in advance.
Comment 2 stephanesp 2018-08-24 15:53:00 UTC
Anonymous file available for download:
https://send.firefox.com/download/8e86075bd3/#2oyCYGuJLW37xoCAzMLSYQ
Comment 3 Thomas Baumgart 2018-08-24 18:12:25 UTC
How did you create some of the securities and accounts? The internal IDs are totally broken. This is the reason why you cannot create new securities (in fact it replaces the first one all the time). I need to take a look to see if one can fix this file.

Example(s):

Accounts receive an internal ID from the application which have the form "A######" and one can spot some of them in your file. But there are also other accounts which carry an ID of the form "###-account" which is completely wrong.

Securities usually have an ID of the form "E######". There are some of them in the file as well, but many more have the form of a name. That simply does not work.

The question now is: how did they find their way into the app or what part created them so that we can fix it.
Comment 4 stephanesp 2018-08-25 04:54:00 UTC
Some of the securities would have come from a QIF as exported from a previously used software. I suspect these must be the bugged ones then.
Comment 5 Thomas Baumgart 2018-08-25 05:48:53 UTC
Git commit 419c2df34b631baa458f13facf7ffce89ed9b511 by Thomas Baumgart.
Committed on 25/08/2018 at 05:49.
Pushed by tbaumgart into branch 'master'.

Improve determination of highest used id

Object IDs in KMyMoney are usually constructed by a letter based lead-in
followed by a numeric value. Adding objects with a different ID layout
could cause trouble when they still contain some numeric values.

The change only takes those IDs into account when determining the
highest used number that follow the above mentioned layout of KMyMoney.
FIXED-IN: 5.0.2

M  +90   -115  kmymoney/mymoney/storage/mymoneystoragemgr.cpp
M  +11   -0    kmymoney/mymoney/storage/mymoneystoragemgr_p.h

https://commits.kde.org/kmymoney/419c2df34b631baa458f13facf7ffce89ed9b511