File indexing completed on 2024-05-19 05:07:14
0001 /* 0002 SPDX-FileCopyrightText: 2000-2002 Michael Edwardes <mte@users.sourceforge.net> 0003 SPDX-FileCopyrightText: 2001 Felix Rodriguez <frodriguez@users.sourceforge.net> 0004 SPDX-FileCopyrightText: 2002-2003 Kevin Tambascio <ktambascio@users.sourceforge.net> 0005 SPDX-FileCopyrightText: 2006-2019 Thomas Baumgart <tbaumgart@kde.org> 0006 SPDX-FileCopyrightText: 2006 Ace Jones <acejones@users.sourceforge.net> 0007 SPDX-FileCopyrightText: 2017-2018 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com> 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 0011 #include "mymoneyaccount.h" 0012 #include "mymoneyaccount_p.h" 0013 0014 // ---------------------------------------------------------------------------- 0015 // QT Includes 0016 0017 #include <QDebug> 0018 #include <QIcon> 0019 #include <QPainter> 0020 #include <QPixmap> 0021 #include <QPixmapCache> 0022 #include <QSet> 0023 0024 // ---------------------------------------------------------------------------- 0025 // KDE Includes 0026 0027 #include <KLocalizedString> 0028 0029 // ---------------------------------------------------------------------------- 0030 // Project Includes 0031 0032 #include "icons.h" 0033 #include "mymoneyexception.h" 0034 #include "mymoneyfile.h" 0035 #include "mymoneyinstitution.h" 0036 #include "mymoneypayee.h" 0037 #include "mymoneysecurity.h" 0038 #include "mymoneysplit.h" 0039 #include "mymoneyutils.h" 0040 #include "payeeidentifier/ibanbic/ibanbic.h" 0041 #include "payeeidentifier/nationalaccount/nationalaccount.h" 0042 #include "payeeidentifier/payeeidentifiertyped.h" 0043 0044 using namespace Icons; 0045 0046 MyMoneyAccount::MyMoneyAccount() : 0047 MyMoneyObject(*new MyMoneyAccountPrivate), 0048 MyMoneyKeyValueContainer() 0049 { 0050 } 0051 0052 MyMoneyAccount::MyMoneyAccount(const QString &id): 0053 MyMoneyObject(*new MyMoneyAccountPrivate, id), 0054 MyMoneyKeyValueContainer() 0055 { 0056 } 0057 0058 MyMoneyAccount::MyMoneyAccount(MyMoneyAccountPrivate* dd, const MyMoneyAccount& other) 0059 : MyMoneyObject(*dd, other.id()) 0060 , MyMoneyKeyValueContainer(other) 0061 { 0062 } 0063 0064 MyMoneyAccount::MyMoneyAccount(const MyMoneyAccount& other) : 0065 MyMoneyObject(*new MyMoneyAccountPrivate(*other.d_func()), other.id()), 0066 MyMoneyKeyValueContainer(other) 0067 { 0068 } 0069 0070 MyMoneyAccount::MyMoneyAccount(const QString& id, const MyMoneyAccount& other) : 0071 MyMoneyObject(*new MyMoneyAccountPrivate(*other.d_func()), id), 0072 MyMoneyKeyValueContainer(other) 0073 { 0074 } 0075 0076 MyMoneyAccount::~MyMoneyAccount() 0077 { 0078 } 0079 0080 void MyMoneyAccount::touch() 0081 { 0082 setLastModified(QDate::currentDate()); 0083 } 0084 0085 eMyMoney::Account::Type MyMoneyAccount::accountType() const 0086 { 0087 Q_D(const MyMoneyAccount); 0088 return d->m_accountType; 0089 } 0090 0091 void MyMoneyAccount::setAccountType(const Account::Type type) 0092 { 0093 Q_D(MyMoneyAccount); 0094 d->m_accountType = type; 0095 } 0096 0097 QString MyMoneyAccount::institutionId() const 0098 { 0099 Q_D(const MyMoneyAccount); 0100 return d->m_institution; 0101 } 0102 0103 void MyMoneyAccount::setInstitutionId(const QString& id) 0104 { 0105 Q_D(MyMoneyAccount); 0106 d->m_institution = id; 0107 d->clearReferences(); 0108 } 0109 0110 QString MyMoneyAccount::name() const 0111 { 0112 Q_D(const MyMoneyAccount); 0113 return d->m_name; 0114 } 0115 0116 void MyMoneyAccount::setName(const QString& name) 0117 { 0118 Q_D(MyMoneyAccount); 0119 d->m_name = name; 0120 } 0121 0122 QString MyMoneyAccount::number() const 0123 { 0124 Q_D(const MyMoneyAccount); 0125 return d->m_number; 0126 } 0127 0128 void MyMoneyAccount::setNumber(const QString& number) 0129 { 0130 Q_D(MyMoneyAccount); 0131 d->m_number = number; 0132 } 0133 0134 QString MyMoneyAccount::description() const 0135 { 0136 Q_D(const MyMoneyAccount); 0137 return d->m_description; 0138 } 0139 0140 void MyMoneyAccount::setDescription(const QString& desc) 0141 { 0142 Q_D(MyMoneyAccount); 0143 d->m_description = desc; 0144 } 0145 0146 QDate MyMoneyAccount::openingDate() const 0147 { 0148 Q_D(const MyMoneyAccount); 0149 return d->m_openingDate; 0150 } 0151 0152 void MyMoneyAccount::setOpeningDate(const QDate& date) 0153 { 0154 Q_D(MyMoneyAccount); 0155 d->m_openingDate = date; 0156 } 0157 0158 QDate MyMoneyAccount::lastReconciliationDate() const 0159 { 0160 Q_D(const MyMoneyAccount); 0161 return d->m_lastReconciliationDate; 0162 } 0163 0164 void MyMoneyAccount::setLastReconciliationDate(const QDate& date) 0165 { 0166 Q_D(MyMoneyAccount); 0167 d->m_lastReconciliationDate = date; 0168 } 0169 0170 QDate MyMoneyAccount::lastModified() const 0171 { 0172 Q_D(const MyMoneyAccount); 0173 return d->m_lastModified; 0174 } 0175 0176 void MyMoneyAccount::setLastModified(const QDate& date) 0177 { 0178 Q_D(MyMoneyAccount); 0179 d->m_lastModified = date; 0180 } 0181 0182 QString MyMoneyAccount::parentAccountId() const 0183 { 0184 Q_D(const MyMoneyAccount); 0185 return d->m_parentAccount; 0186 } 0187 0188 void MyMoneyAccount::setParentAccountId(const QString& parent) 0189 { 0190 Q_D(MyMoneyAccount); 0191 d->m_parentAccount = parent; 0192 d->clearReferences(); 0193 } 0194 0195 QStringList MyMoneyAccount::accountList() const 0196 { 0197 Q_D(const MyMoneyAccount); 0198 return d->m_accountList; 0199 } 0200 0201 int MyMoneyAccount::accountCount() const 0202 { 0203 Q_D(const MyMoneyAccount); 0204 return d->m_accountList.count(); 0205 } 0206 0207 void MyMoneyAccount::addAccountId(const QString& account) 0208 { 0209 Q_D(MyMoneyAccount); 0210 if (!d->m_accountList.contains(account)) 0211 d->m_accountList += account; 0212 } 0213 0214 void MyMoneyAccount::removeAccountIds() 0215 { 0216 Q_D(MyMoneyAccount); 0217 d->m_accountList.clear(); 0218 } 0219 0220 void MyMoneyAccount::removeAccountId(const QString& account) 0221 { 0222 Q_D(MyMoneyAccount); 0223 const auto pos = d->m_accountList.indexOf(account); 0224 if (pos != -1) 0225 d->m_accountList.removeAt(pos); 0226 } 0227 0228 bool MyMoneyAccount::operator == (const MyMoneyAccount& right) const 0229 { 0230 Q_D(const MyMoneyAccount); 0231 auto d2 = static_cast<const MyMoneyAccountPrivate *>(right.d_func()); 0232 // clang-format off 0233 return (MyMoneyKeyValueContainer::operator==(right) 0234 && MyMoneyObject::operator==(right) 0235 && (d->m_accountList == d2->m_accountList) 0236 && (d->m_accountType == d2->m_accountType) 0237 && (d->m_lastModified == d2->m_lastModified) 0238 && (d->m_lastReconciliationDate == d2->m_lastReconciliationDate) 0239 && ((d->m_name.length() == 0 && d2->m_name.length() == 0) || (d->m_name == d2->m_name)) 0240 && ((d->m_number.length() == 0 && d2->m_number.length() == 0) || (d->m_number == d2->m_number)) 0241 && ((d->m_description.length() == 0 && d2->m_description.length() == 0) || (d->m_description == d2->m_description)) 0242 && (d->m_openingDate == d2->m_openingDate) 0243 && (d->m_parentAccount == d2->m_parentAccount) 0244 && (d->m_currencyId == d2->m_currencyId) 0245 && (d->m_institution == d2->m_institution)); 0246 // clang-format on 0247 } 0248 0249 Account::Type MyMoneyAccount::accountGroup(Account::Type type) 0250 { 0251 switch (type) { 0252 case Account::Type::Checkings: 0253 case Account::Type::Savings: 0254 case Account::Type::Cash: 0255 case Account::Type::Currency: 0256 case Account::Type::Investment: 0257 case Account::Type::MoneyMarket: 0258 case Account::Type::CertificateDep: 0259 case Account::Type::AssetLoan: 0260 case Account::Type::Stock: 0261 return Account::Type::Asset; 0262 0263 case Account::Type::CreditCard: 0264 case Account::Type::Loan: 0265 return Account::Type::Liability; 0266 0267 default: 0268 return type; 0269 } 0270 } 0271 0272 Account::Type MyMoneyAccount::accountGroup() const 0273 { 0274 Q_D(const MyMoneyAccount); 0275 return accountGroup(d->m_accountType); 0276 } 0277 0278 QString MyMoneyAccount::currencyId() const 0279 { 0280 Q_D(const MyMoneyAccount); 0281 return d->m_currencyId; 0282 } 0283 0284 QString MyMoneyAccount::tradingCurrencyId() const 0285 { 0286 const auto file = MyMoneyFile::instance(); 0287 0288 // First, get the trading currency (formerly deep currency) 0289 auto deepcurrency = file->security(currencyId()); 0290 if (!deepcurrency.isCurrency()) 0291 deepcurrency = file->security(deepcurrency.tradingCurrency()); 0292 0293 // Return the trading currency's ID 0294 return deepcurrency.id(); 0295 } 0296 0297 bool MyMoneyAccount::isForeignCurrency() const 0298 { 0299 return (tradingCurrencyId() != MyMoneyFile::instance()->baseCurrency().id()); 0300 } 0301 0302 void MyMoneyAccount::setCurrencyId(const QString& id) 0303 { 0304 Q_D(MyMoneyAccount); 0305 d->m_currencyId = id; 0306 d->clearReferences(); 0307 } 0308 0309 bool MyMoneyAccount::isAssetLiability() const 0310 { 0311 return accountGroup() == Account::Type::Asset || accountGroup() == Account::Type::Liability; 0312 } 0313 0314 bool MyMoneyAccount::isIncomeExpense() const 0315 { 0316 return isIncomeExpense(accountType()); 0317 } 0318 0319 bool MyMoneyAccount::isIncomeExpense(eMyMoney::Account::Type type) 0320 { 0321 return (accountGroup(type) == Account::Type::Income) || (accountGroup(type) == Account::Type::Expense); 0322 } 0323 0324 bool MyMoneyAccount::isLoan() const 0325 { 0326 return accountType() == Account::Type::Loan || accountType() == Account::Type::AssetLoan; 0327 } 0328 0329 bool MyMoneyAccount::isInvest() const 0330 { 0331 return accountType() == Account::Type::Stock; 0332 } 0333 0334 bool MyMoneyAccount::isLiquidAsset() const 0335 { 0336 return accountType() == Account::Type::Checkings // 0337 || accountType() == Account::Type::Savings // 0338 || accountType() == Account::Type::Cash; 0339 } 0340 0341 bool MyMoneyAccount::isLiquidLiability() const 0342 { 0343 return accountType() == Account::Type::CreditCard; 0344 } 0345 0346 bool MyMoneyAccount::isCostCenterRequired() const 0347 { 0348 return value(QLatin1String("CostCenter"), false); 0349 } 0350 0351 void MyMoneyAccount::setCostCenterRequired(bool required) 0352 { 0353 setValue(QLatin1String("CostCenter"), required, false); 0354 } 0355 0356 bool MyMoneyAccount::isInTaxReports() const 0357 { 0358 return value(QLatin1String("Tax"), false); 0359 } 0360 0361 void MyMoneyAccount::setIsInTaxReports(bool include) 0362 { 0363 setValue(QLatin1String("Tax"), include, false); 0364 } 0365 0366 void MyMoneyAccount::setOnlineBankingSettings(const MyMoneyKeyValueContainer& values) 0367 { 0368 Q_D(MyMoneyAccount); 0369 d->m_onlineBankingSettings = values; 0370 } 0371 0372 MyMoneyKeyValueContainer MyMoneyAccount::onlineBankingSettings() const 0373 { 0374 Q_D(const MyMoneyAccount); 0375 return d->m_onlineBankingSettings; 0376 } 0377 0378 void MyMoneyAccount::setClosed(bool closed) 0379 { 0380 setValue(QLatin1String("mm-closed"), closed, false); 0381 } 0382 0383 bool MyMoneyAccount::isClosed() const 0384 { 0385 return value(QLatin1String("mm-closed"), false); 0386 } 0387 0388 int MyMoneyAccount::fraction(const MyMoneySecurity& sec) const 0389 { 0390 Q_D(const MyMoneyAccount); 0391 int fraction; 0392 if (d->m_accountType == Account::Type::Cash) 0393 fraction = sec.smallestCashFraction(); 0394 else 0395 fraction = sec.smallestAccountFraction(); 0396 return fraction; 0397 } 0398 0399 int MyMoneyAccount::fraction(const MyMoneySecurity& sec) 0400 { 0401 Q_D(MyMoneyAccount); 0402 if (d->m_accountType == Account::Type::Cash) 0403 d->m_fraction = sec.smallestCashFraction(); 0404 else 0405 d->m_fraction = sec.smallestAccountFraction(); 0406 return d->m_fraction; 0407 } 0408 0409 int MyMoneyAccount::fraction() const 0410 { 0411 Q_D(const MyMoneyAccount); 0412 return d->m_fraction; 0413 } 0414 0415 bool MyMoneyAccount::isCategory() const 0416 { 0417 Q_D(const MyMoneyAccount); 0418 return d->m_accountType == Account::Type::Income || d->m_accountType == Account::Type::Expense; 0419 } 0420 0421 QString MyMoneyAccount::brokerageName() const 0422 { 0423 Q_D(const MyMoneyAccount); 0424 if (d->m_accountType == Account::Type::Investment) 0425 return QString("%1 (%2)").arg(d->m_name, i18nc("Brokerage (suffix for account names)", "Brokerage")); 0426 return d->m_name; 0427 } 0428 0429 MyMoneyMoney MyMoneyAccount::balance() const 0430 { 0431 Q_D(const MyMoneyAccount); 0432 return d->m_balance; 0433 } 0434 0435 MyMoneyMoney MyMoneyAccount::postedValue() const 0436 { 0437 Q_D(const MyMoneyAccount); 0438 return d->m_postedValue; 0439 } 0440 0441 MyMoneyMoney MyMoneyAccount::totalPostedValue() const 0442 { 0443 Q_D(const MyMoneyAccount); 0444 return d->m_totalPostedValue; 0445 } 0446 0447 void MyMoneyAccount::adjustBalance(const MyMoneySplit& s, bool reverse) 0448 { 0449 Q_D(MyMoneyAccount); 0450 const MyMoneyMoney oldBalance = d->m_balance; 0451 0452 if (s.action() == MyMoneySplit::actionName(eMyMoney::Split::Action::SplitShares)) { 0453 if (reverse) 0454 d->m_balance = d->m_balance / s.shares(); 0455 else 0456 d->m_balance = d->m_balance * s.shares(); 0457 } else { 0458 if (reverse) 0459 d->m_balance -= s.shares(); 0460 else 0461 d->m_balance += s.shares(); 0462 } 0463 } 0464 0465 void MyMoneyAccount::setBalance(const MyMoneyMoney& val) 0466 { 0467 Q_D(MyMoneyAccount); 0468 d->m_balance = val; 0469 } 0470 0471 void MyMoneyAccount::setPostedValue(const MyMoneyMoney& val) 0472 { 0473 Q_D(MyMoneyAccount); 0474 d->m_postedValue = val; 0475 } 0476 0477 void MyMoneyAccount::setTotalPostedValue(const MyMoneyMoney& val) 0478 { 0479 Q_D(MyMoneyAccount); 0480 d->m_totalPostedValue = val; 0481 } 0482 0483 QIcon MyMoneyAccount::accountIcon() const 0484 { 0485 switch (accountType()) { 0486 case Account::Type::Checkings: 0487 return Icons::get(isClosed() ? Icons::Icon::CheckingClosed : Icons::Icon::Checking); 0488 case Account::Type::Savings: 0489 return Icons::get(isClosed() ? Icons::Icon::SavingsClosed : Icons::Icon::Savings); 0490 case Account::Type::Cash: 0491 return Icons::get(isClosed() ? Icons::Icon::CashClosed : Icons::Icon::Cash); 0492 case Account::Type::CreditCard: 0493 return Icons::get(isClosed() ? Icons::Icon::CreditCardClosed : Icons::Icon::CreditCard); 0494 case Account::Type::Loan: 0495 return Icons::get(isClosed() ? Icons::Icon::LoanClosed : Icons::Icon::Loan); 0496 case Account::Type::Investment: 0497 case Account::Type::MoneyMarket: 0498 return Icons::get(isClosed()? Icons::Icon::InvestmentClosed : Icons::Icon::Investment); 0499 case Account::Type::Asset: 0500 return Icons::get(isClosed() ? Icons::Icon::AssetClosed : Icons::Icon::Asset); 0501 case Account::Type::Liability: 0502 return Icons::get(isClosed() ? Icons::Icon::LiabilityClosed : Icons::Icon::Liability); 0503 case Account::Type::Income: 0504 return Icons::get(Icons::Icon::Income); 0505 case Account::Type::Expense: 0506 return Icons::get(Icons::Icon::Expense); 0507 case Account::Type::AssetLoan: 0508 return Icons::get(isClosed() ? Icons::Icon::AssetLoanClosed : Icons::Icon::AssetLoan); 0509 case Account::Type::Stock: 0510 return Icons::get(isClosed() ? Icons::Icon::SecurityClosed : Icons::Icon::Security); 0511 case Account::Type::Equity: 0512 return Icons::get(Icons::Icon::Equity); 0513 default: 0514 return Icons::get(isClosed() ? Icons::Icon::BankAccountClosed : Icons::Icon::BankAccount); 0515 } 0516 } 0517 0518 QString MyMoneyAccount::accountTypeToString(const Account::Type accountType) 0519 { 0520 switch (accountType) { 0521 case Account::Type::Checkings: 0522 return i18nc("Account type", "Checking"); 0523 case Account::Type::Savings: 0524 return i18nc("Account type", "Savings"); 0525 case Account::Type::CreditCard: 0526 return i18nc("Account type", "Credit Card"); 0527 case Account::Type::Cash: 0528 return i18nc("Account type", "Cash"); 0529 case Account::Type::Loan: 0530 return i18nc("Account type", "Loan"); 0531 case Account::Type::CertificateDep: 0532 return i18nc("Account type", "Certificate of Deposit"); 0533 case Account::Type::Investment: 0534 return i18nc("Account type", "Investment"); 0535 case Account::Type::MoneyMarket: 0536 return i18nc("Account type", "Money Market"); 0537 case Account::Type::Asset: 0538 return i18nc("Account type", "Asset"); 0539 case Account::Type::Liability: 0540 return i18nc("Account type", "Liability"); 0541 case Account::Type::Currency: 0542 return i18nc("Account type", "Currency"); 0543 case Account::Type::Income: 0544 return i18nc("Account type", "Income"); 0545 case Account::Type::Expense: 0546 return i18nc("Account type", "Expense"); 0547 case Account::Type::AssetLoan: 0548 return i18nc("Account type", "Investment Loan"); 0549 case Account::Type::Stock: 0550 return i18nc("Account type", "Stock"); 0551 case Account::Type::Equity: 0552 return i18nc("Account type", "Equity"); 0553 default: 0554 return i18nc("Account type", "Unknown"); 0555 } 0556 } 0557 0558 bool MyMoneyAccount::addReconciliation(const QDate& date, const MyMoneyMoney& amount) 0559 { 0560 Q_D(MyMoneyAccount); 0561 // make sure, that history has been loaded 0562 reconciliationHistory(); 0563 0564 d->m_reconciliationHistory[date] = amount; 0565 0566 /// @todo remove old reconciliation history storage method 0567 /// once we don't need to write the KVP entry anymore 0568 /// this whole block can be removed 0569 QString history, sep; 0570 QMap<QDate, MyMoneyMoney>::const_iterator it; 0571 for (it = d->m_reconciliationHistory.constBegin(); 0572 it != d->m_reconciliationHistory.constEnd(); 0573 ++it) { 0574 0575 history += QString("%1%2:%3").arg(sep, 0576 it.key().toString(Qt::ISODate), 0577 (*it).toString()); 0578 sep = QLatin1Char(';'); 0579 } 0580 setValue(QLatin1String("reconciliationHistory"), history); 0581 0582 return true; 0583 } 0584 0585 /// @todo remove old reconciliation history storage method 0586 /// once we don't need to read the history from the KVP entry anymore 0587 /// this whole method can be removed 0588 QMap<QDate, MyMoneyMoney> MyMoneyAccount::reconciliationHistory() 0589 { 0590 Q_D(MyMoneyAccount); 0591 0592 // check if the internal history member is already loaded 0593 if (d->m_reconciliationHistory.count() == 0 0594 && !value("reconciliationHistory").isEmpty()) { 0595 const QStringList entries = value("reconciliationHistory").split(';'); 0596 for (const auto& entry : qAsConst(entries)) { 0597 const auto parts = entry.split(':'); 0598 if (parts.count() == 2) { 0599 const auto date = QDate::fromString(parts[0], Qt::ISODate); 0600 MyMoneyMoney amount(parts[1]); 0601 if (parts.count() == 2 && date.isValid()) { 0602 d->m_reconciliationHistory[date] = amount; 0603 } 0604 } else { 0605 qDebug() << "Invalid reconciliationHistory" << entry; 0606 } 0607 } 0608 } 0609 return d->m_reconciliationHistory; 0610 } 0611 0612 QMap<QDate, MyMoneyMoney> MyMoneyAccount::reconciliationHistory() const 0613 { 0614 Q_D(const MyMoneyAccount); 0615 return d->m_reconciliationHistory; 0616 } 0617 0618 /** 0619 * @todo Improve setting of country for nationalAccount 0620 */ 0621 QList< payeeIdentifier > MyMoneyAccount::payeeIdentifiers() const 0622 { 0623 QList< payeeIdentifier > list; 0624 0625 MyMoneyFile* file = MyMoneyFile::instance(); 0626 0627 const auto strIBAN = QStringLiteral("iban"); 0628 const auto strBIC = QStringLiteral("bic"); 0629 // Iban & Bic 0630 if (!value(strIBAN).isEmpty()) { 0631 payeeIdentifierTyped<payeeIdentifiers::ibanBic> iban(new payeeIdentifiers::ibanBic); 0632 iban->setIban(value(strIBAN)); 0633 iban->setBic(file->institution(institutionId()).value(strBIC)); 0634 iban->setOwnerName(file->user().name()); 0635 list.append(iban); 0636 } 0637 0638 // National Account number 0639 if (!number().isEmpty()) { 0640 payeeIdentifierTyped<payeeIdentifiers::nationalAccount> national(new payeeIdentifiers::nationalAccount); 0641 national->setAccountNumber(number()); 0642 national->setBankCode(file->institution(institutionId()).bankcode()); 0643 if (file->user().state().length() == 2) 0644 national->setCountry(file->user().state()); 0645 national->setOwnerName(file->user().name()); 0646 list.append(national); 0647 } 0648 0649 return list; 0650 } 0651 0652 bool MyMoneyAccount::hasOnlineMapping() const 0653 { 0654 Q_D(const MyMoneyAccount); 0655 return !d->m_onlineBankingSettings.value(QLatin1String("provider")).isEmpty(); 0656 } 0657 0658 QString MyMoneyAccount::stdAccName(eMyMoney::Account::Standard stdAccID) 0659 { 0660 static const QHash<eMyMoney::Account::Standard, QString> stdAccNames { 0661 {eMyMoney::Account::Standard::Liability, QStringLiteral("AStd::Liability")}, 0662 {eMyMoney::Account::Standard::Asset, QStringLiteral("AStd::Asset")}, 0663 {eMyMoney::Account::Standard::Expense, QStringLiteral("AStd::Expense")}, 0664 {eMyMoney::Account::Standard::Income, QStringLiteral("AStd::Income")}, 0665 {eMyMoney::Account::Standard::Equity, QStringLiteral("AStd::Equity")}, 0666 {eMyMoney::Account::Standard::Favorite, QStringLiteral("AStd::Favorite")}, 0667 }; 0668 return stdAccNames.value(stdAccID); 0669 } 0670 0671 QString MyMoneyAccount::accountSeparator() 0672 { 0673 return QStringLiteral(":"); 0674 } 0675 0676 void MyMoneyAccount::setBudgetAccountType(eMyMoney::Account::Type type) 0677 { 0678 if ((type != eMyMoney::Account::Type::Income) && (type != eMyMoney::Account::Type::Expense)) { 0679 type = eMyMoney::Account::Type::Unknown; 0680 } 0681 setValue(QLatin1String("budgetAccountType"), static_cast<int>(type), static_cast<int>(eMyMoney::Account::Type::Unknown)); 0682 } 0683 0684 eMyMoney::Account::Type MyMoneyAccount::budgetAccountType() const 0685 { 0686 return static_cast<eMyMoney::Account::Type>(value(QLatin1String("budgetAccountType"), static_cast<int>(accountType()))); 0687 }