Bug 406223 - CSV Import of "Remove" transactions reclassifies as "Add Shares"
Summary: CSV Import of "Remove" transactions reclassifies as "Add Shares"
Status: RESOLVED FIXED
Alias: None
Product: kmymoney
Classification: Applications
Component: importer (show other bugs)
Version: git (master)
Platform: Appimage Linux
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
: 459006 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-04-04 16:13 UTC by mcdraemel
Modified: 2022-09-24 05:09 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
simple csv file to demonstrate bug (144 bytes, text/csv)
2022-09-13 20:17 UTC, Jack
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mcdraemel 2019-04-04 16:13:53 UTC
SUMMARY
Importing investment transactions through CSV reclassifies "remove" transactions as "Add Shares".

STEPS TO REPRODUCE
1. Create CSV file with action as "remove", "Remove", "REMOVE", or any other variant (such as "Out").
2. Import CSV file into KmyMoney
3. If the term is not "remove", it will correctly recognize an invalid transaction type and prompt the user to select a transaction type.  Select "Remove Shares" from the dropdown menu.
3. The importer imports each transaction but erroneously assigns them the the "Add Shares" activity.  

OBSERVED RESULT
The transaction is assigned to the "Add Shares" activity

EXPECTED RESULT
The transaction should be assigned to the "Remove Shares" activity


SOFTWARE/OS VERSIONS
Windows: N/A
macOS: N/A
Linux/KDE Plasma: Kubuntu 18.04
(available in About System)
KDE Plasma Version: 5.12.7
KDE Frameworks Version: 5.44.0
Qt Version: 5.9.5

ADDITIONAL INFORMATION
I have tried a number of different variations:
positive and negative share quantities
upper and lower case combinations
different recognized and unrecognized keywords
modifying csvimporterrc but that file is not present on computer
Comment 1 mcdraemel 2019-04-04 17:39:27 UTC
Also turned on logging and the import seemed good at the point the log is created.  Below is an example of a line:
<TRANSACTION number="" security="security name xxx" action="remove" amount="0/1" shares="1436594533/100000000" brokerageaccount="" dateposted="2017-02-22" payee="" bankid="" reconcile="0" memo="Quarterly Rebalancing"/>
Comment 2 mcdraemel 2019-04-04 17:42:26 UTC
Also a similar thing happens when I import an QFX through the OFX importer: where buy transactions get turned into sell transactions.
Comment 3 mcdraemel 2019-04-04 18:21:26 UTC
Located the csvimporterrc file and confirmed that invalid transaction types that the user maps to the "Remove Shares" action are correctly being appended to the "ShrsoutParam" line.
Comment 4 Jack 2022-09-13 20:12:22 UTC
*** Bug 459006 has been marked as a duplicate of this bug. ***
Comment 5 Jack 2022-09-13 20:15:33 UTC
Duplicate bug was also reported in the forum (https://forum.kde.org/viewtopic.php?f=69&t=176023) for 5.1.3.  I reproduced in git master appimage Version 5.1.80-06ee79919.  (I currently get a crash on File/Import/CSV in my Gentoo git master version.)
Comment 6 Jack 2022-09-13 20:17:54 UTC
Created attachment 152035 [details]
simple csv file to demonstrate bug

I think you can demonstrate the bug importing this csv file into any Investment Account.
Comment 7 Thomas Baumgart 2022-09-17 09:07:47 UTC
Git commit ddc85c396f3931f4920a1f820be44d00a8c7ec1d by Thomas Baumgart.
Committed on 17/09/2022 at 09:04.
Pushed by tbaumgart into branch 'master'.

Use correct sign for import of 'remove shares' transactions

M  +7    -3    kmymoney/converter/mymoneystatementreader.cpp

https://invent.kde.org/office/kmymoney/commit/ddc85c396f3931f4920a1f820be44d00a8c7ec1d
Comment 8 Thomas Baumgart 2022-09-24 05:09:00 UTC
Git commit a0f7c20bab58b07b48e7fbc038138c48952f3eab by Thomas Baumgart.
Committed on 24/09/2022 at 05:08.
Pushed by tbaumgart into branch '5.1'.

Use correct sign for import of 'remove shares' transactions
FIXED-IN: 5.1.4

(cherry picked from commit ddc85c396f3931f4920a1f820be44d00a8c7ec1d)

M  +7    -3    kmymoney/converter/mymoneystatementreader.cpp

https://invent.kde.org/office/kmymoney/commit/a0f7c20bab58b07b48e7fbc038138c48952f3eab