Bug 388935 - Unable to import investment account transaction with .csv
Summary: Unable to import investment account transaction with .csv
Status: RESOLVED NOT A BUG
Alias: None
Product: kmymoney
Classification: Applications
Component: importer (show other bugs)
Version: 4.8.1
Platform: Mint (Debian based) Linux
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-14 00:36 UTC by wgking99@yahoo.com
Modified: 2024-12-18 01:48 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
1 line test file for investment transaction import (80 bytes, text/csv)
2018-01-14 00:36 UTC, wgking99@yahoo.com
Details

Note You need to log in before you can comment on or make changes to this bug.
Description wgking99@yahoo.com 2018-01-14 00:36:21 UTC
Created attachment 109848 [details]
1 line test file for investment transaction import

When trying to import investment transactions from brokerage as .csv file, import fails after mapping fields with popup "The values in the columns you have selected do not match any expected investment type", and all other types from the drop down menu are grayed out. It even fails after modifying .csv file to use sample type in the Merrill Lynch template in the csvimporterrc file. Since option to reassign type are all grayed out (another issue?), the only option is to abort the import. 

The proper action in the sample case would be to recognize "dividend" as a valid brokerage transaction and deposit the amount in the "brokerage" account of the corresponding investment account. The error occurs before  the investment account is selected. The csvimporterrc template is the default M-L one with the columns mapped as follows:
[BankProfiles]
BankNames=Merril Lynch,Schwab
PriorInvProfile=Merril Lynch

[MainWindow]
Height=174
Width=866

[Profiles-Merril Lynch]
AmountCol=7
BrokerageParam=Bill Payment,Check,dividend,interest,qualified div,foreign tax paid,adr mgmt fee
BuyParam=buy
DateCol=1
DateFormat=2
DecimalSymbol=0
DetailCol=9
DivXParam=Dividend
Encoding=0
FeeCol=6
FieldDelimiter=0
FileType=Invest
Filter=
IntIncParam=Interest,Income
InvDirectory=~/
MemoCol=2
PayeeCol=3
PriceCol=5
PriceFraction=2
ProfileName=Merril Lynch
QuantityCol=4
ReinvdivParam=reinvest,Reinv,Re-inv,ReInv
RemoveParam=Remove
SecurityName=-1
SellParam=Sell,Repurchase
ShrsinParam=Add,Stock Dividend,Divd Reinv,Transfer In,Re-Registration In,Journal Entry
StartLine=0
SymbolCol=8
TrailerLines=0
Comment 1 Jordan 2020-06-27 15:25:16 UTC
Looking through the latest code I believe the cause of this issue involves the referenced code below. The isComplete() function of the qWizardPage forces the selection of quantity, price, and amount before the next button can be clicked. When the transactions are processed, a list of valid action types (the ones that don't show as grayed-out in the manual assignment dialog as mentioned) is generated by createValidActionTypes, which will only allow the dividend action type if the shares and prices are zero while the amount is positive.

Thus, I have successfully been able to import dividend transactions by manipulating the input CSV to ensure the values of price and quantity for dividend transactions is 0.

I am unsure if this is intended or a bug but the raw data I receive from my broker includes share amount and price for dividend transactions. Since dividend transactions in KMyMoney are only stored as an amount, perhaps the easiest solution would be to modify createValidActionTypes to allow dividend transactions when the shares and price amounts are non-zero, then simply ignore these fields when storing the transaction.

investmentwizardpage.cpp:156

bool InvestmentPage::isComplete() const
{
  return  ui->m_dateCol->currentIndex() > -1 &&
          ui->m_typeCol->currentIndex() > -1 &&
          ui->m_quantityCol->currentIndex() > -1 &&
          ui->m_priceCol->currentIndex() > -1 &&
          ui->m_amountCol->currentIndex() > -1 &&
          ui->m_priceFraction->currentIndex() > -1;
}

csvimportercore.cpp:1232

QList<eMyMoney::Transaction::Action> CSVImporterCore::createValidActionTypes(MyMoneyStatement::Transaction &tr)
{
  QList<eMyMoney::Transaction::Action> validActionTypes;
  if (tr.m_shares.isPositive() &&
      tr.m_price.isPositive() &&
      !tr.m_amount.isZero())
    validActionTypes << eMyMoney::Transaction::Action::ReinvestDividend <<
                        eMyMoney::Transaction::Action::Buy <<
                        eMyMoney::Transaction::Action::Sell;
  else if (tr.m_shares.isZero() &&
           tr.m_price.isZero() &&
           !tr.m_amount.isZero())
    validActionTypes << eMyMoney::Transaction::Action::CashDividend <<
                        eMyMoney::Transaction::Action::Interest;
  else if (tr.m_shares.isPositive() &&
           tr.m_price.isZero() &&
           tr.m_amount.isZero())
    validActionTypes << eMyMoney::Transaction::Action::Shrsin <<
                        eMyMoney::Transaction::Action::Shrsout;
  return validActionTypes;
}
Comment 2 Jack 2024-12-01 01:52:56 UTC
Given the current stable version is 5.1.3, and we are hoping to release 5.2 in the not to far future, I would see how things work with a newer version.  Also, I realize the OP talks about the csv file being from Merrill Lynch.  I also have accounts with ML, and use OFX direct connect, but have also used WebConnect and also manual file download.  OFX should almost a always be better than csv import.

 wgking99@yahoo.com: can you say why you were trying csv instead of ofx?

jordan:  I don't know the code well enough to comment, but I would check against the code in master branch to see if your conclusions still hold.  One possible reason not to do what you suggest is that if the activity says dividend, but there are more non-zero values than just amount, how do you know whether it is those columns which might be wrong or the activity type?  I suspect it is better to fail (perhaps with a more informative error message) than to chance an incorrect import.
Comment 3 wgking99@yahoo.com 2024-12-01 05:47:38 UTC
(In reply to Jack from comment #2)
> Given the current stable version is 5.1.3, and we are hoping to release 5.2
> in the not to far future, I would see how things work with a newer version. 
> Also, I realize the OP talks about the csv file being from Merrill Lynch.  I
> also have accounts with ML, and use OFX direct connect, but have also used
> WebConnect and also manual file download.  OFX should almost a always be
> better than csv import.
> 
>  wgking99@yahoo.com: can you say why you were trying csv instead of ofx?
> 
> jordan:  I don't know the code well enough to comment, but I would check
> against the code in master branch to see if your conclusions still hold. 
> One possible reason not to do what you suggest is that if the activity says
> dividend, but there are more non-zero values than just amount, how do you
> know whether it is those columns which might be wrong or the activity type? 
> I suspect it is better to fail (perhaps with a more informative error
> message) than to chance an incorrect import.

This was resolved after clarification of the CSV importer rules.  MY Canadian brokerage only supports CSV downloads...
Comment 4 Bug Janitor Service 2024-12-16 03:46:45 UTC
๐Ÿ›๐Ÿงน โš ๏ธ This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information, then set the bug status to REPORTED. If there is no change for at least 30 days, it will be automatically closed as RESOLVED WORKSFORME.

For more information about our bug triaging procedures, please read https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging.

Thank you for helping us make KDE software even better for everyone!