mymoneyscheduled.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           mymoneyscheduled.h
00003                              -------------------
00004     copyright            : (C) 2000-2002 by Michael Edwardes
00005                            (C) 2007 by Thomas Baumgart
00006     email                : mte@users.sourceforge.net
00007                            Thomas Baumgart <ipwizard@users.sourceforge.net>
00008  ***************************************************************************/
00009 
00010 /***************************************************************************
00011  *                                                                         *
00012  *   This program is free software; you can redistribute it and/or modify  *
00013  *   it under the terms of the GNU General Public License as published by  *
00014  *   the Free Software Foundation; either version 2 of the License, or     *
00015  *   (at your option) any later version.                                   *
00016  *                                                                         *
00017  ***************************************************************************/
00018 
00019 #ifndef MYMONEYSCHEDULED_H
00020 #define MYMONEYSCHEDULED_H
00021 
00022 #ifdef HAVE_CONFIG_H
00023 #include <config.h>
00024 #endif
00025 
00026 // ----------------------------------------------------------------------------
00027 // QT Includes
00028 
00029 #include <qstringlist.h>
00030 #include <qmap.h>
00031 #include <qdatetime.h>
00032 
00033 
00034 // ----------------------------------------------------------------------------
00035 // Project Includes
00036 
00037 #include "mymoneytransaction.h"
00038 #include "mymoneyaccount.h"
00039 #include <kmymoney/export.h>
00040 #include <kmymoney/mymoneyobject.h>
00041 
00042 class MyMoneyStorageANON;
00043 
00055 class KMYMONEY_EXPORT MyMoneySchedule : public MyMoneyObject
00056 {
00057   friend class MyMoneyStorageANON;
00058 public:
00063   enum occurenceE { OCCUR_ANY=0, OCCUR_ONCE=1, OCCUR_DAILY=2, OCCUR_WEEKLY=4, OCCUR_FORTNIGHTLY=8,
00064                     OCCUR_EVERYOTHERWEEK=16,
00065                     OCCUR_EVERYHALFMONTH=18,
00066                     OCCUR_EVERYTHREEWEEKS=20,
00067                     OCCUR_EVERYTHIRTYDAYS=30,
00068                     OCCUR_MONTHLY=32, OCCUR_EVERYFOURWEEKS=64,
00069                     OCCUR_EVERYEIGHTWEEKS=126,
00070                     OCCUR_EVERYOTHERMONTH=128, OCCUR_EVERYTHREEMONTHS=256,
00071                     OCCUR_TWICEYEARLY=1024, OCCUR_EVERYOTHERYEAR=2048, OCCUR_QUARTERLY=4096,
00072                     OCCUR_EVERYFOURMONTHS=8192, OCCUR_YEARLY=16384
00073                      };
00074 
00078   enum typeE {  TYPE_ANY=0, TYPE_BILL=1, TYPE_DEPOSIT=2, TYPE_TRANSFER=4, TYPE_LOANPAYMENT=5 };
00079 
00083   enum paymentTypeE { STYPE_ANY=0, STYPE_DIRECTDEBIT=1, STYPE_DIRECTDEPOSIT=2,
00084                       STYPE_MANUALDEPOSIT=4, STYPE_OTHER=8,
00085                       STYPE_WRITECHEQUE=16,
00086                       STYPE_STANDINGORDER=32,
00087                       STYPE_BANKTRANSFER=64 };
00088 
00095   enum weekendOptionE { MoveFriday=0, MoveMonday=1, MoveNothing=2 };
00096 
00100   MyMoneySchedule();
00101 
00110   MyMoneySchedule(const QString& name, typeE type, occurenceE occurence, int occurenceMultiplier,
00111           paymentTypeE paymentType, const QDate& startDate, const QDate& endDate, bool fixed, bool autoEnter);
00112 
00113   MyMoneySchedule(const QDomElement& node);
00114 
00115   MyMoneySchedule(const QString& id, const MyMoneySchedule& right);
00116 
00120   ~MyMoneySchedule() {}
00121 
00127   occurenceE occurence(void) const;
00128 
00136   occurenceE occurencePeriod(void) const { return m_occurence; }
00137 
00143   int occurenceMultiplier(void) const { return m_occurenceMultiplier; }
00144 
00150   typeE type(void) const { return m_type; }
00151 
00160   const QDate& startDate(void) const;
00161 
00167   paymentTypeE paymentType(void) const { return m_paymentType; }
00168 
00174   bool isFixed(void) const { return m_fixed; }
00175 
00182   bool willEnd(void) const { return m_endDate.isValid(); }
00183 
00189   int transactionsRemaining(void) const;
00190 
00198   int transactionsRemainingUntil(const QDate& endDate) const;
00199 
00205   const QDate& endDate(void) const { return m_endDate; }
00206 
00213   bool autoEnter(void) const { return m_autoEnter; }
00214 
00220   const MyMoneyTransaction& transaction(void) const { return m_transaction; }
00221 
00228   const QDate& lastPayment(void) const { return m_lastPayment; }
00229 
00239   const QDate& nextDueDate(void) const;
00240 
00252   QDate adjustedNextDueDate(void) const;
00253 
00260   QDate adjustedDate(QDate date, weekendOptionE option) const;
00261 
00268   weekendOptionE weekendOption(void) const { return m_weekendOption; }
00269 
00276   void setOccurence(occurenceE occ);
00277 
00284   void setOccurencePeriod(occurenceE occ);
00285 
00292   void setOccurenceMultiplier(int occmultiplier);
00293 
00300   void setType(typeE type);
00301 
00308   void setStartDate(const QDate& date);
00309 
00316   void setPaymentType(paymentTypeE type);
00317 
00324   void setFixed(bool fixed);
00325 
00334   void setTransaction(const MyMoneyTransaction& transaction);
00335 
00342   void setEndDate(const QDate& date);
00343 
00352   void setAutoEnter(bool autoenter);
00353 
00360   void setNextDueDate(const QDate& date);
00361 
00372   void setLastPayment(const QDate& date);
00373 
00390   void setWeekendOption(const weekendOptionE option);
00391 
00407   void validate(bool id_check=true) const;
00408 
00421   QDate adjustedNextPayment(const QDate& refDate = QDate::currentDate()) const;
00422 
00434   QDate nextPayment(const QDate& refDate = QDate::currentDate()) const;
00435 
00449   QDate nextPaymentDate(const bool& adjust, const QDate& refDate = QDate::currentDate()) const;
00450 
00460   QValueList<QDate> paymentDates(const QDate& startDate, const QDate& endDate) const;
00461 
00467   const QString& name(void) const { return m_name; }
00468 
00475   void setName(const QString& nm);
00476 
00477   bool operator ==(const MyMoneySchedule& right) const;
00478   bool operator !=(const MyMoneySchedule& right) const { return ! operator==(right); }
00479 
00480   bool operator <(const MyMoneySchedule& right) const;
00481 
00482   MyMoneyAccount account(int cnt = 1) const;
00483   MyMoneyAccount transferAccount(void) const { return account(2); };
00484   QDate dateAfter(int transactions) const;
00485 
00486   bool isOverdue() const;
00487   bool isFinished() const;
00488   bool hasRecordedPayment(const QDate&) const;
00489   void recordPayment(const QDate&);
00490   QValueList<QDate> recordedPayments(void) const { return m_recordedPayments; }
00491 
00492   void writeXML(QDomDocument& document, QDomElement& parent) const;
00493 
00503   virtual bool hasReferenceTo(const QString& id) const;
00504 
00510   QString occurenceToString() const;
00511 
00521   static QString occurenceToString(occurenceE type);
00522 
00534   static QString occurenceToString(int mult, occurenceE type);
00535 
00545   static QString occurencePeriodToString(occurenceE type);
00546 
00556   static QString paymentMethodToString(MyMoneySchedule::paymentTypeE paymentType);
00557 
00567   static QString weekendOptionToString(MyMoneySchedule::weekendOptionE weekendOption);
00568 
00578   static QString scheduleTypeToString(MyMoneySchedule::typeE type);
00579 
00580   int variation(void) const;
00581   void setVariation(int var);
00582 
00593   static int eventsPerYear(MyMoneySchedule::occurenceE occurence);
00594 
00605   static int daysBetweenEvents(MyMoneySchedule::occurenceE occurence);
00606 
00613   static void simpleToCompoundOccurence(int& multiplier,occurenceE& occurence);
00614 
00621   static void compoundToSimpleOccurence(int& multiplier,occurenceE& occurence);
00622 
00630   static MyMoneySchedule::occurenceE stringToOccurence(const QString& text);
00631 
00632 private:
00641   void fixDate(QDate& date) const;
00642 
00653   void setTransaction(const MyMoneyTransaction& transaction, bool noDateCheck);
00654 
00677   QDate addHalfMonths( QDate date, int mult = 1 ) const;
00678 
00679 private:
00681   occurenceE m_occurence;
00682 
00684   int m_occurenceMultiplier;
00685 
00687   typeE m_type;
00688 
00690   QDate m_startDate;
00691 
00693   paymentTypeE m_paymentType;
00694 
00696   bool m_fixed;
00697 
00699   MyMoneyTransaction m_transaction;
00700 
00702   QDate m_endDate;
00703 
00705   bool m_autoEnter;
00706 
00708   QDate m_lastPayment;
00709 
00711   QString m_name;
00712 
00714   QValueList<QDate> m_recordedPayments;
00715 
00717   weekendOptionE m_weekendOption;
00718 };
00719 #endif

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