Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/dialogs/knewaccountdlg.cpp
Context not available. | |||||
132 | MyMoneyFile *file = MyMoneyFile::instance(); | 132 | MyMoneyFile *file = MyMoneyFile::instance(); | ||
---|---|---|---|---|---|
133 | 133 | | |||
134 | // initialize the m_parentAccount member | 134 | // initialize the m_parentAccount member | ||
135 | QVector<MyMoneyAccount::accountTypeE> filterAccountGroup {m_account.accountGroup()}; | 135 | QVector<eMyMoney::Account> filterAccountGroup {m_account.accountGroup()}; | ||
136 | switch (m_account.accountGroup()) { | 136 | switch (m_account.accountGroup()) { | ||
137 | case MyMoneyAccount::Asset: | 137 | case eMyMoney::Account::Asset: | ||
138 | m_parentAccount = file->asset(); | 138 | m_parentAccount = file->asset(); | ||
139 | break; | 139 | break; | ||
140 | case MyMoneyAccount::Liability: | 140 | case eMyMoney::Account::Liability: | ||
141 | m_parentAccount = file->liability(); | 141 | m_parentAccount = file->liability(); | ||
142 | break; | 142 | break; | ||
143 | case MyMoneyAccount::Income: | 143 | case eMyMoney::Account::Income: | ||
144 | m_parentAccount = file->income(); | 144 | m_parentAccount = file->income(); | ||
145 | break; | 145 | break; | ||
146 | case MyMoneyAccount::Expense: | 146 | case eMyMoney::Account::Expense: | ||
147 | m_parentAccount = file->expense(); | 147 | m_parentAccount = file->expense(); | ||
148 | break; | 148 | break; | ||
149 | case MyMoneyAccount::Equity: | 149 | case eMyMoney::Account::Equity: | ||
150 | m_parentAccount = file->equity(); | 150 | m_parentAccount = file->equity(); | ||
151 | break; | 151 | break; | ||
152 | default: | 152 | default: | ||
153 | qDebug("Seems we have an account that hasn't been mapped to the top five"); | 153 | qDebug("Seems we have an account that hasn't been mapped to the top five"); | ||
154 | if (m_categoryEditor) { | 154 | if (m_categoryEditor) { | ||
155 | m_parentAccount = file->income(); | 155 | m_parentAccount = file->income(); | ||
156 | filterAccountGroup[0] = MyMoneyAccount::Income; | 156 | filterAccountGroup[0] = eMyMoney::Account::Income; | ||
157 | } else { | 157 | } else { | ||
158 | m_parentAccount = file->asset(); | 158 | m_parentAccount = file->asset(); | ||
159 | filterAccountGroup[0] = MyMoneyAccount::Asset; | 159 | filterAccountGroup[0] = eMyMoney::Account::Asset; | ||
160 | } | 160 | } | ||
161 | } | 161 | } | ||
162 | 162 | | |||
Context not available. | |||||
190 | m_priceMode->insertItem(i18n("Total for all shares"), 2); | 190 | m_priceMode->insertItem(i18n("Total for all shares"), 2); | ||
191 | 191 | | |||
192 | int priceMode = 0; | 192 | int priceMode = 0; | ||
193 | if (m_account.accountType() == MyMoneyAccount::Investment) { | 193 | if (m_account.accountType() == eMyMoney::Account::Investment) { | ||
194 | m_priceMode->setEnabled(true); | 194 | m_priceMode->setEnabled(true); | ||
195 | if (!m_account.value("priceMode").isEmpty()) | 195 | if (!m_account.value("priceMode").isEmpty()) | ||
196 | priceMode = m_account.value("priceMode").toInt(); | 196 | priceMode = m_account.value("priceMode").toInt(); | ||
Context not available. | |||||
221 | m_institutionBox->hide(); | 221 | m_institutionBox->hide(); | ||
222 | m_qcheckboxNoVat->hide(); | 222 | m_qcheckboxNoVat->hide(); | ||
223 | 223 | | |||
224 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Income)); | 224 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Income)); | ||
225 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Expense)); | 225 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Expense)); | ||
226 | 226 | | |||
227 | // Hardcoded but acceptable - if above we set the default to income do the same here | 227 | // Hardcoded but acceptable - if above we set the default to income do the same here | ||
228 | switch (account.accountType()) { | 228 | switch (account.accountType()) { | ||
229 | case MyMoneyAccount::Expense: | 229 | case eMyMoney::Account::Expense: | ||
230 | typeCombo->setCurrentItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Expense), false); | 230 | typeCombo->setCurrentItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Expense), false); | ||
231 | break; | 231 | break; | ||
232 | 232 | | |||
233 | case MyMoneyAccount::Income: | 233 | case eMyMoney::Account::Income: | ||
234 | default: | 234 | default: | ||
235 | typeCombo->setCurrentItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Income), false); | 235 | typeCombo->setCurrentItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Income), false); | ||
236 | break; | 236 | break; | ||
237 | } | 237 | } | ||
238 | m_currency->setEnabled(true); | 238 | m_currency->setEnabled(true); | ||
Context not available. | |||||
260 | m_costCenterRequiredCheckBox->hide(); | 260 | m_costCenterRequiredCheckBox->hide(); | ||
261 | 261 | | |||
262 | switch (m_account.accountType()) { | 262 | switch (m_account.accountType()) { | ||
263 | case MyMoneyAccount::Savings: | 263 | case eMyMoney::Account::Savings: | ||
264 | case MyMoneyAccount::Cash: | 264 | case eMyMoney::Account::Cash: | ||
265 | haveMinBalance = true; | 265 | haveMinBalance = true; | ||
266 | break; | 266 | break; | ||
267 | 267 | | |||
268 | case MyMoneyAccount::Checkings: | 268 | case eMyMoney::Account::Checkings: | ||
269 | haveMinBalance = true; | 269 | haveMinBalance = true; | ||
270 | haveMaxCredit = true; | 270 | haveMaxCredit = true; | ||
271 | break; | 271 | break; | ||
272 | 272 | | |||
273 | case MyMoneyAccount::CreditCard: | 273 | case eMyMoney::Account::CreditCard: | ||
274 | haveMaxCredit = true; | 274 | haveMaxCredit = true; | ||
275 | break; | 275 | break; | ||
276 | 276 | | |||
Context not available. | |||||
302 | 302 | | |||
303 | if (m_isEditing) { | 303 | if (m_isEditing) { | ||
304 | if (account.isLiquidAsset()) { | 304 | if (account.isLiquidAsset()) { | ||
305 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Checkings)); | 305 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Checkings)); | ||
306 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Savings)); | 306 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Savings)); | ||
307 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Cash)); | 307 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Cash)); | ||
308 | } else { | 308 | } else { | ||
309 | typeCombo->addItem(typeString); | 309 | typeCombo->addItem(typeString); | ||
310 | // Once created, accounts of other account types are not | 310 | // Once created, accounts of other account types are not | ||
Context not available. | |||||
314 | // Once created, a currency cannot be changed if it is referenced. | 314 | // Once created, a currency cannot be changed if it is referenced. | ||
315 | m_currency->setDisabled(MyMoneyFile::instance()->isReferenced(m_account)); | 315 | m_currency->setDisabled(MyMoneyFile::instance()->isReferenced(m_account)); | ||
316 | } else { | 316 | } else { | ||
317 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Checkings)); | 317 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Checkings)); | ||
318 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Savings)); | 318 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Savings)); | ||
319 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Cash)); | 319 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Cash)); | ||
320 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::CreditCard)); | 320 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::CreditCard)); | ||
321 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Loan)); | 321 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Loan)); | ||
322 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Investment)); | 322 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Investment)); | ||
323 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Asset)); | 323 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Asset)); | ||
324 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Liability)); | 324 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Liability)); | ||
325 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Stock)); | 325 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Stock)); | ||
326 | /* | 326 | /* | ||
327 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::CertificateDep)); | 327 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::CertificateDep)); | ||
328 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::MoneyMarket)); | 328 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::MoneyMarket)); | ||
329 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Currency)); | 329 | typeCombo->addItem(KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Currency)); | ||
330 | */ | 330 | */ | ||
331 | // Do not create account types that are not supported | 331 | // Do not create account types that are not supported | ||
332 | // by the current engine. | 332 | // by the current engine. | ||
333 | if (account.accountType() == MyMoneyAccount::UnknownAccountType || | 333 | if (account.accountType() == eMyMoney::Account::Unknown || | ||
334 | account.accountType() == MyMoneyAccount::CertificateDep || | 334 | account.accountType() == eMyMoney::Account::CertificateDep || | ||
335 | account.accountType() == MyMoneyAccount::MoneyMarket || | 335 | account.accountType() == eMyMoney::Account::MoneyMarket || | ||
336 | account.accountType() == MyMoneyAccount::Currency) | 336 | account.accountType() == eMyMoney::Account::Currency) | ||
337 | typeString = KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Checkings); | 337 | typeString = KMyMoneyUtils::accountTypeToString(eMyMoney::Account::Checkings); | ||
338 | } | 338 | } | ||
339 | 339 | | |||
340 | typeCombo->setCurrentItem(typeString, false); | 340 | typeCombo->setCurrentItem(typeString, false); | ||
Context not available. | |||||
545 | // delete a previous version of the minimumbalance information | 545 | // delete a previous version of the minimumbalance information | ||
546 | storeKVP("minimumBalance", QString(), QString()); | 546 | storeKVP("minimumBalance", QString(), QString()); | ||
547 | 547 | | |||
548 | MyMoneyAccount::accountTypeE acctype; | 548 | eMyMoney::Account acctype; | ||
549 | if (!m_categoryEditor) { | 549 | if (!m_categoryEditor) { | ||
550 | acctype = KMyMoneyUtils::stringToAccountType(typeCombo->currentText()); | 550 | acctype = KMyMoneyUtils::stringToAccountType(typeCombo->currentText()); | ||
551 | // If it's a loan, check if the parent is asset or liability. In | 551 | // If it's a loan, check if the parent is asset or liability. In | ||
552 | // case of asset, we change the account type to be AssetLoan | 552 | // case of asset, we change the account type to be AssetLoan | ||
553 | if (acctype == MyMoneyAccount::Loan | 553 | if (acctype == eMyMoney::Account::Loan | ||
554 | && parent.accountGroup() == MyMoneyAccount::Asset) | 554 | && parent.accountGroup() == eMyMoney::Account::Asset) | ||
555 | acctype = MyMoneyAccount::AssetLoan; | 555 | acctype = eMyMoney::Account::AssetLoan; | ||
556 | } else { | 556 | } else { | ||
557 | acctype = parent.accountGroup(); | 557 | acctype = parent.accountGroup(); | ||
558 | QString newName; | 558 | QString newName; | ||
Context not available. | |||||
708 | QStringList loadListLiability; | 708 | QStringList loadListLiability; | ||
709 | for (it = list.begin(); it != list.end(); ++it) { | 709 | for (it = list.begin(); it != list.end(); ++it) { | ||
710 | if (!(*it).value("VatRate").isEmpty()) { | 710 | if (!(*it).value("VatRate").isEmpty()) { | ||
711 | if ((*it).accountType() == MyMoneyAccount::Expense) | 711 | if ((*it).accountType() == eMyMoney::Account::Expense) | ||
712 | loadListExpense += (*it).id(); | 712 | loadListExpense += (*it).id(); | ||
713 | else if ((*it).accountType() == MyMoneyAccount::Income) | 713 | else if ((*it).accountType() == eMyMoney::Account::Income) | ||
714 | loadListIncome += (*it).id(); | 714 | loadListIncome += (*it).id(); | ||
715 | else if ((*it).accountType() == MyMoneyAccount::Asset) | 715 | else if ((*it).accountType() == eMyMoney::Account::Asset) | ||
716 | loadListAsset += (*it).id(); | 716 | loadListAsset += (*it).id(); | ||
717 | else if ((*it).accountType() == MyMoneyAccount::Liability) | 717 | else if ((*it).accountType() == eMyMoney::Account::Liability) | ||
718 | loadListLiability += (*it).id(); | 718 | loadListLiability += (*it).id(); | ||
719 | } | 719 | } | ||
720 | } | 720 | } | ||
Context not available. | |||||
781 | 781 | | |||
782 | void KNewAccountDlg::slotAccountTypeChanged(const QString& typeStr) | 782 | void KNewAccountDlg::slotAccountTypeChanged(const QString& typeStr) | ||
783 | { | 783 | { | ||
784 | MyMoneyAccount::accountTypeE type; | 784 | eMyMoney::Account type; | ||
785 | MyMoneyAccount::accountTypeE oldType; | 785 | eMyMoney::Account oldType; | ||
786 | 786 | | |||
787 | type = KMyMoneyUtils::stringToAccountType(typeStr); | 787 | type = KMyMoneyUtils::stringToAccountType(typeStr); | ||
788 | try { | 788 | try { | ||
Context not available. | |||||
791 | m_account.setAccountType(type); | 791 | m_account.setAccountType(type); | ||
792 | // update the account group displayed in the accounts hierarchy | 792 | // update the account group displayed in the accounts hierarchy | ||
793 | m_filterProxyModel->clear(); | 793 | m_filterProxyModel->clear(); | ||
794 | m_filterProxyModel->addAccountGroup(QVector<MyMoneyAccount::_accountTypeE> {m_account.accountGroup()}); | 794 | m_filterProxyModel->addAccountGroup(QVector<eMyMoney::Account> {m_account.accountGroup()}); | ||
795 | } | 795 | } | ||
796 | } catch (const MyMoneyException &) { | 796 | } catch (const MyMoneyException &) { | ||
797 | qWarning("Unexpected exception in KNewAccountDlg::slotAccountTypeChanged()"); | 797 | qWarning("Unexpected exception in KNewAccountDlg::slotAccountTypeChanged()"); | ||
Context not available. | |||||
837 | void KNewAccountDlg::adjustEditWidgets(kMyMoneyEdit* dst, kMyMoneyEdit* src, char mode, int corr) | 837 | void KNewAccountDlg::adjustEditWidgets(kMyMoneyEdit* dst, kMyMoneyEdit* src, char mode, int corr) | ||
838 | { | 838 | { | ||
839 | MyMoneyMoney factor(corr, 1); | 839 | MyMoneyMoney factor(corr, 1); | ||
840 | if (m_account.accountGroup() == MyMoneyAccount::Asset) | 840 | if (m_account.accountGroup() == eMyMoney::Account::Asset) | ||
841 | factor = -factor; | 841 | factor = -factor; | ||
842 | 842 | | |||
843 | switch (mode) { | 843 | switch (mode) { | ||
Context not available. | |||||
855 | 855 | | |||
856 | void KNewAccountDlg::handleOpeningBalanceCheckbox(const QString ¤cyId) | 856 | void KNewAccountDlg::handleOpeningBalanceCheckbox(const QString ¤cyId) | ||
857 | { | 857 | { | ||
858 | if (m_account.accountType() == MyMoneyAccount::Equity) { | 858 | if (m_account.accountType() == eMyMoney::Account::Equity) { | ||
859 | // check if there is another opening balance account with the same currency | 859 | // check if there is another opening balance account with the same currency | ||
860 | bool isOtherOpenBalancingAccount = false; | 860 | bool isOtherOpenBalancingAccount = false; | ||
861 | QList<MyMoneyAccount> list; | 861 | QList<MyMoneyAccount> list; | ||
Context not available. | |||||
863 | QList<MyMoneyAccount>::Iterator it; | 863 | QList<MyMoneyAccount>::Iterator it; | ||
864 | for (it = list.begin(); it != list.end(); ++it) { | 864 | for (it = list.begin(); it != list.end(); ++it) { | ||
865 | if (it->id() == m_account.id() || currencyId != it->currencyId() | 865 | if (it->id() == m_account.id() || currencyId != it->currencyId() | ||
866 | || it->accountType() != MyMoneyAccount::Equity) | 866 | || it->accountType() != eMyMoney::Account::Equity) | ||
867 | continue; | 867 | continue; | ||
868 | if (it->value("OpeningBalanceAccount") == "Yes") { | 868 | if (it->value("OpeningBalanceAccount") == "Yes") { | ||
869 | isOtherOpenBalancingAccount = true; | 869 | isOtherOpenBalancingAccount = true; | ||
Context not available. |