Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/mymoney/mymoneyaccount.cpp
Context not available. | |||||
38 | #include "mymoneyexception.h" | 38 | #include "mymoneyexception.h" | ||
---|---|---|---|---|---|
39 | #include "mymoneysplit.h" | 39 | #include "mymoneysplit.h" | ||
40 | #include "mymoneyfile.h" | 40 | #include "mymoneyfile.h" | ||
41 | #include "mymoneysecurity.h" | ||||
42 | #include "mymoneyinstitution.h" | ||||
43 | #include "mymoneypayee.h" | ||||
41 | #include "payeeidentifier/payeeidentifiertyped.h" | 44 | #include "payeeidentifier/payeeidentifiertyped.h" | ||
42 | #include "payeeidentifier/ibanandbic/ibanbic.h" | 45 | #include "payeeidentifier/ibanandbic/ibanbic.h" | ||
43 | #include "payeeidentifier/nationalaccount/nationalaccount.h" | 46 | #include "payeeidentifier/nationalaccount/nationalaccount.h" | ||
Context not available. | |||||
48 | using namespace Icons; | 51 | using namespace Icons; | ||
49 | 52 | | |||
50 | MyMoneyAccount::MyMoneyAccount() : | 53 | MyMoneyAccount::MyMoneyAccount() : | ||
51 | m_accountType(UnknownAccountType), | 54 | m_accountType(eMyMoney::Account::Unknown), | ||
52 | m_fraction(-1) | 55 | m_fraction(-1) | ||
53 | { | 56 | { | ||
54 | } | 57 | } | ||
Context not available. | |||||
67 | MyMoneyAccount::MyMoneyAccount(const QDomElement& node) : | 70 | MyMoneyAccount::MyMoneyAccount(const QDomElement& node) : | ||
68 | MyMoneyObject(node), | 71 | MyMoneyObject(node), | ||
69 | MyMoneyKeyValueContainer(node.elementsByTagName(nodeNames[nnKeyValuePairs]).item(0).toElement()), | 72 | MyMoneyKeyValueContainer(node.elementsByTagName(nodeNames[nnKeyValuePairs]).item(0).toElement()), | ||
70 | m_accountType(UnknownAccountType), | 73 | m_accountType(eMyMoney::Account::Unknown), | ||
71 | m_fraction(-1) | 74 | m_fraction(-1) | ||
72 | { | 75 | { | ||
73 | if (nodeNames[nnAccount] != node.tagName()) | 76 | if (nodeNames[nnAccount] != node.tagName()) | ||
Context not available. | |||||
104 | bool bOK = false; | 107 | bool bOK = false; | ||
105 | int type = tmp.toInt(&bOK); | 108 | int type = tmp.toInt(&bOK); | ||
106 | if (bOK) { | 109 | if (bOK) { | ||
107 | setAccountType(static_cast<MyMoneyAccount::accountTypeE>(type)); | 110 | setAccountType(static_cast<eMyMoney::Account>(type)); | ||
108 | } else { | 111 | } else { | ||
109 | qWarning("XMLREADER: Account %s had invalid or no account type information.", qPrintable(name())); | 112 | qWarning("XMLREADER: Account %s had invalid or no account type information.", qPrintable(name())); | ||
110 | } | 113 | } | ||
Context not available. | |||||
195 | m_parentAccount = parent; | 198 | m_parentAccount = parent; | ||
196 | } | 199 | } | ||
197 | 200 | | |||
198 | void MyMoneyAccount::setAccountType(const accountTypeE type) | 201 | void MyMoneyAccount::setAccountType(const eMyMoney::Account type) | ||
199 | { | 202 | { | ||
200 | m_accountType = type; | 203 | m_accountType = type; | ||
201 | } | 204 | } | ||
Context not available. | |||||
237 | (m_institution == right.m_institution)); | 240 | (m_institution == right.m_institution)); | ||
238 | } | 241 | } | ||
239 | 242 | | |||
240 | MyMoneyAccount::accountTypeE MyMoneyAccount::accountGroup() const | 243 | eMyMoney::Account MyMoneyAccount::accountGroup() const | ||
241 | { | 244 | { | ||
242 | switch (m_accountType) { | 245 | switch (m_accountType) { | ||
243 | case MyMoneyAccount::Checkings: | 246 | case eMyMoney::Account::Checkings: | ||
244 | case MyMoneyAccount::Savings: | 247 | case eMyMoney::Account::Savings: | ||
245 | case MyMoneyAccount::Cash: | 248 | case eMyMoney::Account::Cash: | ||
246 | case MyMoneyAccount::Currency: | 249 | case eMyMoney::Account::Currency: | ||
247 | case MyMoneyAccount::Investment: | 250 | case eMyMoney::Account::Investment: | ||
248 | case MyMoneyAccount::MoneyMarket: | 251 | case eMyMoney::Account::MoneyMarket: | ||
249 | case MyMoneyAccount::CertificateDep: | 252 | case eMyMoney::Account::CertificateDep: | ||
250 | case MyMoneyAccount::AssetLoan: | 253 | case eMyMoney::Account::AssetLoan: | ||
251 | case MyMoneyAccount::Stock: | 254 | case eMyMoney::Account::Stock: | ||
252 | return MyMoneyAccount::Asset; | 255 | return eMyMoney::Account::Asset; | ||
253 | 256 | | |||
254 | case MyMoneyAccount::CreditCard: | 257 | case eMyMoney::Account::CreditCard: | ||
255 | case MyMoneyAccount::Loan: | 258 | case eMyMoney::Account::Loan: | ||
256 | return MyMoneyAccount::Liability; | 259 | return eMyMoney::Account::Liability; | ||
257 | 260 | | |||
258 | default: | 261 | default: | ||
259 | return m_accountType; | 262 | return m_accountType; | ||
Context not available. | |||||
267 | 270 | | |||
268 | bool MyMoneyAccount::isAssetLiability() const | 271 | bool MyMoneyAccount::isAssetLiability() const | ||
269 | { | 272 | { | ||
270 | return accountGroup() == Asset || accountGroup() == Liability; | 273 | return accountGroup() == eMyMoney::Account::Asset || accountGroup() == eMyMoney::Account::Liability; | ||
271 | } | 274 | } | ||
272 | 275 | | |||
273 | bool MyMoneyAccount::isIncomeExpense() const | 276 | bool MyMoneyAccount::isIncomeExpense() const | ||
274 | { | 277 | { | ||
275 | return accountGroup() == Income || accountGroup() == Expense; | 278 | return accountGroup() == eMyMoney::Account::Income || accountGroup() == eMyMoney::Account::Expense; | ||
276 | } | 279 | } | ||
277 | 280 | | |||
278 | bool MyMoneyAccount::isLoan() const | 281 | bool MyMoneyAccount::isLoan() const | ||
279 | { | 282 | { | ||
280 | return accountType() == Loan || accountType() == AssetLoan; | 283 | return accountType() == eMyMoney::Account::Loan || accountType() == eMyMoney::Account::AssetLoan; | ||
281 | } | 284 | } | ||
282 | 285 | | |||
283 | bool MyMoneyAccount::isInvest() const | 286 | bool MyMoneyAccount::isInvest() const | ||
284 | { | 287 | { | ||
285 | return accountType() == Stock; | 288 | return accountType() == eMyMoney::Account::Stock; | ||
286 | } | 289 | } | ||
287 | 290 | | |||
288 | bool MyMoneyAccount::isLiquidAsset() const | 291 | bool MyMoneyAccount::isLiquidAsset() const | ||
289 | { | 292 | { | ||
290 | return accountType() == Checkings || | 293 | return accountType() == eMyMoney::Account::Checkings || | ||
291 | accountType() == Savings || | 294 | accountType() == eMyMoney::Account::Savings || | ||
292 | accountType() == Cash; | 295 | accountType() == eMyMoney::Account::Cash; | ||
293 | } | 296 | } | ||
294 | 297 | | |||
295 | bool MyMoneyAccount::isCostCenterRequired() const | 298 | bool MyMoneyAccount::isCostCenterRequired() const | ||
Context not available. | |||||
541 | el.setAttribute(getAttrName(anOpened), dateToString(openingDate())); | 544 | el.setAttribute(getAttrName(anOpened), dateToString(openingDate())); | ||
542 | el.setAttribute(getAttrName(anNumber), number()); | 545 | el.setAttribute(getAttrName(anNumber), number()); | ||
543 | // el.setAttribute(getAttrName(anOpeningBalance), openingBalance().toString()); | 546 | // el.setAttribute(getAttrName(anOpeningBalance), openingBalance().toString()); | ||
544 | el.setAttribute(getAttrName(anType), accountType()); | 547 | el.setAttribute(getAttrName(anType), (int)accountType()); | ||
545 | el.setAttribute(getAttrName(anName), name()); | 548 | el.setAttribute(getAttrName(anName), name()); | ||
546 | el.setAttribute(getAttrName(anDescription), description()); | 549 | el.setAttribute(getAttrName(anDescription), description()); | ||
547 | if (!currencyId().isEmpty()) | 550 | if (!currencyId().isEmpty()) | ||
Context not available. | |||||
614 | int MyMoneyAccount::fraction(const MyMoneySecurity& sec) const | 617 | int MyMoneyAccount::fraction(const MyMoneySecurity& sec) const | ||
615 | { | 618 | { | ||
616 | int fraction; | 619 | int fraction; | ||
617 | if (m_accountType == Cash) | 620 | if (m_accountType == eMyMoney::Account::Cash) | ||
618 | fraction = sec.smallestCashFraction(); | 621 | fraction = sec.smallestCashFraction(); | ||
619 | else | 622 | else | ||
620 | fraction = sec.smallestAccountFraction(); | 623 | fraction = sec.smallestAccountFraction(); | ||
Context not available. | |||||
623 | 626 | | |||
624 | int MyMoneyAccount::fraction(const MyMoneySecurity& sec) | 627 | int MyMoneyAccount::fraction(const MyMoneySecurity& sec) | ||
625 | { | 628 | { | ||
626 | if (m_accountType == Cash) | 629 | if (m_accountType == eMyMoney::Account::Cash) | ||
627 | m_fraction = sec.smallestCashFraction(); | 630 | m_fraction = sec.smallestCashFraction(); | ||
628 | else | 631 | else | ||
629 | m_fraction = sec.smallestAccountFraction(); | 632 | m_fraction = sec.smallestAccountFraction(); | ||
Context not available. | |||||
637 | 640 | | |||
638 | bool MyMoneyAccount::isCategory() const | 641 | bool MyMoneyAccount::isCategory() const | ||
639 | { | 642 | { | ||
640 | return m_accountType == Income || m_accountType == Expense; | 643 | return m_accountType == eMyMoney::Account::Income || m_accountType == eMyMoney::Account::Expense; | ||
641 | } | 644 | } | ||
642 | 645 | | |||
643 | QString MyMoneyAccount::brokerageName() const | 646 | QString MyMoneyAccount::brokerageName() const | ||
644 | { | 647 | { | ||
645 | if (m_accountType == Investment) | 648 | if (m_accountType == eMyMoney::Account::Investment) | ||
646 | return QString("%1 (%2)").arg(m_name, i18nc("Brokerage (suffix for account names)", "Brokerage")); | 649 | return QString("%1 (%2)").arg(m_name, i18nc("Brokerage (suffix for account names)", "Brokerage")); | ||
647 | return m_name; | 650 | return m_name; | ||
648 | } | 651 | } | ||
Context not available. | |||||
665 | 668 | | |||
666 | QPixmap MyMoneyAccount::accountPixmap(const bool reconcileFlag, const int size) const | 669 | QPixmap MyMoneyAccount::accountPixmap(const bool reconcileFlag, const int size) const | ||
667 | { | 670 | { | ||
668 | static const QHash<MyMoneyAccount::accountTypeE, Icon> accToIco { | 671 | static const QHash<eMyMoney::Account, Icon> accToIco { | ||
669 | {MyMoneyAccount::Asset, Icon::ViewAsset}, | 672 | {eMyMoney::Account::Asset, Icon::ViewAsset}, | ||
670 | {MyMoneyAccount::Investment, Icon::ViewStock}, | 673 | {eMyMoney::Account::Investment, Icon::ViewStock}, | ||
671 | {MyMoneyAccount::Stock, Icon::ViewStock}, | 674 | {eMyMoney::Account::Stock, Icon::ViewStock}, | ||
672 | {MyMoneyAccount::MoneyMarket, Icon::ViewStock}, | 675 | {eMyMoney::Account::MoneyMarket, Icon::ViewStock}, | ||
673 | {MyMoneyAccount::Checkings, Icon::ViewChecking}, | 676 | {eMyMoney::Account::Checkings, Icon::ViewChecking}, | ||
674 | {MyMoneyAccount::Savings, Icon::ViewSaving}, | 677 | {eMyMoney::Account::Savings, Icon::ViewSaving}, | ||
675 | {MyMoneyAccount::AssetLoan, Icon::ViewLoanAsset}, | 678 | {eMyMoney::Account::AssetLoan, Icon::ViewLoanAsset}, | ||
676 | {MyMoneyAccount::Loan, Icon::ViewLoan}, | 679 | {eMyMoney::Account::Loan, Icon::ViewLoan}, | ||
677 | {MyMoneyAccount::CreditCard, Icon::ViewCreditCard}, | 680 | {eMyMoney::Account::CreditCard, Icon::ViewCreditCard}, | ||
678 | {MyMoneyAccount::Asset, Icon::ViewAsset}, | 681 | {eMyMoney::Account::Asset, Icon::ViewAsset}, | ||
679 | {MyMoneyAccount::Cash, Icon::ViewCash}, | 682 | {eMyMoney::Account::Cash, Icon::ViewCash}, | ||
680 | {MyMoneyAccount::Income, Icon::ViewIncome}, | 683 | {eMyMoney::Account::Income, Icon::ViewIncome}, | ||
681 | {MyMoneyAccount::Expense, Icon::ViewExpense}, | 684 | {eMyMoney::Account::Expense, Icon::ViewExpense}, | ||
682 | {MyMoneyAccount::Equity, Icon::ViewEquity} | 685 | {eMyMoney::Account::Equity, Icon::ViewEquity} | ||
683 | }; | 686 | }; | ||
684 | 687 | | |||
685 | Icon ixIcon = accToIco.value(accountType(), Icon::ViewLiability); | 688 | Icon ixIcon = accToIco.value(accountType(), Icon::ViewLiability); | ||
Context not available. | |||||
708 | return pxIcon; | 711 | return pxIcon; | ||
709 | } | 712 | } | ||
710 | 713 | | |||
711 | QString MyMoneyAccount::accountTypeToString(const MyMoneyAccount::accountTypeE accountType) | 714 | QString MyMoneyAccount::accountTypeToString(const eMyMoney::Account accountType) | ||
712 | { | 715 | { | ||
713 | QString returnString; | 716 | QString returnString; | ||
714 | 717 | | |||
715 | switch (accountType) { | 718 | switch (accountType) { | ||
716 | case MyMoneyAccount::Checkings: | 719 | case eMyMoney::Account::Checkings: | ||
717 | returnString = i18n("Checking"); | 720 | returnString = i18n("Checking"); | ||
718 | break; | 721 | break; | ||
719 | case MyMoneyAccount::Savings: | 722 | case eMyMoney::Account::Savings: | ||
720 | returnString = i18n("Savings"); | 723 | returnString = i18n("Savings"); | ||
721 | break; | 724 | break; | ||
722 | case MyMoneyAccount::CreditCard: | 725 | case eMyMoney::Account::CreditCard: | ||
723 | returnString = i18n("Credit Card"); | 726 | returnString = i18n("Credit Card"); | ||
724 | break; | 727 | break; | ||
725 | case MyMoneyAccount::Cash: | 728 | case eMyMoney::Account::Cash: | ||
726 | returnString = i18n("Cash"); | 729 | returnString = i18n("Cash"); | ||
727 | break; | 730 | break; | ||
728 | case MyMoneyAccount::Loan: | 731 | case eMyMoney::Account::Loan: | ||
729 | returnString = i18n("Loan"); | 732 | returnString = i18n("Loan"); | ||
730 | break; | 733 | break; | ||
731 | case MyMoneyAccount::CertificateDep: | 734 | case eMyMoney::Account::CertificateDep: | ||
732 | returnString = i18n("Certificate of Deposit"); | 735 | returnString = i18n("Certificate of Deposit"); | ||
733 | break; | 736 | break; | ||
734 | case MyMoneyAccount::Investment: | 737 | case eMyMoney::Account::Investment: | ||
735 | returnString = i18n("Investment"); | 738 | returnString = i18n("Investment"); | ||
736 | break; | 739 | break; | ||
737 | case MyMoneyAccount::MoneyMarket: | 740 | case eMyMoney::Account::MoneyMarket: | ||
738 | returnString = i18n("Money Market"); | 741 | returnString = i18n("Money Market"); | ||
739 | break; | 742 | break; | ||
740 | case MyMoneyAccount::Asset: | 743 | case eMyMoney::Account::Asset: | ||
741 | returnString = i18n("Asset"); | 744 | returnString = i18n("Asset"); | ||
742 | break; | 745 | break; | ||
743 | case MyMoneyAccount::Liability: | 746 | case eMyMoney::Account::Liability: | ||
744 | returnString = i18n("Liability"); | 747 | returnString = i18n("Liability"); | ||
745 | break; | 748 | break; | ||
746 | case MyMoneyAccount::Currency: | 749 | case eMyMoney::Account::Currency: | ||
747 | returnString = i18n("Currency"); | 750 | returnString = i18n("Currency"); | ||
748 | break; | 751 | break; | ||
749 | case MyMoneyAccount::Income: | 752 | case eMyMoney::Account::Income: | ||
750 | returnString = i18n("Income"); | 753 | returnString = i18n("Income"); | ||
751 | break; | 754 | break; | ||
752 | case MyMoneyAccount::Expense: | 755 | case eMyMoney::Account::Expense: | ||
753 | returnString = i18n("Expense"); | 756 | returnString = i18n("Expense"); | ||
754 | break; | 757 | break; | ||
755 | case MyMoneyAccount::AssetLoan: | 758 | case eMyMoney::Account::AssetLoan: | ||
756 | returnString = i18n("Investment Loan"); | 759 | returnString = i18n("Investment Loan"); | ||
757 | break; | 760 | break; | ||
758 | case MyMoneyAccount::Stock: | 761 | case eMyMoney::Account::Stock: | ||
759 | returnString = i18n("Stock"); | 762 | returnString = i18n("Stock"); | ||
760 | break; | 763 | break; | ||
761 | case MyMoneyAccount::Equity: | 764 | case eMyMoney::Account::Equity: | ||
762 | returnString = i18n("Equity"); | 765 | returnString = i18n("Equity"); | ||
763 | break; | 766 | break; | ||
764 | default: | 767 | default: | ||
Context not available. |