When creating the entry for selling a small ammount of an investment (price*ammount ~=0.00) after clikcing "Enter" the ledger shows the entry as "Buy" (Both in the Investment legder and the charge account ledger). The asset balance is calculated correctly as a Sell and the operation has no impact on the charge account, since the ammount is 0.00, but it is also shown as a Buy operation on the account ledger. Even though the issue has no impact on the balance computer, the operation should be recorded properly for tracking purposes.
Created attachment 112585 [details] test xmi file With the appended kmymoney test file the bug can be reproduced: 1. open the appended file with kmymoney 2. select account 'invest' and open ledger view 3. There is a transaction with activity type "buy shares" although it has been created with activity "sell shares". 4. edit the transaction from step 3 5. set activity to "sell shares" and save The transaction shows "buy shares" as activity.
The problem is caused in void InvestTransactionEditor::dissectTransaction() where the transaction type is determined from the split value: 186: } else if (split.action() == MyMoneySplit::ActionBuyShares) { 187: transactionType = (!split.value().isNegative()) ? MyMoneySplit::BuyShares : MyMoneySplit::SellShares; In case the split value is zero, it is determined as BuyShares because it is not negative.
I believe the same issue happens with other account types - a cash/checking account transaction of $0 always ends up labelled as a deposit (I think) even if you entered it as a withdrawal. Should this be turned into a wishlist item that transactions retain the transaction type with which they were originally created?
An investment related split uses 'action="Buy"' in the saved file and uses the sign to indicate a sell. buy: <SPLIT payee="" reconcileflag="0" shares="1/1" reconciledate="" action="Buy" bankid="" account="A000002" number="" value="1/1" memo="" id="S0002"/> sell: <SPLIT payee="" reconcileflag="0" shares="-1/1" reconciledate="" action="Buy" bankid="" account="A000002" number="" value="-1/1" memo="" id="S0002"/> This could be changed into sell: <SPLIT payee="" reconcileflag="0" shares="1/1" reconciledate="" action="Sell" bankid="" account="A000002" number="" value="1/1" memo="" id="S0002"/> to give the transaction type a higher priority. > a cash/checking account transaction of $0 always ends up labeled as a deposit This is a different case and need to be fixed seperatly, because the action attribute is currently only used for investment transactions. All other transaction types detect whether the transaction is a deposit or a withdrawal from the sign: deposit: <TRANSACTION postdate="2018-05-14" commodity="EUR" memo="" id="T000000000000000002" entrydate="2018-05-14"> <SPLITS> <SPLIT payee="" reconcileflag="0" shares="1/1" reconciledate="" action="" bankid="" account="A000001" number="" value="1/1" memo="" id="S0001"/> <SPLIT payee="" reconcileflag="0" shares="-1/1" reconciledate="" action="" bankid="" account="A000002" number="" value="-1/1" memo="" id="S0002"/> </SPLITS> </TRANSACTION> withdrawal: <TRANSACTION postdate="2018-05-14" commodity="EUR" memo="" id="T000000000000000003" entrydate="2018-05-14"> <SPLITS> <SPLIT payee="" reconcileflag="0" shares="-1/1" reconciledate="" action="" bankid="" account="A000001" number="" value="-1/1" memo="" id="S0001"/> <SPLIT payee="" reconcileflag="0" shares="1/1" reconciledate="" action="" bankid="" account="A000002" number="" value="1/1" memo="" id="S0002"/> </SPLITS> </TRANSACTION> To fix this, an action needs to saved into and loaded from the file. In mymoneysplit.h there are already related constants defined static const char ActionDeposit[]; static const char ActionTransfer[]; static const char ActionWithdrawal[]; and are already used for in the gnu cash reader and in KMyMoneyView::fixTransactions_0(), called from KMyMoneyView::initializeStorage().
see https://phabricator.kde.org/D12917 for a preparation patch
In comment #4 you write: > This could be changed into > > sell: > <SPLIT payee="" reconcileflag="0" shares="1/1" reconciledate="" action="Sell" bankid="" account="A000002" number="" value="1/1" memo="" id="S0002"/> > > to give the transaction type a higher priority. Please be aware, that you can change the text of the action but you must keep the sign as it is. Changing the sign here will break other areas of the code.
Git commit 98a9ff8ed371c2a549e3c03ec1a23678434bcdf3 by Ralf Habacker. Committed on 30/05/2018 at 07:53. Pushed by habacker into branch '4.8'. Make sure that all code uses MyMoneySplit::Action... variables instead of duplicated strings Summary: This patch is a preparation for adding MyMoneySplit::ActionSellShares and helps to avoid regressions by not patching all related locations. Test Plan: compiled on linux Reviewers: tbaumgart Reviewed By: tbaumgart Differential Revision: https://phabricator.kde.org/D12917 M +6 -6 kmymoney/converter/mymoneyqifwriter.cpp M +2 -2 kmymoney/dialogs/transactioneditor.cpp M +5 -5 kmymoney/plugins/csvexport/csvwriter.cpp https://commits.kde.org/kmymoney/98a9ff8ed371c2a549e3c03ec1a23678434bcdf3