Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/mymoney/mymoneyfile.cpp
Context not available. | |||||
206 | */ | 206 | */ | ||
---|---|---|---|---|---|
207 | inline void checkStorage() const { | 207 | inline void checkStorage() const { | ||
208 | if (m_storage == 0) | 208 | if (m_storage == 0) | ||
209 | throw MYMONEYEXCEPTION("No storage object attached to MyMoneyFile"); | 209 | throw MYMONEYEXCEPTION_CSTRING("No storage object attached to MyMoneyFile"); | ||
210 | } | 210 | } | ||
211 | 211 | | |||
212 | /** | 212 | /** | ||
Context not available. | |||||
216 | */ | 216 | */ | ||
217 | void checkTransaction(const char* txt) const { | 217 | void checkTransaction(const char* txt) const { | ||
218 | checkStorage(); | 218 | checkStorage(); | ||
219 | if (!m_inTransaction) { | 219 | if (!m_inTransaction) | ||
220 | throw MYMONEYEXCEPTION(QString("No transaction started for %1").arg(txt)); | 220 | throw MYMONEYEXCEPTION(QString::fromLatin1("No transaction started for %1").arg(QString::fromLatin1(txt))); | ||
221 | } | | |||
222 | } | 221 | } | ||
223 | 222 | | |||
224 | void priceChanged(const MyMoneyFile& file, const MyMoneyPrice price) { | 223 | void priceChanged(const MyMoneyFile& file, const MyMoneyPrice price) { | ||
Context not available. | |||||
328 | void MyMoneyFile::attachStorage(MyMoneyStorageMgr* const storage) | 327 | void MyMoneyFile::attachStorage(MyMoneyStorageMgr* const storage) | ||
329 | { | 328 | { | ||
330 | if (d->m_storage != 0) | 329 | if (d->m_storage != 0) | ||
331 | throw MYMONEYEXCEPTION("Storage already attached"); | 330 | throw MYMONEYEXCEPTION_CSTRING("Storage already attached"); | ||
332 | 331 | | |||
333 | if (storage == 0) | 332 | if (storage == 0) | ||
334 | throw MYMONEYEXCEPTION("Storage must not be 0"); | 333 | throw MYMONEYEXCEPTION_CSTRING("Storage must not be 0"); | ||
335 | 334 | | |||
336 | d->m_storage = storage; | 335 | d->m_storage = storage; | ||
337 | 336 | | |||
Context not available. | |||||
369 | { | 368 | { | ||
370 | d->checkStorage(); | 369 | d->checkStorage(); | ||
371 | if (d->m_inTransaction) { | 370 | if (d->m_inTransaction) { | ||
372 | throw MYMONEYEXCEPTION("Already started a transaction!"); | 371 | throw MYMONEYEXCEPTION_CSTRING("Already started a transaction!"); | ||
373 | } | 372 | } | ||
374 | 373 | | |||
375 | d->m_storage->startTransaction(); | 374 | d->m_storage->startTransaction(); | ||
Context not available. | |||||
463 | 462 | | |||
464 | if (institution.name().length() == 0 | 463 | if (institution.name().length() == 0 | ||
465 | || institution.id().length() != 0) | 464 | || institution.id().length() != 0) | ||
466 | throw MYMONEYEXCEPTION("Not a new institution"); | 465 | throw MYMONEYEXCEPTION_CSTRING("Not a new institution"); | ||
467 | 466 | | |||
468 | d->checkTransaction(Q_FUNC_INFO); | 467 | d->checkTransaction(Q_FUNC_INFO); | ||
469 | 468 | | |||
Context not available. | |||||
493 | // account does not exist | 492 | // account does not exist | ||
494 | auto acc = MyMoneyFile::account(split.accountId()); | 493 | auto acc = MyMoneyFile::account(split.accountId()); | ||
495 | if (acc.id().isEmpty()) | 494 | if (acc.id().isEmpty()) | ||
496 | throw MYMONEYEXCEPTION("Cannot store split with no account assigned"); | 495 | throw MYMONEYEXCEPTION_CSTRING("Cannot store split with no account assigned"); | ||
497 | if (isStandardAccount(split.accountId())) | 496 | if (isStandardAccount(split.accountId())) | ||
498 | throw MYMONEYEXCEPTION("Cannot store split referencing standard account"); | 497 | throw MYMONEYEXCEPTION_CSTRING("Cannot store split referencing standard account"); | ||
499 | if (acc.isLoan() && (split.action() == MyMoneySplit::actionName(eMyMoney::Split::Action::Transfer))) | 498 | if (acc.isLoan() && (split.action() == MyMoneySplit::actionName(eMyMoney::Split::Action::Transfer))) | ||
500 | loanAccountAffected = true; | 499 | loanAccountAffected = true; | ||
501 | } | 500 | } | ||
Context not available. | |||||
562 | 561 | | |||
563 | // now check that it is the same | 562 | // now check that it is the same | ||
564 | if (!(account == _account)) | 563 | if (!(account == _account)) | ||
565 | throw MYMONEYEXCEPTION("Unable to modify the standard account groups"); | 564 | throw MYMONEYEXCEPTION_CSTRING("Unable to modify the standard account groups"); | ||
566 | } | 565 | } | ||
567 | 566 | | |||
568 | if (account.accountType() != acc.accountType() && | 567 | if (account.accountType() != acc.accountType() && | ||
569 | !account.isLiquidAsset() && !acc.isLiquidAsset()) | 568 | !account.isLiquidAsset() && !acc.isLiquidAsset()) | ||
570 | throw MYMONEYEXCEPTION("Unable to change account type"); | 569 | throw MYMONEYEXCEPTION_CSTRING("Unable to change account type"); | ||
571 | 570 | | |||
572 | // if the account was moved to another institution, we notify | 571 | // if the account was moved to another institution, we notify | ||
573 | // the old one as well as the new one and the structure change | 572 | // the old one as well as the new one and the structure change | ||
Context not available. | |||||
597 | 596 | | |||
598 | // check that it's not one of the standard account groups | 597 | // check that it's not one of the standard account groups | ||
599 | if (isStandardAccount(acc.id())) | 598 | if (isStandardAccount(acc.id())) | ||
600 | throw MYMONEYEXCEPTION("Unable to reparent the standard account groups"); | 599 | throw MYMONEYEXCEPTION_CSTRING("Unable to reparent the standard account groups"); | ||
601 | 600 | | |||
602 | if (acc.accountGroup() == parent.accountGroup() | 601 | if (acc.accountGroup() == parent.accountGroup() | ||
603 | || (acc.accountType() == Account::Type::Income && parent.accountType() == Account::Type::Expense) | 602 | || (acc.accountType() == Account::Type::Income && parent.accountType() == Account::Type::Expense) | ||
604 | || (acc.accountType() == Account::Type::Expense && parent.accountType() == Account::Type::Income)) { | 603 | || (acc.accountType() == Account::Type::Expense && parent.accountType() == Account::Type::Income)) { | ||
605 | 604 | | |||
606 | if (acc.isInvest() && parent.accountType() != Account::Type::Investment) | 605 | if (acc.isInvest() && parent.accountType() != Account::Type::Investment) | ||
607 | throw MYMONEYEXCEPTION("Unable to reparent Stock to non-investment account"); | 606 | throw MYMONEYEXCEPTION_CSTRING("Unable to reparent Stock to non-investment account"); | ||
608 | 607 | | |||
609 | if (parent.accountType() == Account::Type::Investment && !acc.isInvest()) | 608 | if (parent.accountType() == Account::Type::Investment && !acc.isInvest()) | ||
610 | throw MYMONEYEXCEPTION("Unable to reparent non-stock to investment account"); | 609 | throw MYMONEYEXCEPTION_CSTRING("Unable to reparent non-stock to investment account"); | ||
611 | 610 | | |||
612 | // keep a notification of the current parent | 611 | // keep a notification of the current parent | ||
613 | MyMoneyAccount curParent = account(acc.parentAccountId()); | 612 | MyMoneyAccount curParent = account(acc.parentAccountId()); | ||
Context not available. | |||||
619 | d->m_changeSet += MyMoneyNotification(File::Mode::Modify, acc); | 618 | d->m_changeSet += MyMoneyNotification(File::Mode::Modify, acc); | ||
620 | 619 | | |||
621 | } else | 620 | } else | ||
622 | throw MYMONEYEXCEPTION("Unable to reparent to different account type"); | 621 | throw MYMONEYEXCEPTION_CSTRING("Unable to reparent to different account type"); | ||
623 | } | 622 | } | ||
624 | 623 | | |||
625 | MyMoneyInstitution MyMoneyFile::institution(const QString& id) const | 624 | MyMoneyInstitution MyMoneyFile::institution(const QString& id) const | ||
Context not available. | |||||
652 | { | 651 | { | ||
653 | try { | 652 | try { | ||
654 | return d->m_storage->accountByName(name); | 653 | return d->m_storage->accountByName(name); | ||
655 | } catch(const MyMoneyException&) { | 654 | } catch (const MyMoneyException &) { | ||
656 | } | 655 | } | ||
657 | return MyMoneyAccount(); | 656 | return MyMoneyAccount(); | ||
658 | } | 657 | } | ||
Context not available. | |||||
672 | for (const auto& split : splits) { | 671 | for (const auto& split : splits) { | ||
673 | auto acc = account(split.accountId()); | 672 | auto acc = account(split.accountId()); | ||
674 | if (acc.isClosed()) | 673 | if (acc.isClosed()) | ||
675 | throw MYMONEYEXCEPTION(i18n("Cannot remove transaction that references a closed account.")); | 674 | throw MYMONEYEXCEPTION(QString::fromLatin1("Cannot remove transaction that references a closed account.")); | ||
676 | d->addCacheNotification(split.accountId(), tr.postDate()); | 675 | d->addCacheNotification(split.accountId(), tr.postDate()); | ||
677 | //FIXME-ALEX Do I need to add d->addCacheNotification(split.tagList()); ?? | 676 | //FIXME-ALEX Do I need to add d->addCacheNotification(split.tagList()); ?? | ||
678 | } | 677 | } | ||
Context not available. | |||||
733 | 732 | | |||
734 | // check that it's not one of the standard account groups | 733 | // check that it's not one of the standard account groups | ||
735 | if (isStandardAccount(account.id())) | 734 | if (isStandardAccount(account.id())) | ||
736 | throw MYMONEYEXCEPTION("Unable to remove the standard account groups"); | 735 | throw MYMONEYEXCEPTION_CSTRING("Unable to remove the standard account groups"); | ||
737 | 736 | | |||
738 | if (hasActiveSplits(account.id())) { | 737 | if (hasActiveSplits(account.id())) { | ||
739 | throw MYMONEYEXCEPTION("Unable to remove account with active splits"); | 738 | throw MYMONEYEXCEPTION_CSTRING("Unable to remove account with active splits"); | ||
740 | } | 739 | } | ||
741 | 740 | | |||
742 | // collect all sub-ordinate accounts for notification | 741 | // collect all sub-ordinate accounts for notification | ||
Context not available. | |||||
764 | void MyMoneyFile::removeAccountList(const QStringList& account_list, unsigned int level) | 763 | void MyMoneyFile::removeAccountList(const QStringList& account_list, unsigned int level) | ||
765 | { | 764 | { | ||
766 | if (level > 100) | 765 | if (level > 100) | ||
767 | throw MYMONEYEXCEPTION("Too deep recursion in [MyMoneyFile::removeAccountList]!"); | 766 | throw MYMONEYEXCEPTION_CSTRING("Too deep recursion in [MyMoneyFile::removeAccountList]!"); | ||
768 | 767 | | |||
769 | d->checkTransaction(Q_FUNC_INFO); | 768 | d->checkTransaction(Q_FUNC_INFO); | ||
770 | 769 | | |||
771 | // upon entry, we check that we could proceed with the operation | 770 | // upon entry, we check that we could proceed with the operation | ||
772 | if (!level) { | 771 | if (!level) { | ||
773 | if (!hasOnlyUnusedAccounts(account_list, 0)) { | 772 | if (!hasOnlyUnusedAccounts(account_list, 0)) { | ||
774 | throw MYMONEYEXCEPTION("One or more accounts cannot be removed"); | 773 | throw MYMONEYEXCEPTION_CSTRING("One or more accounts cannot be removed"); | ||
775 | } | 774 | } | ||
776 | } | 775 | } | ||
777 | 776 | | |||
Context not available. | |||||
798 | bool MyMoneyFile::hasOnlyUnusedAccounts(const QStringList& account_list, unsigned int level) | 797 | bool MyMoneyFile::hasOnlyUnusedAccounts(const QStringList& account_list, unsigned int level) | ||
799 | { | 798 | { | ||
800 | if (level > 100) | 799 | if (level > 100) | ||
801 | throw MYMONEYEXCEPTION("Too deep recursion in [MyMoneyFile::hasOnlyUnusedAccounts]!"); | 800 | throw MYMONEYEXCEPTION_CSTRING("Too deep recursion in [MyMoneyFile::hasOnlyUnusedAccounts]!"); | ||
802 | // process all accounts in the list and test if they have transactions assigned | 801 | // process all accounts in the list and test if they have transactions assigned | ||
803 | for (const auto& sAccount : account_list) { | 802 | for (const auto& sAccount : account_list) { | ||
804 | if (transactionCount(sAccount) != 0) | 803 | if (transactionCount(sAccount) != 0) | ||
Context not available. | |||||
907 | ft.commit(); | 906 | ft.commit(); | ||
908 | } catch (const MyMoneyException &e) { | 907 | } catch (const MyMoneyException &e) { | ||
909 | qWarning("Unable to create account: %s", qPrintable(e.what())); | 908 | qWarning("Unable to create account: %s", qPrintable(e.what())); | ||
910 | throw MYMONEYEXCEPTION(e.what()); | 909 | throw; | ||
911 | } | 910 | } | ||
912 | } | 911 | } | ||
913 | 912 | | |||
Context not available. | |||||
923 | // it's own ID is not set and it does not have a pointer to (MyMoneyFile) | 922 | // it's own ID is not set and it does not have a pointer to (MyMoneyFile) | ||
924 | 923 | | |||
925 | if (account.name().length() == 0) | 924 | if (account.name().length() == 0) | ||
926 | throw MYMONEYEXCEPTION("Account has no name"); | 925 | throw MYMONEYEXCEPTION_CSTRING("Account has no name"); | ||
927 | 926 | | |||
928 | if (account.id().length() != 0) | 927 | if (account.id().length() != 0) | ||
929 | throw MYMONEYEXCEPTION("New account must have no id"); | 928 | throw MYMONEYEXCEPTION_CSTRING("New account must have no id"); | ||
930 | 929 | | |||
931 | if (account.accountList().count() != 0) | 930 | if (account.accountList().count() != 0) | ||
932 | throw MYMONEYEXCEPTION("New account must have no sub-accounts"); | 931 | throw MYMONEYEXCEPTION_CSTRING("New account must have no sub-accounts"); | ||
933 | 932 | | |||
934 | if (!account.parentAccountId().isEmpty()) | 933 | if (!account.parentAccountId().isEmpty()) | ||
935 | throw MYMONEYEXCEPTION("New account must have no parent-id"); | 934 | throw MYMONEYEXCEPTION_CSTRING("New account must have no parent-id"); | ||
936 | 935 | | |||
937 | if (account.accountType() == Account::Type::Unknown) | 936 | if (account.accountType() == Account::Type::Unknown) | ||
938 | throw MYMONEYEXCEPTION("Account has invalid type"); | 937 | throw MYMONEYEXCEPTION_CSTRING("Account has invalid type"); | ||
939 | 938 | | |||
940 | // make sure, that the parent account exists | 939 | // make sure, that the parent account exists | ||
941 | // if not, an exception is thrown. If it exists, | 940 | // if not, an exception is thrown. If it exists, | ||
Context not available. | |||||
968 | // that the parent for a stock account must be an investment. Also, | 967 | // that the parent for a stock account must be an investment. Also, | ||
969 | // an investment cannot have another investment account as it's parent | 968 | // an investment cannot have another investment account as it's parent | ||
970 | if (parent.isInvest()) | 969 | if (parent.isInvest()) | ||
971 | throw MYMONEYEXCEPTION("Stock account cannot be parent account"); | 970 | throw MYMONEYEXCEPTION_CSTRING("Stock account cannot be parent account"); | ||
972 | 971 | | |||
973 | if (account.isInvest() && parent.accountType() != Account::Type::Investment) | 972 | if (account.isInvest() && parent.accountType() != Account::Type::Investment) | ||
974 | throw MYMONEYEXCEPTION("Stock account must have investment account as parent "); | 973 | throw MYMONEYEXCEPTION_CSTRING("Stock account must have investment account as parent "); | ||
975 | 974 | | |||
976 | if (!account.isInvest() && parent.accountType() == Account::Type::Investment) | 975 | if (!account.isInvest() && parent.accountType() == Account::Type::Investment) | ||
977 | throw MYMONEYEXCEPTION("Investment account can only have stock accounts as children"); | 976 | throw MYMONEYEXCEPTION_CSTRING("Investment account can only have stock accounts as children"); | ||
978 | 977 | | |||
979 | // if an institution is set, verify that it exists | 978 | // if an institution is set, verify that it exists | ||
980 | if (account.institutionId().length() != 0) { | 979 | if (account.institutionId().length() != 0) { | ||
Context not available. | |||||
1091 | MyMoneyAccount MyMoneyFile::openingBalanceAccount(const MyMoneySecurity& security) | 1090 | MyMoneyAccount MyMoneyFile::openingBalanceAccount(const MyMoneySecurity& security) | ||
1092 | { | 1091 | { | ||
1093 | if (!security.isCurrency()) | 1092 | if (!security.isCurrency()) | ||
1094 | throw MYMONEYEXCEPTION("Opening balance for non currencies not supported"); | 1093 | throw MYMONEYEXCEPTION_CSTRING("Opening balance for non currencies not supported"); | ||
1095 | 1094 | | |||
1096 | try { | 1095 | try { | ||
1097 | return openingBalanceAccount_internal(security); | 1096 | return openingBalanceAccount_internal(security); | ||
Context not available. | |||||
1118 | MyMoneyAccount MyMoneyFile::openingBalanceAccount_internal(const MyMoneySecurity& security) const | 1117 | MyMoneyAccount MyMoneyFile::openingBalanceAccount_internal(const MyMoneySecurity& security) const | ||
1119 | { | 1118 | { | ||
1120 | if (!security.isCurrency()) | 1119 | if (!security.isCurrency()) | ||
1121 | throw MYMONEYEXCEPTION("Opening balance for non currencies not supported"); | 1120 | throw MYMONEYEXCEPTION_CSTRING("Opening balance for non currencies not supported"); | ||
1122 | 1121 | | |||
1123 | MyMoneyAccount acc; | 1122 | MyMoneyAccount acc; | ||
1124 | QList<MyMoneyAccount> accounts; | 1123 | QList<MyMoneyAccount> accounts; | ||
Context not available. | |||||
1144 | } | 1143 | } | ||
1145 | } | 1144 | } | ||
1146 | 1145 | | |||
1147 | if (acc.id().isEmpty()) { | 1146 | if (acc.id().isEmpty()) | ||
1148 | throw MYMONEYEXCEPTION(QString("No opening balance account for %1").arg(security.tradingSymbol())); | 1147 | throw MYMONEYEXCEPTION(QString::fromLatin1("No opening balance account for %1").arg(security.tradingSymbol())); | ||
1149 | } | | |||
1150 | 1148 | | |||
1151 | return acc; | 1149 | return acc; | ||
1152 | } | 1150 | } | ||
Context not available. | |||||
1205 | 1203 | | |||
1206 | // first perform all the checks | 1204 | // first perform all the checks | ||
1207 | if (!transaction.id().isEmpty()) | 1205 | if (!transaction.id().isEmpty()) | ||
1208 | throw MYMONEYEXCEPTION("Unable to add transaction with id set"); | 1206 | throw MYMONEYEXCEPTION_CSTRING("Unable to add transaction with id set"); | ||
1209 | if (!transaction.postDate().isValid()) | 1207 | if (!transaction.postDate().isValid()) | ||
1210 | throw MYMONEYEXCEPTION("Unable to add transaction with invalid postdate"); | 1208 | throw MYMONEYEXCEPTION_CSTRING("Unable to add transaction with invalid postdate"); | ||
1211 | 1209 | | |||
1212 | // now check the splits | 1210 | // now check the splits | ||
1213 | auto loanAccountAffected = false; | 1211 | auto loanAccountAffected = false; | ||
Context not available. | |||||
1217 | // account does not exist or is one of the standard accounts | 1215 | // account does not exist or is one of the standard accounts | ||
1218 | auto acc = MyMoneyFile::account(split.accountId()); | 1216 | auto acc = MyMoneyFile::account(split.accountId()); | ||
1219 | if (acc.id().isEmpty()) | 1217 | if (acc.id().isEmpty()) | ||
1220 | throw MYMONEYEXCEPTION("Cannot add split with no account assigned"); | 1218 | throw MYMONEYEXCEPTION_CSTRING("Cannot add split with no account assigned"); | ||
1221 | if (acc.isLoan()) | 1219 | if (acc.isLoan()) | ||
1222 | loanAccountAffected = true; | 1220 | loanAccountAffected = true; | ||
1223 | if (isStandardAccount(split.accountId())) | 1221 | if (isStandardAccount(split.accountId())) | ||
1224 | throw MYMONEYEXCEPTION("Cannot add split referencing standard account"); | 1222 | throw MYMONEYEXCEPTION_CSTRING("Cannot add split referencing standard account"); | ||
1225 | } | 1223 | } | ||
1226 | 1224 | | |||
1227 | // change transfer splits between asset/liability and loan accounts | 1225 | // change transfer splits between asset/liability and loan accounts | ||
Context not available. | |||||
1577 | qWarning("Missing price info for conversion from %s to %s", qPrintable(from.name()), qPrintable(to.name())); | 1575 | qWarning("Missing price info for conversion from %s to %s", qPrintable(from.name()), qPrintable(to.name())); | ||
1578 | 1576 | | |||
1579 | } catch (const MyMoneyException &e) { | 1577 | } catch (const MyMoneyException &e) { | ||
1580 | qWarning("Missing security caught in MyMoneyFile::warningMissingRate(): %s(%ld) %s", qPrintable(e.file()), e.line(), qPrintable(e.what())); | 1578 | qWarning("Missing security caught in MyMoneyFile::warningMissingRate(). %s", qPrintable(e.what())); | ||
1581 | } | 1579 | } | ||
1582 | } | 1580 | } | ||
1583 | 1581 | | |||
Context not available. | |||||
1718 | // account does not exist or is one of the standard accounts | 1716 | // account does not exist or is one of the standard accounts | ||
1719 | const auto acc = account(split.accountId()); | 1717 | const auto acc = account(split.accountId()); | ||
1720 | if (acc.id().isEmpty()) | 1718 | if (acc.id().isEmpty()) | ||
1721 | throw MYMONEYEXCEPTION("Cannot add split with no account assigned"); | 1719 | throw MYMONEYEXCEPTION_CSTRING("Cannot add split with no account assigned"); | ||
1722 | if (isStandardAccount(split.accountId())) | 1720 | if (isStandardAccount(split.accountId())) | ||
1723 | throw MYMONEYEXCEPTION("Cannot add split referencing standard account"); | 1721 | throw MYMONEYEXCEPTION_CSTRING("Cannot add split referencing standard account"); | ||
1724 | } | 1722 | } | ||
1725 | 1723 | | |||
1726 | d->m_storage->addSchedule(sched); | 1724 | d->m_storage->addSchedule(sched); | ||
Context not available. | |||||
1736 | // account does not exist or is one of the standard accounts | 1734 | // account does not exist or is one of the standard accounts | ||
1737 | auto acc = MyMoneyFile::account(split.accountId()); | 1735 | auto acc = MyMoneyFile::account(split.accountId()); | ||
1738 | if (acc.id().isEmpty()) | 1736 | if (acc.id().isEmpty()) | ||
1739 | throw MYMONEYEXCEPTION("Cannot store split with no account assigned"); | 1737 | throw MYMONEYEXCEPTION_CSTRING("Cannot store split with no account assigned"); | ||
1740 | if (isStandardAccount(split.accountId())) | 1738 | if (isStandardAccount(split.accountId())) | ||
1741 | throw MYMONEYEXCEPTION("Cannot store split referencing standard account"); | 1739 | throw MYMONEYEXCEPTION_CSTRING("Cannot store split referencing standard account"); | ||
1742 | } | 1740 | } | ||
1743 | 1741 | | |||
1744 | d->m_storage->modifySchedule(sched); | 1742 | d->m_storage->modifySchedule(sched); | ||
Context not available. | |||||
1940 | try { | 1938 | try { | ||
1941 | child = account(accountID); | 1939 | child = account(accountID); | ||
1942 | if (child.parentAccountId() != (*it_a).id()) { | 1940 | if (child.parentAccountId() != (*it_a).id()) { | ||
1943 | throw MYMONEYEXCEPTION("Child account has a different parent"); | 1941 | throw MYMONEYEXCEPTION_CSTRING("Child account has a different parent"); | ||
1944 | } | 1942 | } | ||
1945 | } catch (const MyMoneyException &) { | 1943 | } catch (const MyMoneyException &) { | ||
1946 | problemCount++; | 1944 | problemCount++; | ||
Context not available. | |||||
2446 | QString categoryText; | 2444 | QString categoryText; | ||
2447 | 2445 | | |||
2448 | if (base.id() != expense().id() && base.id() != income().id()) | 2446 | if (base.id() != expense().id() && base.id() != income().id()) | ||
2449 | throw MYMONEYEXCEPTION("Invalid base category"); | 2447 | throw MYMONEYEXCEPTION_CSTRING("Invalid base category"); | ||
2450 | 2448 | | |||
2451 | QStringList subAccounts = name.split(AccountSeparator); | 2449 | QStringList subAccounts = name.split(AccountSeparator); | ||
2452 | QStringList::Iterator it; | 2450 | QStringList::Iterator it; | ||
Context not available. | |||||
2609 | d->checkTransaction(Q_FUNC_INFO); | 2607 | d->checkTransaction(Q_FUNC_INFO); | ||
2610 | 2608 | | |||
2611 | if (currency.id() == d->m_baseCurrency.id()) | 2609 | if (currency.id() == d->m_baseCurrency.id()) | ||
2612 | throw MYMONEYEXCEPTION("Cannot delete base currency."); | 2610 | throw MYMONEYEXCEPTION_CSTRING("Cannot delete base currency."); | ||
2613 | 2611 | | |||
2614 | // FIXME check that security is not referenced by other object | 2612 | // FIXME check that security is not referenced by other object | ||
2615 | 2613 | | |||
Context not available. | |||||
2629 | 2627 | | |||
2630 | return currency; | 2628 | return currency; | ||
2631 | 2629 | | |||
2632 | } catch(const MyMoneyException&) { | 2630 | } catch (const MyMoneyException &) { | ||
2633 | const auto security = d->m_storage->security(id); | 2631 | const auto security = d->m_storage->security(id); | ||
2634 | if (security.id().isEmpty()) { | 2632 | if (security.id().isEmpty()) { | ||
2635 | throw MYMONEYEXCEPTION(QString::fromLatin1("Security '%1' not found.").arg(id)); | 2633 | throw MYMONEYEXCEPTION(QString::fromLatin1("Security '%1' not found.").arg(id)); | ||
Context not available. | |||||
3435 | { | 3433 | { | ||
3436 | try { | 3434 | try { | ||
3437 | rollback(); | 3435 | rollback(); | ||
3438 | } catch (const MyMoneyException & e) { | 3436 | } catch (const MyMoneyException &e) { | ||
3439 | qDebug() << e.what(); | 3437 | qDebug() << e.what(); | ||
3440 | } | 3438 | } | ||
3441 | Q_D(MyMoneyFileTransaction); | 3439 | Q_D(MyMoneyFileTransaction); | ||
Context not available. |