Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/converter/mymoneystatementreader.cpp
Show First 20 Lines • Show All 592 Lines • ▼ Show 20 Line(s) | 588 | while (it != list.constEnd() && security.id().isEmpty()) { | |||
---|---|---|---|---|---|
593 | ++it; | 593 | ++it; | ||
594 | } | 594 | } | ||
595 | 595 | | |||
596 | // if the security was not found, we have to create it while not forgetting | 596 | // if the security was not found, we have to create it while not forgetting | ||
597 | // to setup the type | 597 | // to setup the type | ||
598 | if (security.id().isEmpty()) { | 598 | if (security.id().isEmpty()) { | ||
599 | security.setName(sec_in.m_strName); | 599 | security.setName(sec_in.m_strName); | ||
600 | security.setTradingSymbol(sec_in.m_strSymbol); | 600 | security.setTradingSymbol(sec_in.m_strSymbol); | ||
601 | security.setSmallestAccountFraction(1000); | | |||
602 | security.setTradingCurrency(file->baseCurrency().id()); | 601 | security.setTradingCurrency(file->baseCurrency().id()); | ||
603 | security.setValue("kmm-security-id", sec_in.m_strId); | 602 | security.setValue("kmm-security-id", sec_in.m_strId); | ||
604 | security.setValue("kmm-online-source", "Yahoo"); | 603 | security.setValue("kmm-online-source", "Yahoo"); | ||
605 | security.setSecurityType(MyMoneySecurity::SECURITY_STOCK); | 604 | security.setSecurityType(MyMoneySecurity::SECURITY_STOCK); | ||
606 | MyMoneyFileTransaction ft; | 605 | MyMoneyFileTransaction ft; | ||
607 | try { | 606 | try { | ||
608 | file->addSecurity(security); | 607 | file->addSecurity(security); | ||
609 | ft.commit(); | 608 | ft.commit(); | ||
▲ Show 20 Lines • Show All 169 Lines • ▼ Show 20 Line(s) | 774 | if (statementTransactionUnderImport.m_eAction == MyMoneyStatement::Transaction::eaReinvestDividend) { | |||
779 | if (!statementTransactionUnderImport.m_price.isZero()) { | 778 | if (!statementTransactionUnderImport.m_price.isZero()) { | ||
780 | s1.setPrice(statementTransactionUnderImport.m_price); | 779 | s1.setPrice(statementTransactionUnderImport.m_price); | ||
781 | } else { | 780 | } else { | ||
782 | if (statementTransactionUnderImport.m_shares.isZero()) { | 781 | if (statementTransactionUnderImport.m_shares.isZero()) { | ||
783 | KMessageBox::information(0, i18n("This imported statement contains investment transactions with no share amount. These transactions will be ignored."), i18n("No share amount provided"), QString("BlankAmount")); | 782 | KMessageBox::information(0, i18n("This imported statement contains investment transactions with no share amount. These transactions will be ignored."), i18n("No share amount provided"), QString("BlankAmount")); | ||
784 | return; | 783 | return; | ||
785 | } | 784 | } | ||
786 | MyMoneyMoney total = -statementTransactionUnderImport.m_amount - statementTransactionUnderImport.m_fees; | 785 | MyMoneyMoney total = -statementTransactionUnderImport.m_amount - statementTransactionUnderImport.m_fees; | ||
787 | s1.setPrice((total / statementTransactionUnderImport.m_shares).convert(MyMoneyMoney::precToDenom(KMyMoneyGlobalSettings::pricePrecision()))); | 786 | s1.setPrice((total / statementTransactionUnderImport.m_shares).convertPrecision(file->security(thisaccount.currencyId()).pricePrecision())); | ||
788 | } | 787 | } | ||
789 | 788 | | |||
790 | s2.setMemo(statementTransactionUnderImport.m_strMemo); | 789 | s2.setMemo(statementTransactionUnderImport.m_strMemo); | ||
791 | if (statementTransactionUnderImport.m_strInterestCategory.isEmpty()) | 790 | if (statementTransactionUnderImport.m_strInterestCategory.isEmpty()) | ||
792 | s2.setAccountId(d->interestId(thisaccount)); | 791 | s2.setAccountId(d->interestId(thisaccount)); | ||
793 | else | 792 | else | ||
794 | s2.setAccountId(d->interestId(statementTransactionUnderImport.m_strInterestCategory)); | 793 | s2.setAccountId(d->interestId(statementTransactionUnderImport.m_strInterestCategory)); | ||
795 | 794 | | |||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | 844 | } else if (statementTransactionUnderImport.m_eAction == MyMoneyStatement::Transaction::eaFees) { | |||
854 | 853 | | |||
855 | } else if ((statementTransactionUnderImport.m_eAction == MyMoneyStatement::Transaction::eaBuy) || | 854 | } else if ((statementTransactionUnderImport.m_eAction == MyMoneyStatement::Transaction::eaBuy) || | ||
856 | (statementTransactionUnderImport.m_eAction == MyMoneyStatement::Transaction::eaSell)) { | 855 | (statementTransactionUnderImport.m_eAction == MyMoneyStatement::Transaction::eaSell)) { | ||
857 | s1.setAction(MyMoneySplit::ActionBuyShares); | 856 | s1.setAction(MyMoneySplit::ActionBuyShares); | ||
858 | if (!statementTransactionUnderImport.m_price.isZero()) { | 857 | if (!statementTransactionUnderImport.m_price.isZero()) { | ||
859 | s1.setPrice(statementTransactionUnderImport.m_price.abs()); | 858 | s1.setPrice(statementTransactionUnderImport.m_price.abs()); | ||
860 | } else if (!statementTransactionUnderImport.m_shares.isZero()) { | 859 | } else if (!statementTransactionUnderImport.m_shares.isZero()) { | ||
861 | MyMoneyMoney total = statementTransactionUnderImport.m_amount + statementTransactionUnderImport.m_fees.abs(); | 860 | MyMoneyMoney total = statementTransactionUnderImport.m_amount + statementTransactionUnderImport.m_fees.abs(); | ||
862 | s1.setPrice((total / statementTransactionUnderImport.m_shares).abs().convert(MyMoneyMoney::precToDenom(KMyMoneyGlobalSettings::pricePrecision()))); | 861 | s1.setPrice((total / statementTransactionUnderImport.m_shares).abs().convertPrecision(file->security(thisaccount.currencyId()).pricePrecision())); | ||
863 | } | 862 | } | ||
864 | if (statementTransactionUnderImport.m_eAction == MyMoneyStatement::Transaction::eaBuy) | 863 | if (statementTransactionUnderImport.m_eAction == MyMoneyStatement::Transaction::eaBuy) | ||
865 | s1.setShares(statementTransactionUnderImport.m_shares.abs()); | 864 | s1.setShares(statementTransactionUnderImport.m_shares.abs()); | ||
866 | else | 865 | else | ||
867 | s1.setShares(-statementTransactionUnderImport.m_shares.abs()); | 866 | s1.setShares(-statementTransactionUnderImport.m_shares.abs()); | ||
868 | s1.setValue(-(statementTransactionUnderImport.m_amount + statementTransactionUnderImport.m_fees.abs())); | 867 | s1.setValue(-(statementTransactionUnderImport.m_amount + statementTransactionUnderImport.m_fees.abs())); | ||
869 | transfervalue = statementTransactionUnderImport.m_amount; | 868 | transfervalue = statementTransactionUnderImport.m_amount; | ||
870 | 869 | | |||
▲ Show 20 Lines • Show All 664 Lines • Show Last 20 Lines |