diff --git a/kmymoney/converter/existingtransactionmatchfinder.cpp b/kmymoney/converter/existingtransactionmatchfinder.cpp --- a/kmymoney/converter/existingtransactionmatchfinder.cpp +++ b/kmymoney/converter/existingtransactionmatchfinder.cpp @@ -19,6 +19,7 @@ #include #include "mymoneyfile.h" +#include "mymoneytransactionfilter.h" ExistingTransactionMatchFinder::ExistingTransactionMatchFinder(int matchWindow) : TransactionMatchFinder(matchWindow) diff --git a/kmymoney/converter/mymoneygncreader.cpp b/kmymoney/converter/mymoneygncreader.cpp --- a/kmymoney/converter/mymoneygncreader.cpp +++ b/kmymoney/converter/mymoneygncreader.cpp @@ -55,7 +55,9 @@ #include "storage/imymoneystorage.h" #include "kmymoneyutils.h" #include "mymoneyfile.h" +#include "mymoneyschedule.h" #include "mymoneyprice.h" +#include "mymoneyexception.h" #include "kgncimportoptionsdlg.h" #include "kgncpricesourcedlg.h" #include "keditscheduledlg.h" @@ -1480,41 +1482,41 @@ Some don't seem to be used in practice. Not sure what CREDITLINE s/be converted as. */ if ("BANK" == gac->type() || "CHECKING" == gac->type()) { - acc.setAccountType(MyMoneyAccount::Checkings); + acc.setAccountType(Account::Checkings); } else if ("SAVINGS" == gac->type()) { - acc.setAccountType(MyMoneyAccount::Savings); + acc.setAccountType(Account::Savings); } else if ("ASSET" == gac->type()) { - acc.setAccountType(MyMoneyAccount::Asset); + acc.setAccountType(Account::Asset); } else if ("CASH" == gac->type()) { - acc.setAccountType(MyMoneyAccount::Cash); + acc.setAccountType(Account::Cash); } else if ("CURRENCY" == gac->type()) { - acc.setAccountType(MyMoneyAccount::Cash); + acc.setAccountType(Account::Cash); } else if ("STOCK" == gac->type() || "MUTUAL" == gac->type()) { // gnucash allows a 'broker' account to be denominated as type STOCK, but with // a currency balance. We do not need to create a stock account for this // actually, the latest version of gnc (1.8.8) doesn't seem to allow you to do // this any more, though I do have one in my own account... if (gac->commodity()->isCurrency()) { - acc.setAccountType(MyMoneyAccount::Investment); + acc.setAccountType(Account::Investment); } else { - acc.setAccountType(MyMoneyAccount::Stock); + acc.setAccountType(Account::Stock); } } else if ("EQUITY" == gac->type()) { - acc.setAccountType(MyMoneyAccount::Equity); + acc.setAccountType(Account::Equity); } else if ("LIABILITY" == gac->type()) { - acc.setAccountType(MyMoneyAccount::Liability); + acc.setAccountType(Account::Liability); } else if ("CREDIT" == gac->type()) { - acc.setAccountType(MyMoneyAccount::CreditCard); + acc.setAccountType(Account::CreditCard); } else if ("INCOME" == gac->type()) { - acc.setAccountType(MyMoneyAccount::Income); + acc.setAccountType(Account::Income); } else if ("EXPENSE" == gac->type()) { - acc.setAccountType(MyMoneyAccount::Expense); + acc.setAccountType(Account::Expense); } else if ("RECEIVABLE" == gac->type()) { - acc.setAccountType(MyMoneyAccount::Asset); + acc.setAccountType(Account::Asset); } else if ("PAYABLE" == gac->type()) { - acc.setAccountType(MyMoneyAccount::Liability); + acc.setAccountType(Account::Liability); } else if ("MONEYMRKT" == gac->type()) { - acc.setAccountType(MyMoneyAccount::MoneyMarket); + acc.setAccountType(Account::MoneyMarket); } else { // we have here an account type we can't currently handle QString em = i18n("Current importer does not recognize GnuCash account type %1", gac->type()); @@ -1523,19 +1525,19 @@ // if no parent account is present, assign to one of our standard accounts if ((acc.parentAccountId().isEmpty()) || (acc.parentAccountId() == m_rootId)) { switch (acc.accountGroup()) { - case MyMoneyAccount::Asset: + case Account::Asset: acc.setParentAccountId(m_storage->asset().id()); break; - case MyMoneyAccount::Liability: + case Account::Liability: acc.setParentAccountId(m_storage->liability().id()); break; - case MyMoneyAccount::Income: + case Account::Income: acc.setParentAccountId(m_storage->income().id()); break; - case MyMoneyAccount::Expense: + case Account::Expense: acc.setParentAccountId(m_storage->expense().id()); break; - case MyMoneyAccount::Equity: + case Account::Equity: acc.setParentAccountId(m_storage->equity().id()); break; default: @@ -1544,7 +1546,7 @@ } // extra processing for a stock account - if (acc.accountType() == MyMoneyAccount::Stock) { + if (acc.accountType() == Account::Stock) { // save the id for later linking to investment account m_stockList.append(gac->id()); // set the equity type @@ -1708,8 +1710,8 @@ // but keeping each in same order as gnucash switch (splitAccount.accountGroup()) { - case MyMoneyAccount::Asset: - if (splitAccount.accountType() == MyMoneyAccount::Stock) { + case Account::Asset: + if (splitAccount.accountType() == Account::Stock) { split.value().isZero() ? split.setAction(MyMoneySplit::ActionAddShares) : // free shares? split.setAction(MyMoneySplit::ActionBuyShares); @@ -1754,7 +1756,7 @@ } m_splitList.append(split); break; - case MyMoneyAccount::Liability: + case Account::Liability: split.value().isNegative() ? split.setAction(MyMoneySplit::ActionWithdrawal) : split.setAction(MyMoneySplit::ActionDeposit); @@ -1960,10 +1962,10 @@ } */ // add the split to one of the lists switch (splitAccount.accountGroup()) { - case MyMoneyAccount::Asset: + case Account::Asset: m_splitList.append(split); break; - case MyMoneyAccount::Liability: + case Account::Liability: m_liabilitySplitList.append(split); break; default: @@ -2009,8 +2011,8 @@ QString gncType; // the gnucash name unsigned char interval; // for date calculation unsigned int intervalCount; - MyMoneySchedule::occurrenceE occ; // equivalent occurrence code - MyMoneySchedule::weekendOptionE wo; + Schedule::Occurrence occ; // equivalent occurrence code + Schedule::WeekendOption wo; }; /* other intervals supported by gnc according to Josh Sled's schema (see above) "none" "semi_monthly" @@ -2018,26 +2020,26 @@ /* some of these type names do not appear in gnucash and are difficult to generate for pre 2.2 files.They can be generated for 2.2 however, by GncRecurrence::getFrequency() */ static convIntvl vi [] = { - {"once", 'o', 1, MyMoneySchedule::OCCUR_ONCE, MyMoneySchedule::MoveNothing }, - {"daily" , 'd', 1, MyMoneySchedule::OCCUR_DAILY, MyMoneySchedule::MoveNothing }, - //{"daily_mf", 'd', 1, MyMoneySchedule::OCCUR_DAILY, MyMoneySchedule::MoveAfter }, doesn't work, need new freq in kmm - {"30-days" , 'd', 30, MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS, MyMoneySchedule::MoveNothing }, - {"weekly", 'w', 1, MyMoneySchedule::OCCUR_WEEKLY, MyMoneySchedule::MoveNothing }, - {"bi_weekly", 'w', 2, MyMoneySchedule::OCCUR_EVERYOTHERWEEK, MyMoneySchedule::MoveNothing }, - {"three-weekly", 'w', 3, MyMoneySchedule::OCCUR_EVERYTHREEWEEKS, MyMoneySchedule::MoveNothing }, - {"four-weekly", 'w', 4, MyMoneySchedule::OCCUR_EVERYFOURWEEKS, - MyMoneySchedule::MoveNothing }, - {"eight-weekly", 'w', 8, MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS, MyMoneySchedule::MoveNothing }, - {"monthly", 'm', 1, MyMoneySchedule::OCCUR_MONTHLY, MyMoneySchedule::MoveNothing }, - {"two-monthly", 'm', 2, MyMoneySchedule::OCCUR_EVERYOTHERMONTH, - MyMoneySchedule::MoveNothing }, - {"quarterly", 'm', 3, MyMoneySchedule::OCCUR_QUARTERLY, MyMoneySchedule::MoveNothing }, - {"tri_annually", 'm', 4, MyMoneySchedule::OCCUR_EVERYFOURMONTHS, MyMoneySchedule::MoveNothing }, - {"semi_yearly", 'm', 6, MyMoneySchedule::OCCUR_TWICEYEARLY, MyMoneySchedule::MoveNothing }, - {"yearly", 'y', 1, MyMoneySchedule::OCCUR_YEARLY, MyMoneySchedule::MoveNothing }, - {"two-yearly", 'y', 2, MyMoneySchedule::OCCUR_EVERYOTHERYEAR, - MyMoneySchedule::MoveNothing }, - {"zzz", 'y', 1, MyMoneySchedule::OCCUR_YEARLY, MyMoneySchedule::MoveNothing} + {"once", 'o', 1, Schedule::Occurrence::Once, Schedule::WeekendOption::MoveNothing }, + {"daily" , 'd', 1, Schedule::Occurrence::Daily, Schedule::WeekendOption::MoveNothing }, + //{"daily_mf", 'd', 1, Schedule::Occurrence::Daily, Schedule::WeekendOption::MoveAfter }, doesn't work, need new freq in kmm + {"30-days" , 'd', 30, Schedule::Occurrence::EveryThirtyDays, Schedule::WeekendOption::MoveNothing }, + {"weekly", 'w', 1, Schedule::Occurrence::Weekly, Schedule::WeekendOption::MoveNothing }, + {"bi_weekly", 'w', 2, Schedule::Occurrence::EveryOtherWeek, Schedule::WeekendOption::MoveNothing }, + {"three-weekly", 'w', 3, Schedule::Occurrence::EveryThreeWeeks, Schedule::WeekendOption::MoveNothing }, + {"four-weekly", 'w', 4, Schedule::Occurrence::EveryFourWeeks, + Schedule::WeekendOption::MoveNothing }, + {"eight-weekly", 'w', 8, Schedule::Occurrence::EveryEightWeeks, Schedule::WeekendOption::MoveNothing }, + {"monthly", 'm', 1, Schedule::Occurrence::Monthly, Schedule::WeekendOption::MoveNothing }, + {"two-monthly", 'm', 2, Schedule::Occurrence::EveryOtherMonth, + Schedule::WeekendOption::MoveNothing }, + {"quarterly", 'm', 3, Schedule::Occurrence::Quarterly, Schedule::WeekendOption::MoveNothing }, + {"tri_annually", 'm', 4, Schedule::Occurrence::EveryFourMonths, Schedule::WeekendOption::MoveNothing }, + {"semi_yearly", 'm', 6, Schedule::Occurrence::TwiceYearly, Schedule::WeekendOption::MoveNothing }, + {"yearly", 'y', 1, Schedule::Occurrence::Yearly, Schedule::WeekendOption::MoveNothing }, + {"two-yearly", 'y', 2, Schedule::Occurrence::EveryOtherYear, + Schedule::WeekendOption::MoveNothing }, + {"zzz", 'y', 1, Schedule::Occurrence::Yearly, Schedule::WeekendOption::MoveNothing} // zzz = stopper, may cause problems. what else can we do? }; @@ -2054,7 +2056,7 @@ frequency = gre->getFrequency(); schedEnabled = gsc->enabled(); } - sc.setOccurrence(MyMoneySchedule::OCCUR_ONCE); // FIXME - how to convert + sc.setOccurrence(Schedule::Occurrence::Once); // FIXME - how to convert } else { // find this interval const GncFreqSpec *fs = gsc->getFreqSpec(); @@ -2122,7 +2124,7 @@ m_suspectSchedule = true; } // payment type, options - sc.setPaymentType((MyMoneySchedule::paymentTypeE)MyMoneySchedule::STYPE_OTHER); + sc.setPaymentType((Schedule::PaymentType)Schedule::PaymentType::Other); sc.setFixed(!m_suspectSchedule); // if any probs were found, set it as variable so user will always be prompted // we don't currently have a 'disable' option, but just make sure auto-enter is off if not enabled //qDebug(QString("%1 and %2").arg(gsc->autoCreate()).arg(schedEnabled)); @@ -2131,11 +2133,11 @@ // type QString actionType = tx.splits().first().action(); if (actionType == MyMoneySplit::ActionDeposit) { - sc.setType((MyMoneySchedule::typeE)MyMoneySchedule::TYPE_DEPOSIT); + sc.setType((Schedule::Type)Schedule::Type::Deposit); } else if (actionType == MyMoneySplit::ActionTransfer) { - sc.setType((MyMoneySchedule::typeE)MyMoneySchedule::TYPE_TRANSFER); + sc.setType((Schedule::Type)Schedule::Type::Transfer); } else { - sc.setType((MyMoneySchedule::typeE)MyMoneySchedule::TYPE_BILL); + sc.setType((Schedule::Type)Schedule::Type::Bill); } // finally, set the transaction pointer sc.setTransaction(tx); @@ -2395,7 +2397,7 @@ acc.setLastModified(today); acc.setLastReconciliationDate(today); acc.setCurrencyId(m_txCommodity); - acc.setAccountType(MyMoneyAccount::Asset); + acc.setAccountType(Account::Asset); acc.setParentAccountId(m_storage->asset().id()); m_storage->addAccount(acc); // assign the gnucash id as the key into the map to find our id @@ -2432,22 +2434,22 @@ TRY { // gnucash is flexible/weird enough to allow various inconsistencies // these are a couple I found in my file, no doubt more will be discovered - if ((child.accountType() == MyMoneyAccount::Investment) && - (parent.accountType() != MyMoneyAccount::Asset)) { + if ((child.accountType() == Account::Investment) && + (parent.accountType() != Account::Asset)) { m_messageList["CC"].append( i18n("An Investment account must be a child of an Asset account\n" "Account %1 will be stored under the main Asset account", child.name())); return m_storage->asset(); } - if ((child.accountType() == MyMoneyAccount::Income) && - (parent.accountType() != MyMoneyAccount::Income)) { + if ((child.accountType() == Account::Income) && + (parent.accountType() != Account::Income)) { m_messageList["CC"].append( i18n("An Income account must be a child of an Income account\n" "Account %1 will be stored under the main Income account", child.name())); return m_storage->income(); } - if ((child.accountType() == MyMoneyAccount::Expense) && - (parent.accountType() != MyMoneyAccount::Expense)) { + if ((child.accountType() == Account::Expense) && + (parent.accountType() != Account::Expense)) { m_messageList["CC"].append( i18n("An Expense account must be a child of an Expense account\n" "Account %1 will be stored under the main Expense account", child.name())); @@ -2469,13 +2471,13 @@ map_accountIds::const_iterator id = m_mapIds.constFind(parentKey); if (id != m_mapIds.constEnd()) { parent = m_storage->account(id.value()); - if (parent.accountType() == MyMoneyAccount::Investment) return ; + if (parent.accountType() == Account::Investment) return ; } // so now, check the investment option requested by the user // option 0 creates a separate investment account for each stock account if (m_investmentOption == 0) { MyMoneyAccount invAcc(stockAcc); - invAcc.setAccountType(MyMoneyAccount::Investment); + invAcc.setAccountType(Account::Investment); invAcc.setCurrencyId(QString("")); // we don't know what currency it is!! invAcc.setParentAccountId(parentKey); // intersperse it between old parent and child stock acct m_storage->addAccount(invAcc); @@ -2500,7 +2502,7 @@ QLineEdit::Normal, i18n("My Investments"), &ok); } singleInvAcc.setName(invAccName); - singleInvAcc.setAccountType(MyMoneyAccount::Investment); + singleInvAcc.setAccountType(Account::Investment); singleInvAcc.setCurrencyId(QString("")); singleInvAcc.setParentAccountId(m_storage->asset().id()); m_storage->addAccount(singleInvAcc); @@ -2526,8 +2528,8 @@ m_storage->accountList(list); // build a list of candidates for the input box for (acc = list.begin(); acc != list.end(); ++acc) { - // if (((*acc).accountGroup() == MyMoneyAccount::Asset) && ((*acc).accountType() != MyMoneyAccount::Stock)) accList.append ((*acc).name()); - if ((*acc).accountType() == MyMoneyAccount::Investment) accList.append((*acc).name()); + // if (((*acc).accountGroup() == Account::Asset) && ((*acc).accountType() != Account::Stock)) accList.append ((*acc).name()); + if ((*acc).accountType() == Account::Investment) accList.append((*acc).name()); } //if (accList.isEmpty()) qWarning ("No available accounts"); bool ok = false; @@ -2545,14 +2547,14 @@ if (acc != list.end()) { // an account was selected invAcc = *acc; } else { // a new account name was entered - invAcc.setAccountType(MyMoneyAccount::Investment); + invAcc.setAccountType(Account::Investment); invAcc.setName(invAccName); invAcc.setCurrencyId(QString("")); invAcc.setParentAccountId(m_storage->asset().id()); m_storage->addAccount(invAcc); ok = true; } - if (invAcc.accountType() == MyMoneyAccount::Investment) { + if (invAcc.accountType() == Account::Investment) { ok = true; } else { // this code is probably not going to be implemented coz we can't change account types (??) diff --git a/kmymoney/converter/mymoneystatementreader.cpp b/kmymoney/converter/mymoneystatementreader.cpp --- a/kmymoney/converter/mymoneystatementreader.cpp +++ b/kmymoney/converter/mymoneystatementreader.cpp @@ -48,6 +48,9 @@ // Project Headers #include "mymoneyfile.h" +#include "mymoneyprice.h" +#include "mymoneytransactionfilter.h" +#include "mymoneypayee.h" #include "mymoneystatement.h" #include "kmymoneyglobalsettings.h" #include "transactioneditor.h" @@ -135,7 +138,7 @@ // Needed to find/create category:sub-categories MyMoneyFile* file = MyMoneyFile::instance(); - QString id = file->categoryToAccount(name, MyMoneyAccount::UnknownAccountType); + QString id = file->categoryToAccount(name, Account::Unknown); // if it does not exist, we have to create it if (id.isEmpty()) { MyMoneyAccount newAccount; @@ -211,11 +214,11 @@ MyMoneyAccount acc = file->account(s.accountId()); // stock split shouldn't be fee or interest bacause it won't play nice with dissectTransaction // it was caused by processTransactionEntry adding splits in wrong order != with manual transaction entering - if (acc.accountGroup() == MyMoneyAccount::Expense || acc.accountGroup() == MyMoneyAccount::Income) { + if (acc.accountGroup() == Account::Expense || acc.accountGroup() == Account::Income) { foreach (auto sNew , t.splits()) { acc = file->account(sNew.accountId()); - if (acc.accountGroup() != MyMoneyAccount::Expense && // shouldn't be fee - acc.accountGroup() != MyMoneyAccount::Income && // shouldn't be interest + if (acc.accountGroup() != Account::Expense && // shouldn't be fee + acc.accountGroup() != Account::Income && // shouldn't be interest (sNew.value() != sNew.shares() || // shouldn't be checking account... (sNew.value() == sNew.shares() && sNew.price() != MyMoneyMoney::ONE))) { // ...but sometimes it may look like checking account s = sNew; @@ -378,22 +381,22 @@ switch (s.m_eType) { case MyMoneyStatement::etCheckings: - m_account.setAccountType(MyMoneyAccount::Checkings); + m_account.setAccountType(Account::Checkings); break; case MyMoneyStatement::etSavings: - m_account.setAccountType(MyMoneyAccount::Savings); + m_account.setAccountType(Account::Savings); break; case MyMoneyStatement::etInvestment: //testing support for investment statements! //m_userAbort = true; //KMessageBox::error(kmymoney, i18n("This is an investment statement. These are not supported currently."), i18n("Critical Error")); - m_account.setAccountType(MyMoneyAccount::Investment); + m_account.setAccountType(Account::Investment); break; case MyMoneyStatement::etCreditCard: - m_account.setAccountType(MyMoneyAccount::CreditCard); + m_account.setAccountType(Account::CreditCard); break; default: - m_account.setAccountType(MyMoneyAccount::UnknownAccountType); + m_account.setAccountType(Account::Unknown); break; } @@ -657,7 +660,7 @@ MyMoneyAccount thisaccount = m_account; QString brokerageactid; - if (thisaccount.accountType() == MyMoneyAccount::Investment) { + if (thisaccount.accountType() == Account::Investment) { // determine the brokerage account brokerageactid = m_account.value("kmm-brokerage-account").toUtf8(); if (brokerageactid.isEmpty()) { @@ -726,7 +729,7 @@ if (!security.id().isEmpty()) { thisaccount = MyMoneyAccount(); thisaccount.setName(security.name()); - thisaccount.setAccountType(MyMoneyAccount::Stock); + thisaccount.setAccountType(Account::Stock); thisaccount.setCurrencyId(security.id()); currencyid = thisaccount.currencyId(); @@ -1020,7 +1023,7 @@ auto filterProxyModel = new AccountNamesFilterProxyModel(this); filterProxyModel->setHideEquityAccounts(!KMyMoneyGlobalSettings::expertMode()); - filterProxyModel->addAccountGroup(QVector {MyMoneyAccount::Asset, MyMoneyAccount::Liability, MyMoneyAccount::Equity, MyMoneyAccount::Income, MyMoneyAccount::Expense}); + filterProxyModel->addAccountGroup(QVector {Account::Asset, Account::Liability, Account::Equity, Account::Income, Account::Expense}); auto const model = Models::instance()->accountsModel(); filterProxyModel->setSourceModel(model); @@ -1080,7 +1083,7 @@ } } - if (thisaccount.accountType() != MyMoneyAccount::Stock) { + if (thisaccount.accountType() != Account::Stock) { // // Fill in other side of the transaction (category/etc) based on payee // @@ -1275,7 +1278,7 @@ QString MyMoneyStatementReader::SelectBrokerageAccount() { if (m_brokerageAccount.id().isEmpty()) { - m_brokerageAccount.setAccountType(MyMoneyAccount::Checkings); + m_brokerageAccount.setAccountType(Account::Checkings); if (!m_userAbort) m_userAbort = ! selectOrCreateAccount(Select, m_brokerageAccount); } @@ -1338,13 +1341,13 @@ } KMyMoneyUtils::categoryTypeE type; - if (account.accountType() == MyMoneyAccount::Checkings) { + if (account.accountType() == Account::Checkings) { type = static_cast(KMyMoneyUtils::checking); - } else if (account.accountType() == MyMoneyAccount::Savings) { + } else if (account.accountType() == Account::Savings) { type = static_cast(KMyMoneyUtils::savings); - } else if (account.accountType() == MyMoneyAccount::Investment) { + } else if (account.accountType() == Account::Investment) { type = static_cast(KMyMoneyUtils::investment); - } else if (account.accountType() == MyMoneyAccount::CreditCard) { + } else if (account.accountType() == Account::CreditCard) { type = static_cast(KMyMoneyUtils::creditCard); } else { type = static_cast(KMyMoneyUtils::asset | KMyMoneyUtils::liability); diff --git a/kmymoney/converter/mymoneytemplate.cpp b/kmymoney/converter/mymoneytemplate.cpp --- a/kmymoney/converter/mymoneytemplate.cpp +++ b/kmymoney/converter/mymoneytemplate.cpp @@ -182,13 +182,13 @@ QString name = rootNode.attribute("name"); if (rootNode.tagName() == "account") { rootNode = rootNode.firstChild().toElement(); - MyMoneyAccount::accountTypeE type = static_cast(accounts.toElement().attribute("type").toUInt()); + eMyMoney::Account type = static_cast(accounts.toElement().attribute("type").toUInt()); switch (type) { - case MyMoneyAccount::Asset: - case MyMoneyAccount::Liability: - case MyMoneyAccount::Income: - case MyMoneyAccount::Expense: - case MyMoneyAccount::Equity: + case eMyMoney::Account::Asset: + case eMyMoney::Account::Liability: + case eMyMoney::Account::Income: + case eMyMoney::Account::Expense: + case eMyMoney::Account::Equity: if (name.isEmpty()) name = MyMoneyAccount::accountTypeToString(type); list[name] = 0; @@ -220,19 +220,19 @@ ++m_accountsRead; MyMoneyAccount parent; switch (childElement.attribute("type").toUInt()) { - case MyMoneyAccount::Asset: + case (uint)eMyMoney::Account::Asset: parent = file->asset(); break; - case MyMoneyAccount::Liability: + case (uint)eMyMoney::Account::Liability: parent = file->liability(); break; - case MyMoneyAccount::Income: + case (uint)eMyMoney::Account::Income: parent = file->income(); break; - case MyMoneyAccount::Expense: + case (uint)eMyMoney::Account::Expense: parent = file->expense(); break; - case MyMoneyAccount::Equity: + case (uint)eMyMoney::Account::Equity: parent = file->equity(); break; @@ -280,7 +280,7 @@ if (it == subAccountList.constEnd()) { // not found, we need to create it acc.setName(accountElement.attribute("name")); - acc.setAccountType(static_cast(accountElement.attribute("type").toUInt())); + acc.setAccountType(static_cast(accountElement.attribute("type").toUInt())); setFlags(acc, account.firstChild()); try { MyMoneyFile::instance()->addAccount(acc, parent); @@ -411,7 +411,7 @@ account.setAttribute(QString("name"), QString()); else account.setAttribute(QString("name"), acc.name()); - account.setAttribute(QString("type"), acc.accountType()); + account.setAttribute(QString("type"), (int)acc.accountType()); // FIXME: add tax flag stuff if (acc.pairs().contains("OpeningBalanceAccount")) { diff --git a/kmymoney/converter/tests/converter-test.cpp b/kmymoney/converter/tests/converter-test.cpp --- a/kmymoney/converter/tests/converter-test.cpp +++ b/kmymoney/converter/tests/converter-test.cpp @@ -59,12 +59,12 @@ acLiability = (MyMoneyFile::instance()->liability().id()); acExpense = (MyMoneyFile::instance()->expense().id()); acIncome = (MyMoneyFile::instance()->income().id()); - acChecking = makeAccount("Checking Account", MyMoneyAccount::Checkings, moConverterCheckingOpen, QDate(2004, 5, 15), acAsset); - acCredit = makeAccount("Credit Card", MyMoneyAccount::CreditCard, moConverterCreditOpen, QDate(2004, 7, 15), acLiability); - acSolo = makeAccount("Solo", MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); - acParent = makeAccount("Parent", MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); - acChild = makeAccount("Child", MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acParent); - acForeign = makeAccount("Foreign", MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); + acChecking = makeAccount("Checking Account", eMyMoney::Account::Checkings, moConverterCheckingOpen, QDate(2004, 5, 15), acAsset); + acCredit = makeAccount("Credit Card", eMyMoney::Account::CreditCard, moConverterCreditOpen, QDate(2004, 7, 15), acLiability); + acSolo = makeAccount("Solo", eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); + acParent = makeAccount("Parent", eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); + acChild = makeAccount("Child", eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acParent); + acForeign = makeAccount("Foreign", eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); MyMoneyInstitution i("Bank of the World", "", "", "", "", "", ""); file->addInstitution(i); diff --git a/kmymoney/converter/tests/matchfinder-test.cpp b/kmymoney/converter/tests/matchfinder-test.cpp --- a/kmymoney/converter/tests/matchfinder-test.cpp +++ b/kmymoney/converter/tests/matchfinder-test.cpp @@ -77,12 +77,12 @@ account->setName("Expenses account"); - account->setAccountType(MyMoneyAccount::Expense); + account->setAccountType(eMyMoney::Account::Expense); account->setOpeningDate(QDate(2012, 12, 01)); account->setCurrencyId(MyMoneyFile::instance()->baseCurrency().id()); otherAccount->setName("Some other account"); - otherAccount->setAccountType(MyMoneyAccount::Expense); + otherAccount->setAccountType(eMyMoney::Account::Expense); otherAccount->setOpeningDate(QDate(2012, 12, 01)); otherAccount->setCurrencyId(MyMoneyFile::instance()->baseCurrency().id()); @@ -138,7 +138,7 @@ MyMoneyTransaction transaction = buildDefaultTransaction(); transaction.setPostDate(tomorrow); - MyMoneySchedule nonOverdueSchedule("schedule name", MyMoneySchedule::TYPE_TRANSFER, MyMoneySchedule::OCCUR_MONTHLY, 1, MyMoneySchedule::STYPE_BANKTRANSFER, tomorrow, tomorrow.addMonths(2), false, false); + MyMoneySchedule nonOverdueSchedule("schedule name", eMyMoney::Schedule::Type::Transfer, eMyMoney::Schedule::Occurrence::Monthly, 1, eMyMoney::Schedule::PaymentType::BankTransfer, tomorrow, tomorrow.addMonths(2), false, false); nonOverdueSchedule.setTransaction(transaction); return nonOverdueSchedule; diff --git a/kmymoney/converter/transactionmatchfinder.cpp b/kmymoney/converter/transactionmatchfinder.cpp --- a/kmymoney/converter/transactionmatchfinder.cpp +++ b/kmymoney/converter/transactionmatchfinder.cpp @@ -22,6 +22,7 @@ #include "mymoneyaccount.h" #include "mymoneyfile.h" +#include "mymoneypayee.h" TransactionMatchFinder::TransactionMatchFinder(int _matchWindow) : matchWindow(_matchWindow), diff --git a/kmymoney/converter/webpricequote.cpp b/kmymoney/converter/webpricequote.cpp --- a/kmymoney/converter/webpricequote.cpp +++ b/kmymoney/converter/webpricequote.cpp @@ -50,6 +50,7 @@ #include "mymoneyexception.h" #include "mymoneyfile.h" +#include "mymoneysecurity.h" Q_DECLARE_LOGGING_CATEGORY(WEBPRICEQUOTE) Q_LOGGING_CATEGORY(WEBPRICEQUOTE, "kmymoney_webpricequote") diff --git a/kmymoney/dialogs/investtransactioneditor.cpp b/kmymoney/dialogs/investtransactioneditor.cpp --- a/kmymoney/dialogs/investtransactioneditor.cpp +++ b/kmymoney/dialogs/investtransactioneditor.cpp @@ -41,6 +41,7 @@ #include "kmymoneyaccountselector.h" #include "kmymoneymvccombo.h" #include "mymoneyfile.h" +#include "mymoneyprice.h" #include "ksplittransactiondlg.h" #include "kcurrencycalculator.h" #include "kmymoneyglobalsettings.h" @@ -525,13 +526,13 @@ // interest-account aSet.clear(); - aSet.addAccountGroup(MyMoneyAccount::Income); + aSet.addAccountGroup(eMyMoney::Account::Income); aSet.load(interest->selector()); setupCategoryWidget(interest, m_interestSplits, id, SLOT(slotEditInterestSplits())); // fee-account aSet.clear(); - aSet.addAccountGroup(MyMoneyAccount::Expense); + aSet.addAccountGroup(eMyMoney::Account::Expense); aSet.load(fees->selector()); setupCategoryWidget(fees, m_feeSplits, id, SLOT(slotEditFeeSplits())); @@ -559,21 +560,21 @@ QList::const_iterator it_s; for (it_s = m_transaction.splits().constBegin(); !haveEquityAccount && it_s != m_transaction.splits().constEnd(); ++it_s) { MyMoneyAccount acc = MyMoneyFile::instance()->account((*it_s).accountId()); - if (acc.accountType() == MyMoneyAccount::Equity) + if (acc.accountType() == eMyMoney::Account::Equity) haveEquityAccount = true; } // asset-account AccountSet aSet; aSet.clear(); - aSet.addAccountType(MyMoneyAccount::Checkings); - aSet.addAccountType(MyMoneyAccount::Savings); - aSet.addAccountType(MyMoneyAccount::Cash); - aSet.addAccountType(MyMoneyAccount::Asset); - aSet.addAccountType(MyMoneyAccount::Currency); - aSet.addAccountType(MyMoneyAccount::CreditCard); + aSet.addAccountType(eMyMoney::Account::Checkings); + aSet.addAccountType(eMyMoney::Account::Savings); + aSet.addAccountType(eMyMoney::Account::Cash); + aSet.addAccountType(eMyMoney::Account::Asset); + aSet.addAccountType(eMyMoney::Account::Currency); + aSet.addAccountType(eMyMoney::Account::CreditCard); if (KMyMoneyGlobalSettings::expertMode() || haveEquityAccount) - aSet.addAccountGroup(MyMoneyAccount::Equity); + aSet.addAccountGroup(eMyMoney::Account::Equity); aSet.load(asset->selector()); // security @@ -610,14 +611,14 @@ // interest-account aSet.clear(); - aSet.addAccountGroup(MyMoneyAccount::Income); + aSet.addAccountGroup(eMyMoney::Account::Income); aSet.load(interest->selector()); setupCategoryWidget(interest, m_interestSplits, id, SLOT(slotEditInterestSplits())); slotUpdateInterestVisibility(interest->currentText()); // fee-account aSet.clear(); - aSet.addAccountGroup(MyMoneyAccount::Expense); + aSet.addAccountGroup(eMyMoney::Account::Expense); aSet.load(fees->selector()); setupCategoryWidget(fees, m_feeSplits, id, SLOT(slotEditFeeSplits())); slotUpdateFeeVisibility(fees->currentText()); diff --git a/kmymoney/dialogs/kaccountselectdlg.cpp b/kmymoney/dialogs/kaccountselectdlg.cpp --- a/kmymoney/dialogs/kaccountselectdlg.cpp +++ b/kmymoney/dialogs/kaccountselectdlg.cpp @@ -96,23 +96,23 @@ { AccountSet set; if (m_accountType & KMyMoneyUtils::asset) - set.addAccountGroup(MyMoneyAccount::Asset); + set.addAccountGroup(eMyMoney::Account::Asset); if (m_accountType & KMyMoneyUtils::liability) - set.addAccountGroup(MyMoneyAccount::Liability); + set.addAccountGroup(eMyMoney::Account::Liability); if (m_accountType & KMyMoneyUtils::income) - set.addAccountGroup(MyMoneyAccount::Income); + set.addAccountGroup(eMyMoney::Account::Income); if (m_accountType & KMyMoneyUtils::expense) - set.addAccountGroup(MyMoneyAccount::Expense); + set.addAccountGroup(eMyMoney::Account::Expense); if (m_accountType & KMyMoneyUtils::equity) - set.addAccountGroup(MyMoneyAccount::Equity); + set.addAccountGroup(eMyMoney::Account::Equity); if (m_accountType & KMyMoneyUtils::checking) - set.addAccountType(MyMoneyAccount::Checkings); + set.addAccountType(eMyMoney::Account::Checkings); if (m_accountType & KMyMoneyUtils::savings) - set.addAccountType(MyMoneyAccount::Savings); + set.addAccountType(eMyMoney::Account::Savings); if (m_accountType & KMyMoneyUtils::investment) - set.addAccountType(MyMoneyAccount::Investment); + set.addAccountType(eMyMoney::Account::Investment); if (m_accountType & KMyMoneyUtils::creditCard) - set.addAccountType(MyMoneyAccount::CreditCard); + set.addAccountType(eMyMoney::Account::CreditCard); set.load(m_accountSelector->selector()); } @@ -148,7 +148,7 @@ accept(); } } else { - if (m_account.accountType() == MyMoneyAccount::Expense) + if (m_account.accountType() == eMyMoney::Account::Expense) kmymoney->createCategory(m_account, MyMoneyFile::instance()->expense()); else kmymoney->createCategory(m_account, MyMoneyFile::instance()->income()); diff --git a/kmymoney/dialogs/kbalancechartdlg.cpp b/kmymoney/dialogs/kbalancechartdlg.cpp --- a/kmymoney/dialogs/kbalancechartdlg.cpp +++ b/kmymoney/dialogs/kbalancechartdlg.cpp @@ -97,7 +97,7 @@ reportCfg.setChartType(MyMoneyReport::eChartLine); reportCfg.setIncludingForecast(true); reportCfg.setIncludingBudgetActuals(true); - if (account.accountType() == MyMoneyAccount::Investment) { + if (account.accountType() == eMyMoney::Account::Investment) { QStringList::const_iterator it_a; for (it_a = account.accountList().begin(); it_a != account.accountList().end(); ++it_a) reportCfg.addAccount(*it_a); @@ -118,7 +118,7 @@ bool haveMaxCredit = false; MyMoneyMoney minBalance, maxCredit; MyMoneyMoney factor(1, 1); - if (account.accountGroup() == MyMoneyAccount::Asset) + if (account.accountGroup() == eMyMoney::Account::Asset) factor = -factor; if (!account.value("maxCreditEarly").isEmpty()) { diff --git a/kmymoney/dialogs/kcategoryreassigndlg.cpp b/kmymoney/dialogs/kcategoryreassigndlg.cpp --- a/kmymoney/dialogs/kcategoryreassigndlg.cpp +++ b/kmymoney/dialogs/kcategoryreassigndlg.cpp @@ -53,8 +53,8 @@ return QString(); // no payee available? nothing can be selected... AccountSet set; - set.addAccountGroup(MyMoneyAccount::Income); - set.addAccountGroup(MyMoneyAccount::Expense); + set.addAccountGroup(eMyMoney::Account::Income); + set.addAccountGroup(eMyMoney::Account::Expense); set.load(m_category->selector()); // remove the category we are about to delete diff --git a/kmymoney/dialogs/kconfirmmanualenterdlg.cpp b/kmymoney/dialogs/kconfirmmanualenterdlg.cpp --- a/kmymoney/dialogs/kconfirmmanualenterdlg.cpp +++ b/kmymoney/dialogs/kconfirmmanualenterdlg.cpp @@ -34,6 +34,7 @@ // Project Includes #include "mymoneyfile.h" +#include "mymoneypayee.h" #include "kmymoneyutils.h" #include "mymoneytransaction.h" #include "ui_kconfirmmanualenterdlgdecl.h" @@ -52,7 +53,7 @@ d->ui.m_onceRadio->setChecked(true); - if (schedule.type() == MyMoneySchedule::TYPE_LOANPAYMENT) { + if (schedule.type() == eMyMoney::Schedule::Type::LoanPayment) { d->ui.m_setRadio->setEnabled(false); d->ui.m_discardRadio->setEnabled(false); } diff --git a/kmymoney/dialogs/kcurrencyeditdlg.cpp b/kmymoney/dialogs/kcurrencyeditdlg.cpp --- a/kmymoney/dialogs/kcurrencyeditdlg.cpp +++ b/kmymoney/dialogs/kcurrencyeditdlg.cpp @@ -53,6 +53,7 @@ #include "mymoneysecurity.h" #include "mymoneyfile.h" +#include "mymoneyprice.h" #include "kavailablecurrencydlg.h" #include "kcurrencyeditordlg.h" #include "kmymoneyutils.h" diff --git a/kmymoney/dialogs/keditscheduledlg.cpp b/kmymoney/dialogs/keditscheduledlg.cpp --- a/kmymoney/dialogs/keditscheduledlg.cpp +++ b/kmymoney/dialogs/keditscheduledlg.cpp @@ -50,6 +50,8 @@ #include "kmymoney.h" +using namespace eMyMoney; + class KEditScheduleDlg::Private { public: @@ -104,34 +106,34 @@ // setup widget contents m_nameEdit->setText(d->m_schedule.name()); - m_frequencyEdit->setCurrentItem(d->m_schedule.occurrencePeriod()); - if (m_frequencyEdit->currentItem() == MyMoneySchedule::OCCUR_ANY) - m_frequencyEdit->setCurrentItem(MyMoneySchedule::OCCUR_MONTHLY); - slotFrequencyChanged(m_frequencyEdit->currentItem()); + m_frequencyEdit->setCurrentItem((int)d->m_schedule.occurrencePeriod()); + if (m_frequencyEdit->currentItem() == Schedule::Occurrence::Any) + m_frequencyEdit->setCurrentItem((int)Schedule::Occurrence::Monthly); + slotFrequencyChanged((int)m_frequencyEdit->currentItem()); m_frequencyNoEdit->setValue(d->m_schedule.occurrenceMultiplier()); // load option widgets - m_paymentMethodEdit->insertItem(i18n("Direct deposit"), MyMoneySchedule::STYPE_DIRECTDEPOSIT); - m_paymentMethodEdit->insertItem(i18n("Manual deposit"), MyMoneySchedule::STYPE_MANUALDEPOSIT); - m_paymentMethodEdit->insertItem(i18n("Direct debit"), MyMoneySchedule::STYPE_DIRECTDEBIT); - m_paymentMethodEdit->insertItem(i18n("Standing order"), MyMoneySchedule::STYPE_STANDINGORDER); - m_paymentMethodEdit->insertItem(i18n("Bank transfer"), MyMoneySchedule::STYPE_BANKTRANSFER); - m_paymentMethodEdit->insertItem(i18n("Write check"), MyMoneySchedule::STYPE_WRITECHEQUE); - m_paymentMethodEdit->insertItem(i18nc("Other payment method", "Other"), MyMoneySchedule::STYPE_OTHER); - - MyMoneySchedule::paymentTypeE method = d->m_schedule.paymentType(); - if (method == MyMoneySchedule::STYPE_ANY) - method = MyMoneySchedule::STYPE_OTHER; - m_paymentMethodEdit->setCurrentItem(method); + m_paymentMethodEdit->insertItem(i18n("Direct deposit"), (int)Schedule::PaymentType::DirectDeposit); + m_paymentMethodEdit->insertItem(i18n("Manual deposit"), (int)Schedule::PaymentType::ManualDeposit); + m_paymentMethodEdit->insertItem(i18n("Direct debit"), (int)Schedule::PaymentType::DirectDebit); + m_paymentMethodEdit->insertItem(i18n("Standing order"), (int)Schedule::PaymentType::StandingOrder); + m_paymentMethodEdit->insertItem(i18n("Bank transfer"), (int)Schedule::PaymentType::BankTransfer); + m_paymentMethodEdit->insertItem(i18n("Write check"), (int)Schedule::PaymentType::WriteChecque); + m_paymentMethodEdit->insertItem(i18nc("Other payment method", "Other"), (int)Schedule::PaymentType::Other); + + auto method = d->m_schedule.paymentType(); + if (method == Schedule::PaymentType::Any) + method = Schedule::PaymentType::Other; + m_paymentMethodEdit->setCurrentItem((int)method); switch (d->m_schedule.weekendOption()) { - case MyMoneySchedule::MoveNothing: + case Schedule::WeekendOption::MoveNothing: m_weekendOptionEdit->setCurrentIndex(0); break; - case MyMoneySchedule::MoveBefore: + case Schedule::WeekendOption::MoveBefore: m_weekendOptionEdit->setCurrentIndex(1); break; - case MyMoneySchedule::MoveAfter: + case Schedule::WeekendOption::MoveAfter: m_weekendOptionEdit->setCurrentIndex(2); break; } @@ -209,14 +211,14 @@ d->m_tabOrderWidgets.clear(); KMyMoneyRegister::Action action = KMyMoneyRegister::ActionWithdrawal; switch (d->m_schedule.type()) { - case MyMoneySchedule::TYPE_DEPOSIT: + case Schedule::Type::Deposit: action = KMyMoneyRegister::ActionDeposit; break; - case MyMoneySchedule::TYPE_BILL: + case Schedule::Type::Bill: action = KMyMoneyRegister::ActionWithdrawal; editor->m_paymentMethod = d->m_schedule.paymentType(); break; - case MyMoneySchedule::TYPE_TRANSFER: + case Schedule::Type::Transfer: action = KMyMoneyRegister::ActionTransfer; break; default: @@ -249,7 +251,7 @@ // if it's not a check, then we need to clear // a possibly assigned check number - if (d->m_schedule.paymentType() != MyMoneySchedule::STYPE_WRITECHEQUE) { + if (d->m_schedule.paymentType() != Schedule::PaymentType::WriteChecque) { QWidget* w = editor->haveWidget("number"); if (w) dynamic_cast(w)->loadText(QString()); @@ -315,7 +317,7 @@ } d->m_editor = editor; - slotSetPaymentMethod(d->m_schedule.paymentType()); + slotSetPaymentMethod((int)d->m_schedule.paymentType()); connect(m_paymentMethodEdit, SIGNAL(itemSelected(int)), this, SLOT(slotSetPaymentMethod(int))); connect(editor, SIGNAL(operationTypeChanged(int)), this, SLOT(slotFilterPaymentType(int))); @@ -351,35 +353,35 @@ d->m_schedule.setTransaction(t); d->m_schedule.setName(m_nameEdit->text()); d->m_schedule.setFixed(!m_estimateEdit->isChecked()); - d->m_schedule.setOccurrencePeriod(static_cast(m_frequencyEdit->currentItem())); + d->m_schedule.setOccurrencePeriod(static_cast(m_frequencyEdit->currentItem())); d->m_schedule.setOccurrenceMultiplier(m_frequencyNoEdit->value()); switch (m_weekendOptionEdit->currentIndex()) { case 0: - d->m_schedule.setWeekendOption(MyMoneySchedule::MoveNothing); + d->m_schedule.setWeekendOption(Schedule::WeekendOption::MoveNothing); break; case 1: - d->m_schedule.setWeekendOption(MyMoneySchedule::MoveBefore); + d->m_schedule.setWeekendOption(Schedule::WeekendOption::MoveBefore); break; case 2: - d->m_schedule.setWeekendOption(MyMoneySchedule::MoveAfter); + d->m_schedule.setWeekendOption(Schedule::WeekendOption::MoveAfter); break; } - d->m_schedule.setType(MyMoneySchedule::TYPE_BILL); + d->m_schedule.setType(Schedule::Type::Bill); KMyMoneyTransactionForm::TabBar* tabbar = dynamic_cast(d->m_editor->haveWidget("tabbar")); if (tabbar) { switch (static_cast(tabbar->currentIndex())) { case KMyMoneyRegister::ActionDeposit: - d->m_schedule.setType(MyMoneySchedule::TYPE_DEPOSIT); + d->m_schedule.setType(Schedule::Type::Deposit); break; default: case KMyMoneyRegister::ActionWithdrawal: - d->m_schedule.setType(MyMoneySchedule::TYPE_BILL); + d->m_schedule.setType(Schedule::Type::Bill); break; case KMyMoneyRegister::ActionTransfer: - d->m_schedule.setType(MyMoneySchedule::TYPE_TRANSFER); + d->m_schedule.setType(Schedule::Type::Transfer); break; } } else { @@ -387,7 +389,7 @@ } d->m_schedule.setAutoEnter(m_autoEnterEdit->isChecked()); - d->m_schedule.setPaymentType(static_cast(m_paymentMethodEdit->currentItem())); + d->m_schedule.setPaymentType(static_cast(m_paymentMethodEdit->currentItem())); if (m_endSeriesEdit->isEnabled() && m_endSeriesEdit->isChecked()) { d->m_schedule.setEndDate(m_FinalPaymentEdit->date()); } else { @@ -458,7 +460,7 @@ // Make sure the required fields are set kMyMoneyDateInput* dateEdit = dynamic_cast(d->m_editor->haveWidget("postdate")); d->m_schedule.setNextDueDate(dateEdit->date()); - d->m_schedule.setOccurrencePeriod(static_cast(m_frequencyEdit->currentItem())); + d->m_schedule.setOccurrencePeriod(static_cast(m_frequencyEdit->currentItem())); d->m_schedule.setOccurrenceMultiplier(m_frequencyNoEdit->value()); if (d->m_schedule.transactionsRemaining() != value) { @@ -473,7 +475,7 @@ // Make sure the required fields are set kMyMoneyDateInput* dateEdit = dynamic_cast(d->m_editor->haveWidget("postdate")); d->m_schedule.setNextDueDate(dateEdit->date()); - d->m_schedule.setOccurrencePeriod(static_cast(m_frequencyEdit->currentItem())); + d->m_schedule.setOccurrencePeriod(static_cast(m_frequencyEdit->currentItem())); d->m_schedule.setOccurrenceMultiplier(m_frequencyNoEdit->value()); if (d->m_schedule.endDate() != date) { @@ -488,7 +490,7 @@ if (m_endOptionsFrame->isEnabled()) { d->m_schedule.setNextDueDate(date); d->m_schedule.setOccurrenceMultiplier(m_frequencyNoEdit->value()); - d->m_schedule.setOccurrencePeriod(static_cast(m_frequencyEdit->currentItem())); + d->m_schedule.setOccurrencePeriod(static_cast(m_frequencyEdit->currentItem())); d->m_schedule.setEndDate(m_FinalPaymentEdit->date()); updateTransactionsRemaining(); } @@ -499,29 +501,29 @@ { kMyMoneyLineEdit* dateEdit = dynamic_cast(d->m_editor->haveWidget("number")); if (dateEdit) { - dateEdit->setVisible(item == MyMoneySchedule::STYPE_WRITECHEQUE); + dateEdit->setVisible(item == (int)Schedule::PaymentType::WriteChecque); // hiding the label does not work, because the label underneath will shine // through. So we either write the label or a blank QLabel* label = dynamic_cast(d->m_editor->haveWidget("number-label")); if (label) { - label->setText((item == MyMoneySchedule::STYPE_WRITECHEQUE) ? i18n("Number") : " "); + label->setText((item == (int)Schedule::PaymentType::WriteChecque) ? i18n("Number") : " "); } } } void KEditScheduleDlg::slotFrequencyChanged(int item) { - m_endSeriesEdit->setEnabled(item != MyMoneySchedule::OCCUR_ONCE); + m_endSeriesEdit->setEnabled(item != (int)Schedule::Occurrence::Once); bool isEndSeries = m_endSeriesEdit->isChecked(); if (isEndSeries) - m_endOptionsFrame->setEnabled(item != MyMoneySchedule::OCCUR_ONCE); + m_endOptionsFrame->setEnabled(item != (int)Schedule::Occurrence::Once); switch (item) { - case MyMoneySchedule::OCCUR_DAILY: - case MyMoneySchedule::OCCUR_WEEKLY: - case MyMoneySchedule::OCCUR_EVERYHALFMONTH: - case MyMoneySchedule::OCCUR_MONTHLY: - case MyMoneySchedule::OCCUR_YEARLY: + case (int)Schedule::Occurrence::Daily: + case (int)Schedule::Occurrence::Weekly: + case (int)Schedule::Occurrence::EveryHalfMonth: + case (int)Schedule::Occurrence::Monthly: + case (int)Schedule::Occurrence::Yearly: // Supports Frequency Number m_frequencyNoEdit->setEnabled(true); break; @@ -531,13 +533,13 @@ m_frequencyNoEdit->setValue(1); break; } - if (isEndSeries && (item != MyMoneySchedule::OCCUR_ONCE)) { + if (isEndSeries && (item != (int)Schedule::Occurrence::Once)) { // Changing the frequency changes the number // of remaining transactions kMyMoneyDateInput* dateEdit = dynamic_cast(d->m_editor->haveWidget("postdate")); d->m_schedule.setNextDueDate(dateEdit->date()); d->m_schedule.setOccurrenceMultiplier(m_frequencyNoEdit->value()); - d->m_schedule.setOccurrencePeriod(static_cast(item)); + d->m_schedule.setOccurrencePeriod(static_cast(item)); d->m_schedule.setEndDate(m_FinalPaymentEdit->date()); updateTransactionsRemaining(); } @@ -552,7 +554,7 @@ kMyMoneyDateInput* dateEdit = dynamic_cast(d->m_editor->haveWidget("postdate")); d->m_schedule.setNextDueDate(dateEdit->date()); d->m_schedule.setOccurrenceMultiplier(multiplier); - d->m_schedule.setOccurrencePeriod(static_cast(m_frequencyEdit->currentItem())); + d->m_schedule.setOccurrencePeriod(static_cast(m_frequencyEdit->currentItem())); d->m_schedule.setEndDate(m_FinalPaymentEdit->date()); updateTransactionsRemaining(); } @@ -585,16 +587,16 @@ // load option widgets KMyMoneyRegister::Action action = static_cast(index); if (action != KMyMoneyRegister::ActionWithdrawal) { - m_paymentMethodEdit->insertItem(i18n("Direct deposit"), MyMoneySchedule::STYPE_DIRECTDEPOSIT); - m_paymentMethodEdit->insertItem(i18n("Manual deposit"), MyMoneySchedule::STYPE_MANUALDEPOSIT); + m_paymentMethodEdit->insertItem(i18n("Direct deposit"), (int)Schedule::PaymentType::DirectDeposit); + m_paymentMethodEdit->insertItem(i18n("Manual deposit"), (int)Schedule::PaymentType::ManualDeposit); } if (action != KMyMoneyRegister::ActionDeposit) { - m_paymentMethodEdit->insertItem(i18n("Direct debit"), MyMoneySchedule::STYPE_DIRECTDEBIT); - m_paymentMethodEdit->insertItem(i18n("Write check"), MyMoneySchedule::STYPE_WRITECHEQUE); + m_paymentMethodEdit->insertItem(i18n("Direct debit"), (int)Schedule::PaymentType::DirectDebit); + m_paymentMethodEdit->insertItem(i18n("Write check"), (int)Schedule::PaymentType::WriteChecque); } - m_paymentMethodEdit->insertItem(i18n("Standing order"), MyMoneySchedule::STYPE_STANDINGORDER); - m_paymentMethodEdit->insertItem(i18n("Bank transfer"), MyMoneySchedule::STYPE_BANKTRANSFER); - m_paymentMethodEdit->insertItem(i18nc("Other payment method", "Other"), MyMoneySchedule::STYPE_OTHER); + m_paymentMethodEdit->insertItem(i18n("Standing order"), (int)Schedule::PaymentType::StandingOrder); + m_paymentMethodEdit->insertItem(i18n("Bank transfer"), (int)Schedule::PaymentType::BankTransfer); + m_paymentMethodEdit->insertItem(i18nc("Other payment method", "Other"), (int)Schedule::PaymentType::Other); int newIndex = m_paymentMethodEdit->findData(QVariant(selectedId), Qt::UserRole, Qt::MatchExactly); if (newIndex > -1) { diff --git a/kmymoney/dialogs/kenterscheduledlg.cpp b/kmymoney/dialogs/kenterscheduledlg.cpp --- a/kmymoney/dialogs/kenterscheduledlg.cpp +++ b/kmymoney/dialogs/kenterscheduledlg.cpp @@ -146,7 +146,7 @@ MyMoneyTransaction t = d->m_schedule.transaction(); try { - if (d->m_schedule.type() == MyMoneySchedule::TYPE_LOANPAYMENT) { + if (d->m_schedule.type() == eMyMoney::Schedule::Type::LoanPayment) { KMyMoneyUtils::calculateAutoLoan(d->m_schedule, t, QMap()); } } catch (const MyMoneyException &e) { @@ -227,16 +227,16 @@ d->m_tabOrderWidgets.clear(); KMyMoneyRegister::Action action = KMyMoneyRegister::ActionWithdrawal; switch (d->m_schedule.type()) { - case MyMoneySchedule::TYPE_TRANSFER: + case eMyMoney::Schedule::Type::Transfer: action = KMyMoneyRegister::ActionTransfer; break; - case MyMoneySchedule::TYPE_DEPOSIT: + case eMyMoney::Schedule::Type::Deposit: action = KMyMoneyRegister::ActionDeposit; break; - case MyMoneySchedule::TYPE_LOANPAYMENT: + case eMyMoney::Schedule::Type::LoanPayment: switch (d->m_schedule.paymentType()) { - case MyMoneySchedule::STYPE_DIRECTDEPOSIT: - case MyMoneySchedule::STYPE_MANUALDEPOSIT: + case eMyMoney::Schedule::PaymentType::DirectDeposit: + case eMyMoney::Schedule::PaymentType::ManualDeposit: action = KMyMoneyRegister::ActionDeposit; break; default: @@ -251,7 +251,7 @@ MyMoneyTransaction t = d->m_schedule.transaction(); QString num = t.splits().first().number(); QWidget* w = editor->haveWidget("number"); - if (d->m_schedule.paymentType() == MyMoneySchedule::STYPE_WRITECHEQUE) { + if (d->m_schedule.paymentType() == eMyMoney::Schedule::PaymentType::WriteChecque) { MyMoneyFile* file = MyMoneyFile::instance(); if (file->checkNoUsed(d->m_schedule.account().id(), num)) { // increment and try again diff --git a/kmymoney/dialogs/kfindtransactiondlg.cpp b/kmymoney/dialogs/kfindtransactiondlg.cpp --- a/kmymoney/dialogs/kfindtransactiondlg.cpp +++ b/kmymoney/dialogs/kfindtransactiondlg.cpp @@ -48,6 +48,8 @@ #include "kmymoneyedit.h" #include "mymoneyfile.h" +#include "mymoneypayee.h" +#include "mymoneytag.h" #include "kmymoneyglobalsettings.h" #include "register.h" #include "transaction.h" @@ -211,7 +213,7 @@ selectAllItems(m_ui->m_tagsView, true); m_ui->m_typeBox->setCurrentIndex(MyMoneyTransactionFilter::allTypes); - m_ui->m_stateBox->setCurrentIndex(MyMoneyTransactionFilter::allStates); + m_ui->m_stateBox->setCurrentIndex((int)eMyMoney::TransactionFilter::State::All); m_ui->m_validityBox->setCurrentIndex(MyMoneyTransactionFilter::anyValidity); m_ui->m_nrEdit->setEnabled(true); @@ -358,11 +360,11 @@ { m_ui->m_accountsView->setSelectionMode(QTreeWidget::MultiSelection); AccountSet accountSet; - accountSet.addAccountGroup(MyMoneyAccount::Asset); - accountSet.addAccountGroup(MyMoneyAccount::Liability); + accountSet.addAccountGroup(eMyMoney::Account::Asset); + accountSet.addAccountGroup(eMyMoney::Account::Liability); if (withEquityAccounts) - accountSet.addAccountGroup(MyMoneyAccount::Equity); + accountSet.addAccountGroup(eMyMoney::Account::Equity); //set the accountset to show closed account if the settings say so accountSet.setHideClosedAccounts(KMyMoneyGlobalSettings::hideClosedAccounts()); @@ -404,8 +406,8 @@ { m_ui->m_categoriesView->setSelectionMode(QTreeWidget::MultiSelection); AccountSet categorySet; - categorySet.addAccountGroup(MyMoneyAccount::Income); - categorySet.addAccountGroup(MyMoneyAccount::Expense); + categorySet.addAccountGroup(eMyMoney::Account::Income); + categorySet.addAccountGroup(eMyMoney::Account::Expense); categorySet.load(m_ui->m_categoriesView); connect(m_ui->m_categoriesView, SIGNAL(stateChanged()), this, SLOT(slotUpdateSelections())); } @@ -652,7 +654,7 @@ QStringList::const_iterator it_a, it_b; for (it_a = list.constBegin(); it_a != list.constEnd(); ++it_a) { MyMoneyAccount acc = MyMoneyFile::instance()->account(*it_a); - if (acc.accountType() == MyMoneyAccount::Investment) { + if (acc.accountType() == eMyMoney::Account::Investment) { for (it_b = acc.accountList().constBegin(); it_b != acc.accountList().constEnd(); ++it_b) { if (!list.contains(*it_b)) { missing.append(*it_b); diff --git a/kmymoney/dialogs/kmymoneyfileinfodlg.cpp b/kmymoney/dialogs/kmymoneyfileinfodlg.cpp --- a/kmymoney/dialogs/kmymoneyfileinfodlg.cpp +++ b/kmymoney/dialogs/kmymoneyfileinfodlg.cpp @@ -50,8 +50,8 @@ storage->accountList(a_list); m_accountCount->setText(QString("%1").arg(a_list.count())); - QMap accountMap; - QMap accountMapClosed; + QMap accountMap; + QMap accountMapClosed; QList::const_iterator it_a; for (it_a = a_list.constBegin(); it_a != a_list.constEnd(); ++it_a) { accountMap[(*it_a).accountType()] = accountMap[(*it_a).accountType()] + 1; @@ -60,7 +60,7 @@ accountMapClosed[(*it_a).accountType()] = accountMapClosed[(*it_a).accountType()] + 1; } - QMap::const_iterator it_m; + QMap::const_iterator it_m; for (it_m = accountMap.constBegin(); it_m != accountMap.constEnd(); ++it_m) { QTreeWidgetItem *item = new QTreeWidgetItem(); item->setText(0, KMyMoneyUtils::accountTypeToString(it_m.key())); diff --git a/kmymoney/dialogs/kmymoneysplittable.cpp b/kmymoney/dialogs/kmymoneysplittable.cpp --- a/kmymoney/dialogs/kmymoneysplittable.cpp +++ b/kmymoney/dialogs/kmymoneysplittable.cpp @@ -49,6 +49,7 @@ // Project Includes #include "mymoneyfile.h" +#include "mymoneyprice.h" #include "kmymoneyedit.h" #include "kmymoneycategory.h" #include "kmymoneyaccountselector.h" @@ -677,7 +678,7 @@ // determine the fraction required for this category int fract = toCurrency.smallestAccountFraction(); - if (cat.accountType() == MyMoneyAccount::Cash) + if (cat.accountType() == eMyMoney::Account::Cash) fract = toCurrency.smallestCashFraction(); // display only positive values to the user @@ -900,18 +901,18 @@ QString categoryId = m_editCategory->selectedItem(); AccountSet aSet; - aSet.addAccountGroup(MyMoneyAccount::Asset); - aSet.addAccountGroup(MyMoneyAccount::Liability); - aSet.addAccountGroup(MyMoneyAccount::Income); - aSet.addAccountGroup(MyMoneyAccount::Expense); + aSet.addAccountGroup(eMyMoney::Account::Asset); + aSet.addAccountGroup(eMyMoney::Account::Liability); + aSet.addAccountGroup(eMyMoney::Account::Income); + aSet.addAccountGroup(eMyMoney::Account::Expense); if (KMyMoneyGlobalSettings::expertMode()) - aSet.addAccountGroup(MyMoneyAccount::Equity); + aSet.addAccountGroup(eMyMoney::Account::Equity); // remove the accounts with invalid types at this point - aSet.removeAccountType(MyMoneyAccount::CertificateDep); - aSet.removeAccountType(MyMoneyAccount::Investment); - aSet.removeAccountType(MyMoneyAccount::Stock); - aSet.removeAccountType(MyMoneyAccount::MoneyMarket); + aSet.removeAccountType(eMyMoney::Account::CertificateDep); + aSet.removeAccountType(eMyMoney::Account::Investment); + aSet.removeAccountType(eMyMoney::Account::Stock); + aSet.removeAccountType(eMyMoney::Account::MoneyMarket); aSet.load(m_editCategory->selector()); diff --git a/kmymoney/dialogs/knewaccountdlg.cpp b/kmymoney/dialogs/knewaccountdlg.cpp --- a/kmymoney/dialogs/knewaccountdlg.cpp +++ b/kmymoney/dialogs/knewaccountdlg.cpp @@ -132,31 +132,31 @@ MyMoneyFile *file = MyMoneyFile::instance(); // initialize the m_parentAccount member - QVector filterAccountGroup {m_account.accountGroup()}; + QVector filterAccountGroup {m_account.accountGroup()}; switch (m_account.accountGroup()) { - case MyMoneyAccount::Asset: + case eMyMoney::Account::Asset: m_parentAccount = file->asset(); break; - case MyMoneyAccount::Liability: + case eMyMoney::Account::Liability: m_parentAccount = file->liability(); break; - case MyMoneyAccount::Income: + case eMyMoney::Account::Income: m_parentAccount = file->income(); break; - case MyMoneyAccount::Expense: + case eMyMoney::Account::Expense: m_parentAccount = file->expense(); break; - case MyMoneyAccount::Equity: + case eMyMoney::Account::Equity: m_parentAccount = file->equity(); break; default: qDebug("Seems we have an account that hasn't been mapped to the top five"); if (m_categoryEditor) { m_parentAccount = file->income(); - filterAccountGroup[0] = MyMoneyAccount::Income; + filterAccountGroup[0] = eMyMoney::Account::Income; } else { m_parentAccount = file->asset(); - filterAccountGroup[0] = MyMoneyAccount::Asset; + filterAccountGroup[0] = eMyMoney::Account::Asset; } } @@ -190,7 +190,7 @@ m_priceMode->insertItem(i18n("Total for all shares"), 2); int priceMode = 0; - if (m_account.accountType() == MyMoneyAccount::Investment) { + if (m_account.accountType() == eMyMoney::Account::Investment) { m_priceMode->setEnabled(true); if (!m_account.value("priceMode").isEmpty()) priceMode = m_account.value("priceMode").toInt(); @@ -221,18 +221,18 @@ m_institutionBox->hide(); m_qcheckboxNoVat->hide(); - typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Income)); - typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Expense)); + typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Income)); + typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Expense)); // Hardcoded but acceptable - if above we set the default to income do the same here switch (account.accountType()) { - case MyMoneyAccount::Expense: - typeCombo->setCurrentItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Expense), false); + case eMyMoney::Account::Expense: + typeCombo->setCurrentItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Expense), false); break; - case MyMoneyAccount::Income: + case eMyMoney::Account::Income: default: - typeCombo->setCurrentItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Income), false); + typeCombo->setCurrentItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Income), false); break; } m_currency->setEnabled(true); @@ -260,17 +260,17 @@ m_costCenterRequiredCheckBox->hide(); switch (m_account.accountType()) { - case MyMoneyAccount::Savings: - case MyMoneyAccount::Cash: + case eMyMoney::Account::Savings: + case eMyMoney::Account::Cash: haveMinBalance = true; break; - case MyMoneyAccount::Checkings: + case eMyMoney::Account::Checkings: haveMinBalance = true; haveMaxCredit = true; break; - case MyMoneyAccount::CreditCard: + case eMyMoney::Account::CreditCard: haveMaxCredit = true; break; @@ -302,9 +302,9 @@ if (m_isEditing) { if (account.isLiquidAsset()) { - typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Checkings)); - typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Savings)); - typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Cash)); + typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Checkings)); + typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Savings)); + typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Cash)); } else { typeCombo->addItem(typeString); // Once created, accounts of other account types are not @@ -314,27 +314,27 @@ // Once created, a currency cannot be changed if it is referenced. m_currency->setDisabled(MyMoneyFile::instance()->isReferenced(m_account)); } else { - typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Checkings)); - typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Savings)); - typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Cash)); - typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::CreditCard)); - typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Loan)); - typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Investment)); - typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Asset)); - typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Liability)); - typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Stock)); + typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Checkings)); + typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Savings)); + typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Cash)); + typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::CreditCard)); + typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Loan)); + typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Investment)); + typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Asset)); + typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Liability)); + typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Stock)); /* - typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::CertificateDep)); - typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::MoneyMarket)); - typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Currency)); + typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::CertificateDep)); + typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::MoneyMarket)); + typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Currency)); */ // Do not create account types that are not supported // by the current engine. - if (account.accountType() == MyMoneyAccount::UnknownAccountType || - account.accountType() == MyMoneyAccount::CertificateDep || - account.accountType() == MyMoneyAccount::MoneyMarket || - account.accountType() == MyMoneyAccount::Currency) - typeString = KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Checkings); + if (account.accountType() == eMyMoney::Account::Unknown || + account.accountType() == eMyMoney::Account::CertificateDep || + account.accountType() == eMyMoney::Account::MoneyMarket || + account.accountType() == eMyMoney::Account::Currency) + typeString = KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Checkings); } typeCombo->setCurrentItem(typeString, false); @@ -545,14 +545,14 @@ // delete a previous version of the minimumbalance information storeKVP("minimumBalance", QString(), QString()); - MyMoneyAccount::accountTypeE acctype; + eMyMoney::Account acctype; if (!m_categoryEditor) { acctype = KMyMoneyUtils::stringToAccountType(typeCombo->currentText()); // If it's a loan, check if the parent is asset or liability. In // case of asset, we change the account type to be AssetLoan - if (acctype == MyMoneyAccount::Loan - && parent.accountGroup() == MyMoneyAccount::Asset) - acctype = MyMoneyAccount::AssetLoan; + if (acctype == eMyMoney::Account::Loan + && parent.accountGroup() == eMyMoney::Account::Asset) + acctype = eMyMoney::Account::AssetLoan; } else { acctype = parent.accountGroup(); QString newName; @@ -708,13 +708,13 @@ QStringList loadListLiability; for (it = list.begin(); it != list.end(); ++it) { if (!(*it).value("VatRate").isEmpty()) { - if ((*it).accountType() == MyMoneyAccount::Expense) + if ((*it).accountType() == eMyMoney::Account::Expense) loadListExpense += (*it).id(); - else if ((*it).accountType() == MyMoneyAccount::Income) + else if ((*it).accountType() == eMyMoney::Account::Income) loadListIncome += (*it).id(); - else if ((*it).accountType() == MyMoneyAccount::Asset) + else if ((*it).accountType() == eMyMoney::Account::Asset) loadListAsset += (*it).id(); - else if ((*it).accountType() == MyMoneyAccount::Liability) + else if ((*it).accountType() == eMyMoney::Account::Liability) loadListLiability += (*it).id(); } } @@ -781,8 +781,8 @@ void KNewAccountDlg::slotAccountTypeChanged(const QString& typeStr) { - MyMoneyAccount::accountTypeE type; - MyMoneyAccount::accountTypeE oldType; + eMyMoney::Account type; + eMyMoney::Account oldType; type = KMyMoneyUtils::stringToAccountType(typeStr); try { @@ -791,7 +791,7 @@ m_account.setAccountType(type); // update the account group displayed in the accounts hierarchy m_filterProxyModel->clear(); - m_filterProxyModel->addAccountGroup(QVector {m_account.accountGroup()}); + m_filterProxyModel->addAccountGroup(QVector {m_account.accountGroup()}); } } catch (const MyMoneyException &) { qWarning("Unexpected exception in KNewAccountDlg::slotAccountTypeChanged()"); @@ -837,7 +837,7 @@ void KNewAccountDlg::adjustEditWidgets(kMyMoneyEdit* dst, kMyMoneyEdit* src, char mode, int corr) { MyMoneyMoney factor(corr, 1); - if (m_account.accountGroup() == MyMoneyAccount::Asset) + if (m_account.accountGroup() == eMyMoney::Account::Asset) factor = -factor; switch (mode) { @@ -855,7 +855,7 @@ void KNewAccountDlg::handleOpeningBalanceCheckbox(const QString ¤cyId) { - if (m_account.accountType() == MyMoneyAccount::Equity) { + if (m_account.accountType() == eMyMoney::Account::Equity) { // check if there is another opening balance account with the same currency bool isOtherOpenBalancingAccount = false; QList list; @@ -863,7 +863,7 @@ QList::Iterator it; for (it = list.begin(); it != list.end(); ++it) { if (it->id() == m_account.id() || currencyId != it->currencyId() - || it->accountType() != MyMoneyAccount::Equity) + || it->accountType() != eMyMoney::Account::Equity) continue; if (it->value("OpeningBalanceAccount") == "Yes") { isOtherOpenBalancingAccount = true; diff --git a/kmymoney/dialogs/settings/ksettingsgeneral.cpp b/kmymoney/dialogs/settings/ksettingsgeneral.cpp --- a/kmymoney/dialogs/settings/ksettingsgeneral.cpp +++ b/kmymoney/dialogs/settings/ksettingsgeneral.cpp @@ -32,6 +32,8 @@ #include "kmymoneydateinput.h" #include "models.h" #include "accountsmodel.h" +#include "mymoneyfile.h" +#include "mymoneyaccount.h" KSettingsGeneral::KSettingsGeneral(QWidget* parent) : KSettingsGeneralDecl(parent) @@ -99,11 +101,11 @@ foreach (const auto account, accountsList) { if (account.isInvest() && account.balance().isZero()) { // search only for zero balance stocks if (initialHideZeroBalanceEquities) { - accountsModel->slotObjectRemoved(MyMoneyFile::notifyAccount, account.id()); // remove item from accounts' page - institutionsModel->slotObjectRemoved(MyMoneyFile::notifyAccount, account.id()); // remove item from institutions' page + accountsModel->slotObjectRemoved(eMyMoney::File::Object::Account, account.id()); // remove item from accounts' page + institutionsModel->slotObjectRemoved(eMyMoney::File::Object::Account, account.id()); // remove item from institutions' page } else { - accountsModel->slotObjectAdded(MyMoneyFile::notifyAccount, dynamic_cast(&account)); // add item to accounts' page - institutionsModel->slotObjectAdded(MyMoneyFile::notifyAccount, dynamic_cast(&account)); // add item to institutions' page + accountsModel->slotObjectAdded(eMyMoney::File::Object::Account, dynamic_cast(&account)); // add item to accounts' page + institutionsModel->slotObjectAdded(eMyMoney::File::Object::Account, dynamic_cast(&account)); // add item to institutions' page } } } diff --git a/kmymoney/dialogs/settings/ksettingsonlinequotes.cpp b/kmymoney/dialogs/settings/ksettingsonlinequotes.cpp --- a/kmymoney/dialogs/settings/ksettingsonlinequotes.cpp +++ b/kmymoney/dialogs/settings/ksettingsonlinequotes.cpp @@ -36,6 +36,7 @@ #include "kmymoney/converter/webpricequote.h" #include "mymoneyfile.h" +#include "mymoneysecurity.h" #include "icons/icons.h" using namespace Icons; diff --git a/kmymoney/dialogs/transactioneditor.h b/kmymoney/dialogs/transactioneditor.h --- a/kmymoney/dialogs/transactioneditor.h +++ b/kmymoney/dialogs/transactioneditor.h @@ -155,7 +155,7 @@ QString m_memoText; QString m_scheduleInfo; - MyMoneySchedule::paymentTypeE m_paymentMethod; + eMyMoney::Schedule::PaymentType m_paymentMethod; public slots: void slotReloadEditWidgets(); @@ -271,7 +271,7 @@ * This signal is sent out, if the user decides to schedule the transaction @a t * rather then adding it to the ledger right away. */ - void scheduleTransaction(const MyMoneyTransaction& t, MyMoneySchedule::occurrenceE occurrence); + void scheduleTransaction(const MyMoneyTransaction& t, eMyMoney::Schedule::Occurrence occurrence); /** * This signal is sent out, if the user double clicks the number field diff --git a/kmymoney/dialogs/transactioneditor.cpp b/kmymoney/dialogs/transactioneditor.cpp --- a/kmymoney/dialogs/transactioneditor.cpp +++ b/kmymoney/dialogs/transactioneditor.cpp @@ -53,6 +53,8 @@ #include #include "kmymoneyaccountselector.h" #include "mymoneyfile.h" +#include "mymoneyprice.h" +#include "mymoneysecurity.h" #include "kmymoneyutils.h" #include "transactionform.h" #include "kmymoneyglobalsettings.h" @@ -67,7 +69,7 @@ using namespace Icons; TransactionEditor::TransactionEditor() : - m_paymentMethod(MyMoneySchedule::STYPE_ANY), + m_paymentMethod(eMyMoney::Schedule::PaymentType::Any), m_regForm(0), m_item(0), m_initialAction(ActionNone), @@ -77,7 +79,7 @@ } TransactionEditor::TransactionEditor(TransactionEditorContainer* regForm, KMyMoneyRegister::Transaction* item, const KMyMoneyRegister::SelectedTransactions& list, const QDate& lastPostDate) : - m_paymentMethod(MyMoneySchedule::STYPE_ANY), + m_paymentMethod(eMyMoney::Schedule::PaymentType::Any), m_transactions(list), m_regForm(regForm), m_item(item), @@ -652,7 +654,7 @@ // turn object creation on, so that moving the focus does // not screw up the dialog that might be popping up emit objectCreation(true); - emit scheduleTransaction(*it_ts, MyMoneySchedule::OCCUR_ONCE); + emit scheduleTransaction(*it_ts, eMyMoney::Schedule::Occurrence::Once); emit objectCreation(false); newTransactionCreated = false; @@ -859,18 +861,18 @@ bool showNumberField = true; switch (m_account.accountType()) { - case MyMoneyAccount::Savings: - case MyMoneyAccount::Cash: - case MyMoneyAccount::Loan: - case MyMoneyAccount::AssetLoan: - case MyMoneyAccount::Asset: - case MyMoneyAccount::Liability: - case MyMoneyAccount::Equity: + case eMyMoney::Account::Savings: + case eMyMoney::Account::Cash: + case eMyMoney::Account::Loan: + case eMyMoney::Account::AssetLoan: + case eMyMoney::Account::Asset: + case eMyMoney::Account::Liability: + case eMyMoney::Account::Equity: showNumberField = KMyMoneyGlobalSettings::alwaysShowNrField(); break; - case MyMoneyAccount::Income: - case MyMoneyAccount::Expense: + case eMyMoney::Account::Income: + case eMyMoney::Account::Expense: showNumberField = false; break; @@ -1001,14 +1003,14 @@ // load the account widget KMyMoneyCategory* account = dynamic_cast(haveWidget("account")); if (account) { - aSet.addAccountGroup(MyMoneyAccount::Asset); - aSet.addAccountGroup(MyMoneyAccount::Liability); - aSet.removeAccountType(MyMoneyAccount::AssetLoan); - aSet.removeAccountType(MyMoneyAccount::CertificateDep); - aSet.removeAccountType(MyMoneyAccount::Investment); - aSet.removeAccountType(MyMoneyAccount::Stock); - aSet.removeAccountType(MyMoneyAccount::MoneyMarket); - aSet.removeAccountType(MyMoneyAccount::Loan); + aSet.addAccountGroup(eMyMoney::Account::Asset); + aSet.addAccountGroup(eMyMoney::Account::Liability); + aSet.removeAccountType(eMyMoney::Account::AssetLoan); + aSet.removeAccountType(eMyMoney::Account::CertificateDep); + aSet.removeAccountType(eMyMoney::Account::Investment); + aSet.removeAccountType(eMyMoney::Account::Stock); + aSet.removeAccountType(eMyMoney::Account::MoneyMarket); + aSet.removeAccountType(eMyMoney::Account::Loan); aSet.load(account->selector()); account->completion()->setSelected(m_account.id()); account->slotItemSelected(m_account.id()); @@ -1032,22 +1034,22 @@ QList::const_iterator it_s; for (it_s = m_transaction.splits().constBegin(); !haveEquityAccount && it_s != m_transaction.splits().constEnd(); ++it_s) { MyMoneyAccount acc = MyMoneyFile::instance()->account((*it_s).accountId()); - if (acc.accountType() == MyMoneyAccount::Equity) + if (acc.accountType() == eMyMoney::Account::Equity) haveEquityAccount = true; } aSet.clear(); - aSet.addAccountGroup(MyMoneyAccount::Asset); - aSet.addAccountGroup(MyMoneyAccount::Liability); - aSet.addAccountGroup(MyMoneyAccount::Income); - aSet.addAccountGroup(MyMoneyAccount::Expense); + aSet.addAccountGroup(eMyMoney::Account::Asset); + aSet.addAccountGroup(eMyMoney::Account::Liability); + aSet.addAccountGroup(eMyMoney::Account::Income); + aSet.addAccountGroup(eMyMoney::Account::Expense); if (KMyMoneyGlobalSettings::expertMode() || haveEquityAccount) - aSet.addAccountGroup(MyMoneyAccount::Equity); + aSet.addAccountGroup(eMyMoney::Account::Equity); - aSet.removeAccountType(MyMoneyAccount::CertificateDep); - aSet.removeAccountType(MyMoneyAccount::Investment); - aSet.removeAccountType(MyMoneyAccount::Stock); - aSet.removeAccountType(MyMoneyAccount::MoneyMarket); + aSet.removeAccountType(eMyMoney::Account::CertificateDep); + aSet.removeAccountType(eMyMoney::Account::Investment); + aSet.removeAccountType(eMyMoney::Account::Stock); + aSet.removeAccountType(eMyMoney::Account::MoneyMarket); aSet.load(category->selector()); // if an account is specified then remove it from the widget so that the user @@ -1073,10 +1075,10 @@ dynamic_cast(w)->loadText(m_split.number()); if (m_transaction.id().isEmpty() // new transaction && dynamic_cast(w)->text().isEmpty() // no number filled in - && m_account.accountType() == MyMoneyAccount::Checkings // checkings account + && m_account.accountType() == eMyMoney::Account::Checkings // checkings account && KMyMoneyGlobalSettings::autoIncCheckNumber() // and auto inc number turned on? && action != KMyMoneyRegister::ActionDeposit // only transfers or withdrawals - && m_paymentMethod == MyMoneySchedule::STYPE_WRITECHEQUE) {// only for STYPE_WRITECHEQUE + && m_paymentMethod == eMyMoney::Schedule::PaymentType::WriteChecque) {// only for WriteChecque assignNextNumber(); } } @@ -1221,12 +1223,12 @@ QString categoryId = category->selectedItem(); AccountSet aSet; - aSet.addAccountGroup(MyMoneyAccount::Asset); - aSet.addAccountGroup(MyMoneyAccount::Liability); - aSet.addAccountGroup(MyMoneyAccount::Income); - aSet.addAccountGroup(MyMoneyAccount::Expense); + aSet.addAccountGroup(eMyMoney::Account::Asset); + aSet.addAccountGroup(eMyMoney::Account::Liability); + aSet.addAccountGroup(eMyMoney::Account::Income); + aSet.addAccountGroup(eMyMoney::Account::Expense); if (KMyMoneyGlobalSettings::expertMode()) - aSet.addAccountGroup(MyMoneyAccount::Equity); + aSet.addAccountGroup(eMyMoney::Account::Equity); aSet.load(category->selector()); // if an account is specified then remove it from the widget so that the user @@ -1595,7 +1597,7 @@ if (!id.isEmpty()) { MyMoneyAccount acc = MyMoneyFile::instance()->account(id); if (acc.isAssetLiability() - || acc.accountGroup() == MyMoneyAccount::Equity) { + || acc.accountGroup() == eMyMoney::Account::Equity) { if (tabbar) { tabbar->setCurrentIndex(KMyMoneyRegister::ActionTransfer); tabbar->setTabEnabled(KMyMoneyRegister::ActionDeposit, false); diff --git a/kmymoney/kmymoney.h b/kmymoney/kmymoney.h --- a/kmymoney/kmymoney.h +++ b/kmymoney/kmymoney.h @@ -527,7 +527,7 @@ * This slot collects information for a new scheduled transaction * based on transaction @a t and @a occurrence and saves it in the engine. */ - void slotScheduleNew(const MyMoneyTransaction& t, MyMoneySchedule::occurrenceE occurrence = MyMoneySchedule::OCCUR_MONTHLY); + void slotScheduleNew(const MyMoneyTransaction& t, eMyMoney::Schedule::Occurrence occurrence = eMyMoney::Schedule::Occurrence::Monthly); /** */ diff --git a/kmymoney/kmymoney.cpp b/kmymoney/kmymoney.cpp --- a/kmymoney/kmymoney.cpp +++ b/kmymoney/kmymoney.cpp @@ -126,6 +126,7 @@ #include "views/konlinejoboutbox.h" #include "models/onlinejobmessagesmodel.h" +#include "mymoney/mymoneyfile.h" #include "mymoney/mymoneyutils.h" #include "mymoney/mymoneystatement.h" #include "mymoney/storage/mymoneystoragedump.h" @@ -165,6 +166,7 @@ #include "ledgerdelegate.h" #include "storageenums.h" +#include "mymoneyenums.h" using namespace Icons; @@ -2670,7 +2672,7 @@ try { const MyMoneySecurity& sec = file->security(newAccount.currencyId()); // Check the opening balance - if (openingBal.isPositive() && newAccount.accountGroup() == MyMoneyAccount::Liability) { + if (openingBal.isPositive() && newAccount.accountGroup() == eMyMoney::Account::Liability) { QString message = i18n("This account is a liability and if the " "opening balance represents money owed, then it should be negative. " "Negate the amount?\n\n" @@ -2951,8 +2953,8 @@ // in case of a loan account, we keep a reference to this // schedule in the account - if (newAccount.accountType() == MyMoneyAccount::Loan - || newAccount.accountType() == MyMoneyAccount::AssetLoan) { + if (newAccount.accountType() == eMyMoney::Account::Loan + || newAccount.accountType() == eMyMoney::Account::AssetLoan) { newAccount.setValue("schedule", newSchedule.id()); file->modifyAccount(newAccount); } @@ -2990,8 +2992,8 @@ // make sure we only allow transactions in a 'category' (income/expense account) switch (d->m_selectedAccount.accountType()) { - case MyMoneyAccount::Income: - case MyMoneyAccount::Expense: + case eMyMoney::Account::Income: + case eMyMoney::Account::Expense: break; default: @@ -3100,8 +3102,8 @@ // to be deleted anymore switch (d->m_selectedAccount.accountGroup()) { // special handling for categories to allow deleting of empty subcategories - case MyMoneyAccount::Income: - case MyMoneyAccount::Expense: { // open a compound statement here to be able to declare variables + case eMyMoney::Account::Income: + case eMyMoney::Account::Expense: { // open a compound statement here to be able to declare variables // which would otherwise not work within a case label. // case A - only a single, unused category without subcats selected @@ -3209,8 +3211,8 @@ MyMoneyFile* file = MyMoneyFile::instance(); if (!d->m_selectedAccount.id().isEmpty()) { if (!file->isStandardAccount(d->m_selectedAccount.id())) { - if (d->m_selectedAccount.accountType() != MyMoneyAccount::Loan - && d->m_selectedAccount.accountType() != MyMoneyAccount::AssetLoan) { + if (d->m_selectedAccount.accountType() != eMyMoney::Account::Loan + && d->m_selectedAccount.accountType() != eMyMoney::Account::AssetLoan) { QString caption; bool category = false; switch (d->m_selectedAccount.accountGroup()) { @@ -3218,8 +3220,8 @@ caption = i18n("Edit account '%1'", d->m_selectedAccount.name()); break; - case MyMoneyAccount::Expense: - case MyMoneyAccount::Income: + case eMyMoney::Account::Expense: + case eMyMoney::Account::Income: caption = i18n("Edit category '%1'", d->m_selectedAccount.name()); category = true; break; @@ -3245,7 +3247,7 @@ s0 = t.splitByAccount(d->m_selectedAccount.id()); s1 = t.splitByAccount(d->m_selectedAccount.id(), false); dlg->setOpeningBalance(s0.shares()); - if (d->m_selectedAccount.accountGroup() == MyMoneyAccount::Liability) { + if (d->m_selectedAccount.accountGroup() == eMyMoney::Account::Liability) { dlg->setOpeningBalance(-s0.shares()); } } catch (const MyMoneyException &e) { @@ -3280,7 +3282,7 @@ account.setOnlineBankingSettings((*it_plugin)->onlineBankingSettings(account.onlineBankingSettings())); } MyMoneyMoney bal = dlg->openingBalance(); - if (d->m_selectedAccount.accountGroup() == MyMoneyAccount::Liability) { + if (d->m_selectedAccount.accountGroup() == eMyMoney::Account::Liability) { bal = -bal; } @@ -3486,7 +3488,7 @@ // it make's sense for asset and liability accounts try { // check if we have overdue schedules for this account - QList schedules = file->scheduleList(d->m_selectedAccount.id(), MyMoneySchedule::TYPE_ANY, MyMoneySchedule::OCCUR_ANY, MyMoneySchedule::STYPE_ANY, QDate(), QDate(), true); + QList schedules = file->scheduleList(d->m_selectedAccount.id(), eMyMoney::Schedule::Type::Any, eMyMoney::Schedule::Occurrence::Any, eMyMoney::Schedule::PaymentType::Any, QDate(), QDate(), true); if (schedules.count() > 0) { if (KMessageBox::questionYesNo(this, i18n("KMyMoney has detected some overdue scheduled transactions for this account. Do you want to enter those scheduled transactions now?"), i18n("Scheduled transactions found")) == KMessageBox::Yes) { @@ -3509,7 +3511,7 @@ } // reload list (maybe this schedule needs to be added again) - schedules = file->scheduleList(d->m_selectedAccount.id(), MyMoneySchedule::TYPE_ANY, MyMoneySchedule::OCCUR_ANY, MyMoneySchedule::STYPE_ANY, QDate(), QDate(), true); + schedules = file->scheduleList(d->m_selectedAccount.id(), eMyMoney::Schedule::Type::Any, eMyMoney::Schedule::Occurrence::Any, eMyMoney::Schedule::PaymentType::Any, QDate(), QDate(), true); } while (processedOne); } } @@ -3530,8 +3532,8 @@ QList > transactionList; MyMoneyTransactionFilter filter(account.id()); - filter.addState(MyMoneyTransactionFilter::cleared); - filter.addState(MyMoneyTransactionFilter::notReconciled); + filter.addState((int)eMyMoney::TransactionFilter::State::Cleared); + filter.addState((int)eMyMoney::TransactionFilter::State::NotReconciled); filter.setDateFilter(QDate(), endDate); filter.setConsiderCategory(false); filter.setReportAllSplits(true); @@ -3600,8 +3602,8 @@ // retrieve list of all transactions that are not reconciled or cleared QList > transactionList; MyMoneyTransactionFilter filter(d->m_reconciliationAccount.id()); - filter.addState(MyMoneyTransactionFilter::cleared); - filter.addState(MyMoneyTransactionFilter::notReconciled); + filter.addState((int)eMyMoney::TransactionFilter::State::Cleared); + filter.addState((int)eMyMoney::TransactionFilter::State::NotReconciled); filter.setDateFilter(QDate(), d->m_endingBalanceDlg->statementDate()); filter.setConsiderCategory(false); filter.setReportAllSplits(true); @@ -3660,7 +3662,7 @@ // collect the list of cleared splits for this account filter.clear(); filter.addAccount(d->m_reconciliationAccount.id()); - filter.addState(MyMoneyTransactionFilter::cleared); + filter.addState(eMyMoney::TransactionFilter::Cleared); filter.setConsiderCategory(false); filter.setReportAllSplits(true); file->transactionList(transactionList, filter); @@ -3916,7 +3918,7 @@ slotScheduleNew(MyMoneyTransaction()); } -void KMyMoneyApp::slotScheduleNew(const MyMoneyTransaction& _t, MyMoneySchedule::occurrenceE occurrence) +void KMyMoneyApp::slotScheduleNew(const MyMoneyTransaction& _t, eMyMoney::Schedule::Occurrence occurrence) { MyMoneySchedule schedule; schedule.setOccurrence(occurrence); @@ -3927,7 +3929,7 @@ if (_t != MyMoneyTransaction()) { MyMoneyTransaction t(_t); schedule.setTransaction(t); - if (occurrence != MyMoneySchedule::OCCUR_ONCE) + if (occurrence != eMyMoney::Schedule::Occurrence::Once) schedule.setNextDueDate(schedule.nextPayment(t.postDate())); } @@ -3961,9 +3963,9 @@ KEditLoanWizard* loan_wiz = 0; switch (schedule.type()) { - case MyMoneySchedule::TYPE_BILL: - case MyMoneySchedule::TYPE_DEPOSIT: - case MyMoneySchedule::TYPE_TRANSFER: + case eMyMoney::Schedule::Type::Bill: + case eMyMoney::Schedule::Type::Deposit: + case eMyMoney::Schedule::Type::Transfer: sched_dlg = new KEditScheduleDlg(schedule, this); d->m_transactionEditor = sched_dlg->startEdit(); if (d->m_transactionEditor) { @@ -4001,7 +4003,7 @@ delete sched_dlg; break; - case MyMoneySchedule::TYPE_LOANPAYMENT: + case eMyMoney::Schedule::Type::LoanPayment: loan_wiz = new KEditLoanWizard(schedule.account(2)); connect(loan_wiz, SIGNAL(newCategory(MyMoneyAccount&)), this, SLOT(slotCategoryNew(MyMoneyAccount&))); connect(loan_wiz, SIGNAL(createPayee(QString,QString&)), this, SLOT(slotPayeeNew(QString,QString&))); @@ -4018,7 +4020,7 @@ delete loan_wiz; break; - case MyMoneySchedule::TYPE_ANY: + case eMyMoney::Schedule::Type::Any: break; } @@ -4035,7 +4037,7 @@ try { MyMoneySchedule sched = MyMoneyFile::instance()->schedule(d->m_selectedSchedule.id()); QString msg = i18n("

Are you sure you want to delete the scheduled transaction %1?

", d->m_selectedSchedule.name()); - if (sched.type() == MyMoneySchedule::TYPE_LOANPAYMENT) { + if (sched.type() == eMyMoney::Schedule::Type::LoanPayment) { msg += QString(" "); msg += i18n("In case of loan payments it is currently not possible to recreate the scheduled transaction."); } @@ -4097,7 +4099,7 @@ try { schedule = MyMoneyFile::instance()->schedule(schedule.id()); if (!schedule.isFinished()) { - if (schedule.occurrence() != MyMoneySchedule::OCCUR_ONCE) { + if (schedule.occurrence() != eMyMoney::Schedule::Occurrence::Once) { QDate next = schedule.nextDueDate(); if (!schedule.isFinished() && (KMessageBox::questionYesNo(this, QString("") + i18n("Do you really want to skip the %1 transaction scheduled for %2?", schedule.name(), QLocale().toString(next, QLocale::ShortFormat)) + QString(""))) == KMessageBox::Yes) { MyMoneyFileTransaction ft; @@ -5185,7 +5187,7 @@ if (d->m_transactionEditor) { connect(d->m_transactionEditor, SIGNAL(statusProgress(int,int)), this, SLOT(slotStatusProgressBar(int,int))); connect(d->m_transactionEditor, SIGNAL(statusMsg(QString)), this, SLOT(slotStatusMsg(QString))); - connect(d->m_transactionEditor, SIGNAL(scheduleTransaction(MyMoneyTransaction,MyMoneySchedule::occurrenceE)), this, SLOT(slotScheduleNew(MyMoneyTransaction,MyMoneySchedule::occurrenceE))); + connect(d->m_transactionEditor, SIGNAL(scheduleTransaction(MyMoneyTransaction,eMyMoney::Schedule::Occurrence)), this, SLOT(slotScheduleNew(MyMoneyTransaction,eMyMoney::Schedule::Occurrence))); } slotUpdateActions(); } @@ -5632,7 +5634,7 @@ try { KMyMoneyRegister::SelectedTransactions::const_iterator it_t; for (it_t = d->m_selectedTransactions.constBegin(); it_t != d->m_selectedTransactions.constEnd(); ++it_t) { - if (d->m_selectedAccount.accountType() == MyMoneyAccount::Investment) { + if (d->m_selectedAccount.accountType() == eMyMoney::Account::Investment) { d->moveInvestmentTransaction(d->m_selectedAccount.id(), id, (*it_t).transaction()); } else { QList::const_iterator it_s; @@ -5724,24 +5726,24 @@ if (!d->m_selectedAccount.id().isEmpty()) { AccountSet accountSet; - if (d->m_selectedAccount.accountType() == MyMoneyAccount::Investment) { - accountSet.addAccountType(MyMoneyAccount::Investment); + if (d->m_selectedAccount.accountType() == eMyMoney::Account::Investment) { + accountSet.addAccountType(eMyMoney::Account::Investment); } else if (d->m_selectedAccount.isAssetLiability()) { - accountSet.addAccountType(MyMoneyAccount::Checkings); - accountSet.addAccountType(MyMoneyAccount::Savings); - accountSet.addAccountType(MyMoneyAccount::Cash); - accountSet.addAccountType(MyMoneyAccount::AssetLoan); - accountSet.addAccountType(MyMoneyAccount::CertificateDep); - accountSet.addAccountType(MyMoneyAccount::MoneyMarket); - accountSet.addAccountType(MyMoneyAccount::Asset); - accountSet.addAccountType(MyMoneyAccount::Currency); - accountSet.addAccountType(MyMoneyAccount::CreditCard); - accountSet.addAccountType(MyMoneyAccount::Loan); - accountSet.addAccountType(MyMoneyAccount::Liability); + accountSet.addAccountType(eMyMoney::Account::Checkings); + accountSet.addAccountType(eMyMoney::Account::Savings); + accountSet.addAccountType(eMyMoney::Account::Cash); + accountSet.addAccountType(eMyMoney::Account::AssetLoan); + accountSet.addAccountType(eMyMoney::Account::CertificateDep); + accountSet.addAccountType(eMyMoney::Account::MoneyMarket); + accountSet.addAccountType(eMyMoney::Account::Asset); + accountSet.addAccountType(eMyMoney::Account::Currency); + accountSet.addAccountType(eMyMoney::Account::CreditCard); + accountSet.addAccountType(eMyMoney::Account::Loan); + accountSet.addAccountType(eMyMoney::Account::Liability); } else if (d->m_selectedAccount.isIncomeExpense()) { - accountSet.addAccountType(MyMoneyAccount::Income); - accountSet.addAccountType(MyMoneyAccount::Expense); + accountSet.addAccountType(eMyMoney::Account::Income); + accountSet.addAccountType(eMyMoney::Account::Expense); } accountSet.load(d->m_moveToAccountSelector); @@ -6100,7 +6102,7 @@ if (d->m_selectedTransactions.count() == 1) { aC->action(s_Actions[Action::TransactionEditSplits])->setEnabled(true); } - if (d->m_selectedAccount.isAssetLiability() && d->m_selectedAccount.accountType() != MyMoneyAccount::Investment) { + if (d->m_selectedAccount.isAssetLiability() && d->m_selectedAccount.accountType() != eMyMoney::Account::Investment) { aC->action(s_Actions[Action::TransactionCreateSchedule])->setEnabled(d->m_selectedTransactions.count() == 1); } } @@ -6231,14 +6233,14 @@ if (!d->m_selectedAccount.id().isEmpty()) { if (!file->isStandardAccount(d->m_selectedAccount.id())) { switch (d->m_selectedAccount.accountGroup()) { - case MyMoneyAccount::Asset: - case MyMoneyAccount::Liability: - case MyMoneyAccount::Equity: + case eMyMoney::Account::Asset: + case eMyMoney::Account::Liability: + case eMyMoney::Account::Equity: aC->action(s_Actions[Action::AccountTransactionReport])->setEnabled(true); aC->action(s_Actions[Action::AccountEdit])->setEnabled(true); aC->action(s_Actions[Action::AccountDelete])->setEnabled(!file->isReferenced(d->m_selectedAccount)); aC->action(s_Actions[Action::AccountOpen])->setEnabled(true); - if (d->m_selectedAccount.accountGroup() != MyMoneyAccount::Equity) { + if (d->m_selectedAccount.accountGroup() != eMyMoney::Account::Equity) { if (d->m_reconciliationAccount.id().isEmpty()) { aC->action(s_Actions[Action::AccountStartReconciliation])->setEnabled(true); aC->action(s_Actions[Action::AccountStartReconciliation])->setToolTip(i18n("Reconcile")); @@ -6253,7 +6255,7 @@ } } - if (d->m_selectedAccount.accountType() == MyMoneyAccount::Investment) + if (d->m_selectedAccount.accountType() == eMyMoney::Account::Investment) aC->action(s_Actions[Action::InvestmentNew])->setEnabled(true); if (d->m_selectedAccount.isClosed()) @@ -6280,8 +6282,8 @@ aC->action(s_Actions[Action::AccountBalanceChart])->setEnabled(true); break; - case MyMoneyAccount::Income : - case MyMoneyAccount::Expense : + case eMyMoney::Account::Income : + case eMyMoney::Account::Expense : aC->action(s_Actions[Action::CategoryEdit])->setEnabled(true); // enable delete action, if category/account itself is not referenced // by any object except accounts, because we want to allow @@ -6331,7 +6333,7 @@ if (!d->m_selectedSchedule.isFinished()) { aC->action(s_Actions[Action::ScheduleEnter])->setEnabled(true); // a schedule with a single occurrence cannot be skipped - if (d->m_selectedSchedule.occurrence() != MyMoneySchedule::OCCUR_ONCE) { + if (d->m_selectedSchedule.occurrence() != eMyMoney::Schedule::Occurrence::Once) { aC->action(s_Actions[Action::ScheduleSkip])->setEnabled(true); } } diff --git a/kmymoney/kmymoneyutils.h b/kmymoney/kmymoneyutils.h --- a/kmymoney/kmymoneyutils.h +++ b/kmymoney/kmymoneyutils.h @@ -139,12 +139,12 @@ * an account type into a human readable format * * @param accountType numerical representation of the account type. - * For possible values, see MyMoneyAccount::accountTypeE + * For possible values, see eMyMoney::Account * @return QString representing the human readable form translated according to the language cataglogue * * @sa MyMoneyAccount::accountTypeToString() */ - static const QString accountTypeToString(const MyMoneyAccount::accountTypeE accountType); + static const QString accountTypeToString(const eMyMoney::Account accountType); /** * This method is used to convert an account type from its @@ -152,9 +152,9 @@ * * @param type reference to a QString containing the string to convert * @return accountTypeE containing the internal used numeric value. For possible - * values see MyMoneyAccount::accountTypeE + * values see eMyMoney::Account */ - static MyMoneyAccount::accountTypeE stringToAccountType(const QString& type); + static eMyMoney::Account stringToAccountType(const QString& type); /** * This method is used to convert a rounding method from its @@ -191,7 +191,7 @@ * * @deprecated Use i18n(MyMoneySchedule::occurrenceToString(occurrence)) instead */ - static const QString occurrenceToString(const MyMoneySchedule::occurrenceE occurrence); + static const QString occurrenceToString(const eMyMoney::Schedule::Occurrence occurrence); /** * This method is used to convert the payment type from its @@ -204,7 +204,7 @@ * * @sa MyMoneySchedule::paymentMethodToString() */ - static const QString paymentMethodToString(MyMoneySchedule::paymentTypeE paymentType); + static const QString paymentMethodToString(eMyMoney::Schedule::PaymentType paymentType); /** * This method is used to convert the schedule weekend option from its @@ -217,7 +217,7 @@ * * @sa MyMoneySchedule::weekendOptionToString() */ - static const QString weekendOptionToString(MyMoneySchedule::weekendOptionE weekendOption); + static const QString weekendOptionToString(eMyMoney::Schedule::WeekendOption weekendOption); /** * This method is used to convert the schedule type from its @@ -230,7 +230,7 @@ * * @sa MyMoneySchedule::scheduleTypeToString() */ - static const QString scheduleTypeToString(MyMoneySchedule::typeE type); + static const QString scheduleTypeToString(eMyMoney::Schedule::Type type); /** * This method is used to convert a numeric index of an item diff --git a/kmymoney/kmymoneyutils.cpp b/kmymoney/kmymoneyutils.cpp --- a/kmymoney/kmymoneyutils.cpp +++ b/kmymoney/kmymoneyutils.cpp @@ -49,6 +49,7 @@ // Project Includes #include "mymoneyfile.h" +#include "mymoneyprice.h" #include "mymoneyforecast.h" #include "kmymoneyglobalsettings.h" #include "icons.h" @@ -64,68 +65,68 @@ { } -const QString KMyMoneyUtils::accountTypeToString(const MyMoneyAccount::accountTypeE accountType) +const QString KMyMoneyUtils::accountTypeToString(const eMyMoney::Account accountType) { return MyMoneyAccount::accountTypeToString(accountType); } -MyMoneyAccount::accountTypeE KMyMoneyUtils::stringToAccountType(const QString& type) +eMyMoney::Account KMyMoneyUtils::stringToAccountType(const QString& type) { - MyMoneyAccount::accountTypeE rc = MyMoneyAccount::UnknownAccountType; + eMyMoney::Account rc = eMyMoney::Account::Unknown; QString tmp = type.toLower(); if (tmp == i18n("Checking").toLower()) - rc = MyMoneyAccount::Checkings; + rc = eMyMoney::Account::Checkings; else if (tmp == i18n("Savings").toLower()) - rc = MyMoneyAccount::Savings; + rc = eMyMoney::Account::Savings; else if (tmp == i18n("Credit Card").toLower()) - rc = MyMoneyAccount::CreditCard; + rc = eMyMoney::Account::CreditCard; else if (tmp == i18n("Cash").toLower()) - rc = MyMoneyAccount::Cash; + rc = eMyMoney::Account::Cash; else if (tmp == i18n("Loan").toLower()) - rc = MyMoneyAccount::Loan; + rc = eMyMoney::Account::Loan; else if (tmp == i18n("Certificate of Deposit").toLower()) - rc = MyMoneyAccount::CertificateDep; + rc = eMyMoney::Account::CertificateDep; else if (tmp == i18n("Investment").toLower()) - rc = MyMoneyAccount::Investment; + rc = eMyMoney::Account::Investment; else if (tmp == i18n("Money Market").toLower()) - rc = MyMoneyAccount::MoneyMarket; + rc = eMyMoney::Account::MoneyMarket; else if (tmp == i18n("Asset").toLower()) - rc = MyMoneyAccount::Asset; + rc = eMyMoney::Account::Asset; else if (tmp == i18n("Liability").toLower()) - rc = MyMoneyAccount::Liability; + rc = eMyMoney::Account::Liability; else if (tmp == i18n("Currency").toLower()) - rc = MyMoneyAccount::Currency; + rc = eMyMoney::Account::Currency; else if (tmp == i18n("Income").toLower()) - rc = MyMoneyAccount::Income; + rc = eMyMoney::Account::Income; else if (tmp == i18n("Expense").toLower()) - rc = MyMoneyAccount::Expense; + rc = eMyMoney::Account::Expense; else if (tmp == i18n("Investment Loan").toLower()) - rc = MyMoneyAccount::AssetLoan; + rc = eMyMoney::Account::AssetLoan; else if (tmp == i18n("Stock").toLower()) - rc = MyMoneyAccount::Stock; + rc = eMyMoney::Account::Stock; else if (tmp == i18n("Equity").toLower()) - rc = MyMoneyAccount::Equity; + rc = eMyMoney::Account::Equity; return rc; } -const QString KMyMoneyUtils::occurrenceToString(const MyMoneySchedule::occurrenceE occurrence) +const QString KMyMoneyUtils::occurrenceToString(const eMyMoney::Schedule::Occurrence occurrence) { return i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(occurrence).toLatin1()); } -const QString KMyMoneyUtils::paymentMethodToString(MyMoneySchedule::paymentTypeE paymentType) +const QString KMyMoneyUtils::paymentMethodToString(eMyMoney::Schedule::PaymentType paymentType) { return i18nc("Scheduled Transaction payment type", MyMoneySchedule::paymentMethodToString(paymentType).toLatin1()); } -const QString KMyMoneyUtils::weekendOptionToString(MyMoneySchedule::weekendOptionE weekendOption) +const QString KMyMoneyUtils::weekendOptionToString(eMyMoney::Schedule::WeekendOption weekendOption) { return i18n(MyMoneySchedule::weekendOptionToString(weekendOption).toLatin1()); } -const QString KMyMoneyUtils::scheduleTypeToString(MyMoneySchedule::typeE type) +const QString KMyMoneyUtils::scheduleTypeToString(eMyMoney::Schedule::Type type) { return i18nc("Scheduled transaction type", MyMoneySchedule::scheduleTypeToString(type).toLatin1()); } @@ -286,7 +287,7 @@ return *it_s; } // if we have a reference to an investment account, we remember it here - if (acc.accountType() == MyMoneyAccount::Investment) + if (acc.accountType() == eMyMoney::Account::Investment) investmentAccountSplit = *it_s; } } @@ -321,10 +322,10 @@ MyMoneyAccount a, b; a = MyMoneyFile::instance()->account(ida); b = MyMoneyFile::instance()->account(idb); - if ((a.accountGroup() == MyMoneyAccount::Asset - || a.accountGroup() == MyMoneyAccount::Liability) - && (b.accountGroup() == MyMoneyAccount::Asset - || b.accountGroup() == MyMoneyAccount::Liability)) + if ((a.accountGroup() == eMyMoney::Account::Asset + || a.accountGroup() == eMyMoney::Account::Liability) + && (b.accountGroup() == eMyMoney::Account::Asset + || b.accountGroup() == eMyMoney::Account::Liability)) return Transfer; return Normal; } @@ -481,7 +482,7 @@ MyMoneyTransaction t = schedule.transaction(); try { - if (schedule.type() == MyMoneySchedule::TYPE_LOANPAYMENT) { + if (schedule.type() == eMyMoney::Schedule::Type::LoanPayment) { calculateAutoLoan(schedule, t, QMap()); } } catch (const MyMoneyException &e) { @@ -578,10 +579,10 @@ MyMoneyAccount acc = file->account((*it_s).accountId()); if ((*it_s).id() == split.id()) { security = file->security(acc.currencyId()); - } else if (acc.accountGroup() == MyMoneyAccount::Expense) { + } else if (acc.accountGroup() == eMyMoney::Account::Expense) { feeSplits.append(*it_s); // feeAmount += (*it_s).value(); - } else if (acc.accountGroup() == MyMoneyAccount::Income) { + } else if (acc.accountGroup() == eMyMoney::Account::Income) { interestSplits.append(*it_s); // interestAmount += (*it_s).value(); } else { diff --git a/kmymoney/models/accountsmodel.h b/kmymoney/models/accountsmodel.h --- a/kmymoney/models/accountsmodel.h +++ b/kmymoney/models/accountsmodel.h @@ -33,8 +33,8 @@ // ---------------------------------------------------------------------------- // Project Includes -#include "mymoneyfile.h" #include "modelenums.h" +#include "mymoneyenums.h" /** * A model for the accounts. @@ -51,6 +51,8 @@ * @author Łukasz Wojniłowicz 2017 * */ +class MyMoneyObject; +class MyMoneyMoney; class MyMoneyAccount; class AccountsModel : public QStandardItemModel { @@ -94,9 +96,9 @@ public slots: void slotReconcileAccount(const MyMoneyAccount &account, const QDate &reconciliationDate, const MyMoneyMoney &endingBalance); - void slotObjectAdded(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj); - void slotObjectModified(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj); - void slotObjectRemoved(MyMoneyFile::notificationObjectT objType, const QString& id); + void slotObjectAdded(eMyMoney::File::Object objType, const MyMoneyObject * const obj); + void slotObjectModified(eMyMoney::File::Object objType, const MyMoneyObject * const obj); + void slotObjectRemoved(eMyMoney::File::Object objType, const QString& id); void slotBalanceOrValueChanged(const MyMoneyAccount &account); signals: @@ -157,9 +159,9 @@ void load(); public slots: - void slotObjectAdded(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj); - void slotObjectModified(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj); - void slotObjectRemoved(MyMoneyFile::notificationObjectT objType, const QString& id); + void slotObjectAdded(eMyMoney::File::Object objType, const MyMoneyObject * const obj); + void slotObjectModified(eMyMoney::File::Object objType, const MyMoneyObject * const obj); + void slotObjectRemoved(eMyMoney::File::Object objType, const QString& id); private: InstitutionsModel(QObject *parent = 0); diff --git a/kmymoney/models/accountsmodel.cpp b/kmymoney/models/accountsmodel.cpp --- a/kmymoney/models/accountsmodel.cpp +++ b/kmymoney/models/accountsmodel.cpp @@ -37,12 +37,17 @@ #include "mymoneyutils.h" #include "mymoneyfile.h" +#include "mymoneyinstitution.h" +#include "mymoneyaccount.h" +#include "mymoneysecurity.h" +#include "mymoneyprice.h" #include "kmymoneyglobalsettings.h" #include "icons.h" #include "modelenums.h" using namespace Icons; using namespace eAccountsModel; +using namespace eMyMoney; class AccountsModel::Private { @@ -173,10 +178,10 @@ const auto checkMark = QIcon::fromTheme(g_Icons[Icon::DialogOK]); switch (account.accountType()) { - case MyMoneyAccount::Income: - case MyMoneyAccount::Expense: - case MyMoneyAccount::Asset: - case MyMoneyAccount::Liability: + case Account::Income: + case Account::Expense: + case Account::Asset: + case Account::Liability: // Tax if (columns.contains(Column::Tax)) { colNum = m_columns.indexOf(Column::Tax); @@ -361,9 +366,9 @@ // for income and liability accounts, we reverse the sign switch (account.accountGroup()) { - case MyMoneyAccount::Income: - case MyMoneyAccount::Liability: - case MyMoneyAccount::Equity: + case Account::Income: + case Account::Liability: + case Account::Equity: balance = -balance; break; @@ -448,7 +453,7 @@ auto value = data.value(); if (isInstitutionsModel) { const auto account = childNode->data((int)Role::Account).value(); - if (account.accountGroup() == MyMoneyAccount::Liability) + if (account.accountGroup() == Account::Liability) value = -value; } totalValue += value; @@ -578,10 +583,10 @@ } // adding account categories (asset, liability, etc.) node - QVector categories { - MyMoneyAccount::Asset, MyMoneyAccount::Liability, - MyMoneyAccount::Income, MyMoneyAccount::Expense, - MyMoneyAccount::Equity + QVector categories { + Account::Asset, Account::Liability, + Account::Income, Account::Expense, + Account::Equity }; foreach (const auto category, categories) { @@ -590,31 +595,31 @@ int displayOrder; switch (category) { - case MyMoneyAccount::Asset: + case Account::Asset: // Asset accounts account = d->m_file->asset(); accountName = i18n("Asset accounts"); displayOrder = 1; break; - case MyMoneyAccount::Liability: + case Account::Liability: // Liability accounts account = d->m_file->liability(); accountName = i18n("Liability accounts"); displayOrder = 2; break; - case MyMoneyAccount::Income: + case Account::Income: // Income categories account = d->m_file->income(); accountName = i18n("Income categories"); displayOrder = 3; break; - case MyMoneyAccount::Expense: + case Account::Expense: // Expense categories account = d->m_file->expense(); accountName = i18n("Expense categories"); displayOrder = 4; break; - case MyMoneyAccount::Equity: + case Account::Equity: // Equity accounts account = d->m_file->equity(); accountName = i18n("Equity accounts"); @@ -879,9 +884,9 @@ * Notify the model that an object has been added. An action is performed only if the object is an account. * */ -void AccountsModel::slotObjectAdded(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj) +void AccountsModel::slotObjectAdded(File::Object objType, const MyMoneyObject * const obj) { - if (objType != MyMoneyFile::notifyAccount) + if (objType != File::Object::Account) return; const MyMoneyAccount * const account = dynamic_cast(obj); @@ -912,9 +917,9 @@ * Notify the model that an object has been modified. An action is performed only if the object is an account. * */ -void AccountsModel::slotObjectModified(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj) +void AccountsModel::slotObjectModified(File::Object objType, const MyMoneyObject * const obj) { - if (objType != MyMoneyFile::notifyAccount) + if (objType != File::Object::Account) return; const MyMoneyAccount * const account = dynamic_cast(obj); @@ -938,8 +943,8 @@ favoriteAccountsItem->removeRow(favItem->row()); // it's not favorite anymore } else { // this means that the hierarchy was changed - simulate this with a remove followed by and add operation - slotObjectRemoved(MyMoneyFile::notifyAccount, oldAccount.id()); - slotObjectAdded(MyMoneyFile::notifyAccount, obj); + slotObjectRemoved(File::Object::Account, oldAccount.id()); + slotObjectAdded(File::Object::Account, obj); } checkNetWorth(); @@ -950,9 +955,9 @@ * Notify the model that an object has been removed. An action is performed only if the object is an account. * */ -void AccountsModel::slotObjectRemoved(MyMoneyFile::notificationObjectT objType, const QString& id) +void AccountsModel::slotObjectRemoved(File::Object objType, const QString& id) { - if (objType != MyMoneyFile::notifyAccount) + if (objType != File::Object::Account) return; auto list = match(index(0, 0), (int)Role::ID, id, -1, Qt::MatchFlags(Qt::MatchExactly | Qt::MatchRecursive)); @@ -1121,10 +1126,10 @@ * Notify the model that an object has been added. An action is performed only if the object is an account or an institution. * */ -void InstitutionsModel::slotObjectAdded(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj) +void InstitutionsModel::slotObjectAdded(File::Object objType, const MyMoneyObject * const obj) { auto modelUtils = static_cast(d); - if (objType == MyMoneyFile::notifyInstitution) { + if (objType == File::Object::Institution) { // if an institution was added then add the item which will represent it const MyMoneyInstitution * const institution = dynamic_cast(obj); if (!institution) @@ -1132,7 +1137,7 @@ modelUtils->addInstitutionItem(this, *institution); } - if (objType != MyMoneyFile::notifyAccount) + if (objType != File::Object::Account) return; // if an account was added then add the item which will represent it only for real accounts @@ -1161,9 +1166,9 @@ * Notify the model that an object has been modified. An action is performed only if the object is an account or an institution. * */ -void InstitutionsModel::slotObjectModified(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj) +void InstitutionsModel::slotObjectModified(File::Object objType, const MyMoneyObject * const obj) { - if (objType == MyMoneyFile::notifyInstitution) { + if (objType == File::Object::Institution) { // if an institution was modified then modify the item which represents it const MyMoneyInstitution * const institution = dynamic_cast(obj); if (!institution) @@ -1174,13 +1179,13 @@ institutionItem->setIcon(institution->pixmap()); } - if (objType != MyMoneyFile::notifyAccount) + if (objType != File::Object::Account) return; // if an account was modified then modify the item which represents it const MyMoneyAccount * const account = dynamic_cast(obj); // nothing to do for root accounts, categories and equity accounts since they don't have a representation in this model - if (!account || account->parentAccountId().isEmpty() || account->isIncomeExpense() || account->accountType() == MyMoneyAccount::Equity) + if (!account || account->parentAccountId().isEmpty() || account->isIncomeExpense() || account->accountType() == Account::Equity) return; auto accountItem = d->itemFromAccountId(this, account->id()); @@ -1190,8 +1195,8 @@ d->setAccountData(accountItem->parent(), accountItem->row(), *account, d->m_columns); } else { // this means that the hierarchy was changed - simulate this with a remove followed by and add operation - slotObjectRemoved(MyMoneyFile::notifyAccount, oldAccount.id()); - slotObjectAdded(MyMoneyFile::notifyAccount, obj); + slotObjectRemoved(File::Object::Account, oldAccount.id()); + slotObjectAdded(File::Object::Account, obj); } } @@ -1199,16 +1204,16 @@ * Notify the model that an object has been removed. An action is performed only if the object is an account or an institution. * */ -void InstitutionsModel::slotObjectRemoved(MyMoneyFile::notificationObjectT objType, const QString& id) +void InstitutionsModel::slotObjectRemoved(File::Object objType, const QString& id) { - if (objType == MyMoneyFile::notifyInstitution) { + if (objType == File::Object::Institution) { // if an institution was removed then remove the item which represents it auto itInstitution = static_cast(d)->institutionItemFromId(this, id); if (itInstitution) removeRow(itInstitution->row(), itInstitution->index().parent()); } - if (objType != MyMoneyFile::notifyAccount) + if (objType != File::Object::Account) return; // if an account was removed then remove the item which represents it and recompute the institution's value diff --git a/kmymoney/models/accountsproxymodel.h b/kmymoney/models/accountsproxymodel.h --- a/kmymoney/models/accountsproxymodel.h +++ b/kmymoney/models/accountsproxymodel.h @@ -44,8 +44,8 @@ * * @code * AccountsFilterProxyModel *filterModel = new AccountsFilterProxyModel(widget); - * filterModel->addAccountGroup(MyMoneyAccount::Asset); - * filterModel->addAccountGroup(MyMoneyAccount::Liability); + * filterModel->addAccountGroup(eMyMoney::Account::Asset); + * filterModel->addAccountGroup(eMyMoney::Account::Liability); * filterModel->setSourceModel(Models::instance()->accountsModel()); * filterModel->sort(0); * @@ -70,9 +70,9 @@ AccountsProxyModel(QObject *parent = nullptr); ~AccountsProxyModel(); - void addAccountType(MyMoneyAccount::accountTypeE type); - void addAccountGroup(const QVector &groups); - void removeAccountType(MyMoneyAccount::accountTypeE type); + void addAccountType(eMyMoney::Account type); + void addAccountGroup(const QVector &groups); + void removeAccountType(eMyMoney::Account type); void clear(); diff --git a/kmymoney/models/accountsproxymodel.cpp b/kmymoney/models/accountsproxymodel.cpp --- a/kmymoney/models/accountsproxymodel.cpp +++ b/kmymoney/models/accountsproxymodel.cpp @@ -51,7 +51,7 @@ ~Private() { } - QList m_typeList; + QList m_typeList; bool m_hideClosedAccounts; bool m_hideEquityAccounts; bool m_hideUnusedIncomeExpenseAccounts; @@ -133,37 +133,37 @@ /** * Add the given account group to the filter. * @param group The account group to be added. - * @see MyMoneyAccount::accountTypeE + * @see eMyMoney::Account */ -void AccountsProxyModel::addAccountGroup(const QVector &groups) +void AccountsProxyModel::addAccountGroup(const QVector &groups) { foreach (const auto group, groups) { switch (group) { - case MyMoneyAccount::Asset: - d->m_typeList << MyMoneyAccount::Checkings; - d->m_typeList << MyMoneyAccount::Savings; - d->m_typeList << MyMoneyAccount::Cash; - d->m_typeList << MyMoneyAccount::AssetLoan; - d->m_typeList << MyMoneyAccount::CertificateDep; - d->m_typeList << MyMoneyAccount::Investment; - d->m_typeList << MyMoneyAccount::Stock; - d->m_typeList << MyMoneyAccount::MoneyMarket; - d->m_typeList << MyMoneyAccount::Asset; - d->m_typeList << MyMoneyAccount::Currency; + case eMyMoney::Account::Asset: + d->m_typeList << eMyMoney::Account::Checkings; + d->m_typeList << eMyMoney::Account::Savings; + d->m_typeList << eMyMoney::Account::Cash; + d->m_typeList << eMyMoney::Account::AssetLoan; + d->m_typeList << eMyMoney::Account::CertificateDep; + d->m_typeList << eMyMoney::Account::Investment; + d->m_typeList << eMyMoney::Account::Stock; + d->m_typeList << eMyMoney::Account::MoneyMarket; + d->m_typeList << eMyMoney::Account::Asset; + d->m_typeList << eMyMoney::Account::Currency; break; - case MyMoneyAccount::Liability: - d->m_typeList << MyMoneyAccount::CreditCard; - d->m_typeList << MyMoneyAccount::Loan; - d->m_typeList << MyMoneyAccount::Liability; + case eMyMoney::Account::Liability: + d->m_typeList << eMyMoney::Account::CreditCard; + d->m_typeList << eMyMoney::Account::Loan; + d->m_typeList << eMyMoney::Account::Liability; break; - case MyMoneyAccount::Income: - d->m_typeList << MyMoneyAccount::Income; + case eMyMoney::Account::Income: + d->m_typeList << eMyMoney::Account::Income; break; - case MyMoneyAccount::Expense: - d->m_typeList << MyMoneyAccount::Expense; + case eMyMoney::Account::Expense: + d->m_typeList << eMyMoney::Account::Expense; break; - case MyMoneyAccount::Equity: - d->m_typeList << MyMoneyAccount::Equity; + case eMyMoney::Account::Equity: + d->m_typeList << eMyMoney::Account::Equity; break; default: break; @@ -175,9 +175,9 @@ /** * Add the given account type to the filter. * @param type The account type to be added. - * @see MyMoneyAccount::accountTypeE + * @see eMyMoney::Account */ -void AccountsProxyModel::addAccountType(MyMoneyAccount::accountTypeE type) +void AccountsProxyModel::addAccountType(eMyMoney::Account type) { d->m_typeList << type; invalidateFilter(); @@ -186,9 +186,9 @@ /** * Remove the given account type from the filter. * @param type The account type to be removed. - * @see MyMoneyAccount::accountTypeE + * @see eMyMoney::Account */ -void AccountsProxyModel::removeAccountType(MyMoneyAccount::accountTypeE type) +void AccountsProxyModel::removeAccountType(eMyMoney::Account type) { if (d->m_typeList.removeAll(type) > 0) { invalidateFilter(); @@ -222,11 +222,11 @@ return false; // we hide equity accounts if not in expert mode - if (account.accountType() == MyMoneyAccount::Equity && hideEquityAccounts()) + if (account.accountType() == eMyMoney::Account::Equity && hideEquityAccounts()) return false; // we hide unused income and expense accounts if the specific flag is set - if ((account.accountType() == MyMoneyAccount::Income || account.accountType() == MyMoneyAccount::Expense) && hideUnusedIncomeExpenseAccounts()) { + if ((account.accountType() == eMyMoney::Account::Income || account.accountType() == eMyMoney::Account::Expense) && hideUnusedIncomeExpenseAccounts()) { const auto totalValue = sourceModel()->data(source, (int)Role::TotalValue); if (totalValue.isValid() && totalValue.value().isZero()) { emit unusedIncomeExpenseAccountHidden(); diff --git a/kmymoney/models/equitiesmodel.h b/kmymoney/models/equitiesmodel.h --- a/kmymoney/models/equitiesmodel.h +++ b/kmymoney/models/equitiesmodel.h @@ -29,8 +29,10 @@ // ---------------------------------------------------------------------------- // Project Includes -#include "mymoneyfile.h" +#include "mymoneyenums.h" +class MyMoneyObject; +class MyMoneyAccount; class EquitiesModel : public QStandardItemModel { Q_OBJECT @@ -45,9 +47,9 @@ static QString getHeaderName(const Column column); public slots: - void slotObjectAdded(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj); - void slotObjectModified(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj); - void slotObjectRemoved(MyMoneyFile::notificationObjectT objType, const QString& id); + void slotObjectAdded(eMyMoney::File::Object objType, const MyMoneyObject * const obj); + void slotObjectModified(eMyMoney::File::Object objType, const MyMoneyObject * const obj); + void slotObjectRemoved(eMyMoney::File::Object objType, const QString& id); void slotBalanceOrValueChanged(const MyMoneyAccount &account); private: diff --git a/kmymoney/models/equitiesmodel.cpp b/kmymoney/models/equitiesmodel.cpp --- a/kmymoney/models/equitiesmodel.cpp +++ b/kmymoney/models/equitiesmodel.cpp @@ -28,6 +28,11 @@ // ---------------------------------------------------------------------------- // Project Includes +#include "mymoneyfile.h" +#include "mymoneyaccount.h" +#include "mymoneysecurity.h" +#include "mymoneyprice.h" + class EquitiesModel::Private { public: @@ -84,7 +89,7 @@ cell->setData(account.currencyId(), Role::SecurityID); } - if (account.accountType() == MyMoneyAccount::Investment) // investments accounts are not meant to be displayed, so stop here + if (account.accountType() == eMyMoney::Account::Investment) // investments accounts are not meant to be displayed, so stop here return; // Symbol @@ -206,7 +211,7 @@ QList accList; d->m_file->accountList(accList); // get all available accounts foreach (const auto acc, accList) - if (acc.accountType() == MyMoneyAccount::Investment) // but add only investment accounts (and its children) to the model + if (acc.accountType() == eMyMoney::Account::Investment) // but add only investment accounts (and its children) to the model d->loadInvestmentAccount(rootItem, acc); this->blockSignals(false); @@ -216,22 +221,22 @@ * Notify the model that an object has been added. An action is performed only if the object is an account. * */ -void EquitiesModel::slotObjectAdded(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj) +void EquitiesModel::slotObjectAdded(eMyMoney::File::Object objType, const MyMoneyObject * const obj) { // check whether change is about accounts - if (objType != MyMoneyFile::notifyAccount) + if (objType != eMyMoney::File::Object::Account) return; // check whether change is about either investment or stock account const auto acc = dynamic_cast(obj); if (!acc || - (acc->accountType() != MyMoneyAccount::Investment && - acc->accountType() != MyMoneyAccount::Stock)) + (acc->accountType() != eMyMoney::Account::Investment && + acc->accountType() != eMyMoney::Account::Stock)) return; auto itAcc = d->itemFromId(this, acc->id(), Role::EquityID); QStandardItem *itParentAcc; - if (acc->accountType() == MyMoneyAccount::Investment) // if it's investment account then its parent is root item + if (acc->accountType() == eMyMoney::Account::Investment) // if it's investment account then its parent is root item itParentAcc = invisibleRootItem(); else // otherwise it's stock account and its parent is investment account itParentAcc = d->itemFromId(this, acc->parentAccountId(), Role::InvestmentID); @@ -250,21 +255,21 @@ * Notify the model that an object has been modified. An action is performed only if the object is an account. * */ -void EquitiesModel::slotObjectModified(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj) +void EquitiesModel::slotObjectModified(eMyMoney::File::Object objType, const MyMoneyObject * const obj) { const MyMoneyAccount *acc; QStandardItem *itAcc; switch (objType) { - case MyMoneyFile::notifyAccount: + case eMyMoney::File::Object::Account: { auto tmpAcc = dynamic_cast(obj); - if (!tmpAcc || tmpAcc->accountType() != MyMoneyAccount::Stock) + if (!tmpAcc || tmpAcc->accountType() != eMyMoney::Account::Stock) return; acc = tmpAcc; itAcc = d->itemFromId(this, acc->id(), Role::EquityID); break; } - case MyMoneyFile::notifySecurity: + case eMyMoney::File::Object::Security: { auto sec = dynamic_cast(obj); itAcc = d->itemFromId(this, sec->id(), Role::SecurityID); @@ -284,8 +289,8 @@ if (modelID == acc->parentAccountId()) { // and if it matches with those from file then modify only d->setAccountData(itParentAcc, itAcc->row(), *acc, d->m_columns); } else { // and if not then reparent - slotObjectRemoved(MyMoneyFile::notifyAccount, acc->id()); - slotObjectAdded(MyMoneyFile::notifyAccount, obj); + slotObjectRemoved(eMyMoney::File::Object::Account, acc->id()); + slotObjectAdded(eMyMoney::File::Object::Account, obj); } } @@ -293,9 +298,9 @@ * Notify the model that an object has been removed. An action is performed only if the object is an account. * */ -void EquitiesModel::slotObjectRemoved(MyMoneyFile::notificationObjectT objType, const QString& id) +void EquitiesModel::slotObjectRemoved(eMyMoney::File::Object objType, const QString& id) { - if (objType != MyMoneyFile::notifyAccount) + if (objType != eMyMoney::File::Object::Account) return; const auto indexList = match(index(0, 0), Role::EquityID, id, -1, Qt::MatchFlags(Qt::MatchExactly | Qt::MatchRecursive)); @@ -308,7 +313,7 @@ */ void EquitiesModel::slotBalanceOrValueChanged(const MyMoneyAccount &account) { - if (account.accountType() != MyMoneyAccount::Stock) + if (account.accountType() != eMyMoney::Account::Stock) return; const auto itAcc = d->itemFromId(this, account.id(), Role::EquityID); @@ -415,7 +420,7 @@ acc.isClosed()) return false; if (d->m_hideZeroBalanceAccounts && - acc.accountType() != MyMoneyAccount::Investment && acc.balance().isZero()) // we should never hide investment account because all underlaying stocks will be hidden as well + acc.accountType() != eMyMoney::Account::Investment && acc.balance().isZero()) // we should never hide investment account because all underlaying stocks will be hidden as well return false; } return true; diff --git a/kmymoney/models/ledgermodel.h b/kmymoney/models/ledgermodel.h --- a/kmymoney/models/ledgermodel.h +++ b/kmymoney/models/ledgermodel.h @@ -35,7 +35,7 @@ #include "mymoneyaccount.h" #include "mymoneysplit.h" #include "mymoneyschedule.h" -#include "mymoneyfile.h" +#include "mymoneyenums.h" /** * Forward declarations for the returned models. @@ -492,12 +492,12 @@ public Q_SLOTS: protected Q_SLOTS: - void removeTransaction(MyMoneyFile::notificationObjectT objType, const QString& id); - void addTransaction(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj); - void modifyTransaction(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj); - void removeSchedule(MyMoneyFile::notificationObjectT objType, const QString& id); - void addSchedule(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj); - void modifySchedule(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj); + void removeTransaction(eMyMoney::File::Object objType, const QString& id); + void addTransaction(eMyMoney::File::Object objType, const MyMoneyObject * const obj); + void modifyTransaction(eMyMoney::File::Object objType, const MyMoneyObject * const obj); + void removeSchedule(eMyMoney::File::Object objType, const QString& id); + void addSchedule(eMyMoney::File::Object objType, const MyMoneyObject * const obj); + void modifySchedule(eMyMoney::File::Object objType, const MyMoneyObject * const obj); protected: struct Private; @@ -512,7 +512,7 @@ virtual ~LedgerSortFilterProxyModel(); void setShowNewTransaction(bool show); - void setAccountType(MyMoneyAccount::accountTypeE type); + void setAccountType(eMyMoney::Account type); /** * This method maps the @a index to the base model and calls setData on it @@ -531,7 +531,7 @@ private: bool m_showNewTransaction; - MyMoneyAccount::accountTypeE m_accountType; + eMyMoney::Account m_accountType; }; diff --git a/kmymoney/models/ledgermodel.cpp b/kmymoney/models/ledgermodel.cpp --- a/kmymoney/models/ledgermodel.cpp +++ b/kmymoney/models/ledgermodel.cpp @@ -34,10 +34,15 @@ // Project Includes #include "mymoneytransaction.h" +#include "mymoneytransactionfilter.h" #include "mymoneyfile.h" +#include "mymoneypayee.h" #include "mymoneymoney.h" #include "kmymoneyutils.h" #include "kmymoneyglobalsettings.h" +#include "mymoneyenums.h" + +using namespace eMyMoney; LedgerItem::LedgerItem() { @@ -281,7 +286,7 @@ LedgerSortFilterProxyModel::LedgerSortFilterProxyModel(QObject* parent) : QSortFilterProxyModel(parent) , m_showNewTransaction(false) - , m_accountType(MyMoneyAccount::Asset) + , m_accountType(Account::Asset) { setFilterRole(LedgerRole::AccountIdRole); setFilterKeyColumn(0); @@ -293,7 +298,7 @@ { } -void LedgerSortFilterProxyModel::setAccountType(MyMoneyAccount::accountTypeE type) +void LedgerSortFilterProxyModel::setAccountType(Account type) { m_accountType = type; } @@ -304,19 +309,19 @@ switch(section) { case LedgerModel::PaymentColumn: switch(m_accountType) { - case MyMoneyAccount::CreditCard: + case Account::CreditCard: return i18nc("Payment made with credit card", "Charge"); - case MyMoneyAccount::Asset: - case MyMoneyAccount::AssetLoan: + case Account::Asset: + case Account::AssetLoan: return i18nc("Decrease of asset/liability value", "Decrease"); - case MyMoneyAccount::Liability: - case MyMoneyAccount::Loan: + case Account::Liability: + case Account::Loan: return i18nc("Increase of asset/liability value", "Increase"); - case MyMoneyAccount::Income: - case MyMoneyAccount::Expense: + case Account::Income: + case Account::Expense: return i18n("Income"); default: @@ -326,19 +331,19 @@ case LedgerModel::DepositColumn: switch(m_accountType) { - case MyMoneyAccount::CreditCard: + case Account::CreditCard: return i18nc("Payment towards credit card", "Payment"); - case MyMoneyAccount::Asset: - case MyMoneyAccount::AssetLoan: + case Account::Asset: + case Account::AssetLoan: return i18nc("Increase of asset/liability value", "Increase"); - case MyMoneyAccount::Liability: - case MyMoneyAccount::Loan: + case Account::Liability: + case Account::Loan: return i18nc("Decrease of asset/liability value", "Decrease"); - case MyMoneyAccount::Income: - case MyMoneyAccount::Expense: + case Account::Income: + case Account::Expense: return i18n("Expense"); default: @@ -435,13 +440,13 @@ { MyMoneyFile* file = MyMoneyFile::instance(); - connect(file, SIGNAL(objectAdded(MyMoneyFile::notificationObjectT,MyMoneyObject*const)), this, SLOT(addTransaction(MyMoneyFile::notificationObjectT,MyMoneyObject*const))); - connect(file, SIGNAL(objectModified(MyMoneyFile::notificationObjectT,MyMoneyObject*const)), this, SLOT(modifyTransaction(MyMoneyFile::notificationObjectT,MyMoneyObject*const))); - connect(file, SIGNAL(objectRemoved(MyMoneyFile::notificationObjectT,QString)), this, SLOT(removeTransaction(MyMoneyFile::notificationObjectT,QString))); + connect(file, SIGNAL(objectAdded(File::Object,MyMoneyObject*const)), this, SLOT(addTransaction(File::Object,MyMoneyObject*const))); + connect(file, SIGNAL(objectModified(File::Object,MyMoneyObject*const)), this, SLOT(modifyTransaction(File::Object,MyMoneyObject*const))); + connect(file, SIGNAL(objectRemoved(File::Object,QString)), this, SLOT(removeTransaction(File::Object,QString))); - connect(file, SIGNAL(objectAdded(MyMoneyFile::notificationObjectT,MyMoneyObject*const)), this, SLOT(addSchedule(MyMoneyFile::notificationObjectT,MyMoneyObject*const))); - connect(file, SIGNAL(objectModified(MyMoneyFile::notificationObjectT,MyMoneyObject*const)), this, SLOT(modifySchedule(MyMoneyFile::notificationObjectT,MyMoneyObject*const))); - connect(file, SIGNAL(objectRemoved(MyMoneyFile::notificationObjectT,QString)), this, SLOT(removeSchedule(MyMoneyFile::notificationObjectT,QString))); + connect(file, SIGNAL(objectAdded(File::Object,MyMoneyObject*const)), this, SLOT(addSchedule(File::Object,MyMoneyObject*const))); + connect(file, SIGNAL(objectModified(File::Object,MyMoneyObject*const)), this, SLOT(modifySchedule(File::Object,MyMoneyObject*const))); + connect(file, SIGNAL(objectRemoved(File::Object,QString)), this, SLOT(removeSchedule(File::Object,QString))); } LedgerModel::~LedgerModel() @@ -836,7 +841,7 @@ } // if this is a one time schedule, we can bail out here as we're done - if (schedule.occurrence() == MyMoneySchedule::OCCUR_ONCE) + if (schedule.occurrence() == Schedule::Occurrence::Once) break; // for all others, we check if the next payment date is still 'in range' @@ -876,9 +881,9 @@ qDebug() << "Loaded" << rowCount() << "elements"; } -void LedgerModel::addTransaction(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj) +void LedgerModel::addTransaction(File::Object objType, const MyMoneyObject * const obj) { - if(objType != MyMoneyFile::notifyTransaction) { + if(objType != File::Object::Transaction) { return; } @@ -896,9 +901,9 @@ Q_ASSERT(d->m_ledgerItems.count() == rowCount()); } -void LedgerModel::modifyTransaction(MyMoneyFile::notificationObjectT objType, const MyMoneyObject* const obj) +void LedgerModel::modifyTransaction(File::Object objType, const MyMoneyObject* const obj) { - if(objType != MyMoneyFile::notifyTransaction) { + if(objType != File::Object::Transaction) { return; } @@ -967,9 +972,9 @@ Q_ASSERT(d->m_ledgerItems.count() == rowCount()); } -void LedgerModel::removeTransaction(MyMoneyFile::notificationObjectT objType, const QString& id) +void LedgerModel::removeTransaction(File::Object objType, const QString& id) { - if(objType != MyMoneyFile::notifyTransaction) { + if(objType != File::Object::Transaction) { return; } @@ -989,30 +994,30 @@ } } -void LedgerModel::addSchedule(MyMoneyFile::notificationObjectT objType, const MyMoneyObject*const obj) +void LedgerModel::addSchedule(File::Object objType, const MyMoneyObject*const obj) { Q_UNUSED(obj); - if(objType != MyMoneyFile::notifySchedule) { + if(objType != File::Object::Schedule) { return; } /// @todo implement LedgerModel::addSchedule } -void LedgerModel::modifySchedule(MyMoneyFile::notificationObjectT objType, const MyMoneyObject*const obj) +void LedgerModel::modifySchedule(File::Object objType, const MyMoneyObject*const obj) { Q_UNUSED(obj); - if(objType != MyMoneyFile::notifySchedule) { + if(objType != File::Object::Schedule) { return; } /// @todo implement LedgerModel::modifySchedule } -void LedgerModel::removeSchedule(MyMoneyFile::notificationObjectT objType, const QString& id) +void LedgerModel::removeSchedule(File::Object objType, const QString& id) { Q_UNUSED(id); - if(objType != MyMoneyFile::notifySchedule) { + if(objType != File::Object::Schedule) { return; } diff --git a/kmymoney/models/onlinejobmodel.h b/kmymoney/models/onlinejobmodel.h --- a/kmymoney/models/onlinejobmodel.h +++ b/kmymoney/models/onlinejobmodel.h @@ -22,8 +22,9 @@ #include #include -#include "mymoney/mymoneyfile.h" +#include "mymoneyenums.h" +class MyMoneyObject; class onlineJobModel : public QAbstractTableModel { Q_OBJECT @@ -58,9 +59,9 @@ public slots: void reloadAll(); - void slotObjectAdded(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj); - void slotObjectModified(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj); - void slotObjectRemoved(MyMoneyFile::notificationObjectT objType, const QString& id); + void slotObjectAdded(eMyMoney::File::Object objType, const MyMoneyObject * const obj); + void slotObjectModified(eMyMoney::File::Object objType, const MyMoneyObject * const obj); + void slotObjectRemoved(eMyMoney::File::Object objType, const QString& id); /** @brief Load data from MyMoneyFile */ void load(); diff --git a/kmymoney/models/onlinejobmodel.cpp b/kmymoney/models/onlinejobmodel.cpp --- a/kmymoney/models/onlinejobmodel.cpp +++ b/kmymoney/models/onlinejobmodel.cpp @@ -22,6 +22,8 @@ #include +#include "mymoneyobject.h" +#include "mymoneyfile.h" #include "mymoneyutils.h" #include "onlinetasks/interfaces/tasks/onlinetask.h" #include "onlinetasks/interfaces/tasks/credittransfer.h" @@ -239,18 +241,18 @@ return true; } -void onlineJobModel::slotObjectAdded(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj) +void onlineJobModel::slotObjectAdded(eMyMoney::File::Object objType, const MyMoneyObject * const obj) { - if (Q_LIKELY(objType != MyMoneyFile::notifyOnlineJob)) + if (Q_LIKELY(objType != eMyMoney::File::Object::OnlineJob)) return; beginInsertRows(QModelIndex(), rowCount(), rowCount()); m_jobIdList.append(obj->id()); endInsertRows(); } -void onlineJobModel::slotObjectModified(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj) +void onlineJobModel::slotObjectModified(eMyMoney::File::Object objType, const MyMoneyObject * const obj) { - if (Q_LIKELY(objType != MyMoneyFile::notifyOnlineJob)) + if (Q_LIKELY(objType != eMyMoney::File::Object::OnlineJob)) return; int row = m_jobIdList.indexOf(obj->id()); @@ -258,9 +260,9 @@ emit dataChanged(index(row, 0), index(row, columnCount() - 1)); } -void onlineJobModel::slotObjectRemoved(MyMoneyFile::notificationObjectT objType, const QString& id) +void onlineJobModel::slotObjectRemoved(eMyMoney::File::Object objType, const QString& id) { - if (Q_LIKELY(objType != MyMoneyFile::notifyOnlineJob)) + if (Q_LIKELY(objType != eMyMoney::File::Object::OnlineJob)) return; int row = m_jobIdList.indexOf(id); diff --git a/kmymoney/models/payeesmodel.cpp b/kmymoney/models/payeesmodel.cpp --- a/kmymoney/models/payeesmodel.cpp +++ b/kmymoney/models/payeesmodel.cpp @@ -32,6 +32,7 @@ // Project Includes #include "mymoneyfile.h" +#include "mymoneypayee.h" struct PayeesModel::Private { diff --git a/kmymoney/models/securitiesmodel.h b/kmymoney/models/securitiesmodel.h --- a/kmymoney/models/securitiesmodel.h +++ b/kmymoney/models/securitiesmodel.h @@ -29,8 +29,9 @@ // ---------------------------------------------------------------------------- // Project Includes -#include "mymoneyfile.h" +#include "mymoneyenums.h" +class MyMoneyObject; class SecuritiesModel : public QStandardItemModel { Q_OBJECT @@ -44,9 +45,9 @@ static QString getHeaderName(const Column column); public slots: - void slotObjectAdded(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj); - void slotObjectModified(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj); - void slotObjectRemoved(MyMoneyFile::notificationObjectT objType, const QString& id); + void slotObjectAdded(eMyMoney::File::Object objType, const MyMoneyObject * const obj); + void slotObjectModified(eMyMoney::File::Object objType, const MyMoneyObject * const obj); + void slotObjectRemoved(eMyMoney::File::Object objType, const QString& id); private: SecuritiesModel(QObject *parent = nullptr); diff --git a/kmymoney/models/securitiesmodel.cpp b/kmymoney/models/securitiesmodel.cpp --- a/kmymoney/models/securitiesmodel.cpp +++ b/kmymoney/models/securitiesmodel.cpp @@ -28,6 +28,9 @@ // ---------------------------------------------------------------------------- // Project Includes +#include "mymoneyfile.h" +#include "mymoneysecurity.h" + class SecuritiesModel::Private { public: @@ -189,10 +192,10 @@ * Notify the model that an object has been added. An action is performed only if the object is a security. * */ -void SecuritiesModel::slotObjectAdded(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj) +void SecuritiesModel::slotObjectAdded(eMyMoney::File::Object objType, const MyMoneyObject * const obj) { // check whether change is about security - if (objType != MyMoneyFile::notifySecurity) + if (objType != eMyMoney::File::Object::Security) return; // check that we're about to add security @@ -222,9 +225,9 @@ * Notify the model that an object has been modified. An action is performed only if the object is a security. * */ -void SecuritiesModel::slotObjectModified(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj) +void SecuritiesModel::slotObjectModified(eMyMoney::File::Object objType, const MyMoneyObject * const obj) { - if (objType != MyMoneyFile::notifySecurity) + if (objType != eMyMoney::File::Object::Security) return; // check that we're about to modify security @@ -246,9 +249,9 @@ * Notify the model that an object has been removed. An action is performed only if the object is an account. * */ -void SecuritiesModel::slotObjectRemoved(MyMoneyFile::notificationObjectT objType, const QString& id) +void SecuritiesModel::slotObjectRemoved(eMyMoney::File::Object objType, const QString& id) { - if (objType != MyMoneyFile::notifySecurity) + if (objType != eMyMoney::File::Object::Security) return; const auto indexList = match(index(0, 0), Qt::UserRole, id, -1, Qt::MatchFlags(Qt::MatchExactly | Qt::MatchRecursive)); diff --git a/kmymoney/mymoney/mymoneyaccount.h b/kmymoney/mymoney/mymoneyaccount.h --- a/kmymoney/mymoney/mymoneyaccount.h +++ b/kmymoney/mymoney/mymoneyaccount.h @@ -23,7 +23,6 @@ #include #include -#include #include // ---------------------------------------------------------------------------- @@ -32,10 +31,12 @@ #include "mymoneykeyvaluecontainer.h" #include "mymoneymoney.h" #include "mymoneyobject.h" -#include "mymoneysecurity.h" #include "kmm_mymoney_export.h" #include "mymoneyunittestable.h" +#include "mymoneyenums.h" +class QPixmap; +class MyMoneySecurity; class MyMoneySplit; class payeeIdentifier; namespace payeeIdentifiers { class ibanBic; } @@ -49,7 +50,7 @@ * * Currently, the following account types are known: * - * @li UnknownAccountType + * @li Unknown * @li Checkings * @li Savings * @li Cash @@ -92,33 +93,6 @@ Q_ENUM(attrNameE) /** - * Account types currently supported. - */ - typedef enum _accountTypeE { - UnknownAccountType = 0, /**< For error handling */ - Checkings, /**< Standard checking account */ - Savings, /**< Typical savings account */ - Cash, /**< Denotes a shoe-box or pillowcase stuffed - with cash */ - CreditCard, /**< Credit card accounts */ - Loan, /**< Loan and mortgage accounts (liability) */ - CertificateDep, /**< Certificates of Deposit */ - Investment, /**< Investment account */ - MoneyMarket, /**< Money Market Account */ - Asset, /**< Denotes a generic asset account.*/ - Liability, /**< Denotes a generic liability account.*/ - Currency, /**< Denotes a currency trading account. */ - Income, /**< Denotes an income account */ - Expense, /**< Denotes an expense account */ - AssetLoan, /**< Denotes a loan (asset of the owner of this object) */ - Stock, /**< Denotes an security account as sub-account for an investment */ - Equity, /**< Denotes an equity account e.g. opening/closeing balance */ - - /* insert new account types above this line */ - MaxAccountTypes /**< Denotes the number of different account types */ - } accountTypeE; - - /** * This is the constructor for a new empty account */ MyMoneyAccount(); @@ -183,7 +157,7 @@ * * @return accountTypeE of major account type */ - MyMoneyAccount::accountTypeE accountGroup() const; + eMyMoney::Account accountGroup() const; /** * This method returns the id of the MyMoneyInstitution object this account @@ -375,7 +349,7 @@ * * @param type account type */ - void setAccountType(const accountTypeE type); + void setAccountType(const eMyMoney::Account type); /** * This method is used to set a new parent account id @@ -393,7 +367,7 @@ /** * This method returns the type of the account. */ - accountTypeE accountType() const { + eMyMoney::Account accountType() const { return m_accountType; } @@ -599,10 +573,10 @@ * an account type into a human readable format * * @param accountType numerical representation of the account type. - * For possible values, see MyMoneyAccount::accountTypeE + * For possible values, see eMyMoney::Account * @return QString representing the human readable form */ - static QString accountTypeToString(const MyMoneyAccount::accountTypeE accountType); + static QString accountTypeToString(const eMyMoney::Account accountType); /** * keeps a history record of a reconciliation for this account on @a date @@ -628,7 +602,7 @@ /** * This member variable identifies the type of account */ - accountTypeE m_accountType; + eMyMoney::Account m_accountType; /** * This member variable keeps the ID of the MyMoneyInstitution object @@ -798,6 +772,6 @@ * @ref accountTypeE and @ref amountTypeE inside @ref QVariant objects. */ Q_DECLARE_METATYPE(MyMoneyAccount) -Q_DECLARE_METATYPE(MyMoneyAccount::accountTypeE) +Q_DECLARE_METATYPE(eMyMoney::Account) #endif diff --git a/kmymoney/mymoney/mymoneyaccount.cpp b/kmymoney/mymoney/mymoneyaccount.cpp --- a/kmymoney/mymoney/mymoneyaccount.cpp +++ b/kmymoney/mymoney/mymoneyaccount.cpp @@ -38,6 +38,9 @@ #include "mymoneyexception.h" #include "mymoneysplit.h" #include "mymoneyfile.h" +#include "mymoneysecurity.h" +#include "mymoneyinstitution.h" +#include "mymoneypayee.h" #include "payeeidentifier/payeeidentifiertyped.h" #include "payeeidentifier/ibanandbic/ibanbic.h" #include "payeeidentifier/nationalaccount/nationalaccount.h" @@ -48,7 +51,7 @@ using namespace Icons; MyMoneyAccount::MyMoneyAccount() : - m_accountType(UnknownAccountType), + m_accountType(eMyMoney::Account::Unknown), m_fraction(-1) { } @@ -67,7 +70,7 @@ MyMoneyAccount::MyMoneyAccount(const QDomElement& node) : MyMoneyObject(node), MyMoneyKeyValueContainer(node.elementsByTagName(nodeNames[nnKeyValuePairs]).item(0).toElement()), - m_accountType(UnknownAccountType), + m_accountType(eMyMoney::Account::Unknown), m_fraction(-1) { if (nodeNames[nnAccount] != node.tagName()) @@ -104,7 +107,7 @@ bool bOK = false; int type = tmp.toInt(&bOK); if (bOK) { - setAccountType(static_cast(type)); + setAccountType(static_cast(type)); } else { qWarning("XMLREADER: Account %s had invalid or no account type information.", qPrintable(name())); } @@ -195,7 +198,7 @@ m_parentAccount = parent; } -void MyMoneyAccount::setAccountType(const accountTypeE type) +void MyMoneyAccount::setAccountType(const eMyMoney::Account type) { m_accountType = type; } @@ -237,23 +240,23 @@ (m_institution == right.m_institution)); } -MyMoneyAccount::accountTypeE MyMoneyAccount::accountGroup() const +eMyMoney::Account MyMoneyAccount::accountGroup() const { switch (m_accountType) { - case MyMoneyAccount::Checkings: - case MyMoneyAccount::Savings: - case MyMoneyAccount::Cash: - case MyMoneyAccount::Currency: - case MyMoneyAccount::Investment: - case MyMoneyAccount::MoneyMarket: - case MyMoneyAccount::CertificateDep: - case MyMoneyAccount::AssetLoan: - case MyMoneyAccount::Stock: - return MyMoneyAccount::Asset; - - case MyMoneyAccount::CreditCard: - case MyMoneyAccount::Loan: - return MyMoneyAccount::Liability; + case eMyMoney::Account::Checkings: + case eMyMoney::Account::Savings: + case eMyMoney::Account::Cash: + case eMyMoney::Account::Currency: + case eMyMoney::Account::Investment: + case eMyMoney::Account::MoneyMarket: + case eMyMoney::Account::CertificateDep: + case eMyMoney::Account::AssetLoan: + case eMyMoney::Account::Stock: + return eMyMoney::Account::Asset; + + case eMyMoney::Account::CreditCard: + case eMyMoney::Account::Loan: + return eMyMoney::Account::Liability; default: return m_accountType; @@ -267,29 +270,29 @@ bool MyMoneyAccount::isAssetLiability() const { - return accountGroup() == Asset || accountGroup() == Liability; + return accountGroup() == eMyMoney::Account::Asset || accountGroup() == eMyMoney::Account::Liability; } bool MyMoneyAccount::isIncomeExpense() const { - return accountGroup() == Income || accountGroup() == Expense; + return accountGroup() == eMyMoney::Account::Income || accountGroup() == eMyMoney::Account::Expense; } bool MyMoneyAccount::isLoan() const { - return accountType() == Loan || accountType() == AssetLoan; + return accountType() == eMyMoney::Account::Loan || accountType() == eMyMoney::Account::AssetLoan; } bool MyMoneyAccount::isInvest() const { - return accountType() == Stock; + return accountType() == eMyMoney::Account::Stock; } bool MyMoneyAccount::isLiquidAsset() const { - return accountType() == Checkings || - accountType() == Savings || - accountType() == Cash; + return accountType() == eMyMoney::Account::Checkings || + accountType() == eMyMoney::Account::Savings || + accountType() == eMyMoney::Account::Cash; } bool MyMoneyAccount::isCostCenterRequired() const @@ -541,7 +544,7 @@ el.setAttribute(getAttrName(anOpened), dateToString(openingDate())); el.setAttribute(getAttrName(anNumber), number()); // el.setAttribute(getAttrName(anOpeningBalance), openingBalance().toString()); - el.setAttribute(getAttrName(anType), accountType()); + el.setAttribute(getAttrName(anType), (int)accountType()); el.setAttribute(getAttrName(anName), name()); el.setAttribute(getAttrName(anDescription), description()); if (!currencyId().isEmpty()) @@ -614,7 +617,7 @@ int MyMoneyAccount::fraction(const MyMoneySecurity& sec) const { int fraction; - if (m_accountType == Cash) + if (m_accountType == eMyMoney::Account::Cash) fraction = sec.smallestCashFraction(); else fraction = sec.smallestAccountFraction(); @@ -623,7 +626,7 @@ int MyMoneyAccount::fraction(const MyMoneySecurity& sec) { - if (m_accountType == Cash) + if (m_accountType == eMyMoney::Account::Cash) m_fraction = sec.smallestCashFraction(); else m_fraction = sec.smallestAccountFraction(); @@ -637,12 +640,12 @@ bool MyMoneyAccount::isCategory() const { - return m_accountType == Income || m_accountType == Expense; + return m_accountType == eMyMoney::Account::Income || m_accountType == eMyMoney::Account::Expense; } QString MyMoneyAccount::brokerageName() const { - if (m_accountType == Investment) + if (m_accountType == eMyMoney::Account::Investment) return QString("%1 (%2)").arg(m_name, i18nc("Brokerage (suffix for account names)", "Brokerage")); return m_name; } @@ -665,21 +668,21 @@ QPixmap MyMoneyAccount::accountPixmap(const bool reconcileFlag, const int size) const { - static const QHash accToIco { - {MyMoneyAccount::Asset, Icon::ViewAsset}, - {MyMoneyAccount::Investment, Icon::ViewStock}, - {MyMoneyAccount::Stock, Icon::ViewStock}, - {MyMoneyAccount::MoneyMarket, Icon::ViewStock}, - {MyMoneyAccount::Checkings, Icon::ViewChecking}, - {MyMoneyAccount::Savings, Icon::ViewSaving}, - {MyMoneyAccount::AssetLoan, Icon::ViewLoanAsset}, - {MyMoneyAccount::Loan, Icon::ViewLoan}, - {MyMoneyAccount::CreditCard, Icon::ViewCreditCard}, - {MyMoneyAccount::Asset, Icon::ViewAsset}, - {MyMoneyAccount::Cash, Icon::ViewCash}, - {MyMoneyAccount::Income, Icon::ViewIncome}, - {MyMoneyAccount::Expense, Icon::ViewExpense}, - {MyMoneyAccount::Equity, Icon::ViewEquity} + static const QHash accToIco { + {eMyMoney::Account::Asset, Icon::ViewAsset}, + {eMyMoney::Account::Investment, Icon::ViewStock}, + {eMyMoney::Account::Stock, Icon::ViewStock}, + {eMyMoney::Account::MoneyMarket, Icon::ViewStock}, + {eMyMoney::Account::Checkings, Icon::ViewChecking}, + {eMyMoney::Account::Savings, Icon::ViewSaving}, + {eMyMoney::Account::AssetLoan, Icon::ViewLoanAsset}, + {eMyMoney::Account::Loan, Icon::ViewLoan}, + {eMyMoney::Account::CreditCard, Icon::ViewCreditCard}, + {eMyMoney::Account::Asset, Icon::ViewAsset}, + {eMyMoney::Account::Cash, Icon::ViewCash}, + {eMyMoney::Account::Income, Icon::ViewIncome}, + {eMyMoney::Account::Expense, Icon::ViewExpense}, + {eMyMoney::Account::Equity, Icon::ViewEquity} }; Icon ixIcon = accToIco.value(accountType(), Icon::ViewLiability); @@ -708,57 +711,57 @@ return pxIcon; } -QString MyMoneyAccount::accountTypeToString(const MyMoneyAccount::accountTypeE accountType) +QString MyMoneyAccount::accountTypeToString(const eMyMoney::Account accountType) { QString returnString; switch (accountType) { - case MyMoneyAccount::Checkings: + case eMyMoney::Account::Checkings: returnString = i18n("Checking"); break; - case MyMoneyAccount::Savings: + case eMyMoney::Account::Savings: returnString = i18n("Savings"); break; - case MyMoneyAccount::CreditCard: + case eMyMoney::Account::CreditCard: returnString = i18n("Credit Card"); break; - case MyMoneyAccount::Cash: + case eMyMoney::Account::Cash: returnString = i18n("Cash"); break; - case MyMoneyAccount::Loan: + case eMyMoney::Account::Loan: returnString = i18n("Loan"); break; - case MyMoneyAccount::CertificateDep: + case eMyMoney::Account::CertificateDep: returnString = i18n("Certificate of Deposit"); break; - case MyMoneyAccount::Investment: + case eMyMoney::Account::Investment: returnString = i18n("Investment"); break; - case MyMoneyAccount::MoneyMarket: + case eMyMoney::Account::MoneyMarket: returnString = i18n("Money Market"); break; - case MyMoneyAccount::Asset: + case eMyMoney::Account::Asset: returnString = i18n("Asset"); break; - case MyMoneyAccount::Liability: + case eMyMoney::Account::Liability: returnString = i18n("Liability"); break; - case MyMoneyAccount::Currency: + case eMyMoney::Account::Currency: returnString = i18n("Currency"); break; - case MyMoneyAccount::Income: + case eMyMoney::Account::Income: returnString = i18n("Income"); break; - case MyMoneyAccount::Expense: + case eMyMoney::Account::Expense: returnString = i18n("Expense"); break; - case MyMoneyAccount::AssetLoan: + case eMyMoney::Account::AssetLoan: returnString = i18n("Investment Loan"); break; - case MyMoneyAccount::Stock: + case eMyMoney::Account::Stock: returnString = i18n("Stock"); break; - case MyMoneyAccount::Equity: + case eMyMoney::Account::Equity: returnString = i18n("Equity"); break; default: diff --git a/kmymoney/mymoney/mymoneyenums.h b/kmymoney/mymoney/mymoneyenums.h --- a/kmymoney/mymoney/mymoneyenums.h +++ b/kmymoney/mymoney/mymoneyenums.h @@ -20,14 +20,207 @@ #define MYMONEYENUMS_H namespace eMyMoney { - enum class Security { - Stock, - MutualFund, - Bond, - Currency, - None + /** + * Account types currently supported. + */ + enum class Account { + Unknown = 0, /**< For error handling */ + Checkings, /**< Standard checking account */ + Savings, /**< Typical savings account */ + Cash, /**< Denotes a shoe-box or pillowcase stuffed + with cash */ + CreditCard, /**< Credit card accounts */ + Loan, /**< Loan and mortgage accounts (liability) */ + CertificateDep, /**< Certificates of Deposit */ + Investment, /**< Investment account */ + MoneyMarket, /**< Money Market Account */ + Asset, /**< Denotes a generic asset account.*/ + Liability, /**< Denotes a generic liability account.*/ + Currency, /**< Denotes a currency trading account. */ + Income, /**< Denotes an income account */ + Expense, /**< Denotes an expense account */ + AssetLoan, /**< Denotes a loan (asset of the owner of this object) */ + Stock, /**< Denotes an security account as sub-account for an investment */ + Equity, /**< Denotes an equity account e.g. opening/closeing balance */ + + /* insert new account types above this line */ + MaxAccountTypes /**< Denotes the number of different account types */ + }; + + inline uint qHash(const Account key, uint seed) { return ::qHash(static_cast(key), seed); } + + enum class Security { + Stock, + MutualFund, + Bond, + Currency, + None + }; + + inline uint qHash(const Security key, uint seed) { return ::qHash(static_cast(key), seed); } + + namespace Schedule { + /** + * This enum is used to describe all the possible schedule frequencies. + * The special entry, Any, is used to combine all the other types. + */ + enum class Occurrence { + Any = 0, + Once = 1, + Daily = 2, + Weekly = 4, + Fortnightly = 8, + EveryOtherWeek = 16, + EveryHalfMonth = 18, + EveryThreeWeeks = 20, + EveryThirtyDays = 30, + Monthly = 32, + EveryFourWeeks = 64, + EveryEightWeeks = 126, + EveryOtherMonth = 128, + EveryThreeMonths = 256, + TwiceYearly = 1024, + EveryOtherYear = 2048, + Quarterly = 4096, + EveryFourMonths = 8192, + Yearly = 16384 + }; + + /** + * This enum is used to describe the schedule type. + */ + enum class Type { + Any = 0, + Bill = 1, + Deposit = 2, + Transfer = 4, + LoanPayment = 5 + }; + + /** + * This enum is used to describe the schedule's payment type. + */ + enum class PaymentType { + Any = 0, + DirectDebit = 1, + DirectDeposit = 2, + ManualDeposit = 4, + Other = 8, + WriteChecque = 16, + StandingOrder = 32, + BankTransfer = 64 + }; + + /** + * This enum is used by the auto-commit functionality. + * + * Depending upon the value of m_weekendOption the schedule can + * be entered on a different date + **/ + enum class WeekendOption { + MoveBefore = 0, + MoveAfter = 1, + MoveNothing = 2 + }; + } + + namespace TransactionFilter { + // Make sure to keep the following enum valus in sync with the values + // used by the GUI (for KMyMoney in kfindtransactiondlgdecl.ui) + enum class Type { + All = 0, + Payments, + Deposits, + Transfers, + // insert new constants above of this line + LastType + }; + + // Make sure to keep the following enum valus in sync with the values + // used by the GUI (for KMyMoney in kfindtransactiondlgdecl.ui) + enum class State { + All = 0, + NotReconciled, + Cleared, + Reconciled, + Frozen, + // insert new constants above of this line + LastState + }; + + // Make sure to keep the following enum valus in sync with the values + // used by the GUI (for KMyMoney in kfindtransactiondlgdecl.ui) + enum class Validity { + Any = 0, + Valid, + Invalid, + // insert new constants above of this line + LastValidity + }; + + // Make sure to keep the following enum valus in sync with the values + // used by the GUI (for KMyMoney in kfindtransactiondlgdecl.ui) + enum class Date { + All = 0, + AsOfToday, + CurrentMonth, + CurrentYear, + MonthToDate, + YearToDate, + YearToMonth, + LastMonth, + LastYear, + Last7Days, + Last30Days, + Last3Months, + Last6Months, + Last12Months, + Next7Days, + Next30Days, + Next3Months, + Next6Months, + Next12Months, + UserDefined, + Last3ToNext3Months, + Last11Months, + CurrentQuarter, + LastQuarter, + NextQuarter, + CurrentFiscalYear, + LastFiscalYear, + Today, + Next18Months, + // insert new constants above of this line + LastDateItem + }; + } + + namespace File { + /** + * notificationObject identifies the type of the object + * for which this notification is stored + */ + enum class Object { + Account = 1, + Institution, + Payee, + Transaction, + Tag, + Schedule, + Security, + OnlineJob + }; + + /** + * notificationMode identifies the type of notifiation + * (add, modify, remove) + */ + enum class Mode { + Add = 1, + Modify, + Remove }; - inline uint qHash(const Security key, uint seed) { return ::qHash(static_cast(key), seed); } + } } #endif diff --git a/kmymoney/mymoney/mymoneyfile.h b/kmymoney/mymoney/mymoneyfile.h --- a/kmymoney/mymoney/mymoneyfile.h +++ b/kmymoney/mymoney/mymoneyfile.h @@ -2,6 +2,7 @@ mymoneyfile.h ------------------- copyright : (C) 2002, 2007 by Thomas Baumgart + (C) 2017 by Łukasz Wojniłowicz ***************************************************************************/ @@ -21,26 +22,14 @@ // QT Includes #include -#include -#include -#include // ---------------------------------------------------------------------------- // Project Includes - -#include "mymoneyinstitution.h" -#include "mymoneyaccount.h" -#include "mymoneytransaction.h" -#include "mymoneypayee.h" -#include "mymoneytag.h" -#include "mymoneysecurity.h" -#include "mymoneyprice.h" -#include "mymoneyreport.h" -#include -#include -#include "mymoneyschedule.h" #include "kmm_mymoney_export.h" #include "mymoneyunittestable.h" +#include "mymoneyenums.h" + +using namespace eMyMoney; /** * @author Thomas Baumgart, Michael Edwardes, Kevin Tambascio, Christian Dávid @@ -131,40 +120,36 @@ * while the engine code is running. The MyMoneyException:: object * describes the problem. */ +template class QMap; +class QString; +class QStringList; +class QBitArray; class IMyMoneyStorage; class MyMoneyCostCenter; -class QBitArray; +class MyMoneyAccount; +class MyMoneyInstitution; +class MyMoneySecurity; +class MyMoneyPrice; +typedef QPair MyMoneySecurityPair; +typedef QMap MyMoneyPriceEntries; +typedef QMap MyMoneyPriceList; +class MyMoneySchedule; +class MyMoneyTag; +class MyMoneyPayee; +class MyMoneyBudget; +class MyMoneyReport; +class MyMoneyMoney; +class MyMoneySplit; +class MyMoneyObject; +class MyMoneyTransaction; +class MyMoneyTransactionFilter; +class onlineJob; class KMM_MYMONEY_EXPORT MyMoneyFile : public QObject { Q_OBJECT KMM_MYMONEY_UNIT_TESTABLE public: - /** - * notificationObject identifies the type of the object - * for which this notification is stored - */ - typedef enum { - notifyAccount = 1, - notifyInstitution, - notifyPayee, - notifyTransaction, - notifyTag, - notifySchedule, - notifySecurity, - notifyOnlineJob - } notificationObjectT; - - /** - * notificationMode identifies the type of notifiation - * (add, modify, remove) - */ - typedef enum { - notifyAdd = 1, - notifyModify, - notifyRemove - } notificationModeT; - friend class MyMoneyNotifier; /** @@ -625,7 +610,8 @@ * @param date return balance for specific date (default = QDate()) * @return balance of the account as MyMoneyMoney object */ - const MyMoneyMoney balance(const QString& id, const QDate& date = QDate()) const; + const MyMoneyMoney balance(const QString& id, const QDate& date) const; + const MyMoneyMoney balance(const QString& id) const; /** * This method is used to return the cleared balance of an account @@ -651,7 +637,8 @@ * @param date return balance for specific date (default = QDate()) * @return balance of the account as MyMoneyMoney object */ - const MyMoneyMoney totalBalance(const QString& id, const QDate& date = QDate()) const; + const MyMoneyMoney totalBalance(const QString& id, const QDate& date) const; + const MyMoneyMoney totalBalance(const QString& id) const; /** * This method returns the number of transactions currently known to file @@ -664,7 +651,8 @@ * * @return number of transactions in journal/account */ - unsigned int transactionCount(const QString& account = QString()) const; + unsigned int transactionCount(const QString& account) const; + unsigned int transactionCount() const; /** * This method returns a QMap filled with the number of transactions @@ -783,12 +771,12 @@ * MyMoneyAccount::AccountSeperator. * * @param category const reference to QString containing the category - * @param type account type if a specific type is required (defaults to UnknownAccountType) + * @param type account type if a specific type is required (defaults to Unknown) * * @return QString of the corresponding account. If account was not found * the return value will be an empty string. */ - QString categoryToAccount(const QString& category, MyMoneyAccount::accountTypeE type = MyMoneyAccount::UnknownAccountType) const; + QString categoryToAccount(const QString& category, eMyMoney::Account type = eMyMoney::Account::Unknown) const; /** * This method is used to convert a string representing an asset or @@ -1030,15 +1018,15 @@ * account @p accountId. If accountId is the empty string, * this filter is off. Default is @p QString(). * @param type only schedules of type @p type are searched for. - * See MyMoneySchedule::typeE for details. - * Default is MyMoneySchedule::TYPE_ANY + * See eMyMoney::Schedule::Type for details. + * Default is eMyMoney::Schedule::Type::Any * @param occurrence only schedules of occurrence type @p occurrence are searched for. - * See MyMoneySchedule::occurrenceE for details. - * Default is MyMoneySchedule::OCCUR_ANY + * See eMyMoney::Schedule::Occurence for details. + * Default is eMyMoney::Schedule::Occurrence::Any * @param paymentType only schedules of payment method @p paymentType * are searched for. - * See MyMoneySchedule::paymentTypeE for details. - * Default is MyMoneySchedule::STYPE_ANY + * See eMyMoney::Schedule::PaymentType for details. + * Default is eMyMoney::Schedule::PaymentType::Any * @param startDate only schedules with payment dates after @p startDate * are searched for. Default is all dates (QDate()). * @param endDate only schedules with payment dates ending prior to @p endDate @@ -1048,13 +1036,15 @@ * * @return const QList list of schedule objects. */ - const QList scheduleList(const QString& accountId = QString(), - const MyMoneySchedule::typeE type = MyMoneySchedule::TYPE_ANY, - const MyMoneySchedule::occurrenceE occurrence = MyMoneySchedule::OCCUR_ANY, - const MyMoneySchedule::paymentTypeE paymentType = MyMoneySchedule::STYPE_ANY, - const QDate& startDate = QDate(), - const QDate& endDate = QDate(), - const bool overdue = false) const; + const QList scheduleList(const QString& accountId, + const eMyMoney::Schedule::Type type, + const eMyMoney::Schedule::Occurrence occurrence, + const eMyMoney::Schedule::PaymentType paymentType, + const QDate& startDate, + const QDate& endDate, + const bool overdue) const; + const QList scheduleList(const QString& accountId) const; + const QList scheduleList() const; const QStringList consistencyCheck(); @@ -1292,7 +1282,9 @@ * @return price found as MyMoneyPrice object * @note This throws an exception when the base currency is not set and toId is empty */ - MyMoneyPrice price(const QString& fromId, const QString& toId = QString(), const QDate& date = QDate::currentDate(), const bool exactDate = false) const; + MyMoneyPrice price(const QString& fromId, const QString& toId, const QDate& date, const bool exactDate = false) const; + MyMoneyPrice price(const QString& fromId, const QString& toId) const; + MyMoneyPrice price(const QString& fromId) const; /** * This method returns a list of all prices. @@ -1546,7 +1538,7 @@ * @param state @p state reconciliation state * @return number of transactions with state @p state */ - int countTransactionsWithSpecificReconciliationState(const QString& accId, enum MyMoneyTransactionFilter::stateOptionE state) const; + int countTransactionsWithSpecificReconciliationState(const QString& accId, TransactionFilter::State state) const; /** * @brief Saves a new onlineJob @@ -1622,7 +1614,7 @@ * had been added. The data for the new object is contained in * @a obj. */ - void objectAdded(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj); + void objectAdded(eMyMoney::File::Object objType, const MyMoneyObject * const obj); /** * This signal is emitted by the engine whenever an object @@ -1633,14 +1625,14 @@ * method anymore as the object is already deleted in the storage * when the signal is emitted. */ - void objectRemoved(MyMoneyFile::notificationObjectT objType, const QString& id); + void objectRemoved(eMyMoney::File::Object objType, const QString& id); /** * This signal is emitted by the engine whenever an object * had been changed. The new state of the object is contained * in @a obj. */ - void objectModified(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj); + void objectModified(eMyMoney::File::Object objType, const MyMoneyObject * const obj); /** * This signal is emitted by the engine whenever the balance diff --git a/kmymoney/mymoney/mymoneyfile.cpp b/kmymoney/mymoney/mymoneyfile.cpp --- a/kmymoney/mymoney/mymoneyfile.cpp +++ b/kmymoney/mymoney/mymoneyfile.cpp @@ -3,6 +3,7 @@ ------------------- copyright : (C) 2000 by Michael Edwardes (C) 2002, 2007-2011 by Thomas Baumgart + (C) 2017 by Łukasz Wojniłowicz ***************************************************************************/ @@ -37,6 +38,7 @@ // Project Includes #include "imymoneystorage.h" #include "mymoneyaccount.h" +#include "mymoneysecurity.h" #include "mymoneyreport.h" #include "mymoneybalancecache.h" #include "mymoneybudget.h" @@ -49,6 +51,8 @@ // include the following line to get a 'cout' for debug purposes // #include +using namespace eMyMoney; + const QString MyMoneyFile::AccountSeperator = QChar(':'); MyMoneyFile MyMoneyFile::file; @@ -60,58 +64,58 @@ class MyMoneyNotification { public: - MyMoneyNotification(MyMoneyFile::notificationModeT mode, const MyMoneyTransaction& t) : - m_objType(MyMoneyFile::notifyTransaction), + MyMoneyNotification(File::Mode mode, const MyMoneyTransaction& t) : + m_objType(File::Object::Transaction), m_notificationMode(mode), m_id(t.id()) { } - MyMoneyNotification(MyMoneyFile::notificationModeT mode, const MyMoneyAccount& acc) : - m_objType(MyMoneyFile::notifyAccount), + MyMoneyNotification(File::Mode mode, const MyMoneyAccount& acc) : + m_objType(File::Object::Account), m_notificationMode(mode), m_id(acc.id()) { } - MyMoneyNotification(MyMoneyFile::notificationModeT mode, const MyMoneyInstitution& institution) : - m_objType(MyMoneyFile::notifyInstitution), + MyMoneyNotification(File::Mode mode, const MyMoneyInstitution& institution) : + m_objType(File::Object::Institution), m_notificationMode(mode), m_id(institution.id()) { } - MyMoneyNotification(MyMoneyFile::notificationModeT mode, const MyMoneyPayee& payee) : - m_objType(MyMoneyFile::notifyPayee), + MyMoneyNotification(File::Mode mode, const MyMoneyPayee& payee) : + m_objType(File::Object::Payee), m_notificationMode(mode), m_id(payee.id()) { } - MyMoneyNotification(MyMoneyFile::notificationModeT mode, const MyMoneyTag& tag) : - m_objType(MyMoneyFile::notifyTag), + MyMoneyNotification(File::Mode mode, const MyMoneyTag& tag) : + m_objType(File::Object::Tag), m_notificationMode(mode), m_id(tag.id()) { } - MyMoneyNotification(MyMoneyFile::notificationModeT mode, const MyMoneySchedule& schedule) : - m_objType(MyMoneyFile::notifySchedule), + MyMoneyNotification(File::Mode mode, const MyMoneySchedule& schedule) : + m_objType(File::Object::Schedule), m_notificationMode(mode), m_id(schedule.id()) { } - MyMoneyNotification(MyMoneyFile::notificationModeT mode, const MyMoneySecurity& security) : - m_objType(MyMoneyFile::notifySecurity), + MyMoneyNotification(File::Mode mode, const MyMoneySecurity& security) : + m_objType(File::Object::Security), m_notificationMode(mode), m_id(security.id()) { } - MyMoneyNotification(MyMoneyFile::notificationModeT mode, const onlineJob& job) : - m_objType(MyMoneyFile::notifyOnlineJob), + MyMoneyNotification(File::Mode mode, const onlineJob& job) : + m_objType(File::Object::OnlineJob), m_notificationMode(mode), m_id(job.id()) { } - MyMoneyFile::notificationObjectT objectType() const { + File::Object objectType() const { return m_objType; } - MyMoneyFile::notificationModeT notificationMode() const { + File::Mode notificationMode() const { return m_notificationMode; } const QString& id() const { @@ -119,16 +123,16 @@ } protected: - MyMoneyNotification(MyMoneyFile::notificationObjectT obj, - MyMoneyFile::notificationModeT mode, + MyMoneyNotification(File::Object obj, + File::Mode mode, const QString& id) : m_objType(obj), m_notificationMode(mode), m_id(id) {} private: - MyMoneyFile::notificationObjectT m_objType; - MyMoneyFile::notificationModeT m_notificationMode; + File::Object m_objType; + File::Mode m_notificationMode; QString m_id; }; @@ -408,7 +412,7 @@ // signals about addition, modification and removal of engine objects QList::const_iterator it = d->m_changeSet.constBegin(); while (it != d->m_changeSet.constEnd()) { - if ((*it).notificationMode() == notifyRemove) { + if ((*it).notificationMode() == File::Mode::Remove) { emit objectRemoved((*it).objectType(), (*it).id()); // if there is a balance change recorded for this account remove it since the account itself will be removed // this can happen when deleting categories that have transactions and the reassign category feature was used @@ -418,7 +422,7 @@ MyMoneyTransaction tr; switch((*it).objectType()) { - case MyMoneyFile::notifyTransaction: + case File::Object::Transaction: tr = transaction((*it).id()); obj = &tr; break; @@ -428,7 +432,7 @@ break; } if (obj) { - if ((*it).notificationMode() == notifyAdd) { + if ((*it).notificationMode() == File::Mode::Add) { emit objectAdded((*it).objectType(), obj); } else { @@ -503,7 +507,7 @@ // load new objects. So we simply force loading of the new one here d->m_cache.preloadInstitution(institution); - d->m_changeSet += MyMoneyNotification(notifyAdd, institution); + d->m_changeSet += MyMoneyNotification(File::Mode::Add, institution); } void MyMoneyFile::modifyInstitution(const MyMoneyInstitution& institution) @@ -516,7 +520,7 @@ d->m_storage->modifyInstitution(institution); d->addCacheNotification(institution.id()); - d->m_changeSet += MyMoneyNotification(notifyModify, institution); + d->m_changeSet += MyMoneyNotification(File::Mode::Modify, institution); } void MyMoneyFile::modifyTransaction(const MyMoneyTransaction& transaction) @@ -584,7 +588,7 @@ //FIXME-ALEX Do I need to add d->addCacheNotification((*it_s).tagList()); ?? } - d->m_changeSet += MyMoneyNotification(notifyModify, transaction); + d->m_changeSet += MyMoneyNotification(File::Mode::Modify, transaction); } void MyMoneyFile::modifyAccount(const MyMoneyAccount& _account) @@ -639,7 +643,7 @@ d->m_storage->modifyAccount(account); d->addCacheNotification(account.id()); - d->m_changeSet += MyMoneyNotification(notifyModify, account); + d->m_changeSet += MyMoneyNotification(File::Mode::Modify, account); } void MyMoneyFile::reparentAccount(MyMoneyAccount &acc, MyMoneyAccount& parent) @@ -651,13 +655,13 @@ throw MYMONEYEXCEPTION("Unable to reparent the standard account groups"); if (acc.accountGroup() == parent.accountGroup() - || (acc.accountType() == MyMoneyAccount::Income && parent.accountType() == MyMoneyAccount::Expense) - || (acc.accountType() == MyMoneyAccount::Expense && parent.accountType() == MyMoneyAccount::Income)) { + || (acc.accountType() == Account::Income && parent.accountType() == Account::Expense) + || (acc.accountType() == Account::Expense && parent.accountType() == Account::Income)) { - if (acc.isInvest() && parent.accountType() != MyMoneyAccount::Investment) + if (acc.isInvest() && parent.accountType() != Account::Investment) throw MYMONEYEXCEPTION("Unable to reparent Stock to non-investment account"); - if (parent.accountType() == MyMoneyAccount::Investment && !acc.isInvest()) + if (parent.accountType() == Account::Investment && !acc.isInvest()) throw MYMONEYEXCEPTION("Unable to reparent non-stock to investment account"); // clear all changed objects from cache @@ -674,9 +678,9 @@ d->addCacheNotification(acc.id()); d->addCacheNotification(parent.id()); - d->m_changeSet += MyMoneyNotification(notifyModify, curParent); - d->m_changeSet += MyMoneyNotification(notifyModify, parent); - d->m_changeSet += MyMoneyNotification(notifyModify, acc); + d->m_changeSet += MyMoneyNotification(File::Mode::Modify, curParent); + d->m_changeSet += MyMoneyNotification(File::Mode::Modify, parent); + d->m_changeSet += MyMoneyNotification(File::Mode::Modify, acc); } else throw MYMONEYEXCEPTION("Unable to reparent to different account type"); @@ -743,7 +747,7 @@ } } - d->m_changeSet += MyMoneyNotification(notifyRemove, transaction); + d->m_changeSet += MyMoneyNotification(File::Mode::Remove, transaction); } @@ -771,7 +775,7 @@ d->m_storage->setAccountName(id, name); d->addCacheNotification(id); - d->m_changeSet += MyMoneyNotification(notifyModify, acc); + d->m_changeSet += MyMoneyNotification(File::Mode::Modify, acc); } void MyMoneyFile::removeAccount(const MyMoneyAccount& account) @@ -804,7 +808,7 @@ foreach (const QString& id, acc.accountList()) { d->addCacheNotification(id); const MyMoneyAccount& acc = MyMoneyFile::account(id); - d->m_changeSet += MyMoneyNotification(notifyModify, acc); + d->m_changeSet += MyMoneyNotification(File::Mode::Modify, acc); } // don't forget the parent and a possible institution d->addCacheNotification(parent.id()); @@ -813,7 +817,7 @@ if (!institution.id().isEmpty()) { institution.removeAccountId(account.id()); d->m_storage->modifyInstitution(institution); - d->m_changeSet += MyMoneyNotification(notifyModify, institution); + d->m_changeSet += MyMoneyNotification(File::Mode::Modify, institution); } acc.setInstitutionId(QString()); @@ -823,8 +827,8 @@ d->m_cache.clear(acc.id()); d->m_balanceCache.clear(acc.id()); - d->m_changeSet += MyMoneyNotification(notifyModify, parent); - d->m_changeSet += MyMoneyNotification(notifyRemove, acc); + d->m_changeSet += MyMoneyNotification(File::Mode::Modify, parent); + d->m_changeSet += MyMoneyNotification(File::Mode::Remove, acc); } void MyMoneyFile::removeAccountList(const QStringList& account_list, unsigned int level) @@ -893,13 +897,13 @@ MyMoneyAccount acc = account(*it_a); acc.setInstitutionId(QString()); modifyAccount(acc); - d->m_changeSet += MyMoneyNotification(notifyModify, acc); + d->m_changeSet += MyMoneyNotification(File::Mode::Modify, acc); } blockSignals(blocked); d->m_storage->removeInstitution(institution); - d->m_changeSet += MyMoneyNotification(notifyRemove, institution); + d->m_changeSet += MyMoneyNotification(File::Mode::Remove, institution); d->addCacheNotification(institution.id(), false); } @@ -935,8 +939,8 @@ addAccount(newAccount, parentAccount); // in case of a loan account, we add the initial payment - if ((newAccount.accountType() == MyMoneyAccount::Loan - || newAccount.accountType() == MyMoneyAccount::AssetLoan) + if ((newAccount.accountType() == Account::Loan + || newAccount.accountType() == Account::AssetLoan) && !newAccount.value("kmm-loan-payment-acc").isEmpty() && !newAccount.value("kmm-loan-payment-date").isEmpty()) { MyMoneyAccountLoan acc(newAccount); @@ -945,7 +949,7 @@ a.setAccountId(acc.id()); b.setAccountId(acc.value("kmm-loan-payment-acc").toLatin1()); a.setValue(acc.loanAmount()); - if (acc.accountType() == MyMoneyAccount::Loan) + if (acc.accountType() == Account::Loan) a.setValue(-a.value()); a.setShares(a.value()); @@ -965,7 +969,7 @@ // in case of an investment account we check if we should create // a brokerage account - } else if (newAccount.accountType() == MyMoneyAccount::Investment + } else if (newAccount.accountType() == Account::Investment && !brokerageAccount.name().isEmpty()) { addAccount(brokerageAccount, parentAccount); @@ -1006,7 +1010,7 @@ if (!account.parentAccountId().isEmpty()) throw MYMONEYEXCEPTION("New account must have no parent-id"); - if (account.accountType() == MyMoneyAccount::UnknownAccountType) + if (account.accountType() == Account::Unknown) throw MYMONEYEXCEPTION("Account has invalid type"); // make sure, that the parent account exists @@ -1042,10 +1046,10 @@ if (parent.isInvest()) throw MYMONEYEXCEPTION("Stock account cannot be parent account"); - if (account.isInvest() && parent.accountType() != MyMoneyAccount::Investment) + if (account.isInvest() && parent.accountType() != Account::Investment) throw MYMONEYEXCEPTION("Stock account must have investment account as parent "); - if (!account.isInvest() && parent.accountType() == MyMoneyAccount::Investment) + if (!account.isInvest() && parent.accountType() == Account::Investment) throw MYMONEYEXCEPTION("Investment account can only have stock accounts as children"); // clear all changed objects from cache @@ -1078,15 +1082,15 @@ account.setParentAccountId(parent.id()); d->m_storage->addAccount(account); - d->m_changeSet += MyMoneyNotification(notifyAdd, account); + d->m_changeSet += MyMoneyNotification(File::Mode::Add, account); d->m_storage->addAccount(parent, account); - d->m_changeSet += MyMoneyNotification(notifyModify, parent); + d->m_changeSet += MyMoneyNotification(File::Mode::Modify, parent); if (account.institutionId().length() != 0) { institution.addAccountId(account.id()); d->m_storage->modifyInstitution(institution); - d->m_changeSet += MyMoneyNotification(notifyModify, institution); + d->m_changeSet += MyMoneyNotification(File::Mode::Modify, institution); d->addCacheNotification(institution.id()); } @@ -1263,7 +1267,7 @@ name += QString(" (%1)").arg(security.id()); } acc.setName(name); - acc.setAccountType(MyMoneyAccount::Equity); + acc.setAccountType(Account::Equity); acc.setCurrencyId(security.id()); acc.setValue("OpeningBalanceAccount", "Yes"); @@ -1341,7 +1345,7 @@ //FIXME-ALEX Do I need to add d->addCacheNotification((*it_s).tagList()); ?? } - d->m_changeSet += MyMoneyNotification(notifyAdd, transaction); + d->m_changeSet += MyMoneyNotification(File::Mode::Add, transaction); } const MyMoneyTransaction MyMoneyFile::transaction(const QString& id) const @@ -1371,7 +1375,7 @@ // load new objects. So we simply force loading of the new one here d->m_cache.preloadPayee(payee); - d->m_changeSet += MyMoneyNotification(notifyAdd, payee); + d->m_changeSet += MyMoneyNotification(File::Mode::Add, payee); } const MyMoneyPayee& MyMoneyFile::payee(const QString& id) const @@ -1397,7 +1401,7 @@ d->m_storage->modifyPayee(payee); - d->m_changeSet += MyMoneyNotification(notifyModify, payee); + d->m_changeSet += MyMoneyNotification(File::Mode::Modify, payee); } void MyMoneyFile::removePayee(const MyMoneyPayee& payee) @@ -1413,7 +1417,7 @@ d->addCacheNotification(payee.id(), false); - d->m_changeSet += MyMoneyNotification(notifyRemove, payee); + d->m_changeSet += MyMoneyNotification(File::Mode::Remove, payee); } void MyMoneyFile::addTag(MyMoneyTag& tag) @@ -1429,7 +1433,7 @@ // load new objects. So we simply force loading of the new one here d->m_cache.preloadTag(tag); - d->m_changeSet += MyMoneyNotification(notifyAdd, tag); + d->m_changeSet += MyMoneyNotification(File::Mode::Add, tag); } const MyMoneyTag& MyMoneyFile::tag(const QString& id) const @@ -1455,7 +1459,7 @@ d->m_storage->modifyTag(tag); - d->m_changeSet += MyMoneyNotification(notifyModify, tag); + d->m_changeSet += MyMoneyNotification(File::Mode::Modify, tag); } void MyMoneyFile::removeTag(const MyMoneyTag& tag) @@ -1471,7 +1475,7 @@ d->addCacheNotification(tag.id(), false); - d->m_changeSet += MyMoneyNotification(notifyRemove, tag); + d->m_changeSet += MyMoneyNotification(File::Mode::Remove, tag); } void MyMoneyFile::accountList(QList& list, const QStringList& idlist, const bool recursive) const @@ -1615,6 +1619,10 @@ return d->m_storage->transactionCount(account); } +unsigned int MyMoneyFile::transactionCount() const +{ + return transactionCount(QString()); +} const QMap MyMoneyFile::transactionCountMap() const { @@ -1648,6 +1656,10 @@ return returnValue; } +const MyMoneyMoney MyMoneyFile::balance(const QString& id) const +{ + return balance(id, QDate()); +} const MyMoneyMoney MyMoneyFile::clearedBalance(const QString &id, const QDate& date) const { @@ -1658,14 +1670,14 @@ MyMoneyAccount account = this->account(id); MyMoneyMoney factor(1, 1); - if (account.accountGroup() == MyMoneyAccount::Liability || account.accountGroup() == MyMoneyAccount::Equity) + if (account.accountGroup() == Account::Liability || account.accountGroup() == Account::Equity) factor = -factor; MyMoneyTransactionFilter filter; filter.addAccount(id); filter.setDateFilter(QDate(), date); filter.setReportAllSplits(false); - filter.addState(MyMoneyTransactionFilter::notReconciled); + filter.addState((int)TransactionFilter::State::NotReconciled); transactionList(list, filter); for (QList::const_iterator it_t = list.constBegin(); it_t != list.constEnd(); ++it_t) { @@ -1687,6 +1699,11 @@ return d->m_storage->totalBalance(id, date); } +const MyMoneyMoney MyMoneyFile::totalBalance(const QString& id) const +{ + return totalBalance(id, QDate()); +} + void MyMoneyFile::warningMissingRate(const QString& fromId, const QString& toId) const { MyMoneySecurity from, to; @@ -1750,19 +1767,19 @@ return rc; } -QString MyMoneyFile::categoryToAccount(const QString& category, MyMoneyAccount::accountTypeE type) const +QString MyMoneyFile::categoryToAccount(const QString& category, Account type) const { QString id; // search the category in the expense accounts and if it is not found, try // to locate it in the income accounts - if (type == MyMoneyAccount::UnknownAccountType - || type == MyMoneyAccount::Expense) { + if (type == Account::Unknown + || type == Account::Expense) { id = locateSubAccount(MyMoneyFile::instance()->expense(), category); } - if ((id.isEmpty() && type == MyMoneyAccount::UnknownAccountType) - || type == MyMoneyAccount::Income) { + if ((id.isEmpty() && type == Account::Unknown) + || type == Account::Income) { id = locateSubAccount(MyMoneyFile::instance()->income(), category); } @@ -1861,7 +1878,7 @@ // load new objects. So we simply force loading of the new one here d->m_cache.preloadSchedule(sched); - d->m_changeSet += MyMoneyNotification(notifyAdd, sched); + d->m_changeSet += MyMoneyNotification(File::Mode::Add, sched); } void MyMoneyFile::modifySchedule(const MyMoneySchedule& sched) @@ -1886,7 +1903,7 @@ d->m_storage->modifySchedule(sched); d->addCacheNotification(sched.id()); - d->m_changeSet += MyMoneyNotification(notifyModify, sched); + d->m_changeSet += MyMoneyNotification(File::Mode::Modify, sched); } void MyMoneyFile::removeSchedule(const MyMoneySchedule& sched) @@ -1899,7 +1916,7 @@ d->m_storage->removeSchedule(sched); d->addCacheNotification(sched.id(), false); - d->m_changeSet += MyMoneyNotification(notifyRemove, sched); + d->m_changeSet += MyMoneyNotification(File::Mode::Remove, sched); } const MyMoneySchedule MyMoneyFile::schedule(const QString& id) const @@ -1909,9 +1926,9 @@ const QList MyMoneyFile::scheduleList( const QString& accountId, - const MyMoneySchedule::typeE type, - const MyMoneySchedule::occurrenceE occurrence, - const MyMoneySchedule::paymentTypeE paymentType, + const Schedule::Type type, + const Schedule::Occurrence occurrence, + const Schedule::PaymentType paymentType, const QDate& startDate, const QDate& endDate, const bool overdue) const @@ -1921,6 +1938,18 @@ return d->m_storage->scheduleList(accountId, type, occurrence, paymentType, startDate, endDate, overdue); } +const QList MyMoneyFile::scheduleList( + const QString& accountId) const +{ + return scheduleList(accountId, Schedule::Type::Any, Schedule::Occurrence::Any, Schedule::PaymentType::Any, + QDate(), QDate(), false); +} + +const QList MyMoneyFile::scheduleList() const +{ + return scheduleList(QString(), Schedule::Type::Any, Schedule::Occurrence::Any, Schedule::PaymentType::Any, + QDate(), QDate(), false); +} const QStringList MyMoneyFile::consistencyCheck() { @@ -1967,19 +1996,19 @@ } switch ((*it_a).accountGroup()) { - case MyMoneyAccount::Asset: + case Account::Asset: toplevel = asset(); break; - case MyMoneyAccount::Liability: + case Account::Liability: toplevel = liability(); break; - case MyMoneyAccount::Expense: + case Account::Expense: toplevel = expense(); break; - case MyMoneyAccount::Income: + case Account::Income: toplevel = income(); break; - case MyMoneyAccount::Equity: + case Account::Equity: toplevel = equity(); break; default: @@ -2224,13 +2253,13 @@ interestAccounts[(*it_s).accountId()] = true; } } - QSet supportedAccountTypes; - supportedAccountTypes << MyMoneyAccount::Checkings - << MyMoneyAccount::Savings - << MyMoneyAccount::Cash - << MyMoneyAccount::CreditCard - << MyMoneyAccount::Asset - << MyMoneyAccount::Liability; + QSet supportedAccountTypes; + supportedAccountTypes << Account::Checkings + << Account::Savings + << Account::Cash + << Account::CreditCard + << Account::Asset + << Account::Liability; QSet reportedUnsupportedAccounts; for (it_t = tList.begin(); it_t != tList.end(); ++it_t) { @@ -2685,7 +2714,7 @@ } else { parent = account(newAccount.parentAccountId()); } - newAccount.setAccountType((!value.isNegative() && value2.isNegative()) ? MyMoneyAccount::Income : MyMoneyAccount::Expense); + newAccount.setAccountType((!value.isNegative() && value2.isNegative()) ? Account::Income : Account::Expense); MyMoneyAccount brokerage; // clear out the parent id, because createAccount() does not like that newAccount.setParentAccountId(QString()); @@ -2721,7 +2750,7 @@ // load new objects. So we simply force loading of the new one here d->m_cache.preloadSecurity(security); - d->m_changeSet += MyMoneyNotification(notifyAdd, security); + d->m_changeSet += MyMoneyNotification(File::Mode::Add, security); } void MyMoneyFile::modifySecurity(const MyMoneySecurity& security) @@ -2735,7 +2764,7 @@ d->addCacheNotification(security.id()); - d->m_changeSet += MyMoneyNotification(notifyModify, security); + d->m_changeSet += MyMoneyNotification(File::Mode::Modify, security); } void MyMoneyFile::removeSecurity(const MyMoneySecurity& security) @@ -2751,7 +2780,7 @@ d->addCacheNotification(security.id(), false); - d->m_changeSet += MyMoneyNotification(notifyRemove, security); + d->m_changeSet += MyMoneyNotification(File::Mode::Remove, security); } const MyMoneySecurity& MyMoneyFile::security(const QString& id) const @@ -2782,7 +2811,7 @@ // load new objects. So we simply force loading of the new one here d->m_cache.preloadSecurity(currency); - d->m_changeSet += MyMoneyNotification(notifyAdd, currency); + d->m_changeSet += MyMoneyNotification(File::Mode::Add, currency); } void MyMoneyFile::modifyCurrency(const MyMoneySecurity& currency) @@ -2800,7 +2829,7 @@ d->addCacheNotification(currency.id()); - d->m_changeSet += MyMoneyNotification(notifyModify, currency); + d->m_changeSet += MyMoneyNotification(File::Mode::Modify, currency); } void MyMoneyFile::removeCurrency(const MyMoneySecurity& currency) @@ -2820,7 +2849,7 @@ d->addCacheNotification(currency.id(), false); - d->m_changeSet += MyMoneyNotification(notifyRemove, currency); + d->m_changeSet += MyMoneyNotification(File::Mode::Remove, currency); } const MyMoneySecurity& MyMoneyFile::currency(const QString& id) const @@ -3177,6 +3206,16 @@ return rc; } +MyMoneyPrice MyMoneyFile::price(const QString& fromId, const QString& toId) const +{ + return price(fromId, toId, QDate::currentDate(), false); +} + +MyMoneyPrice MyMoneyFile::price(const QString& fromId) const +{ + return price(fromId, QString(), QDate::currentDate(), false); +} + const MyMoneyPriceList MyMoneyFile::priceList() const { d->checkStorage(); @@ -3322,14 +3361,14 @@ MyMoneyNotifier notifier(d); d->m_storage->addOnlineJob(job); d->m_cache.preloadOnlineJob(job); - d->m_changeSet += MyMoneyNotification(notifyAdd, job); + d->m_changeSet += MyMoneyNotification(File::Mode::Add, job); } void MyMoneyFile::modifyOnlineJob(const onlineJob job) { d->checkTransaction(Q_FUNC_INFO); d->m_storage->modifyOnlineJob(job); - d->m_changeSet += MyMoneyNotification(notifyModify, job); + d->m_changeSet += MyMoneyNotification(File::Mode::Modify, job); d->addCacheNotification(job.id()); } @@ -3365,7 +3404,7 @@ return; } d->addCacheNotification(job.id(), false); - d->m_changeSet += MyMoneyNotification(notifyRemove, job); + d->m_changeSet += MyMoneyNotification(File::Mode::Remove, job); d->m_storage->removeOnlineJob(job); } @@ -3616,11 +3655,11 @@ return balance == accBalance; } -int MyMoneyFile::countTransactionsWithSpecificReconciliationState(const QString& accId, enum MyMoneyTransactionFilter::stateOptionE state) const +int MyMoneyFile::countTransactionsWithSpecificReconciliationState(const QString& accId, TransactionFilter::State state) const { MyMoneyTransactionFilter filter; filter.addAccount(accId); - filter.addState(state); + filter.addState((int)state); return transactionList(filter).count(); } diff --git a/kmymoney/mymoney/mymoneyforecast.cpp b/kmymoney/mymoney/mymoneyforecast.cpp --- a/kmymoney/mymoney/mymoneyforecast.cpp +++ b/kmymoney/mymoney/mymoneyforecast.cpp @@ -31,6 +31,11 @@ // Project Includes #include "mymoneyfile.h" +#include "mymoneysecurity.h" +#include "mymoneybudget.h" +#include "mymoneyschedule.h" +#include "mymoneyprice.h" +#include "mymoneytransaction.h" #include "mymoneytransactionfilter.h" #include "mymoneyfinancialcalculator.h" @@ -125,7 +130,7 @@ //workaround for stock accounts which have faulty opening dates QDate openingDate; - if (acc.accountType() == MyMoneyAccount::Stock) { + if (acc.accountType() == eMyMoney::Account::Stock) { MyMoneyAccount parentAccount = file->account(acc.parentAccountId()); openingDate = parentAccount.openingDate(); } else { @@ -138,7 +143,7 @@ dailyBalances balance; //FIXME deal with leap years balance = m_accountListPast[acc.id()]; - if (acc.accountType() == MyMoneyAccount::Income) {//if it is income, the balance is stored as negative number + if (acc.accountType() == eMyMoney::Account::Income) {//if it is income, the balance is stored as negative number balance[(*it_t).postDate()] += ((*it_s).shares() * MyMoneyMoney::MINUS_ONE); } else { balance[(*it_t).postDate()] += (*it_s).shares(); @@ -214,7 +219,7 @@ if (skipOpeningDate()) { QDate openingDate; - if (acc.accountType() == MyMoneyAccount::Stock) { + if (acc.accountType() == eMyMoney::Account::Stock) { MyMoneyAccount parentAccount = file->account(acc.parentAccountId()); openingDate = parentAccount.openingDate(); } else { @@ -273,7 +278,7 @@ MyMoneyAccount acc = *accList_t; if (acc.isClosed() //check the account is not closed || (!acc.isAssetLiability())) { - //|| (acc.accountType() == MyMoneyAccount::Investment) ) {//check that it is not an Investment account and only include Stock accounts + //|| (acc.accountType() == eMyMoney::Account::Investment) ) {//check that it is not an Investment account and only include Stock accounts //remove the account if it is not of the correct type accList_t = accList.erase(accList_t); } else { @@ -325,8 +330,8 @@ } //get all transactions for the period filter.setDateFilter(startDate, QDate::currentDate()); - if (acc.accountGroup() == MyMoneyAccount::Income - || acc.accountGroup() == MyMoneyAccount::Expense) { + if (acc.accountGroup() == eMyMoney::Account::Income + || acc.accountGroup() == eMyMoney::Account::Expense) { filter.addCategory(acc.id()); } else { filter.addAccount(acc.id()); @@ -573,7 +578,7 @@ dailyBalances balance; balance = m_accountList[acc.id()]; //if it is income, the balance is stored as negative number - if (acc.accountType() == MyMoneyAccount::Income) { + if (acc.accountType() == eMyMoney::Account::Income) { balance[(*it_t).postDate()] += ((*it_s).shares() * MyMoneyMoney::MINUS_ONE); } else { balance[(*it_t).postDate()] += (*it_s).shares(); @@ -614,8 +619,8 @@ // now process all the schedules that may have an impact QList schedule; - schedule = file->scheduleList("", MyMoneySchedule::TYPE_ANY, MyMoneySchedule::OCCUR_ANY, MyMoneySchedule::STYPE_ANY, - QDate(), forecastEndDate()); + schedule = file->scheduleList(QString(), eMyMoney::Schedule::Type::Any, eMyMoney::Schedule::Occurrence::Any, eMyMoney::Schedule::PaymentType::Any, + QDate(), forecastEndDate(), false); if (schedule.count() > 0) { QList::Iterator it; do { @@ -650,7 +655,7 @@ if (!acc.id().isEmpty()) { try { - if (acc.accountType() != MyMoneyAccount::Investment) { + if (acc.accountType() != eMyMoney::Account::Investment) { MyMoneyTransaction t = (*it).transaction(); // only process the entry, if it is still active @@ -694,7 +699,7 @@ if (QDate::currentDate() >= nextDate) forecastDate = QDate::currentDate().addDays(1); - if (acc.accountType() == MyMoneyAccount::Income) { + if (acc.accountType() == eMyMoney::Account::Income) { balance[forecastDate] += ((*it_s).shares() * MyMoneyMoney::MINUS_ONE); } else { balance[forecastDate] += (*it_s).shares(); @@ -791,14 +796,14 @@ balance = m_accountList[acc.id()]; - if (acc.accountGroup() == MyMoneyAccount::Asset) { + if (acc.accountGroup() == eMyMoney::Account::Asset) { for (QDate it_day = QDate::currentDate() ; it_day <= forecastEndDate();) { if (balance[it_day] < MyMoneyMoney()) { return QDate::currentDate().daysTo(it_day); } it_day = it_day.addDays(1); } - } else if (acc.accountGroup() == MyMoneyAccount::Liability) { + } else if (acc.accountGroup() == eMyMoney::Account::Liability) { for (QDate it_day = QDate::currentDate() ; it_day <= forecastEndDate();) { if (balance[it_day] > MyMoneyMoney()) { return QDate::currentDate().daysTo(it_day); @@ -1153,7 +1158,7 @@ if (forecastMethod() == eHistoric && historyMethod() == 2) { //FIXME workaround for stock opening dates QDate openingDate; - if (acc.accountType() == MyMoneyAccount::Stock) { + if (acc.accountType() == eMyMoney::Account::Stock) { MyMoneyAccount parentAccount = file->account(acc.parentAccountId()); openingDate = parentAccount.openingDate(); } else { @@ -1196,7 +1201,7 @@ void MyMoneyForecast::calculateAutoLoan(const MyMoneySchedule& schedule, MyMoneyTransaction& transaction, const QMap& balances) { - if (schedule.type() == MyMoneySchedule::TYPE_LOANPAYMENT) { + if (schedule.type() == eMyMoney::Schedule::Type::LoanPayment) { //get amortization and interest autoCalc splits MyMoneySplit amortizationSplit = transaction.amortizationSplit(); @@ -1232,8 +1237,8 @@ calc.setDisc(); calc.setPF(MyMoneySchedule::eventsPerYear(schedule.occurrence())); - MyMoneySchedule::occurrenceE compoundingOccurrence = static_cast(acc.interestCompounding()); - if (compoundingOccurrence == MyMoneySchedule::OCCUR_ANY) + eMyMoney::Schedule::Occurrence compoundingOccurrence = static_cast(acc.interestCompounding()); + if (compoundingOccurrence == eMyMoney::Schedule::Occurrence::Any) compoundingOccurrence = schedule.occurrence(); calc.setCF(MyMoneySchedule::eventsPerYear(compoundingOccurrence)); @@ -1246,7 +1251,7 @@ interest = interest.abs(); // make sure it's positive for now amortization = acc.periodicPayment() - interest; - if (acc.accountType() == MyMoneyAccount::AssetLoan) { + if (acc.accountType() == eMyMoney::Account::AssetLoan) { interest = -interest; amortization = -amortization; } diff --git a/kmymoney/mymoney/mymoneyreport.h b/kmymoney/mymoney/mymoneyreport.h --- a/kmymoney/mymoney/mymoneyreport.h +++ b/kmymoney/mymoney/mymoneyreport.h @@ -530,7 +530,7 @@ * * @param type the account group to add to the allowed groups list */ - void addAccountGroup(MyMoneyAccount::accountTypeE type); + void addAccountGroup(eMyMoney::Account type); /** * This method returns whether an account group filter has been set, @@ -539,7 +539,7 @@ * @param list list to append account groups into * @return return true if an account group filter has been set */ - bool accountGroups(QList& list) const; + bool accountGroups(QList& list) const; /** * This method returns whether the specified account group @@ -548,7 +548,7 @@ * @param type group to append account groups into * @return return true if an account group filter has been set */ - bool includesAccountGroup(MyMoneyAccount::accountTypeE type) const; + bool includesAccountGroup(eMyMoney::Account type) const; /** * This method is used to test whether a specific account @@ -721,7 +721,7 @@ * is applied to the individual splits AFTER a transaction has been * matched using the underlying filter. */ - QList m_accountGroups; + QList m_accountGroups; /** * Whether an account group filter has been set (see m_accountGroups) */ diff --git a/kmymoney/mymoney/mymoneyreport.cpp b/kmymoney/mymoney/mymoneyreport.cpp --- a/kmymoney/mymoney/mymoneyreport.cpp +++ b/kmymoney/mymoney/mymoneyreport.cpp @@ -32,6 +32,7 @@ #include "mymoneyfile.h" #include "mymoneystoragenames.h" +#include "mymoneytransaction.h" using namespace MyMoneyStorageNodes; @@ -180,51 +181,51 @@ //add the corresponding account groups if (_rt == MyMoneyReport::eAssetLiability) { - addAccountGroup(MyMoneyAccount::Asset); - addAccountGroup(MyMoneyAccount::Liability); + addAccountGroup(eMyMoney::Account::Asset); + addAccountGroup(eMyMoney::Account::Liability); m_showRowTotals = true; } if (_rt == MyMoneyReport::eAccount) { - addAccountGroup(MyMoneyAccount::Asset); - addAccountGroup(MyMoneyAccount::AssetLoan); - addAccountGroup(MyMoneyAccount::Cash); - addAccountGroup(MyMoneyAccount::Checkings); - addAccountGroup(MyMoneyAccount::CreditCard); + addAccountGroup(eMyMoney::Account::Asset); + addAccountGroup(eMyMoney::Account::AssetLoan); + addAccountGroup(eMyMoney::Account::Cash); + addAccountGroup(eMyMoney::Account::Checkings); + addAccountGroup(eMyMoney::Account::CreditCard); if (KMyMoneyGlobalSettings::expertMode()) - addAccountGroup(MyMoneyAccount::Equity); - addAccountGroup(MyMoneyAccount::Expense); - addAccountGroup(MyMoneyAccount::Income); - addAccountGroup(MyMoneyAccount::Liability); - addAccountGroup(MyMoneyAccount::Loan); - addAccountGroup(MyMoneyAccount::Savings); - addAccountGroup(MyMoneyAccount::Stock); + addAccountGroup(eMyMoney::Account::Equity); + addAccountGroup(eMyMoney::Account::Expense); + addAccountGroup(eMyMoney::Account::Income); + addAccountGroup(eMyMoney::Account::Liability); + addAccountGroup(eMyMoney::Account::Loan); + addAccountGroup(eMyMoney::Account::Savings); + addAccountGroup(eMyMoney::Account::Stock); m_showRowTotals = true; } if (_rt == MyMoneyReport::eExpenseIncome) { - addAccountGroup(MyMoneyAccount::Expense); - addAccountGroup(MyMoneyAccount::Income); + addAccountGroup(eMyMoney::Account::Expense); + addAccountGroup(eMyMoney::Account::Income); m_showRowTotals = true; } //FIXME take this out once we have sorted out all issues regarding budget of assets and liabilities -- asoliverez@gmail.com if (_rt == MyMoneyReport::eBudget || _rt == MyMoneyReport::eBudgetActual) { - addAccountGroup(MyMoneyAccount::Expense); - addAccountGroup(MyMoneyAccount::Income); + addAccountGroup(eMyMoney::Account::Expense); + addAccountGroup(eMyMoney::Account::Income); } if (_rt == MyMoneyReport::eAccountInfo) { - addAccountGroup(MyMoneyAccount::Asset); - addAccountGroup(MyMoneyAccount::Liability); + addAccountGroup(eMyMoney::Account::Asset); + addAccountGroup(eMyMoney::Account::Liability); } //cash flow reports show splits for all account groups if (_rt == MyMoneyReport::eCashFlow) { - addAccountGroup(MyMoneyAccount::Expense); - addAccountGroup(MyMoneyAccount::Income); - addAccountGroup(MyMoneyAccount::Asset); - addAccountGroup(MyMoneyAccount::Liability); + addAccountGroup(eMyMoney::Account::Expense); + addAccountGroup(eMyMoney::Account::Income); + addAccountGroup(eMyMoney::Account::Asset); + addAccountGroup(eMyMoney::Account::Liability); } #ifdef DEBUG_REPORTS QDebug out = qDebug(); out << _name << toString(_rt) << toString(m_reportType); - foreach(const MyMoneyAccount::accountTypeE accountType, m_accountGroups) + foreach(const eMyMoney::Account accountType, m_accountGroups) out << MyMoneyAccount::accountTypeToString(accountType); if (m_accounts.size() > 0) out << m_accounts; @@ -302,22 +303,22 @@ m_accountGroups.clear(); if (_rt == MyMoneyReport::eAssetLiability) { - addAccountGroup(MyMoneyAccount::Asset); - addAccountGroup(MyMoneyAccount::Liability); + addAccountGroup(eMyMoney::Account::Asset); + addAccountGroup(eMyMoney::Account::Liability); } if (_rt == MyMoneyReport::eExpenseIncome) { - addAccountGroup(MyMoneyAccount::Expense); - addAccountGroup(MyMoneyAccount::Income); + addAccountGroup(eMyMoney::Account::Expense); + addAccountGroup(eMyMoney::Account::Income); } } -bool MyMoneyReport::accountGroups(QList& list) const +bool MyMoneyReport::accountGroups(QList& list) const { bool result = m_accountGroupFilter; if (result) { - QList::const_iterator it_group = m_accountGroups.begin(); + QList::const_iterator it_group = m_accountGroups.begin(); while (it_group != m_accountGroups.end()) { list += (*it_group); ++it_group; @@ -326,18 +327,18 @@ return result; } -void MyMoneyReport::addAccountGroup(MyMoneyAccount::accountTypeE type) +void MyMoneyReport::addAccountGroup(eMyMoney::Account type) { - if (!m_accountGroups.isEmpty() && type != MyMoneyAccount::UnknownAccountType) { + if (!m_accountGroups.isEmpty() && type != eMyMoney::Account::Unknown) { if (m_accountGroups.contains(type)) return; } m_accountGroupFilter = true; - if (type != MyMoneyAccount::UnknownAccountType) + if (type != eMyMoney::Account::Unknown) m_accountGroups.push_back(type); } -bool MyMoneyReport::includesAccountGroup(MyMoneyAccount::accountTypeE type) const +bool MyMoneyReport::includesAccountGroup(eMyMoney::Account type) const { bool result = (! m_accountGroupFilter) || (isIncludingTransfers() && m_rowType == MyMoneyReport::eExpenseIncome) @@ -352,15 +353,15 @@ if (includesAccountGroup(acc.accountGroup())) { switch (acc.accountGroup()) { - case MyMoneyAccount::Income: - case MyMoneyAccount::Expense: + case eMyMoney::Account::Income: + case eMyMoney::Account::Expense: if (isTax()) result = (acc.value("Tax") == "Yes") && includesCategory(acc.id()); else result = includesCategory(acc.id()); break; - case MyMoneyAccount::Asset: - case MyMoneyAccount::Liability: + case eMyMoney::Account::Asset: + case eMyMoney::Account::Liability: if (isLoansOnly()) result = acc.isLoan() && includesAccount(acc.id()); else if (isInvestmentsOnly()) @@ -372,7 +373,7 @@ else result = includesAccount(acc.id()); break; - case MyMoneyAccount::Equity: + case eMyMoney::Account::Equity: if (isInvestmentsOnly()) result = (isIncludingPrice() || isIncludingAveragePrice()) && acc.isInvest() && includesAccount(acc.id()); break; @@ -613,13 +614,13 @@ // Account Groups Filter // - QList accountgrouplist; + QList accountgrouplist; if (accountGroups(accountgrouplist)) { // iterate over accounts, and add each one - QList::const_iterator it_group = accountgrouplist.constBegin(); + QList::const_iterator it_group = accountgrouplist.constBegin(); while (it_group != accountgrouplist.constEnd()) { QDomElement p = doc->createElement(getElName(enAccountGroup)); - p.setAttribute(getAttrName(anGroup), kAccountTypeText[*it_group]); + p.setAttribute(getAttrName(anGroup), kAccountTypeText[(int)*it_group]); e.appendChild(p); ++it_group; @@ -883,7 +884,7 @@ if (getElName(enAccountGroup) == c.tagName() && c.hasAttribute(getAttrName(anGroup))) { i = kAccountTypeText.indexOf(c.attribute(getAttrName(anGroup))); if (i != -1) - addAccountGroup(static_cast(i)); + addAccountGroup(static_cast(i)); } child = child.nextSibling(); } diff --git a/kmymoney/mymoney/mymoneyschedule.h b/kmymoney/mymoney/mymoneyschedule.h --- a/kmymoney/mymoney/mymoneyschedule.h +++ b/kmymoney/mymoney/mymoneyschedule.h @@ -52,45 +52,6 @@ KMM_MYMONEY_UNIT_TESTABLE public: - /** - * This enum is used to describe all the possible schedule frequencies. - * The special entry, OCCUR_ANY, is used to combine all the other types. - */ - enum occurrenceE { OCCUR_ANY = 0, OCCUR_ONCE = 1, OCCUR_DAILY = 2, OCCUR_WEEKLY = 4, OCCUR_FORTNIGHTLY = 8, - OCCUR_EVERYOTHERWEEK = 16, - OCCUR_EVERYHALFMONTH = 18, - OCCUR_EVERYTHREEWEEKS = 20, - OCCUR_EVERYTHIRTYDAYS = 30, - OCCUR_MONTHLY = 32, OCCUR_EVERYFOURWEEKS = 64, - OCCUR_EVERYEIGHTWEEKS = 126, - OCCUR_EVERYOTHERMONTH = 128, OCCUR_EVERYTHREEMONTHS = 256, - OCCUR_TWICEYEARLY = 1024, OCCUR_EVERYOTHERYEAR = 2048, OCCUR_QUARTERLY = 4096, - OCCUR_EVERYFOURMONTHS = 8192, OCCUR_YEARLY = 16384 - }; - - /** - * This enum is used to describe the schedule type. - */ - enum typeE { TYPE_ANY = 0, TYPE_BILL = 1, TYPE_DEPOSIT = 2, TYPE_TRANSFER = 4, TYPE_LOANPAYMENT = 5 }; - - /** - * This enum is used to describe the schedule's payment type. - */ - enum paymentTypeE { STYPE_ANY = 0, STYPE_DIRECTDEBIT = 1, STYPE_DIRECTDEPOSIT = 2, - STYPE_MANUALDEPOSIT = 4, STYPE_OTHER = 8, - STYPE_WRITECHEQUE = 16, - STYPE_STANDINGORDER = 32, - STYPE_BANKTRANSFER = 64 - }; - - /** - * This enum is used by the auto-commit functionality. - * - * Depending upon the value of m_weekendOption the schedule can - * be entered on a different date - **/ - enum weekendOptionE { MoveBefore = 0, MoveAfter = 1, MoveNothing = 2 }; - enum elNameE { enPayment, enPayments }; Q_ENUM(elNameE) @@ -114,8 +75,8 @@ * * @a startDate is not used anymore and internally set to QDate() */ - MyMoneySchedule(const QString& name, typeE type, occurrenceE occurrence, int occurrenceMultiplier, - paymentTypeE paymentType, const QDate& startDate, const QDate& endDate, bool fixed, bool autoEnter); + MyMoneySchedule(const QString& name, eMyMoney::Schedule::Type type, eMyMoney::Schedule::Occurrence occurrence, int occurrenceMultiplier, + eMyMoney::Schedule::PaymentType paymentType, const QDate& startDate, const QDate& endDate, bool fixed, bool autoEnter); explicit MyMoneySchedule(const QDomElement& node); @@ -129,18 +90,18 @@ /** * Simple get method that returns the occurrence frequency. * - * @return occurrenceE The instance frequency. + * @return eMyMoney::Schedule::Occurrence The instance frequency. */ - occurrenceE occurrence() const; + eMyMoney::Schedule::Occurrence occurrence() const; /** * Simple get method that returns the occurrence period * multiplier and occurrence * - * @return occurrenceE The instance period + * @return eMyMoney::Schedule::Occurrence The instance period * */ - occurrenceE occurrencePeriod() const { + eMyMoney::Schedule::Occurrence occurrencePeriod() const { return m_occurrence; } @@ -156,9 +117,9 @@ /** * Simple get method that returns the schedule type. * - * @return typeE The instance type. + * @return eMyMoney::Schedule::Type The instance type. */ - typeE type() const { + eMyMoney::Schedule::Type type() const { return m_type; } @@ -175,9 +136,9 @@ /** * Simple get method that returns the schedule paymentType. * - * @return paymentTypeE The instance paymentType. + * @return eMyMoney::Schedule::PaymentType The instance paymentType. */ - paymentTypeE paymentType() const { + eMyMoney::Schedule::PaymentType paymentType() const { return m_paymentType; } @@ -284,7 +245,7 @@ * * @return QDate containing the adjusted date. */ - QDate adjustedDate(QDate date, weekendOptionE option) const; + QDate adjustedDate(QDate date, eMyMoney::Schedule::WeekendOption option) const; /** @@ -294,7 +255,7 @@ * * This not used by MyMoneySchedule but by the support code. **/ - weekendOptionE weekendOption() const { + eMyMoney::Schedule::WeekendOption weekendOption() const { return m_weekendOption; } @@ -304,7 +265,7 @@ * @param occ The new occurrence (frequency). * @return none */ - void setOccurrence(occurrenceE occ); + void setOccurrence(eMyMoney::Schedule::Occurrence occ); /** * Simple method that sets the schedule period @@ -312,7 +273,7 @@ * @param occ The new occurrence period (frequency) * @return none */ - void setOccurrencePeriod(occurrenceE occ); + void setOccurrencePeriod(eMyMoney::Schedule::Occurrence occ); /** * Simple method that sets the frequency multiplier for the schedule. @@ -328,7 +289,7 @@ * @param type The new type. * @return none */ - void setType(typeE type); + void setType(eMyMoney::Schedule::Type type); /** * Simple method that sets the start date for the schedule. @@ -344,7 +305,7 @@ * @param type The new payment type. * @return none */ - void setPaymentType(paymentTypeE type); + void setPaymentType(eMyMoney::Schedule::PaymentType type); /** * Simple method to set whether the schedule is fixed or not. @@ -419,7 +380,7 @@ * * @note This not used by MyMoneySchedule but by the support code. **/ - void setWeekendOption(const weekendOptionE option); + void setWeekendOption(const eMyMoney::Schedule::WeekendOption option); /** * Validates the schedule instance. @@ -567,7 +528,7 @@ * * @return QString representing the human readable format */ - static QString occurrenceToString(occurrenceE type); + static QString occurrenceToString(eMyMoney::Schedule::Occurrence type); /** * This method is used to convert a multiplier and base occurrence type @@ -580,7 +541,7 @@ * * @return QString representing the human readable format */ - static QString occurrenceToString(int mult, occurrenceE type); + static QString occurrenceToString(int mult, eMyMoney::Schedule::Occurrence type); /** * This method is used to convert an occurrence period from @@ -591,7 +552,7 @@ * * @return QString representing the human readable format */ - static QString occurrencePeriodToString(occurrenceE type); + static QString occurrencePeriodToString(eMyMoney::Schedule::Occurrence type); /** * This method is used to convert the payment type from its @@ -602,7 +563,7 @@ * * @return QString representing the human readable format */ - static QString paymentMethodToString(MyMoneySchedule::paymentTypeE paymentType); + static QString paymentMethodToString(eMyMoney::Schedule::PaymentType paymentType); /** * This method is used to convert the schedule weekend option from its @@ -613,7 +574,7 @@ * * @return QString representing the human readable format */ - static QString weekendOptionToString(MyMoneySchedule::weekendOptionE weekendOption); + static QString weekendOptionToString(eMyMoney::Schedule::WeekendOption weekendOption); /** * This method is used to convert the schedule type from its @@ -624,7 +585,7 @@ * * @return QString representing the human readable format */ - static QString scheduleTypeToString(MyMoneySchedule::typeE type); + static QString scheduleTypeToString(eMyMoney::Schedule::Type type); int variation() const; void setVariation(int var); @@ -639,7 +600,7 @@ * * @return int Number of days between events */ - static int eventsPerYear(MyMoneySchedule::occurrenceE occurrence); + static int eventsPerYear(eMyMoney::Schedule::Occurrence occurrence); /** * @@ -651,7 +612,7 @@ * * @return int Number of days between events */ - static int daysBetweenEvents(MyMoneySchedule::occurrenceE occurrence); + static int daysBetweenEvents(eMyMoney::Schedule::Occurrence occurrence); /** * Helper method to convert simple occurrence to compound occurrence + multiplier @@ -659,7 +620,7 @@ * @param multiplier Returned by reference. Adjusted multiplier * @param occurrence Returned by reference. Occurrence type */ - static void simpleToCompoundOccurrence(int& multiplier, occurrenceE& occurrence); + static void simpleToCompoundOccurrence(int& multiplier, eMyMoney::Schedule::Occurrence& occurrence); /** * Helper method to convert compound occurrence + multiplier to simple occurrence @@ -667,7 +628,7 @@ * @param multiplier Returned by reference. Adjusted multiplier * @param occurrence Returned by reference. Occurrence type */ - static void compoundToSimpleOccurrence(int& multiplier, occurrenceE& occurrence); + static void compoundToSimpleOccurrence(int& multiplier, eMyMoney::Schedule::Occurrence& occurrence); /** * This method is used to set the static point to relevant @@ -708,7 +669,7 @@ /** * This method adds a number of Half Months to the given Date. - * This is used for OCCUR_EVERYHALFMONTH occurrences. + * This is used for EveryHalfMonth occurrences. * The addition uses the following rules to add a half month: * Day 1-13: add 15 days * Day 14: add 15 days (except February: the last day of the month) @@ -744,19 +705,19 @@ private: /// Its occurrence - occurrenceE m_occurrence; + eMyMoney::Schedule::Occurrence m_occurrence; /// Its occurrence multiplier int m_occurrenceMultiplier; /// Its type - typeE m_type; + eMyMoney::Schedule::Type m_type; /// The date the schedule commences QDate m_startDate; /// The payment type - paymentTypeE m_paymentType; + eMyMoney::Schedule::PaymentType m_paymentType; /// Can the amount vary bool m_fixed; @@ -780,7 +741,7 @@ QList m_recordedPayments; /// The weekend option - weekendOptionE m_weekendOption; + eMyMoney::Schedule::WeekendOption m_weekendOption; }; /** diff --git a/kmymoney/mymoney/mymoneyschedule.cpp b/kmymoney/mymoney/mymoneyschedule.cpp --- a/kmymoney/mymoney/mymoneyschedule.cpp +++ b/kmymoney/mymoney/mymoneyschedule.cpp @@ -38,6 +38,7 @@ #include "mymoneystoragenames.h" using namespace MyMoneyStorageNodes; +using namespace eMyMoney; static IMyMoneyProcessingCalendar* processingCalendarPtr = 0; @@ -45,21 +46,21 @@ MyMoneyObject() { // Set up the default values - m_occurrence = OCCUR_ANY; + m_occurrence = Schedule::Occurrence::Any; m_occurrenceMultiplier = 1; - m_type = TYPE_ANY; - m_paymentType = STYPE_ANY; + m_type = Schedule::Type::Any; + m_paymentType = Schedule::PaymentType::Any; m_fixed = false; m_autoEnter = false; m_startDate = QDate(); m_endDate = QDate(); m_lastPayment = QDate(); - m_weekendOption = MoveNothing; + m_weekendOption = Schedule::WeekendOption::MoveNothing; } -MyMoneySchedule::MyMoneySchedule(const QString& name, typeE type, - occurrenceE occurrence, int occurrenceMultiplier, - paymentTypeE paymentType, +MyMoneySchedule::MyMoneySchedule(const QString& name, Schedule::Type type, + Schedule::Occurrence occurrence, int occurrenceMultiplier, + Schedule::PaymentType paymentType, const QDate& /* startDate */, const QDate& endDate, bool fixed, bool autoEnter) : @@ -77,7 +78,7 @@ m_startDate = QDate(); m_endDate = endDate; m_lastPayment = QDate(); - m_weekendOption = MoveNothing; + m_weekendOption = Schedule::WeekendOption::MoveNothing; } MyMoneySchedule::MyMoneySchedule(const QDomElement& node) : @@ -91,15 +92,15 @@ m_endDate = stringToDate(node.attribute(getAttrName(anEndDate))); m_lastPayment = stringToDate(node.attribute(getAttrName(anLastPayment))); - m_type = static_cast(node.attribute(getAttrName(anType)).toInt()); - m_paymentType = static_cast(node.attribute(getAttrName(anPaymentType)).toInt()); - m_occurrence = static_cast(node.attribute(getAttrName(anOccurence)).toInt()); // krazy:exclude=spelling + m_type = static_cast(node.attribute(getAttrName(anType)).toInt()); + m_paymentType = static_cast(node.attribute(getAttrName(anPaymentType)).toInt()); + m_occurrence = static_cast(node.attribute(getAttrName(anOccurence)).toInt()); // krazy:exclude=spelling m_occurrenceMultiplier = node.attribute(getAttrName(anOccurenceMultiplier), "1").toInt(); // krazy:exclude=spelling // Convert to compound occurrence simpleToCompoundOccurrence(m_occurrenceMultiplier, m_occurrence); m_autoEnter = static_cast(node.attribute(getAttrName(anAutoEnter)).toInt()); m_fixed = static_cast(node.attribute(getAttrName(anFixed)).toInt()); - m_weekendOption = static_cast(node.attribute(getAttrName(anWeekendOption)).toInt()); + m_weekendOption = static_cast(node.attribute(getAttrName(anWeekendOption)).toInt()); // read in the associated transaction QDomNodeList nodeList = node.elementsByTagName(nodeNames[nnTransaction]); @@ -154,9 +155,9 @@ setId(id); } -MyMoneySchedule::occurrenceE MyMoneySchedule::occurrence() const +Schedule::Occurrence MyMoneySchedule::occurrence() const { - MyMoneySchedule::occurrenceE occ = m_occurrence; + Schedule::Occurrence occ = m_occurrence; int mult = m_occurrenceMultiplier; compoundToSimpleOccurrence(mult, occ); return occ; @@ -167,7 +168,7 @@ m_startDate = date; } -void MyMoneySchedule::setPaymentType(paymentTypeE type) +void MyMoneySchedule::setPaymentType(Schedule::PaymentType type) { m_paymentType = type; } @@ -270,13 +271,13 @@ return adjustedDate(nextDueDate(), weekendOption()); } -QDate MyMoneySchedule::adjustedDate(QDate date, weekendOptionE option) const +QDate MyMoneySchedule::adjustedDate(QDate date, Schedule::WeekendOption option) const { - if (!date.isValid() || option == MyMoneySchedule::MoveNothing || isProcessingDate(date)) + if (!date.isValid() || option == Schedule::WeekendOption::MoveNothing || isProcessingDate(date)) return date; int step = 1; - if (option == MyMoneySchedule::MoveBefore) + if (option == Schedule::WeekendOption::MoveBefore) step = -1; while (!isProcessingDate(date)) @@ -318,16 +319,16 @@ m_name = nm; } -void MyMoneySchedule::setOccurrence(occurrenceE occ) +void MyMoneySchedule::setOccurrence(Schedule::Occurrence occ) { - MyMoneySchedule::occurrenceE occ2 = occ; + Schedule::Occurrence occ2 = occ; int mult = 1; simpleToCompoundOccurrence(mult, occ2); setOccurrencePeriod(occ2); setOccurrenceMultiplier(mult); } -void MyMoneySchedule::setOccurrencePeriod(occurrenceE occ) +void MyMoneySchedule::setOccurrencePeriod(Schedule::Occurrence occ) { m_occurrence = occ; } @@ -337,7 +338,7 @@ m_occurrenceMultiplier = occmultiplier < 1 ? 1 : occmultiplier; } -void MyMoneySchedule::setType(typeE type) +void MyMoneySchedule::setType(Schedule::Type type) { m_type = type; } @@ -358,16 +359,16 @@ if (id_check && !m_id.isEmpty()) throw MYMONEYEXCEPTION("ID for schedule not empty when required"); - if (m_occurrence == OCCUR_ANY) + if (m_occurrence == Schedule::Occurrence::Any) throw MYMONEYEXCEPTION("Invalid occurrence type for schedule"); - if (m_type == TYPE_ANY) + if (m_type == Schedule::Type::Any) throw MYMONEYEXCEPTION("Invalid type for schedule"); if (!nextDueDate().isValid()) throw MYMONEYEXCEPTION("Invalid next due date for schedule"); - if (m_paymentType == STYPE_ANY) + if (m_paymentType == Schedule::PaymentType::Any) throw MYMONEYEXCEPTION("Invalid payment type for schedule"); if (m_transaction.splitCount() == 0) @@ -375,26 +376,26 @@ // Check the payment types switch (m_type) { - case TYPE_BILL: - if (m_paymentType == STYPE_DIRECTDEPOSIT || m_paymentType == STYPE_MANUALDEPOSIT) + case Schedule::Type::Bill: + if (m_paymentType == Schedule::PaymentType::DirectDeposit || m_paymentType == Schedule::PaymentType::ManualDeposit) throw MYMONEYEXCEPTION("Invalid payment type for bills"); break; - case TYPE_DEPOSIT: - if (m_paymentType == STYPE_DIRECTDEBIT || m_paymentType == STYPE_WRITECHEQUE) + case Schedule::Type::Deposit: + if (m_paymentType == Schedule::PaymentType::DirectDebit || m_paymentType == Schedule::PaymentType::WriteChecque) throw MYMONEYEXCEPTION("Invalid payment type for deposits"); break; - case TYPE_ANY: + case Schedule::Type::Any: throw MYMONEYEXCEPTION("Invalid type ANY"); break; - case TYPE_TRANSFER: -// if (m_paymentType == STYPE_DIRECTDEPOSIT || m_paymentType == STYPE_MANUALDEPOSIT) + case Schedule::Type::Transfer: +// if (m_paymentType == DirectDeposit || m_paymentType == ManualDeposit) // return false; break; - case TYPE_LOANPAYMENT: + case Schedule::Type::LoanPayment: break; } } @@ -411,8 +412,8 @@ QDate MyMoneySchedule::nextPaymentDate(const bool& adjust, const QDate& refDate) const { - weekendOptionE option(adjust ? weekendOption() : - MyMoneySchedule::MoveNothing); + Schedule::WeekendOption option(adjust ? weekendOption() : + Schedule::WeekendOption::MoveNothing); QDate adjEndDate(adjustedDate(m_endDate, option)); @@ -428,14 +429,14 @@ if (paymentDate.isValid() && (paymentDate <= refDate || m_recordedPayments.contains(dueDate))) { switch (m_occurrence) { - case OCCUR_ONCE: + case Schedule::Occurrence::Once: // If the lastPayment is already set or the payment should have been // prior to the reference date then invalidate the payment date. if (m_lastPayment.isValid() || paymentDate <= refDate) paymentDate = QDate(); break; - case OCCUR_DAILY: { + case Schedule::Occurrence::Daily: { int step = m_occurrenceMultiplier; do { dueDate = dueDate.addDays(step); @@ -446,7 +447,7 @@ } break; - case OCCUR_WEEKLY: { + case Schedule::Occurrence::Weekly: { int step = 7 * m_occurrenceMultiplier; do { dueDate = dueDate.addDays(step); @@ -457,7 +458,7 @@ } break; - case OCCUR_EVERYHALFMONTH: + case Schedule::Occurrence::EveryHalfMonth: do { dueDate = addHalfMonths(dueDate, m_occurrenceMultiplier); paymentDate = adjustedDate(dueDate, option); @@ -466,7 +467,7 @@ m_recordedPayments.contains(dueDate))); break; - case OCCUR_MONTHLY: + case Schedule::Occurrence::Monthly: do { dueDate = dueDate.addMonths(m_occurrenceMultiplier); fixDate(dueDate); @@ -476,7 +477,7 @@ m_recordedPayments.contains(dueDate))); break; - case OCCUR_YEARLY: + case Schedule::Occurrence::Yearly: do { dueDate = dueDate.addYears(m_occurrenceMultiplier); fixDate(dueDate); @@ -486,7 +487,7 @@ m_recordedPayments.contains(dueDate))); break; - case OCCUR_ANY: + case Schedule::Occurrence::Any: default: paymentDate = QDate(); break; @@ -503,7 +504,7 @@ QDate paymentDate(nextDueDate()); QList theDates; - weekendOptionE option(weekendOption()); + Schedule::WeekendOption option(weekendOption()); QDate endDate(_endDate); if (willEnd() && m_endDate < endDate) { @@ -521,12 +522,12 @@ QDate date(adjustedDate(paymentDate, option)); switch (m_occurrence) { - case OCCUR_ONCE: + case Schedule::Occurrence::Once: if (start_date >= _startDate && start_date <= endDate) theDates.append(start_date); break; - case OCCUR_DAILY: + case Schedule::Occurrence::Daily: while (date.isValid() && (date <= endDate)) { if (date >= _startDate) theDates.append(date); @@ -535,7 +536,7 @@ } break; - case OCCUR_WEEKLY: { + case Schedule::Occurrence::Weekly: { int step = 7 * m_occurrenceMultiplier; while (date.isValid() && (date <= endDate)) { if (date >= _startDate) @@ -546,7 +547,7 @@ } break; - case OCCUR_EVERYHALFMONTH: + case Schedule::Occurrence::EveryHalfMonth: while (date.isValid() && (date <= endDate)) { if (date >= _startDate) theDates.append(date); @@ -555,7 +556,7 @@ } break; - case OCCUR_MONTHLY: + case Schedule::Occurrence::Monthly: while (date.isValid() && (date <= endDate)) { if (date >= _startDate) theDates.append(date); @@ -565,7 +566,7 @@ } break; - case OCCUR_YEARLY: + case Schedule::Occurrence::Yearly: while (date.isValid() && (date <= endDate)) { if (date >= _startDate) theDates.append(date); @@ -575,7 +576,7 @@ } break; - case OCCUR_ANY: + case Schedule::Occurrence::Any: default: break; } @@ -657,36 +658,36 @@ return paymentDate; switch (m_occurrence) { - case OCCUR_ONCE: + case Schedule::Occurrence::Once: break; - case OCCUR_DAILY: + case Schedule::Occurrence::Daily: while (counter++ < transactions) paymentDate = paymentDate.addDays(m_occurrenceMultiplier); break; - case OCCUR_WEEKLY: { + case Schedule::Occurrence::Weekly: { int step = 7 * m_occurrenceMultiplier; while (counter++ < transactions) paymentDate = paymentDate.addDays(step); } break; - case OCCUR_EVERYHALFMONTH: + case Schedule::Occurrence::EveryHalfMonth: paymentDate = addHalfMonths(paymentDate, m_occurrenceMultiplier * (transactions - 1)); break; - case OCCUR_MONTHLY: + case Schedule::Occurrence::Monthly: while (counter++ < transactions) paymentDate = paymentDate.addMonths(m_occurrenceMultiplier); break; - case OCCUR_YEARLY: + case Schedule::Occurrence::Yearly: while (counter++ < transactions) paymentDate = paymentDate.addYears(m_occurrenceMultiplier); break; - case OCCUR_ANY: + case Schedule::Occurrence::Any: default: break; } @@ -718,7 +719,7 @@ } // Check to see if its a once off payment - if (m_occurrence == MyMoneySchedule::OCCUR_ONCE) + if (m_occurrence == Schedule::Occurrence::Once) return true; return false; @@ -741,17 +742,17 @@ m_recordedPayments.append(date); } -void MyMoneySchedule::setWeekendOption(const weekendOptionE option) +void MyMoneySchedule::setWeekendOption(const Schedule::WeekendOption option) { // make sure only valid values are used. Invalid defaults to MoveNothing. switch (option) { - case MoveBefore: - case MoveAfter: + case Schedule::WeekendOption::MoveBefore: + case Schedule::WeekendOption::MoveAfter: m_weekendOption = option; break; default: - m_weekendOption = MoveNothing; + m_weekendOption = Schedule::WeekendOption::MoveNothing; break; } } @@ -773,16 +774,16 @@ writeBaseXML(document, el); el.setAttribute(getAttrName(anName), m_name); - el.setAttribute(getAttrName(anType), m_type); - el.setAttribute(getAttrName(anOccurence), m_occurrence); // krazy:exclude=spelling + el.setAttribute(getAttrName(anType), (int)m_type); + el.setAttribute(getAttrName(anOccurence), (int)m_occurrence); // krazy:exclude=spelling el.setAttribute(getAttrName(anOccurenceMultiplier), m_occurrenceMultiplier); - el.setAttribute(getAttrName(anPaymentType), m_paymentType); + el.setAttribute(getAttrName(anPaymentType), (int)m_paymentType); el.setAttribute(getAttrName(anStartDate), dateToString(m_startDate)); el.setAttribute(getAttrName(anEndDate), dateToString(m_endDate)); el.setAttribute(getAttrName(anFixed), m_fixed); el.setAttribute(getAttrName(anAutoEnter), m_autoEnter); el.setAttribute(getAttrName(anLastPayment), dateToString(m_lastPayment)); - el.setAttribute(getAttrName(anWeekendOption), m_weekendOption); + el.setAttribute(getAttrName(anWeekendOption), (int)m_weekendOption); //store the payment history for this scheduled task. QList payments = recordedPayments(); @@ -811,54 +812,54 @@ return occurrenceToString(occurrenceMultiplier(), occurrencePeriod()); } -QString MyMoneySchedule::occurrenceToString(occurrenceE occurrence) +QString MyMoneySchedule::occurrenceToString(Schedule::Occurrence occurrence) { QString occurrenceString = I18N_NOOP2("Frequency of schedule", "Any"); - if (occurrence == MyMoneySchedule::OCCUR_ONCE) + if (occurrence == Schedule::Occurrence::Once) occurrenceString = I18N_NOOP2("Frequency of schedule", "Once"); - else if (occurrence == MyMoneySchedule::OCCUR_DAILY) + else if (occurrence == Schedule::Occurrence::Daily) occurrenceString = I18N_NOOP2("Frequency of schedule", "Daily"); - else if (occurrence == MyMoneySchedule::OCCUR_WEEKLY) + else if (occurrence == Schedule::Occurrence::Weekly) occurrenceString = I18N_NOOP2("Frequency of schedule", "Weekly"); - else if (occurrence == MyMoneySchedule::OCCUR_FORTNIGHTLY) + else if (occurrence == Schedule::Occurrence::Fortnightly) occurrenceString = I18N_NOOP2("Frequency of schedule", "Fortnightly"); - else if (occurrence == MyMoneySchedule::OCCUR_EVERYOTHERWEEK) + else if (occurrence == Schedule::Occurrence::EveryOtherWeek) occurrenceString = I18N_NOOP2("Frequency of schedule", "Every other week"); - else if (occurrence == MyMoneySchedule::OCCUR_EVERYHALFMONTH) + else if (occurrence == Schedule::Occurrence::EveryHalfMonth) occurrenceString = I18N_NOOP2("Frequency of schedule", "Every half month"); - else if (occurrence == MyMoneySchedule::OCCUR_EVERYTHREEWEEKS) + else if (occurrence == Schedule::Occurrence::EveryThreeWeeks) occurrenceString = I18N_NOOP2("Frequency of schedule", "Every three weeks"); - else if (occurrence == MyMoneySchedule::OCCUR_EVERYFOURWEEKS) + else if (occurrence == Schedule::Occurrence::EveryFourWeeks) occurrenceString = I18N_NOOP2("Frequency of schedule", "Every four weeks"); - else if (occurrence == MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS) + else if (occurrence == Schedule::Occurrence::EveryThirtyDays) occurrenceString = I18N_NOOP2("Frequency of schedule", "Every thirty days"); - else if (occurrence == MyMoneySchedule::OCCUR_MONTHLY) + else if (occurrence == Schedule::Occurrence::Monthly) occurrenceString = I18N_NOOP2("Frequency of schedule", "Monthly"); - else if (occurrence == MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS) + else if (occurrence == Schedule::Occurrence::EveryEightWeeks) occurrenceString = I18N_NOOP2("Frequency of schedule", "Every eight weeks"); - else if (occurrence == MyMoneySchedule::OCCUR_EVERYOTHERMONTH) + else if (occurrence == Schedule::Occurrence::EveryOtherMonth) occurrenceString = I18N_NOOP2("Frequency of schedule", "Every two months"); - else if (occurrence == MyMoneySchedule::OCCUR_EVERYTHREEMONTHS) + else if (occurrence == Schedule::Occurrence::EveryThreeMonths) occurrenceString = I18N_NOOP2("Frequency of schedule", "Every three months"); - else if (occurrence == MyMoneySchedule::OCCUR_QUARTERLY) + else if (occurrence == Schedule::Occurrence::Quarterly) occurrenceString = I18N_NOOP2("Frequency of schedule", "Quarterly"); - else if (occurrence == MyMoneySchedule::OCCUR_EVERYFOURMONTHS) + else if (occurrence == Schedule::Occurrence::EveryFourMonths) occurrenceString = I18N_NOOP2("Frequency of schedule", "Every four months"); - else if (occurrence == MyMoneySchedule::OCCUR_TWICEYEARLY) + else if (occurrence == Schedule::Occurrence::TwiceYearly) occurrenceString = I18N_NOOP2("Frequency of schedule", "Twice yearly"); - else if (occurrence == MyMoneySchedule::OCCUR_YEARLY) + else if (occurrence == Schedule::Occurrence::Yearly) occurrenceString = I18N_NOOP2("Frequency of schedule", "Yearly"); - else if (occurrence == MyMoneySchedule::OCCUR_EVERYOTHERYEAR) + else if (occurrence == Schedule::Occurrence::EveryOtherYear) occurrenceString = I18N_NOOP2("Frequency of schedule", "Every other year"); return occurrenceString; } -QString MyMoneySchedule::occurrenceToString(int mult, occurrenceE type) +QString MyMoneySchedule::occurrenceToString(int mult, Schedule::Occurrence type) { QString occurrenceString = I18N_NOOP2("Frequency of schedule", "Any"); - if (type == MyMoneySchedule::OCCUR_ONCE) + if (type == Schedule::Occurrence::Once) switch (mult) { case 1: occurrenceString = I18N_NOOP2("Frequency of schedule", "Once"); @@ -866,7 +867,7 @@ default: occurrenceString = I18N_NOOP2("Frequency of schedule", QString("%1 times").arg(mult)); } - else if (type == MyMoneySchedule::OCCUR_DAILY) + else if (type == Schedule::Occurrence::Daily) switch (mult) { case 1: occurrenceString = I18N_NOOP2("Frequency of schedule", "Daily"); @@ -877,7 +878,7 @@ default: occurrenceString = I18N_NOOP2("Frequency of schedule", QString("Every %1 days").arg(mult)); } - else if (type == MyMoneySchedule::OCCUR_WEEKLY) + else if (type == Schedule::Occurrence::Weekly) switch (mult) { case 1: occurrenceString = I18N_NOOP2("Frequency of schedule", "Weekly"); @@ -897,7 +898,7 @@ default: occurrenceString = I18N_NOOP2("Frequency of schedule", QString("Every %1 weeks").arg(mult)); } - else if (type == MyMoneySchedule::OCCUR_EVERYHALFMONTH) + else if (type == Schedule::Occurrence::EveryHalfMonth) switch (mult) { case 1: occurrenceString = I18N_NOOP2("Frequency of schedule", "Every half month"); @@ -905,7 +906,7 @@ default: occurrenceString = I18N_NOOP2("Frequency of schedule", QString("Every %1 half months").arg(mult)); } - else if (type == MyMoneySchedule::OCCUR_MONTHLY) + else if (type == Schedule::Occurrence::Monthly) switch (mult) { case 1: occurrenceString = I18N_NOOP2("Frequency of schedule", "Monthly"); @@ -925,7 +926,7 @@ default: occurrenceString = I18N_NOOP2("Frequency of schedule", QString("Every %1 months").arg(mult)); } - else if (type == MyMoneySchedule::OCCUR_YEARLY) + else if (type == Schedule::Occurrence::Yearly) switch (mult) { case 1: occurrenceString = I18N_NOOP2("Frequency of schedule", "Yearly"); @@ -939,43 +940,43 @@ return occurrenceString; } -QString MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::occurrenceE type) +QString MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence type) { QString occurrenceString = I18N_NOOP2("Schedule occurrence period", "Any"); - if (type == MyMoneySchedule::OCCUR_ONCE) + if (type == Schedule::Occurrence::Once) occurrenceString = I18N_NOOP2("Schedule occurrence period", "Once"); - else if (type == MyMoneySchedule::OCCUR_DAILY) + else if (type == Schedule::Occurrence::Daily) occurrenceString = I18N_NOOP2("Schedule occurrence period", "Day"); - else if (type == MyMoneySchedule::OCCUR_WEEKLY) + else if (type == Schedule::Occurrence::Weekly) occurrenceString = I18N_NOOP2("Schedule occurrence period", "Week"); - else if (type == MyMoneySchedule::OCCUR_EVERYHALFMONTH) + else if (type == Schedule::Occurrence::EveryHalfMonth) occurrenceString = I18N_NOOP2("Schedule occurrence period", "Half-month"); - else if (type == MyMoneySchedule::OCCUR_MONTHLY) + else if (type == Schedule::Occurrence::Monthly) occurrenceString = I18N_NOOP2("Schedule occurrence period", "Month"); - else if (type == MyMoneySchedule::OCCUR_YEARLY) + else if (type == Schedule::Occurrence::Yearly) occurrenceString = I18N_NOOP2("Schedule occurrence period", "Year"); return occurrenceString; } -QString MyMoneySchedule::scheduleTypeToString(MyMoneySchedule::typeE type) +QString MyMoneySchedule::scheduleTypeToString(Schedule::Type type) { QString text; switch (type) { - case MyMoneySchedule::TYPE_BILL: + case Schedule::Type::Bill: text = I18N_NOOP2("Scheduled transaction type", "Bill"); break; - case MyMoneySchedule::TYPE_DEPOSIT: + case Schedule::Type::Deposit: text = I18N_NOOP2("Scheduled transaction type", "Deposit"); break; - case MyMoneySchedule::TYPE_TRANSFER: + case Schedule::Type::Transfer: text = I18N_NOOP2("Scheduled transaction type", "Transfer"); break; - case MyMoneySchedule::TYPE_LOANPAYMENT: + case Schedule::Type::LoanPayment: text = I18N_NOOP2("Scheduled transaction type", "Loan payment"); break; - case MyMoneySchedule::TYPE_ANY: + case Schedule::Type::Any: default: text = I18N_NOOP2("Scheduled transaction type", "Unknown"); } @@ -983,51 +984,51 @@ } -QString MyMoneySchedule::paymentMethodToString(MyMoneySchedule::paymentTypeE paymentType) +QString MyMoneySchedule::paymentMethodToString(Schedule::PaymentType paymentType) { QString text; switch (paymentType) { - case MyMoneySchedule::STYPE_DIRECTDEBIT: + case Schedule::PaymentType::DirectDebit: text = I18N_NOOP2("Scheduled Transaction payment type", "Direct debit"); break; - case MyMoneySchedule::STYPE_DIRECTDEPOSIT: + case Schedule::PaymentType::DirectDeposit: text = I18N_NOOP2("Scheduled Transaction payment type", "Direct deposit"); break; - case MyMoneySchedule::STYPE_MANUALDEPOSIT: + case Schedule::PaymentType::ManualDeposit: text = I18N_NOOP2("Scheduled Transaction payment type", "Manual deposit"); break; - case MyMoneySchedule::STYPE_OTHER: + case Schedule::PaymentType::Other: text = I18N_NOOP2("Scheduled Transaction payment type", "Other"); break; - case MyMoneySchedule::STYPE_WRITECHEQUE: + case Schedule::PaymentType::WriteChecque: text = I18N_NOOP2("Scheduled Transaction payment type", "Write check"); break; - case MyMoneySchedule::STYPE_STANDINGORDER: + case Schedule::PaymentType::StandingOrder: text = I18N_NOOP2("Scheduled Transaction payment type", "Standing order"); break; - case MyMoneySchedule::STYPE_BANKTRANSFER: + case Schedule::PaymentType::BankTransfer: text = I18N_NOOP2("Scheduled Transaction payment type", "Bank transfer"); break; - case MyMoneySchedule::STYPE_ANY: + case Schedule::PaymentType::Any: text = I18N_NOOP2("Scheduled Transaction payment type", "Any (Error)"); break; } return text; } -QString MyMoneySchedule::weekendOptionToString(MyMoneySchedule::weekendOptionE weekendOption) +QString MyMoneySchedule::weekendOptionToString(Schedule::WeekendOption weekendOption) { QString text; switch (weekendOption) { - case MyMoneySchedule::MoveBefore: + case Schedule::WeekendOption::MoveBefore: text = I18N_NOOP("Change the date to the previous processing day"); break; - case MyMoneySchedule::MoveAfter: + case Schedule::WeekendOption::MoveAfter: text = I18N_NOOP("Change the date to the next processing day"); break; - case MyMoneySchedule::MoveNothing: + case Schedule::WeekendOption::MoveNothing: text = I18N_NOOP("Do Nothing"); break; } @@ -1064,53 +1065,53 @@ #endif } -int MyMoneySchedule::eventsPerYear(MyMoneySchedule::occurrenceE occurrence) +int MyMoneySchedule::eventsPerYear(Schedule::Occurrence occurrence) { int rc = 0; switch (occurrence) { - case MyMoneySchedule::OCCUR_DAILY: + case Schedule::Occurrence::Daily: rc = 365; break; - case MyMoneySchedule::OCCUR_WEEKLY: + case Schedule::Occurrence::Weekly: rc = 52; break; - case MyMoneySchedule::OCCUR_FORTNIGHTLY: + case Schedule::Occurrence::Fortnightly: rc = 26; break; - case MyMoneySchedule::OCCUR_EVERYOTHERWEEK: + case Schedule::Occurrence::EveryOtherWeek: rc = 26; break; - case MyMoneySchedule::OCCUR_EVERYHALFMONTH: + case Schedule::Occurrence::EveryHalfMonth: rc = 24; break; - case MyMoneySchedule::OCCUR_EVERYTHREEWEEKS: + case Schedule::Occurrence::EveryThreeWeeks: rc = 17; break; - case MyMoneySchedule::OCCUR_EVERYFOURWEEKS: + case Schedule::Occurrence::EveryFourWeeks: rc = 13; break; - case MyMoneySchedule::OCCUR_MONTHLY: - case MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS: + case Schedule::Occurrence::Monthly: + case Schedule::Occurrence::EveryThirtyDays: rc = 12; break; - case MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS: + case Schedule::Occurrence::EveryEightWeeks: rc = 6; break; - case MyMoneySchedule::OCCUR_EVERYOTHERMONTH: + case Schedule::Occurrence::EveryOtherMonth: rc = 6; break; - case MyMoneySchedule::OCCUR_EVERYTHREEMONTHS: - case MyMoneySchedule::OCCUR_QUARTERLY: + case Schedule::Occurrence::EveryThreeMonths: + case Schedule::Occurrence::Quarterly: rc = 4; break; - case MyMoneySchedule::OCCUR_EVERYFOURMONTHS: + case Schedule::Occurrence::EveryFourMonths: rc = 3; break; - case MyMoneySchedule::OCCUR_TWICEYEARLY: + case Schedule::Occurrence::TwiceYearly: rc = 2; break; - case MyMoneySchedule::OCCUR_YEARLY: + case Schedule::Occurrence::Yearly: rc = 1; break; default: @@ -1120,55 +1121,55 @@ return rc; } -int MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::occurrenceE occurrence) +int MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence occurrence) { int rc = 0; switch (occurrence) { - case MyMoneySchedule::OCCUR_DAILY: + case Schedule::Occurrence::Daily: rc = 1; break; - case MyMoneySchedule::OCCUR_WEEKLY: + case Schedule::Occurrence::Weekly: rc = 7; break; - case MyMoneySchedule::OCCUR_FORTNIGHTLY: + case Schedule::Occurrence::Fortnightly: rc = 14; break; - case MyMoneySchedule::OCCUR_EVERYOTHERWEEK: + case Schedule::Occurrence::EveryOtherWeek: rc = 14; break; - case MyMoneySchedule::OCCUR_EVERYHALFMONTH: + case Schedule::Occurrence::EveryHalfMonth: rc = 15; break; - case MyMoneySchedule::OCCUR_EVERYTHREEWEEKS: + case Schedule::Occurrence::EveryThreeWeeks: rc = 21; break; - case MyMoneySchedule::OCCUR_EVERYFOURWEEKS: + case Schedule::Occurrence::EveryFourWeeks: rc = 28; break; - case MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS: + case Schedule::Occurrence::EveryThirtyDays: rc = 30; break; - case MyMoneySchedule::OCCUR_MONTHLY: + case Schedule::Occurrence::Monthly: rc = 30; break; - case MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS: + case Schedule::Occurrence::EveryEightWeeks: rc = 56; break; - case MyMoneySchedule::OCCUR_EVERYOTHERMONTH: + case Schedule::Occurrence::EveryOtherMonth: rc = 60; break; - case MyMoneySchedule::OCCUR_EVERYTHREEMONTHS: - case MyMoneySchedule::OCCUR_QUARTERLY: + case Schedule::Occurrence::EveryThreeMonths: + case Schedule::Occurrence::Quarterly: rc = 90; break; - case MyMoneySchedule::OCCUR_EVERYFOURMONTHS: + case Schedule::Occurrence::EveryFourMonths: rc = 120; break; - case MyMoneySchedule::OCCUR_TWICEYEARLY: + case Schedule::Occurrence::TwiceYearly: rc = 180; break; - case MyMoneySchedule::OCCUR_YEARLY: + case Schedule::Occurrence::Yearly: rc = 360; break; default: @@ -1232,50 +1233,50 @@ * @param multiplier Returned by reference. Adjusted multiplier * @param occurrence Returned by reference. Occurrence type */ -void MyMoneySchedule::simpleToCompoundOccurrence(int& multiplier, occurrenceE& occurrence) +void MyMoneySchedule::simpleToCompoundOccurrence(int& multiplier, Schedule::Occurrence& occurrence) { - occurrenceE newOcc = occurrence; + Schedule::Occurrence newOcc = occurrence; int newMulti = 1; - if (occurrence == MyMoneySchedule::OCCUR_ONCE || - occurrence == MyMoneySchedule::OCCUR_DAILY || - occurrence == MyMoneySchedule::OCCUR_WEEKLY || - occurrence == MyMoneySchedule::OCCUR_EVERYHALFMONTH || - occurrence == MyMoneySchedule::OCCUR_MONTHLY || - occurrence == MyMoneySchedule::OCCUR_YEARLY) { // Already a base occurrence and multiplier - } else if (occurrence == MyMoneySchedule::OCCUR_FORTNIGHTLY || - occurrence == MyMoneySchedule::OCCUR_EVERYOTHERWEEK) { - newOcc = MyMoneySchedule::OCCUR_WEEKLY; + if (occurrence == Schedule::Occurrence::Once || + occurrence == Schedule::Occurrence::Daily || + occurrence == Schedule::Occurrence::Weekly || + occurrence == Schedule::Occurrence::EveryHalfMonth || + occurrence == Schedule::Occurrence::Monthly || + occurrence == Schedule::Occurrence::Yearly) { // Already a base occurrence and multiplier + } else if (occurrence == Schedule::Occurrence::Fortnightly || + occurrence == Schedule::Occurrence::EveryOtherWeek) { + newOcc = Schedule::Occurrence::Weekly; newMulti = 2; - } else if (occurrence == MyMoneySchedule::OCCUR_EVERYTHREEWEEKS) { - newOcc = MyMoneySchedule::OCCUR_WEEKLY; + } else if (occurrence == Schedule::Occurrence::EveryThreeWeeks) { + newOcc = Schedule::Occurrence::Weekly; newMulti = 3; - } else if (occurrence == MyMoneySchedule::OCCUR_EVERYFOURWEEKS) { - newOcc = MyMoneySchedule::OCCUR_WEEKLY; + } else if (occurrence == Schedule::Occurrence::EveryFourWeeks) { + newOcc = Schedule::Occurrence::Weekly; newMulti = 4; - } else if (occurrence == MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS) { - newOcc = MyMoneySchedule::OCCUR_DAILY; + } else if (occurrence == Schedule::Occurrence::EveryThirtyDays) { + newOcc = Schedule::Occurrence::Daily; newMulti = 30; - } else if (occurrence == MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS) { - newOcc = MyMoneySchedule::OCCUR_WEEKLY; + } else if (occurrence == Schedule::Occurrence::EveryEightWeeks) { + newOcc = Schedule::Occurrence::Weekly; newMulti = 8; - } else if (occurrence == MyMoneySchedule::OCCUR_EVERYOTHERMONTH) { - newOcc = MyMoneySchedule::OCCUR_MONTHLY; + } else if (occurrence == Schedule::Occurrence::EveryOtherMonth) { + newOcc = Schedule::Occurrence::Monthly; newMulti = 2; - } else if (occurrence == MyMoneySchedule::OCCUR_EVERYTHREEMONTHS || - occurrence == MyMoneySchedule::OCCUR_QUARTERLY) { - newOcc = MyMoneySchedule::OCCUR_MONTHLY; + } else if (occurrence == Schedule::Occurrence::EveryThreeMonths || + occurrence == Schedule::Occurrence::Quarterly) { + newOcc = Schedule::Occurrence::Monthly; newMulti = 3; - } else if (occurrence == MyMoneySchedule::OCCUR_EVERYFOURMONTHS) { - newOcc = MyMoneySchedule::OCCUR_MONTHLY; + } else if (occurrence == Schedule::Occurrence::EveryFourMonths) { + newOcc = Schedule::Occurrence::Monthly; newMulti = 4; - } else if (occurrence == MyMoneySchedule::OCCUR_TWICEYEARLY) { - newOcc = MyMoneySchedule::OCCUR_MONTHLY; + } else if (occurrence == Schedule::Occurrence::TwiceYearly) { + newOcc = Schedule::Occurrence::Monthly; newMulti = 6; - } else if (occurrence == MyMoneySchedule::OCCUR_EVERYOTHERYEAR) { - newOcc = MyMoneySchedule::OCCUR_YEARLY; + } else if (occurrence == Schedule::Occurrence::EveryOtherYear) { + newOcc = Schedule::Occurrence::Yearly; newMulti = 2; } else { // Unknown - newOcc = MyMoneySchedule::OCCUR_ANY; + newOcc = Schedule::Occurrence::Any; newMulti = 1; } if (newOcc != occurrence) { @@ -1290,63 +1291,63 @@ * @param multiplier Returned by reference. Adjusted multiplier * @param occurrence Returned by reference. Occurrence type */ -void MyMoneySchedule::compoundToSimpleOccurrence(int& multiplier, occurrenceE& occurrence) +void MyMoneySchedule::compoundToSimpleOccurrence(int& multiplier, Schedule::Occurrence& occurrence) { - occurrenceE newOcc = occurrence; - if (occurrence == MyMoneySchedule::OCCUR_ONCE) { // Nothing to do - } else if (occurrence == MyMoneySchedule::OCCUR_DAILY) { + Schedule::Occurrence newOcc = occurrence; + if (occurrence == Schedule::Occurrence::Once) { // Nothing to do + } else if (occurrence == Schedule::Occurrence::Daily) { switch (multiplier) { case 1: break; case 30: - newOcc = MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS; + newOcc = Schedule::Occurrence::EveryThirtyDays; break; } - } else if (newOcc == MyMoneySchedule::OCCUR_WEEKLY) { + } else if (newOcc == Schedule::Occurrence::Weekly) { switch (multiplier) { case 1: break; case 2: - newOcc = MyMoneySchedule::OCCUR_EVERYOTHERWEEK; + newOcc = Schedule::Occurrence::EveryOtherWeek; break; case 3: - newOcc = MyMoneySchedule::OCCUR_EVERYTHREEWEEKS; + newOcc = Schedule::Occurrence::EveryThreeWeeks; break; case 4: - newOcc = MyMoneySchedule::OCCUR_EVERYFOURWEEKS; + newOcc = Schedule::Occurrence::EveryFourWeeks; break; case 8: - newOcc = MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS; + newOcc = Schedule::Occurrence::EveryEightWeeks; break; } - } else if (occurrence == MyMoneySchedule::OCCUR_MONTHLY) + } else if (occurrence == Schedule::Occurrence::Monthly) switch (multiplier) { case 1: break; case 2: - newOcc = MyMoneySchedule::OCCUR_EVERYOTHERMONTH; + newOcc = Schedule::Occurrence::EveryOtherMonth; break; case 3: - newOcc = MyMoneySchedule::OCCUR_EVERYTHREEMONTHS; + newOcc = Schedule::Occurrence::EveryThreeMonths; break; case 4: - newOcc = MyMoneySchedule::OCCUR_EVERYFOURMONTHS; + newOcc = Schedule::Occurrence::EveryFourMonths; break; case 6: - newOcc = MyMoneySchedule::OCCUR_TWICEYEARLY; + newOcc = Schedule::Occurrence::TwiceYearly; break; } - else if (occurrence == MyMoneySchedule::OCCUR_EVERYHALFMONTH) + else if (occurrence == Schedule::Occurrence::EveryHalfMonth) switch (multiplier) { case 1: break; } - else if (occurrence == MyMoneySchedule::OCCUR_YEARLY) { + else if (occurrence == Schedule::Occurrence::Yearly) { switch (multiplier) { case 1: break; case 2: - newOcc = MyMoneySchedule::OCCUR_EVERYOTHERYEAR; + newOcc = Schedule::Occurrence::EveryOtherYear; break; } } diff --git a/kmymoney/mymoney/mymoneytransactionfilter.h b/kmymoney/mymoney/mymoneytransactionfilter.h --- a/kmymoney/mymoney/mymoneytransactionfilter.h +++ b/kmymoney/mymoney/mymoneytransactionfilter.h @@ -63,18 +63,6 @@ // Make sure to keep the following enum valus in sync with the values // used by the GUI (for KMyMoney in kfindtransactiondlgdecl.ui) - enum stateOptionE { - allStates = 0, - notReconciled, - cleared, - reconciled, - frozen, - // insert new constants above of this line - stateOptionCount - }; - - // Make sure to keep the following enum valus in sync with the values - // used by the GUI (for KMyMoney in kfindtransactiondlgdecl.ui) enum validityOptionE { anyValidity = 0, valid, diff --git a/kmymoney/mymoney/mymoneytransactionfilter.cpp b/kmymoney/mymoney/mymoneytransactionfilter.cpp --- a/kmymoney/mymoney/mymoneytransactionfilter.cpp +++ b/kmymoney/mymoney/mymoneytransactionfilter.cpp @@ -32,6 +32,10 @@ // Project Includes #include "mymoneyfile.h" +#include "mymoneyaccount.h" +#include "mymoneypayee.h" +#include "mymoneytag.h" +#include "mymoneytransaction.h" MyMoneyTransactionFilter::MyMoneyTransactionFilter() { @@ -337,8 +341,8 @@ const MyMoneyAccount& acc = file->account(s->accountId()); if (m_considerCategory) { switch (acc.accountGroup()) { - case MyMoneyAccount::Income: - case MyMoneyAccount::Expense: + case eMyMoney::Account::Income: + case eMyMoney::Account::Expense: isTransfer = false; // check if the split references one of the categories in the list if (m_filterSet.singleFilter.categoryFilter) { @@ -420,8 +424,8 @@ // Determine if this account is a category or an account bool isCategory = false; switch (acc.accountGroup()) { - case MyMoneyAccount::Income: - case MyMoneyAccount::Expense: + case eMyMoney::Account::Income: + case eMyMoney::Account::Expense: isCategory = true; default: break; @@ -512,7 +516,7 @@ int MyMoneyTransactionFilter::splitState(const MyMoneySplit& split) const { - int rc = notReconciled; + int rc = (int)eMyMoney::TransactionFilter::State::NotReconciled; switch (split.reconcileFlag()) { default: @@ -520,15 +524,15 @@ break;; case MyMoneySplit::Cleared: - rc = cleared; + rc = (int)eMyMoney::TransactionFilter::State::Cleared; break; case MyMoneySplit::Reconciled: - rc = reconciled; + rc = (int)eMyMoney::TransactionFilter::State::Reconciled; break; case MyMoneySplit::Frozen: - rc = frozen; + rc = (int)eMyMoney::TransactionFilter::State::Frozen; break; } return rc; @@ -539,8 +543,8 @@ MyMoneyFile* file = MyMoneyFile::instance(); MyMoneyAccount a, b; a = file->account(split.accountId()); - if ((a.accountGroup() == MyMoneyAccount::Income - || a.accountGroup() == MyMoneyAccount::Expense)) + if ((a.accountGroup() == eMyMoney::Account::Income + || a.accountGroup() == eMyMoney::Account::Expense)) return allTypes; if (t.splitCount() == 2) { @@ -552,10 +556,10 @@ a = file->account(ida); b = file->account(idb); - if ((a.accountGroup() != MyMoneyAccount::Expense - && a.accountGroup() != MyMoneyAccount::Income) - && (b.accountGroup() != MyMoneyAccount::Expense - && b.accountGroup() != MyMoneyAccount::Income)) + if ((a.accountGroup() != eMyMoney::Account::Expense + && a.accountGroup() != eMyMoney::Account::Income) + && (b.accountGroup() != eMyMoney::Account::Expense + && b.accountGroup() != eMyMoney::Account::Income)) return transfers; } diff --git a/kmymoney/mymoney/mymoneyutils.cpp b/kmymoney/mymoney/mymoneyutils.cpp --- a/kmymoney/mymoney/mymoneyutils.cpp +++ b/kmymoney/mymoney/mymoneyutils.cpp @@ -26,6 +26,7 @@ #include "mymoneyaccount.h" #include "mymoneymoney.h" +#include "mymoneysecurity.h" #include #include diff --git a/kmymoney/mymoney/payeeidentifiermodel.cpp b/kmymoney/mymoney/payeeidentifiermodel.cpp --- a/kmymoney/mymoney/payeeidentifiermodel.cpp +++ b/kmymoney/mymoney/payeeidentifiermodel.cpp @@ -23,6 +23,7 @@ #include #include "mymoneyfile.h" +#include "mymoneyexception.h" /** * @brief create unique value for QModelIndex::internalId() to indicate "not set" diff --git a/kmymoney/mymoney/storage/imymoneyserialize.h b/kmymoney/mymoney/storage/imymoneyserialize.h --- a/kmymoney/mymoney/storage/imymoneyserialize.h +++ b/kmymoney/mymoney/storage/imymoneyserialize.h @@ -151,9 +151,9 @@ * default arguments. */ virtual const QList scheduleList(const QString& = QString(), - const MyMoneySchedule::typeE = MyMoneySchedule::TYPE_ANY, - const MyMoneySchedule::occurrenceE = MyMoneySchedule::OCCUR_ANY, - const MyMoneySchedule::paymentTypeE = MyMoneySchedule::STYPE_ANY, + const eMyMoney::Schedule::Type = eMyMoney::Schedule::Type::Any, + const eMyMoney::Schedule::Occurrence = eMyMoney::Schedule::Occurrence::Any, + const eMyMoney::Schedule::PaymentType = eMyMoney::Schedule::PaymentType::Any, const QDate& = QDate(), const QDate& = QDate(), const bool = false) const = 0; diff --git a/kmymoney/mymoney/storage/imymoneystorage.h b/kmymoney/mymoney/storage/imymoneystorage.h --- a/kmymoney/mymoney/storage/imymoneystorage.h +++ b/kmymoney/mymoney/storage/imymoneystorage.h @@ -660,15 +660,15 @@ * accound @p accountId. If accountId is the empty string, * this filter is off. Default is @p QString(). * @param type only schedules of type @p type are searched for. - * See MyMoneySchedule::typeE for details. - * Default is MyMoneySchedule::TYPE_ANY + * See eMyMoney::Schedule::Type for details. + * Default is eMyMoney::Schedule::Type::Any * @param occurrence only schedules of occurrence type @p occurrence are searched for. - * See MyMoneySchedule::occurrenceE for details. - * Default is MyMoneySchedule::OCCUR_ANY + * See eMyMoney::Schedule::Occurence for details. + * Default is eMyMoney::Schedule::Occurrence::Any * @param paymentType only schedules of payment method @p paymentType * are searched for. - * See MyMoneySchedule::paymentTypeE for details. - * Default is MyMoneySchedule::STYPE_ANY + * See eMyMoney::Schedule::PaymentType for details. + * Default is eMyMoney::Schedule::PaymentType::Any * @param startDate only schedules with payment dates after @p startDate * are searched for. Default is all dates (QDate()). * @param endDate only schedules with payment dates ending prior to @p endDate @@ -679,9 +679,9 @@ * @return const QList list of schedule objects. */ virtual const QList scheduleList(const QString& accountId = QString(), - const MyMoneySchedule::typeE type = MyMoneySchedule::TYPE_ANY, - const MyMoneySchedule::occurrenceE occurrence = MyMoneySchedule::OCCUR_ANY, - const MyMoneySchedule::paymentTypeE paymentType = MyMoneySchedule::STYPE_ANY, + const eMyMoney::Schedule::Type type = eMyMoney::Schedule::Type::Any, + const eMyMoney::Schedule::Occurrence occurrence = eMyMoney::Schedule::Occurrence::Any, + const eMyMoney::Schedule::PaymentType paymentType = eMyMoney::Schedule::PaymentType::Any, const QDate& startDate = QDate(), const QDate& endDate = QDate(), const bool overdue = false) const = 0; diff --git a/kmymoney/mymoney/storage/mymoneydatabasemgr.h b/kmymoney/mymoney/storage/mymoneydatabasemgr.h --- a/kmymoney/mymoney/storage/mymoneydatabasemgr.h +++ b/kmymoney/mymoney/storage/mymoneydatabasemgr.h @@ -665,15 +665,15 @@ * accound @p accountId. If accountId is the empty string, * this filter is off. Default is @p QString(). * @param type only schedules of type @p type are searched for. - * See MyMoneySchedule::typeE for details. - * Default is MyMoneySchedule::TYPE_ANY + * See eMyMoney::Schedule::Type for details. + * Default is eMyMoney::Schedule::Type::Any * @param occurrence only schedules of occurrence type @p occurrence are searched for. - * See MyMoneySchedule::occurrenceE for details. - * Default is MyMoneySchedule::OCCUR_ANY + * See eMyMoney::Schedule::Occurence for details. + * Default is eMyMoney::Schedule::Occurrence::Any * @param paymentType only schedules of payment method @p paymentType * are searched for. - * See MyMoneySchedule::paymentTypeE for details. - * Default is MyMoneySchedule::STYPE_ANY + * See eMyMoney::Schedule::PaymentType for details. + * Default is eMyMoney::Schedule::PaymentType::Any * @param startDate only schedules with payment dates after @p startDate * are searched for. Default is all dates (QDate()). * @param endDate only schedules with payment dates ending prior to @p endDate @@ -684,9 +684,9 @@ * @return const QList list of schedule objects. */ virtual const QList scheduleList(const QString& accountId = QString(), - const MyMoneySchedule::typeE type = MyMoneySchedule::TYPE_ANY, - const MyMoneySchedule::occurrenceE occurrence = MyMoneySchedule::OCCUR_ANY, - const MyMoneySchedule::paymentTypeE paymentType = MyMoneySchedule::STYPE_ANY, + const eMyMoney::Schedule::Type type = eMyMoney::Schedule::Type::Any, + const eMyMoney::Schedule::Occurrence occurrence = eMyMoney::Schedule::Occurrence::Any, + const eMyMoney::Schedule::PaymentType paymentType = eMyMoney::Schedule::PaymentType::Any, const QDate& startDate = QDate(), const QDate& endDate = QDate(), const bool overdue = false) const; diff --git a/kmymoney/mymoney/storage/mymoneydatabasemgr.cpp b/kmymoney/mymoney/storage/mymoneydatabasemgr.cpp --- a/kmymoney/mymoney/storage/mymoneydatabasemgr.cpp +++ b/kmymoney/mymoney/storage/mymoneydatabasemgr.cpp @@ -926,7 +926,7 @@ void MyMoneyDatabaseMgr::reparentAccount(MyMoneyAccount &account, MyMoneyAccount& parent) { - if (account.accountType() == MyMoneyAccount::Stock && parent.accountType() != MyMoneyAccount::Investment) + if (account.accountType() == eMyMoney::Account::Stock && parent.accountType() != eMyMoney::Account::Investment) throw MYMONEYEXCEPTION("Cannot move a stock acocunt into a non-investment account"); QStringList accountIdList; @@ -1219,7 +1219,7 @@ QMap accountList = m_sql->fetchAccounts(/*QString(id)*/); //QMap::const_iterator accpos = accountList.find(id); if (date_ != QDate()) qDebug("request balance for %s at %s", qPrintable(id), qPrintable(date_.toString(Qt::ISODate))); -// if(!date_.isValid() && MyMoneyFile::instance()->account(id).accountType() != MyMoneyAccount::Stock) { +// if(!date_.isValid() && MyMoneyFile::instance()->account(id).accountType() != eMyMoney::Account::Stock) { // if(accountList.find(id) != accountList.end()) // return accountList[id].balance(); // return MyMoneyMoney(0); @@ -1301,8 +1301,8 @@ MyMoneyAccount acc = m_sql->fetchAccounts(QStringList(account))[account]; MyMoneyTransactionFilter filter; - if (acc.accountGroup() == MyMoneyAccount::Income - || acc.accountGroup() == MyMoneyAccount::Expense) + if (acc.accountGroup() == eMyMoney::Account::Income + || acc.accountGroup() == eMyMoney::Account::Expense) filter.addCategory(account); else filter.addAccount(account); @@ -1524,9 +1524,9 @@ } const QList MyMoneyDatabaseMgr::scheduleList(const QString& accountId, - const MyMoneySchedule::typeE type, - const MyMoneySchedule::occurrenceE occurrence, - const MyMoneySchedule::paymentTypeE paymentType, + const eMyMoney::Schedule::Type type, + const eMyMoney::Schedule::Occurrence occurrence, + const eMyMoney::Schedule::PaymentType paymentType, const QDate& startDate, const QDate& endDate, const bool overdue) const @@ -1544,19 +1544,19 @@ for (pos = scheduleList.constBegin(); pos != scheduleList.constEnd(); ++pos) { // qDebug(" '%s'", (*pos).id().data()); - if (type != MyMoneySchedule::TYPE_ANY) { + if (type != eMyMoney::Schedule::Type::Any) { if (type != (*pos).type()) { continue; } } - if (occurrence != MyMoneySchedule::OCCUR_ANY) { + if (occurrence != eMyMoney::Schedule::Occurrence::Any) { if (occurrence != (*pos).occurrence()) { continue; } } - if (paymentType != MyMoneySchedule::STYPE_ANY) { + if (paymentType != eMyMoney::Schedule::PaymentType::Any) { if (paymentType != (*pos).paymentType()) { continue; } @@ -1627,13 +1627,13 @@ return list; for (pos = scheduleList.constBegin(); pos != scheduleList.constEnd(); ++pos) { - if (scheduleTypes && !(scheduleTypes & (*pos).type())) + if (scheduleTypes && !(scheduleTypes & (int)(*pos).type())) continue; - if (scheduleOcurrences && !(scheduleOcurrences & (*pos).occurrence())) + if (scheduleOcurrences && !(scheduleOcurrences & (int)(*pos).occurrence())) continue; - if (schedulePaymentTypes && !(schedulePaymentTypes & (*pos).paymentType())) + if (schedulePaymentTypes && !(schedulePaymentTypes & (int)(*pos).paymentType())) continue; if ((*pos).paymentDates(startDate, startDate).count() == 0) diff --git a/kmymoney/mymoney/storage/mymoneydbdef.cpp b/kmymoney/mymoney/storage/mymoneydbdef.cpp --- a/kmymoney/mymoney/storage/mymoneydbdef.cpp +++ b/kmymoney/mymoney/storage/mymoneydbdef.cpp @@ -540,7 +540,7 @@ toReplace.prepend(':'); QString replace = "NULL"; if ((*act)->name() == "accountType") - replace = QString::number(pac->accountType()); + replace = QString::number((int)pac->accountType()); if ((*act)->name() == "accountTypeString") replace = enclose(pac->name()); if ((*act)->name() == "isStockAccount") diff --git a/kmymoney/mymoney/storage/mymoneyseqaccessmgr.h b/kmymoney/mymoney/storage/mymoneyseqaccessmgr.h --- a/kmymoney/mymoney/storage/mymoneyseqaccessmgr.h +++ b/kmymoney/mymoney/storage/mymoneyseqaccessmgr.h @@ -870,15 +870,15 @@ * accound @p accountId. If accountId is the empty string, * this filter is off. Default is @p QString(). * @param type only schedules of type @p type are searched for. - * See MyMoneySchedule::typeE for details. - * Default is MyMoneySchedule::TYPE_ANY + * See eMyMoney::Schedule::Type for details. + * Default is eMyMoney::Schedule::Type::Any * @param occurrence only schedules of occurrence type @p occurrence are searched for. - * See MyMoneySchedule::occurrenceE for details. - * Default is MyMoneySchedule::OCCUR_ANY + * See eMyMoney::Schedule::Occurence for details. + * Default is eMyMoney::Schedule::Occurrence::Any * @param paymentType only schedules of payment method @p paymentType * are searched for. - * See MyMoneySchedule::paymentTypeE for details. - * Default is MyMoneySchedule::STYPE_ANY + * See eMyMoney::Schedule::PaymentType for details. + * Default is eMyMoney::Schedule::PaymentType::Any * @param startDate only schedules with payment dates after @p startDate * are searched for. Default is all dates (QDate()). * @param endDate only schedules with payment dates ending prior to @p endDate @@ -889,9 +889,9 @@ * @return const QList list of schedule objects. */ const QList scheduleList(const QString& accountId = QString(), - const MyMoneySchedule::typeE type = MyMoneySchedule::TYPE_ANY, - const MyMoneySchedule::occurrenceE occurrence = MyMoneySchedule::OCCUR_ANY, - const MyMoneySchedule::paymentTypeE paymentType = MyMoneySchedule::STYPE_ANY, + const eMyMoney::Schedule::Type type = eMyMoney::Schedule::Type::Any, + const eMyMoney::Schedule::Occurrence occurrence = eMyMoney::Schedule::Occurrence::Any, + const eMyMoney::Schedule::PaymentType paymentType = eMyMoney::Schedule::PaymentType::Any, const QDate& startDate = QDate(), const QDate& endDate = QDate(), const bool overdue = false) const; diff --git a/kmymoney/mymoney/storage/mymoneyseqaccessmgr.cpp b/kmymoney/mymoney/storage/mymoneyseqaccessmgr.cpp --- a/kmymoney/mymoney/storage/mymoneyseqaccessmgr.cpp +++ b/kmymoney/mymoney/storage/mymoneyseqaccessmgr.cpp @@ -63,27 +63,27 @@ // setup standard accounts MyMoneyAccount acc_l; - acc_l.setAccountType(MyMoneyAccount::Liability); + acc_l.setAccountType(eMyMoney::Account::Liability); acc_l.setName("Liability"); MyMoneyAccount liability(STD_ACC_LIABILITY, acc_l); MyMoneyAccount acc_a; - acc_a.setAccountType(MyMoneyAccount::Asset); + acc_a.setAccountType(eMyMoney::Account::Asset); acc_a.setName("Asset"); MyMoneyAccount asset(STD_ACC_ASSET, acc_a); MyMoneyAccount acc_e; - acc_e.setAccountType(MyMoneyAccount::Expense); + acc_e.setAccountType(eMyMoney::Account::Expense); acc_e.setName("Expense"); MyMoneyAccount expense(STD_ACC_EXPENSE, acc_e); MyMoneyAccount acc_i; - acc_i.setAccountType(MyMoneyAccount::Income); + acc_i.setAccountType(eMyMoney::Account::Income); acc_i.setName("Income"); MyMoneyAccount income(STD_ACC_INCOME, acc_i); MyMoneyAccount acc_q; - acc_q.setAccountType(MyMoneyAccount::Equity); + acc_q.setAccountType(eMyMoney::Account::Equity); acc_q.setName("Equity"); MyMoneyAccount equity(STD_ACC_EQUITY, acc_q); @@ -766,7 +766,7 @@ oldParent = m_accountList.find(account.parentAccountId()); } - if (account.accountType() == MyMoneyAccount::Stock && parent.accountType() != MyMoneyAccount::Investment) + if (account.accountType() == eMyMoney::Account::Stock && parent.accountType() != eMyMoney::Account::Investment) throw MYMONEYEXCEPTION("Cannot move a stock acocunt into a non-investment account"); newParent = m_accountList.find(parent.id()); @@ -789,7 +789,7 @@ #if 0 // make sure the type is the same as the new parent. This does not work for stock and investment - if (account.accountType() != MyMoneyAccount::Stock && account.accountType() != MyMoneyAccount::Investment) + if (account.accountType() != eMyMoney::Account::Stock && account.accountType() != eMyMoney::Account::Investment) (*childAccount).setAccountType((*newParent).accountType()); #endif } @@ -1029,8 +1029,8 @@ MyMoneyAccount acc = m_accountList[account]; MyMoneyTransactionFilter filter; - if (acc.accountGroup() == MyMoneyAccount::Income - || acc.accountGroup() == MyMoneyAccount::Expense) + if (acc.accountGroup() == eMyMoney::Account::Income + || acc.accountGroup() == eMyMoney::Account::Expense) filter.addCategory(account); else filter.addAccount(account); @@ -1400,9 +1400,9 @@ const QList MyMoneySeqAccessMgr::scheduleList( const QString& accountId, - const MyMoneySchedule::typeE type, - const MyMoneySchedule::occurrenceE occurrence, - const MyMoneySchedule::paymentTypeE paymentType, + const eMyMoney::Schedule::Type type, + const eMyMoney::Schedule::Occurrence occurrence, + const eMyMoney::Schedule::PaymentType paymentType, const QDate& startDate, const QDate& endDate, const bool overdue) const @@ -1415,19 +1415,19 @@ for (pos = m_scheduleList.begin(); pos != m_scheduleList.end(); ++pos) { // qDebug(" '%s'", qPrintable((*pos).id())); - if (type != MyMoneySchedule::TYPE_ANY) { + if (type != eMyMoney::Schedule::Type::Any) { if (type != (*pos).type()) { continue; } } - if (occurrence != MyMoneySchedule::OCCUR_ANY) { + if (occurrence != eMyMoney::Schedule::Occurrence::Any) { if (occurrence != (*pos).occurrence()) { continue; } } - if (paymentType != MyMoneySchedule::STYPE_ANY) { + if (paymentType != eMyMoney::Schedule::PaymentType::Any) { if (paymentType != (*pos).paymentType()) { continue; } @@ -1514,13 +1514,13 @@ return list; for (pos = m_scheduleList.begin(); pos != m_scheduleList.end(); ++pos) { - if (scheduleTypes && !(scheduleTypes & (*pos).type())) + if (scheduleTypes && !(scheduleTypes & (int)(*pos).type())) continue; - if (scheduleOcurrences && !(scheduleOcurrences & (*pos).occurrence())) + if (scheduleOcurrences && !(scheduleOcurrences & (int)(*pos).occurrence())) continue; - if (schedulePaymentTypes && !(schedulePaymentTypes & (*pos).paymentType())) + if (schedulePaymentTypes && !(schedulePaymentTypes & (int)(*pos).paymentType())) continue; if ((*pos).paymentDates(date, date).count() == 0) diff --git a/kmymoney/mymoney/storage/mymoneystoragedump.cpp b/kmymoney/mymoney/storage/mymoneystoragedump.cpp --- a/kmymoney/mymoney/storage/mymoneystoragedump.cpp +++ b/kmymoney/mymoney/storage/mymoneystoragedump.cpp @@ -94,8 +94,8 @@ int accountCount = 0; for (it_s = (*it_t).splits().constBegin(); it_s != (*it_t).splits().constEnd(); ++it_s) { MyMoneyAccount acc = storage->account((*it_s).accountId()); - if (acc.accountGroup() != MyMoneyAccount::Expense - && acc.accountGroup() != MyMoneyAccount::Income) + if (acc.accountGroup() != eMyMoney::Account::Expense + && acc.accountGroup() != eMyMoney::Account::Income) accountCount++; } if (accountCount > 1) @@ -172,7 +172,7 @@ s << " Name = " << (*it_a).name() << "\n"; s << " Number = " << (*it_a).number() << "\n"; s << " Description = " << (*it_a).description() << "\n"; - s << " Type = " << (*it_a).accountType() << "\n"; + s << " Type = " << (int)(*it_a).accountType() << "\n"; if ((*it_a).currencyId().isEmpty()) { s << " Currency = unknown\n"; } else { diff --git a/kmymoney/mymoney/storage/mymoneystoragesql.h b/kmymoney/mymoney/storage/mymoneystoragesql.h --- a/kmymoney/mymoney/storage/mymoneystoragesql.h +++ b/kmymoney/mymoney/storage/mymoneystoragesql.h @@ -441,7 +441,7 @@ //void startCommitUnit (const QString& callingFunction); //void endCommitUnit (const QString& callingFunction); //void cancelCommitUnit (const QString& callingFunction); - int splitState(const MyMoneyTransactionFilter::stateOptionE& state) const; + int splitState(const eMyMoney::TransactionFilter::State& state) const; inline const QDate getDate(const QString& date) const { return (date.isNull() ? QDate() : QDate::fromString(date, Qt::ISODate)); diff --git a/kmymoney/mymoney/storage/mymoneystoragesql.cpp b/kmymoney/mymoney/storage/mymoneystoragesql.cpp --- a/kmymoney/mymoney/storage/mymoneystoragesql.cpp +++ b/kmymoney/mymoney/storage/mymoneystoragesql.cpp @@ -63,6 +63,7 @@ #include "mymoneytransaction.h" #include "mymoneyutils.h" #include "payeeidentifier/payeeidentifierdata.h" +#include "mymoneyenums.h" using namespace eMyMoney; @@ -1483,27 +1484,27 @@ // If the above failed, assume that the database is empty and create // the standard accounts by hand before writing them. MyMoneyAccount acc_l; - acc_l.setAccountType(MyMoneyAccount::Liability); + acc_l.setAccountType(eMyMoney::Account::Liability); acc_l.setName("Liability"); MyMoneyAccount liability(STD_ACC_LIABILITY, acc_l); MyMoneyAccount acc_a; - acc_a.setAccountType(MyMoneyAccount::Asset); + acc_a.setAccountType(eMyMoney::Account::Asset); acc_a.setName("Asset"); MyMoneyAccount asset(STD_ACC_ASSET, acc_a); MyMoneyAccount acc_e; - acc_e.setAccountType(MyMoneyAccount::Expense); + acc_e.setAccountType(eMyMoney::Account::Expense); acc_e.setName("Expense"); MyMoneyAccount expense(STD_ACC_EXPENSE, acc_e); MyMoneyAccount acc_i; - acc_i.setAccountType(MyMoneyAccount::Income); + acc_i.setAccountType(eMyMoney::Account::Income); acc_i.setName("Income"); MyMoneyAccount income(STD_ACC_INCOME, acc_i); MyMoneyAccount acc_q; - acc_q.setAccountType(MyMoneyAccount::Equity); + acc_q.setAccountType(eMyMoney::Account::Equity); acc_q.setName("Equity"); MyMoneyAccount equity(STD_ACC_EQUITY, acc_q); @@ -1643,9 +1644,9 @@ else openingDateList << a.openingDate().toString(Qt::ISODate); accountNumberList << a.number(); - accountTypeList << a.accountType(); + accountTypeList << (int)a.accountType(); accountTypeStringList << MyMoneyAccount::accountTypeToString(a.accountType()); - if (a.accountType() == MyMoneyAccount::Stock) + if (a.accountType() == eMyMoney::Account::Stock) isStockAccountList << "Y"; else isStockAccountList << "N"; @@ -2134,12 +2135,12 @@ { q.bindValue(":id", sch.id()); q.bindValue(":name", sch.name()); - q.bindValue(":type", sch.type()); + q.bindValue(":type", (int)sch.type()); q.bindValue(":typeString", MyMoneySchedule::scheduleTypeToString(sch.type())); - q.bindValue(":occurence", sch.occurrencePeriod()); // krazy:exclude=spelling + q.bindValue(":occurence", (int)sch.occurrencePeriod()); // krazy:exclude=spelling q.bindValue(":occurenceMultiplier", sch.occurrenceMultiplier()); q.bindValue(":occurenceString", sch.occurrenceToString()); - q.bindValue(":paymentType", sch.paymentType()); + q.bindValue(":paymentType", (int)sch.paymentType()); q.bindValue(":paymentTypeString", MyMoneySchedule::paymentMethodToString(sch.paymentType())); q.bindValue(":startDate", sch.startDate().toString(Qt::ISODate)); q.bindValue(":endDate", sch.endDate().toString(Qt::ISODate)); @@ -2155,7 +2156,7 @@ } q.bindValue(":lastPayment", sch.lastPayment()); q.bindValue(":nextPaymentDue", sch.nextDueDate().toString(Qt::ISODate)); - q.bindValue(":weekendOption", sch.weekendOption()); + q.bindValue(":weekendOption", (int)sch.weekendOption()); q.bindValue(":weekendOptionString", MyMoneySchedule::weekendOptionToString(sch.weekendOption())); if (!q.exec()) throw MYMONEYEXCEPTION(buildError(q, Q_FUNC_INFO, QString("writing Schedules"))); // krazy:exclude=crashy @@ -3604,7 +3605,7 @@ acc.setLastModified(GETDATE(lastModifiedCol)); acc.setOpeningDate(GETDATE(openingDateCol)); acc.setNumber(GETSTRING(accountNumberCol)); - acc.setAccountType(static_cast(GETINT(accountTypeCol))); + acc.setAccountType(static_cast(GETINT(accountTypeCol))); acc.setName(GETSTRING(accountNameCol)); acc.setDescription(GETSTRING(descriptionCol)); acc.setCurrencyId(GETSTRING(currencyIdCol)); @@ -3848,24 +3849,24 @@ return txMap; } -int MyMoneyStorageSql::splitState(const MyMoneyTransactionFilter::stateOptionE& state) const +int MyMoneyStorageSql::splitState(const eMyMoney::TransactionFilter::State& state) const { int rc = MyMoneySplit::NotReconciled; switch (state) { default: - case MyMoneyTransactionFilter::notReconciled: + case eMyMoney::TransactionFilter::State::NotReconciled: break; - case MyMoneyTransactionFilter::cleared: + case eMyMoney::TransactionFilter::State::Cleared: rc = MyMoneySplit::Cleared; break; - case MyMoneyTransactionFilter::reconciled: + case eMyMoney::TransactionFilter::State::Reconciled: rc = MyMoneySplit::Reconciled; break; - case MyMoneyTransactionFilter::frozen: + case eMyMoney::TransactionFilter::State::Frozen: rc = MyMoneySplit::Frozen; break; } @@ -4002,7 +4003,7 @@ QString statesClause = ""; foreach (int it, splitStates) { statesClause.append(QString(" %1 '%2'").arg(itemConnector) - .arg(splitState(MyMoneyTransactionFilter::stateOptionE(it)))); + .arg(splitState(eMyMoney::TransactionFilter::State(it)))); itemConnector = ','; } if (!statesClause.isEmpty()) { @@ -4205,21 +4206,21 @@ QString sId = GETSTRING(idCol); s.setName(GETSTRING(nameCol)); - s.setType(static_cast(GETINT(typeCol))); - s.setOccurrencePeriod(static_cast(GETINT(occurenceCol))); + s.setType(static_cast(GETINT(typeCol))); + s.setOccurrencePeriod(static_cast(GETINT(occurenceCol))); s.setOccurrenceMultiplier(GETINT(occurenceMultiplierCol)); - s.setPaymentType(static_cast(GETINT(paymentTypeCol))); + s.setPaymentType(static_cast(GETINT(paymentTypeCol))); s.setStartDate(GETDATE(startDateCol)); s.setEndDate(GETDATE(endDateCol)); boolChar = GETSTRING(fixedCol); s.setFixed(boolChar == "Y"); boolChar = GETSTRING(autoEnterCol); s.setAutoEnter(boolChar == "Y"); s.setLastPayment(GETDATE(lastPaymentCol)); - s.setWeekendOption(static_cast(GETINT(weekendOptionCol))); + s.setWeekendOption(static_cast(GETINT(weekendOptionCol))); QDate nextPaymentDue = GETDATE(nextPaymentDueCol); // convert simple occurrence to compound occurrence int mult = s.occurrenceMultiplier(); - MyMoneySchedule::occurrenceE occ = s.occurrencePeriod(); + eMyMoney::Schedule::Occurrence occ = s.occurrencePeriod(); MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); s.setOccurrencePeriod(occ); s.setOccurrenceMultiplier(mult); diff --git a/kmymoney/mymoney/storage/tests/mymoneydatabasemgr-test.cpp b/kmymoney/mymoney/storage/tests/mymoneydatabasemgr-test.cpp --- a/kmymoney/mymoney/storage/tests/mymoneydatabasemgr-test.cpp +++ b/kmymoney/mymoney/storage/tests/mymoneydatabasemgr-test.cpp @@ -26,6 +26,10 @@ #include "onlinetasks/dummy/tasks/dummytask.h" +#include "mymoneyenums.h" + +using namespace eMyMoney; + QTEST_GUILESS_MAIN(MyMoneyDatabaseMgrTest) MyMoneyDatabaseMgrTest::MyMoneyDatabaseMgrTest() @@ -516,7 +520,7 @@ // use different account type MyMoneyAccount d; - d.setAccountType(MyMoneyAccount::CreditCard); + d.setAccountType(Account::CreditCard); MyMoneyAccount f("A000001", d); try { m->modifyAccount(f); @@ -569,17 +573,17 @@ // this one adds some accounts to the database MyMoneyAccount ex1; - ex1.setAccountType(MyMoneyAccount::Expense); + ex1.setAccountType(Account::Expense); MyMoneyAccount ex2; - ex2.setAccountType(MyMoneyAccount::Expense); + ex2.setAccountType(Account::Expense); MyMoneyAccount ex3; - ex3.setAccountType(MyMoneyAccount::Expense); + ex3.setAccountType(Account::Expense); MyMoneyAccount ex4; - ex4.setAccountType(MyMoneyAccount::Expense); + ex4.setAccountType(Account::Expense); MyMoneyAccount in; - in.setAccountType(MyMoneyAccount::Income); + in.setAccountType(Account::Income); MyMoneyAccount ch; - ch.setAccountType(MyMoneyAccount::Checkings); + ch.setAccountType(Account::Checkings); ex1.setName("Sales Tax"); ex2.setName("Sales Tax 16%"); @@ -1750,9 +1754,9 @@ s2.setAccountId("A000002"); t1.addSplit(s2); MyMoneySchedule schedule("Sched-Name", - MyMoneySchedule::TYPE_DEPOSIT, - MyMoneySchedule::OCCUR_DAILY, 1, - MyMoneySchedule::STYPE_MANUALDEPOSIT, + Schedule::Type::Deposit, + Schedule::Occurrence::Daily, 1, + Schedule::PaymentType::ManualDeposit, QDate(), QDate(), true, @@ -1772,9 +1776,9 @@ try { MyMoneySchedule schedule("Sched-Name", - MyMoneySchedule::TYPE_DEPOSIT, - MyMoneySchedule::OCCUR_DAILY, 1, - MyMoneySchedule::STYPE_MANUALDEPOSIT, + Schedule::Type::Deposit, + Schedule::Occurrence::Daily, 1, + Schedule::PaymentType::ManualDeposit, QDate(), QDate(), true, @@ -1795,9 +1799,9 @@ s2.setAccountId("Abadaccount2"); //t1.addSplit(s2); MyMoneySchedule schedule("Sched-Name", - MyMoneySchedule::TYPE_DEPOSIT, - MyMoneySchedule::OCCUR_DAILY, 1, - MyMoneySchedule::STYPE_MANUALDEPOSIT, + Schedule::Type::Deposit, + Schedule::Occurrence::Daily, 1, + Schedule::PaymentType::ManualDeposit, QDate(), QDate(), true, @@ -1916,9 +1920,9 @@ s2.setAccountId("A000002"); t1.addSplit(s2); MyMoneySchedule schedule1("Schedule 1", - MyMoneySchedule::TYPE_BILL, - MyMoneySchedule::OCCUR_ONCE, 1, - MyMoneySchedule::STYPE_DIRECTDEBIT, + Schedule::Type::Bill, + Schedule::Occurrence::Once, 1, + Schedule::PaymentType::DirectDebit, QDate(), QDate(), false, @@ -1934,9 +1938,9 @@ s4.setAccountId("A000003"); t2.addSplit(s4); MyMoneySchedule schedule2("Schedule 2", - MyMoneySchedule::TYPE_DEPOSIT, - MyMoneySchedule::OCCUR_DAILY, 1, - MyMoneySchedule::STYPE_DIRECTDEPOSIT, + Schedule::Type::Deposit, + Schedule::Occurrence::Daily, 1, + Schedule::PaymentType::DirectDeposit, QDate(), QDate(), false, @@ -1952,9 +1956,9 @@ s6.setAccountId("A000006"); t3.addSplit(s6); MyMoneySchedule schedule3("Schedule 3", - MyMoneySchedule::TYPE_TRANSFER, - MyMoneySchedule::OCCUR_WEEKLY, 1, - MyMoneySchedule::STYPE_OTHER, + Schedule::Type::Transfer, + Schedule::Occurrence::Weekly, 1, + Schedule::PaymentType::Other, QDate(), QDate(), false, @@ -1970,9 +1974,9 @@ s8.setAccountId("A000006"); t4.addSplit(s8); MyMoneySchedule schedule4("Schedule 4", - MyMoneySchedule::TYPE_BILL, - MyMoneySchedule::OCCUR_WEEKLY, 1, - MyMoneySchedule::STYPE_WRITECHEQUE, + Schedule::Type::Bill, + Schedule::Occurrence::Weekly, 1, + Schedule::PaymentType::WriteChecque, QDate(), notOverdue.addDays(31), false, @@ -1996,21 +2000,21 @@ QVERIFY(list.count() == 4); // filter by type - list = m->scheduleList("", MyMoneySchedule::TYPE_BILL); + list = m->scheduleList(QString(), Schedule::Type::Bill); QVERIFY(list.count() == 2); QVERIFY(list[0].name() == "Schedule 1"); QVERIFY(list[1].name() == "Schedule 4"); // filter by occurrence - list = m->scheduleList("", MyMoneySchedule::TYPE_ANY, - MyMoneySchedule::OCCUR_DAILY); + list = m->scheduleList(QString(), Schedule::Type::Any, + Schedule::Occurrence::Daily); QVERIFY(list.count() == 1); QVERIFY(list[0].name() == "Schedule 2"); // filter by payment type - list = m->scheduleList("", MyMoneySchedule::TYPE_ANY, - MyMoneySchedule::OCCUR_ANY, - MyMoneySchedule::STYPE_DIRECTDEPOSIT); + list = m->scheduleList(QString(), Schedule::Type::Any, + Schedule::Occurrence::Any, + Schedule::PaymentType::DirectDeposit); QVERIFY(list.count() == 1); QVERIFY(list[0].name() == "Schedule 2"); @@ -2023,40 +2027,44 @@ QVERIFY(list.count() == 1); // filter by start date - list = m->scheduleList("", MyMoneySchedule::TYPE_ANY, - MyMoneySchedule::OCCUR_ANY, - MyMoneySchedule::STYPE_ANY, - notOverdue.addDays(31)); + list = m->scheduleList(QString(), Schedule::Type::Any, + Schedule::Occurrence::Any, + Schedule::PaymentType::Any, + notOverdue.addDays(31), + QDate(), + false); QVERIFY(list.count() == 3); QVERIFY(list[0].name() == "Schedule 2"); QVERIFY(list[1].name() == "Schedule 3"); QVERIFY(list[2].name() == "Schedule 4"); // filter by end date - list = m->scheduleList("", MyMoneySchedule::TYPE_ANY, - MyMoneySchedule::OCCUR_ANY, - MyMoneySchedule::STYPE_ANY, + list = m->scheduleList(QString(), Schedule::Type::Any, + Schedule::Occurrence::Any, + Schedule::PaymentType::Any, QDate(), - notOverdue.addDays(1)); + notOverdue.addDays(1), + false); QVERIFY(list.count() == 3); QVERIFY(list[0].name() == "Schedule 1"); QVERIFY(list[1].name() == "Schedule 2"); QVERIFY(list[2].name() == "Schedule 4"); // filter by start and end date - list = m->scheduleList("", MyMoneySchedule::TYPE_ANY, - MyMoneySchedule::OCCUR_ANY, - MyMoneySchedule::STYPE_ANY, + list = m->scheduleList(QString(), Schedule::Type::Any, + Schedule::Occurrence::Any, + Schedule::PaymentType::Any, notOverdue.addDays(-1), - notOverdue.addDays(1)); + notOverdue.addDays(1), + false); QVERIFY(list.count() == 2); QVERIFY(list[0].name() == "Schedule 1"); QVERIFY(list[1].name() == "Schedule 2"); // filter by overdue status - list = m->scheduleList("", MyMoneySchedule::TYPE_ANY, - MyMoneySchedule::OCCUR_ANY, - MyMoneySchedule::STYPE_ANY, + list = m->scheduleList(QString(), Schedule::Type::Any, + Schedule::Occurrence::Any, + Schedule::PaymentType::Any, QDate(), QDate(), true); diff --git a/kmymoney/mymoney/storage/tests/mymoneyseqaccessmgr-test.cpp b/kmymoney/mymoney/storage/tests/mymoneyseqaccessmgr-test.cpp --- a/kmymoney/mymoney/storage/tests/mymoneyseqaccessmgr-test.cpp +++ b/kmymoney/mymoney/storage/tests/mymoneyseqaccessmgr-test.cpp @@ -24,6 +24,10 @@ #include "onlinetasks/dummy/tasks/dummytask.h" +#include "mymoneyenums.h" + +using namespace eMyMoney; + QTEST_GUILESS_MAIN(MyMoneySeqAccessMgrTest) void MyMoneySeqAccessMgrTest::init() @@ -380,7 +384,7 @@ // use different account type MyMoneyAccount d; - d.setAccountType(MyMoneyAccount::CreditCard); + d.setAccountType(Account::CreditCard); MyMoneyAccount f("A000001", d); try { m->modifyAccount(f); @@ -429,17 +433,17 @@ { // this one adds some accounts to the database MyMoneyAccount ex1; - ex1.setAccountType(MyMoneyAccount::Expense); + ex1.setAccountType(Account::Expense); MyMoneyAccount ex2; - ex2.setAccountType(MyMoneyAccount::Expense); + ex2.setAccountType(Account::Expense); MyMoneyAccount ex3; - ex3.setAccountType(MyMoneyAccount::Expense); + ex3.setAccountType(Account::Expense); MyMoneyAccount ex4; - ex4.setAccountType(MyMoneyAccount::Expense); + ex4.setAccountType(Account::Expense); MyMoneyAccount in; - in.setAccountType(MyMoneyAccount::Income); + in.setAccountType(Account::Income); MyMoneyAccount ch; - ch.setAccountType(MyMoneyAccount::Checkings); + ch.setAccountType(Account::Checkings); ex1.setName("Sales Tax"); ex2.setName("Sales Tax 16%"); @@ -1276,9 +1280,9 @@ s2.setAccountId("A000002"); t1.addSplit(s2); MyMoneySchedule schedule("Sched-Name", - MyMoneySchedule::TYPE_DEPOSIT, - MyMoneySchedule::OCCUR_DAILY, 1, - MyMoneySchedule::STYPE_MANUALDEPOSIT, + Schedule::Type::Deposit, + Schedule::Occurrence::Daily, 1, + Schedule::PaymentType::ManualDeposit, QDate(), QDate(), true, @@ -1297,9 +1301,9 @@ try { MyMoneySchedule schedule("Sched-Name", - MyMoneySchedule::TYPE_DEPOSIT, - MyMoneySchedule::OCCUR_DAILY, 1, - MyMoneySchedule::STYPE_MANUALDEPOSIT, + Schedule::Type::Deposit, + Schedule::Occurrence::Daily, 1, + Schedule::PaymentType::ManualDeposit, QDate(), QDate(), true, @@ -1397,9 +1401,9 @@ s2.setAccountId("A000002"); t1.addSplit(s2); MyMoneySchedule schedule1("Schedule 1", - MyMoneySchedule::TYPE_BILL, - MyMoneySchedule::OCCUR_ONCE, 1, - MyMoneySchedule::STYPE_DIRECTDEBIT, + Schedule::Type::Bill, + Schedule::Occurrence::Once, 1, + Schedule::PaymentType::DirectDebit, QDate(), QDate(), false, @@ -1415,9 +1419,9 @@ s4.setAccountId("A000003"); t2.addSplit(s4); MyMoneySchedule schedule2("Schedule 2", - MyMoneySchedule::TYPE_DEPOSIT, - MyMoneySchedule::OCCUR_DAILY, 1, - MyMoneySchedule::STYPE_DIRECTDEPOSIT, + Schedule::Type::Deposit, + Schedule::Occurrence::Daily, 1, + Schedule::PaymentType::DirectDeposit, QDate(), QDate(), false, @@ -1433,9 +1437,9 @@ s6.setAccountId("A000006"); t3.addSplit(s6); MyMoneySchedule schedule3("Schedule 3", - MyMoneySchedule::TYPE_TRANSFER, - MyMoneySchedule::OCCUR_WEEKLY, 1, - MyMoneySchedule::STYPE_OTHER, + Schedule::Type::Transfer, + Schedule::Occurrence::Weekly, 1, + Schedule::PaymentType::Other, QDate(), QDate(), false, @@ -1451,9 +1455,9 @@ s8.setAccountId("A000006"); t4.addSplit(s8); MyMoneySchedule schedule4("Schedule 4", - MyMoneySchedule::TYPE_BILL, - MyMoneySchedule::OCCUR_WEEKLY, 1, - MyMoneySchedule::STYPE_WRITECHEQUE, + Schedule::Type::Bill, + Schedule::Occurrence::Weekly, 1, + Schedule::PaymentType::WriteChecque, QDate(), notOverdue.addDays(31), false, @@ -1478,21 +1482,21 @@ QCOMPARE(list.count(), 4); // filter by type - list = m->scheduleList("", MyMoneySchedule::TYPE_BILL); + list = m->scheduleList("", Schedule::Type::Bill); QCOMPARE(list.count(), 2); QCOMPARE(list[0].name(), QLatin1String("Schedule 1")); QCOMPARE(list[1].name(), QLatin1String("Schedule 4")); // filter by occurrence - list = m->scheduleList("", MyMoneySchedule::TYPE_ANY, - MyMoneySchedule::OCCUR_DAILY); + list = m->scheduleList("", Schedule::Type::Any, + Schedule::Occurrence::Daily); QCOMPARE(list.count(), 1); QCOMPARE(list[0].name(), QLatin1String("Schedule 2")); // filter by payment type - list = m->scheduleList("", MyMoneySchedule::TYPE_ANY, - MyMoneySchedule::OCCUR_ANY, - MyMoneySchedule::STYPE_DIRECTDEPOSIT); + list = m->scheduleList("", Schedule::Type::Any, + Schedule::Occurrence::Any, + Schedule::PaymentType::DirectDeposit); QCOMPARE(list.count(), 1); QCOMPARE(list[0].name(), QLatin1String("Schedule 2")); @@ -1505,9 +1509,9 @@ QCOMPARE(list.count(), 1); // filter by start date - list = m->scheduleList("", MyMoneySchedule::TYPE_ANY, - MyMoneySchedule::OCCUR_ANY, - MyMoneySchedule::STYPE_ANY, + list = m->scheduleList("", Schedule::Type::Any, + Schedule::Occurrence::Any, + Schedule::PaymentType::Any, notOverdue.addDays(31)); QCOMPARE(list.count(), 3); QCOMPARE(list[0].name(), QLatin1String("Schedule 2")); @@ -1515,9 +1519,9 @@ QCOMPARE(list[2].name(), QLatin1String("Schedule 4")); // filter by end date - list = m->scheduleList("", MyMoneySchedule::TYPE_ANY, - MyMoneySchedule::OCCUR_ANY, - MyMoneySchedule::STYPE_ANY, + list = m->scheduleList("", Schedule::Type::Any, + Schedule::Occurrence::Any, + Schedule::PaymentType::Any, QDate(), notOverdue.addDays(1)); QCOMPARE(list.count(), 3); @@ -1526,9 +1530,9 @@ QCOMPARE(list[2].name(), QLatin1String("Schedule 4")); // filter by start and end date - list = m->scheduleList("", MyMoneySchedule::TYPE_ANY, - MyMoneySchedule::OCCUR_ANY, - MyMoneySchedule::STYPE_ANY, + list = m->scheduleList("", Schedule::Type::Any, + Schedule::Occurrence::Any, + Schedule::PaymentType::Any, notOverdue.addDays(-1), notOverdue.addDays(1)); QCOMPARE(list.count(), 2); @@ -1536,9 +1540,9 @@ QCOMPARE(list[1].name(), QLatin1String("Schedule 2")); // filter by overdue status - list = m->scheduleList("", MyMoneySchedule::TYPE_ANY, - MyMoneySchedule::OCCUR_ANY, - MyMoneySchedule::STYPE_ANY, + list = m->scheduleList("", Schedule::Type::Any, + Schedule::Occurrence::Any, + Schedule::PaymentType::Any, QDate(), QDate(), true); diff --git a/kmymoney/mymoney/tests/mymoneyaccount-test.cpp b/kmymoney/mymoney/tests/mymoneyaccount-test.cpp --- a/kmymoney/mymoney/tests/mymoneyaccount-test.cpp +++ b/kmymoney/mymoney/tests/mymoneyaccount-test.cpp @@ -40,7 +40,7 @@ QVERIFY(a.id().isEmpty()); QVERIFY(a.name().isEmpty()); - QVERIFY(a.accountType() == MyMoneyAccount::UnknownAccountType); + QVERIFY(a.accountType() == eMyMoney::Account::Unknown); QVERIFY(a.openingDate() == QDate()); QVERIFY(a.lastModified() == QDate()); QVERIFY(a.lastReconciliationDate() == QDate()); @@ -55,7 +55,7 @@ QString parent = "Parent"; MyMoneyAccount r; MyMoneySplit s; - r.setAccountType(MyMoneyAccount::Asset); + r.setAccountType(eMyMoney::Account::Asset); r.setOpeningDate(QDate::currentDate()); r.setLastModified(QDate::currentDate()); r.setDescription("Desc"); @@ -71,7 +71,7 @@ QVERIFY(a.id() == id); QVERIFY(a.institutionId().isEmpty()); - QVERIFY(a.accountType() == MyMoneyAccount::Asset); + QVERIFY(a.accountType() == eMyMoney::Account::Asset); QVERIFY(a.openingDate() == QDate::currentDate()); QVERIFY(a.lastModified() == QDate::currentDate()); QVERIFY(a.number() == "465500"); @@ -100,14 +100,14 @@ a.setLastModified(today); a.setDescription("Desc"); a.setNumber("123456"); - a.setAccountType(MyMoneyAccount::MoneyMarket); + a.setAccountType(eMyMoney::Account::MoneyMarket); QVERIFY(a.name() == "Account"); QVERIFY(a.institutionId() == "Institution1"); QVERIFY(a.lastModified() == today); QVERIFY(a.description() == "Desc"); QVERIFY(a.number() == "123456"); - QVERIFY(a.accountType() == MyMoneyAccount::MoneyMarket); + QVERIFY(a.accountType() == eMyMoney::Account::MoneyMarket); } void MyMoneyAccountTest::testCopyConstructor() @@ -116,7 +116,7 @@ QString institutionid = "B000001"; QString parent = "ParentAccount"; MyMoneyAccount r; - r.setAccountType(MyMoneyAccount::Expense); + r.setAccountType(eMyMoney::Account::Expense); r.setOpeningDate(QDate::currentDate()); r.setLastModified(QDate::currentDate()); r.setName("Account"); @@ -133,7 +133,7 @@ QVERIFY(b.name() == "Account"); QVERIFY(b.institutionId() == institutionid); - QVERIFY(b.accountType() == MyMoneyAccount::Expense); + QVERIFY(b.accountType() == eMyMoney::Account::Expense); QVERIFY(b.lastModified() == QDate::currentDate()); QVERIFY(b.openingDate() == QDate::currentDate()); QVERIFY(b.description() == "Desc1"); @@ -146,7 +146,7 @@ void MyMoneyAccountTest::testAssignmentConstructor() { MyMoneyAccount a; - a.setAccountType(MyMoneyAccount::Checkings); + a.setAccountType(eMyMoney::Account::Checkings); a.setName("Account"); a.setInstitutionId("Inst1"); a.setDescription("Bla"); @@ -162,7 +162,7 @@ QVERIFY(b.name() == "Account"); QVERIFY(b.institutionId() == "Inst1"); - QVERIFY(b.accountType() == MyMoneyAccount::Checkings); + QVERIFY(b.accountType() == eMyMoney::Account::Checkings); QVERIFY(b.lastModified() == QDate()); QVERIFY(b.openingDate() == a.openingDate()); QVERIFY(b.description() == "Bla"); @@ -195,7 +195,7 @@ void MyMoneyAccountTest::testSubAccounts() { MyMoneyAccount a; - a.setAccountType(MyMoneyAccount::Checkings); + a.setAccountType(eMyMoney::Account::Checkings); a.addAccountId("Subaccount1"); QVERIFY(a.accountList().count() == 1); @@ -217,7 +217,7 @@ a.setInstitutionId("I-ID"); a.setOpeningDate(QDate::currentDate()); a.setLastReconciliationDate(QDate::currentDate()); - a.setAccountType(MyMoneyAccount::Asset); + a.setAccountType(eMyMoney::Account::Asset); a.setParentAccountId("P-ID"); a.setId("A-ID"); a.setCurrencyId("C-ID"); @@ -256,7 +256,7 @@ QVERIFY(!(b == a)); b = a; - a.setAccountType(MyMoneyAccount::Liability); + a.setAccountType(eMyMoney::Account::Liability); QVERIFY(!(b == a)); b = a; @@ -289,7 +289,7 @@ QString parent = "Parent"; MyMoneyAccount r; - r.setAccountType(MyMoneyAccount::Asset); + r.setAccountType(eMyMoney::Account::Asset); r.setOpeningDate(QDate::currentDate()); r.setLastModified(QDate::currentDate()); r.setDescription("Desc"); @@ -427,7 +427,7 @@ QVERIFY(a.m_institution == "B000001"); QVERIFY(a.m_number == "465500"); QVERIFY(a.m_openingDate == QDate::currentDate()); - QVERIFY(a.m_accountType == MyMoneyAccount::Asset); + QVERIFY(a.m_accountType == eMyMoney::Account::Asset); QVERIFY(a.m_description == "Desc"); QVERIFY(a.accountList().count() == 2); QVERIFY(a.accountList()[0] == "A000002"); @@ -474,34 +474,34 @@ void MyMoneyAccountTest::specialAccountTypes_data() { - QTest::addColumn("accountType"); + QTest::addColumn("accountType"); QTest::addColumn("incomeExpense"); QTest::addColumn("assetLibility"); QTest::addColumn("loan"); // positive and null is debit - QTest::newRow("unknown") << MyMoneyAccount::UnknownAccountType << false << false << false; - QTest::newRow("checking") << MyMoneyAccount::Checkings << false << true << false; - QTest::newRow("savings") << MyMoneyAccount::Savings << false << true << false; - QTest::newRow("cash") << MyMoneyAccount::Cash << false << true << false; - QTest::newRow("investment") << MyMoneyAccount::Investment << false << true << false; - QTest::newRow("asset") << MyMoneyAccount::Asset << false << true << false; - QTest::newRow("currency") << MyMoneyAccount::Currency << false << true << false; - QTest::newRow("expense") << MyMoneyAccount::Expense << true << false << false; - QTest::newRow("moneymarket") << MyMoneyAccount::MoneyMarket << false << true << false; - QTest::newRow("certificatedeposit") << MyMoneyAccount::CertificateDep << false << true << false; - QTest::newRow("assetloan") << MyMoneyAccount::AssetLoan << false << true << true; - QTest::newRow("stock") << MyMoneyAccount::Stock << false << true << false; - QTest::newRow("creditcard") << MyMoneyAccount::CreditCard << false << true << false; - QTest::newRow("loan") << MyMoneyAccount::Loan << false << true << true; - QTest::newRow("liability") << MyMoneyAccount::Liability << false << true << false; - QTest::newRow("income") << MyMoneyAccount::Income << true << false << false; - QTest::newRow("equity") << MyMoneyAccount::Equity << false << false << false; + QTest::newRow("unknown") << eMyMoney::Account::Unknown << false << false << false; + QTest::newRow("checking") << eMyMoney::Account::Checkings << false << true << false; + QTest::newRow("savings") << eMyMoney::Account::Savings << false << true << false; + QTest::newRow("cash") << eMyMoney::Account::Cash << false << true << false; + QTest::newRow("investment") << eMyMoney::Account::Investment << false << true << false; + QTest::newRow("asset") << eMyMoney::Account::Asset << false << true << false; + QTest::newRow("currency") << eMyMoney::Account::Currency << false << true << false; + QTest::newRow("expense") << eMyMoney::Account::Expense << true << false << false; + QTest::newRow("moneymarket") << eMyMoney::Account::MoneyMarket << false << true << false; + QTest::newRow("certificatedeposit") << eMyMoney::Account::CertificateDep << false << true << false; + QTest::newRow("assetloan") << eMyMoney::Account::AssetLoan << false << true << true; + QTest::newRow("stock") << eMyMoney::Account::Stock << false << true << false; + QTest::newRow("creditcard") << eMyMoney::Account::CreditCard << false << true << false; + QTest::newRow("loan") << eMyMoney::Account::Loan << false << true << true; + QTest::newRow("liability") << eMyMoney::Account::Liability << false << true << false; + QTest::newRow("income") << eMyMoney::Account::Income << true << false << false; + QTest::newRow("equity") << eMyMoney::Account::Equity << false << false << false; } void MyMoneyAccountTest::specialAccountTypes() { - QFETCH(MyMoneyAccount::accountTypeE, accountType); + QFETCH(eMyMoney::Account, accountType); QFETCH(bool, incomeExpense); QFETCH(bool, assetLibility); QFETCH(bool, loan); diff --git a/kmymoney/mymoney/tests/mymoneyfile-test.h b/kmymoney/mymoney/tests/mymoneyfile-test.h --- a/kmymoney/mymoney/tests/mymoneyfile-test.h +++ b/kmymoney/mymoney/tests/mymoneyfile-test.h @@ -105,15 +105,15 @@ void testVatAssignment(); private slots: - void objectAdded(MyMoneyFile::notificationObjectT type, const MyMoneyObject * const obj); - void objectModified(MyMoneyFile::notificationObjectT type, const MyMoneyObject * const obj); - void objectRemoved(MyMoneyFile::notificationObjectT type, const QString& id); + void objectAdded(eMyMoney::File::Object type, const MyMoneyObject * const obj); + void objectModified(eMyMoney::File::Object type, const MyMoneyObject * const obj); + void objectRemoved(eMyMoney::File::Object type, const QString& id); void balanceChanged(const MyMoneyAccount& account); void valueChanged(const MyMoneyAccount& account); private: void testRemoveStdAccount(const MyMoneyAccount& acc); - void testReparentEquity(QList& list, MyMoneyAccount& parent); + void testReparentEquity(QList& list, MyMoneyAccount& parent); void clearObjectLists(); void AddOneAccount(); diff --git a/kmymoney/mymoney/tests/mymoneyfile-test.cpp b/kmymoney/mymoney/tests/mymoneyfile-test.cpp --- a/kmymoney/mymoney/tests/mymoneyfile-test.cpp +++ b/kmymoney/mymoney/tests/mymoneyfile-test.cpp @@ -32,19 +32,19 @@ QTEST_GUILESS_MAIN(MyMoneyFileTest) -void MyMoneyFileTest::objectAdded(MyMoneyFile::notificationObjectT type, const MyMoneyObject * const obj) +void MyMoneyFileTest::objectAdded(eMyMoney::File::Object type, const MyMoneyObject * const obj) { Q_UNUSED(type); m_objectsAdded += obj->id(); } -void MyMoneyFileTest::objectRemoved(MyMoneyFile::notificationObjectT type, const QString& id) +void MyMoneyFileTest::objectRemoved(eMyMoney::File::Object type, const QString& id) { Q_UNUSED(type); m_objectsRemoved += id; } -void MyMoneyFileTest::objectModified(MyMoneyFile::notificationObjectT type, const MyMoneyObject * const obj) +void MyMoneyFileTest::objectModified(eMyMoney::File::Object type, const MyMoneyObject * const obj) { Q_UNUSED(type); m_objectsModified += obj->id(); @@ -74,9 +74,9 @@ { m = MyMoneyFile::instance(); - connect(m, SIGNAL(objectAdded(MyMoneyFile::notificationObjectT,MyMoneyObject*const)), this, SLOT(objectAdded(MyMoneyFile::notificationObjectT,MyMoneyObject*const))); - connect(m, SIGNAL(objectRemoved(MyMoneyFile::notificationObjectT,QString)), this, SLOT(objectRemoved(MyMoneyFile::notificationObjectT,QString))); - connect(m, SIGNAL(objectModified(MyMoneyFile::notificationObjectT,MyMoneyObject*const)), this, SLOT(objectModified(MyMoneyFile::notificationObjectT,MyMoneyObject*const))); + connect(m, SIGNAL(objectAdded(eMyMoney::File::Object,MyMoneyObject*const)), this, SLOT(objectAdded(eMyMoney::File::Object,MyMoneyObject*const))); + connect(m, SIGNAL(objectRemoved(eMyMoney::File::Object,QString)), this, SLOT(objectRemoved(eMyMoney::File::Object,QString))); + connect(m, SIGNAL(objectModified(eMyMoney::File::Object,MyMoneyObject*const)), this, SLOT(objectModified(eMyMoney::File::Object,MyMoneyObject*const))); connect(m, SIGNAL(balanceChanged(MyMoneyAccount)), this, SLOT(balanceChanged(MyMoneyAccount))); connect(m, SIGNAL(valueChanged(MyMoneyAccount)), this, SLOT(valueChanged(MyMoneyAccount))); } @@ -453,8 +453,8 @@ { testAddTwoInstitutions(); MyMoneyAccount a, b, c; - a.setAccountType(MyMoneyAccount::Checkings); - b.setAccountType(MyMoneyAccount::Checkings); + a.setAccountType(eMyMoney::Account::Checkings); + b.setAccountType(eMyMoney::Account::Checkings); MyMoneyInstitution institution; @@ -521,7 +521,7 @@ // check if we can get the same info to a different object c = m->account("A000001"); - QCOMPARE(c.accountType(), MyMoneyAccount::Checkings); + QCOMPARE(c.accountType(), eMyMoney::Account::Checkings); QCOMPARE(c.id(), QLatin1String("A000001")); QCOMPARE(c.name(), QLatin1String("Account1")); QCOMPARE(c.institutionId(), QLatin1String("I000001")); @@ -573,7 +573,7 @@ MyMoneyAccount p; p = m->account("A000002"); - QCOMPARE(p.accountType(), MyMoneyAccount::Checkings); + QCOMPARE(p.accountType(), eMyMoney::Account::Checkings); QCOMPARE(p.id(), QLatin1String("A000002")); QCOMPARE(p.name(), QLatin1String("Account2")); QCOMPARE(p.institutionId(), QLatin1String("I000002")); @@ -583,9 +583,9 @@ void MyMoneyFileTest::testAddCategories() { MyMoneyAccount a, b, c; - a.setAccountType(MyMoneyAccount::Income); + a.setAccountType(eMyMoney::Account::Income); a.setOpeningDate(QDate::currentDate()); - b.setAccountType(MyMoneyAccount::Expense); + b.setAccountType(eMyMoney::Account::Expense); storage->m_dirty = false; @@ -659,7 +659,7 @@ MyMoneyAccount p = m->account("A000001"); MyMoneyInstitution institution; - QCOMPARE(p.accountType(), MyMoneyAccount::Checkings); + QCOMPARE(p.accountType(), eMyMoney::Account::Checkings); QCOMPARE(p.name(), QLatin1String("Account1")); p.setName("New account name"); @@ -671,7 +671,7 @@ QCOMPARE(m->dirty(), true); QCOMPARE(m->accountCount(), static_cast(7)); - QCOMPARE(p.accountType(), MyMoneyAccount::Checkings); + QCOMPARE(p.accountType(), eMyMoney::Account::Checkings); QCOMPARE(p.name(), QLatin1String("New account name")); QCOMPARE(m_objectsRemoved.count(), 0); @@ -696,7 +696,7 @@ QCOMPARE(m->dirty(), true); QCOMPARE(m->accountCount(), static_cast(7)); - QCOMPARE(p.accountType(), MyMoneyAccount::Checkings); + QCOMPARE(p.accountType(), eMyMoney::Account::Checkings); QCOMPARE(p.name(), QLatin1String("New account name")); QCOMPARE(p.institutionId(), QLatin1String("I000002")); @@ -723,7 +723,7 @@ storage->m_dirty = false; // try to change to an account type that is allowed - p.setAccountType(MyMoneyAccount::Savings); + p.setAccountType(eMyMoney::Account::Savings); ft.restart(); try { m->modifyAccount(p); @@ -731,7 +731,7 @@ QCOMPARE(m->dirty(), true); QCOMPARE(m->accountCount(), static_cast(7)); - QCOMPARE(p.accountType(), MyMoneyAccount::Savings); + QCOMPARE(p.accountType(), eMyMoney::Account::Savings); QCOMPARE(p.name(), QLatin1String("New account name")); } catch (const MyMoneyException &) { @@ -740,7 +740,7 @@ storage->m_dirty = false; // try to change to an account type that is not allowed - p.setAccountType(MyMoneyAccount::CreditCard); + p.setAccountType(eMyMoney::Account::CreditCard); ft.restart(); try { m->modifyAccount(p); @@ -936,8 +936,8 @@ QCOMPARE(m->dirty(), false); QCOMPARE(list.count(), 2); - QCOMPARE(list[0].accountType(), MyMoneyAccount::Checkings); - QCOMPARE(list[1].accountType(), MyMoneyAccount::Checkings); + QCOMPARE(list[0].accountType(), eMyMoney::Account::Checkings); + QCOMPARE(list[1].accountType(), eMyMoney::Account::Checkings); } void MyMoneyFileTest::testAddTransaction() @@ -946,10 +946,10 @@ MyMoneyTransaction t, p; MyMoneyAccount exp1; - exp1.setAccountType(MyMoneyAccount::Expense); + exp1.setAccountType(eMyMoney::Account::Expense); exp1.setName("Expense1"); MyMoneyAccount exp2; - exp2.setAccountType(MyMoneyAccount::Expense); + exp2.setAccountType(eMyMoney::Account::Expense); exp2.setName("Expense2"); MyMoneyFileTransaction ft; @@ -1668,7 +1668,7 @@ testAddAccounts(); MyMoneyAccount a, b; - a.setAccountType(MyMoneyAccount::Checkings); + a.setAccountType(eMyMoney::Account::Checkings); a.setName("Account3"); b = m->account("A000001"); MyMoneyFileTransaction ft; @@ -1689,7 +1689,7 @@ { MyMoneyAccount i; i.setName("Investment"); - i.setAccountType(MyMoneyAccount::Investment); + i.setAccountType(eMyMoney::Account::Investment); MyMoneyFileTransaction ft; try { @@ -1705,30 +1705,30 @@ // make sure, that only equity accounts can be children to it MyMoneyAccount a; a.setName("Testaccount"); - QList list; - list << MyMoneyAccount::Checkings; - list << MyMoneyAccount::Savings; - list << MyMoneyAccount::Cash; - list << MyMoneyAccount::CreditCard; - list << MyMoneyAccount::Loan; - list << MyMoneyAccount::CertificateDep; - list << MyMoneyAccount::Investment; - list << MyMoneyAccount::MoneyMarket; - list << MyMoneyAccount::Asset; - list << MyMoneyAccount::Liability; - list << MyMoneyAccount::Currency; - list << MyMoneyAccount::Income; - list << MyMoneyAccount::Expense; - list << MyMoneyAccount::AssetLoan; - - QList::Iterator it; + QList list; + list << eMyMoney::Account::Checkings; + list << eMyMoney::Account::Savings; + list << eMyMoney::Account::Cash; + list << eMyMoney::Account::CreditCard; + list << eMyMoney::Account::Loan; + list << eMyMoney::Account::CertificateDep; + list << eMyMoney::Account::Investment; + list << eMyMoney::Account::MoneyMarket; + list << eMyMoney::Account::Asset; + list << eMyMoney::Account::Liability; + list << eMyMoney::Account::Currency; + list << eMyMoney::Account::Income; + list << eMyMoney::Account::Expense; + list << eMyMoney::Account::AssetLoan; + + QList::Iterator it; for (it = list.begin(); it != list.end(); ++it) { a.setAccountType(*it); ft.restart(); try { char msg[100]; m->addAccount(a, i); - sprintf(msg, "Can add non-equity type %d to investment", *it); + sprintf(msg, "Can add non-equity type %d to investment", (int)*it); QFAIL(msg); } catch (const MyMoneyException &) { ft.commit(); @@ -1737,7 +1737,7 @@ ft.restart(); try { a.setName("Teststock"); - a.setAccountType(MyMoneyAccount::Stock); + a.setAccountType(eMyMoney::Account::Stock); m->addAccount(a, i); ft.commit(); } catch (const MyMoneyException &e) { @@ -1752,32 +1752,32 @@ MyMoneyAccount parent; // check the bad cases - QList list; - list << MyMoneyAccount::Checkings; - list << MyMoneyAccount::Savings; - list << MyMoneyAccount::Cash; - list << MyMoneyAccount::CertificateDep; - list << MyMoneyAccount::MoneyMarket; - list << MyMoneyAccount::Asset; - list << MyMoneyAccount::AssetLoan; - list << MyMoneyAccount::Currency; + QList list; + list << eMyMoney::Account::Checkings; + list << eMyMoney::Account::Savings; + list << eMyMoney::Account::Cash; + list << eMyMoney::Account::CertificateDep; + list << eMyMoney::Account::MoneyMarket; + list << eMyMoney::Account::Asset; + list << eMyMoney::Account::AssetLoan; + list << eMyMoney::Account::Currency; parent = m->asset(); testReparentEquity(list, parent); list.clear(); - list << MyMoneyAccount::CreditCard; - list << MyMoneyAccount::Loan; - list << MyMoneyAccount::Liability; + list << eMyMoney::Account::CreditCard; + list << eMyMoney::Account::Loan; + list << eMyMoney::Account::Liability; parent = m->liability(); testReparentEquity(list, parent); list.clear(); - list << MyMoneyAccount::Income; + list << eMyMoney::Account::Income; parent = m->income(); testReparentEquity(list, parent); list.clear(); - list << MyMoneyAccount::Expense; + list << eMyMoney::Account::Expense; parent = m->expense(); testReparentEquity(list, parent); @@ -1793,21 +1793,21 @@ } } -void MyMoneyFileTest::testReparentEquity(QList& list, MyMoneyAccount& parent) +void MyMoneyFileTest::testReparentEquity(QList& list, MyMoneyAccount& parent) { MyMoneyAccount a; MyMoneyAccount stock = m->account("A000002"); - QList::Iterator it; + QList::Iterator it; MyMoneyFileTransaction ft; for (it = list.begin(); it != list.end(); ++it) { - a.setName(QString("Testaccount %1").arg(*it)); + a.setName(QString("Testaccount %1").arg((int)*it)); a.setAccountType(*it); try { m->addAccount(a, parent); char msg[100]; m->reparentAccount(stock, a); - sprintf(msg, "Can reparent stock to non-investment type %d account", *it); + sprintf(msg, "Can reparent stock to non-investment type %d account", (int)*it); QFAIL(msg); } catch (const MyMoneyException &) { ft.commit(); @@ -2060,7 +2060,7 @@ testAddTwoInstitutions(); MyMoneySecurity base("EUR", "Euro", QChar(0x20ac)); MyMoneyAccount a; - a.setAccountType(MyMoneyAccount::Checkings); + a.setAccountType(eMyMoney::Account::Checkings); MyMoneyInstitution institution; @@ -2241,7 +2241,7 @@ { QString accountId = "A000001"; MyMoneyAccount a; - a.setAccountType(MyMoneyAccount::Checkings); + a.setAccountType(eMyMoney::Account::Checkings); storage->m_dirty = false; @@ -2282,7 +2282,7 @@ AddOneAccount(); QString accountId = "A000001"; - QCOMPARE(m->countTransactionsWithSpecificReconciliationState(accountId, MyMoneyTransactionFilter::notReconciled), 0); + QCOMPARE(m->countTransactionsWithSpecificReconciliationState(accountId, eMyMoney::TransactionFilter::State::NotReconciled), 0); } void MyMoneyFileTest::testCountTransactionsWithSpecificReconciliationState_transactionWithWantedReconcileState() @@ -2305,7 +2305,7 @@ m->addTransaction(transaction); ft.commit(); - QCOMPARE(m->countTransactionsWithSpecificReconciliationState(accountId, MyMoneyTransactionFilter::notReconciled), 1); + QCOMPARE(m->countTransactionsWithSpecificReconciliationState(accountId, eMyMoney::TransactionFilter::State::NotReconciled), 1); } void MyMoneyFileTest::testCountTransactionsWithSpecificReconciliationState_transactionWithUnwantedReconcileState() @@ -2329,7 +2329,7 @@ m->addTransaction(transaction); ft.commit(); - QCOMPARE(m->countTransactionsWithSpecificReconciliationState(accountId, MyMoneyTransactionFilter::notReconciled), 0); + QCOMPARE(m->countTransactionsWithSpecificReconciliationState(accountId, eMyMoney::TransactionFilter::State::NotReconciled), 0); } void MyMoneyFileTest::testAddOnlineJob() @@ -2545,7 +2545,7 @@ AddOneAccount(); MyMoneyAccount exp1; - exp1.setAccountType(MyMoneyAccount::Expense); + exp1.setAccountType(eMyMoney::Account::Expense); exp1.setName("Expense1"); exp1.setCurrencyId("EUR"); @@ -2578,7 +2578,7 @@ try { stock.setName("Teststock"); stock.setCurrencyId(stockSecurity.id()); - stock.setAccountType(MyMoneyAccount::Stock); + stock.setAccountType(eMyMoney::Account::Stock); m->addAccount(stock, i); ft.commit(); } catch (const MyMoneyException &e) { @@ -2676,7 +2676,7 @@ vat.setName("VAT"); vat.setCurrencyId("EUR"); - vat.setAccountType(MyMoneyAccount::Expense); + vat.setAccountType(eMyMoney::Account::Expense); // make it a VAT account vat.setValue(QLatin1String("VatRate"), QLatin1String("20/100")); diff --git a/kmymoney/mymoney/tests/mymoneyforecast-test.cpp b/kmymoney/mymoney/tests/mymoneyforecast-test.cpp --- a/kmymoney/mymoney/tests/mymoneyforecast-test.cpp +++ b/kmymoney/mymoney/tests/mymoneyforecast-test.cpp @@ -28,6 +28,9 @@ #include "mymoneystoragexml.h" #include "reportstestcommon.h" +#include "mymoneyenums.h" + +using namespace eMyMoney; using namespace test; QTEST_GUILESS_MAIN(MyMoneyForecastTest) @@ -66,20 +69,20 @@ acLiability = (MyMoneyFile::instance()->liability().id()); acExpense = (MyMoneyFile::instance()->expense().id()); acIncome = (MyMoneyFile::instance()->income().id()); - acChecking = makeAccount(QString("Checking Account"), MyMoneyAccount::Checkings, moCheckingOpen, QDate(2004, 5, 15), acAsset, "USD"); - acCredit = makeAccount(QString("Credit Card"), MyMoneyAccount::CreditCard, moCreditOpen, QDate(2004, 7, 15), acLiability, "USD"); - acSolo = makeAccount(QString("Solo"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense, "USD"); - acParent = makeAccount(QString("Parent"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense, "USD"); - acChild = makeAccount(QString("Child"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acParent, "USD"); - acForeign = makeAccount(QString("Foreign"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense, "USD"); - acInvestment = makeAccount("Investment", MyMoneyAccount::Investment, moZero, QDate(2004, 1, 1), acAsset, "USD"); - - acSecondChild = makeAccount(QString("Second Child"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acParent, "USD"); - acGrandChild1 = makeAccount(QString("Grand Child 1"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acChild, "USD"); - acGrandChild2 = makeAccount(QString("Grand Child 2"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acChild, "USD"); + acChecking = makeAccount(QString("Checking Account"), Account::Checkings, moCheckingOpen, QDate(2004, 5, 15), acAsset, "USD"); + acCredit = makeAccount(QString("Credit Card"), Account::CreditCard, moCreditOpen, QDate(2004, 7, 15), acLiability, "USD"); + acSolo = makeAccount(QString("Solo"), Account::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense, "USD"); + acParent = makeAccount(QString("Parent"), Account::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense, "USD"); + acChild = makeAccount(QString("Child"), Account::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acParent, "USD"); + acForeign = makeAccount(QString("Foreign"), Account::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense, "USD"); + acInvestment = makeAccount("Investment", Account::Investment, moZero, QDate(2004, 1, 1), acAsset, "USD"); + + acSecondChild = makeAccount(QString("Second Child"), Account::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acParent, "USD"); + acGrandChild1 = makeAccount(QString("Grand Child 1"), Account::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acChild, "USD"); + acGrandChild2 = makeAccount(QString("Grand Child 2"), Account::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acChild, "USD"); //this account added to have an account to test opening date calculations - acCash = makeAccount(QString("Cash"), MyMoneyAccount::Cash, moCreditOpen, QDate::currentDate().addDays(-2), acAsset, "USD"); + acCash = makeAccount(QString("Cash"), Account::Cash, moCreditOpen, QDate::currentDate().addDays(-2), acAsset, "USD"); MyMoneyInstitution i("Bank of the World", "", "", "", "", "", ""); @@ -386,9 +389,9 @@ MyMoneyFileTransaction ft; MyMoneySchedule sch("A Name", - MyMoneySchedule::TYPE_BILL, - MyMoneySchedule::OCCUR_WEEKLY, 1, - MyMoneySchedule::STYPE_DIRECTDEBIT, + Schedule::Type::Bill, + Schedule::Occurrence::Weekly, 1, + Schedule::PaymentType::DirectDebit, QDate::currentDate().addDays(1), QDate(), true, @@ -428,9 +431,9 @@ MyMoneyFileTransaction ft3; MyMoneySchedule sch3("A Name1", - MyMoneySchedule::TYPE_BILL, - MyMoneySchedule::OCCUR_WEEKLY, 1, - MyMoneySchedule::STYPE_DIRECTDEBIT, + Schedule::Type::Bill, + Schedule::Occurrence::Weekly, 1, + Schedule::PaymentType::DirectDebit, QDate::currentDate().addDays(5), QDate(), true, @@ -475,9 +478,9 @@ MyMoneyFileTransaction ft2; MyMoneySchedule sch2("A Name2", - MyMoneySchedule::TYPE_BILL, - MyMoneySchedule::OCCUR_WEEKLY, 1, - MyMoneySchedule::STYPE_DIRECTDEBIT, + Schedule::Type::Bill, + Schedule::Occurrence::Weekly, 1, + Schedule::PaymentType::DirectDebit, QDate::currentDate().addDays(2), QDate(), true, @@ -902,9 +905,9 @@ MyMoneyFileTransaction ft; MyMoneySchedule sch("A Name", - MyMoneySchedule::TYPE_BILL, - MyMoneySchedule::OCCUR_MONTHLY, 1, - MyMoneySchedule::STYPE_DIRECTDEBIT, + Schedule::Type::Bill, + Schedule::Occurrence::Monthly, 1, + Schedule::PaymentType::DirectDebit, QDate::currentDate(), QDate(), true, diff --git a/kmymoney/mymoney/tests/mymoneyschedule-test.cpp b/kmymoney/mymoney/tests/mymoneyschedule-test.cpp --- a/kmymoney/mymoney/tests/mymoneyschedule-test.cpp +++ b/kmymoney/mymoney/tests/mymoneyschedule-test.cpp @@ -29,14 +29,16 @@ QTEST_GUILESS_MAIN(MyMoneyScheduleTest) +using namespace eMyMoney; + void MyMoneyScheduleTest::testEmptyConstructor() { MyMoneySchedule s; QCOMPARE(s.id().isEmpty(), true); - QCOMPARE(s.m_occurrence, MyMoneySchedule::OCCUR_ANY); - QCOMPARE(s.m_type, MyMoneySchedule::TYPE_ANY); - QCOMPARE(s.m_paymentType, MyMoneySchedule::STYPE_ANY); + QCOMPARE(s.m_occurrence, Schedule::Occurrence::Any); + QCOMPARE(s.m_type, Schedule::Type::Any); + QCOMPARE(s.m_paymentType, Schedule::PaymentType::Any); QCOMPARE(s.m_fixed, false); QCOMPARE(!s.m_startDate.isValid(), true); QCOMPARE(!s.m_endDate.isValid(), true); @@ -49,18 +51,18 @@ void MyMoneyScheduleTest::testConstructor() { MyMoneySchedule s("A Name", - MyMoneySchedule::TYPE_BILL, - MyMoneySchedule::OCCUR_WEEKLY, 1, - MyMoneySchedule::STYPE_DIRECTDEBIT, + Schedule::Type::Bill, + Schedule::Occurrence::Weekly, 1, + Schedule::PaymentType::DirectDebit, QDate::currentDate(), QDate(), true, true); - QCOMPARE(s.type(), MyMoneySchedule::TYPE_BILL); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_WEEKLY); + QCOMPARE(s.type(), Schedule::Type::Bill); + QCOMPARE(s.occurrence(), Schedule::Occurrence::Weekly); QCOMPARE(s.occurrenceMultiplier(), 1); - QCOMPARE(s.paymentType(), MyMoneySchedule::STYPE_DIRECTDEBIT); + QCOMPARE(s.paymentType(), Schedule::PaymentType::DirectDebit); QCOMPARE(s.startDate(), QDate()); QCOMPARE(s.willEnd(), false); QCOMPARE(s.isFixed(), true); @@ -77,8 +79,8 @@ s.setId("SCHED001"); QCOMPARE(s.id(), QLatin1String("SCHED001")); - s.setType(MyMoneySchedule::TYPE_BILL); - QCOMPARE(s.type(), MyMoneySchedule::TYPE_BILL); + s.setType(Schedule::Type::Bill); + QCOMPARE(s.type(), Schedule::Type::Bill); s.setEndDate(QDate::currentDate()); QCOMPARE(s.endDate(), QDate::currentDate()); @@ -90,7 +92,7 @@ MyMoneySchedule s; s.setId("SCHED001"); - s.setType(MyMoneySchedule::TYPE_BILL); + s.setType(Schedule::Type::Bill); MyMoneySchedule s2(s); @@ -103,7 +105,7 @@ MyMoneySchedule s; s.setId("SCHED001"); - s.setType(MyMoneySchedule::TYPE_BILL); + s.setType(Schedule::Type::Bill); MyMoneySchedule s2 = s; @@ -263,10 +265,10 @@ void MyMoneyScheduleTest::testAddHalfMonths() { // addHalfMonths is private - // Test a Schedule with occurrence OCCUR_EVERYHALFMONTH using nextPayment + // Test a Schedule with occurrence EveryHalfMonth using nextPayment MyMoneySchedule s; s.setStartDate(QDate(2007, 1, 1)); - s.setOccurrence(MyMoneySchedule::OCCUR_EVERYHALFMONTH); + s.setOccurrence(Schedule::Occurrence::EveryHalfMonth); s.setNextDueDate(s.startDate()); s.setLastPayment(s.startDate()); @@ -455,8 +457,8 @@ // Add tests for each possible occurrence. // Check how paymentDates is meant to work // Build a list of expected dates and compare - // MyMoneySchedule::OCCUR_ONCE - sch.setOccurrence(MyMoneySchedule::OCCUR_ONCE); + // Schedule::Occurrence::Once + sch.setOccurrence(Schedule::Occurrence::Once); startDate.setDate(2009, 1, 1); endDate.setDate(2009, 12, 31); sch.setStartDate(startDate); @@ -464,8 +466,8 @@ list = sch.paymentDates(startDate, endDate); QVERIFY(list.count() == 1); QVERIFY(list[0] == QDate(2009, 1, 1)); - // MyMoneySchedule::OCCUR_DAILY - sch.setOccurrence(MyMoneySchedule::OCCUR_DAILY); + // Schedule::Occurrence::Daily + sch.setOccurrence(Schedule::Occurrence::Daily); startDate.setDate(2009, 1, 1); endDate.setDate(2009, 1, 5); sch.setStartDate(startDate); @@ -479,7 +481,7 @@ // Would fall on Sunday so gets moved to 2nd. QVERIFY(list[3] == QDate(2009, 1, 2)); QVERIFY(list[4] == QDate(2009, 1, 5)); - // MyMoneySchedule::OCCUR_DAILY with multiplier 2 + // Schedule::Occurrence::Daily with multiplier 2 sch.setOccurrenceMultiplier(2); list = sch.paymentDates(startDate.addDays(1), endDate); QVERIFY(list.count() == 2); @@ -487,8 +489,8 @@ QVERIFY(list[0] == QDate(2009, 1, 2)); QVERIFY(list[1] == QDate(2009, 1, 5)); sch.setOccurrenceMultiplier(1); - // MyMoneySchedule::OCCUR_WEEKLY - sch.setOccurrence(MyMoneySchedule::OCCUR_WEEKLY); + // Schedule::Occurrence::Weekly + sch.setOccurrence(Schedule::Occurrence::Weekly); startDate.setDate(2009, 1, 6); endDate.setDate(2009, 2, 4); sch.setStartDate(startDate); @@ -500,8 +502,8 @@ QVERIFY(list[2] == QDate(2009, 1, 20)); QVERIFY(list[3] == QDate(2009, 1, 27)); QVERIFY(list[4] == QDate(2009, 2, 3)); - // MyMoneySchedule::OCCUR_EVERYOTHERWEEK - sch.setOccurrence(MyMoneySchedule::OCCUR_EVERYOTHERWEEK); + // Schedule::Occurrence::EveryOtherWeek + sch.setOccurrence(Schedule::Occurrence::EveryOtherWeek); startDate.setDate(2009, 2, 5); endDate.setDate(2009, 4, 3); sch.setStartDate(startDate); @@ -513,8 +515,8 @@ QVERIFY(list[2] == QDate(2009, 3, 5)); QVERIFY(list[3] == QDate(2009, 3, 19)); QVERIFY(list[4] == QDate(2009, 4, 2)); - // MyMoneySchedule::OCCUR_FORTNIGHTLY - sch.setOccurrence(MyMoneySchedule::OCCUR_FORTNIGHTLY); + // Schedule::Occurrence::Fortnightly + sch.setOccurrence(Schedule::Occurrence::Fortnightly); startDate.setDate(2009, 4, 4); endDate.setDate(2009, 5, 31); sch.setStartDate(startDate); @@ -531,8 +533,8 @@ QVERIFY(list[2] == QDate(2009, 5, 15)); // Would fall on a Saturday so gets moved to 29th. QVERIFY(list[3] == QDate(2009, 5, 29)); - // MyMoneySchedule::OCCUR_EVERYHALFMONTH - sch.setOccurrence(MyMoneySchedule::OCCUR_EVERYHALFMONTH); + // Schedule::Occurrence::EveryHalfMonth + sch.setOccurrence(Schedule::Occurrence::EveryHalfMonth); startDate.setDate(2009, 6, 1); endDate.setDate(2009, 8, 11); sch.setStartDate(startDate); @@ -545,8 +547,8 @@ QVERIFY(list[3] == QDate(2009, 7, 16)); // Would fall on a Saturday so gets moved to 31st. QVERIFY(list[4] == QDate(2009, 7, 31)); - // MyMoneySchedule::OCCUR_EVERYTHREEWEEKS - sch.setOccurrence(MyMoneySchedule::OCCUR_EVERYTHREEWEEKS); + // Schedule::Occurrence::EveryThreeWeeks + sch.setOccurrence(Schedule::Occurrence::EveryThreeWeeks); startDate.setDate(2009, 8, 12); endDate.setDate(2009, 11, 12); sch.setStartDate(startDate); @@ -558,8 +560,8 @@ QVERIFY(list[2] == QDate(2009, 9, 23)); QVERIFY(list[3] == QDate(2009, 10, 14)); QVERIFY(list[4] == QDate(2009, 11, 4)); - // MyMoneySchedule::OCCUR_EVERYFOURWEEKS - sch.setOccurrence(MyMoneySchedule::OCCUR_EVERYFOURWEEKS); + // Schedule::Occurrence::EveryFourWeeks + sch.setOccurrence(Schedule::Occurrence::EveryFourWeeks); startDate.setDate(2009, 11, 13); endDate.setDate(2010, 3, 13); sch.setStartDate(startDate); @@ -571,8 +573,8 @@ QVERIFY(list[2] == QDate(2010, 1, 8)); QVERIFY(list[3] == QDate(2010, 2, 5)); QVERIFY(list[4] == QDate(2010, 3, 5)); - // MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS - sch.setOccurrence(MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS); + // Schedule::Occurrence::EveryThirtyDays + sch.setOccurrence(Schedule::Occurrence::EveryThirtyDays); startDate.setDate(2010, 3, 19); endDate.setDate(2010, 7, 19); sch.setStartDate(startDate); @@ -586,8 +588,8 @@ QVERIFY(list[3] == QDate(2010, 6, 17)); // Would fall on a Saturday so gets moved to 16th. QVERIFY(list[4] == QDate(2010, 7, 16)); - // MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS - sch.setOccurrence(MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS); + // Schedule::Occurrence::EveryEightWeeks + sch.setOccurrence(Schedule::Occurrence::EveryEightWeeks); startDate.setDate(2010, 7, 26); endDate.setDate(2011, 3, 26); sch.setStartDate(startDate); @@ -599,8 +601,8 @@ QVERIFY(list[2] == QDate(2010, 11, 15)); QVERIFY(list[3] == QDate(2011, 1, 10)); QVERIFY(list[4] == QDate(2011, 3, 7)); - // MyMoneySchedule::OCCUR_EVERYOTHERMONTH - sch.setOccurrence(MyMoneySchedule::OCCUR_EVERYOTHERMONTH); + // Schedule::Occurrence::EveryOtherMonth + sch.setOccurrence(Schedule::Occurrence::EveryOtherMonth); startDate.setDate(2011, 3, 14); endDate.setDate(2011, 11, 20); sch.setStartDate(startDate); @@ -613,8 +615,8 @@ QVERIFY(list[2] == QDate(2011, 7, 14)); QVERIFY(list[3] == QDate(2011, 9, 14)); QVERIFY(list[4] == QDate(2011, 11, 14)); - // MyMoneySchedule::OCCUR_EVERYTHREEMONTHS - sch.setOccurrence(MyMoneySchedule::OCCUR_EVERYTHREEMONTHS); + // Schedule::Occurrence::EveryThreeMonths + sch.setOccurrence(Schedule::Occurrence::EveryThreeMonths); startDate.setDate(2011, 11, 15); endDate.setDate(2012, 11, 19); sch.setStartDate(startDate); @@ -626,8 +628,8 @@ QVERIFY(list[2] == QDate(2012, 5, 15)); QVERIFY(list[3] == QDate(2012, 8, 15)); QVERIFY(list[4] == QDate(2012, 11, 15)); - // MyMoneySchedule::OCCUR_QUARTERLY - sch.setOccurrence(MyMoneySchedule::OCCUR_QUARTERLY); + // Schedule::Occurrence::Quarterly + sch.setOccurrence(Schedule::Occurrence::Quarterly); startDate.setDate(2012, 11, 20); endDate.setDate(2013, 11, 23); sch.setStartDate(startDate); @@ -639,8 +641,8 @@ QVERIFY(list[2] == QDate(2013, 5, 20)); QVERIFY(list[3] == QDate(2013, 8, 20)); QVERIFY(list[4] == QDate(2013, 11, 20)); - // MyMoneySchedule::OCCUR_EVERYFOURMONTHS - sch.setOccurrence(MyMoneySchedule::OCCUR_EVERYFOURMONTHS); + // Schedule::Occurrence::EveryFourMonths + sch.setOccurrence(Schedule::Occurrence::EveryFourMonths); startDate.setDate(2013, 11, 21); endDate.setDate(2015, 3, 23); sch.setStartDate(startDate); @@ -653,8 +655,8 @@ QVERIFY(list[3] == QDate(2014, 11, 21)); // Would fall on a Saturday so gets moved to 20th. QVERIFY(list[4] == QDate(2015, 3, 20)); - // MyMoneySchedule::OCCUR_TWICEYEARLY - sch.setOccurrence(MyMoneySchedule::OCCUR_TWICEYEARLY); + // Schedule::Occurrence::TwiceYearly + sch.setOccurrence(Schedule::Occurrence::TwiceYearly); startDate.setDate(2015, 3, 22); endDate.setDate(2017, 3, 29); sch.setStartDate(startDate); @@ -667,8 +669,8 @@ QVERIFY(list[1] == QDate(2016, 3, 22)); QVERIFY(list[2] == QDate(2016, 9, 22)); QVERIFY(list[3] == QDate(2017, 3, 22)); - // MyMoneySchedule::OCCUR_YEARLY - sch.setOccurrence(MyMoneySchedule::OCCUR_YEARLY); + // Schedule::Occurrence::Yearly + sch.setOccurrence(Schedule::Occurrence::Yearly); startDate.setDate(2017, 3, 23); endDate.setDate(2021, 3, 29); sch.setStartDate(startDate); @@ -681,8 +683,8 @@ QVERIFY(list[2] == QDate(2019, 3, 22)); QVERIFY(list[3] == QDate(2020, 3, 23)); QVERIFY(list[4] == QDate(2021, 3, 23)); - // MyMoneySchedule::OCCUR_EVERYOTHERYEAR - sch.setOccurrence(MyMoneySchedule::OCCUR_EVERYOTHERYEAR); + // Schedule::Occurrence::EveryOtherYear + sch.setOccurrence(Schedule::Occurrence::EveryOtherYear); startDate.setDate(2021, 3, 24); endDate.setDate(2029, 3, 30); sch.setStartDate(startDate); @@ -703,9 +705,9 @@ void MyMoneyScheduleTest::testWriteXML() { MyMoneySchedule sch("A Name", - MyMoneySchedule::TYPE_BILL, - MyMoneySchedule::OCCUR_WEEKLY, 123, - MyMoneySchedule::STYPE_DIRECTDEBIT, + Schedule::Type::Bill, + Schedule::Occurrence::Weekly, 123, + Schedule::PaymentType::DirectDebit, QDate::currentDate(), QDate(), true, @@ -927,12 +929,12 @@ QVERIFY(sch.endDate() == QDate()); QVERIFY(sch.autoEnter() == true); QVERIFY(sch.isFixed() == true); - QVERIFY(sch.weekendOption() == MyMoneySchedule::MoveNothing); + QVERIFY(sch.weekendOption() == Schedule::WeekendOption::MoveNothing); QVERIFY(sch.lastPayment() == QDate::currentDate()); - QVERIFY(sch.paymentType() == MyMoneySchedule::STYPE_DIRECTDEBIT); - QVERIFY(sch.type() == MyMoneySchedule::TYPE_BILL); + QVERIFY(sch.paymentType() == Schedule::PaymentType::DirectDebit); + QVERIFY(sch.type() == Schedule::Type::Bill); QVERIFY(sch.name() == "A Name"); - QVERIFY(sch.occurrence() == MyMoneySchedule::OCCUR_WEEKLY); + QVERIFY(sch.occurrence() == Schedule::Occurrence::Weekly); QVERIFY(sch.occurrenceMultiplier() == 1); QVERIFY(sch.nextDueDate() == sch.lastPayment().addDays(7)); QVERIFY(sch.recordedPayments().count() == 1); @@ -953,12 +955,12 @@ QVERIFY(sch.endDate() == QDate()); QVERIFY(sch.autoEnter() == true); QVERIFY(sch.isFixed() == true); - QVERIFY(sch.weekendOption() == MyMoneySchedule::MoveNothing); + QVERIFY(sch.weekendOption() == Schedule::WeekendOption::MoveNothing); QVERIFY(sch.lastPayment() == QDate::currentDate()); - QVERIFY(sch.paymentType() == MyMoneySchedule::STYPE_DIRECTDEBIT); - QVERIFY(sch.type() == MyMoneySchedule::TYPE_BILL); + QVERIFY(sch.paymentType() == Schedule::PaymentType::DirectDebit); + QVERIFY(sch.type() == Schedule::Type::Bill); QVERIFY(sch.name() == "A Name"); - QVERIFY(sch.occurrence() == MyMoneySchedule::OCCUR_WEEKLY); + QVERIFY(sch.occurrence() == Schedule::Occurrence::Weekly); QVERIFY(sch.occurrenceMultiplier() == 1); QVERIFY(sch.nextDueDate() == sch.lastPayment().addDays(7)); QVERIFY(sch.recordedPayments().count() == 1); @@ -1018,10 +1020,10 @@ QDate dueDate(2007, 9, 3); // start on a Monday for (int i = 0; i < 7; ++i) { s.setNextDueDate(dueDate); - s.setWeekendOption(MyMoneySchedule::MoveNothing); + s.setWeekendOption(Schedule::WeekendOption::MoveNothing); QVERIFY(s.adjustedNextDueDate() == dueDate); - s.setWeekendOption(MyMoneySchedule::MoveBefore); + s.setWeekendOption(Schedule::WeekendOption::MoveBefore); switch (i) { case 5: // Saturday case 6: // Sunday @@ -1032,7 +1034,7 @@ break; } - s.setWeekendOption(MyMoneySchedule::MoveAfter); + s.setWeekendOption(Schedule::WeekendOption::MoveAfter); switch (i) { case 5: // Saturday case 6: // Sunday @@ -1050,7 +1052,7 @@ { MyMoneySchedule s; s.setStartDate(QDate(2007, 1, 2)); - s.setOccurrence(MyMoneySchedule::OCCUR_MONTHLY); + s.setOccurrence(Schedule::Occurrence::Monthly); s.setNextDueDate(s.startDate().addMonths(1)); s.setLastPayment(s.startDate()); @@ -1078,139 +1080,139 @@ void MyMoneyScheduleTest::testDaysBetweenEvents() { - QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_ONCE), 0); - QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_DAILY), 1); - QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_WEEKLY), 7); - QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_EVERYOTHERWEEK), 14); - QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_FORTNIGHTLY), 14); - QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_EVERYHALFMONTH), 15); - QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_EVERYTHREEWEEKS), 21); - QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_EVERYFOURWEEKS), 28); - QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS), 30); - QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_MONTHLY), 30); - QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS), 56); - QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_EVERYOTHERMONTH), 60); - QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_EVERYTHREEMONTHS), 90); - QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_QUARTERLY), 90); - QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_EVERYFOURMONTHS), 120); - QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_TWICEYEARLY), 180); - QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_YEARLY), 360); - QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_EVERYOTHERYEAR), 0); + QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::Once), 0); + QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::Daily), 1); + QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::Weekly), 7); + QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::EveryOtherWeek), 14); + QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::Fortnightly), 14); + QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::EveryHalfMonth), 15); + QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::EveryThreeWeeks), 21); + QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::EveryFourWeeks), 28); + QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::EveryThirtyDays), 30); + QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::Monthly), 30); + QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::EveryEightWeeks), 56); + QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::EveryOtherMonth), 60); + QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::EveryThreeMonths), 90); + QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::Quarterly), 90); + QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::EveryFourMonths), 120); + QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::TwiceYearly), 180); + QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::Yearly), 360); + QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::EveryOtherYear), 0); } void MyMoneyScheduleTest::testEventsPerYear() { - QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_ONCE), 0); - QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_DAILY), 365); - QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_WEEKLY), 52); - QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_EVERYOTHERWEEK), 26); - QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_FORTNIGHTLY), 26); - QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_EVERYHALFMONTH), 24); - QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_EVERYTHREEWEEKS), 17); - QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_EVERYFOURWEEKS), 13); - QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS), 12); - QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_MONTHLY), 12); - QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS), 6); - QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_EVERYOTHERMONTH), 6); - QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_EVERYTHREEMONTHS), 4); - QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_QUARTERLY), 4); - QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_EVERYFOURMONTHS), 3); - QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_TWICEYEARLY), 2); - QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_YEARLY), 1); - QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_EVERYOTHERYEAR), 0); + QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::Once), 0); + QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::Daily), 365); + QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::Weekly), 52); + QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::EveryOtherWeek), 26); + QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::Fortnightly), 26); + QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::EveryHalfMonth), 24); + QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::EveryThreeWeeks), 17); + QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::EveryFourWeeks), 13); + QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::EveryThirtyDays), 12); + QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::Monthly), 12); + QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::EveryEightWeeks), 6); + QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::EveryOtherMonth), 6); + QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::EveryThreeMonths), 4); + QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::Quarterly), 4); + QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::EveryFourMonths), 3); + QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::TwiceYearly), 2); + QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::Yearly), 1); + QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::EveryOtherYear), 0); } void MyMoneyScheduleTest::testOccurrenceToString() { // For each occurrenceE test MyMoneySchedule::occurrenceToString(occurrenceE) - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_ONCE), QLatin1String("Once")); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_DAILY), QLatin1String("Daily")); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_WEEKLY), QLatin1String("Weekly")); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYOTHERWEEK), QLatin1String("Every other week")); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_FORTNIGHTLY), QLatin1String("Fortnightly")); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYHALFMONTH), QLatin1String("Every half month")); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYTHREEWEEKS), QLatin1String("Every three weeks")); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYFOURWEEKS), QLatin1String("Every four weeks")); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS), QLatin1String("Every thirty days")); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_MONTHLY), QLatin1String("Monthly")); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS), QLatin1String("Every eight weeks")); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYOTHERMONTH), QLatin1String("Every two months")); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYTHREEMONTHS), QLatin1String("Every three months")); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_QUARTERLY), QLatin1String("Quarterly")); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYFOURMONTHS), QLatin1String("Every four months")); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_TWICEYEARLY), QLatin1String("Twice yearly")); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_YEARLY), QLatin1String("Yearly")); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYOTHERYEAR), QLatin1String("Every other year")); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Once), QLatin1String("Once")); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Daily), QLatin1String("Daily")); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Weekly), QLatin1String("Weekly")); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryOtherWeek), QLatin1String("Every other week")); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Fortnightly), QLatin1String("Fortnightly")); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryHalfMonth), QLatin1String("Every half month")); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryThreeWeeks), QLatin1String("Every three weeks")); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryFourWeeks), QLatin1String("Every four weeks")); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryThirtyDays), QLatin1String("Every thirty days")); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Monthly), QLatin1String("Monthly")); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryEightWeeks), QLatin1String("Every eight weeks")); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryOtherMonth), QLatin1String("Every two months")); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryThreeMonths), QLatin1String("Every three months")); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Quarterly), QLatin1String("Quarterly")); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryFourMonths), QLatin1String("Every four months")); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::TwiceYearly), QLatin1String("Twice yearly")); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Yearly), QLatin1String("Yearly")); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryOtherYear), QLatin1String("Every other year")); // For each occurrenceE set occurrence and compare occurrenceToString() with oTS(occurrence()) MyMoneySchedule s; s.setStartDate(QDate(2007, 1, 1)); s.setNextDueDate(s.startDate()); s.setLastPayment(s.startDate()); - s.setOccurrence(MyMoneySchedule::OCCUR_ONCE); QCOMPARE(s.occurrenceToString(), QLatin1String("Once")); - s.setOccurrence(MyMoneySchedule::OCCUR_DAILY); QCOMPARE(s.occurrenceToString(), QLatin1String("Daily")); - s.setOccurrence(MyMoneySchedule::OCCUR_WEEKLY); QCOMPARE(s.occurrenceToString(), QLatin1String("Weekly")); - s.setOccurrence(MyMoneySchedule::OCCUR_EVERYOTHERWEEK); QCOMPARE(s.occurrenceToString(), QLatin1String("Every other week")); + s.setOccurrence(Schedule::Occurrence::Once); QCOMPARE(s.occurrenceToString(), QLatin1String("Once")); + s.setOccurrence(Schedule::Occurrence::Daily); QCOMPARE(s.occurrenceToString(), QLatin1String("Daily")); + s.setOccurrence(Schedule::Occurrence::Weekly); QCOMPARE(s.occurrenceToString(), QLatin1String("Weekly")); + s.setOccurrence(Schedule::Occurrence::EveryOtherWeek); QCOMPARE(s.occurrenceToString(), QLatin1String("Every other week")); // Fortnightly no longer used: Every other week used instead - s.setOccurrence(MyMoneySchedule::OCCUR_FORTNIGHTLY); QCOMPARE(s.occurrenceToString(), QLatin1String("Every other week")); - s.setOccurrence(MyMoneySchedule::OCCUR_EVERYHALFMONTH); QCOMPARE(s.occurrenceToString(), QLatin1String("Every half month")); - s.setOccurrence(MyMoneySchedule::OCCUR_EVERYTHREEWEEKS); QCOMPARE(s.occurrenceToString(), QLatin1String("Every three weeks")); - s.setOccurrence(MyMoneySchedule::OCCUR_EVERYFOURWEEKS); QCOMPARE(s.occurrenceToString(), QLatin1String("Every four weeks")); - s.setOccurrence(MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS); QCOMPARE(s.occurrenceToString(), QLatin1String("Every thirty days")); - s.setOccurrence(MyMoneySchedule::OCCUR_MONTHLY); QCOMPARE(s.occurrenceToString(), QLatin1String("Monthly")); - s.setOccurrence(MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS); QCOMPARE(s.occurrenceToString(), QLatin1String("Every eight weeks")); - s.setOccurrence(MyMoneySchedule::OCCUR_EVERYOTHERMONTH); QCOMPARE(s.occurrenceToString(), QLatin1String("Every two months")); - s.setOccurrence(MyMoneySchedule::OCCUR_EVERYTHREEMONTHS); QCOMPARE(s.occurrenceToString(), QLatin1String("Every three months")); + s.setOccurrence(Schedule::Occurrence::Fortnightly); QCOMPARE(s.occurrenceToString(), QLatin1String("Every other week")); + s.setOccurrence(Schedule::Occurrence::EveryHalfMonth); QCOMPARE(s.occurrenceToString(), QLatin1String("Every half month")); + s.setOccurrence(Schedule::Occurrence::EveryThreeWeeks); QCOMPARE(s.occurrenceToString(), QLatin1String("Every three weeks")); + s.setOccurrence(Schedule::Occurrence::EveryFourWeeks); QCOMPARE(s.occurrenceToString(), QLatin1String("Every four weeks")); + s.setOccurrence(Schedule::Occurrence::EveryThirtyDays); QCOMPARE(s.occurrenceToString(), QLatin1String("Every thirty days")); + s.setOccurrence(Schedule::Occurrence::Monthly); QCOMPARE(s.occurrenceToString(), QLatin1String("Monthly")); + s.setOccurrence(Schedule::Occurrence::EveryEightWeeks); QCOMPARE(s.occurrenceToString(), QLatin1String("Every eight weeks")); + s.setOccurrence(Schedule::Occurrence::EveryOtherMonth); QCOMPARE(s.occurrenceToString(), QLatin1String("Every two months")); + s.setOccurrence(Schedule::Occurrence::EveryThreeMonths); QCOMPARE(s.occurrenceToString(), QLatin1String("Every three months")); // Quarterly no longer used. Every three months used instead - s.setOccurrence(MyMoneySchedule::OCCUR_QUARTERLY); QCOMPARE(s.occurrenceToString(), QLatin1String("Every three months")); - s.setOccurrence(MyMoneySchedule::OCCUR_EVERYFOURMONTHS); QCOMPARE(s.occurrenceToString(), QLatin1String("Every four months")); - s.setOccurrence(MyMoneySchedule::OCCUR_TWICEYEARLY); QCOMPARE(s.occurrenceToString(), QLatin1String("Twice yearly")); - s.setOccurrence(MyMoneySchedule::OCCUR_YEARLY); QCOMPARE(s.occurrenceToString(), QLatin1String("Yearly")); - s.setOccurrence(MyMoneySchedule::OCCUR_EVERYOTHERYEAR); QCOMPARE(s.occurrenceToString(), QLatin1String("Every other year")); + s.setOccurrence(Schedule::Occurrence::Quarterly); QCOMPARE(s.occurrenceToString(), QLatin1String("Every three months")); + s.setOccurrence(Schedule::Occurrence::EveryFourMonths); QCOMPARE(s.occurrenceToString(), QLatin1String("Every four months")); + s.setOccurrence(Schedule::Occurrence::TwiceYearly); QCOMPARE(s.occurrenceToString(), QLatin1String("Twice yearly")); + s.setOccurrence(Schedule::Occurrence::Yearly); QCOMPARE(s.occurrenceToString(), QLatin1String("Yearly")); + s.setOccurrence(Schedule::Occurrence::EveryOtherYear); QCOMPARE(s.occurrenceToString(), QLatin1String("Every other year")); // Test occurrenceToString(mult,occ) // Test all pairs equivalent to simple occurrences: should return the same as occurrenceToString(simpleOcc) // TODO replace string with (mult,occ) call. - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_ONCE), MyMoneySchedule::occurrenceToString(1, MyMoneySchedule::OCCUR_ONCE)); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_DAILY), MyMoneySchedule::occurrenceToString(1, MyMoneySchedule::OCCUR_DAILY)); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_WEEKLY), MyMoneySchedule::occurrenceToString(1, MyMoneySchedule::OCCUR_WEEKLY)); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYOTHERWEEK), MyMoneySchedule::occurrenceToString(2, MyMoneySchedule::OCCUR_WEEKLY)); - // OCCUR_FORTNIGHTLY will no longer be used: only Every Other Week - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYHALFMONTH), MyMoneySchedule::occurrenceToString(1, MyMoneySchedule::OCCUR_EVERYHALFMONTH)); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYTHREEWEEKS), MyMoneySchedule::occurrenceToString(3, MyMoneySchedule::OCCUR_WEEKLY)); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYFOURWEEKS), MyMoneySchedule::occurrenceToString(4, MyMoneySchedule::OCCUR_WEEKLY)); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_MONTHLY), MyMoneySchedule::occurrenceToString(1, MyMoneySchedule::OCCUR_MONTHLY)); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS), MyMoneySchedule::occurrenceToString(8, MyMoneySchedule::OCCUR_WEEKLY)); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYOTHERMONTH), MyMoneySchedule::occurrenceToString(2, MyMoneySchedule::OCCUR_MONTHLY)); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYTHREEMONTHS), MyMoneySchedule::occurrenceToString(3, MyMoneySchedule::OCCUR_MONTHLY)); - // OCCUR_QUARTERLY will no longer be used: only Every Three Months - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYFOURMONTHS), MyMoneySchedule::occurrenceToString(4, MyMoneySchedule::OCCUR_MONTHLY)); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_TWICEYEARLY), MyMoneySchedule::occurrenceToString(6, MyMoneySchedule::OCCUR_MONTHLY)); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_YEARLY), MyMoneySchedule::occurrenceToString(1, MyMoneySchedule::OCCUR_YEARLY)); - QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYOTHERYEAR), MyMoneySchedule::occurrenceToString(2, MyMoneySchedule::OCCUR_YEARLY)); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Once), MyMoneySchedule::occurrenceToString(1, Schedule::Occurrence::Once)); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Daily), MyMoneySchedule::occurrenceToString(1, Schedule::Occurrence::Daily)); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Weekly), MyMoneySchedule::occurrenceToString(1, Schedule::Occurrence::Weekly)); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryOtherWeek), MyMoneySchedule::occurrenceToString(2, Schedule::Occurrence::Weekly)); + // Fortnightly will no longer be used: only Every Other Week + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryHalfMonth), MyMoneySchedule::occurrenceToString(1, Schedule::Occurrence::EveryHalfMonth)); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryThreeWeeks), MyMoneySchedule::occurrenceToString(3, Schedule::Occurrence::Weekly)); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryFourWeeks), MyMoneySchedule::occurrenceToString(4, Schedule::Occurrence::Weekly)); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Monthly), MyMoneySchedule::occurrenceToString(1, Schedule::Occurrence::Monthly)); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryEightWeeks), MyMoneySchedule::occurrenceToString(8, Schedule::Occurrence::Weekly)); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryOtherMonth), MyMoneySchedule::occurrenceToString(2, Schedule::Occurrence::Monthly)); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryThreeMonths), MyMoneySchedule::occurrenceToString(3, Schedule::Occurrence::Monthly)); + // Quarterly will no longer be used: only Every Three Months + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryFourMonths), MyMoneySchedule::occurrenceToString(4, Schedule::Occurrence::Monthly)); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::TwiceYearly), MyMoneySchedule::occurrenceToString(6, Schedule::Occurrence::Monthly)); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Yearly), MyMoneySchedule::occurrenceToString(1, Schedule::Occurrence::Yearly)); + QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryOtherYear), MyMoneySchedule::occurrenceToString(2, Schedule::Occurrence::Yearly)); // Test additional calls with other mult,occ - QCOMPARE(MyMoneySchedule::occurrenceToString(2, MyMoneySchedule::OCCUR_ONCE), QLatin1String("2 times")); - QCOMPARE(MyMoneySchedule::occurrenceToString(2, MyMoneySchedule::OCCUR_DAILY), QLatin1String("Every 2 days")); - QCOMPARE(MyMoneySchedule::occurrenceToString(5, MyMoneySchedule::OCCUR_WEEKLY), QLatin1String("Every 5 weeks")); - QCOMPARE(MyMoneySchedule::occurrenceToString(2, MyMoneySchedule::OCCUR_EVERYHALFMONTH), QLatin1String("Every 2 half months")); - QCOMPARE(MyMoneySchedule::occurrenceToString(5, MyMoneySchedule::OCCUR_MONTHLY), QLatin1String("Every 5 months")); - QCOMPARE(MyMoneySchedule::occurrenceToString(3, MyMoneySchedule::OCCUR_YEARLY), QLatin1String("Every 3 years")); - QCOMPARE(MyMoneySchedule::occurrenceToString(37, MyMoneySchedule::OCCUR_ONCE), QLatin1String("37 times")); - QCOMPARE(MyMoneySchedule::occurrenceToString(43, MyMoneySchedule::OCCUR_DAILY), QLatin1String("Every 43 days")); - QCOMPARE(MyMoneySchedule::occurrenceToString(61, MyMoneySchedule::OCCUR_WEEKLY), QLatin1String("Every 61 weeks")); - QCOMPARE(MyMoneySchedule::occurrenceToString(73, MyMoneySchedule::OCCUR_EVERYHALFMONTH), QLatin1String("Every 73 half months")); - QCOMPARE(MyMoneySchedule::occurrenceToString(83, MyMoneySchedule::OCCUR_MONTHLY), QLatin1String("Every 83 months")); - QCOMPARE(MyMoneySchedule::occurrenceToString(89, MyMoneySchedule::OCCUR_YEARLY), QLatin1String("Every 89 years")); + QCOMPARE(MyMoneySchedule::occurrenceToString(2, Schedule::Occurrence::Once), QLatin1String("2 times")); + QCOMPARE(MyMoneySchedule::occurrenceToString(2, Schedule::Occurrence::Daily), QLatin1String("Every 2 days")); + QCOMPARE(MyMoneySchedule::occurrenceToString(5, Schedule::Occurrence::Weekly), QLatin1String("Every 5 weeks")); + QCOMPARE(MyMoneySchedule::occurrenceToString(2, Schedule::Occurrence::EveryHalfMonth), QLatin1String("Every 2 half months")); + QCOMPARE(MyMoneySchedule::occurrenceToString(5, Schedule::Occurrence::Monthly), QLatin1String("Every 5 months")); + QCOMPARE(MyMoneySchedule::occurrenceToString(3, Schedule::Occurrence::Yearly), QLatin1String("Every 3 years")); + QCOMPARE(MyMoneySchedule::occurrenceToString(37, Schedule::Occurrence::Once), QLatin1String("37 times")); + QCOMPARE(MyMoneySchedule::occurrenceToString(43, Schedule::Occurrence::Daily), QLatin1String("Every 43 days")); + QCOMPARE(MyMoneySchedule::occurrenceToString(61, Schedule::Occurrence::Weekly), QLatin1String("Every 61 weeks")); + QCOMPARE(MyMoneySchedule::occurrenceToString(73, Schedule::Occurrence::EveryHalfMonth), QLatin1String("Every 73 half months")); + QCOMPARE(MyMoneySchedule::occurrenceToString(83, Schedule::Occurrence::Monthly), QLatin1String("Every 83 months")); + QCOMPARE(MyMoneySchedule::occurrenceToString(89, Schedule::Occurrence::Yearly), QLatin1String("Every 89 years")); // Test instance-level occurrenceToString method is using occurrencePeriod and multiplier // For each base occurrence set occurrencePeriod and multiplier - s.setOccurrencePeriod(MyMoneySchedule::OCCUR_ONCE); s.setOccurrenceMultiplier(1); - s.setOccurrence(MyMoneySchedule::OCCUR_ONCE); + s.setOccurrencePeriod(Schedule::Occurrence::Once); s.setOccurrenceMultiplier(1); + s.setOccurrence(Schedule::Occurrence::Once); s.setOccurrenceMultiplier(1); QCOMPARE(s.occurrenceToString(), QLatin1String("Once")); s.setOccurrenceMultiplier(2); QCOMPARE(s.occurrenceToString(), QLatin1String("2 times")); s.setOccurrenceMultiplier(3); QCOMPARE(s.occurrenceToString(), QLatin1String("3 times")); - s.setOccurrencePeriod(MyMoneySchedule::OCCUR_DAILY); + s.setOccurrencePeriod(Schedule::Occurrence::Daily); s.setOccurrenceMultiplier(1); QCOMPARE(s.occurrenceToString(), QLatin1String("Daily")); s.setOccurrenceMultiplier(30); QCOMPARE(s.occurrenceToString(), QLatin1String("Every thirty days")); s.setOccurrenceMultiplier(3); QCOMPARE(s.occurrenceToString(), QLatin1String("Every 3 days")); - s.setOccurrence(MyMoneySchedule::OCCUR_WEEKLY); + s.setOccurrence(Schedule::Occurrence::Weekly); QCOMPARE(s.occurrenceToString(), QLatin1String("Weekly")); s.setOccurrenceMultiplier(2); QCOMPARE(s.occurrenceToString(), QLatin1String("Every other week")); s.setOccurrenceMultiplier(3); QCOMPARE(s.occurrenceToString(), QLatin1String("Every three weeks")); @@ -1219,10 +1221,10 @@ s.setOccurrenceMultiplier(7); QCOMPARE(s.occurrenceToString(), QLatin1String("Every 7 weeks")); s.setOccurrenceMultiplier(8); QCOMPARE(s.occurrenceToString(), QLatin1String("Every eight weeks")); s.setOccurrenceMultiplier(9); QCOMPARE(s.occurrenceToString(), QLatin1String("Every 9 weeks")); - s.setOccurrence(MyMoneySchedule::OCCUR_EVERYHALFMONTH); + s.setOccurrence(Schedule::Occurrence::EveryHalfMonth); s.setOccurrenceMultiplier(1); QCOMPARE(s.occurrenceToString(), QLatin1String("Every half month")); s.setOccurrenceMultiplier(2); QCOMPARE(s.occurrenceToString(), QLatin1String("Every 2 half months")); - s.setOccurrence(MyMoneySchedule::OCCUR_MONTHLY); + s.setOccurrence(Schedule::Occurrence::Monthly); s.setOccurrenceMultiplier(1); QCOMPARE(s.occurrenceToString(), QLatin1String("Monthly")); s.setOccurrenceMultiplier(2); QCOMPARE(s.occurrenceToString(), QLatin1String("Every two months")); s.setOccurrenceMultiplier(3); QCOMPARE(s.occurrenceToString(), QLatin1String("Every three months")); @@ -1230,7 +1232,7 @@ s.setOccurrenceMultiplier(5); QCOMPARE(s.occurrenceToString(), QLatin1String("Every 5 months")); s.setOccurrenceMultiplier(6); QCOMPARE(s.occurrenceToString(), QLatin1String("Twice yearly")); s.setOccurrenceMultiplier(7); QCOMPARE(s.occurrenceToString(), QLatin1String("Every 7 months")); - s.setOccurrence(MyMoneySchedule::OCCUR_YEARLY); + s.setOccurrence(Schedule::Occurrence::Yearly); s.setOccurrenceMultiplier(1); QCOMPARE(s.occurrenceToString(), QLatin1String("Yearly")); s.setOccurrenceMultiplier(2); QCOMPARE(s.occurrenceToString(), QLatin1String("Every other year")); s.setOccurrenceMultiplier(3); QCOMPARE(s.occurrenceToString(), QLatin1String("Every 3 years")); @@ -1240,25 +1242,25 @@ { // For each occurrenceE test MyMoneySchedule::occurrencePeriodToString(occurrenceE) // Base occurrences are translated - QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_ONCE), QLatin1String("Once")); - QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_DAILY), QLatin1String("Day")); - QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_WEEKLY), QLatin1String("Week")); - QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_EVERYHALFMONTH), QLatin1String("Half-month")); - QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_MONTHLY), QLatin1String("Month")); - QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_YEARLY), QLatin1String("Year")); + QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::Once), QLatin1String("Once")); + QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::Daily), QLatin1String("Day")); + QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::Weekly), QLatin1String("Week")); + QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::EveryHalfMonth), QLatin1String("Half-month")); + QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::Monthly), QLatin1String("Month")); + QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::Yearly), QLatin1String("Year")); // All others are not translated so return Any - QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_EVERYOTHERWEEK), QLatin1String("Any")); - QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_FORTNIGHTLY), QLatin1String("Any")); - QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_EVERYTHREEWEEKS), QLatin1String("Any")); - QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_EVERYFOURWEEKS), QLatin1String("Any")); - QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS), QLatin1String("Any")); - QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS), QLatin1String("Any")); - QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_EVERYOTHERMONTH), QLatin1String("Any")); - QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_EVERYTHREEMONTHS), QLatin1String("Any")); - QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_QUARTERLY), QLatin1String("Any")); - QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_EVERYFOURMONTHS), QLatin1String("Any")); - QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_TWICEYEARLY), QLatin1String("Any")); - QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_EVERYOTHERYEAR), QLatin1String("Any")); + QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::EveryOtherWeek), QLatin1String("Any")); + QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::Fortnightly), QLatin1String("Any")); + QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::EveryThreeWeeks), QLatin1String("Any")); + QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::EveryFourWeeks), QLatin1String("Any")); + QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::EveryThirtyDays), QLatin1String("Any")); + QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::EveryEightWeeks), QLatin1String("Any")); + QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::EveryOtherMonth), QLatin1String("Any")); + QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::EveryThreeMonths), QLatin1String("Any")); + QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::Quarterly), QLatin1String("Any")); + QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::EveryFourMonths), QLatin1String("Any")); + QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::TwiceYearly), QLatin1String("Any")); + QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::EveryOtherYear), QLatin1String("Any")); } void MyMoneyScheduleTest::testOccurrencePeriod() @@ -1275,191 +1277,191 @@ s.setNextDueDate(s.startDate()); s.setLastPayment(s.startDate()); // Set all base occurrences - s.setOccurrencePeriod(MyMoneySchedule::OCCUR_ONCE); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_ONCE); + s.setOccurrencePeriod(Schedule::Occurrence::Once); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Once); s.setOccurrenceMultiplier(1); QCOMPARE(s.occurrenceMultiplier(), 1); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_ONCE); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_ONCE); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Once); + QCOMPARE(s.occurrence(), Schedule::Occurrence::Once); s.setOccurrenceMultiplier(2); QCOMPARE(s.occurrenceMultiplier(), 2); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_ONCE); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_ONCE); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Once); + QCOMPARE(s.occurrence(), Schedule::Occurrence::Once); - s.setOccurrencePeriod(MyMoneySchedule::OCCUR_DAILY); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_DAILY); + s.setOccurrencePeriod(Schedule::Occurrence::Daily); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Daily); s.setOccurrenceMultiplier(1); QCOMPARE(s.occurrenceMultiplier(), 1); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_DAILY); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_DAILY); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Daily); + QCOMPARE(s.occurrence(), Schedule::Occurrence::Daily); s.setOccurrenceMultiplier(30); QCOMPARE(s.occurrenceMultiplier(), 30); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_DAILY); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Daily); + QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryThirtyDays); s.setOccurrenceMultiplier(2); QCOMPARE(s.occurrenceMultiplier(), 2); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_DAILY); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_DAILY); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Daily); + QCOMPARE(s.occurrence(), Schedule::Occurrence::Daily); - s.setOccurrencePeriod(MyMoneySchedule::OCCUR_WEEKLY); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); + s.setOccurrencePeriod(Schedule::Occurrence::Weekly); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); s.setOccurrenceMultiplier(1); QCOMPARE(s.occurrenceMultiplier(), 1); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_WEEKLY); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); + QCOMPARE(s.occurrence(), Schedule::Occurrence::Weekly); s.setOccurrenceMultiplier(2); QCOMPARE(s.occurrenceMultiplier(), 2); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYOTHERWEEK); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); + QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryOtherWeek); s.setOccurrenceMultiplier(3); QCOMPARE(s.occurrenceMultiplier(), 3); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYTHREEWEEKS); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); + QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryThreeWeeks); s.setOccurrenceMultiplier(4); QCOMPARE(s.occurrenceMultiplier(), 4); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYFOURWEEKS); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); + QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryFourWeeks); s.setOccurrenceMultiplier(5); QCOMPARE(s.occurrenceMultiplier(), 5); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_WEEKLY); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); + QCOMPARE(s.occurrence(), Schedule::Occurrence::Weekly); s.setOccurrenceMultiplier(8); QCOMPARE(s.occurrenceMultiplier(), 8); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); + QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryEightWeeks); - s.setOccurrencePeriod(MyMoneySchedule::OCCUR_EVERYHALFMONTH); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_EVERYHALFMONTH); + s.setOccurrencePeriod(Schedule::Occurrence::EveryHalfMonth); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::EveryHalfMonth); s.setOccurrenceMultiplier(1); QCOMPARE(s.occurrenceMultiplier(), 1); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_EVERYHALFMONTH); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYHALFMONTH); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::EveryHalfMonth); + QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryHalfMonth); s.setOccurrenceMultiplier(2); QCOMPARE(s.occurrenceMultiplier(), 2); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_EVERYHALFMONTH); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYHALFMONTH); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::EveryHalfMonth); + QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryHalfMonth); - s.setOccurrencePeriod(MyMoneySchedule::OCCUR_MONTHLY); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); + s.setOccurrencePeriod(Schedule::Occurrence::Monthly); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); s.setOccurrenceMultiplier(1); QCOMPARE(s.occurrenceMultiplier(), 1); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_MONTHLY); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); + QCOMPARE(s.occurrence(), Schedule::Occurrence::Monthly); s.setOccurrenceMultiplier(2); QCOMPARE(s.occurrenceMultiplier(), 2); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYOTHERMONTH); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); + QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryOtherMonth); s.setOccurrenceMultiplier(3); QCOMPARE(s.occurrenceMultiplier(), 3); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYTHREEMONTHS); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); + QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryThreeMonths); s.setOccurrenceMultiplier(4); QCOMPARE(s.occurrenceMultiplier(), 4); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYFOURMONTHS); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); + QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryFourMonths); s.setOccurrenceMultiplier(5); QCOMPARE(s.occurrenceMultiplier(), 5); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_MONTHLY); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); + QCOMPARE(s.occurrence(), Schedule::Occurrence::Monthly); s.setOccurrenceMultiplier(6); QCOMPARE(s.occurrenceMultiplier(), 6); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_TWICEYEARLY); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); + QCOMPARE(s.occurrence(), Schedule::Occurrence::TwiceYearly); - s.setOccurrencePeriod(MyMoneySchedule::OCCUR_YEARLY); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_YEARLY); + s.setOccurrencePeriod(Schedule::Occurrence::Yearly); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Yearly); s.setOccurrenceMultiplier(1); QCOMPARE(s.occurrenceMultiplier(), 1); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_YEARLY); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_YEARLY); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Yearly); + QCOMPARE(s.occurrence(), Schedule::Occurrence::Yearly); s.setOccurrenceMultiplier(2); QCOMPARE(s.occurrenceMultiplier(), 2); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_YEARLY); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYOTHERYEAR); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Yearly); + QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryOtherYear); s.setOccurrenceMultiplier(3); QCOMPARE(s.occurrenceMultiplier(), 3); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_YEARLY); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_YEARLY); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Yearly); + QCOMPARE(s.occurrence(), Schedule::Occurrence::Yearly); // Set occurrence: check occurrence, Period and Multiplier - s.setOccurrence(MyMoneySchedule::OCCUR_ONCE); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_ONCE); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_ONCE); + s.setOccurrence(Schedule::Occurrence::Once); + QCOMPARE(s.occurrence(), Schedule::Occurrence::Once); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Once); QCOMPARE(s.occurrenceMultiplier(), 1); - s.setOccurrence(MyMoneySchedule::OCCUR_DAILY); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_DAILY); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_DAILY); + s.setOccurrence(Schedule::Occurrence::Daily); + QCOMPARE(s.occurrence(), Schedule::Occurrence::Daily); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Daily); QCOMPARE(s.occurrenceMultiplier(), 1); - s.setOccurrence(MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_DAILY); + s.setOccurrence(Schedule::Occurrence::EveryThirtyDays); + QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryThirtyDays); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Daily); QCOMPARE(s.occurrenceMultiplier(), 30); - s.setOccurrence(MyMoneySchedule::OCCUR_WEEKLY); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_WEEKLY); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); + s.setOccurrence(Schedule::Occurrence::Weekly); + QCOMPARE(s.occurrence(), Schedule::Occurrence::Weekly); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); QCOMPARE(s.occurrenceMultiplier(), 1); - s.setOccurrence(MyMoneySchedule::OCCUR_EVERYOTHERWEEK); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYOTHERWEEK); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); + s.setOccurrence(Schedule::Occurrence::EveryOtherWeek); + QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryOtherWeek); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); QCOMPARE(s.occurrenceMultiplier(), 2); // Fortnightly no longer used: Every other week used instead - s.setOccurrence(MyMoneySchedule::OCCUR_FORTNIGHTLY); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYOTHERWEEK); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); + s.setOccurrence(Schedule::Occurrence::Fortnightly); + QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryOtherWeek); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); QCOMPARE(s.occurrenceMultiplier(), 2); - s.setOccurrence(MyMoneySchedule::OCCUR_EVERYTHREEWEEKS); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYTHREEWEEKS); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); + s.setOccurrence(Schedule::Occurrence::EveryThreeWeeks); + QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryThreeWeeks); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); QCOMPARE(s.occurrenceMultiplier(), 3); - s.setOccurrence(MyMoneySchedule::OCCUR_EVERYFOURWEEKS); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYFOURWEEKS); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); + s.setOccurrence(Schedule::Occurrence::EveryFourWeeks); + QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryFourWeeks); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); QCOMPARE(s.occurrenceMultiplier(), 4); - s.setOccurrence(MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); + s.setOccurrence(Schedule::Occurrence::EveryEightWeeks); + QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryEightWeeks); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); QCOMPARE(s.occurrenceMultiplier(), 8); - s.setOccurrence(MyMoneySchedule::OCCUR_EVERYHALFMONTH); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYHALFMONTH); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_EVERYHALFMONTH); + s.setOccurrence(Schedule::Occurrence::EveryHalfMonth); + QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryHalfMonth); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::EveryHalfMonth); QCOMPARE(s.occurrenceMultiplier(), 1); - s.setOccurrence(MyMoneySchedule::OCCUR_MONTHLY); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_MONTHLY); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); + s.setOccurrence(Schedule::Occurrence::Monthly); + QCOMPARE(s.occurrence(), Schedule::Occurrence::Monthly); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); QCOMPARE(s.occurrenceMultiplier(), 1); - s.setOccurrence(MyMoneySchedule::OCCUR_EVERYOTHERMONTH); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYOTHERMONTH); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); + s.setOccurrence(Schedule::Occurrence::EveryOtherMonth); + QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryOtherMonth); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); QCOMPARE(s.occurrenceMultiplier(), 2); - s.setOccurrence(MyMoneySchedule::OCCUR_EVERYTHREEMONTHS); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYTHREEMONTHS); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); + s.setOccurrence(Schedule::Occurrence::EveryThreeMonths); + QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryThreeMonths); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); QCOMPARE(s.occurrenceMultiplier(), 3); // Quarterly no longer used. Every three months used instead - s.setOccurrence(MyMoneySchedule::OCCUR_QUARTERLY); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYTHREEMONTHS); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); + s.setOccurrence(Schedule::Occurrence::Quarterly); + QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryThreeMonths); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); QCOMPARE(s.occurrenceMultiplier(), 3); - s.setOccurrence(MyMoneySchedule::OCCUR_EVERYFOURMONTHS); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYFOURMONTHS); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); + s.setOccurrence(Schedule::Occurrence::EveryFourMonths); + QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryFourMonths); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); QCOMPARE(s.occurrenceMultiplier(), 4); - s.setOccurrence(MyMoneySchedule::OCCUR_TWICEYEARLY); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_TWICEYEARLY); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); + s.setOccurrence(Schedule::Occurrence::TwiceYearly); + QCOMPARE(s.occurrence(), Schedule::Occurrence::TwiceYearly); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); QCOMPARE(s.occurrenceMultiplier(), 6); - s.setOccurrence(MyMoneySchedule::OCCUR_YEARLY); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_YEARLY); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_YEARLY); + s.setOccurrence(Schedule::Occurrence::Yearly); + QCOMPARE(s.occurrence(), Schedule::Occurrence::Yearly); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Yearly); QCOMPARE(s.occurrenceMultiplier(), 1); - s.setOccurrence(MyMoneySchedule::OCCUR_EVERYOTHERYEAR); - QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYOTHERYEAR); - QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_YEARLY); + s.setOccurrence(Schedule::Occurrence::EveryOtherYear); + QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryOtherYear); + QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Yearly); QCOMPARE(s.occurrenceMultiplier(), 2); } @@ -1467,113 +1469,113 @@ { // Conversion between Simple and Compound occurrences // Each simple occurrence to compound occurrence - MyMoneySchedule::occurrenceE occ; + Schedule::Occurrence occ; int mult; - occ = MyMoneySchedule::OCCUR_ONCE; mult = 1; + occ = Schedule::Occurrence::Once; mult = 1; MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_ONCE && mult == 1); - occ = MyMoneySchedule::OCCUR_DAILY; mult = 1; + QVERIFY(occ == Schedule::Occurrence::Once && mult == 1); + occ = Schedule::Occurrence::Daily; mult = 1; MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_DAILY && mult == 1); - occ = MyMoneySchedule::OCCUR_WEEKLY; mult = 1; + QVERIFY(occ == Schedule::Occurrence::Daily && mult == 1); + occ = Schedule::Occurrence::Weekly; mult = 1; MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_WEEKLY && mult == 1); - occ = MyMoneySchedule::OCCUR_EVERYOTHERWEEK; mult = 1; + QVERIFY(occ == Schedule::Occurrence::Weekly && mult == 1); + occ = Schedule::Occurrence::EveryOtherWeek; mult = 1; MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_WEEKLY && mult == 2); - occ = MyMoneySchedule::OCCUR_FORTNIGHTLY; mult = 1; + QVERIFY(occ == Schedule::Occurrence::Weekly && mult == 2); + occ = Schedule::Occurrence::Fortnightly; mult = 1; MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_WEEKLY && mult == 2); - occ = MyMoneySchedule::OCCUR_EVERYHALFMONTH; mult = 1; + QVERIFY(occ == Schedule::Occurrence::Weekly && mult == 2); + occ = Schedule::Occurrence::EveryHalfMonth; mult = 1; MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_EVERYHALFMONTH && mult == 1); - occ = MyMoneySchedule::OCCUR_EVERYTHREEWEEKS; mult = 1; + QVERIFY(occ == Schedule::Occurrence::EveryHalfMonth && mult == 1); + occ = Schedule::Occurrence::EveryThreeWeeks; mult = 1; MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_WEEKLY && mult == 3); - occ = MyMoneySchedule::OCCUR_EVERYFOURWEEKS; mult = 1; + QVERIFY(occ == Schedule::Occurrence::Weekly && mult == 3); + occ = Schedule::Occurrence::EveryFourWeeks; mult = 1; MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_WEEKLY && mult == 4); - occ = MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS; mult = 1; + QVERIFY(occ == Schedule::Occurrence::Weekly && mult == 4); + occ = Schedule::Occurrence::EveryThirtyDays; mult = 1; MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_DAILY && mult == 30); - occ = MyMoneySchedule::OCCUR_MONTHLY; mult = 1; + QVERIFY(occ == Schedule::Occurrence::Daily && mult == 30); + occ = Schedule::Occurrence::Monthly; mult = 1; MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_MONTHLY && mult == 1); - occ = MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS; mult = 1; + QVERIFY(occ == Schedule::Occurrence::Monthly && mult == 1); + occ = Schedule::Occurrence::EveryEightWeeks; mult = 1; MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_WEEKLY && mult == 8); - occ = MyMoneySchedule::OCCUR_EVERYOTHERMONTH; mult = 1; + QVERIFY(occ == Schedule::Occurrence::Weekly && mult == 8); + occ = Schedule::Occurrence::EveryOtherMonth; mult = 1; MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_MONTHLY && mult == 2); - occ = MyMoneySchedule::OCCUR_EVERYTHREEMONTHS; mult = 1; + QVERIFY(occ == Schedule::Occurrence::Monthly && mult == 2); + occ = Schedule::Occurrence::EveryThreeMonths; mult = 1; MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_MONTHLY && mult == 3); - occ = MyMoneySchedule::OCCUR_QUARTERLY; mult = 1; + QVERIFY(occ == Schedule::Occurrence::Monthly && mult == 3); + occ = Schedule::Occurrence::Quarterly; mult = 1; MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_MONTHLY && mult == 3); - occ = MyMoneySchedule::OCCUR_EVERYFOURMONTHS; mult = 1; + QVERIFY(occ == Schedule::Occurrence::Monthly && mult == 3); + occ = Schedule::Occurrence::EveryFourMonths; mult = 1; MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_MONTHLY && mult == 4); - occ = MyMoneySchedule::OCCUR_TWICEYEARLY; mult = 1; + QVERIFY(occ == Schedule::Occurrence::Monthly && mult == 4); + occ = Schedule::Occurrence::TwiceYearly; mult = 1; MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_MONTHLY && mult == 6); - occ = MyMoneySchedule::OCCUR_YEARLY; mult = 1; + QVERIFY(occ == Schedule::Occurrence::Monthly && mult == 6); + occ = Schedule::Occurrence::Yearly; mult = 1; MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_YEARLY && mult == 1); - occ = MyMoneySchedule::OCCUR_EVERYOTHERYEAR; mult = 1; + QVERIFY(occ == Schedule::Occurrence::Yearly && mult == 1); + occ = Schedule::Occurrence::EveryOtherYear; mult = 1; MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_YEARLY && mult == 2); + QVERIFY(occ == Schedule::Occurrence::Yearly && mult == 2); // Compound to Simple Occurrences - occ = MyMoneySchedule::OCCUR_ONCE; mult = 1; + occ = Schedule::Occurrence::Once; mult = 1; MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_ONCE && mult == 1); - occ = MyMoneySchedule::OCCUR_DAILY; mult = 1; + QVERIFY(occ == Schedule::Occurrence::Once && mult == 1); + occ = Schedule::Occurrence::Daily; mult = 1; MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_DAILY && mult == 1); - occ = MyMoneySchedule::OCCUR_WEEKLY; mult = 1; + QVERIFY(occ == Schedule::Occurrence::Daily && mult == 1); + occ = Schedule::Occurrence::Weekly; mult = 1; MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_WEEKLY && mult == 1); - occ = MyMoneySchedule::OCCUR_WEEKLY; mult = 2; + QVERIFY(occ == Schedule::Occurrence::Weekly && mult == 1); + occ = Schedule::Occurrence::Weekly; mult = 2; MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_EVERYOTHERWEEK && mult == 1); - // MyMoneySchedule::OCCUR_FORTNIGHTLY not converted back - occ = MyMoneySchedule::OCCUR_EVERYHALFMONTH; mult = 1; + QVERIFY(occ == Schedule::Occurrence::EveryOtherWeek && mult == 1); + // Schedule::Occurrence::Fortnightly not converted back + occ = Schedule::Occurrence::EveryHalfMonth; mult = 1; MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_EVERYHALFMONTH && mult == 1); - occ = MyMoneySchedule::OCCUR_WEEKLY; mult = 3; + QVERIFY(occ == Schedule::Occurrence::EveryHalfMonth && mult == 1); + occ = Schedule::Occurrence::Weekly; mult = 3; MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_EVERYTHREEWEEKS && mult == 1); - occ = MyMoneySchedule::OCCUR_WEEKLY ; mult = 4; + QVERIFY(occ == Schedule::Occurrence::EveryThreeWeeks && mult == 1); + occ = Schedule::Occurrence::Weekly ; mult = 4; MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_EVERYFOURWEEKS && mult == 1); - occ = MyMoneySchedule::OCCUR_DAILY; mult = 30; + QVERIFY(occ == Schedule::Occurrence::EveryFourWeeks && mult == 1); + occ = Schedule::Occurrence::Daily; mult = 30; MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS && mult == 1); - occ = MyMoneySchedule::OCCUR_MONTHLY; mult = 1; + QVERIFY(occ == Schedule::Occurrence::EveryThirtyDays && mult == 1); + occ = Schedule::Occurrence::Monthly; mult = 1; MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_MONTHLY && mult == 1); - occ = MyMoneySchedule::OCCUR_WEEKLY; mult = 8; + QVERIFY(occ == Schedule::Occurrence::Monthly && mult == 1); + occ = Schedule::Occurrence::Weekly; mult = 8; MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS && mult == 1); - occ = MyMoneySchedule::OCCUR_MONTHLY; mult = 2; + QVERIFY(occ == Schedule::Occurrence::EveryEightWeeks && mult == 1); + occ = Schedule::Occurrence::Monthly; mult = 2; MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_EVERYOTHERMONTH && mult == 1); - occ = MyMoneySchedule::OCCUR_MONTHLY; mult = 3; + QVERIFY(occ == Schedule::Occurrence::EveryOtherMonth && mult == 1); + occ = Schedule::Occurrence::Monthly; mult = 3; MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_EVERYTHREEMONTHS && mult == 1); - // MyMoneySchedule::OCCUR_QUARTERLY not converted back - occ = MyMoneySchedule::OCCUR_MONTHLY; mult = 4; + QVERIFY(occ == Schedule::Occurrence::EveryThreeMonths && mult == 1); + // Schedule::Occurrence::Quarterly not converted back + occ = Schedule::Occurrence::Monthly; mult = 4; MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_EVERYFOURMONTHS && mult == 1); - occ = MyMoneySchedule::OCCUR_MONTHLY; mult = 6; + QVERIFY(occ == Schedule::Occurrence::EveryFourMonths && mult == 1); + occ = Schedule::Occurrence::Monthly; mult = 6; MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_TWICEYEARLY && mult == 1); - occ = MyMoneySchedule::OCCUR_YEARLY; mult = 1; + QVERIFY(occ == Schedule::Occurrence::TwiceYearly && mult == 1); + occ = Schedule::Occurrence::Yearly; mult = 1; MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_YEARLY && mult == 1); - occ = MyMoneySchedule::OCCUR_YEARLY; mult = 2; + QVERIFY(occ == Schedule::Occurrence::Yearly && mult == 1); + occ = Schedule::Occurrence::Yearly; mult = 2; MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); - QVERIFY(occ == MyMoneySchedule::OCCUR_EVERYOTHERYEAR && mult == 1); + QVERIFY(occ == Schedule::Occurrence::EveryOtherYear && mult == 1); } void MyMoneyScheduleTest::testProcessingDates() @@ -1625,7 +1627,7 @@ try { sch = MyMoneySchedule(node); QVERIFY(sch.isFinished() == true); - QVERIFY(sch.occurrencePeriod() == MyMoneySchedule::OCCUR_MONTHLY); + QVERIFY(sch.occurrencePeriod() == Schedule::Occurrence::Monthly); QVERIFY(sch.paymentDates(QDate::currentDate(), QDate::currentDate().addDays(21)).count() == 0); } catch (const MyMoneyException &) { QFAIL("Unexpected exception"); @@ -1640,8 +1642,8 @@ QDate dueDate(2010, 5, 23); QDate adjustedDueDate(2010, 5, 21); s.setNextDueDate(dueDate); - s.setOccurrence(MyMoneySchedule::OCCUR_MONTHLY); - s.setWeekendOption(MyMoneySchedule::MoveBefore); + s.setOccurrence(Schedule::Occurrence::Monthly); + s.setWeekendOption(Schedule::WeekendOption::MoveBefore); //if adjustedNextPayment works ok with adjusted date prior to the current date, it should return 2010-06-23 QDate nextDueDate(2010, 6, 23); @@ -1703,11 +1705,11 @@ QDate refDate(2011, 8, 10); // just some ref date before the last payment s.setStartDate(endDate.addMonths(-1)); - s.setOccurrence(MyMoneySchedule::OCCUR_MONTHLY); + s.setOccurrence(Schedule::Occurrence::Monthly); s.setEndDate(endDate); // the next due date is on this day but the policy is to move the // schedule to the next processing day (Monday) - s.setWeekendOption(MyMoneySchedule::MoveAfter); + s.setWeekendOption(Schedule::WeekendOption::MoveAfter); s.setNextDueDate(endDate); // the payment should be found between the respective date and one month after diff --git a/kmymoney/mymoney/tests/onlinejobadministration-test.cpp b/kmymoney/mymoney/tests/onlinejobadministration-test.cpp --- a/kmymoney/mymoney/tests/onlinejobadministration-test.cpp +++ b/kmymoney/mymoney/tests/onlinejobadministration-test.cpp @@ -36,7 +36,7 @@ try { MyMoneyAccount account = MyMoneyAccount(); account.setName("Test Account"); - account.setAccountType(MyMoneyAccount::Savings); + account.setAccountType(eMyMoney::Account::Savings); MyMoneyAccount asset = file->asset(); MyMoneyFileTransaction transaction; file->addAccount(account , asset); diff --git a/kmymoney/plugins/csvexport/csvexportdlg.cpp b/kmymoney/plugins/csvexport/csvexportdlg.cpp --- a/kmymoney/plugins/csvexport/csvexportdlg.cpp +++ b/kmymoney/plugins/csvexport/csvexportdlg.cpp @@ -41,6 +41,9 @@ // Project Headers #include "mymoneyfile.h" +#include "mymoneyaccount.h" +#include "mymoneytransaction.h" +#include "mymoneytransactionfilter.h" #include "icons/icons.h" using namespace Icons; @@ -160,7 +163,7 @@ account = file->accountByName(accountName); m_accountId = account.id(); MyMoneyAccount accnt; - if (account.accountType() == MyMoneyAccount::Investment) { + if (account.accountType() == eMyMoney::Account::Investment) { // If this is Investment account, we need child account. QStringList listAccounts = account.accountList(); QStringList::Iterator itAccounts; @@ -223,9 +226,9 @@ while (it_account != accounts.constEnd()) { MyMoneyAccount account((*it_account).id(), (*it_account)); if (!account.isClosed()) { - MyMoneyAccount::accountTypeE accntType = account.accountType(); - MyMoneyAccount::accountTypeE accntGroup = account.accountGroup(); - if ((accntGroup == MyMoneyAccount::Liability) || ((accntGroup == MyMoneyAccount::Asset) && (accntType != MyMoneyAccount::Stock))) { // ie Asset or Liability types + eMyMoney::Account accntType = account.accountType(); + eMyMoney::Account accntGroup = account.accountGroup(); + if ((accntGroup == eMyMoney::Account::Liability) || ((accntGroup == eMyMoney::Account::Asset) && (accntType != eMyMoney::Account::Stock))) { // ie Asset or Liability types list << account.name(); m_idList << account.id(); } diff --git a/kmymoney/plugins/csvexport/csvwriter.cpp b/kmymoney/plugins/csvexport/csvwriter.cpp --- a/kmymoney/plugins/csvexport/csvwriter.cpp +++ b/kmymoney/plugins/csvexport/csvwriter.cpp @@ -35,6 +35,10 @@ // Project Headers #include "mymoneyfile.h" +#include "mymoneytransaction.h" +#include "mymoneytransactionfilter.h" +#include "mymoneysplit.h" +#include "mymoneypayee.h" #include "csvexportdlg.h" #include "csvexporterplugin.h" @@ -158,7 +162,7 @@ QString name = acc.name(); s << leadIn << name << m_separator; - s << (acc.accountGroup() == MyMoneyAccount::Expense ? QLatin1Char('E') : QLatin1Char('I')); + s << (acc.accountGroup() == eMyMoney::Account::Expense ? QLatin1Char('E') : QLatin1Char('I')); s << endl; QStringList list = acc.accountList(); @@ -302,11 +306,11 @@ QString chkAccnt; QList lst = t.splits(); QList::Iterator itSplit; - MyMoneyAccount::_accountTypeE typ; + eMyMoney::Account typ; QString chkAccntId; MyMoneyMoney qty; MyMoneyMoney value; - QMap map; + QMap map; for (int i = 0; i < lst.count(); i++) { MyMoneyAccount acc = file->account(lst[i].accountId()); @@ -314,7 +318,7 @@ typ = acc.accountType(); map.insert(typ, lst[i].accountId()); - if (typ == MyMoneyAccount::Stock) { + if (typ == eMyMoney::Account::Stock) { switch (lst[i].reconcileFlag()) { case MyMoneySplit::Cleared: strStatus = QLatin1Char('C'); @@ -340,30 +344,30 @@ for (itSplit = lst.begin(); itSplit != lst.end(); ++itSplit) { MyMoneyAccount acc = file->account((*itSplit).accountId()); // - // MyMoneyAccount::Checkings. + // eMyMoney::Account::Checkings. // - if ((acc.accountType() == MyMoneyAccount::Checkings) || (acc.accountType() == MyMoneyAccount::Cash) || (acc.accountType() == MyMoneyAccount::Savings)) { + if ((acc.accountType() == eMyMoney::Account::Checkings) || (acc.accountType() == eMyMoney::Account::Cash) || (acc.accountType() == eMyMoney::Account::Savings)) { chkAccntId = (*itSplit).accountId(); chkAccnt = file->account(chkAccntId).name(); strCheckingAccountName = file->accountToCategory(chkAccntId) + m_separator; strAmount = (*itSplit).value().formatMoney("", 2).remove(localeThousands) + m_separator; - } else if (acc.accountType() == MyMoneyAccount::Income) { + } else if (acc.accountType() == eMyMoney::Account::Income) { // - // MyMoneyAccount::Income. + // eMyMoney::Account::Income. // qty = (*itSplit).shares(); value = (*itSplit).value(); strInterest = value.formatMoney("", 2, false) + m_separator; - } else if (acc.accountType() == MyMoneyAccount::Expense) { + } else if (acc.accountType() == eMyMoney::Account::Expense) { // - // MyMoneyAccount::Expense. + // eMyMoney::Account::Expense. // qty = (*itSplit).shares(); value = (*itSplit).value(); strFees = value.formatMoney("", 2, false) + m_separator; - } else if (acc.accountType() == MyMoneyAccount::Stock) { + } else if (acc.accountType() == eMyMoney::Account::Stock) { // - // MyMoneyAccount::Stock. + // eMyMoney::Account::Stock. // strMemo = QString("%1" + m_separator).arg((*itSplit).memo()); strMemo.replace(QLatin1Char('\n'), QLatin1Char('~')).remove('\''); @@ -376,7 +380,7 @@ strAction = QLatin1String("IntIncX"); } if ((strAction == QLatin1String("DivX")) || (strAction == QLatin1String("IntIncX"))) { - if ((map.value(MyMoneyAccount::Checkings).isEmpty()) && (map.value(MyMoneyAccount::Cash).isEmpty())) { + if ((map.value(eMyMoney::Account::Checkings).isEmpty()) && (map.value(eMyMoney::Account::Cash).isEmpty())) { KMessageBox::sorry(0, i18n("Transaction number '%1' is missing an account assignment.\n" "Date '%2', Amount '%3'.\nTransaction dropped.\n", count, t.postDate().toString(Qt::ISODate), strAmount), i18n("Invalid transaction")); diff --git a/kmymoney/plugins/csvimport/csvimporter.h b/kmymoney/plugins/csvimport/csvimporter.h --- a/kmymoney/plugins/csvimport/csvimporter.h +++ b/kmymoney/plugins/csvimport/csvimporter.h @@ -283,7 +283,7 @@ /** * This method will try to detect account from csv header. */ - QList findAccounts(const QList &accountTypes, const QString &statementHeader); + QList findAccounts(const QList &accountTypes, const QString &statementHeader); bool detectAccount(MyMoneyStatement &st); /** diff --git a/kmymoney/plugins/csvimport/csvimporter.cpp b/kmymoney/plugins/csvimport/csvimporter.cpp --- a/kmymoney/plugins/csvimport/csvimporter.cpp +++ b/kmymoney/plugins/csvimport/csvimporter.cpp @@ -40,6 +40,8 @@ // Project Includes #include "mymoneyfile.h" +#include "mymoneysecurity.h" +#include "mymoneytransaction.h" #include "csvutil.h" #include "convdate.h" @@ -674,17 +676,17 @@ MyMoneyFile *file = MyMoneyFile::instance(); file->accountList(accounts); - QList accountTypes; - accountTypes << MyMoneyAccount::Checkings << - MyMoneyAccount::Savings << - MyMoneyAccount::Liability << - MyMoneyAccount::Checkings << - MyMoneyAccount::Savings << - MyMoneyAccount::Cash << - MyMoneyAccount::CreditCard << - MyMoneyAccount::Loan << - MyMoneyAccount::Asset << - MyMoneyAccount::Liability; + QList accountTypes; + accountTypes << eMyMoney::Account::Checkings << + eMyMoney::Account::Savings << + eMyMoney::Account::Liability << + eMyMoney::Account::Checkings << + eMyMoney::Account::Savings << + eMyMoney::Account::Cash << + eMyMoney::Account::CreditCard << + eMyMoney::Account::Loan << + eMyMoney::Account::Asset << + eMyMoney::Account::Liability; QSet currencySymbols; foreach (const auto account, accounts) { @@ -707,7 +709,7 @@ return ret; } -QList CSVImporter::findAccounts(const QList &accountTypes, const QString &statementHeader) +QList CSVImporter::findAccounts(const QList &accountTypes, const QString &statementHeader) { MyMoneyFile* file = MyMoneyFile::instance(); QList accountList; @@ -804,25 +806,25 @@ statementHeader.remove(QRegularExpression(QStringLiteral("[-., ]"))); QList accounts; - QList accountTypes; + QList accountTypes; switch(m_profile->type()) { default: case Profile::Banking: - accountTypes << MyMoneyAccount::Checkings << - MyMoneyAccount::Savings << - MyMoneyAccount::Liability << - MyMoneyAccount::Checkings << - MyMoneyAccount::Savings << - MyMoneyAccount::Cash << - MyMoneyAccount::CreditCard << - MyMoneyAccount::Loan << - MyMoneyAccount::Asset << - MyMoneyAccount::Liability; + accountTypes << eMyMoney::Account::Checkings << + eMyMoney::Account::Savings << + eMyMoney::Account::Liability << + eMyMoney::Account::Checkings << + eMyMoney::Account::Savings << + eMyMoney::Account::Cash << + eMyMoney::Account::CreditCard << + eMyMoney::Account::Loan << + eMyMoney::Account::Asset << + eMyMoney::Account::Liability; accounts = findAccounts(accountTypes, statementHeader); break; case Profile::Investment: - accountTypes << MyMoneyAccount::Investment; // take investment accounts... + accountTypes << eMyMoney::Account::Investment; // take investment accounts... accounts = findAccounts(accountTypes, statementHeader); //...and search them in statement header break; } @@ -833,16 +835,16 @@ st.m_accountId = accounts.first().id(); switch (accounts.first().accountType()) { - case MyMoneyAccount::Checkings: + case eMyMoney::Account::Checkings: st.m_eType = MyMoneyStatement::etCheckings; break; - case MyMoneyAccount::Savings: + case eMyMoney::Account::Savings: st.m_eType = MyMoneyStatement::etSavings; break; - case MyMoneyAccount::Investment: + case eMyMoney::Account::Investment: st.m_eType = MyMoneyStatement::etInvestment; break; - case MyMoneyAccount::CreditCard: + case eMyMoney::Account::CreditCard: st.m_eType = MyMoneyStatement::etCreditCard; break; default: diff --git a/kmymoney/plugins/csvimport/currenciesdlg.cpp b/kmymoney/plugins/csvimport/currenciesdlg.cpp --- a/kmymoney/plugins/csvimport/currenciesdlg.cpp +++ b/kmymoney/plugins/csvimport/currenciesdlg.cpp @@ -21,6 +21,7 @@ #include "ui_currenciesdlg.h" #include "mymoneyfile.h" +#include "mymoneysecurity.h" CurrenciesDlg::CurrenciesDlg() : ui(new Ui::CurrenciesDlg) { diff --git a/kmymoney/plugins/csvimport/investmentwizardpage.cpp b/kmymoney/plugins/csvimport/investmentwizardpage.cpp --- a/kmymoney/plugins/csvimport/investmentwizardpage.cpp +++ b/kmymoney/plugins/csvimport/investmentwizardpage.cpp @@ -36,6 +36,7 @@ // Project Includes #include "mymoneyfile.h" +#include "mymoneysecurity.h" #include "csvwizard.h" #include "csvimporter.h" diff --git a/kmymoney/plugins/csvimport/priceswizardpage.cpp b/kmymoney/plugins/csvimport/priceswizardpage.cpp --- a/kmymoney/plugins/csvimport/priceswizardpage.cpp +++ b/kmymoney/plugins/csvimport/priceswizardpage.cpp @@ -29,6 +29,7 @@ // Project Includes #include "mymoneyfile.h" +#include "mymoneysecurity.h" #include "csvwizard.h" #include "csvimporter.h" diff --git a/kmymoney/plugins/csvimport/securitydlg.cpp b/kmymoney/plugins/csvimport/securitydlg.cpp --- a/kmymoney/plugins/csvimport/securitydlg.cpp +++ b/kmymoney/plugins/csvimport/securitydlg.cpp @@ -22,6 +22,7 @@ #include "ui_securitydlg.h" #include "mymoneyfile.h" +#include "mymoneysecurity.h" SecurityDlg::SecurityDlg() : ui(new Ui::SecurityDlg) { diff --git a/kmymoney/plugins/csvimport/tests/csvimporter-test.cpp b/kmymoney/plugins/csvimport/tests/csvimporter-test.cpp --- a/kmymoney/plugins/csvimport/tests/csvimporter-test.cpp +++ b/kmymoney/plugins/csvimport/tests/csvimporter-test.cpp @@ -268,13 +268,13 @@ void CsvImporterTest::testInvAccountAutodetection() { MyMoneyFileTransaction ft; - makeAccount("Eas", "123", MyMoneyAccount::Investment, QDate(2017, 8, 1), file->asset().id()); - makeAccount("BigInvestments", "", MyMoneyAccount::Investment, QDate(2017, 8, 1), file->asset().id()); - makeAccount("BigInvestments", "1234567890", MyMoneyAccount::Investment, QDate(2017, 8, 1), file->asset().id()); - makeAccount("EasyAccount", "", MyMoneyAccount::Investment, QDate(2017, 8, 1), file->asset().id()); - auto toBeClosedAccID = makeAccount("EasyAccount", "123456789", MyMoneyAccount::Investment, QDate(2017, 8, 1), file->asset().id()); // this account has the most characters matching the statement - auto accID = makeAccount("Easy", "123456789", MyMoneyAccount::Investment, QDate(2017, 8, 1), file->asset().id()); - makeAccount("EasyAccount", "123456789", MyMoneyAccount::Checkings, QDate(2017, 8, 1), file->asset().id()); + makeAccount("Eas", "123", eMyMoney::Account::Investment, QDate(2017, 8, 1), file->asset().id()); + makeAccount("BigInvestments", "", eMyMoney::Account::Investment, QDate(2017, 8, 1), file->asset().id()); + makeAccount("BigInvestments", "1234567890", eMyMoney::Account::Investment, QDate(2017, 8, 1), file->asset().id()); + makeAccount("EasyAccount", "", eMyMoney::Account::Investment, QDate(2017, 8, 1), file->asset().id()); + auto toBeClosedAccID = makeAccount("EasyAccount", "123456789", eMyMoney::Account::Investment, QDate(2017, 8, 1), file->asset().id()); // this account has the most characters matching the statement + auto accID = makeAccount("Easy", "123456789", eMyMoney::Account::Investment, QDate(2017, 8, 1), file->asset().id()); + makeAccount("EasyAccount", "123456789", eMyMoney::Account::Checkings, QDate(2017, 8, 1), file->asset().id()); ft.commit(); auto csvContent = csvDataset(0); diff --git a/kmymoney/plugins/csvimport/tests/csvimporttestcommon.h b/kmymoney/plugins/csvimport/tests/csvimporttestcommon.h --- a/kmymoney/plugins/csvimport/tests/csvimporttestcommon.h +++ b/kmymoney/plugins/csvimport/tests/csvimporttestcommon.h @@ -16,10 +16,11 @@ #ifndef CSVIMPORTTESTCOMMON_H #define CSVIMPORTTESTCOMMON_H -#include "mymoneyaccount.h" +#include "mymoneyenums.h" class QString; +class QDate; extern void writeStatementToCSV(const QString& content, const QString& filename); extern QString csvDataset(const int set); -extern QString makeAccount(const QString& name, const QString& number, MyMoneyAccount::accountTypeE type, const QDate& open, const QString& parent); +extern QString makeAccount(const QString& name, const QString& number, eMyMoney::Account type, const QDate& open, const QString& parent); #endif diff --git a/kmymoney/plugins/csvimport/tests/csvimporttestcommon.cpp b/kmymoney/plugins/csvimport/tests/csvimporttestcommon.cpp --- a/kmymoney/plugins/csvimport/tests/csvimporttestcommon.cpp +++ b/kmymoney/plugins/csvimport/tests/csvimporttestcommon.cpp @@ -19,6 +19,8 @@ #include #include "mymoneyfile.h" +#include "mymoneyaccount.h" +#include "mymoneysecurity.h" void writeStatementToCSV(const QString& content, const QString& filename) { @@ -44,7 +46,7 @@ return csvContent; } -QString makeAccount(const QString& name, const QString& number, MyMoneyAccount::accountTypeE type, const QDate& open, const QString& parent) +QString makeAccount(const QString& name, const QString& number, eMyMoney::Account type, const QDate& open, const QString& parent) { MyMoneyAccount acc; MyMoneyFileTransaction ft; diff --git a/kmymoney/plugins/ofximport/dialogs/mymoneyofxconnector.cpp b/kmymoney/plugins/ofximport/dialogs/mymoneyofxconnector.cpp --- a/kmymoney/plugins/ofximport/dialogs/mymoneyofxconnector.cpp +++ b/kmymoney/plugins/ofximport/dialogs/mymoneyofxconnector.cpp @@ -273,13 +273,13 @@ result = OfxAccountData::OFX_INVESTMENT; else { switch (m_account.accountType()) { - case MyMoneyAccount::Investment: + case eMyMoney::Account::Investment: result = OfxAccountData::OFX_INVESTMENT; break; - case MyMoneyAccount::CreditCard: + case eMyMoney::Account::CreditCard: result = OfxAccountData::OFX_CREDITCARD; break; - case MyMoneyAccount::Savings: + case eMyMoney::Account::Savings: result = OfxAccountData::OFX_SAVINGS; break; default: @@ -711,7 +711,7 @@ while (it_split != splits.end()) { QByteArray accid = (*it_split).accountId(); MyMoneyAccount acc = file->account(accid); - if (acc.accountType() == MyMoneyAccount::Income || acc.accountType() == MyMoneyAccount::Expense) { + if (acc.accountType() == eMyMoney::Account::Income || acc.accountType() == eMyMoney::Account::Expense) { found = true; break; } diff --git a/kmymoney/plugins/onlinetasks/sepa/tasks/sepaonlinetransferimpl.cpp b/kmymoney/plugins/onlinetasks/sepa/tasks/sepaonlinetransferimpl.cpp --- a/kmymoney/plugins/onlinetasks/sepa/tasks/sepaonlinetransferimpl.cpp +++ b/kmymoney/plugins/onlinetasks/sepa/tasks/sepaonlinetransferimpl.cpp @@ -23,6 +23,7 @@ #include "mymoneyutils.h" #include "mymoney/mymoneyfile.h" +#include "mymoneypayee.h" #include "mymoney/onlinejobadministration.h" #include "misc/validators.h" #include "payeeidentifiertyped.h" diff --git a/kmymoney/plugins/printcheck/printcheck.cpp b/kmymoney/plugins/printcheck/printcheck.cpp --- a/kmymoney/plugins/printcheck/printcheck.cpp +++ b/kmymoney/plugins/printcheck/printcheck.cpp @@ -121,7 +121,7 @@ bool KMMPrintCheckPlugin::canBePrinted(const KMyMoneyRegister::SelectedTransaction & selectedTransaction) const { MyMoneyFile* file = MyMoneyFile::instance(); - bool isACheck = file->account(selectedTransaction.split().accountId()).accountType() == MyMoneyAccount::Checkings && selectedTransaction.split().shares().isNegative(); + bool isACheck = file->account(selectedTransaction.split().accountId()).accountType() == eMyMoney::Account::Checkings && selectedTransaction.split().shares().isNegative(); return isACheck && d->m_printedTransactionIdList.contains(selectedTransaction.transaction().id()) == 0; } diff --git a/kmymoney/plugins/qif/export/kexportdlg.cpp b/kmymoney/plugins/qif/export/kexportdlg.cpp --- a/kmymoney/plugins/qif/export/kexportdlg.cpp +++ b/kmymoney/plugins/qif/export/kexportdlg.cpp @@ -45,6 +45,7 @@ #include "mymoneycategory.h" #include "mymoneyfile.h" +#include "mymoneytransactionfilter.h" #include "kmymoneyaccountcombo.h" #include "kmymoneyutils.h" #include "models.h" @@ -209,7 +210,7 @@ void KExportDlg::loadAccounts() { auto filterProxyModel = new AccountNamesFilterProxyModel(this); - filterProxyModel->addAccountGroup(QVector {MyMoneyAccount::Asset, MyMoneyAccount::Liability}); + filterProxyModel->addAccountGroup(QVector {eMyMoney::Account::Asset, eMyMoney::Account::Liability}); auto const model = Models::instance()->accountsModel(); model->load(); filterProxyModel->setSourceColumns(model->getColumns()); diff --git a/kmymoney/plugins/qif/export/mymoneyqifwriter.cpp b/kmymoney/plugins/qif/export/mymoneyqifwriter.cpp --- a/kmymoney/plugins/qif/export/mymoneyqifwriter.cpp +++ b/kmymoney/plugins/qif/export/mymoneyqifwriter.cpp @@ -40,6 +40,13 @@ // Project Headers #include "mymoneyfile.h" +#include "mymoneyaccount.h" +#include "mymoneytransaction.h" +#include "mymoneytransactionfilter.h" +#include "mymoneysplit.h" +#include "mymoneymoney.h" +#include "mymoneypayee.h" +#include "mymoneyexception.h" MyMoneyQifWriter::MyMoneyQifWriter() { @@ -164,7 +171,7 @@ QString name = acc.name(); s << "N" << leadIn << name << endl; - s << (acc.accountGroup() == MyMoneyAccount::Expense ? "E" : "I") << endl; + s << (acc.accountGroup() == eMyMoney::Account::Expense ? "E" : "I") << endl; s << "^" << endl; QStringList list = acc.accountList(); @@ -216,8 +223,8 @@ if (list.count() > 1) { MyMoneySplit sp = t.splitByAccount(accountId, false); MyMoneyAccount acc = file->account(sp.accountId()); - if (acc.accountGroup() != MyMoneyAccount::Income - && acc.accountGroup() != MyMoneyAccount::Expense) { + if (acc.accountGroup() != eMyMoney::Account::Income + && acc.accountGroup() != eMyMoney::Account::Expense) { s << "L" << m_qifProfile.accountDelimiter()[0] << MyMoneyFile::instance()->accountToCategory(sp.accountId()) << m_qifProfile.accountDelimiter()[1] << endl; @@ -242,8 +249,8 @@ s << "S"; MyMoneyAccount acc = file->account(split.accountId()); - if (acc.accountGroup() != MyMoneyAccount::Income - && acc.accountGroup() != MyMoneyAccount::Expense) { + if (acc.accountGroup() != eMyMoney::Account::Income + && acc.accountGroup() != eMyMoney::Account::Expense) { s << m_qifProfile.accountDelimiter()[0] << file->accountToCategory(split.accountId()) << m_qifProfile.accountDelimiter()[1]; @@ -290,11 +297,11 @@ bool noError = true; QList lst = t.splits(); QList::Iterator it; - MyMoneyAccount::_accountTypeE typ; + eMyMoney::Account typ; QString chkAccntId; MyMoneyMoney qty; MyMoneyMoney value; - QMap map; + QMap map; for (int i = 0; i < lst.count(); i++) { QString actionType = lst[i].action(); @@ -302,7 +309,7 @@ QString accName = acc.name(); typ = acc.accountType(); map.insert(typ, lst[i].accountId()); - if (typ == MyMoneyAccount::Stock) { + if (typ == eMyMoney::Account::Stock) { memo = lst[i].memo(); } } @@ -318,22 +325,22 @@ MyMoneyAccount acc = file->account((*it).accountId()); typ = acc.accountType(); // - // MyMoneyAccount::Checkings. + // eMyMoney::Account::Checkings. // - if ((acc.accountType() == MyMoneyAccount::Checkings) || (acc.accountType() == MyMoneyAccount::Cash)) { + if ((acc.accountType() == eMyMoney::Account::Checkings) || (acc.accountType() == eMyMoney::Account::Cash)) { chkAccntId = (*it).accountId(); chkAccnt = file->account(chkAccntId).name(); - } else if (acc.accountType() == MyMoneyAccount::Income) { + } else if (acc.accountType() == eMyMoney::Account::Income) { // - // MyMoneyAccount::Income. + // eMyMoney::Account::Income. // - } else if (acc.accountType() == MyMoneyAccount::Expense) { + } else if (acc.accountType() == eMyMoney::Account::Expense) { // - // MyMoneyAccount::Expense. + // eMyMoney::Account::Expense. // - } else if (acc.accountType() == MyMoneyAccount::Stock) { + } else if (acc.accountType() == eMyMoney::Account::Stock) { // - // MyMoneyAccount::Stock. + // eMyMoney::Account::Stock. // qty = (*it).shares(); value = (*it).value(); @@ -352,14 +359,14 @@ action = "IntIncX"; } if ((action == "DivX") || (action == "IntIncX")) { - if (map.value(MyMoneyAccount::Checkings).isEmpty()) { + if (map.value(eMyMoney::Account::Checkings).isEmpty()) { KMessageBox::sorry(0, QString("%1").arg(i18n("Transaction number %1 is missing an account assignment.\nTransaction dropped.", count)), i18n("Invalid transaction")); noError = false; return; } - MyMoneySplit sp = t.splitByAccount(map.value(MyMoneyAccount::Checkings), true); + MyMoneySplit sp = t.splitByAccount(map.value(eMyMoney::Account::Checkings), true); QString txt = sp.value().formatMoney("", 2); if (noError) { s += 'T' + txt + '\n'; diff --git a/kmymoney/plugins/qif/import/mymoneyqifreader.h b/kmymoney/plugins/qif/import/mymoneyqifreader.h --- a/kmymoney/plugins/qif/import/mymoneyqifreader.h +++ b/kmymoney/plugins/qif/import/mymoneyqifreader.h @@ -150,9 +150,9 @@ * specify the account to which the transactions should be imported. * The entry data is found in m_qifEntry. * - * @param accountType see MyMoneyAccount() for details. Defaults to MyMoneyAccount::Checkings + * @param accountType see MyMoneyAccount() for details. Defaults to eMyMoney::Account::Checkings */ - void processMSAccountEntry(const MyMoneyAccount::accountTypeE accountType = MyMoneyAccount::Checkings); + void processMSAccountEntry(const eMyMoney::Account accountType = eMyMoney::Account::Checkings); /** * This method scans the m_qifEntry object as a payee record specified by Quicken @@ -281,7 +281,7 @@ const QString transferAccount(const QString& name, bool useBrokerage = true); // void processQifLine(); - void createOpeningBalance(MyMoneyAccount::_accountTypeE accType = MyMoneyAccount::Checkings); + void createOpeningBalance(eMyMoney::Account accType = eMyMoney::Account::Checkings); signals: void statementsReady(QList &); diff --git a/kmymoney/plugins/qif/import/mymoneyqifreader.cpp b/kmymoney/plugins/qif/import/mymoneyqifreader.cpp --- a/kmymoney/plugins/qif/import/mymoneyqifreader.cpp +++ b/kmymoney/plugins/qif/import/mymoneyqifreader.cpp @@ -50,6 +50,7 @@ // Project Headers #include "mymoneyfile.h" +#include "mymoneysecurity.h" #include "kmymoneyglobalsettings.h" #include "mymoneystatement.h" @@ -69,10 +70,10 @@ { public: Private() : - accountType(MyMoneyAccount::Checkings), + accountType(eMyMoney::Account::Checkings), mapCategories(true) {} - const QString accountTypeToQif(MyMoneyAccount::accountTypeE type) const; + const QString accountTypeToQif(eMyMoney::Account type) const; /** * finalize the current statement and add it to the statement list @@ -113,7 +114,7 @@ QString st_AccountName; QString st_AccountId; - MyMoneyAccount::accountTypeE accountType; + eMyMoney::Account accountType; bool firstTransaction; bool mapCategories; MyMoneyQifReader::QifEntryTypeE transactionType; @@ -139,26 +140,26 @@ st.m_eType = type; } -const QString MyMoneyQifReader::Private::accountTypeToQif(MyMoneyAccount::accountTypeE type) const +const QString MyMoneyQifReader::Private::accountTypeToQif(eMyMoney::Account type) const { QString rc = "Bank"; switch (type) { default: break; - case MyMoneyAccount::Cash: + case eMyMoney::Account::Cash: rc = "Cash"; break; - case MyMoneyAccount::CreditCard: + case eMyMoney::Account::CreditCard: rc = "CCard"; break; - case MyMoneyAccount::Asset: + case eMyMoney::Account::Asset: rc = "Oth A"; break; - case MyMoneyAccount::Liability: + case eMyMoney::Account::Liability: rc = "Oth L"; break; - case MyMoneyAccount::Investment: + case eMyMoney::Account::Investment: rc = "Port"; break; } @@ -498,32 +499,32 @@ // exportable accounts if (line.toLower() == "ccard" || KMyMoneyGlobalSettings::qifCreditCard().toLower().contains(line.toLower())) { - d->accountType = MyMoneyAccount::CreditCard; + d->accountType = eMyMoney::Account::CreditCard; d->firstTransaction = true; d->transactionType = m_entryType = EntryTransaction; } else if (line.toLower() == "bank" || KMyMoneyGlobalSettings::qifBank().toLower().contains(line.toLower())) { - d->accountType = MyMoneyAccount::Checkings; + d->accountType = eMyMoney::Account::Checkings; d->firstTransaction = true; d->transactionType = m_entryType = EntryTransaction; } else if (line.toLower() == "cash" || KMyMoneyGlobalSettings::qifCash().toLower().contains(line.toLower())) { - d->accountType = MyMoneyAccount::Cash; + d->accountType = eMyMoney::Account::Cash; d->firstTransaction = true; d->transactionType = m_entryType = EntryTransaction; } else if (line.toLower() == "oth a" || KMyMoneyGlobalSettings::qifAsset().toLower().contains(line.toLower())) { - d->accountType = MyMoneyAccount::Asset; + d->accountType = eMyMoney::Account::Asset; d->firstTransaction = true; d->transactionType = m_entryType = EntryTransaction; } else if (line.toLower() == "oth l" || line.toLower() == i18nc("QIF tag for liability account", "Oth L").toLower()) { - d->accountType = MyMoneyAccount::Liability; + d->accountType = eMyMoney::Account::Liability; d->firstTransaction = true; d->transactionType = m_entryType = EntryTransaction; } else if (line.toLower() == "invst" || line.toLower() == i18nc("QIF tag for investment account", "Invst").toLower()) { - d->accountType = MyMoneyAccount::Investment; + d->accountType = eMyMoney::Account::Investment; d->transactionType = m_entryType = EntryInvestmentTransaction; } else if (line.toLower() == "invoice" || KMyMoneyGlobalSettings::qifInvoice().toLower().contains(line.toLower())) { @@ -700,7 +701,7 @@ } #if 0 -void MyMoneyQifReader::processMSAccountEntry(const MyMoneyAccount::accountTypeE accountType) +void MyMoneyQifReader::processMSAccountEntry(const eMyMoney::Account accountType) { if (extractLine('P').toLower() == m_qifProfile.openingBalanceText().toLower()) { m_account = MyMoneyAccount(); @@ -829,10 +830,10 @@ // so also have to test that either the 'I' or 'E' was detected //and set up accounts accordingly. if ((!extractLine('I').isEmpty()) || (m_extractedLine != -1)) { - account.setAccountType(MyMoneyAccount::Income); + account.setAccountType(eMyMoney::Account::Income); parentAccount = file->income(); } else if ((!extractLine('E').isEmpty()) || (m_extractedLine != -1)) { - account.setAccountType(MyMoneyAccount::Expense); + account.setAccountType(eMyMoney::Account::Expense); parentAccount = file->expense(); } @@ -891,7 +892,7 @@ continue; const MyMoneyAccount& existingAccount = file->subAccountByName(parentAccount, name); if (!existingAccount.id().isEmpty()) { - if (acc.accountType() != MyMoneyAccount::UnknownAccountType) { + if (acc.accountType() != eMyMoney::Account::Unknown) { if (acc.accountType() != existingAccount.accountType()) continue; } @@ -919,7 +920,7 @@ // in case we found a reference to an investment account, we need // to switch to the brokerage account instead. MyMoneyAccount acc = MyMoneyFile::instance()->account(accountId); - if (useBrokerage && (acc.accountType() == MyMoneyAccount::Investment)) { + if (useBrokerage && (acc.accountType() == eMyMoney::Account::Investment)) { m_qifEntry.clear(); // and construct a temp entry to create/search the account m_qifEntry << QString("N%1").arg(acc.brokerageName()); m_qifEntry << QString("Tunknown"); @@ -932,7 +933,7 @@ return accountId; } -void MyMoneyQifReader::createOpeningBalance(MyMoneyAccount::_accountTypeE accType) +void MyMoneyQifReader::createOpeningBalance(eMyMoney::Account accType) { MyMoneyFile* file = MyMoneyFile::instance(); @@ -1056,16 +1057,16 @@ s1.m_accountId = d->st.m_accountId; switch (d->accountType) { - case MyMoneyAccount::Checkings: + case eMyMoney::Account::Checkings: d->st.m_eType=MyMoneyStatement::etCheckings; break; - case MyMoneyAccount::Savings: + case eMyMoney::Account::Savings: d->st.m_eType=MyMoneyStatement::etSavings; break; - case MyMoneyAccount::Investment: + case eMyMoney::Account::Investment: d->st.m_eType=MyMoneyStatement::etInvestment; break; - case MyMoneyAccount::CreditCard: + case eMyMoney::Account::CreditCard: d->st.m_eType=MyMoneyStatement::etCreditCard; break; default: @@ -1185,7 +1186,7 @@ MyMoneyAccount account = file->account(accountId); // FIXME: check that the type matches and ask if not - if (account.accountType() == MyMoneyAccount::Investment) { + if (account.accountType() == eMyMoney::Account::Investment) { qDebug() << "Line " << m_linenumber << ": Cannot transfer to/from an investment account. Transaction ignored."; return; } @@ -1231,7 +1232,7 @@ MyMoneyAccount account = file->account(accountId); // FIXME: check that the type matches and ask if not - if (account.accountType() == MyMoneyAccount::Investment) { + if (account.accountType() == eMyMoney::Account::Investment) { qDebug() << "Line " << m_linenumber << ": Cannot convert a split transfer to/from an investment account. Split removed. Total amount adjusted from " << tr.m_amount.formatMoney("", 2) << " to " << (tr.m_amount + s2.m_amount).formatMoney("", 2) << "\n"; tr.m_amount += s2.m_amount; continue; @@ -1539,7 +1540,7 @@ } else if (action == "xin" || action == "xout") { QString payee = extractLine('P'); if (!payee.isEmpty() && ((payee.toLower() == "opening balance") || KMyMoneyGlobalSettings::qifOpeningBalance().toLower().contains(payee.toLower()))) { - createOpeningBalance(MyMoneyAccount::Investment); + createOpeningBalance(eMyMoney::Account::Investment); return; } @@ -1841,7 +1842,7 @@ if (result.isEmpty()) { MyMoneyAccount acc; acc.setName(searchname); - acc.setAccountType(MyMoneyAccount::Income); + acc.setAccountType(eMyMoney::Account::Income); MyMoneyAccount income = file->income(); MyMoneyFileTransaction ft; file->addAccount(acc, income); @@ -1877,7 +1878,7 @@ if (result.isEmpty()) { MyMoneyAccount acc; acc.setName(searchname); - acc.setAccountType(MyMoneyAccount::Expense); + acc.setAccountType(eMyMoney::Account::Expense); MyMoneyFileTransaction ft; MyMoneyAccount expense = file->expense(); file->addAccount(acc, expense); @@ -1911,25 +1912,25 @@ QifEntryTypeE transactionType = EntryTransaction; QString type = extractLine('T').toLower().remove(QRegExp("\\s+")); if (type == m_qifProfile.profileType().toLower().remove(QRegExp("\\s+"))) { - account.setAccountType(MyMoneyAccount::Checkings); + account.setAccountType(eMyMoney::Account::Checkings); } else if (type == "ccard" || type == "creditcard") { - account.setAccountType(MyMoneyAccount::CreditCard); + account.setAccountType(eMyMoney::Account::CreditCard); } else if (type == "cash") { - account.setAccountType(MyMoneyAccount::Cash); + account.setAccountType(eMyMoney::Account::Cash); } else if (type == "otha") { - account.setAccountType(MyMoneyAccount::Asset); + account.setAccountType(eMyMoney::Account::Asset); } else if (type == "othl") { - account.setAccountType(MyMoneyAccount::Liability); + account.setAccountType(eMyMoney::Account::Liability); } else if (type == "invst" || type == "port") { - account.setAccountType(MyMoneyAccount::Investment); + account.setAccountType(eMyMoney::Account::Investment); transactionType = EntryInvestmentTransaction; } else if (type == "mutual") { // stock account w/o umbrella investment account - account.setAccountType(MyMoneyAccount::Stock); + account.setAccountType(eMyMoney::Account::Stock); transactionType = EntryInvestmentTransaction; } else if (type == "unknown") { // don't do anything with the type, leave it unknown } else { - account.setAccountType(MyMoneyAccount::Checkings); + account.setAccountType(eMyMoney::Account::Checkings); qDebug() << "Line " << m_linenumber << ": Unknown account type '" << type << "', checkings assumed"; } @@ -1939,8 +1940,8 @@ // in case the account is not found by name and the type is // unknown, we have to assume something and create a checking account. // this might be wrong, but we have no choice at this point. - if (account.accountType() == MyMoneyAccount::UnknownAccountType) - account.setAccountType(MyMoneyAccount::Checkings); + if (account.accountType() == eMyMoney::Account::Unknown) + account.setAccountType(eMyMoney::Account::Checkings); MyMoneyAccount parentAccount; MyMoneyAccount brokerage; @@ -1948,7 +1949,7 @@ if (account.isInvest()) { acc.setName(i18n("%1 (Investment)", account.name())); // use the same name for the investment account acc.setDescription(i18n("Autogenerated by QIF importer from type Mutual account entry")); - acc.setAccountType(MyMoneyAccount::Investment); + acc.setAccountType(eMyMoney::Account::Investment); parentAccount = file->asset(); file->createAccount(acc, parentAccount, brokerage, MyMoneyMoney()); parentAccount = acc; @@ -1956,14 +1957,14 @@ } else { // setup parent according the type of the account switch (account.accountGroup()) { - case MyMoneyAccount::Asset: + case eMyMoney::Account::Asset: default: parentAccount = file->asset(); break; - case MyMoneyAccount::Liability: + case eMyMoney::Account::Liability: parentAccount = file->liability(); break; - case MyMoneyAccount::Equity: + case eMyMoney::Account::Equity: parentAccount = file->equity(); break; } @@ -1972,9 +1973,9 @@ // investment accounts will receive a brokerage account, as KMyMoney // currently does not allow to store funds in the investment account directly // but only create it (not here, but later) if it is needed - if (account.accountType() == MyMoneyAccount::Investment) { + if (account.accountType() == eMyMoney::Account::Investment) { brokerage.setName(QString()); // brokerage name empty so account not created yet - brokerage.setAccountType(MyMoneyAccount::Checkings); + brokerage.setAccountType(eMyMoney::Account::Checkings); brokerage.setCurrencyId(MyMoneyFile::instance()->baseCurrency().id()); } file->createAccount(account, parentAccount, brokerage, MyMoneyMoney()); diff --git a/kmymoney/plugins/reconciliationreport/reconciliationreport.cpp b/kmymoney/plugins/reconciliationreport/reconciliationreport.cpp --- a/kmymoney/plugins/reconciliationreport/reconciliationreport.cpp +++ b/kmymoney/plugins/reconciliationreport/reconciliationreport.cpp @@ -187,8 +187,8 @@ // retrieve list of all transactions after the reconciliation date that are not reconciled or cleared QList > afterTransactionList; MyMoneyTransactionFilter filter(account.id()); - filter.addState(MyMoneyTransactionFilter::cleared); - filter.addState(MyMoneyTransactionFilter::notReconciled); + filter.addState((int)eMyMoney::TransactionFilter::State::Cleared); + filter.addState((int)eMyMoney::TransactionFilter::State::NotReconciled); filter.setDateFilter(date.addDays(1), QDate()); filter.setConsiderCategory(false); filter.setReportAllSplits(true); diff --git a/kmymoney/reports/kreportchartview.cpp b/kmymoney/reports/kreportchartview.cpp --- a/kmymoney/reports/kreportchartview.cpp +++ b/kmymoney/reports/kreportchartview.cpp @@ -46,6 +46,7 @@ #include "kmymoneyglobalsettings.h" #include #include "mymoneyfile.h" +#include "mymoneysecurity.h" using namespace reports; @@ -296,7 +297,7 @@ PivotInnerGroup::const_iterator it_row = (*it_innergroup).begin(); while (it_row != (*it_innergroup).end()) { //Do not include investments accounts in the chart because they are merely container of stock and other accounts - if (it_row.key().accountType() != MyMoneyAccount::Investment) { + if (it_row.key().accountType() != eMyMoney::Account::Investment) { // get displayed precision int currencyPrecision = precision; diff --git a/kmymoney/reports/listtable.h b/kmymoney/reports/listtable.h --- a/kmymoney/reports/listtable.h +++ b/kmymoney/reports/listtable.h @@ -22,6 +22,8 @@ // ---------------------------------------------------------------------------- // QT Includes +#include + // ---------------------------------------------------------------------------- // KDE Includes diff --git a/kmymoney/reports/listtable.cpp b/kmymoney/reports/listtable.cpp --- a/kmymoney/reports/listtable.cpp +++ b/kmymoney/reports/listtable.cpp @@ -36,6 +36,9 @@ // Project Includes #include "mymoneyfile.h" +#include "mymoneyaccount.h" +#include "mymoneysecurity.h" +#include "mymoneytransaction.h" #include "mymoneyreport.h" #include "kmymoneyglobalsettings.h" @@ -484,7 +487,7 @@ file->accountList(accountList); QList::const_iterator it_ma; for (it_ma = accountList.constBegin(); it_ma != accountList.constEnd(); ++it_ma) { - if ((*it_ma).accountType() == MyMoneyAccount::Investment) { + if ((*it_ma).accountType() == eMyMoney::Account::Investment) { accountIdList.append((*it_ma).id()); } } @@ -493,7 +496,7 @@ QStringList::const_iterator it_a; for (it_a = accountIdList.constBegin(); it_a != accountIdList.constEnd(); ++it_a) { MyMoneyAccount acc = file->account(*it_a); - if (acc.accountType() == MyMoneyAccount::Investment) { + if (acc.accountType() == eMyMoney::Account::Investment) { QStringList::const_iterator it_b; for (it_b = acc.accountList().constBegin(); it_b != acc.accountList().constEnd(); ++it_b) { if (!accountIdList.contains(*it_b)) { diff --git a/kmymoney/reports/objectinfotable.cpp b/kmymoney/reports/objectinfotable.cpp --- a/kmymoney/reports/objectinfotable.cpp +++ b/kmymoney/reports/objectinfotable.cpp @@ -32,6 +32,12 @@ // Project Includes #include "mymoneyfile.h" +#include "mymoneyaccount.h" +#include "mymoneyinstitution.h" +#include "mymoneyprice.h" +#include "mymoneypayee.h" +#include "mymoneysplit.h" +#include "mymoneytransaction.h" #include "mymoneyreport.h" #include "mymoneyexception.h" #include "kmymoneyutils.h" @@ -141,7 +147,7 @@ QList schedules; - schedules = file->scheduleList("", MyMoneySchedule::TYPE_ANY, MyMoneySchedule::OCCUR_ANY, MyMoneySchedule::STYPE_ANY, m_config.fromDate(), m_config.toDate()); + schedules = file->scheduleList(QString(), eMyMoney::Schedule::Type::Any, eMyMoney::Schedule::Occurrence::Any, eMyMoney::Schedule::PaymentType::Any, m_config.fromDate(), m_config.toDate(), false); QList::const_iterator it_schedule = schedules.constBegin(); while (it_schedule != schedules.constEnd()) { @@ -246,7 +252,7 @@ ReportAccount account = *it_account; if (m_config.includes(account) - && account.accountType() != MyMoneyAccount::Stock + && account.accountType() != eMyMoney::Account::Stock && !account.isClosed()) { MyMoneyMoney value; accountRow[ctRank] = QLatin1Char('0'); @@ -268,7 +274,7 @@ accountRow[ctFavorite] = account.value("PreferredAccount") == QLatin1String("Yes") ? i18nc("Is this a favorite account?", "Yes") : QString(); //investment accounts show the balances of all its subaccounts - if (account.accountType() == MyMoneyAccount::Investment) { + if (account.accountType() == eMyMoney::Account::Investment) { value = investmentBalance(account); } else { value = file->balance(account.id()); diff --git a/kmymoney/reports/pivottable.h b/kmymoney/reports/pivottable.h --- a/kmymoney/reports/pivottable.h +++ b/kmymoney/reports/pivottable.h @@ -235,13 +235,13 @@ * actual amount. The calculation is based on the type of the * @a repAccount. The difference value is calculated as follows: * - * If @a repAccount is of type MyMoneyAccount::Income + * If @a repAccount is of type eMyMoney::Account::Income * * @code * diff = actual - budgeted * @endcode * - * If @a repAccount is of type MyMoneyAccount::Expense + * If @a repAccount is of type eMyMoney::Account::Expense * * @code * diff = budgeted - actual diff --git a/kmymoney/reports/pivottable.cpp b/kmymoney/reports/pivottable.cpp --- a/kmymoney/reports/pivottable.cpp +++ b/kmymoney/reports/pivottable.cpp @@ -130,11 +130,11 @@ // Initialize outer groups of the grid // if (m_config.rowType() == MyMoneyReport::eAssetLiability) { - m_grid.insert(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Asset), PivotOuterGroup(m_numColumns)); - m_grid.insert(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Liability), PivotOuterGroup(m_numColumns, PivotOuterGroup::m_kDefaultSortOrder, true /* inverted */)); + m_grid.insert(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Asset), PivotOuterGroup(m_numColumns)); + m_grid.insert(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Liability), PivotOuterGroup(m_numColumns, PivotOuterGroup::m_kDefaultSortOrder, true /* inverted */)); } else { - m_grid.insert(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Income), PivotOuterGroup(m_numColumns, PivotOuterGroup::m_kDefaultSortOrder - 2)); - m_grid.insert(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Expense), PivotOuterGroup(m_numColumns, PivotOuterGroup::m_kDefaultSortOrder - 1, true /* inverted */)); + m_grid.insert(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Income), PivotOuterGroup(m_numColumns, PivotOuterGroup::m_kDefaultSortOrder - 2)); + m_grid.insert(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Expense), PivotOuterGroup(m_numColumns, PivotOuterGroup::m_kDefaultSortOrder - 1, true /* inverted */)); // // Create rows for income/expense reports with all accounts included // @@ -269,7 +269,7 @@ const MyMoneySplit& split = tx.amortizationSplit(); if (!split.id().isEmpty()) { ReportAccount splitAccount = file->account(split.accountId()); - MyMoneyAccount::accountTypeE type = splitAccount.accountGroup(); + eMyMoney::Account type = splitAccount.accountGroup(); QString outergroup = KMyMoneyUtils::accountTypeToString(type); //if the account is included in the report, calculate the balance from the cells @@ -315,7 +315,7 @@ MyMoneyMoney value; // the outer group is the account class (major account type) - MyMoneyAccount::accountTypeE type = splitAccount.accountGroup(); + eMyMoney::Account type = splitAccount.accountGroup(); QString outergroup = KMyMoneyUtils::accountTypeToString(type); value = (*it_split).shares(); @@ -330,7 +330,7 @@ } // Except in the case of transfers on an income/expense report - if (al_transfers && (type == MyMoneyAccount::Asset || type == MyMoneyAccount::Liability)) { + if (al_transfers && (type == eMyMoney::Account::Asset || type == eMyMoney::Account::Liability)) { outergroup = i18n("Transfers"); value = -value; } @@ -884,11 +884,11 @@ //include the budget account only if it is included in the report if (m_config.includes(splitAccount)) { - MyMoneyAccount::accountTypeE type = splitAccount.accountGroup(); + eMyMoney::Account type = splitAccount.accountGroup(); QString outergroup = KMyMoneyUtils::accountTypeToString(type); // reverse sign to match common notation for cash flow direction, only for expense/income splits - MyMoneyMoney reverse((splitAccount.accountType() == MyMoneyAccount::Expense) ? -1 : 1, 1); + MyMoneyMoney reverse((splitAccount.accountType() == eMyMoney::Account::Expense) ? -1 : 1, 1); const QMap& periods = (*it_bacc).getPeriods(); @@ -1402,7 +1402,7 @@ for (int i = 0; i < m_rowTypeList.size(); ++i) isUsed |= it_row.value()[ m_rowTypeList[i] ][0].isUsed(); - if (it_row.key().accountType() != MyMoneyAccount::Investment) { + if (it_row.key().accountType() != eMyMoney::Account::Investment) { while (column < m_numColumns) { //show columns @@ -1703,7 +1703,7 @@ pricePrecision = 0; // new row => new account => new precision currencyPrecision = 0; bool isUsed = it_row.value()[eActual][0].isUsed(); - if (it_row.key().accountType() != MyMoneyAccount::Investment) { + if (it_row.key().accountType() != eMyMoney::Account::Investment) { while (column < m_numColumns) { QString lb; if (column > 0) @@ -1964,15 +1964,15 @@ while (it_row != (*it_innergroup).end()) { int column = m_startColumn; switch (it_row.key().accountGroup()) { - case MyMoneyAccount::Income: - case MyMoneyAccount::Asset: + case eMyMoney::Account::Income: + case eMyMoney::Account::Asset: while (column < m_numColumns) { it_row.value()[eBudgetDiff][column] = it_row.value()[eActual][column] - it_row.value()[eBudget][column]; ++column; } break; - case MyMoneyAccount::Expense: - case MyMoneyAccount::Liability: + case eMyMoney::Account::Expense: + case eMyMoney::Account::Liability: while (column < m_numColumns) { it_row.value()[eBudgetDiff][column] = it_row.value()[eBudget][column] - it_row.value()[eActual][column]; ++column; @@ -2297,7 +2297,7 @@ QStringList::const_iterator it_a, it_b; for (it_a = accountList.constBegin(); it_a != accountList.constEnd(); ++it_a) { MyMoneyAccount acc = MyMoneyFile::instance()->account(*it_a); - if (acc.accountType() == MyMoneyAccount::Investment) { + if (acc.accountType() == eMyMoney::Account::Investment) { for (it_b = acc.accountList().constBegin(); it_b != acc.accountList().constEnd(); ++it_b) { if (!accountList.contains(*it_b)) { m_config.addAccount(*it_b); diff --git a/kmymoney/reports/querytable.cpp b/kmymoney/reports/querytable.cpp --- a/kmymoney/reports/querytable.cpp +++ b/kmymoney/reports/querytable.cpp @@ -42,6 +42,11 @@ // Project Includes #include "mymoneyfile.h" +#include "mymoneyaccount.h" +#include "mymoneyinstitution.h" +#include "mymoneyprice.h" +#include "mymoneypayee.h" +#include "mymoneytag.h" #include "mymoneytransaction.h" #include "mymoneyreport.h" #include "mymoneyexception.h" @@ -1688,7 +1693,7 @@ // Note, "Investment" accounts are never included in account rows because // they don't contain anything by themselves. In reports, they are only // useful as a "topaccount" aggregator of stock accounts - if ((*it_account).isAssetLiability() && m_config.includes((*it_account)) && (*it_account).accountType() != MyMoneyAccount::Investment) { + if ((*it_account).isAssetLiability() && m_config.includes((*it_account)) && (*it_account).accountType() != eMyMoney::Account::Investment) { // don't add the account if it is closed. In fact, the business logic // should prevent that an account can be closed with a balance not equal // to zero, but we never know. diff --git a/kmymoney/reports/reportaccount.cpp b/kmymoney/reports/reportaccount.cpp --- a/kmymoney/reports/reportaccount.cpp +++ b/kmymoney/reports/reportaccount.cpp @@ -27,13 +27,14 @@ // without using this macro directly, I'll be freed of KDE dependency. This // is a minor problem because we use these terms when rendering to HTML, // and a more major problem because we need it to translate account types -// (e.g. MyMoneyAccount::Checkings) into their text representation. We also +// (e.g. eMyMoney::Account::Checkings) into their text representation. We also // use that text representation in the core data structure of the report. (Ace) // ---------------------------------------------------------------------------- // Project Includes #include "mymoneyfile.h" +#include "mymoneyprice.h" #include "mymoneysecurity.h" #include "reportdebug.h" @@ -322,7 +323,7 @@ bool ReportAccount::isLiquidLiability() const { - return accountType() == MyMoneyAccount::CreditCard; + return accountType() == eMyMoney::Account::CreditCard; } diff --git a/kmymoney/reports/reporttable.h b/kmymoney/reports/reporttable.h --- a/kmymoney/reports/reporttable.h +++ b/kmymoney/reports/reporttable.h @@ -21,6 +21,8 @@ // ---------------------------------------------------------------------------- // QT Includes +#include + // ---------------------------------------------------------------------------- // KDE Includes diff --git a/kmymoney/reports/tests/pivotgrid-test.cpp b/kmymoney/reports/tests/pivotgrid-test.cpp --- a/kmymoney/reports/tests/pivotgrid-test.cpp +++ b/kmymoney/reports/tests/pivotgrid-test.cpp @@ -50,16 +50,16 @@ acLiability = (MyMoneyFile::instance()->liability().id()); acExpense = (MyMoneyFile::instance()->expense().id()); acIncome = (MyMoneyFile::instance()->income().id()); - acChecking = makeAccount(QString("Checking Account"), MyMoneyAccount::Checkings, moCheckingOpen, QDate(2004, 5, 15), acAsset); - acCredit = makeAccount(QString("Credit Card"), MyMoneyAccount::CreditCard, moCreditOpen, QDate(2004, 7, 15), acLiability); - acSolo = makeAccount(QString("Solo"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); - acParent = makeAccount(QString("Parent"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); - acChild = makeAccount(QString("Child"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acParent); - acForeign = makeAccount(QString("Foreign"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); - - acSecondChild = makeAccount(QString("Second Child"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acParent); - acGrandChild1 = makeAccount(QString("Grand Child 1"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acChild); - acGrandChild2 = makeAccount(QString("Grand Child 2"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acChild); + acChecking = makeAccount(QString("Checking Account"), eMyMoney::Account::Checkings, moCheckingOpen, QDate(2004, 5, 15), acAsset); + acCredit = makeAccount(QString("Credit Card"), eMyMoney::Account::CreditCard, moCreditOpen, QDate(2004, 7, 15), acLiability); + acSolo = makeAccount(QString("Solo"), eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); + acParent = makeAccount(QString("Parent"), eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); + acChild = makeAccount(QString("Child"), eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acParent); + acForeign = makeAccount(QString("Foreign"), eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); + + acSecondChild = makeAccount(QString("Second Child"), eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acParent); + acGrandChild1 = makeAccount(QString("Grand Child 1"), eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acChild); + acGrandChild2 = makeAccount(QString("Grand Child 2"), eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acChild); MyMoneyInstitution i("Bank of the World", "", "", "", "", "", ""); file->addInstitution(i); diff --git a/kmymoney/reports/tests/pivottable-test.cpp b/kmymoney/reports/tests/pivottable-test.cpp --- a/kmymoney/reports/tests/pivottable-test.cpp +++ b/kmymoney/reports/tests/pivottable-test.cpp @@ -62,16 +62,16 @@ acLiability = (MyMoneyFile::instance()->liability().id()); acExpense = (MyMoneyFile::instance()->expense().id()); acIncome = (MyMoneyFile::instance()->income().id()); - acChecking = makeAccount(QString("Checking Account"), MyMoneyAccount::Checkings, moCheckingOpen, QDate(2004, 5, 15), acAsset); - acCredit = makeAccount(QString("Credit Card"), MyMoneyAccount::CreditCard, moCreditOpen, QDate(2004, 7, 15), acLiability); - acSolo = makeAccount(QString("Solo"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); - acParent = makeAccount(QString("Parent"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); - acChild = makeAccount(QString("Child"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acParent); - acForeign = makeAccount(QString("Foreign"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); + acChecking = makeAccount(QString("Checking Account"), eMyMoney::Account::Checkings, moCheckingOpen, QDate(2004, 5, 15), acAsset); + acCredit = makeAccount(QString("Credit Card"), eMyMoney::Account::CreditCard, moCreditOpen, QDate(2004, 7, 15), acLiability); + acSolo = makeAccount(QString("Solo"), eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); + acParent = makeAccount(QString("Parent"), eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); + acChild = makeAccount(QString("Child"), eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acParent); + acForeign = makeAccount(QString("Foreign"), eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); - acSecondChild = makeAccount(QString("Second Child"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acParent); - acGrandChild1 = makeAccount(QString("Grand Child 1"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acChild); - acGrandChild2 = makeAccount(QString("Grand Child 2"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acChild); + acSecondChild = makeAccount(QString("Second Child"), eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acParent); + acGrandChild1 = makeAccount(QString("Grand Child 1"), eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acChild); + acGrandChild2 = makeAccount(QString("Grand Child 2"), eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acChild); MyMoneyInstitution i("Bank of the World", "", "", "", "", "", ""); file->addInstitution(i); @@ -178,9 +178,9 @@ void PivotTableTest::testNetWorthOpening() { MyMoneyMoney openingBalance(12000000); - auto acBasicAccount = makeAccount(QString("Basic Account"), MyMoneyAccount::Checkings, openingBalance, QDate(2016, 1, 1), acAsset); - auto ctBasicIncome = makeAccount(QString("Basic Income"), MyMoneyAccount::Income, MyMoneyMoney(), QDate(2016, 1, 1), acIncome); - auto ctBasicExpense = makeAccount(QString("Basic Expense"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2016, 1, 1), acExpense); + auto acBasicAccount = makeAccount(QString("Basic Account"), eMyMoney::Account::Checkings, openingBalance, QDate(2016, 1, 1), acAsset); + auto ctBasicIncome = makeAccount(QString("Basic Income"), eMyMoney::Account::Income, MyMoneyMoney(), QDate(2016, 1, 1), acIncome); + auto ctBasicExpense = makeAccount(QString("Basic Expense"), eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2016, 1, 1), acExpense); TransactionHelper t1(QDate(2016, 7, 1), MyMoneySplit::ActionDeposit, MyMoneyMoney(-6200000), acBasicAccount, ctBasicIncome); TransactionHelper t2(QDate(2016, 8, 1), MyMoneySplit::ActionDeposit, MyMoneyMoney(-200000), acBasicAccount, ctBasicIncome); @@ -425,10 +425,10 @@ MyMoneyMoney moCanTransaction(100.0, 10); MyMoneyMoney moJpyTransaction(100.0, 10); - QString acCanChecking = makeAccount(QString("Canadian Checking"), MyMoneyAccount::Checkings, moCanOpening, QDate(2003, 11, 15), acAsset, "CAD"); - QString acJpyChecking = makeAccount(QString("Japanese Checking"), MyMoneyAccount::Checkings, moJpyOpening, QDate(2003, 11, 15), acAsset, "JPY"); - QString acCanCash = makeAccount(QString("Canadian"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acForeign, "CAD"); - QString acJpyCash = makeAccount(QString("Japanese"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acForeign, "JPY"); + QString acCanChecking = makeAccount(QString("Canadian Checking"), eMyMoney::Account::Checkings, moCanOpening, QDate(2003, 11, 15), acAsset, "CAD"); + QString acJpyChecking = makeAccount(QString("Japanese Checking"), eMyMoney::Account::Checkings, moJpyOpening, QDate(2003, 11, 15), acAsset, "JPY"); + QString acCanCash = makeAccount(QString("Canadian"), eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acForeign, "CAD"); + QString acJpyCash = makeAccount(QString("Japanese"), eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acForeign, "JPY"); makePrice("CAD", QDate(2004, 1, 1), MyMoneyMoney(moCanPrice)); makePrice("JPY", QDate(2004, 1, 1), MyMoneyMoney(moJpyPrice)); @@ -657,20 +657,20 @@ MyMoneyReport filter; filter.setRowType(MyMoneyReport::eExpenseIncome); filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); - filter.addState(MyMoneyTransactionFilter::cleared); + filter.addState((int)eMyMoney::TransactionFilter::State::Cleared); XMLandback(filter); PivotTable spending_f(filter); QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo); - filter.addState(MyMoneyTransactionFilter::reconciled); + filter.addState((int)eMyMoney::TransactionFilter::State::Reconciled); XMLandback(filter); PivotTable spending_f2(filter); QVERIFY(spending_f2.m_grid.m_total[eActual].m_total == -moSolo - moParent1); filter.clearTransactionFilter(); - filter.addState(MyMoneyTransactionFilter::notReconciled); + filter.addState((int)eMyMoney::TransactionFilter::State::NotReconciled); XMLandback(filter); PivotTable spending_f3(filter); @@ -901,10 +901,10 @@ eqStock2 = makeEquity("Stock2", "STK2"); // Accounts - acInvestment = makeAccount("Investment", MyMoneyAccount::Investment, moZero, QDate(2004, 1, 1), acAsset); - acStock1 = makeAccount("Stock 1", MyMoneyAccount::Stock, moZero, QDate(2004, 1, 1), acInvestment, eqStock1); - acStock2 = makeAccount("Stock 2", MyMoneyAccount::Stock, moZero, QDate(2004, 1, 1), acInvestment, eqStock2); - acDividends = makeAccount("Dividends", MyMoneyAccount::Income, moZero, QDate(2004, 1, 1), acIncome); + acInvestment = makeAccount("Investment", eMyMoney::Account::Investment, moZero, QDate(2004, 1, 1), acAsset); + acStock1 = makeAccount("Stock 1", eMyMoney::Account::Stock, moZero, QDate(2004, 1, 1), acInvestment, eqStock1); + acStock2 = makeAccount("Stock 2", eMyMoney::Account::Stock, moZero, QDate(2004, 1, 1), acInvestment, eqStock2); + acDividends = makeAccount("Dividends", eMyMoney::Account::Income, moZero, QDate(2004, 1, 1), acIncome); // Transactions // Date Action Shares Price Stock Asset Income diff --git a/kmymoney/reports/tests/querytable-test.cpp b/kmymoney/reports/tests/querytable-test.cpp --- a/kmymoney/reports/tests/querytable-test.cpp +++ b/kmymoney/reports/tests/querytable-test.cpp @@ -58,13 +58,13 @@ acLiability = (MyMoneyFile::instance()->liability().id()); acExpense = (MyMoneyFile::instance()->expense().id()); acIncome = (MyMoneyFile::instance()->income().id()); - acChecking = makeAccount(QString("Checking Account"), MyMoneyAccount::Checkings, moCheckingOpen, QDate(2004, 5, 15), acAsset); - acCredit = makeAccount(QString("Credit Card"), MyMoneyAccount::CreditCard, moCreditOpen, QDate(2004, 7, 15), acLiability); - acSolo = makeAccount(QString("Solo"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); - acParent = makeAccount(QString("Parent"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); - acChild = makeAccount(QString("Child"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acParent); - acForeign = makeAccount(QString("Foreign"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); - acTax = makeAccount(QString("Tax"), MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2005, 1, 11), acExpense, "", true); + acChecking = makeAccount(QString("Checking Account"), eMyMoney::Account::Checkings, moCheckingOpen, QDate(2004, 5, 15), acAsset); + acCredit = makeAccount(QString("Credit Card"), eMyMoney::Account::CreditCard, moCreditOpen, QDate(2004, 7, 15), acLiability); + acSolo = makeAccount(QString("Solo"), eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); + acParent = makeAccount(QString("Parent"), eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); + acChild = makeAccount(QString("Child"), eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acParent); + acForeign = makeAccount(QString("Foreign"), eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); + acTax = makeAccount(QString("Tax"), eMyMoney::Account::Expense, MyMoneyMoney(), QDate(2005, 1, 11), acExpense, "", true); MyMoneyInstitution i("Bank of the World", "", "", "", "", "", ""); file->addInstitution(i); @@ -413,14 +413,14 @@ eqStock4 = makeEquity("Stock4", "STK4"); // Accounts - acInvestment = makeAccount("Investment", MyMoneyAccount::Investment, moZero, QDate(2003, 11, 1), acAsset); - acStock1 = makeAccount("Stock 1", MyMoneyAccount::Stock, moZero, QDate(2004, 1, 1), acInvestment, eqStock1); - acStock2 = makeAccount("Stock 2", MyMoneyAccount::Stock, moZero, QDate(2004, 1, 1), acInvestment, eqStock2); - acStock3 = makeAccount("Stock 3", MyMoneyAccount::Stock, moZero, QDate(2003, 11, 1), acInvestment, eqStock3); - acStock4 = makeAccount("Stock 4", MyMoneyAccount::Stock, moZero, QDate(2004, 1, 1), acInvestment, eqStock4); - acDividends = makeAccount("Dividends", MyMoneyAccount::Income, moZero, QDate(2004, 1, 1), acIncome); - acInterest = makeAccount("Interest", MyMoneyAccount::Income, moZero, QDate(2004, 1, 1), acIncome); - acFees = makeAccount("Fees", MyMoneyAccount::Expense, moZero, QDate(2003, 11, 1), acExpense); + acInvestment = makeAccount("Investment", eMyMoney::Account::Investment, moZero, QDate(2003, 11, 1), acAsset); + acStock1 = makeAccount("Stock 1", eMyMoney::Account::Stock, moZero, QDate(2004, 1, 1), acInvestment, eqStock1); + acStock2 = makeAccount("Stock 2", eMyMoney::Account::Stock, moZero, QDate(2004, 1, 1), acInvestment, eqStock2); + acStock3 = makeAccount("Stock 3", eMyMoney::Account::Stock, moZero, QDate(2003, 11, 1), acInvestment, eqStock3); + acStock4 = makeAccount("Stock 4", eMyMoney::Account::Stock, moZero, QDate(2004, 1, 1), acInvestment, eqStock4); + acDividends = makeAccount("Dividends", eMyMoney::Account::Income, moZero, QDate(2004, 1, 1), acIncome); + acInterest = makeAccount("Interest", eMyMoney::Account::Income, moZero, QDate(2004, 1, 1), acIncome); + acFees = makeAccount("Fees", eMyMoney::Account::Expense, moZero, QDate(2003, 11, 1), acExpense); // Transactions // Date Action Shares Price Stock Asset Income @@ -616,8 +616,8 @@ eqStock1 = makeEquity("Stock1", "STK1"); // Accounts - acInvestment = makeAccount("Investment", MyMoneyAccount::Investment, moZero, QDate(2017, 8, 1), acAsset); - acStock1 = makeAccount("Stock 1", MyMoneyAccount::Stock, moZero, QDate(2017, 8, 1), acInvestment, eqStock1); + acInvestment = makeAccount("Investment", eMyMoney::Account::Investment, moZero, QDate(2017, 8, 1), acAsset); + acStock1 = makeAccount("Stock 1", eMyMoney::Account::Stock, moZero, QDate(2017, 8, 1), acInvestment, eqStock1); // Transactions // Date Action Shares Price Stock Asset Income @@ -662,7 +662,7 @@ MyMoneyMoney secondConversionRate(1.1567, 10000); MyMoneyMoney amountWithdrawn(100); - const auto acCadChecking = makeAccount(QString("Canadian Checking"), MyMoneyAccount::Checkings, moZero, QDate(2017, 8, 1), acAsset, "CAD"); + const auto acCadChecking = makeAccount(QString("Canadian Checking"), eMyMoney::Account::Checkings, moZero, QDate(2017, 8, 1), acAsset, "CAD"); makePrice("CAD", QDate(2017, 8, 1), firsConversionRate); makePrice("CAD", QDate(2017, 8, 2), secondConversionRate); @@ -757,7 +757,7 @@ MyMoneyMoney moTransaction(100, 1); MyMoneyMoney moJpyTransaction(100, 1); - QString acJpyChecking = makeAccount(QString("Japanese Checking"), MyMoneyAccount::Checkings, moJpyOpening, QDate(2003, 11, 15), acAsset, "JPY"); + QString acJpyChecking = makeAccount(QString("Japanese Checking"), eMyMoney::Account::Checkings, moJpyOpening, QDate(2003, 11, 15), acAsset, "JPY"); makePrice("JPY", QDate(2004, 1, 1), MyMoneyMoney(moJpyPrice)); makePrice("JPY", QDate(2004, 5, 1), MyMoneyMoney(moJpyPrice2)); diff --git a/kmymoney/reports/tests/reportstestcommon.h b/kmymoney/reports/tests/reportstestcommon.h --- a/kmymoney/reports/tests/reportstestcommon.h +++ b/kmymoney/reports/tests/reportstestcommon.h @@ -117,7 +117,7 @@ MyMoneyMoney budgetAmount(const QDate& _date, const QString& _categoryid, bool& _applytosub); }; -extern QString makeAccount(const QString& _name, MyMoneyAccount::accountTypeE _type, MyMoneyMoney _balance, const QDate& _open, const QString& _parent, QString _currency = "", bool _taxReport = false, bool _openingBalance = false); +extern QString makeAccount(const QString& _name, eMyMoney::Account _type, MyMoneyMoney _balance, const QDate& _open, const QString& _parent, QString _currency = "", bool _taxReport = false, bool _openingBalance = false); extern void makePrice(const QString& _currencyid, const QDate& _date, const MyMoneyMoney& _price); QString makeEquity(const QString& _name, const QString& _symbol); extern void makeEquityPrice(const QString& _id, const QDate& _date, const MyMoneyMoney& _price); diff --git a/kmymoney/reports/tests/reportstestcommon.cpp b/kmymoney/reports/tests/reportstestcommon.cpp --- a/kmymoney/reports/tests/reportstestcommon.cpp +++ b/kmymoney/reports/tests/reportstestcommon.cpp @@ -233,7 +233,7 @@ //qDebug() << "successfully added " << id(); } -QString makeAccount(const QString& _name, MyMoneyAccount::accountTypeE _type, MyMoneyMoney _balance, const QDate& _open, const QString& _parent, QString _currency, bool _taxReport, bool _openingBalance) +QString makeAccount(const QString& _name, eMyMoney::Account _type, MyMoneyMoney _balance, const QDate& _open, const QString& _parent, QString _currency, bool _taxReport, bool _openingBalance) { MyMoneyAccount info; MyMoneyFileTransaction ft; diff --git a/kmymoney/views/kaccountsview.cpp b/kmymoney/views/kaccountsview.cpp --- a/kmymoney/views/kaccountsview.cpp +++ b/kmymoney/views/kaccountsview.cpp @@ -65,10 +65,10 @@ d->m_proxyModel->setHideClosedAccounts(KMyMoneyGlobalSettings::hideClosedAccounts()); d->m_proxyModel->setHideEquityAccounts(!KMyMoneyGlobalSettings::expertMode()); if (KMyMoneyGlobalSettings::showCategoriesInAccountsView()) { - d->m_proxyModel->addAccountGroup(QVector {MyMoneyAccount::Income, MyMoneyAccount::Expense}); + d->m_proxyModel->addAccountGroup(QVector {eMyMoney::Account::Income, eMyMoney::Account::Expense}); } else { - d->m_proxyModel->removeAccountType(MyMoneyAccount::Income); - d->m_proxyModel->removeAccountType(MyMoneyAccount::Expense); + d->m_proxyModel->removeAccountType(eMyMoney::Account::Income); + d->m_proxyModel->removeAccountType(eMyMoney::Account::Expense); } // reinitialize the default state of the hidden categories label diff --git a/kmymoney/views/kforecastview.h b/kmymoney/views/kforecastview.h --- a/kmymoney/views/kforecastview.h +++ b/kmymoney/views/kforecastview.h @@ -32,6 +32,7 @@ #include "mymoneymoney.h" #include "mymoneysecurity.h" #include "mymoneyforecast.h" +#include "mymoneyprice.h" #include "ui_kforecastviewdecl.h" diff --git a/kmymoney/views/kforecastview.cpp b/kmymoney/views/kforecastview.cpp --- a/kmymoney/views/kforecastview.cpp +++ b/kmymoney/views/kforecastview.cpp @@ -39,6 +39,8 @@ #include "mymoneyutils.h" #include "mymoneyfile.h" +#include "mymoneyprice.h" +#include "mymoneysecurity.h" #include "kmymoneyglobalsettings.h" #include "mymoneyforecast.h" #include "mymoneybudget.h" @@ -404,19 +406,19 @@ case -1: break; case 0: - if (acc.accountGroup() == MyMoneyAccount::Asset) { + if (acc.accountGroup() == eMyMoney::Account::Asset) { msg = QString("").arg(KMyMoneyGlobalSettings::schemeColor(SchemeColor::Negative).name()); msg += i18n("The balance of %1 is below %2 today.", acc.name(), MyMoneyUtils::formatMoney(MyMoneyMoney(), acc, currency)); msg += QString(""); break; } - if (acc.accountGroup() == MyMoneyAccount::Liability) { + if (acc.accountGroup() == eMyMoney::Account::Liability) { msg = i18n("The balance of %1 is above %2 today.", acc.name(), MyMoneyUtils::formatMoney(MyMoneyMoney(), acc, currency)); break; } break; default: - if (acc.accountGroup() == MyMoneyAccount::Asset) { + if (acc.accountGroup() == eMyMoney::Account::Asset) { msg = QString("").arg(KMyMoneyGlobalSettings::schemeColor(SchemeColor::Negative).name()); msg += i18np("The balance of %2 will drop below %3 in %1 day.", "The balance of %2 will drop below %3 in %1 days.", @@ -424,7 +426,7 @@ msg += QString(""); break; } - if (acc.accountGroup() == MyMoneyAccount::Liability) { + if (acc.accountGroup() == eMyMoney::Account::Liability) { msg = i18np("The balance of %2 will raise above %3 in %1 day.", "The balance of %2 will raise above %3 in %1 days.", dropZero, acc.name(), MyMoneyUtils::formatMoney(MyMoneyMoney(), acc, currency)); @@ -930,7 +932,7 @@ for (; forecastDate <= forecast.forecastEndDate(); forecastDate = forecastDate.addMonths(1), ++it_c) { MyMoneyMoney amountMM; amountMM = forecast.forecastBalance(account, forecastDate); - if (account.accountType() == MyMoneyAccount::Expense) + if (account.accountType() == eMyMoney::Account::Expense) amountMM = -amountMM; tAmountMM += amountMM; diff --git a/kmymoney/views/kgloballedgerview.cpp b/kmymoney/views/kgloballedgerview.cpp --- a/kmymoney/views/kgloballedgerview.cpp +++ b/kmymoney/views/kgloballedgerview.cpp @@ -233,7 +233,7 @@ // the proxy filter model d->m_filterProxyModel = new AccountNamesFilterProxyModel(this); - d->m_filterProxyModel->addAccountGroup(QVector {MyMoneyAccount::Asset, MyMoneyAccount::Liability, MyMoneyAccount::Equity}); + d->m_filterProxyModel->addAccountGroup(QVector {eMyMoney::Account::Asset, eMyMoney::Account::Liability, eMyMoney::Account::Equity}); auto const model = Models::instance()->accountsModel(); d->m_filterProxyModel->setSourceModel(model); d->m_filterProxyModel->setSourceColumns(model->getColumns()); @@ -464,22 +464,22 @@ MyMoneyTransactionFilter filter(m_account.id()); // if it's an investment account, we also take care of // the sub-accounts (stock accounts) - if (m_account.accountType() == MyMoneyAccount::Investment) + if (m_account.accountType() == eMyMoney::Account::Investment) filter.addAccount(m_account.accountList()); if (isReconciliationAccount()) { key = "kmm-sort-reconcile"; sortOrder = KMyMoneyGlobalSettings::sortReconcileView(); - filter.addState(MyMoneyTransactionFilter::notReconciled); - filter.addState(MyMoneyTransactionFilter::cleared); + filter.addState((int)eMyMoney::TransactionFilter::State::NotReconciled); + filter.addState((int)eMyMoney::TransactionFilter::State::Cleared); } else { filter.setDateFilter(KMyMoneyGlobalSettings::startDate().date(), QDate()); key = "kmm-sort-std"; sortOrder = KMyMoneyGlobalSettings::sortNormalView(); if (KMyMoneyGlobalSettings::hideReconciledTransactions() && !m_account.isIncomeExpense()) { - filter.addState(MyMoneyTransactionFilter::notReconciled); - filter.addState(MyMoneyTransactionFilter::cleared); + filter.addState((int)eMyMoney::TransactionFilter::State::NotReconciled); + filter.addState((int)eMyMoney::TransactionFilter::State::Cleared); } } filter.setReportAllSplits(true); @@ -554,7 +554,7 @@ } // if this is a one time schedule, we can bail out here as we're done - if (s.occurrence() == MyMoneySchedule::OCCUR_ONCE) + if (s.occurrence() == eMyMoney::Schedule::Occurrence::Once) break; // for all others, we check if the next payment date is still 'in range' @@ -605,7 +605,7 @@ // we need at least the balance for the account we currently show actBalance[m_account.id()] = MyMoneyMoney(); - if (m_account.accountType() == MyMoneyAccount::Investment) { + if (m_account.accountType() == eMyMoney::Account::Investment) { QList::const_iterator it_a; for (it_a = m_account.accountList().begin(); it_a != m_account.accountList().end(); ++it_a) { actBalance[*it_a] = MyMoneyMoney(); @@ -618,8 +618,8 @@ // selected before and setup the focus item. MyMoneyMoney factor(1, 1); - if (m_account.accountGroup() == MyMoneyAccount::Liability - || m_account.accountGroup() == MyMoneyAccount::Equity) + if (m_account.accountGroup() == eMyMoney::Account::Liability + || m_account.accountGroup() == eMyMoney::Account::Equity) factor = -factor; QMap deposits; @@ -781,7 +781,7 @@ m_rightSummaryLabel->show(); if (isReconciliationAccount()) { - if (m_account.accountType() != MyMoneyAccount::Investment) { + if (m_account.accountType() != eMyMoney::Account::Investment) { m_leftSummaryLabel->setText(i18n("Statement: %1", d->m_endingBalance.formatMoney("", d->m_precision))); m_centerSummaryLabel->setText(i18nc("Cleared balance", "Cleared: %1", clearedBalance[m_account.id()].formatMoney("", d->m_precision))); d->m_totalBalance = clearedBalance[m_account.id()] - d->m_endingBalance; @@ -798,7 +798,7 @@ QPalette palette = m_rightSummaryLabel->palette(); palette.setColor(m_rightSummaryLabel->foregroundRole(), m_leftSummaryLabel->palette().color(foregroundRole())); - if (m_account.accountType() != MyMoneyAccount::Investment) { + if (m_account.accountType() != eMyMoney::Account::Investment) { m_centerSummaryLabel->setText(i18nc("Cleared balance", "Cleared: %1", clearedBalance[m_account.id()].formatMoney("", d->m_precision))); d->m_totalBalance = actBalance[m_account.id()]; } else { @@ -854,10 +854,10 @@ m_rightSummaryLabel->setText(i18n("Difference: %1", d->m_totalBalance.formatMoney("", d->m_precision))); } else { - if (m_account.accountType() != MyMoneyAccount::Investment) { + if (m_account.accountType() != eMyMoney::Account::Investment) { m_rightSummaryLabel->setText(i18n("Balance: %1", d->m_totalBalance.formatMoney("", d->m_precision))); bool showNegative = d->m_totalBalance.isNegative(); - if (m_account.accountGroup() == MyMoneyAccount::Liability && !d->m_totalBalance.isZero()) + if (m_account.accountGroup() == eMyMoney::Account::Liability && !d->m_totalBalance.isZero()) showNegative = !showNegative; if (showNegative) { QPalette palette = m_rightSummaryLabel->palette(); @@ -1008,7 +1008,7 @@ d->m_reconciliationAccount = acc.id(); d->m_reconciliationDate = reconciliationDate; d->m_endingBalance = endingBalance; - if (acc.accountGroup() == MyMoneyAccount::Liability) + if (acc.accountGroup() == eMyMoney::Account::Liability) d->m_endingBalance = -endingBalance; m_newAccountLoaded = true; @@ -1093,9 +1093,9 @@ void KGlobalLedgerView::setupDefaultAction() { switch (m_account.accountType()) { - case MyMoneyAccount::Asset: - case MyMoneyAccount::AssetLoan: - case MyMoneyAccount::Savings: + case eMyMoney::Account::Asset: + case eMyMoney::Account::AssetLoan: + case eMyMoney::Account::Savings: d->m_action = KMyMoneyRegister::ActionDeposit; break; default: @@ -1477,8 +1477,8 @@ tooltip = i18n("Cannot create transactions when no account is selected."); rc = false; } - if (m_account.accountGroup() == MyMoneyAccount::Income - || m_account.accountGroup() == MyMoneyAccount::Expense) { + if (m_account.accountGroup() == eMyMoney::Account::Income + || m_account.accountGroup() == eMyMoney::Account::Expense) { tooltip = i18n("Cannot create transactions in the context of a category."); showTooltip(tooltip); rc = false; @@ -1559,8 +1559,8 @@ int investmentTransactions = 0; int normalTransactions = 0; - if (m_account.accountGroup() == MyMoneyAccount::Income - || m_account.accountGroup() == MyMoneyAccount::Expense) { + if (m_account.accountGroup() == eMyMoney::Account::Income + || m_account.accountGroup() == eMyMoney::Account::Expense) { tooltip = i18n("Cannot edit transactions in the context of a category."); showTooltip(tooltip); rc = false; @@ -1632,7 +1632,7 @@ // now check that we have the correct account type for investment transactions if (rc == true && investmentTransactions != 0) { - if (m_account.accountType() != MyMoneyAccount::Investment) { + if (m_account.accountType() != eMyMoney::Account::Investment) { tooltip = i18n("Cannot edit investment transactions in the context of this account."); rc = false; } diff --git a/kmymoney/views/khomeview.cpp b/kmymoney/views/khomeview.cpp --- a/kmymoney/views/khomeview.cpp +++ b/kmymoney/views/khomeview.cpp @@ -57,6 +57,7 @@ #include "kwelcomepage.h" #include "kmymoneyglobalsettings.h" #include "mymoneyfile.h" +#include "mymoneyprice.h" #include "mymoneyforecast.h" #include "kmymoney.h" #include "kreportchartview.h" @@ -66,6 +67,7 @@ #include "icons.h" #include "kmymoneywebpage.h" #include "mymoneyschedule.h" +#include "mymoneyenums.h" #define VIEW_LEDGER "ledger" #define VIEW_SCHEDULE "schedule" @@ -74,6 +76,7 @@ #define VIEW_REPORTS "reports" using namespace Icons; +using namespace eMyMoney; bool accountNameLess(const MyMoneyAccount &acc1, const MyMoneyAccount &acc2) { @@ -347,8 +350,8 @@ reportCfg.setChartDataLabels(false); reportCfg.setChartType(MyMoneyReport::eChartLine); reportCfg.setIncludingSchedules(false); - reportCfg.addAccountGroup(MyMoneyAccount::Asset); - reportCfg.addAccountGroup(MyMoneyAccount::Liability); + reportCfg.addAccountGroup(Account::Asset); + reportCfg.addAccountGroup(Account::Liability); reportCfg.setColumnsAreDays(true); reportCfg.setConvertCurrency(true); reportCfg.setIncludingForecast(true); @@ -392,14 +395,14 @@ if (!d->m_forecast.isForecastDone()) doForecast(); - schedule = file->scheduleList("", MyMoneySchedule::TYPE_ANY, - MyMoneySchedule::OCCUR_ANY, - MyMoneySchedule::STYPE_ANY, + schedule = file->scheduleList(QString(), Schedule::Type::Any, + Schedule::Occurrence::Any, + Schedule::PaymentType::Any, QDate::currentDate(), - QDate::currentDate().addMonths(1)); - overdues = file->scheduleList("", MyMoneySchedule::TYPE_ANY, - MyMoneySchedule::OCCUR_ANY, - MyMoneySchedule::STYPE_ANY, + QDate::currentDate().addMonths(1), false); + overdues = file->scheduleList(QString(), Schedule::Type::Any, + Schedule::Occurrence::Any, + Schedule::PaymentType::Any, QDate(), QDate(), true); if (schedule.empty() && overdues.empty()) @@ -586,7 +589,7 @@ // for single occurrence we have reported everything so we // better get out of here. - if ((*it).occurrence() == MyMoneySchedule::OCCUR_ONCE) { + if ((*it).occurrence() == Schedule::Occurrence::Once) { schedule.erase(it); continue; } @@ -698,8 +701,8 @@ bool removeAccount = false; if (!(*it).isClosed() || showClosedAccounts) { switch ((*it).accountType()) { - case MyMoneyAccount::Expense: - case MyMoneyAccount::Income: + case Account::Expense: + case Account::Income: // never show a category account // Note: This might be different in a future version when // the homepage also shows category based information @@ -708,9 +711,9 @@ // Asset and Liability accounts are only shown if they // have the preferred flag set - case MyMoneyAccount::Asset: - case MyMoneyAccount::Liability: - case MyMoneyAccount::Investment: + case Account::Asset: + case Account::Liability: + case Account::Investment: // if preferred accounts are requested, then keep in list if ((*it).value("PreferredAccount") != "Yes" || (type & Preferred) == 0) { @@ -721,10 +724,10 @@ // Check payment accounts. If payment and preferred is selected, // then always show them. If only payment is selected, then // show only if preferred flag is not set. - case MyMoneyAccount::Checkings: - case MyMoneyAccount::Savings: - case MyMoneyAccount::Cash: - case MyMoneyAccount::CreditCard: + case Account::Checkings: + case Account::Savings: + case Account::Cash: + case Account::CreditCard: switch (type & (Payment | Preferred)) { case Payment: if ((*it).value("PreferredAccount") == "Yes") @@ -829,7 +832,7 @@ bool showLimit = KMyMoneyGlobalSettings::showLimitInfo(); - if (acc.accountType() == MyMoneyAccount::Investment) { + if (acc.accountType() == Account::Investment) { //investment accounts show the balances of all its subaccounts value = investmentBalance(acc); @@ -848,8 +851,8 @@ d->m_total += value; } //if credit card or checkings account, show maximum credit - if (acc.accountType() == MyMoneyAccount::CreditCard || - acc.accountType() == MyMoneyAccount::Checkings) { + if (acc.accountType() == Account::CreditCard || + acc.accountType() == Account::Checkings) { QString maximumCredit = acc.value("maxCreditAbsolute"); if (maximumCredit.isEmpty()) { maximumCredit = acc.value("minBalanceAbsolute"); @@ -909,10 +912,10 @@ QString countStr; if (KMyMoneyGlobalSettings::showCountOfUnmarkedTransactions() || KMyMoneyGlobalSettings::showCountOfNotReconciledTransactions()) - countNotMarked = file->countTransactionsWithSpecificReconciliationState(acc.id(), MyMoneyTransactionFilter::notReconciled); + countNotMarked = file->countTransactionsWithSpecificReconciliationState(acc.id(), TransactionFilter::State::NotReconciled); if (KMyMoneyGlobalSettings::showCountOfClearedTransactions() || KMyMoneyGlobalSettings::showCountOfNotReconciledTransactions()) - countCleared = file->countTransactionsWithSpecificReconciliationState(acc.id(), MyMoneyTransactionFilter::cleared); + countCleared = file->countTransactionsWithSpecificReconciliationState(acc.id(), TransactionFilter::State::Cleared); if (KMyMoneyGlobalSettings::showCountOfNotReconciledTransactions()) countNotReconciled = countNotMarked + countCleared; @@ -947,7 +950,7 @@ //show minimum balance column if requested if (showMinBal) { //if it is an investment, show minimum balance empty - if (acc.accountType() == MyMoneyAccount::Investment) { + if (acc.accountType() == Account::Investment) { tmp += QString(" "); } else { //show minimum balance entry @@ -1142,25 +1145,25 @@ case -1: break; case 0: - if ((*it_account).accountGroup() == MyMoneyAccount::Asset) { + if ((*it_account).accountGroup() == Account::Asset) { msg = i18n("The balance of %1 is below %2 today.", (*it_account).name(), MyMoneyUtils::formatMoney(MyMoneyMoney(), *it_account, currency)); msg = showColoredAmount(msg, true); break; } - if ((*it_account).accountGroup() == MyMoneyAccount::Liability) { + if ((*it_account).accountGroup() == Account::Liability) { msg = i18n("The balance of %1 is above %2 today.", (*it_account).name(), MyMoneyUtils::formatMoney(MyMoneyMoney(), *it_account, currency)); break; } break; default: - if ((*it_account).accountGroup() == MyMoneyAccount::Asset) { + if ((*it_account).accountGroup() == Account::Asset) { msg = i18np("The balance of %2 will drop below %3 in %1 day.", "The balance of %2 will drop below %3 in %1 days.", dropZero, (*it_account).name(), MyMoneyUtils::formatMoney(MyMoneyMoney(), *it_account, currency)); msg = showColoredAmount(msg, true); break; } - if ((*it_account).accountGroup() == MyMoneyAccount::Liability) { + if ((*it_account).accountGroup() == Account::Liability) { msg = i18np("The balance of %2 will raise above %3 in %1 day.", "The balance of %2 will raise above %3 in %1 days.", dropZero, (*it_account).name(), MyMoneyUtils::formatMoney(MyMoneyMoney(), *it_account, currency)); @@ -1276,15 +1279,15 @@ if (!(*it).isClosed()) { switch ((*it).accountType()) { // group all assets into one list but make sure that investment accounts always show up - case MyMoneyAccount::Investment: + case Account::Investment: assets << *it; break; - case MyMoneyAccount::Checkings: - case MyMoneyAccount::Savings: - case MyMoneyAccount::Cash: - case MyMoneyAccount::Asset: - case MyMoneyAccount::AssetLoan: + case Account::Checkings: + case Account::Savings: + case Account::Cash: + case Account::Asset: + case Account::AssetLoan: // list account if it's the last in the hierarchy or has transactions in it if ((*it).accountList().isEmpty() || (file->transactionCount((*it).id()) > 0)) { assets << *it; @@ -1292,9 +1295,9 @@ break; // group the liabilities into the other - case MyMoneyAccount::CreditCard: - case MyMoneyAccount::Liability: - case MyMoneyAccount::Loan: + case Account::CreditCard: + case Account::Liability: + case Account::Loan: // list account if it's the last in the hierarchy or has transactions in it if ((*it).accountList().isEmpty() || (file->transactionCount((*it).id()) > 0)) { liabilities << *it; @@ -1392,7 +1395,7 @@ if (asset_it != assets.constEnd()) { MyMoneyMoney value; //investment accounts consolidate the balance of its subaccounts - if ((*asset_it).accountType() == MyMoneyAccount::Investment) { + if ((*asset_it).accountType() == Account::Investment) { value = investmentBalance(*asset_it); } else { value = MyMoneyFile::instance()->balance((*asset_it).id(), QDate::currentDate()); @@ -1713,7 +1716,7 @@ } //store depending on account type - if (repSplitAcc.accountType() == MyMoneyAccount::Income) { + if (repSplitAcc.accountType() == Account::Income) { incomeValue += value; } else { expenseValue += value; @@ -1739,11 +1742,11 @@ MyMoneyMoney scheduledOtherTransfer; //get overdues and schedules until the end of this month - QList schedule = file->scheduleList("", MyMoneySchedule::TYPE_ANY, - MyMoneySchedule::OCCUR_ANY, - MyMoneySchedule::STYPE_ANY, + QList schedule = file->scheduleList(QString(), Schedule::Type::Any, + Schedule::Occurrence::Any, + Schedule::PaymentType::Any, QDate(), - endOfMonth); + endOfMonth, false); //Remove the finished schedules QList::Iterator finished_it; @@ -1766,7 +1769,7 @@ nextDate = (*sched_it).nextPayment(nextDate); // for single occurrence nextDate will not change, so we // better get out of here. - if ((*sched_it).occurrence() == MyMoneySchedule::OCCUR_ONCE) + if ((*sched_it).occurrence() == Schedule::Occurrence::Once) break; } @@ -1778,7 +1781,7 @@ MyMoneySplit sp = transaction.splitByAccount(acc.id(), true); // take care of the autoCalc stuff - if ((*sched_it).type() == MyMoneySchedule::TYPE_LOANPAYMENT) { + if ((*sched_it).type() == Schedule::Type::LoanPayment) { QDate nextDate = (*sched_it).nextPayment((*sched_it).lastPayment()); //make sure we have all 'starting balances' so that the autocalc works @@ -1824,9 +1827,9 @@ scheduledOtherTransfer += value; } else if (repSplitAcc.isIncomeExpense()) { //income and expenses are stored as negative values - if (repSplitAcc.accountType() == MyMoneyAccount::Income) + if (repSplitAcc.accountType() == Account::Income) scheduledIncome -= value; - if (repSplitAcc.accountType() == MyMoneyAccount::Expense) + if (repSplitAcc.accountType() == Account::Expense) scheduledExpense -= value; } } @@ -1858,9 +1861,9 @@ if (!(*account_it).isClosed()) { switch ((*account_it).accountType()) { //group all assets into one list - case MyMoneyAccount::Checkings: - case MyMoneyAccount::Savings: - case MyMoneyAccount::Cash: { + case Account::Checkings: + case Account::Savings: + case Account::Cash: { MyMoneyMoney value = MyMoneyFile::instance()->balance((*account_it).id(), QDate::currentDate()); //calculate balance for foreign currency accounts if ((*account_it).currencyId() != file->baseCurrency().id()) { @@ -1875,7 +1878,7 @@ break; } //group the liabilities into the other - case MyMoneyAccount::CreditCard: { + case Account::CreditCard: { MyMoneyMoney value; value = MyMoneyFile::instance()->balance((*account_it).id(), QDate::currentDate()); //calculate balance if foreign currency diff --git a/kmymoney/views/kinvestmentview.cpp b/kmymoney/views/kinvestmentview.cpp --- a/kmymoney/views/kinvestmentview.cpp +++ b/kmymoney/views/kinvestmentview.cpp @@ -130,7 +130,7 @@ // Equities tab d->m_accountsProxyModel = new AccountNamesFilterProxyModel(this); - d->m_accountsProxyModel->addAccountType(MyMoneyAccount::Investment); + d->m_accountsProxyModel->addAccountType(eMyMoney::Account::Investment); d->m_accountsProxyModel->setHideEquityAccounts(false); auto const model = Models::instance()->accountsModel(); d->m_accountsProxyModel->setSourceModel(model); @@ -288,7 +288,7 @@ return; const auto acc = dynamic_cast(obj); - if (acc.accountType() == MyMoneyAccount::Investment) + if (acc.accountType() == eMyMoney::Account::Investment) slotSelectAccount(acc.id()); } @@ -316,7 +316,7 @@ if (!d->m_idInvAcc.isEmpty()) { // check if account to be selected exist try { // it could not exist anymore (e.g. another file has been opened) const auto acc = MyMoneyFile::instance()->account(d->m_idInvAcc); // then this should throw an exception - if (acc.accountType() == MyMoneyAccount::Investment) // it could be that id exists but account in new file isn't investment account anymore + if (acc.accountType() == eMyMoney::Account::Investment) // it could be that id exists but account in new file isn't investment account anymore slotSelectAccount(d->m_idInvAcc); // otherwise select preset account else d->m_idInvAcc.clear(); diff --git a/kmymoney/views/kmymoneyaccountsviewbase_p.h b/kmymoney/views/kmymoneyaccountsviewbase_p.h --- a/kmymoney/views/kmymoneyaccountsviewbase_p.h +++ b/kmymoney/views/kmymoneyaccountsviewbase_p.h @@ -33,6 +33,8 @@ #include "kmymoneyviewbase_p.h" #include "kmymoneyglobalsettings.h" #include "mymoneyfile.h" +#include "mymoneymoney.h" +#include "mymoneysecurity.h" #include "viewenums.h" class AccountsViewProxyModel; diff --git a/kmymoney/views/kmymoneyview.cpp b/kmymoney/views/kmymoneyview.cpp --- a/kmymoney/views/kmymoneyview.cpp +++ b/kmymoney/views/kmymoneyview.cpp @@ -95,8 +95,11 @@ #include "mymoneysplit.h" #include "mymoneyaccount.h" #include "kmymoneyedit.h" +#include "mymoneyfile.h" +#include "mymoneyenums.h" using namespace Icons; +using namespace eMyMoney; static constexpr KCompressionDevice::CompressionType const& COMPRESSION_TYPE = KCompressionDevice::GZip; static constexpr char recoveryKeyId[] = "0xD2B08440"; @@ -657,37 +660,37 @@ QString accId(_accId); switch (acc.accountType()) { - case MyMoneyAccount::Stock: + case Account::Stock: // if a stock account is selected, we show the // the corresponding parent (investment) account acc = MyMoneyFile::instance()->account(acc.parentAccountId()); accId = acc.id(); // intentional fall through - case MyMoneyAccount::Checkings: - case MyMoneyAccount::Savings: - case MyMoneyAccount::Cash: - case MyMoneyAccount::CreditCard: - case MyMoneyAccount::Loan: - case MyMoneyAccount::Asset: - case MyMoneyAccount::Liability: - case MyMoneyAccount::AssetLoan: - case MyMoneyAccount::Income: - case MyMoneyAccount::Expense: - case MyMoneyAccount::Investment: - case MyMoneyAccount::Equity: + case Account::Checkings: + case Account::Savings: + case Account::Cash: + case Account::CreditCard: + case Account::Loan: + case Account::Asset: + case Account::Liability: + case Account::AssetLoan: + case Account::Income: + case Account::Expense: + case Account::Investment: + case Account::Equity: setCurrentPage(viewFrames[View::Ledgers]); m_ledgerView->slotSelectAccount(accId, transaction); break; - case MyMoneyAccount::CertificateDep: - case MyMoneyAccount::MoneyMarket: - case MyMoneyAccount::Currency: - qDebug("No ledger view available for account type %d", acc.accountType()); + case Account::CertificateDep: + case Account::MoneyMarket: + case Account::Currency: + qDebug("No ledger view available for account type %d", (int)acc.accountType()); break; default: - qDebug("Unknown account type %d in KMyMoneyView::slotLedgerSelected", acc.accountType()); + qDebug("Unknown account type %d in KMyMoneyView::slotLedgerSelected", (int)acc.accountType()); break; } } @@ -1808,7 +1811,7 @@ QStringList::const_iterator it_a, it_b; for (it_a = list.constBegin(); it_a != list.constEnd(); ++it_a) { MyMoneyAccount acc = MyMoneyFile::instance()->account(*it_a); - if (acc.accountType() == MyMoneyAccount::Investment) { + if (acc.accountType() == Account::Investment) { for (it_b = acc.accountList().begin(); it_b != acc.accountList().end(); ++it_b) { if (!list.contains(*it_b)) { missing.append(*it_b); @@ -1841,7 +1844,7 @@ QStringList::const_iterator it_a, it_b; for (it_a = list.begin(); it_a != list.end(); ++it_a) { MyMoneyAccount acc = MyMoneyFile::instance()->account(*it_a); - if (acc.accountType() == MyMoneyAccount::Investment) { + if (acc.accountType() == Account::Investment) { for (it_b = acc.accountList().begin(); it_b != acc.accountList().end(); ++it_b) { if (!list.contains(*it_b)) { missing.append(*it_b); @@ -1881,8 +1884,8 @@ bool equityListEmpty = equity.accountList().count() == 0; for (it_a = accountList.begin(); it_a != accountList.end(); ++it_a) { - if ((*it_a).accountType() == MyMoneyAccount::Loan - || (*it_a).accountType() == MyMoneyAccount::AssetLoan) { + if ((*it_a).accountType() == Account::Loan + || (*it_a).accountType() == Account::AssetLoan) { fixLoanAccount_0(*it_a); } // until early before 0.8 release, the equity account was not saved to @@ -1890,7 +1893,7 @@ // find and equity account that has equity() as it's parent, we reparent // this account. Need to move it to asset() first, because otherwise // MyMoneyFile::reparent would act as NOP. - if (equityListEmpty && (*it_a).accountType() == MyMoneyAccount::Equity) { + if (equityListEmpty && (*it_a).accountType() == Account::Equity) { if ((*it_a).parentAccountId() == equity.id()) { MyMoneyAccount acc = *it_a; // tricky, force parent account to be empty so that we really @@ -2099,12 +2102,12 @@ MyMoneyMoney val; for (it_s = splits.begin(); it_s != splits.end(); ++it_s) { MyMoneyAccount acc = file->account((*it_s).accountId()); - if (acc.accountGroup() == MyMoneyAccount::Asset - || acc.accountGroup() == MyMoneyAccount::Liability) { + if (acc.accountGroup() == Account::Asset + || acc.accountGroup() == Account::Liability) { val = (*it_s).value(); accountCount++; - if (acc.accountType() == MyMoneyAccount::Loan - || acc.accountType() == MyMoneyAccount::AssetLoan) + if (acc.accountType() == Account::Loan + || acc.accountType() == Account::AssetLoan) isLoan = true; } else break; @@ -2126,8 +2129,8 @@ for (it_s = splits.begin(); defaultAction == 0 && it_s != splits.end(); ++it_s) { MyMoneyAccount acc = file->account((*it_s).accountId()); MyMoneyMoney val = (*it_s).value(); - if (acc.accountGroup() == MyMoneyAccount::Asset - || acc.accountGroup() == MyMoneyAccount::Liability) { + if (acc.accountGroup() == Account::Asset + || acc.accountGroup() == Account::Liability) { if (!val.isPositive()) defaultAction = MyMoneySplit::ActionWithdrawal; else @@ -2143,7 +2146,7 @@ for (it_s = splits.begin(); needModify == false && it_s != splits.end(); ++it_s) { MyMoneyAccount acc = file->account((*it_s).accountId()); MyMoneyMoney val = (*it_s).value(); - if (acc.accountType() == MyMoneyAccount::CreditCard) { + if (acc.accountType() == Account::CreditCard) { if (val < 0 && (*it_s).action() != MyMoneySplit::ActionWithdrawal && (*it_s).action() != MyMoneySplit::ActionTransfer) needModify = true; if (val >= 0 && (*it_s).action() != MyMoneySplit::ActionDeposit && (*it_s).action() != MyMoneySplit::ActionTransfer) diff --git a/kmymoney/views/kpayeesview.cpp b/kmymoney/views/kpayeesview.cpp --- a/kmymoney/views/kpayeesview.cpp +++ b/kmymoney/views/kpayeesview.cpp @@ -54,6 +54,8 @@ #include "config-kmymoney.h" #include "mymoneyfile.h" +#include "mymoneyprice.h" +#include "mymoneytransactionfilter.h" #include "kmymoneyglobalsettings.h" #include "kmymoney.h" #include "models.h" @@ -114,7 +116,7 @@ m_filterProxyModel = new AccountNamesFilterProxyModel(this); m_filterProxyModel->setHideEquityAccounts(!KMyMoneyGlobalSettings::expertMode()); - m_filterProxyModel->addAccountGroup(QVector {MyMoneyAccount::Asset, MyMoneyAccount::Liability, MyMoneyAccount::Income, MyMoneyAccount::Expense, MyMoneyAccount::Equity}); + m_filterProxyModel->addAccountGroup(QVector {eMyMoney::Account::Asset, eMyMoney::Account::Liability, eMyMoney::Account::Income, eMyMoney::Account::Expense, eMyMoney::Account::Equity}); auto const model = Models::instance()->accountsModel(); m_filterProxyModel->setSourceModel(model); @@ -282,7 +284,7 @@ QString txt; if (s.action() != MyMoneySplit::ActionAmortization - && acc.accountType() != MyMoneyAccount::AssetLoan + && acc.accountType() != eMyMoney::Account::AssetLoan && !file->isTransfer(t->transaction()) && t->transaction().splitCount() == 2) { MyMoneySplit s0 = t->transaction().splitByAccount(s.accountId(), false); diff --git a/kmymoney/views/kscheduledview.cpp b/kmymoney/views/kscheduledview.cpp --- a/kmymoney/views/kscheduledview.cpp +++ b/kmymoney/views/kscheduledview.cpp @@ -55,6 +55,7 @@ #include "mymoneyaccount.h" #include "mymoneyschedule.h" #include "mymoneyfile.h" +#include "mymoneypayee.h" using namespace Icons; @@ -222,23 +223,23 @@ QTreeWidgetItem* parent = 0; switch (schedData.type()) { - case MyMoneySchedule::TYPE_ANY: + case eMyMoney::Schedule::Type::Any: // Should we display an error ? // We just sort it as bill and fall through here - case MyMoneySchedule::TYPE_BILL: + case eMyMoney::Schedule::Type::Bill: parent = itemBills; break; - case MyMoneySchedule::TYPE_DEPOSIT: + case eMyMoney::Schedule::Type::Deposit: parent = itemDeposits; break; - case MyMoneySchedule::TYPE_TRANSFER: + case eMyMoney::Schedule::Type::Transfer: parent = itemTransfers; break; - case MyMoneySchedule::TYPE_LOANPAYMENT: + case eMyMoney::Schedule::Type::LoanPayment: parent = itemLoans; break; @@ -323,20 +324,20 @@ MyMoneyAccount acc; switch (schedule.type()) { - case MyMoneySchedule::TYPE_DEPOSIT: + case eMyMoney::Schedule::Type::Deposit: if (s1.value().isNegative()) split = s2; else split = s1; break; - case MyMoneySchedule::TYPE_LOANPAYMENT: + case eMyMoney::Schedule::Type::LoanPayment: for (it_s = transaction.splits().constBegin(); it_s != transaction.splits().constEnd(); ++it_s) { acc = MyMoneyFile::instance()->account((*it_s).accountId()); - if (acc.accountGroup() == MyMoneyAccount::Asset - || acc.accountGroup() == MyMoneyAccount::Liability) { - if (acc.accountType() != MyMoneyAccount::Loan - && acc.accountType() != MyMoneyAccount::AssetLoan) { + if (acc.accountGroup() == eMyMoney::Account::Asset + || acc.accountGroup() == eMyMoney::Account::Liability) { + if (acc.accountType() != eMyMoney::Account::Loan + && acc.accountType() != eMyMoney::Account::AssetLoan) { split = *it_s; break; } diff --git a/kmymoney/views/ktagsview.cpp b/kmymoney/views/ktagsview.cpp --- a/kmymoney/views/ktagsview.cpp +++ b/kmymoney/views/ktagsview.cpp @@ -45,6 +45,8 @@ // Project Includes #include "mymoneyfile.h" +#include "mymoneyprice.h" +#include "mymoneytransactionfilter.h" #include "kmymoneyglobalsettings.h" #include "kmymoney.h" #include "models.h" @@ -106,7 +108,7 @@ setupUi(this); m_filterProxyModel = new AccountNamesFilterProxyModel(this); - m_filterProxyModel->addAccountGroup(QVector {MyMoneyAccount::Asset, MyMoneyAccount::Liability, MyMoneyAccount::Income, MyMoneyAccount::Expense}); + m_filterProxyModel->addAccountGroup(QVector {eMyMoney::Account::Asset, eMyMoney::Account::Liability, eMyMoney::Account::Income, eMyMoney::Account::Expense}); auto const model = Models::instance()->accountsModel(); m_filterProxyModel->setSourceModel(model); m_filterProxyModel->setSourceColumns(model->getColumns()); diff --git a/kmymoney/views/ledgerview.cpp b/kmymoney/views/ledgerview.cpp --- a/kmymoney/views/ledgerview.cpp +++ b/kmymoney/views/ledgerview.cpp @@ -143,7 +143,7 @@ { d->account = acc; switch(acc.accountType()) { - case MyMoneyAccount::Investment: + case eMyMoney::Account::Investment: break; default: @@ -162,8 +162,8 @@ } d->showValuesInverted = false; - if(acc.accountGroup() == MyMoneyAccount::Liability - || acc.accountGroup() == MyMoneyAccount::Income) { + if(acc.accountGroup() == eMyMoney::Account::Liability + || acc.accountGroup() == eMyMoney::Account::Income) { d->showValuesInverted = true; } diff --git a/kmymoney/views/ledgerviewpage.cpp b/kmymoney/views/ledgerviewpage.cpp --- a/kmymoney/views/ledgerviewpage.cpp +++ b/kmymoney/views/ledgerviewpage.cpp @@ -85,7 +85,7 @@ d->hideFormReasons.insert(QLatin1String("FormAvailable")); switch(acc.accountType()) { - case MyMoneyAccount::Investment: + case eMyMoney::Account::Investment: break; default: diff --git a/kmymoney/views/newspliteditor.cpp b/kmymoney/views/newspliteditor.cpp --- a/kmymoney/views/newspliteditor.cpp +++ b/kmymoney/views/newspliteditor.cpp @@ -200,7 +200,7 @@ d->ui->enterButton->setIcon(QIcon::fromTheme(g_Icons[Icon::DialogOK])); d->ui->cancelButton->setIcon(QIcon::fromTheme(g_Icons[Icon::DialogCancel])); - d->accountsModel->addAccountGroup(QVector {MyMoneyAccount::Asset, MyMoneyAccount::Liability, MyMoneyAccount::Income, MyMoneyAccount::Expense, MyMoneyAccount::Equity}); + d->accountsModel->addAccountGroup(QVector {eMyMoney::Account::Asset, eMyMoney::Account::Liability, eMyMoney::Account::Income, eMyMoney::Account::Expense, eMyMoney::Account::Equity}); d->accountsModel->setHideEquityAccounts(false); auto const model = Models::instance()->accountsModel(); d->accountsModel->setSourceModel(model); diff --git a/kmymoney/views/newtransactioneditor.cpp b/kmymoney/views/newtransactioneditor.cpp --- a/kmymoney/views/newtransactioneditor.cpp +++ b/kmymoney/views/newtransactioneditor.cpp @@ -35,6 +35,8 @@ // ---------------------------------------------------------------------------- // Project Includes +#include "mymoneyfile.h" +#include "mymoneyaccount.h" #include "kmymoneyutils.h" #include "kmymoneyaccountcombo.h" #include "models.h" @@ -352,7 +354,7 @@ d->ui->setupUi(this); - d->accountsModel->addAccountGroup(QVector {MyMoneyAccount::Asset, MyMoneyAccount::Liability, MyMoneyAccount::Income, MyMoneyAccount::Expense, MyMoneyAccount::Equity}); + d->accountsModel->addAccountGroup(QVector {eMyMoney::Account::Asset, eMyMoney::Account::Liability, eMyMoney::Account::Income, eMyMoney::Account::Expense, eMyMoney::Account::Equity}); d->accountsModel->setHideEquityAccounts(false); d->accountsModel->setSourceModel(model); d->accountsModel->setSourceColumns(model->getColumns()); diff --git a/kmymoney/views/simpleledgerview.cpp b/kmymoney/views/simpleledgerview.cpp --- a/kmymoney/views/simpleledgerview.cpp +++ b/kmymoney/views/simpleledgerview.cpp @@ -105,7 +105,7 @@ connect(m_kmymoneyview, &KMyMoneyView::fileClosed, this, &SimpleLedgerView::closeLedgers); connect(m_kmymoneyview, &KMyMoneyView::fileOpened, this, &SimpleLedgerView::openFavoriteLedgers); - d->accountsModel->addAccountGroup(QVector {MyMoneyAccount::Asset, MyMoneyAccount::Liability, MyMoneyAccount::Equity}); + d->accountsModel->addAccountGroup(QVector {eMyMoney::Account::Asset, eMyMoney::Account::Liability, eMyMoney::Account::Equity}); d->accountsModel->setHideEquityAccounts(false); auto const model = Models::instance()->accountsModel(); diff --git a/kmymoney/widgets/budgetviewproxymodel.cpp b/kmymoney/widgets/budgetviewproxymodel.cpp --- a/kmymoney/widgets/budgetviewproxymodel.cpp +++ b/kmymoney/widgets/budgetviewproxymodel.cpp @@ -29,6 +29,7 @@ #include "mymoneyutils.h" #include "mymoneyfile.h" +#include "mymoneysecurity.h" #include "models.h" #include "accountsmodel.h" #include "modelenums.h" diff --git a/kmymoney/widgets/kmymoneyaccountcompletion.h b/kmymoney/widgets/kmymoneyaccountcompletion.h --- a/kmymoney/widgets/kmymoneyaccountcompletion.h +++ b/kmymoney/widgets/kmymoneyaccountcompletion.h @@ -48,7 +48,7 @@ kMyMoneyAccountCompletion(QWidget *parent = 0); virtual ~kMyMoneyAccountCompletion(); - QStringList accountList(const QList& list = QList()) const { + QStringList accountList(const QList& list = QList()) const { return selector()->accountList(list); } diff --git a/kmymoney/widgets/kmymoneyaccountcompletion.cpp b/kmymoney/widgets/kmymoneyaccountcompletion.cpp --- a/kmymoney/widgets/kmymoneyaccountcompletion.cpp +++ b/kmymoney/widgets/kmymoneyaccountcompletion.cpp @@ -50,10 +50,10 @@ // Default is to show all accounts // FIXME We should leave this also to the caller AccountSet set; - set.addAccountGroup(MyMoneyAccount::Asset); - set.addAccountGroup(MyMoneyAccount::Liability); - set.addAccountGroup(MyMoneyAccount::Income); - set.addAccountGroup(MyMoneyAccount::Expense); + set.addAccountGroup(eMyMoney::Account::Asset); + set.addAccountGroup(eMyMoney::Account::Liability); + set.addAccountGroup(eMyMoney::Account::Income); + set.addAccountGroup(eMyMoney::Account::Expense); set.load(selector()); #endif diff --git a/kmymoney/widgets/kmymoneyaccountselector.h b/kmymoney/widgets/kmymoneyaccountselector.h --- a/kmymoney/widgets/kmymoneyaccountselector.h +++ b/kmymoney/widgets/kmymoneyaccountselector.h @@ -73,7 +73,7 @@ * will be returned. * @return QStringList of account ids */ - QStringList accountList(const QList& list = QList()) const; + QStringList accountList(const QList& list = QList()) const; void setSelectionMode(QTreeWidget::SelectionMode mode); @@ -167,9 +167,9 @@ public: AccountSet(); - void addAccountType(MyMoneyAccount::accountTypeE type); - void addAccountGroup(MyMoneyAccount::accountTypeE type); - void removeAccountType(MyMoneyAccount::accountTypeE type); + void addAccountType(eMyMoney::Account type); + void addAccountGroup(eMyMoney::Account type); + void removeAccountType(eMyMoney::Account type); void clear(); @@ -194,7 +194,7 @@ private: int m_count; MyMoneyFile* m_file; - QList m_typeList; + QList m_typeList; QTreeWidgetItem* m_favorites; bool m_hideClosedAccounts; }; diff --git a/kmymoney/widgets/kmymoneyaccountselector.cpp b/kmymoney/widgets/kmymoneyaccountselector.cpp --- a/kmymoney/widgets/kmymoneyaccountselector.cpp +++ b/kmymoney/widgets/kmymoneyaccountselector.cpp @@ -43,8 +43,10 @@ #include "kmymoneyutils.h" #include "kmymoneyglobalsettings.h" #include "icons/icons.h" +#include "mymoneyenums.h" using namespace Icons; +using namespace eMyMoney; kMyMoneyAccountSelector::kMyMoneyAccountSelector(QWidget *parent, Qt::WindowFlags flags, const bool createButtons) : KMyMoneySelector(parent, flags), @@ -121,7 +123,7 @@ KMyMoneySelector::setSelectionMode(mode); } -QStringList kMyMoneyAccountSelector::accountList(const QList& filterList) const +QStringList kMyMoneyAccountSelector::accountList(const QList& filterList) const { QStringList list; QTreeWidgetItemIterator it(m_treeWidget, QTreeWidgetItemIterator::Selectable); @@ -173,42 +175,42 @@ { } -void AccountSet::addAccountGroup(MyMoneyAccount::accountTypeE group) +void AccountSet::addAccountGroup(Account group) { - if (group == MyMoneyAccount::Asset) { - m_typeList << MyMoneyAccount::Checkings; - m_typeList << MyMoneyAccount::Savings; - m_typeList << MyMoneyAccount::Cash; - m_typeList << MyMoneyAccount::AssetLoan; - m_typeList << MyMoneyAccount::CertificateDep; - m_typeList << MyMoneyAccount::Investment; - m_typeList << MyMoneyAccount::Stock; - m_typeList << MyMoneyAccount::MoneyMarket; - m_typeList << MyMoneyAccount::Asset; - m_typeList << MyMoneyAccount::Currency; - - } else if (group == MyMoneyAccount::Liability) { - m_typeList << MyMoneyAccount::CreditCard; - m_typeList << MyMoneyAccount::Loan; - m_typeList << MyMoneyAccount::Liability; - - } else if (group == MyMoneyAccount::Income) { - m_typeList << MyMoneyAccount::Income; - - } else if (group == MyMoneyAccount::Expense) { - m_typeList << MyMoneyAccount::Expense; - - } else if (group == MyMoneyAccount::Equity) { - m_typeList << MyMoneyAccount::Equity; + if (group == Account::Asset) { + m_typeList << Account::Checkings; + m_typeList << Account::Savings; + m_typeList << Account::Cash; + m_typeList << Account::AssetLoan; + m_typeList << Account::CertificateDep; + m_typeList << Account::Investment; + m_typeList << Account::Stock; + m_typeList << Account::MoneyMarket; + m_typeList << Account::Asset; + m_typeList << Account::Currency; + + } else if (group == Account::Liability) { + m_typeList << Account::CreditCard; + m_typeList << Account::Loan; + m_typeList << Account::Liability; + + } else if (group == Account::Income) { + m_typeList << Account::Income; + + } else if (group == Account::Expense) { + m_typeList << Account::Expense; + + } else if (group == Account::Equity) { + m_typeList << Account::Equity; } } -void AccountSet::addAccountType(MyMoneyAccount::accountTypeE type) +void AccountSet::addAccountType(Account type) { m_typeList << type; } -void AccountSet::removeAccountType(MyMoneyAccount::accountTypeE type) +void AccountSet::removeAccountType(Account type) { int index = m_typeList.indexOf(type); if (index != -1) { @@ -235,30 +237,30 @@ if (!list.isEmpty()) currentId = list.first(); } - if (m_typeList.contains(MyMoneyAccount::Checkings) - || m_typeList.contains(MyMoneyAccount::Savings) - || m_typeList.contains(MyMoneyAccount::Cash) - || m_typeList.contains(MyMoneyAccount::AssetLoan) - || m_typeList.contains(MyMoneyAccount::CertificateDep) - || m_typeList.contains(MyMoneyAccount::Investment) - || m_typeList.contains(MyMoneyAccount::Stock) - || m_typeList.contains(MyMoneyAccount::MoneyMarket) - || m_typeList.contains(MyMoneyAccount::Asset) - || m_typeList.contains(MyMoneyAccount::Currency)) + if (m_typeList.contains(Account::Checkings) + || m_typeList.contains(Account::Savings) + || m_typeList.contains(Account::Cash) + || m_typeList.contains(Account::AssetLoan) + || m_typeList.contains(Account::CertificateDep) + || m_typeList.contains(Account::Investment) + || m_typeList.contains(Account::Stock) + || m_typeList.contains(Account::MoneyMarket) + || m_typeList.contains(Account::Asset) + || m_typeList.contains(Account::Currency)) typeMask |= KMyMoneyUtils::asset; - if (m_typeList.contains(MyMoneyAccount::CreditCard) - || m_typeList.contains(MyMoneyAccount::Loan) - || m_typeList.contains(MyMoneyAccount::Liability)) + if (m_typeList.contains(Account::CreditCard) + || m_typeList.contains(Account::Loan) + || m_typeList.contains(Account::Liability)) typeMask |= KMyMoneyUtils::liability; - if (m_typeList.contains(MyMoneyAccount::Income)) + if (m_typeList.contains(Account::Income)) typeMask |= KMyMoneyUtils::income; - if (m_typeList.contains(MyMoneyAccount::Expense)) + if (m_typeList.contains(Account::Expense)) typeMask |= KMyMoneyUtils::expense; - if (m_typeList.contains(MyMoneyAccount::Equity)) + if (m_typeList.contains(Account::Equity)) typeMask |= KMyMoneyUtils::equity; selector->clear(); diff --git a/kmymoney/widgets/kmymoneyaccounttreeview.h b/kmymoney/widgets/kmymoneyaccounttreeview.h --- a/kmymoney/widgets/kmymoneyaccounttreeview.h +++ b/kmymoney/widgets/kmymoneyaccounttreeview.h @@ -94,7 +94,7 @@ void openIndex(const QModelIndex &index); static QString getConfGrpName(const View view); QSet readVisibleColumns(const View view); - QVector getVisibleGroups(const View view); + QVector getVisibleGroups(const View view); AccountsViewProxyModel *m_model; View m_view; diff --git a/kmymoney/widgets/kmymoneyaccounttreeview.cpp b/kmymoney/widgets/kmymoneyaccounttreeview.cpp --- a/kmymoney/widgets/kmymoneyaccounttreeview.cpp +++ b/kmymoney/widgets/kmymoneyaccounttreeview.cpp @@ -197,17 +197,17 @@ emit selectObject(MyMoneyInstitution()); } -QVector KMyMoneyAccountTreeView::getVisibleGroups(const View view) +QVector KMyMoneyAccountTreeView::getVisibleGroups(const View view) { switch (view) { case View::Institutions: case View::Accounts: - return QVector {MyMoneyAccount::Asset, MyMoneyAccount::Liability, MyMoneyAccount::Equity}; + return QVector {eMyMoney::Account::Asset, eMyMoney::Account::Liability, eMyMoney::Account::Equity}; case View::Categories: case View::Budget: - return QVector {MyMoneyAccount::Income, MyMoneyAccount::Expense}; + return QVector {eMyMoney::Account::Income, eMyMoney::Account::Expense}; default: - return QVector (); + return QVector (); } } diff --git a/kmymoney/widgets/kmymoneybriefschedule.cpp b/kmymoney/widgets/kmymoneybriefschedule.cpp --- a/kmymoney/widgets/kmymoneybriefschedule.cpp +++ b/kmymoney/widgets/kmymoneybriefschedule.cpp @@ -139,7 +139,7 @@ m_prevButton->setEnabled(true); m_nextButton->setEnabled(true); - m_skipButton->setEnabled(sched.occurrencePeriod() != MyMoneySchedule::OCCUR_ONCE); + m_skipButton->setEnabled(sched.occurrencePeriod() != eMyMoney::Schedule::Occurrence::Once); if (m_index == 0) m_prevButton->setEnabled(false); diff --git a/kmymoney/widgets/kmymoneymvccombo.h b/kmymoney/widgets/kmymoneymvccombo.h --- a/kmymoney/widgets/kmymoneymvccombo.h +++ b/kmymoney/widgets/kmymoneymvccombo.h @@ -308,7 +308,7 @@ * Create a combo box that contains the entries "Pay to", "From" and * " " for don't care. */ - explicit KMyMoneyCashFlowCombo(QWidget *w = 0, MyMoneyAccount::accountTypeE type = MyMoneyAccount::Asset); + explicit KMyMoneyCashFlowCombo(QWidget *w = 0, eMyMoney::Account type = eMyMoney::Account::Asset); void setDirection(KMyMoneyRegister::CashFlowDirection dir); KMyMoneyRegister::CashFlowDirection direction() const { @@ -427,7 +427,7 @@ public: KMyMoneyOccurrenceCombo(QWidget* parent = 0); - MyMoneySchedule::occurrenceE currentItem() const; + eMyMoney::Schedule::Occurrence currentItem() const; }; /** diff --git a/kmymoney/widgets/kmymoneymvccombo.cpp b/kmymoney/widgets/kmymoneymvccombo.cpp --- a/kmymoney/widgets/kmymoneymvccombo.cpp +++ b/kmymoney/widgets/kmymoneymvccombo.cpp @@ -51,6 +51,7 @@ #include "mymoneytransactionfilter.h" using namespace Icons; +using namespace eMyMoney; class KMyMoneyMVCCombo::Private { @@ -557,12 +558,12 @@ return state; } -KMyMoneyCashFlowCombo::KMyMoneyCashFlowCombo(QWidget* w, MyMoneyAccount::accountTypeE accountType) : +KMyMoneyCashFlowCombo::KMyMoneyCashFlowCombo(QWidget* w, Account accountType) : KMyMoneyMVCCombo(false, w), m_dir(KMyMoneyRegister::Unknown) { addItem(" ", QVariant(KMyMoneyRegister::Unknown)); - if (accountType == MyMoneyAccount::Income || accountType == MyMoneyAccount::Expense) { + if (accountType == Account::Income || accountType == Account::Expense) { // this is used for income/expense accounts to just show the reverse sense addItem(i18nc("Activity for income categories", "Received"), QVariant(KMyMoneyRegister::Payment)); addItem(i18nc("Activity for expense categories", "Paid"), QVariant(KMyMoneyRegister::Deposit)); @@ -751,41 +752,41 @@ { } -MyMoneySchedule::occurrenceE KMyMoneyOccurrenceCombo::currentItem() const +Schedule::Occurrence KMyMoneyOccurrenceCombo::currentItem() const { - return static_cast(KMyMoneyGeneralCombo::currentItem()); + return static_cast(KMyMoneyGeneralCombo::currentItem()); } KMyMoneyOccurrencePeriodCombo::KMyMoneyOccurrencePeriodCombo(QWidget* parent) : KMyMoneyOccurrenceCombo(parent) { - addItem(i18nc("Schedule occurrence period", MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_ONCE).toLatin1()), MyMoneySchedule::OCCUR_ONCE); - addItem(i18nc("Schedule occurrence period", MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_DAILY).toLatin1()), MyMoneySchedule::OCCUR_DAILY); - addItem(i18nc("Schedule occurrence period", MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_WEEKLY).toLatin1()), MyMoneySchedule::OCCUR_WEEKLY); - addItem(i18nc("Schedule occurrence period", MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_EVERYHALFMONTH).toLatin1()), MyMoneySchedule::OCCUR_EVERYHALFMONTH); - addItem(i18nc("Schedule occurrence period", MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_MONTHLY).toLatin1()), MyMoneySchedule::OCCUR_MONTHLY); - addItem(i18nc("Schedule occurrence period", MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_YEARLY).toLatin1()), MyMoneySchedule::OCCUR_YEARLY); + addItem(i18nc("Schedule occurrence period", MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::Once).toLatin1()), (int)Schedule::Occurrence::Once); + addItem(i18nc("Schedule occurrence period", MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::Daily).toLatin1()), (int)Schedule::Occurrence::Daily); + addItem(i18nc("Schedule occurrence period", MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::Weekly).toLatin1()), (int)Schedule::Occurrence::Weekly); + addItem(i18nc("Schedule occurrence period", MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::EveryHalfMonth).toLatin1()), (int)Schedule::Occurrence::EveryHalfMonth); + addItem(i18nc("Schedule occurrence period", MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::Monthly).toLatin1()), (int)Schedule::Occurrence::Monthly); + addItem(i18nc("Schedule occurrence period", MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::Yearly).toLatin1()), (int)Schedule::Occurrence::Yearly); } KMyMoneyFrequencyCombo::KMyMoneyFrequencyCombo(QWidget* parent) : KMyMoneyOccurrenceCombo(parent) { - addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_ONCE).toLatin1()), MyMoneySchedule::OCCUR_ONCE); - addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_DAILY).toLatin1()), MyMoneySchedule::OCCUR_DAILY); - addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_WEEKLY).toLatin1()), MyMoneySchedule::OCCUR_WEEKLY); - addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYOTHERWEEK).toLatin1()), MyMoneySchedule::OCCUR_EVERYOTHERWEEK); - addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYHALFMONTH).toLatin1()), MyMoneySchedule::OCCUR_EVERYHALFMONTH); - addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYTHREEWEEKS).toLatin1()), MyMoneySchedule::OCCUR_EVERYTHREEWEEKS); - addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS).toLatin1()), MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS); - addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYFOURWEEKS).toLatin1()), MyMoneySchedule::OCCUR_EVERYFOURWEEKS); - addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_MONTHLY).toLatin1()), MyMoneySchedule::OCCUR_MONTHLY); - addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS).toLatin1()), MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS); - addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYOTHERMONTH).toLatin1()), MyMoneySchedule::OCCUR_EVERYOTHERMONTH); - addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYTHREEMONTHS).toLatin1()), MyMoneySchedule::OCCUR_EVERYTHREEMONTHS); - addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYFOURMONTHS).toLatin1()), MyMoneySchedule::OCCUR_EVERYFOURMONTHS); - addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_TWICEYEARLY).toLatin1()), MyMoneySchedule::OCCUR_TWICEYEARLY); - addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_YEARLY).toLatin1()), MyMoneySchedule::OCCUR_YEARLY); - addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYOTHERYEAR).toLatin1()), MyMoneySchedule::OCCUR_EVERYOTHERYEAR); + addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Once).toLatin1()), (int)Schedule::Occurrence::Once); + addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Daily).toLatin1()), (int)Schedule::Occurrence::Daily); + addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Weekly).toLatin1()), (int)Schedule::Occurrence::Weekly); + addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryOtherWeek).toLatin1()), (int)Schedule::Occurrence::EveryOtherWeek); + addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryHalfMonth).toLatin1()), (int)Schedule::Occurrence::EveryHalfMonth); + addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryThreeWeeks).toLatin1()), (int)Schedule::Occurrence::EveryThreeWeeks); + addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryThirtyDays).toLatin1()), (int)Schedule::Occurrence::EveryThirtyDays); + addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryFourWeeks).toLatin1()), (int)Schedule::Occurrence::EveryFourWeeks); + addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Monthly).toLatin1()), (int)Schedule::Occurrence::Monthly); + addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryEightWeeks).toLatin1()), (int)Schedule::Occurrence::EveryEightWeeks); + addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryOtherMonth).toLatin1()), (int)Schedule::Occurrence::EveryOtherMonth); + addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryThreeMonths).toLatin1()), (int)Schedule::Occurrence::EveryThreeMonths); + addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryFourMonths).toLatin1()), (int)Schedule::Occurrence::EveryFourMonths); + addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(Schedule::Occurrence::TwiceYearly).toLatin1()), (int)Schedule::Occurrence::TwiceYearly); + addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Yearly).toLatin1()), (int)Schedule::Occurrence::Yearly); + addItem(i18nc("Frequency of schedule", MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryOtherYear).toLatin1()), (int)Schedule::Occurrence::EveryOtherYear); connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCurrentDataChanged())); } diff --git a/kmymoney/widgets/register.h b/kmymoney/widgets/register.h --- a/kmymoney/widgets/register.h +++ b/kmymoney/widgets/register.h @@ -210,7 +210,7 @@ class TypeGroupMarker : public GroupMarker { public: - TypeGroupMarker(Register* parent, CashFlowDirection dir, MyMoneyAccount::accountTypeE accType); + TypeGroupMarker(Register* parent, CashFlowDirection dir, eMyMoney::Account accType); CashFlowDirection sortType() const { return m_dir; } diff --git a/kmymoney/widgets/register.cpp b/kmymoney/widgets/register.cpp --- a/kmymoney/widgets/register.cpp +++ b/kmymoney/widgets/register.cpp @@ -51,6 +51,7 @@ #include "scheduledtransaction.h" #include "kmymoneyglobalsettings.h" #include "mymoneyfile.h" +#include "mymoneyenums.h" static const char * sortOrderText[] = { I18N_NOOP2("Unknown sort order", "Unknown"), @@ -68,6 +69,7 @@ }; using namespace KMyMoneyRegister; +using namespace eMyMoney; static unsigned char fancymarker_bg_image[] = { /* 200x49 */ @@ -378,20 +380,20 @@ painter->restore(); } -TypeGroupMarker::TypeGroupMarker(Register* parent, CashFlowDirection dir, MyMoneyAccount::accountTypeE accType) : +TypeGroupMarker::TypeGroupMarker(Register* parent, CashFlowDirection dir, Account accType) : GroupMarker(parent), m_dir(dir) { switch (dir) { case Deposit: m_txt = i18nc("Deposits onto account", "Deposits"); - if (accType == MyMoneyAccount::CreditCard) { + if (accType == Account::CreditCard) { m_txt = i18nc("Payments towards credit card", "Payments"); } break; case Payment: m_txt = i18nc("Payments made from account", "Payments"); - if (accType == MyMoneyAccount::CreditCard) { + if (accType == Account::CreditCard) { m_txt = i18nc("Payments made with credit card", "Charges"); } break; @@ -587,7 +589,7 @@ // balance switch (account.accountType()) { - case MyMoneyAccount::Stock: + case Account::Stock: break; default: showColumn(BalanceColumn); @@ -596,19 +598,19 @@ // Number column switch (account.accountType()) { - case MyMoneyAccount::Savings: - case MyMoneyAccount::Cash: - case MyMoneyAccount::Loan: - case MyMoneyAccount::AssetLoan: - case MyMoneyAccount::Asset: - case MyMoneyAccount::Liability: - case MyMoneyAccount::Equity: + case Account::Savings: + case Account::Cash: + case Account::Loan: + case Account::AssetLoan: + case Account::Asset: + case Account::Liability: + case Account::Equity: if (KMyMoneyGlobalSettings::alwaysShowNrField()) showColumn(NumberColumn); break; - case MyMoneyAccount::Checkings: - case MyMoneyAccount::CreditCard: + case Account::Checkings: + case Account::CreditCard: showColumn(NumberColumn); break; @@ -618,8 +620,8 @@ } switch (account.accountType()) { - case MyMoneyAccount::Income: - case MyMoneyAccount::Expense: + case Account::Income: + case Account::Expense: showAccountColumn = true; break; default: @@ -636,7 +638,7 @@ showColumn(DepositColumn); break; - case MyMoneyAccount::Investment: + case Account::Investment: showColumn(SecurityColumn); showColumn(QuantityColumn); showColumn(PriceColumn); @@ -646,22 +648,22 @@ // headings switch (account.accountType()) { - case MyMoneyAccount::CreditCard: + case Account::CreditCard: horizontalHeaderItem(PaymentColumn)->setText(i18nc("Payment made with credit card", "Charge")); horizontalHeaderItem(DepositColumn)->setText(i18nc("Payment towards credit card", "Payment")); break; - case MyMoneyAccount::Asset: - case MyMoneyAccount::AssetLoan: + case Account::Asset: + case Account::AssetLoan: horizontalHeaderItem(PaymentColumn)->setText(i18nc("Decrease of asset/liability value", "Decrease")); horizontalHeaderItem(DepositColumn)->setText(i18nc("Increase of asset/liability value", "Increase")); break; - case MyMoneyAccount::Liability: - case MyMoneyAccount::Loan: + case Account::Liability: + case Account::Loan: horizontalHeaderItem(PaymentColumn)->setText(i18nc("Increase of asset/liability value", "Increase")); horizontalHeaderItem(DepositColumn)->setText(i18nc("Decrease of asset/liability value", "Decrease")); break; - case MyMoneyAccount::Income: - case MyMoneyAccount::Expense: + case Account::Income: + case Account::Expense: horizontalHeaderItem(PaymentColumn)->setText(i18n("Income")); horizontalHeaderItem(DepositColumn)->setText(i18n("Expense")); break; @@ -1893,18 +1895,18 @@ } switch (parent->account().accountType()) { - case MyMoneyAccount::Checkings: - case MyMoneyAccount::Savings: - case MyMoneyAccount::Cash: - case MyMoneyAccount::CreditCard: - case MyMoneyAccount::Loan: - case MyMoneyAccount::Asset: - case MyMoneyAccount::Liability: - case MyMoneyAccount::Currency: - case MyMoneyAccount::Income: - case MyMoneyAccount::Expense: - case MyMoneyAccount::AssetLoan: - case MyMoneyAccount::Equity: + case Account::Checkings: + case Account::Savings: + case Account::Cash: + case Account::CreditCard: + case Account::Loan: + case Account::Asset: + case Account::Liability: + case Account::Currency: + case Account::Income: + case Account::Expense: + case Account::AssetLoan: + case Account::Equity: if (s.accountId().isEmpty()) s.setAccountId(parent->account().id()); if (s.isMatched()) @@ -1915,7 +1917,7 @@ t = new KMyMoneyRegister::StdTransaction(parent, transaction, s, uniqueId); break; - case MyMoneyAccount::Investment: + case Account::Investment: if (s.isMatched()) t = new KMyMoneyRegister::InvestTransaction/* Matched */(parent, transaction, s, uniqueId); else if (transaction.isImported()) @@ -1924,11 +1926,11 @@ t = new KMyMoneyRegister::InvestTransaction(parent, transaction, s, uniqueId); break; - case MyMoneyAccount::CertificateDep: - case MyMoneyAccount::MoneyMarket: - case MyMoneyAccount::Stock: + case Account::CertificateDep: + case Account::MoneyMarket: + case Account::Stock: default: - qDebug("Register::transactionFactory: invalid accountTypeE %d", parent->account().accountType()); + qDebug("Register::transactionFactory: invalid accountTypeE %d", (int)parent->account().accountType()); break; } return t; @@ -1973,7 +1975,7 @@ if (!m_account.value("lastImportedTransactionDate").isEmpty() && !m_account.value("lastStatementBalance").isEmpty()) { MyMoneyMoney balance(m_account.value("lastStatementBalance")); - if (m_account.accountGroup() == MyMoneyAccount::Liability) + if (m_account.accountGroup() == Account::Liability) balance = -balance; QString txt = i18n("Online Statement Balance: %1", balance.formatMoney(m_account.fraction())); diff --git a/kmymoney/widgets/transaction.cpp b/kmymoney/widgets/transaction.cpp --- a/kmymoney/widgets/transaction.cpp +++ b/kmymoney/widgets/transaction.cpp @@ -259,7 +259,7 @@ // do we need to switch to the negative balance color? if (index.column() == BalanceColumn) { bool showNegative = m_balance.isNegative(); - if (m_account.accountGroup() == MyMoneyAccount::Liability && !m_balance.isZero()) + if (m_account.accountGroup() == eMyMoney::Account::Liability && !m_balance.isZero()) showNegative = !showNegative; if (showNegative) option.palette.setColor(QPalette::Text, KMyMoneyGlobalSettings::schemeColor(SchemeColor::TransactionErroneous)); @@ -496,21 +496,21 @@ { bool rc = true; switch (m_account.accountType()) { - case MyMoneyAccount::Savings: - case MyMoneyAccount::Cash: - case MyMoneyAccount::Loan: - case MyMoneyAccount::AssetLoan: - case MyMoneyAccount::Asset: - case MyMoneyAccount::Liability: - case MyMoneyAccount::Equity: + case eMyMoney::Account::Savings: + case eMyMoney::Account::Cash: + case eMyMoney::Account::Loan: + case eMyMoney::Account::AssetLoan: + case eMyMoney::Account::Asset: + case eMyMoney::Account::Liability: + case eMyMoney::Account::Equity: rc = KMyMoneyGlobalSettings::alwaysShowNrField(); break; - case MyMoneyAccount::Checkings: - case MyMoneyAccount::CreditCard: + case eMyMoney::Account::Checkings: + case eMyMoney::Account::CreditCard: // the next case is used for the editor when the account // is unknown (eg. when creating new schedules) - case MyMoneyAccount::UnknownAccountType: + case eMyMoney::Account::Unknown: break; default: @@ -824,8 +824,8 @@ { m_category = MyMoneyFile::instance()->accountToCategory(id); switch (MyMoneyFile::instance()->account(id).accountGroup()) { - case MyMoneyAccount::Asset: - case MyMoneyAccount::Liability: + case eMyMoney::Account::Asset: + case eMyMoney::Account::Liability: m_categoryHeader = m_split.shares().isNegative() ? i18n("Transfer to") : i18n("Transfer from"); break; @@ -847,8 +847,8 @@ if ((*it_s).accountId() == m_split.accountId()) continue; MyMoneyAccount acc = MyMoneyFile::instance()->account((*it_s).accountId()); - if (acc.accountGroup() == MyMoneyAccount::Income - || acc.accountGroup() == MyMoneyAccount::Expense) { + if (acc.accountGroup() == eMyMoney::Account::Income + || acc.accountGroup() == eMyMoney::Account::Expense) { // otherwise, we have to determine between deposit and withdrawal action = m_split.shares().isNegative() ? ActionWithdrawal : ActionDeposit; break; @@ -1067,8 +1067,8 @@ singleLineMemo(txt, m_split); } if (txt.isEmpty() && m_rowsRegister < 2) { - if (m_account.accountType() != MyMoneyAccount::Income - && m_account.accountType() != MyMoneyAccount::Expense) { + if (m_account.accountType() != eMyMoney::Account::Income + && m_account.accountType() != eMyMoney::Account::Expense) { txt = m_category; if (txt.isEmpty() && !m_split.value().isZero()) { txt = i18n("*** UNASSIGNED ***"); @@ -1352,8 +1352,8 @@ // For income and expense accounts that only have // two splits we only show one line, because the // account name is already contained in the account column. - if (m_account.accountType() == MyMoneyAccount::Income - || m_account.accountType() == MyMoneyAccount::Expense) { + if (m_account.accountType() == eMyMoney::Account::Income + || m_account.accountType() == eMyMoney::Account::Expense) { if (numRows > 2 && m_transaction.splitCount() == 2) numRows = 1; } diff --git a/kmymoney/widgets/transactionform.cpp b/kmymoney/widgets/transactionform.cpp --- a/kmymoney/widgets/transactionform.cpp +++ b/kmymoney/widgets/transactionform.cpp @@ -312,30 +312,30 @@ m_tabBar->insertTab(KMyMoneyRegister::ActionWithdrawal, i18n("&Withdrawal")); break; - case MyMoneyAccount::CreditCard: + case eMyMoney::Account::CreditCard: m_tabBar->insertTab(KMyMoneyRegister::ActionDeposit, i18n("&Payment")); m_tabBar->insertTab(KMyMoneyRegister::ActionTransfer, i18n("&Transfer")); m_tabBar->insertTab(KMyMoneyRegister::ActionWithdrawal, i18n("&Charge")); break; - case MyMoneyAccount::Liability: - case MyMoneyAccount::Loan: + case eMyMoney::Account::Liability: + case eMyMoney::Account::Loan: m_tabBar->insertTab(KMyMoneyRegister::ActionDeposit, i18n("&Decrease")); m_tabBar->insertTab(KMyMoneyRegister::ActionTransfer, i18n("&Transfer")); m_tabBar->insertTab(KMyMoneyRegister::ActionWithdrawal, i18n("&Increase")); break; - case MyMoneyAccount::Asset: - case MyMoneyAccount::AssetLoan: + case eMyMoney::Account::Asset: + case eMyMoney::Account::AssetLoan: m_tabBar->insertTab(KMyMoneyRegister::ActionDeposit, i18n("&Increase")); m_tabBar->insertTab(KMyMoneyRegister::ActionTransfer, i18n("&Transfer")); m_tabBar->insertTab(KMyMoneyRegister::ActionWithdrawal, i18n("&Decrease")); break; - case MyMoneyAccount::Income: - case MyMoneyAccount::Expense: - case MyMoneyAccount::Investment: - case MyMoneyAccount::Stock: + case eMyMoney::Account::Income: + case eMyMoney::Account::Expense: + case eMyMoney::Account::Investment: + case eMyMoney::Account::Stock: m_tabBar->hide(); break; } diff --git a/kmymoney/wizards/endingbalancedlg/kendingbalancedlg.cpp b/kmymoney/wizards/endingbalancedlg/kendingbalancedlg.cpp --- a/kmymoney/wizards/endingbalancedlg/kendingbalancedlg.cpp +++ b/kmymoney/wizards/endingbalancedlg/kendingbalancedlg.cpp @@ -36,6 +36,7 @@ #include "kmymoneyedit.h" #include "mymoneysplit.h" #include "mymoneyfile.h" +#include "mymoneyinstitution.h" #include "kmymoneycategory.h" #include "kmymoneyaccountselector.h" #include "kmymoneyutils.h" @@ -93,7 +94,7 @@ setStartId(Page_PreviousPostpone); MyMoneyMoney factor(1, 1); - if (d->m_account.accountGroup() == MyMoneyAccount::Liability) + if (d->m_account.accountGroup() == eMyMoney::Account::Liability) factor = -factor; startBalance = MyMoneyMoney(value) * factor; @@ -168,7 +169,7 @@ // start balance = end balance - sum(all cleared transactions // up to statement date) MyMoneyTransactionFilter filter(d->m_account.id()); - filter.addState(MyMoneyTransactionFilter::notReconciled); + filter.addState((int)eMyMoney::TransactionFilter::State::NotReconciled); filter.setReportAllSplits(true); QList > transactionList; @@ -185,14 +186,14 @@ m_statementInfoPageCheckings->m_oldestTransactionDate->setText(i18n("Oldest unmarked transaction: %1", QLocale().toString(oldestTransactionDate))); } - filter.addState(MyMoneyTransactionFilter::cleared); + filter.addState((int)eMyMoney::TransactionFilter::State::Cleared); // retrieve the list from the engine to calculate the starting and ending balance MyMoneyFile::instance()->transactionList(transactionList, filter); MyMoneyMoney balance = MyMoneyFile::instance()->balance(d->m_account.id()); MyMoneyMoney factor(1, 1); - if (d->m_account.accountGroup() == MyMoneyAccount::Liability) + if (d->m_account.accountGroup() == eMyMoney::Account::Liability) factor = -factor; MyMoneyMoney endBalance, startBalance; @@ -273,7 +274,7 @@ const MyMoneyMoney KEndingBalanceDlg::adjustedReturnValue(const MyMoneyMoney& v) const { - return d->m_account.accountGroup() == MyMoneyAccount::Liability ? -v : v; + return d->m_account.accountGroup() == eMyMoney::Account::Liability ? -v : v; } void KEndingBalanceDlg::slotReloadEditWidgets() @@ -291,8 +292,8 @@ // a user request to show all categories in both selectors due to a valid use case. AccountSet aSet; - aSet.addAccountGroup(MyMoneyAccount::Expense); - aSet.addAccountGroup(MyMoneyAccount::Income); + aSet.addAccountGroup(eMyMoney::Account::Expense); + aSet.addAccountGroup(eMyMoney::Account::Income); //FIXME: port aSet.load(m_interestChargeCheckings->m_interestCategoryEdit->selector()); aSet.load(m_interestChargeCheckings->m_chargesCategoryEdit->selector()); diff --git a/kmymoney/wizards/newaccountwizard/knewaccountwizard.cpp b/kmymoney/wizards/newaccountwizard/knewaccountwizard.cpp --- a/kmymoney/wizards/newaccountwizard/knewaccountwizard.cpp +++ b/kmymoney/wizards/newaccountwizard/knewaccountwizard.cpp @@ -56,6 +56,7 @@ using namespace NewAccountWizard; using namespace Icons; +using namespace eMyMoney; namespace NewAccountWizard { @@ -156,7 +157,7 @@ if (m_account.isLoan()) { // in case we lend the money we adjust the account type if (!moneyBorrowed()) - m_account.setAccountType(MyMoneyAccount::AssetLoan); + m_account.setAccountType(Account::AssetLoan); m_account.setLoanAmount(m_loanDetailsPage->m_loanAmount->value()); m_account.setInterestRate(m_loanSchedulePage->firstPaymentDueDate(), m_loanDetailsPage->m_interestRate->value()); m_account.setInterestCalculation(m_loanDetailsPage->m_paymentDue->currentIndex() == 0 ? MyMoneyAccountLoan::paymentReceived : MyMoneyAccountLoan::paymentDue); @@ -165,7 +166,7 @@ m_account.setTerm(m_loanDetailsPage->term()); m_account.setPeriodicPayment(m_loanDetailsPage->m_paymentAmount->value()); m_account.setPayee(m_generalLoanInfoPage->m_payee->selectedItem()); - m_account.setInterestCompounding(m_generalLoanInfoPage->m_compoundFrequency->currentItem()); + m_account.setInterestCompounding((int)m_generalLoanInfoPage->m_compoundFrequency->currentItem()); if (!m_account.fixedInterestRate()) { m_account.setNextInterestChange(m_generalLoanInfoPage->m_interestChangeDateEdit->date()); @@ -206,7 +207,7 @@ { return m_accountTypePage->allowsParentAccount() ? m_hierarchyPage->parentAccount() - : (m_accountTypePage->accountType() == MyMoneyAccount::Loan + : (m_accountTypePage->accountType() == Account::Loan ? m_generalLoanInfoPage->parentAccount() : m_accountTypePage->parentAccount()); } @@ -214,10 +215,10 @@ MyMoneyAccount Wizard::brokerageAccount() const { MyMoneyAccount account; - if (m_account.accountType() == MyMoneyAccount::Investment + if (m_account.accountType() == Account::Investment && m_brokeragepage->m_createBrokerageButton->isChecked()) { account.setName(m_account.brokerageName()); - account.setAccountType(MyMoneyAccount::Checkings); + account.setAccountType(Account::Checkings); account.setInstitutionId(m_account.institutionId()); account.setOpeningDate(m_account.openingDate()); account.setCurrencyId(m_brokeragepage->m_brokerageCurrency->security().id()); @@ -234,12 +235,12 @@ m_schedule = MyMoneySchedule(); if (!m_account.id().isEmpty()) { - if (m_schedulePage->m_reminderCheckBox->isChecked() && (m_account.accountType() == MyMoneyAccount::CreditCard)) { + if (m_schedulePage->m_reminderCheckBox->isChecked() && (m_account.accountType() == Account::CreditCard)) { m_schedule.setName(m_schedulePage->m_name->text()); - m_schedule.setType(MyMoneySchedule::TYPE_TRANSFER); - m_schedule.setPaymentType(static_cast(m_schedulePage->m_method->currentItem())); + m_schedule.setType(Schedule::Type::Transfer); + m_schedule.setPaymentType(static_cast(m_schedulePage->m_method->currentItem())); m_schedule.setFixed(false); - m_schedule.setOccurrencePeriod(MyMoneySchedule::OCCUR_MONTHLY); + m_schedule.setOccurrencePeriod(Schedule::Occurrence::Monthly); m_schedule.setOccurrenceMultiplier(1); MyMoneyTransaction t; MyMoneySplit s; @@ -262,11 +263,11 @@ } else if (m_account.isLoan()) { m_schedule.setName(i18n("Loan payment for %1", m_accountTypePage->m_accountName->text())); - m_schedule.setType(MyMoneySchedule::TYPE_LOANPAYMENT); + m_schedule.setType(Schedule::Type::LoanPayment); if (moneyBorrowed()) - m_schedule.setPaymentType(MyMoneySchedule::STYPE_DIRECTDEBIT); + m_schedule.setPaymentType(Schedule::PaymentType::DirectDebit); else - m_schedule.setPaymentType(MyMoneySchedule::STYPE_DIRECTDEPOSIT); + m_schedule.setPaymentType(Schedule::PaymentType::DirectDeposit); m_schedule.setFixed(true); m_schedule.setOccurrence(m_generalLoanInfoPage->m_paymentFrequency->currentItem()); @@ -337,10 +338,10 @@ MyMoneyMoney Wizard::openingBalance() const { // equity accounts don't have an opening balance - if (m_accountTypePage->accountType() == MyMoneyAccount::Equity) + if (m_accountTypePage->accountType() == Account::Equity) return MyMoneyMoney(); - if (m_accountTypePage->accountType() == MyMoneyAccount::Loan) { + if (m_accountTypePage->accountType() == Account::Loan) { if (m_generalLoanInfoPage->recordAllPayments()) return MyMoneyMoney(); if (moneyBorrowed()) @@ -468,19 +469,19 @@ WizardPage(StepAccount, this, wizard), m_showPriceWarning(true) { - m_typeSelection->insertItem(i18n("Checking"), MyMoneyAccount::Checkings); - m_typeSelection->insertItem(i18n("Savings"), MyMoneyAccount::Savings); - m_typeSelection->insertItem(i18n("Credit Card"), MyMoneyAccount::CreditCard); - m_typeSelection->insertItem(i18n("Cash"), MyMoneyAccount::Cash); - m_typeSelection->insertItem(i18n("Loan"), MyMoneyAccount::Loan); - m_typeSelection->insertItem(i18n("Investment"), MyMoneyAccount::Investment); - m_typeSelection->insertItem(i18n("Asset"), MyMoneyAccount::Asset); - m_typeSelection->insertItem(i18n("Liability"), MyMoneyAccount::Liability); + m_typeSelection->insertItem(i18n("Checking"), (int)Account::Checkings); + m_typeSelection->insertItem(i18n("Savings"), (int)Account::Savings); + m_typeSelection->insertItem(i18n("Credit Card"), (int)Account::CreditCard); + m_typeSelection->insertItem(i18n("Cash"), (int)Account::Cash); + m_typeSelection->insertItem(i18n("Loan"), (int)Account::Loan); + m_typeSelection->insertItem(i18n("Investment"), (int)Account::Investment); + m_typeSelection->insertItem(i18n("Asset"), (int)Account::Asset); + m_typeSelection->insertItem(i18n("Liability"), (int)Account::Liability); if (KMyMoneyGlobalSettings::expertMode()) { - m_typeSelection->insertItem(i18n("Equity"), MyMoneyAccount::Equity); + m_typeSelection->insertItem(i18n("Equity"), (int)Account::Equity); } - m_typeSelection->setCurrentItem(MyMoneyAccount::Checkings); + m_typeSelection->setCurrentItem((int)Account::Checkings); m_currencyComboBox->setSecurity(MyMoneyFile::instance()->baseCurrency()); @@ -499,33 +500,33 @@ void AccountTypePage::slotUpdateType(int i) { - hideShowPages(static_cast(i)); - m_openingBalance->setDisabled(static_cast(i) == MyMoneyAccount::Equity); + hideShowPages(static_cast(i)); + m_openingBalance->setDisabled(static_cast(i) == Account::Equity); } -void AccountTypePage::hideShowPages(MyMoneyAccount::accountTypeE accountType) const +void AccountTypePage::hideShowPages(Account accountType) const { - bool hideSchedulePage = (accountType != MyMoneyAccount::CreditCard) - && (accountType != MyMoneyAccount::Loan); - bool hideLoanPage = (accountType != MyMoneyAccount::Loan); + bool hideSchedulePage = (accountType != Account::CreditCard) + && (accountType != Account::Loan); + bool hideLoanPage = (accountType != Account::Loan); m_wizard->setStepHidden(StepDetails, hideLoanPage); m_wizard->setStepHidden(StepPayments, hideLoanPage); m_wizard->setStepHidden(StepFees, hideLoanPage); m_wizard->setStepHidden(StepSchedule, hideSchedulePage); - m_wizard->setStepHidden(StepPayout, (accountType != MyMoneyAccount::Loan)); - m_wizard->setStepHidden(StepBroker, accountType != MyMoneyAccount::Investment); - m_wizard->setStepHidden(StepParentAccount, accountType == MyMoneyAccount::Loan); + m_wizard->setStepHidden(StepPayout, (accountType != Account::Loan)); + m_wizard->setStepHidden(StepBroker, accountType != Account::Investment); + m_wizard->setStepHidden(StepParentAccount, accountType == Account::Loan); // Force an update of the steps in case the list has changed m_wizard->reselectStep(); } KMyMoneyWizardPage* AccountTypePage::nextPage() const { - if (accountType() == MyMoneyAccount::Loan) + if (accountType() == Account::Loan) return m_wizard->m_generalLoanInfoPage; - if (accountType() == MyMoneyAccount::CreditCard) + if (accountType() == Account::CreditCard) return m_wizard->m_schedulePage; - if (accountType() == MyMoneyAccount::Investment) + if (accountType() == Account::Investment) return m_wizard->m_brokeragepage; return m_wizard->m_hierarchyPage; } @@ -600,9 +601,9 @@ return rc; } -MyMoneyAccount::accountTypeE AccountTypePage::accountType() const +Account AccountTypePage::accountType() const { - return static_cast(m_typeSelection->currentItem()); + return static_cast(m_typeSelection->currentItem()); } const MyMoneySecurity& AccountTypePage::currency() const @@ -612,11 +613,11 @@ void AccountTypePage::setAccount(const MyMoneyAccount& acc) { - if (acc.accountType() != MyMoneyAccount::UnknownAccountType) { - if (acc.accountType() == MyMoneyAccount::AssetLoan) { - m_typeSelection->setCurrentItem(MyMoneyAccount::Loan); + if (acc.accountType() != Account::Unknown) { + if (acc.accountType() == Account::AssetLoan) { + m_typeSelection->setCurrentItem((int)Account::Loan); } else { - m_typeSelection->setCurrentItem(acc.accountType()); + m_typeSelection->setCurrentItem((int)acc.accountType()); } } m_openingDate->setDate(acc.openingDate()); @@ -626,12 +627,12 @@ const MyMoneyAccount& AccountTypePage::parentAccount() { switch (accountType()) { - case MyMoneyAccount::CreditCard: - case MyMoneyAccount::Liability: - case MyMoneyAccount::Loan: // Can be either but we return liability here + case Account::CreditCard: + case Account::Liability: + case Account::Loan: // Can be either but we return liability here return MyMoneyFile::instance()->liability(); break; - case MyMoneyAccount::Equity: + case Account::Equity: return MyMoneyFile::instance()->equity(); default: break; @@ -641,7 +642,7 @@ bool AccountTypePage::allowsParentAccount() const { - return accountType() != MyMoneyAccount::Loan; + return accountType() != Account::Loan; } BrokeragePage::BrokeragePage(Wizard* wizard) : @@ -696,16 +697,16 @@ connect(MyMoneyFile::instance(), SIGNAL(dataChanged()), this, SLOT(slotLoadWidgets())); - m_method->insertItem(i18n("Write check"), MyMoneySchedule::STYPE_WRITECHEQUE); + m_method->insertItem(i18n("Write check"), (int)Schedule::PaymentType::WriteChecque); #if 0 - m_method->insertItem(i18n("Direct debit"), MyMoneySchedule::STYPE_DIRECTDEBIT); - m_method->insertItem(i18n("Bank transfer"), MyMoneySchedule::STYPE_BANKTRANSFER); + m_method->insertItem(i18n("Direct debit"), Schedule::PaymentType::DirectDebit); + m_method->insertItem(i18n("Bank transfer"), Schedule::PaymentType::BankTransfer); #endif - m_method->insertItem(i18n("Standing order"), MyMoneySchedule::STYPE_STANDINGORDER); - m_method->insertItem(i18n("Manual deposit"), MyMoneySchedule::STYPE_MANUALDEPOSIT); - m_method->insertItem(i18n("Direct deposit"), MyMoneySchedule::STYPE_DIRECTDEPOSIT); - m_method->insertItem(i18nc("Other payment method", "Other"), MyMoneySchedule::STYPE_OTHER); - m_method->setCurrentItem(MyMoneySchedule::STYPE_DIRECTDEBIT); + m_method->insertItem(i18n("Standing order"), (int)Schedule::PaymentType::StandingOrder); + m_method->insertItem(i18n("Manual deposit"), (int)Schedule::PaymentType::ManualDeposit); + m_method->insertItem(i18n("Direct deposit"), (int)Schedule::PaymentType::DirectDeposit); + m_method->insertItem(i18nc("Other payment method", "Other"), (int)Schedule::PaymentType::Other); + m_method->setCurrentItem((int)Schedule::PaymentType::DirectDebit); slotLoadWidgets(); } @@ -751,7 +752,7 @@ void CreditCardSchedulePage::slotLoadWidgets() { AccountSet set; - set.addAccountGroup(MyMoneyAccount::Asset); + set.addAccountGroup(Account::Asset); set.load(m_paymentAccount->selector()); m_payee->loadPayees(MyMoneyFile::instance()->payeeList()); @@ -770,12 +771,12 @@ m_mandatoryGroup->add(m_payee); // remove the unsupported payment and compounding frequencies and setup default - m_paymentFrequency->removeItem(MyMoneySchedule::OCCUR_ONCE); - m_paymentFrequency->removeItem(MyMoneySchedule::OCCUR_EVERYOTHERYEAR); - m_paymentFrequency->setCurrentItem(MyMoneySchedule::OCCUR_MONTHLY); - m_compoundFrequency->removeItem(MyMoneySchedule::OCCUR_ONCE); - m_compoundFrequency->removeItem(MyMoneySchedule::OCCUR_EVERYOTHERYEAR); - m_compoundFrequency->setCurrentItem(MyMoneySchedule::OCCUR_MONTHLY); + m_paymentFrequency->removeItem((int)Schedule::Occurrence::Once); + m_paymentFrequency->removeItem((int)Schedule::Occurrence::EveryOtherYear); + m_paymentFrequency->setCurrentItem((int)Schedule::Occurrence::Monthly); + m_compoundFrequency->removeItem((int)Schedule::Occurrence::Once); + m_compoundFrequency->removeItem((int)Schedule::Occurrence::EveryOtherYear); + m_compoundFrequency->setCurrentItem((int)Schedule::Occurrence::Monthly); slotLoadWidgets(); @@ -896,17 +897,17 @@ switch (m_wizard->m_generalLoanInfoPage->m_paymentFrequency->currentItem()) { default: - m_termUnit->insertItem(i18n("Payments"), MyMoneySchedule::OCCUR_ONCE); - m_termUnit->setCurrentItem(MyMoneySchedule::OCCUR_ONCE); + m_termUnit->insertItem(i18n("Payments"), (int)Schedule::Occurrence::Once); + m_termUnit->setCurrentItem((int)Schedule::Occurrence::Once); break; - case MyMoneySchedule::OCCUR_MONTHLY: - m_termUnit->insertItem(i18n("Months"), MyMoneySchedule::OCCUR_MONTHLY); - m_termUnit->insertItem(i18n("Years"), MyMoneySchedule::OCCUR_YEARLY); - m_termUnit->setCurrentItem(MyMoneySchedule::OCCUR_MONTHLY); + case Schedule::Occurrence::Monthly: + m_termUnit->insertItem(i18n("Months"), (int)Schedule::Occurrence::Monthly); + m_termUnit->insertItem(i18n("Years"), (int)Schedule::Occurrence::Yearly); + m_termUnit->setCurrentItem((int)Schedule::Occurrence::Monthly); break; - case MyMoneySchedule::OCCUR_YEARLY: - m_termUnit->insertItem(i18n("Years"), MyMoneySchedule::OCCUR_YEARLY); - m_termUnit->setCurrentItem(MyMoneySchedule::OCCUR_YEARLY); + case Schedule::Occurrence::Yearly: + m_termUnit->insertItem(i18n("Years"), (int)Schedule::Occurrence::Yearly); + m_termUnit->setCurrentItem((int)Schedule::Occurrence::Yearly); break; } } @@ -1098,11 +1099,11 @@ if (m_termAmount->value() != 0) { factor = 1; switch (m_termUnit->currentItem()) { - case MyMoneySchedule::OCCUR_YEARLY: // years + case Schedule::Occurrence::Yearly: // years factor = 12; // intentional fall through - case MyMoneySchedule::OCCUR_MONTHLY: // months + case Schedule::Occurrence::Monthly: // months factor *= 30; factor *= m_termAmount->value(); // factor now is the duration in days. we divide this by the @@ -1111,10 +1112,10 @@ break; default: - qDebug("Unknown term unit %d in LoanDetailsPage::term(). Using payments.", m_termUnit->currentItem()); + qDebug("Unknown term unit %d in LoanDetailsPage::term(). Using payments.", (int)m_termUnit->currentItem()); // intentional fall through - case MyMoneySchedule::OCCUR_ONCE: // payments + case Schedule::Occurrence::Once: // payments factor = m_termAmount->value(); break; } @@ -1127,26 +1128,26 @@ long vl = qFloor(val); QString valString; - MyMoneySchedule::occurrenceE unit = m_termUnit->currentItem(); + Schedule::Occurrence unit = m_termUnit->currentItem(); - if ((unit == MyMoneySchedule::OCCUR_MONTHLY) + if ((unit == Schedule::Occurrence::Monthly) && ((vl % 12) == 0)) { vl /= 12; - unit = MyMoneySchedule::OCCUR_YEARLY; + unit = Schedule::Occurrence::Yearly; } switch (unit) { - case MyMoneySchedule::OCCUR_MONTHLY: + case Schedule::Occurrence::Monthly: valString = i18np("one month", "%1 months", vl); - m_termUnit->setCurrentItem(MyMoneySchedule::OCCUR_MONTHLY); + m_termUnit->setCurrentItem((int)Schedule::Occurrence::Monthly); break; - case MyMoneySchedule::OCCUR_YEARLY: + case Schedule::Occurrence::Yearly: valString = i18np("one year", "%1 years", vl); - m_termUnit->setCurrentItem(MyMoneySchedule::OCCUR_YEARLY); + m_termUnit->setCurrentItem((int)Schedule::Occurrence::Yearly); break; default: valString = i18np("one payment", "%1 payments", vl); - m_termUnit->setCurrentItem(MyMoneySchedule::OCCUR_ONCE); + m_termUnit->setCurrentItem((int)Schedule::Occurrence::Once); break; } m_termAmount->setValue(vl); @@ -1347,13 +1348,13 @@ { AccountSet set; if (m_wizard->moneyBorrowed()) - set.addAccountGroup(MyMoneyAccount::Expense); + set.addAccountGroup(Account::Expense); else - set.addAccountGroup(MyMoneyAccount::Income); + set.addAccountGroup(Account::Income); set.load(m_interestCategory->selector()); set.clear(); - set.addAccountGroup(MyMoneyAccount::Asset); + set.addAccountGroup(Account::Asset); set.load(m_paymentAccount->selector()); } @@ -1402,7 +1403,7 @@ void LoanPayoutPage::slotCreateAssetAccount() { MyMoneyAccount acc; - acc.setAccountType(MyMoneyAccount::Asset); + acc.setAccountType(Account::Asset); acc.setOpeningDate(m_wizard->m_accountTypePage->m_openingDate->date()); emit m_wizard->createAccount(acc); @@ -1415,11 +1416,11 @@ void LoanPayoutPage::slotLoadWidgets() { AccountSet set; - set.addAccountGroup(MyMoneyAccount::Asset); + set.addAccountGroup(Account::Asset); set.load(m_assetAccount->selector()); set.clear(); - set.addAccountType(MyMoneyAccount::Loan); + set.addAccountType(Account::Loan); set.load(m_loanAccount->selector()); } @@ -1492,7 +1493,7 @@ m_filterProxyModel = new HierarchyFilterProxyModel(this); m_filterProxyModel->setHideClosedAccounts(true); m_filterProxyModel->setHideEquityAccounts(!KMyMoneyGlobalSettings::expertMode()); - m_filterProxyModel->addAccountGroup(QVector {MyMoneyAccount::Asset, MyMoneyAccount::Liability}); + m_filterProxyModel->addAccountGroup(QVector {Account::Asset, Account::Liability}); auto const model = Models::instance()->accountsModel(); m_filterProxyModel->setSourceModel(model); m_filterProxyModel->setSourceColumns(model->getColumns()); @@ -1509,7 +1510,7 @@ // Ensure that the list reflects the Account Type MyMoneyAccount topAccount = m_wizard->m_accountTypePage->parentAccount(); m_filterProxyModel->clear(); - m_filterProxyModel->addAccountGroup(QVector {topAccount.accountGroup()}); + m_filterProxyModel->addAccountGroup(QVector {topAccount.accountGroup()}); m_parentAccounts->expandAll(); } @@ -1570,7 +1571,7 @@ if (!acc.isLoan()) m_dataList->append(i18n("Subaccount of %1", m_wizard->parentAccount().name())); QString accTypeText; - if (acc.accountType() == MyMoneyAccount::AssetLoan) + if (acc.accountType() == Account::AssetLoan) accTypeText = i18n("Loan"); else accTypeText = m_wizard->m_accountTypePage->m_typeSelection->currentText(); @@ -1594,7 +1595,7 @@ } } - if (acc.accountType() == MyMoneyAccount::Investment) { + if (acc.accountType() == Account::Investment) { if (m_wizard->m_brokeragepage->m_createBrokerageButton->isChecked()) { m_dataList->setFontWeight(QFont::Bold); m_dataList->append(i18n("Brokerage Account")); @@ -1648,7 +1649,7 @@ m_dataList->append(i18n("Schedule information")); m_dataList->setFontWeight(QFont::Normal); m_dataList->append(i18nc("Schedule name", "Name: %1", sch.name())); - if (acc.accountType() == MyMoneyAccount::CreditCard) { + if (acc.accountType() == Account::CreditCard) { MyMoneyAccount paymentAccount = MyMoneyFile::instance()->account(m_wizard->m_schedulePage->m_paymentAccount->selectedItem()); m_dataList->append(i18n("Occurrence: Monthly")); m_dataList->append(i18n("Paid from %1", paymentAccount.name())); diff --git a/kmymoney/wizards/newaccountwizard/knewaccountwizard_p.h b/kmymoney/wizards/newaccountwizard/knewaccountwizard_p.h --- a/kmymoney/wizards/newaccountwizard/knewaccountwizard_p.h +++ b/kmymoney/wizards/newaccountwizard/knewaccountwizard_p.h @@ -121,7 +121,7 @@ return m_accountName; } - MyMoneyAccount::accountTypeE accountType(void) const; + eMyMoney::Account accountType(void) const; const MyMoneyAccount& parentAccount(void); bool allowsParentAccount(void) const; const MyMoneySecurity& currency(void) const; @@ -129,7 +129,7 @@ void setAccount(const MyMoneyAccount& acc); private: - void hideShowPages(MyMoneyAccount::accountTypeE i) const; + void hideShowPages(eMyMoney::Account i) const; void priceWarning(bool); private slots: diff --git a/kmymoney/wizards/newinvestmentwizard/knewinvestmentwizard.cpp b/kmymoney/wizards/newinvestmentwizard/knewinvestmentwizard.cpp --- a/kmymoney/wizards/newinvestmentwizard/knewinvestmentwizard.cpp +++ b/kmymoney/wizards/newinvestmentwizard/knewinvestmentwizard.cpp @@ -207,8 +207,8 @@ if (m_createAccount) { // now that the security exists, we can add the account to store it m_account.setName(field("investmentName").toString()); - if (m_account.accountType() == MyMoneyAccount::UnknownAccountType) - m_account.setAccountType(MyMoneyAccount::Stock); + if (m_account.accountType() == eMyMoney::Account::Unknown) + m_account.setAccountType(eMyMoney::Account::Stock); m_account.setCurrencyId(m_security.id()); switch (m_investmentDetailsPage->priceMode()) { diff --git a/kmymoney/wizards/newloanwizard/durationwizardpage.cpp b/kmymoney/wizards/newloanwizard/durationwizardpage.cpp --- a/kmymoney/wizards/newloanwizard/durationwizardpage.cpp +++ b/kmymoney/wizards/newloanwizard/durationwizardpage.cpp @@ -30,13 +30,16 @@ // ---------------------------------------------------------------------------- // Project Includes +#include "mymoneyenums.h" + +using namespace eMyMoney; DurationWizardPage::DurationWizardPage(QWidget *parent) : DurationWizardPageDecl(parent) { - m_durationUnitEdit->insertItem(i18n("Months"), static_cast(MyMoneySchedule::OCCUR_MONTHLY)); - m_durationUnitEdit->insertItem(i18n("Years"), static_cast(MyMoneySchedule::OCCUR_YEARLY)); - m_durationUnitEdit->insertItem(i18n("Payments"), static_cast(MyMoneySchedule::OCCUR_ONCE)); + m_durationUnitEdit->insertItem(i18n("Months"), static_cast(Schedule::Occurrence::Monthly)); + m_durationUnitEdit->insertItem(i18n("Years"), static_cast(Schedule::Occurrence::Yearly)); + m_durationUnitEdit->insertItem(i18n("Payments"), static_cast(Schedule::Occurrence::Once)); // Register the fields with the QWizard and connect the // appropriate signals to update the "Next" button correctly @@ -66,19 +69,19 @@ if (m_durationValueEdit->value() != 0) { factor = 1; switch (m_durationUnitEdit->currentItem()) { - case MyMoneySchedule::OCCUR_YEARLY: // years + case (int)Schedule::Occurrence::Yearly: // years factor = 12; // intentional fall through - case MyMoneySchedule::OCCUR_MONTHLY: // months + case (int)Schedule::Occurrence::Monthly: // months factor *= 30; factor *= m_durationValueEdit->value(); // factor now is the duration in days. we divide this by the // payment frequency and get the number of payments - factor /= MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::occurrenceE(field("paymentFrequencyUnitEdit").toInt())); + factor /= MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence(field("paymentFrequencyUnitEdit").toInt())); break; - case MyMoneySchedule::OCCUR_ONCE: // payments + case (int)Schedule::Occurrence::Once: // payments factor = m_durationValueEdit->value(); break; } @@ -91,27 +94,27 @@ long vl = qFloor(val); QString valString; - MyMoneySchedule::occurrenceE unit; - unit = MyMoneySchedule::occurrenceE(field("paymentFrequencyUnitEdit").toInt()); + Schedule::Occurrence unit; + unit = Schedule::Occurrence(field("paymentFrequencyUnitEdit").toInt()); - if ((unit == MyMoneySchedule::OCCUR_MONTHLY) + if ((unit == Schedule::Occurrence::Monthly) && ((vl % 12) == 0)) { vl /= 12; - unit = MyMoneySchedule::OCCUR_YEARLY; + unit = Schedule::Occurrence::Yearly; } switch (unit) { - case MyMoneySchedule::OCCUR_MONTHLY: + case Schedule::Occurrence::Monthly: valString = i18np("one month", "%1 months", vl); - m_durationUnitEdit->setCurrentItem(static_cast(MyMoneySchedule::OCCUR_MONTHLY)); + m_durationUnitEdit->setCurrentItem(static_cast(Schedule::Occurrence::Monthly)); break; - case MyMoneySchedule::OCCUR_YEARLY: + case Schedule::Occurrence::Yearly: valString = i18np("one year", "%1 years", vl); - m_durationUnitEdit->setCurrentItem(static_cast(MyMoneySchedule::OCCUR_YEARLY)); + m_durationUnitEdit->setCurrentItem(static_cast(Schedule::Occurrence::Yearly)); break; default: valString = i18np("one payment", "%1 payments", vl); - m_durationUnitEdit->setCurrentItem(static_cast(MyMoneySchedule::OCCUR_ONCE)); + m_durationUnitEdit->setCurrentItem(static_cast(Schedule::Occurrence::Once)); break; } m_durationValueEdit->setValue(vl); diff --git a/kmymoney/wizards/newloanwizard/interestcategorywizardpage.cpp b/kmymoney/wizards/newloanwizard/interestcategorywizardpage.cpp --- a/kmymoney/wizards/newloanwizard/interestcategorywizardpage.cpp +++ b/kmymoney/wizards/newloanwizard/interestcategorywizardpage.cpp @@ -72,10 +72,10 @@ if (field("borrowButton").toBool()) { base = file->expense(); - acc.setAccountType(MyMoneyAccount::Expense); + acc.setAccountType(eMyMoney::Account::Expense); } else { base = file->income(); - acc.setAccountType(MyMoneyAccount::Income); + acc.setAccountType(eMyMoney::Account::Income); } acc.setParentAccountId(base.id()); diff --git a/kmymoney/wizards/newloanwizard/keditloanwizard.cpp b/kmymoney/wizards/newloanwizard/keditloanwizard.cpp --- a/kmymoney/wizards/newloanwizard/keditloanwizard.cpp +++ b/kmymoney/wizards/newloanwizard/keditloanwizard.cpp @@ -44,6 +44,7 @@ #include "kmymoneyedit.h" #include "kmymoneyaccountselector.h" #include "mymoneyfile.h" +#include "mymoneyinstitution.h" KEditLoanWizard::KEditLoanWizard(const MyMoneyAccount& account, QWidget *parent) : KNewLoanWizard(parent) @@ -126,7 +127,7 @@ m_interestEditPage->m_newInterestRateEdit->setPrecision(3); m_interestEditPage->m_interestRateLabel->setText(QString(" ") + ir.formatMoney("", 3) + QString("%")); - m_paymentFrequencyPage->m_paymentFrequencyUnitEdit->setCurrentIndex(m_paymentFrequencyPage->m_paymentFrequencyUnitEdit->findData(QVariant(m_schedule.occurrencePeriod()), Qt::UserRole, Qt::MatchExactly)); + m_paymentFrequencyPage->m_paymentFrequencyUnitEdit->setCurrentIndex(m_paymentFrequencyPage->m_paymentFrequencyUnitEdit->findData(QVariant((int)m_schedule.occurrencePeriod()), Qt::UserRole, Qt::MatchExactly)); m_durationPage->updateTermWidgets(m_account.term()); // the base payment (amortization and interest) is determined @@ -444,7 +445,7 @@ { MyMoneySchedule sched = m_schedule; sched.setTransaction(transaction()); - sched.setOccurrence(MyMoneySchedule::occurrenceE(field("paymentFrequencyUnitEdit").toInt())); + sched.setOccurrence(eMyMoney::Schedule::Occurrence(field("paymentFrequencyUnitEdit").toInt())); if (field("nextDueDateEdit").toDate() < m_schedule.startDate()) sched.setStartDate(field("nextDueDateEdit").toDate()); diff --git a/kmymoney/wizards/newloanwizard/knewloanwizard.cpp b/kmymoney/wizards/newloanwizard/knewloanwizard.cpp --- a/kmymoney/wizards/newloanwizard/knewloanwizard.cpp +++ b/kmymoney/wizards/newloanwizard/knewloanwizard.cpp @@ -348,7 +348,7 @@ // FIXME: for now, we only support periodic compounding calc.setDisc(); - PF = MyMoneySchedule::eventsPerYear(MyMoneySchedule::occurrenceE(field("paymentFrequencyUnitEdit").toInt())); + PF = MyMoneySchedule::eventsPerYear(eMyMoney::Schedule::Occurrence(field("paymentFrequencyUnitEdit").toInt())); if (PF == 0) return 0; calc.setPF(PF); @@ -512,23 +512,23 @@ AccountSet interestSet, assetSet; if (field("borrowButton").toBool()) { - interestSet.addAccountType(MyMoneyAccount::Expense); + interestSet.addAccountType(eMyMoney::Account::Expense); } else { - interestSet.addAccountType(MyMoneyAccount::Income); + interestSet.addAccountType(eMyMoney::Account::Income); } if (m_interestCategoryPage) interestSet.load(m_interestCategoryPage->m_interestAccountEdit); - assetSet.addAccountType(MyMoneyAccount::Checkings); - assetSet.addAccountType(MyMoneyAccount::Savings); - assetSet.addAccountType(MyMoneyAccount::Cash); - assetSet.addAccountType(MyMoneyAccount::Asset); - assetSet.addAccountType(MyMoneyAccount::Currency); + assetSet.addAccountType(eMyMoney::Account::Checkings); + assetSet.addAccountType(eMyMoney::Account::Savings); + assetSet.addAccountType(eMyMoney::Account::Cash); + assetSet.addAccountType(eMyMoney::Account::Asset); + assetSet.addAccountType(eMyMoney::Account::Currency); if (m_assetAccountPage) assetSet.load(m_assetAccountPage->m_assetAccountEdit); - assetSet.addAccountType(MyMoneyAccount::CreditCard); - assetSet.addAccountType(MyMoneyAccount::Liability); + assetSet.addAccountType(eMyMoney::Account::CreditCard); + assetSet.addAccountType(eMyMoney::Account::Liability); if (m_schedulePage) assetSet.load(m_schedulePage->m_paymentAccountEdit); } @@ -608,9 +608,9 @@ MyMoneySchedule KNewLoanWizard::schedule() const { MyMoneySchedule sched(field("nameEdit").toString(), - MyMoneySchedule::TYPE_LOANPAYMENT, - MyMoneySchedule::occurrenceE(field("paymentFrequencyUnitEdit").toInt()), 1, - MyMoneySchedule::STYPE_OTHER, + eMyMoney::Schedule::Type::LoanPayment, + eMyMoney::Schedule::Occurrence(field("paymentFrequencyUnitEdit").toInt()), 1, + eMyMoney::Schedule::PaymentType::Other, QDate(), QDate(), false, diff --git a/kmymoney/wizards/newloanwizard/loanattributeswizardpage.cpp b/kmymoney/wizards/newloanwizard/loanattributeswizardpage.cpp --- a/kmymoney/wizards/newloanwizard/loanattributeswizardpage.cpp +++ b/kmymoney/wizards/newloanwizard/loanattributeswizardpage.cpp @@ -32,6 +32,7 @@ #include "knewbankdlg.h" #include "mymoneyfile.h" +#include "mymoneyexception.h" LoanAttributesWizardPage::LoanAttributesWizardPage(QWidget *parent) : LoanAttributesWizardPageDecl(parent) diff --git a/kmymoney/wizards/newloanwizard/paymentfrequencywizardpage.cpp b/kmymoney/wizards/newloanwizard/paymentfrequencywizardpage.cpp --- a/kmymoney/wizards/newloanwizard/paymentfrequencywizardpage.cpp +++ b/kmymoney/wizards/newloanwizard/paymentfrequencywizardpage.cpp @@ -33,5 +33,5 @@ : PaymentFrequencyWizardPageDecl(parent) { registerField("paymentFrequencyUnitEdit", m_paymentFrequencyUnitEdit, "data", SIGNAL(currentDataChanged(QVariant))); - m_paymentFrequencyUnitEdit->setCurrentIndex(m_paymentFrequencyUnitEdit->findData(QVariant(MyMoneySchedule::OCCUR_MONTHLY), Qt::UserRole, Qt::MatchExactly)); + m_paymentFrequencyUnitEdit->setCurrentIndex(m_paymentFrequencyUnitEdit->findData(QVariant((int)eMyMoney::Schedule::Occurrence::Monthly), Qt::UserRole, Qt::MatchExactly)); } diff --git a/kmymoney/wizards/newloanwizard/summarywizardpage.cpp b/kmymoney/wizards/newloanwizard/summarywizardpage.cpp --- a/kmymoney/wizards/newloanwizard/summarywizardpage.cpp +++ b/kmymoney/wizards/newloanwizard/summarywizardpage.cpp @@ -32,6 +32,8 @@ #include "mymoneyaccount.h" #include "mymoneyexception.h" #include "mymoneyfile.h" +#include "mymoneypayee.h" +#include "mymoneyschedule.h" SummaryWizardPage::SummaryWizardPage(QWidget *parent) : SummaryWizardPageDecl(parent) @@ -67,7 +69,7 @@ m_summaryInterestDue->setText(i18n("on reception")); else m_summaryInterestDue->setText(i18n("on due date")); - m_summaryPaymentFrequency->setText(MyMoneySchedule::occurrenceToString(MyMoneySchedule::occurrenceE(field("paymentFrequencyUnitEdit").toInt()))); + m_summaryPaymentFrequency->setText(MyMoneySchedule::occurrenceToString(eMyMoney::Schedule::Occurrence(field("paymentFrequencyUnitEdit").toInt()))); m_summaryAmount->setText(field("loanAmount6").toString()); m_summaryInterestRate->setText(field("interestRate6").toString()); m_summaryTerm->setText(field("duration6").toString()); diff --git a/kmymoney/wizards/newuserwizard/knewuserwizard.cpp b/kmymoney/wizards/newuserwizard/knewuserwizard.cpp --- a/kmymoney/wizards/newuserwizard/knewuserwizard.cpp +++ b/kmymoney/wizards/newuserwizard/knewuserwizard.cpp @@ -126,7 +126,7 @@ acc.setNumber(m_accountPage->m_accountNumberEdit->text()); acc.setOpeningDate(m_accountPage->m_openingDateEdit->date()); acc.setCurrencyId(m_baseCurrency.id()); - acc.setAccountType(MyMoneyAccount::Checkings); + acc.setAccountType(eMyMoney::Account::Checkings); } return acc; } diff --git a/tools/xea2kmt.cpp b/tools/xea2kmt.cpp --- a/tools/xea2kmt.cpp +++ b/tools/xea2kmt.cpp @@ -24,6 +24,9 @@ #include #include +#include "mymoneyenums.h" + +using namespace eMyMoney; QDebug operator <<(QDebug out, const QXmlStreamNamespaceDeclaration &a) { @@ -72,21 +75,21 @@ int toKMyMoneyAccountType(const QString &type) { - if(type == "ROOT") return MyMoneyAccount::UnknownAccountType; - else if (type == "BANK") return MyMoneyAccount::Checkings; - else if (type == "CASH") return MyMoneyAccount::Cash; - else if (type == "CREDIT") return MyMoneyAccount::CreditCard; - else if (type == "INVEST") return MyMoneyAccount::Investment; - else if (type == "RECEIVABLE") return MyMoneyAccount::Asset; - else if (type == "ASSET") return MyMoneyAccount::Asset; - else if (type == "PAYABLE") return MyMoneyAccount::Liability; - else if (type == "LIABILITY") return MyMoneyAccount::Liability; - else if (type == "CURRENCY") return MyMoneyAccount::Currency; - else if (type == "INCOME") return MyMoneyAccount::Income; - else if (type == "EXPENSE") return MyMoneyAccount::Expense; - else if (type == "STOCK") return MyMoneyAccount::Stock; - else if (type == "MUTUAL") return MyMoneyAccount::Stock; - else if (type == "EQUITY") return MyMoneyAccount::Equity; + if(type == "ROOT") return (int)Account::Unknown; + else if (type == "BANK") return (int)Account::Checkings; + else if (type == "CASH") return (int)Account::Cash; + else if (type == "CREDIT") return (int)Account::CreditCard; + else if (type == "INVEST") return (int)Account::Investment; + else if (type == "RECEIVABLE") return (int)Account::Asset; + else if (type == "ASSET") return (int)Account::Asset; + else if (type == "PAYABLE") return (int)Account::Liability; + else if (type == "LIABILITY") return (int)Account::Liability; + else if (type == "CURRENCY") return (int)Account::Currency; + else if (type == "INCOME") return (int)Account::Income; + else if (type == "EXPENSE") return (int)Account::Expense; + else if (type == "STOCK") return (int)Account::Stock; + else if (type == "MUTUAL") return (int)Account::Stock; + else if (type == "EQUITY") return (int)Account::Equity; else return 99; // unknown }