Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/converter/mymoneygncreader.cpp
Context not available. | |||||
55 | #include "storage/imymoneystorage.h" | 55 | #include "storage/imymoneystorage.h" | ||
---|---|---|---|---|---|
56 | #include "kmymoneyutils.h" | 56 | #include "kmymoneyutils.h" | ||
57 | #include "mymoneyfile.h" | 57 | #include "mymoneyfile.h" | ||
58 | #include "mymoneyschedule.h" | ||||
58 | #include "mymoneyprice.h" | 59 | #include "mymoneyprice.h" | ||
60 | #include "mymoneyexception.h" | ||||
59 | #include "kgncimportoptionsdlg.h" | 61 | #include "kgncimportoptionsdlg.h" | ||
60 | #include "kgncpricesourcedlg.h" | 62 | #include "kgncpricesourcedlg.h" | ||
61 | #include "keditscheduledlg.h" | 63 | #include "keditscheduledlg.h" | ||
Context not available. | |||||
1480 | Some don't seem to be used in practice. Not sure what CREDITLINE s/be converted as. | 1482 | Some don't seem to be used in practice. Not sure what CREDITLINE s/be converted as. | ||
1481 | */ | 1483 | */ | ||
1482 | if ("BANK" == gac->type() || "CHECKING" == gac->type()) { | 1484 | if ("BANK" == gac->type() || "CHECKING" == gac->type()) { | ||
1483 | acc.setAccountType(MyMoneyAccount::Checkings); | 1485 | acc.setAccountType(Account::Checkings); | ||
1484 | } else if ("SAVINGS" == gac->type()) { | 1486 | } else if ("SAVINGS" == gac->type()) { | ||
1485 | acc.setAccountType(MyMoneyAccount::Savings); | 1487 | acc.setAccountType(Account::Savings); | ||
1486 | } else if ("ASSET" == gac->type()) { | 1488 | } else if ("ASSET" == gac->type()) { | ||
1487 | acc.setAccountType(MyMoneyAccount::Asset); | 1489 | acc.setAccountType(Account::Asset); | ||
1488 | } else if ("CASH" == gac->type()) { | 1490 | } else if ("CASH" == gac->type()) { | ||
1489 | acc.setAccountType(MyMoneyAccount::Cash); | 1491 | acc.setAccountType(Account::Cash); | ||
1490 | } else if ("CURRENCY" == gac->type()) { | 1492 | } else if ("CURRENCY" == gac->type()) { | ||
1491 | acc.setAccountType(MyMoneyAccount::Cash); | 1493 | acc.setAccountType(Account::Cash); | ||
1492 | } else if ("STOCK" == gac->type() || "MUTUAL" == gac->type()) { | 1494 | } else if ("STOCK" == gac->type() || "MUTUAL" == gac->type()) { | ||
1493 | // gnucash allows a 'broker' account to be denominated as type STOCK, but with | 1495 | // gnucash allows a 'broker' account to be denominated as type STOCK, but with | ||
1494 | // a currency balance. We do not need to create a stock account for this | 1496 | // a currency balance. We do not need to create a stock account for this | ||
1495 | // actually, the latest version of gnc (1.8.8) doesn't seem to allow you to do | 1497 | // actually, the latest version of gnc (1.8.8) doesn't seem to allow you to do | ||
1496 | // this any more, though I do have one in my own account... | 1498 | // this any more, though I do have one in my own account... | ||
1497 | if (gac->commodity()->isCurrency()) { | 1499 | if (gac->commodity()->isCurrency()) { | ||
1498 | acc.setAccountType(MyMoneyAccount::Investment); | 1500 | acc.setAccountType(Account::Investment); | ||
1499 | } else { | 1501 | } else { | ||
1500 | acc.setAccountType(MyMoneyAccount::Stock); | 1502 | acc.setAccountType(Account::Stock); | ||
1501 | } | 1503 | } | ||
1502 | } else if ("EQUITY" == gac->type()) { | 1504 | } else if ("EQUITY" == gac->type()) { | ||
1503 | acc.setAccountType(MyMoneyAccount::Equity); | 1505 | acc.setAccountType(Account::Equity); | ||
1504 | } else if ("LIABILITY" == gac->type()) { | 1506 | } else if ("LIABILITY" == gac->type()) { | ||
1505 | acc.setAccountType(MyMoneyAccount::Liability); | 1507 | acc.setAccountType(Account::Liability); | ||
1506 | } else if ("CREDIT" == gac->type()) { | 1508 | } else if ("CREDIT" == gac->type()) { | ||
1507 | acc.setAccountType(MyMoneyAccount::CreditCard); | 1509 | acc.setAccountType(Account::CreditCard); | ||
1508 | } else if ("INCOME" == gac->type()) { | 1510 | } else if ("INCOME" == gac->type()) { | ||
1509 | acc.setAccountType(MyMoneyAccount::Income); | 1511 | acc.setAccountType(Account::Income); | ||
1510 | } else if ("EXPENSE" == gac->type()) { | 1512 | } else if ("EXPENSE" == gac->type()) { | ||
1511 | acc.setAccountType(MyMoneyAccount::Expense); | 1513 | acc.setAccountType(Account::Expense); | ||
1512 | } else if ("RECEIVABLE" == gac->type()) { | 1514 | } else if ("RECEIVABLE" == gac->type()) { | ||
1513 | acc.setAccountType(MyMoneyAccount::Asset); | 1515 | acc.setAccountType(Account::Asset); | ||
1514 | } else if ("PAYABLE" == gac->type()) { | 1516 | } else if ("PAYABLE" == gac->type()) { | ||
1515 | acc.setAccountType(MyMoneyAccount::Liability); | 1517 | acc.setAccountType(Account::Liability); | ||
1516 | } else if ("MONEYMRKT" == gac->type()) { | 1518 | } else if ("MONEYMRKT" == gac->type()) { | ||
1517 | acc.setAccountType(MyMoneyAccount::MoneyMarket); | 1519 | acc.setAccountType(Account::MoneyMarket); | ||
1518 | } else { // we have here an account type we can't currently handle | 1520 | } else { // we have here an account type we can't currently handle | ||
1519 | QString em = | 1521 | QString em = | ||
1520 | i18n("Current importer does not recognize GnuCash account type %1", gac->type()); | 1522 | i18n("Current importer does not recognize GnuCash account type %1", gac->type()); | ||
Context not available. | |||||
1523 | // if no parent account is present, assign to one of our standard accounts | 1525 | // if no parent account is present, assign to one of our standard accounts | ||
1524 | if ((acc.parentAccountId().isEmpty()) || (acc.parentAccountId() == m_rootId)) { | 1526 | if ((acc.parentAccountId().isEmpty()) || (acc.parentAccountId() == m_rootId)) { | ||
1525 | switch (acc.accountGroup()) { | 1527 | switch (acc.accountGroup()) { | ||
1526 | case MyMoneyAccount::Asset: | 1528 | case Account::Asset: | ||
1527 | acc.setParentAccountId(m_storage->asset().id()); | 1529 | acc.setParentAccountId(m_storage->asset().id()); | ||
1528 | break; | 1530 | break; | ||
1529 | case MyMoneyAccount::Liability: | 1531 | case Account::Liability: | ||
1530 | acc.setParentAccountId(m_storage->liability().id()); | 1532 | acc.setParentAccountId(m_storage->liability().id()); | ||
1531 | break; | 1533 | break; | ||
1532 | case MyMoneyAccount::Income: | 1534 | case Account::Income: | ||
1533 | acc.setParentAccountId(m_storage->income().id()); | 1535 | acc.setParentAccountId(m_storage->income().id()); | ||
1534 | break; | 1536 | break; | ||
1535 | case MyMoneyAccount::Expense: | 1537 | case Account::Expense: | ||
1536 | acc.setParentAccountId(m_storage->expense().id()); | 1538 | acc.setParentAccountId(m_storage->expense().id()); | ||
1537 | break; | 1539 | break; | ||
1538 | case MyMoneyAccount::Equity: | 1540 | case Account::Equity: | ||
1539 | acc.setParentAccountId(m_storage->equity().id()); | 1541 | acc.setParentAccountId(m_storage->equity().id()); | ||
1540 | break; | 1542 | break; | ||
1541 | default: | 1543 | default: | ||
Context not available. | |||||
1544 | } | 1546 | } | ||
1545 | 1547 | | |||
1546 | // extra processing for a stock account | 1548 | // extra processing for a stock account | ||
1547 | if (acc.accountType() == MyMoneyAccount::Stock) { | 1549 | if (acc.accountType() == Account::Stock) { | ||
1548 | // save the id for later linking to investment account | 1550 | // save the id for later linking to investment account | ||
1549 | m_stockList.append(gac->id()); | 1551 | m_stockList.append(gac->id()); | ||
1550 | // set the equity type | 1552 | // set the equity type | ||
Context not available. | |||||
1708 | // but keeping each in same order as gnucash | 1710 | // but keeping each in same order as gnucash | ||
1709 | 1711 | | |||
1710 | switch (splitAccount.accountGroup()) { | 1712 | switch (splitAccount.accountGroup()) { | ||
1711 | case MyMoneyAccount::Asset: | 1713 | case Account::Asset: | ||
1712 | if (splitAccount.accountType() == MyMoneyAccount::Stock) { | 1714 | if (splitAccount.accountType() == Account::Stock) { | ||
1713 | split.value().isZero() ? | 1715 | split.value().isZero() ? | ||
1714 | split.setAction(MyMoneySplit::ActionAddShares) : // free shares? | 1716 | split.setAction(MyMoneySplit::ActionAddShares) : // free shares? | ||
1715 | split.setAction(MyMoneySplit::ActionBuyShares); | 1717 | split.setAction(MyMoneySplit::ActionBuyShares); | ||
Context not available. | |||||
1754 | } | 1756 | } | ||
1755 | m_splitList.append(split); | 1757 | m_splitList.append(split); | ||
1756 | break; | 1758 | break; | ||
1757 | case MyMoneyAccount::Liability: | 1759 | case Account::Liability: | ||
1758 | split.value().isNegative() ? | 1760 | split.value().isNegative() ? | ||
1759 | split.setAction(MyMoneySplit::ActionWithdrawal) : | 1761 | split.setAction(MyMoneySplit::ActionWithdrawal) : | ||
1760 | split.setAction(MyMoneySplit::ActionDeposit); | 1762 | split.setAction(MyMoneySplit::ActionDeposit); | ||
Context not available. | |||||
1960 | } */ | 1962 | } */ | ||
1961 | // add the split to one of the lists | 1963 | // add the split to one of the lists | ||
1962 | switch (splitAccount.accountGroup()) { | 1964 | switch (splitAccount.accountGroup()) { | ||
1963 | case MyMoneyAccount::Asset: | 1965 | case Account::Asset: | ||
1964 | m_splitList.append(split); | 1966 | m_splitList.append(split); | ||
1965 | break; | 1967 | break; | ||
1966 | case MyMoneyAccount::Liability: | 1968 | case Account::Liability: | ||
1967 | m_liabilitySplitList.append(split); | 1969 | m_liabilitySplitList.append(split); | ||
1968 | break; | 1970 | break; | ||
1969 | default: | 1971 | default: | ||
Context not available. | |||||
2009 | QString gncType; // the gnucash name | 2011 | QString gncType; // the gnucash name | ||
2010 | unsigned char interval; // for date calculation | 2012 | unsigned char interval; // for date calculation | ||
2011 | unsigned int intervalCount; | 2013 | unsigned int intervalCount; | ||
2012 | MyMoneySchedule::occurrenceE occ; // equivalent occurrence code | 2014 | Schedule::Occurrence occ; // equivalent occurrence code | ||
2013 | MyMoneySchedule::weekendOptionE wo; | 2015 | Schedule::WeekendOption wo; | ||
2014 | }; | 2016 | }; | ||
2015 | /* other intervals supported by gnc according to Josh Sled's schema (see above) | 2017 | /* other intervals supported by gnc according to Josh Sled's schema (see above) | ||
2016 | "none" "semi_monthly" | 2018 | "none" "semi_monthly" | ||
Context not available. | |||||
2018 | /* some of these type names do not appear in gnucash and are difficult to generate for | 2020 | /* some of these type names do not appear in gnucash and are difficult to generate for | ||
2019 | pre 2.2 files.They can be generated for 2.2 however, by GncRecurrence::getFrequency() */ | 2021 | pre 2.2 files.They can be generated for 2.2 however, by GncRecurrence::getFrequency() */ | ||
2020 | static convIntvl vi [] = { | 2022 | static convIntvl vi [] = { | ||
2021 | {"once", 'o', 1, MyMoneySchedule::OCCUR_ONCE, MyMoneySchedule::MoveNothing }, | 2023 | {"once", 'o', 1, Schedule::Occurrence::Once, Schedule::WeekendOption::MoveNothing }, | ||
2022 | {"daily" , 'd', 1, MyMoneySchedule::OCCUR_DAILY, MyMoneySchedule::MoveNothing }, | 2024 | {"daily" , 'd', 1, Schedule::Occurrence::Daily, Schedule::WeekendOption::MoveNothing }, | ||
2023 | //{"daily_mf", 'd', 1, MyMoneySchedule::OCCUR_DAILY, MyMoneySchedule::MoveAfter }, doesn't work, need new freq in kmm | 2025 | //{"daily_mf", 'd', 1, Schedule::Occurrence::Daily, Schedule::WeekendOption::MoveAfter }, doesn't work, need new freq in kmm | ||
2024 | {"30-days" , 'd', 30, MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS, MyMoneySchedule::MoveNothing }, | 2026 | {"30-days" , 'd', 30, Schedule::Occurrence::EveryThirtyDays, Schedule::WeekendOption::MoveNothing }, | ||
2025 | {"weekly", 'w', 1, MyMoneySchedule::OCCUR_WEEKLY, MyMoneySchedule::MoveNothing }, | 2027 | {"weekly", 'w', 1, Schedule::Occurrence::Weekly, Schedule::WeekendOption::MoveNothing }, | ||
2026 | {"bi_weekly", 'w', 2, MyMoneySchedule::OCCUR_EVERYOTHERWEEK, MyMoneySchedule::MoveNothing }, | 2028 | {"bi_weekly", 'w', 2, Schedule::Occurrence::EveryOtherWeek, Schedule::WeekendOption::MoveNothing }, | ||
2027 | {"three-weekly", 'w', 3, MyMoneySchedule::OCCUR_EVERYTHREEWEEKS, MyMoneySchedule::MoveNothing }, | 2029 | {"three-weekly", 'w', 3, Schedule::Occurrence::EveryThreeWeeks, Schedule::WeekendOption::MoveNothing }, | ||
2028 | {"four-weekly", 'w', 4, MyMoneySchedule::OCCUR_EVERYFOURWEEKS, | 2030 | {"four-weekly", 'w', 4, Schedule::Occurrence::EveryFourWeeks, | ||
2029 | MyMoneySchedule::MoveNothing }, | 2031 | Schedule::WeekendOption::MoveNothing }, | ||
2030 | {"eight-weekly", 'w', 8, MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS, MyMoneySchedule::MoveNothing }, | 2032 | {"eight-weekly", 'w', 8, Schedule::Occurrence::EveryEightWeeks, Schedule::WeekendOption::MoveNothing }, | ||
2031 | {"monthly", 'm', 1, MyMoneySchedule::OCCUR_MONTHLY, MyMoneySchedule::MoveNothing }, | 2033 | {"monthly", 'm', 1, Schedule::Occurrence::Monthly, Schedule::WeekendOption::MoveNothing }, | ||
2032 | {"two-monthly", 'm', 2, MyMoneySchedule::OCCUR_EVERYOTHERMONTH, | 2034 | {"two-monthly", 'm', 2, Schedule::Occurrence::EveryOtherMonth, | ||
2033 | MyMoneySchedule::MoveNothing }, | 2035 | Schedule::WeekendOption::MoveNothing }, | ||
2034 | {"quarterly", 'm', 3, MyMoneySchedule::OCCUR_QUARTERLY, MyMoneySchedule::MoveNothing }, | 2036 | {"quarterly", 'm', 3, Schedule::Occurrence::Quarterly, Schedule::WeekendOption::MoveNothing }, | ||
2035 | {"tri_annually", 'm', 4, MyMoneySchedule::OCCUR_EVERYFOURMONTHS, MyMoneySchedule::MoveNothing }, | 2037 | {"tri_annually", 'm', 4, Schedule::Occurrence::EveryFourMonths, Schedule::WeekendOption::MoveNothing }, | ||
2036 | {"semi_yearly", 'm', 6, MyMoneySchedule::OCCUR_TWICEYEARLY, MyMoneySchedule::MoveNothing }, | 2038 | {"semi_yearly", 'm', 6, Schedule::Occurrence::TwiceYearly, Schedule::WeekendOption::MoveNothing }, | ||
2037 | {"yearly", 'y', 1, MyMoneySchedule::OCCUR_YEARLY, MyMoneySchedule::MoveNothing }, | 2039 | {"yearly", 'y', 1, Schedule::Occurrence::Yearly, Schedule::WeekendOption::MoveNothing }, | ||
2038 | {"two-yearly", 'y', 2, MyMoneySchedule::OCCUR_EVERYOTHERYEAR, | 2040 | {"two-yearly", 'y', 2, Schedule::Occurrence::EveryOtherYear, | ||
2039 | MyMoneySchedule::MoveNothing }, | 2041 | Schedule::WeekendOption::MoveNothing }, | ||
2040 | {"zzz", 'y', 1, MyMoneySchedule::OCCUR_YEARLY, MyMoneySchedule::MoveNothing} | 2042 | {"zzz", 'y', 1, Schedule::Occurrence::Yearly, Schedule::WeekendOption::MoveNothing} | ||
2041 | // zzz = stopper, may cause problems. what else can we do? | 2043 | // zzz = stopper, may cause problems. what else can we do? | ||
2042 | }; | 2044 | }; | ||
2043 | 2045 | | |||
Context not available. | |||||
2054 | frequency = gre->getFrequency(); | 2056 | frequency = gre->getFrequency(); | ||
2055 | schedEnabled = gsc->enabled(); | 2057 | schedEnabled = gsc->enabled(); | ||
2056 | } | 2058 | } | ||
2057 | sc.setOccurrence(MyMoneySchedule::OCCUR_ONCE); // FIXME - how to convert | 2059 | sc.setOccurrence(Schedule::Occurrence::Once); // FIXME - how to convert | ||
2058 | } else { | 2060 | } else { | ||
2059 | // find this interval | 2061 | // find this interval | ||
2060 | const GncFreqSpec *fs = gsc->getFreqSpec(); | 2062 | const GncFreqSpec *fs = gsc->getFreqSpec(); | ||
Context not available. | |||||
2122 | m_suspectSchedule = true; | 2124 | m_suspectSchedule = true; | ||
2123 | } | 2125 | } | ||
2124 | // payment type, options | 2126 | // payment type, options | ||
2125 | sc.setPaymentType((MyMoneySchedule::paymentTypeE)MyMoneySchedule::STYPE_OTHER); | 2127 | sc.setPaymentType((Schedule::PaymentType)Schedule::PaymentType::Other); | ||
2126 | sc.setFixed(!m_suspectSchedule); // if any probs were found, set it as variable so user will always be prompted | 2128 | sc.setFixed(!m_suspectSchedule); // if any probs were found, set it as variable so user will always be prompted | ||
2127 | // we don't currently have a 'disable' option, but just make sure auto-enter is off if not enabled | 2129 | // we don't currently have a 'disable' option, but just make sure auto-enter is off if not enabled | ||
2128 | //qDebug(QString("%1 and %2").arg(gsc->autoCreate()).arg(schedEnabled)); | 2130 | //qDebug(QString("%1 and %2").arg(gsc->autoCreate()).arg(schedEnabled)); | ||
Context not available. | |||||
2131 | // type | 2133 | // type | ||
2132 | QString actionType = tx.splits().first().action(); | 2134 | QString actionType = tx.splits().first().action(); | ||
2133 | if (actionType == MyMoneySplit::ActionDeposit) { | 2135 | if (actionType == MyMoneySplit::ActionDeposit) { | ||
2134 | sc.setType((MyMoneySchedule::typeE)MyMoneySchedule::TYPE_DEPOSIT); | 2136 | sc.setType((Schedule::Type)Schedule::Type::Deposit); | ||
2135 | } else if (actionType == MyMoneySplit::ActionTransfer) { | 2137 | } else if (actionType == MyMoneySplit::ActionTransfer) { | ||
2136 | sc.setType((MyMoneySchedule::typeE)MyMoneySchedule::TYPE_TRANSFER); | 2138 | sc.setType((Schedule::Type)Schedule::Type::Transfer); | ||
2137 | } else { | 2139 | } else { | ||
2138 | sc.setType((MyMoneySchedule::typeE)MyMoneySchedule::TYPE_BILL); | 2140 | sc.setType((Schedule::Type)Schedule::Type::Bill); | ||
2139 | } | 2141 | } | ||
2140 | // finally, set the transaction pointer | 2142 | // finally, set the transaction pointer | ||
2141 | sc.setTransaction(tx); | 2143 | sc.setTransaction(tx); | ||
Context not available. | |||||
2395 | acc.setLastModified(today); | 2397 | acc.setLastModified(today); | ||
2396 | acc.setLastReconciliationDate(today); | 2398 | acc.setLastReconciliationDate(today); | ||
2397 | acc.setCurrencyId(m_txCommodity); | 2399 | acc.setCurrencyId(m_txCommodity); | ||
2398 | acc.setAccountType(MyMoneyAccount::Asset); | 2400 | acc.setAccountType(Account::Asset); | ||
2399 | acc.setParentAccountId(m_storage->asset().id()); | 2401 | acc.setParentAccountId(m_storage->asset().id()); | ||
2400 | m_storage->addAccount(acc); | 2402 | m_storage->addAccount(acc); | ||
2401 | // assign the gnucash id as the key into the map to find our id | 2403 | // assign the gnucash id as the key into the map to find our id | ||
Context not available. | |||||
2432 | TRY { | 2434 | TRY { | ||
2433 | // gnucash is flexible/weird enough to allow various inconsistencies | 2435 | // gnucash is flexible/weird enough to allow various inconsistencies | ||
2434 | // these are a couple I found in my file, no doubt more will be discovered | 2436 | // these are a couple I found in my file, no doubt more will be discovered | ||
2435 | if ((child.accountType() == MyMoneyAccount::Investment) && | 2437 | if ((child.accountType() == Account::Investment) && | ||
2436 | (parent.accountType() != MyMoneyAccount::Asset)) { | 2438 | (parent.accountType() != Account::Asset)) { | ||
2437 | m_messageList["CC"].append( | 2439 | m_messageList["CC"].append( | ||
2438 | i18n("An Investment account must be a child of an Asset account\n" | 2440 | i18n("An Investment account must be a child of an Asset account\n" | ||
2439 | "Account %1 will be stored under the main Asset account", child.name())); | 2441 | "Account %1 will be stored under the main Asset account", child.name())); | ||
2440 | return m_storage->asset(); | 2442 | return m_storage->asset(); | ||
2441 | } | 2443 | } | ||
2442 | if ((child.accountType() == MyMoneyAccount::Income) && | 2444 | if ((child.accountType() == Account::Income) && | ||
2443 | (parent.accountType() != MyMoneyAccount::Income)) { | 2445 | (parent.accountType() != Account::Income)) { | ||
2444 | m_messageList["CC"].append( | 2446 | m_messageList["CC"].append( | ||
2445 | i18n("An Income account must be a child of an Income account\n" | 2447 | i18n("An Income account must be a child of an Income account\n" | ||
2446 | "Account %1 will be stored under the main Income account", child.name())); | 2448 | "Account %1 will be stored under the main Income account", child.name())); | ||
2447 | return m_storage->income(); | 2449 | return m_storage->income(); | ||
2448 | } | 2450 | } | ||
2449 | if ((child.accountType() == MyMoneyAccount::Expense) && | 2451 | if ((child.accountType() == Account::Expense) && | ||
2450 | (parent.accountType() != MyMoneyAccount::Expense)) { | 2452 | (parent.accountType() != Account::Expense)) { | ||
2451 | m_messageList["CC"].append( | 2453 | m_messageList["CC"].append( | ||
2452 | i18n("An Expense account must be a child of an Expense account\n" | 2454 | i18n("An Expense account must be a child of an Expense account\n" | ||
2453 | "Account %1 will be stored under the main Expense account", child.name())); | 2455 | "Account %1 will be stored under the main Expense account", child.name())); | ||
Context not available. | |||||
2469 | map_accountIds::const_iterator id = m_mapIds.constFind(parentKey); | 2471 | map_accountIds::const_iterator id = m_mapIds.constFind(parentKey); | ||
2470 | if (id != m_mapIds.constEnd()) { | 2472 | if (id != m_mapIds.constEnd()) { | ||
2471 | parent = m_storage->account(id.value()); | 2473 | parent = m_storage->account(id.value()); | ||
2472 | if (parent.accountType() == MyMoneyAccount::Investment) return ; | 2474 | if (parent.accountType() == Account::Investment) return ; | ||
2473 | } | 2475 | } | ||
2474 | // so now, check the investment option requested by the user | 2476 | // so now, check the investment option requested by the user | ||
2475 | // option 0 creates a separate investment account for each stock account | 2477 | // option 0 creates a separate investment account for each stock account | ||
2476 | if (m_investmentOption == 0) { | 2478 | if (m_investmentOption == 0) { | ||
2477 | MyMoneyAccount invAcc(stockAcc); | 2479 | MyMoneyAccount invAcc(stockAcc); | ||
2478 | invAcc.setAccountType(MyMoneyAccount::Investment); | 2480 | invAcc.setAccountType(Account::Investment); | ||
2479 | invAcc.setCurrencyId(QString("")); // we don't know what currency it is!! | 2481 | invAcc.setCurrencyId(QString("")); // we don't know what currency it is!! | ||
2480 | invAcc.setParentAccountId(parentKey); // intersperse it between old parent and child stock acct | 2482 | invAcc.setParentAccountId(parentKey); // intersperse it between old parent and child stock acct | ||
2481 | m_storage->addAccount(invAcc); | 2483 | m_storage->addAccount(invAcc); | ||
Context not available. | |||||
2500 | QLineEdit::Normal, i18n("My Investments"), &ok); | 2502 | QLineEdit::Normal, i18n("My Investments"), &ok); | ||
2501 | } | 2503 | } | ||
2502 | singleInvAcc.setName(invAccName); | 2504 | singleInvAcc.setName(invAccName); | ||
2503 | singleInvAcc.setAccountType(MyMoneyAccount::Investment); | 2505 | singleInvAcc.setAccountType(Account::Investment); | ||
2504 | singleInvAcc.setCurrencyId(QString("")); | 2506 | singleInvAcc.setCurrencyId(QString("")); | ||
2505 | singleInvAcc.setParentAccountId(m_storage->asset().id()); | 2507 | singleInvAcc.setParentAccountId(m_storage->asset().id()); | ||
2506 | m_storage->addAccount(singleInvAcc); | 2508 | m_storage->addAccount(singleInvAcc); | ||
Context not available. | |||||
2526 | m_storage->accountList(list); | 2528 | m_storage->accountList(list); | ||
2527 | // build a list of candidates for the input box | 2529 | // build a list of candidates for the input box | ||
2528 | for (acc = list.begin(); acc != list.end(); ++acc) { | 2530 | for (acc = list.begin(); acc != list.end(); ++acc) { | ||
2529 | // if (((*acc).accountGroup() == MyMoneyAccount::Asset) && ((*acc).accountType() != MyMoneyAccount::Stock)) accList.append ((*acc).name()); | 2531 | // if (((*acc).accountGroup() == Account::Asset) && ((*acc).accountType() != Account::Stock)) accList.append ((*acc).name()); | ||
2530 | if ((*acc).accountType() == MyMoneyAccount::Investment) accList.append((*acc).name()); | 2532 | if ((*acc).accountType() == Account::Investment) accList.append((*acc).name()); | ||
2531 | } | 2533 | } | ||
2532 | //if (accList.isEmpty()) qWarning ("No available accounts"); | 2534 | //if (accList.isEmpty()) qWarning ("No available accounts"); | ||
2533 | bool ok = false; | 2535 | bool ok = false; | ||
Context not available. | |||||
2545 | if (acc != list.end()) { // an account was selected | 2547 | if (acc != list.end()) { // an account was selected | ||
2546 | invAcc = *acc; | 2548 | invAcc = *acc; | ||
2547 | } else { // a new account name was entered | 2549 | } else { // a new account name was entered | ||
2548 | invAcc.setAccountType(MyMoneyAccount::Investment); | 2550 | invAcc.setAccountType(Account::Investment); | ||
2549 | invAcc.setName(invAccName); | 2551 | invAcc.setName(invAccName); | ||
2550 | invAcc.setCurrencyId(QString("")); | 2552 | invAcc.setCurrencyId(QString("")); | ||
2551 | invAcc.setParentAccountId(m_storage->asset().id()); | 2553 | invAcc.setParentAccountId(m_storage->asset().id()); | ||
2552 | m_storage->addAccount(invAcc); | 2554 | m_storage->addAccount(invAcc); | ||
2553 | ok = true; | 2555 | ok = true; | ||
2554 | } | 2556 | } | ||
2555 | if (invAcc.accountType() == MyMoneyAccount::Investment) { | 2557 | if (invAcc.accountType() == Account::Investment) { | ||
2556 | ok = true; | 2558 | ok = true; | ||
2557 | } else { | 2559 | } else { | ||
2558 | // this code is probably not going to be implemented coz we can't change account types (??) | 2560 | // this code is probably not going to be implemented coz we can't change account types (??) | ||
Context not available. |