Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/kmymoney.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 3812 Lines • ▼ Show 20 Line(s) | |||||
3813 | 3813 | | |||
3814 | KMyMoneyUtils::CanCloseAccountCodeE KMyMoneyApp::canCloseAccount(const MyMoneyAccount& acc) const | 3814 | KMyMoneyUtils::CanCloseAccountCodeE KMyMoneyApp::canCloseAccount(const MyMoneyAccount& acc) const | ||
3815 | { | 3815 | { | ||
3816 | // balance must be zero | 3816 | // balance must be zero | ||
3817 | if (!acc.balance().isZero()) | 3817 | if (!acc.balance().isZero()) | ||
3818 | return KMyMoneyUtils::AccountBalanceNonZero; | 3818 | return KMyMoneyUtils::AccountBalanceNonZero; | ||
3819 | 3819 | | |||
3820 | // all children must be already closed | 3820 | // all children must be already closed | ||
3821 | QStringList::const_iterator it_a; | 3821 | foreach (const auto sAccount, acc.accountList()) { | ||
3822 | for (it_a = acc.accountList().constBegin(); it_a != acc.accountList().constEnd(); ++it_a) { | 3822 | if (!MyMoneyFile::instance()->account(sAccount).isClosed()) { | ||
3823 | MyMoneyAccount a = MyMoneyFile::instance()->account(*it_a); | | |||
3824 | if (!a.isClosed()) { | | |||
3825 | return KMyMoneyUtils::AccountChildrenOpen; | 3823 | return KMyMoneyUtils::AccountChildrenOpen; | ||
3826 | } | 3824 | } | ||
3827 | } | 3825 | } | ||
3828 | 3826 | | |||
3829 | // there must be no unfinished schedule referencing the account | 3827 | // there must be no unfinished schedule referencing the account | ||
3830 | QList<MyMoneySchedule> list = MyMoneyFile::instance()->scheduleList(); | 3828 | QList<MyMoneySchedule> list = MyMoneyFile::instance()->scheduleList(); | ||
3831 | QList<MyMoneySchedule>::const_iterator it_l; | 3829 | QList<MyMoneySchedule>::const_iterator it_l; | ||
3832 | for (it_l = list.constBegin(); it_l != list.constEnd(); ++it_l) { | 3830 | for (it_l = list.constBegin(); it_l != list.constEnd(); ++it_l) { | ||
▲ Show 20 Lines • Show All 1846 Lines • ▼ Show 20 Line(s) | 5673 | foreach (const auto split, t.splits()) { | |||
5679 | if (!MyMoneyFile::instance()->security(stockSecurityId).isCurrency()) { | 5677 | if (!MyMoneyFile::instance()->security(stockSecurityId).isCurrency()) { | ||
5680 | s = split; | 5678 | s = split; | ||
5681 | break; | 5679 | break; | ||
5682 | } | 5680 | } | ||
5683 | } | 5681 | } | ||
5684 | // Now check the target investment account to see if it | 5682 | // Now check the target investment account to see if it | ||
5685 | // contains a stock with this id | 5683 | // contains a stock with this id | ||
5686 | QString newStockAccountId; | 5684 | QString newStockAccountId; | ||
5687 | QStringList accountList = toInvAcc.accountList(); | 5685 | foreach (const auto sAccount, toInvAcc.accountList()) { | ||
5688 | for (QStringList::const_iterator it_a = accountList.constBegin(); it_a != accountList.constEnd(); ++it_a) { | 5686 | if (MyMoneyFile::instance()->account(sAccount).currencyId() == | ||
5689 | if (MyMoneyFile::instance()->account((*it_a)).currencyId() == | | |||
5690 | stockSecurityId) { | 5687 | stockSecurityId) { | ||
5691 | newStockAccountId = (*it_a); | 5688 | newStockAccountId = sAccount; | ||
5692 | break; | 5689 | break; | ||
5693 | } | 5690 | } | ||
5694 | } | 5691 | } | ||
5695 | // if it doesn't exist, we need to add it as a copy of the old one | 5692 | // if it doesn't exist, we need to add it as a copy of the old one | ||
5696 | // no 'copyAccount()' function?? | 5693 | // no 'copyAccount()' function?? | ||
5697 | if (newStockAccountId.isEmpty()) { | 5694 | if (newStockAccountId.isEmpty()) { | ||
5698 | MyMoneyAccount stockAccount = | 5695 | MyMoneyAccount stockAccount = | ||
5699 | MyMoneyFile::instance()->account(stockAccountId); | 5696 | MyMoneyFile::instance()->account(stockAccountId); | ||
▲ Show 20 Lines • Show All 1879 Lines • Show Last 20 Lines |