Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/converter/mymoneystatementreader.cpp
Context not available. | |||||
48 | // Project Headers | 48 | // Project Headers | ||
---|---|---|---|---|---|
49 | 49 | | |||
50 | #include "mymoneyfile.h" | 50 | #include "mymoneyfile.h" | ||
51 | #include "mymoneyprice.h" | ||||
52 | #include "mymoneytransactionfilter.h" | ||||
53 | #include "mymoneypayee.h" | ||||
51 | #include "mymoneystatement.h" | 54 | #include "mymoneystatement.h" | ||
52 | #include "kmymoneyglobalsettings.h" | 55 | #include "kmymoneyglobalsettings.h" | ||
53 | #include "transactioneditor.h" | 56 | #include "transactioneditor.h" | ||
Context not available. | |||||
135 | // Needed to find/create category:sub-categories | 138 | // Needed to find/create category:sub-categories | ||
136 | MyMoneyFile* file = MyMoneyFile::instance(); | 139 | MyMoneyFile* file = MyMoneyFile::instance(); | ||
137 | 140 | | |||
138 | QString id = file->categoryToAccount(name, MyMoneyAccount::UnknownAccountType); | 141 | QString id = file->categoryToAccount(name, Account::Unknown); | ||
139 | // if it does not exist, we have to create it | 142 | // if it does not exist, we have to create it | ||
140 | if (id.isEmpty()) { | 143 | if (id.isEmpty()) { | ||
141 | MyMoneyAccount newAccount; | 144 | MyMoneyAccount newAccount; | ||
Context not available. | |||||
211 | MyMoneyAccount acc = file->account(s.accountId()); | 214 | MyMoneyAccount acc = file->account(s.accountId()); | ||
212 | // stock split shouldn't be fee or interest bacause it won't play nice with dissectTransaction | 215 | // stock split shouldn't be fee or interest bacause it won't play nice with dissectTransaction | ||
213 | // it was caused by processTransactionEntry adding splits in wrong order != with manual transaction entering | 216 | // it was caused by processTransactionEntry adding splits in wrong order != with manual transaction entering | ||
214 | if (acc.accountGroup() == MyMoneyAccount::Expense || acc.accountGroup() == MyMoneyAccount::Income) { | 217 | if (acc.accountGroup() == Account::Expense || acc.accountGroup() == Account::Income) { | ||
215 | foreach (auto sNew , t.splits()) { | 218 | foreach (auto sNew , t.splits()) { | ||
216 | acc = file->account(sNew.accountId()); | 219 | acc = file->account(sNew.accountId()); | ||
217 | if (acc.accountGroup() != MyMoneyAccount::Expense && // shouldn't be fee | 220 | if (acc.accountGroup() != Account::Expense && // shouldn't be fee | ||
218 | acc.accountGroup() != MyMoneyAccount::Income && // shouldn't be interest | 221 | acc.accountGroup() != Account::Income && // shouldn't be interest | ||
219 | (sNew.value() != sNew.shares() || // shouldn't be checking account... | 222 | (sNew.value() != sNew.shares() || // shouldn't be checking account... | ||
220 | (sNew.value() == sNew.shares() && sNew.price() != MyMoneyMoney::ONE))) { // ...but sometimes it may look like checking account | 223 | (sNew.value() == sNew.shares() && sNew.price() != MyMoneyMoney::ONE))) { // ...but sometimes it may look like checking account | ||
221 | s = sNew; | 224 | s = sNew; | ||
Context not available. | |||||
378 | 381 | | |||
379 | switch (s.m_eType) { | 382 | switch (s.m_eType) { | ||
380 | case MyMoneyStatement::etCheckings: | 383 | case MyMoneyStatement::etCheckings: | ||
381 | m_account.setAccountType(MyMoneyAccount::Checkings); | 384 | m_account.setAccountType(Account::Checkings); | ||
382 | break; | 385 | break; | ||
383 | case MyMoneyStatement::etSavings: | 386 | case MyMoneyStatement::etSavings: | ||
384 | m_account.setAccountType(MyMoneyAccount::Savings); | 387 | m_account.setAccountType(Account::Savings); | ||
385 | break; | 388 | break; | ||
386 | case MyMoneyStatement::etInvestment: | 389 | case MyMoneyStatement::etInvestment: | ||
387 | //testing support for investment statements! | 390 | //testing support for investment statements! | ||
388 | //m_userAbort = true; | 391 | //m_userAbort = true; | ||
389 | //KMessageBox::error(kmymoney, i18n("This is an investment statement. These are not supported currently."), i18n("Critical Error")); | 392 | //KMessageBox::error(kmymoney, i18n("This is an investment statement. These are not supported currently."), i18n("Critical Error")); | ||
390 | m_account.setAccountType(MyMoneyAccount::Investment); | 393 | m_account.setAccountType(Account::Investment); | ||
391 | break; | 394 | break; | ||
392 | case MyMoneyStatement::etCreditCard: | 395 | case MyMoneyStatement::etCreditCard: | ||
393 | m_account.setAccountType(MyMoneyAccount::CreditCard); | 396 | m_account.setAccountType(Account::CreditCard); | ||
394 | break; | 397 | break; | ||
395 | default: | 398 | default: | ||
396 | m_account.setAccountType(MyMoneyAccount::UnknownAccountType); | 399 | m_account.setAccountType(Account::Unknown); | ||
397 | break; | 400 | break; | ||
398 | } | 401 | } | ||
399 | 402 | | |||
Context not available. | |||||
657 | MyMoneyAccount thisaccount = m_account; | 660 | MyMoneyAccount thisaccount = m_account; | ||
658 | QString brokerageactid; | 661 | QString brokerageactid; | ||
659 | 662 | | |||
660 | if (thisaccount.accountType() == MyMoneyAccount::Investment) { | 663 | if (thisaccount.accountType() == Account::Investment) { | ||
661 | // determine the brokerage account | 664 | // determine the brokerage account | ||
662 | brokerageactid = m_account.value("kmm-brokerage-account").toUtf8(); | 665 | brokerageactid = m_account.value("kmm-brokerage-account").toUtf8(); | ||
663 | if (brokerageactid.isEmpty()) { | 666 | if (brokerageactid.isEmpty()) { | ||
Context not available. | |||||
726 | if (!security.id().isEmpty()) { | 729 | if (!security.id().isEmpty()) { | ||
727 | thisaccount = MyMoneyAccount(); | 730 | thisaccount = MyMoneyAccount(); | ||
728 | thisaccount.setName(security.name()); | 731 | thisaccount.setName(security.name()); | ||
729 | thisaccount.setAccountType(MyMoneyAccount::Stock); | 732 | thisaccount.setAccountType(Account::Stock); | ||
730 | thisaccount.setCurrencyId(security.id()); | 733 | thisaccount.setCurrencyId(security.id()); | ||
731 | currencyid = thisaccount.currencyId(); | 734 | currencyid = thisaccount.currencyId(); | ||
732 | 735 | | |||
Context not available. | |||||
1020 | 1023 | | |||
1021 | auto filterProxyModel = new AccountNamesFilterProxyModel(this); | 1024 | auto filterProxyModel = new AccountNamesFilterProxyModel(this); | ||
1022 | filterProxyModel->setHideEquityAccounts(!KMyMoneyGlobalSettings::expertMode()); | 1025 | filterProxyModel->setHideEquityAccounts(!KMyMoneyGlobalSettings::expertMode()); | ||
1023 | filterProxyModel->addAccountGroup(QVector<MyMoneyAccount::_accountTypeE> {MyMoneyAccount::Asset, MyMoneyAccount::Liability, MyMoneyAccount::Equity, MyMoneyAccount::Income, MyMoneyAccount::Expense}); | 1026 | filterProxyModel->addAccountGroup(QVector<Account> {Account::Asset, Account::Liability, Account::Equity, Account::Income, Account::Expense}); | ||
1024 | 1027 | | |||
1025 | auto const model = Models::instance()->accountsModel(); | 1028 | auto const model = Models::instance()->accountsModel(); | ||
1026 | filterProxyModel->setSourceModel(model); | 1029 | filterProxyModel->setSourceModel(model); | ||
Context not available. | |||||
1080 | } | 1083 | } | ||
1081 | } | 1084 | } | ||
1082 | 1085 | | |||
1083 | if (thisaccount.accountType() != MyMoneyAccount::Stock) { | 1086 | if (thisaccount.accountType() != Account::Stock) { | ||
1084 | // | 1087 | // | ||
1085 | // Fill in other side of the transaction (category/etc) based on payee | 1088 | // Fill in other side of the transaction (category/etc) based on payee | ||
1086 | // | 1089 | // | ||
Context not available. | |||||
1275 | QString MyMoneyStatementReader::SelectBrokerageAccount() | 1278 | QString MyMoneyStatementReader::SelectBrokerageAccount() | ||
1276 | { | 1279 | { | ||
1277 | if (m_brokerageAccount.id().isEmpty()) { | 1280 | if (m_brokerageAccount.id().isEmpty()) { | ||
1278 | m_brokerageAccount.setAccountType(MyMoneyAccount::Checkings); | 1281 | m_brokerageAccount.setAccountType(Account::Checkings); | ||
1279 | if (!m_userAbort) | 1282 | if (!m_userAbort) | ||
1280 | m_userAbort = ! selectOrCreateAccount(Select, m_brokerageAccount); | 1283 | m_userAbort = ! selectOrCreateAccount(Select, m_brokerageAccount); | ||
1281 | } | 1284 | } | ||
Context not available. | |||||
1338 | } | 1341 | } | ||
1339 | 1342 | | |||
1340 | KMyMoneyUtils::categoryTypeE type; | 1343 | KMyMoneyUtils::categoryTypeE type; | ||
1341 | if (account.accountType() == MyMoneyAccount::Checkings) { | 1344 | if (account.accountType() == Account::Checkings) { | ||
1342 | type = static_cast<KMyMoneyUtils::categoryTypeE>(KMyMoneyUtils::checking); | 1345 | type = static_cast<KMyMoneyUtils::categoryTypeE>(KMyMoneyUtils::checking); | ||
1343 | } else if (account.accountType() == MyMoneyAccount::Savings) { | 1346 | } else if (account.accountType() == Account::Savings) { | ||
1344 | type = static_cast<KMyMoneyUtils::categoryTypeE>(KMyMoneyUtils::savings); | 1347 | type = static_cast<KMyMoneyUtils::categoryTypeE>(KMyMoneyUtils::savings); | ||
1345 | } else if (account.accountType() == MyMoneyAccount::Investment) { | 1348 | } else if (account.accountType() == Account::Investment) { | ||
1346 | type = static_cast<KMyMoneyUtils::categoryTypeE>(KMyMoneyUtils::investment); | 1349 | type = static_cast<KMyMoneyUtils::categoryTypeE>(KMyMoneyUtils::investment); | ||
1347 | } else if (account.accountType() == MyMoneyAccount::CreditCard) { | 1350 | } else if (account.accountType() == Account::CreditCard) { | ||
1348 | type = static_cast<KMyMoneyUtils::categoryTypeE>(KMyMoneyUtils::creditCard); | 1351 | type = static_cast<KMyMoneyUtils::categoryTypeE>(KMyMoneyUtils::creditCard); | ||
1349 | } else { | 1352 | } else { | ||
1350 | type = static_cast<KMyMoneyUtils::categoryTypeE>(KMyMoneyUtils::asset | KMyMoneyUtils::liability); | 1353 | type = static_cast<KMyMoneyUtils::categoryTypeE>(KMyMoneyUtils::asset | KMyMoneyUtils::liability); | ||
Context not available. |