[kmymoney] [Bug 388935] Unable to import investment account transaction with .csv

Jordan bugzilla_noreply at kde.org
Sat Jun 27 16:25:16 BST 2020


https://bugs.kde.org/show_bug.cgi?id=388935

Jordan <jordan.reed.blake at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jordan.reed.blake at gmail.com

--- Comment #1 from Jordan <jordan.reed.blake at gmail.com> ---
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;
}

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the KMyMoney-devel mailing list