mymoneyaccount.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           mymoneyaccount.h
00003                           -------------------
00004     copyright            : (C) 2002 by Thomas Baumgart
00005     email                : ipwizard@users.sourceforge.net
00006  ***************************************************************************/
00007 
00008 /***************************************************************************
00009  *                                                                         *
00010  *   This program is free software; you can redistribute it and/or modify  *
00011  *   it under the terms of the GNU General Public License as published by  *
00012  *   the Free Software Foundation; either version 2 of the License, or     *
00013  *   (at your option) any later version.                                   *
00014  *                                                                         *
00015  ***************************************************************************/
00016 
00017 #ifndef MYMONEYACCOUNT_H
00018 #define MYMONEYACCOUNT_H
00019 
00020 #ifdef HAVE_CONFIG_H
00021 #include <config.h>
00022 #endif
00023 
00024 // ----------------------------------------------------------------------------
00025 // QT Includes
00026 
00027 #include <qstring.h>
00028 #include <qdatetime.h>
00029 #include <qvaluelist.h>
00030 #include <qstringlist.h>
00031 #include <qdom.h>
00032 #include <qpixmap.h>
00033 
00034 // ----------------------------------------------------------------------------
00035 // Project Includes
00036 
00037 #include <kmymoney/mymoneymoney.h>
00038 #include <kmymoney/mymoneyobject.h>
00039 #include <kmymoney/mymoneykeyvaluecontainer.h>
00040 #include <kmymoney/mymoneysecurity.h>
00041 #include <kmymoney/mymoneytransaction.h>
00042 #include <kmymoney/export.h>
00043 #include "mymoneyutils.h"
00044 class MyMoneyTransaction;
00045 class MyMoneyInstitution;
00046 class MyMoneySplit;
00047 class MyMoneyObjectContainer;
00048 
00081 class KMYMONEY_EXPORT MyMoneyAccount : public MyMoneyObject, public MyMoneyKeyValueContainer
00082 {
00083   friend class MyMoneyObjectContainer;
00084 public:
00085 
00089   typedef enum _accountTypeE {
00090     UnknownAccountType=0, 
00091     Checkings,            
00092     Savings,              
00093     Cash,                 
00095     CreditCard,           
00096     Loan,                 
00097     CertificateDep,       
00098     Investment,           
00099     MoneyMarket,          
00100     Asset,                
00101     Liability,            
00102     Currency,             
00103     Income,               
00104     Expense,              
00105     AssetLoan,            
00106     Stock,                
00107     Equity,               
00109     /* insert new account types above this line */
00110     MaxAccountTypes       
00111   }accountTypeE;
00112 
00116   MyMoneyAccount();
00117 
00126   MyMoneyAccount(const QString& id, const MyMoneyAccount& right);
00127 
00135   MyMoneyAccount(const QDomElement& el);
00136 
00140   ~MyMoneyAccount();
00141 
00145   bool operator == (const MyMoneyAccount &) const;
00146 
00179   static MyMoneyAccount::accountTypeE accountGroup(MyMoneyAccount::accountTypeE type);
00180 
00181   MyMoneyAccount::accountTypeE accountGroup(void) const;
00182 
00190   const QString& institutionId(void) const { return m_institution; }
00191 
00197   const QString& name(void) const { return m_name; }
00198 
00204   const QString& number(void) const { return m_number; }
00205 
00211   const QString& description(void) const { return m_description; }
00212 
00218   const QDate& openingDate(void) const { return m_openingDate; }
00219 
00225   const QDate& lastReconciliationDate(void) const { return m_lastReconciliationDate; }
00226 
00232   const QDate& lastModified(void) const { return m_lastModified; }
00233 
00238   const QString& parentAccountId(void) const { return m_parentAccount; };
00239 
00245   const QStringList& accountList(void) const { return m_accountList; };
00246 
00251   int accountCount(void) const { return m_accountList.count(); };
00252 
00257   void addAccountId(const QString& account);
00258 
00264   void removeAccountId(const QString& account);
00265 
00270   void removeAccountIds(void);
00271 
00278   void setLastModified(const QDate& date);
00279 
00285   void setName(const QString& name);
00286 
00292   void setNumber(const QString& number);
00293 
00300   void setDescription(const QString& desc);
00301 
00309   void setInstitutionId(const QString& id);
00310 
00318   void setOpeningDate(const QDate& date);
00319 
00326   void setLastReconciliationDate(const QDate& date);
00327 
00333   void setAccountType(const accountTypeE type);
00334 
00339   void setParentAccountId(const QString& parent);
00340 
00344   void touch(void) { setLastModified(QDate::currentDate()); }
00345 
00349   accountTypeE accountType(void) const { return m_accountType; }
00350 
00357   const QString& currencyId(void) const { return m_currencyId; };
00358 
00364   void setCurrencyId(const QString& id);
00365 
00366   void writeXML(QDomDocument& document, QDomElement& parent) const;
00367 
00377   virtual bool hasReferenceTo(const QString& id) const;
00378 
00383   const MyMoneyMoney& balance(void) const { return m_balance; }
00384 
00396   void adjustBalance(const MyMoneySplit& s, bool reverse = false);
00397 
00405   void setBalance(const MyMoneyMoney& val) { m_balance = val; }
00406 
00412   void setOnlineBankingSettings(const MyMoneyKeyValueContainer& values);
00413 
00419   const MyMoneyKeyValueContainer& onlineBankingSettings(void) const;
00420 
00429   void setClosed(bool isClosed);
00430 
00437   bool isClosed(void) const;
00438 
00449   int fraction(const MyMoneySecurity& sec);
00450 
00454   int fraction(const MyMoneySecurity& sec) const;
00455 
00464   int fraction(void) const;
00465 
00475   bool isCategory(void) const __attribute__ ((deprecated));
00476 
00484   bool isIncomeExpense(void) const;
00485 
00493   bool isAssetLiability(void) const;
00494 
00502   bool isLoan(void) const;
00503 
00511   bool isInvest(void) const;
00512 
00518   QString brokerageName(void) const;
00519 
00524   QPixmap accountPixmap(bool reconcileFlag = false, int size = 0) const;
00525 
00534   static QString accountTypeToString(const MyMoneyAccount::accountTypeE accountType);
00535 
00536   KMYMONEY_EXPORT QDataStream &operator<<( const MyMoneyAccount & );
00537   KMYMONEY_EXPORT QDataStream &operator>>( MyMoneyAccount & );
00538 
00539 private:
00543   accountTypeE m_accountType;
00544 
00549   QString m_institution;
00550 
00556   QString m_name;
00557 
00563   QString m_number;
00564 
00570   QString m_description;
00571 
00576   QDate m_lastModified;
00577 
00582   QDate m_openingDate;
00583 
00588   QDate m_lastReconciliationDate;
00589 
00593   QStringList m_accountList;
00594 
00598   QString m_parentAccount;
00599 
00603   QString m_currencyId;
00604 
00609   MyMoneyMoney    m_balance;
00610 
00615   MyMoneyKeyValueContainer m_onlineBankingSettings;
00616 
00621   int             m_fraction;
00622 
00623 };
00624 
00632 class KMYMONEY_EXPORT MyMoneyAccountLoan : public MyMoneyAccount
00633 {
00634 public:
00635   enum interestDueE {
00636     paymentDue = 0,
00637     paymentReceived
00638   };
00639 
00640   enum interestChangeUnitE {
00641     changeDaily = 0,
00642     changeWeekly,
00643     changeMonthly,
00644     changeYearly
00645   };
00646 
00647   MyMoneyAccountLoan() {}
00648   MyMoneyAccountLoan(const MyMoneyAccount&);
00649   ~MyMoneyAccountLoan() {}
00650 
00651   const MyMoneyMoney loanAmount(void) const;
00652   void setLoanAmount(const MyMoneyMoney& amount);
00653   const MyMoneyMoney interestRate(const QDate& date) const;
00654   void setInterestRate(const QDate& date, const MyMoneyMoney& rate);
00655   interestDueE interestCalculation(void) const;
00656   void setInterestCalculation(const interestDueE onReception);
00657   const QDate nextInterestChange(void) const;
00658   void setNextInterestChange(const QDate& date);
00659   const QString schedule(void) const;
00660   void setSchedule(const QString& sched);
00661   bool fixedInterestRate(void) const;
00662   void setFixedInterestRate(const bool fixed);
00663   const MyMoneyMoney finalPayment(void) const;
00664   void setFinalPayment(const MyMoneyMoney& finalPayment);
00665   unsigned int term(void) const;
00666   void setTerm(const unsigned int payments);
00667   int interestChangeFrequency(int* unit = 0) const;
00668   void setInterestChangeFrequency(const int amount, const int unit);
00669   const MyMoneyMoney periodicPayment(void) const;
00670   void setPeriodicPayment(const MyMoneyMoney& payment);
00671   int interestCompounding(void) const;
00672   void setInterestCompounding(int frequency);
00673   const QString payee(void) const;
00674   void setPayee(const QString& payee);
00675   const QString interestAccountId(void) const;
00676   void setInterestAccountId(const QString& id);
00677 
00687   virtual bool hasReferenceTo(const QString& id) const;
00688 
00689 };
00690 
00691 #endif
00692 
00693 

Generated on Wed Jan 26 13:03:18 2011 for KMyMoney by  doxygen 1.5.6