MyMoneySchedule Class Reference

A class to represent a schedule. More...

#include <mymoneyscheduled.h>

Inheritance diagram for MyMoneySchedule:

MyMoneyObject
Collaboration diagram for MyMoneySchedule:

Collaboration graph
[legend]

List of all members.

Public Types

enum  occurenceE {
  OCCUR_ANY = 0, OCCUR_ONCE = 1, OCCUR_DAILY = 2, OCCUR_WEEKLY = 4,
  OCCUR_FORTNIGHTLY = 8, OCCUR_EVERYOTHERWEEK = 16, OCCUR_EVERYHALFMONTH = 18, OCCUR_EVERYTHREEWEEKS = 20,
  OCCUR_EVERYTHIRTYDAYS = 30, OCCUR_MONTHLY = 32, OCCUR_EVERYFOURWEEKS = 64, OCCUR_EVERYEIGHTWEEKS = 126,
  OCCUR_EVERYOTHERMONTH = 128, OCCUR_EVERYTHREEMONTHS = 256, OCCUR_TWICEYEARLY = 1024, OCCUR_EVERYOTHERYEAR = 2048,
  OCCUR_QUARTERLY = 4096, OCCUR_EVERYFOURMONTHS = 8192, OCCUR_YEARLY = 16384
}
enum  typeE {
  TYPE_ANY = 0, TYPE_BILL = 1, TYPE_DEPOSIT = 2, TYPE_TRANSFER = 4,
  TYPE_LOANPAYMENT = 5
}
enum  paymentTypeE {
  STYPE_ANY = 0, STYPE_DIRECTDEBIT = 1, STYPE_DIRECTDEPOSIT = 2, STYPE_MANUALDEPOSIT = 4,
  STYPE_OTHER = 8, STYPE_WRITECHEQUE = 16, STYPE_STANDINGORDER = 32, STYPE_BANKTRANSFER = 64
}
enum  weekendOptionE { MoveFriday = 0, MoveMonday = 1, MoveNothing = 2 }

Public Member Functions

 MyMoneySchedule ()
 MyMoneySchedule (const QString &name, typeE type, occurenceE occurence, int occurenceMultiplier, paymentTypeE paymentType, const QDate &startDate, const QDate &endDate, bool fixed, bool autoEnter)
 MyMoneySchedule (const QDomElement &node)
 MyMoneySchedule (const QString &id, const MyMoneySchedule &right)
 ~MyMoneySchedule ()
occurenceE occurence (void) const
occurenceE occurencePeriod (void) const
int occurenceMultiplier (void) const
typeE type (void) const
const QDate & startDate (void) const
paymentTypeE paymentType (void) const
bool isFixed (void) const
bool willEnd (void) const
int transactionsRemaining (void) const
int transactionsRemainingUntil (const QDate &endDate) const
const QDate & endDate (void) const
bool autoEnter (void) const
const MyMoneyTransactiontransaction (void) const
const QDate & lastPayment (void) const
const QDate & nextDueDate (void) const
QDate adjustedNextDueDate (void) const
QDate adjustedDate (QDate date, weekendOptionE option) const
weekendOptionE weekendOption (void) const
void setOccurence (occurenceE occ)
void setOccurencePeriod (occurenceE occ)
void setOccurenceMultiplier (int occmultiplier)
void setType (typeE type)
void setStartDate (const QDate &date)
void setPaymentType (paymentTypeE type)
void setFixed (bool fixed)
void setTransaction (const MyMoneyTransaction &transaction)
void setEndDate (const QDate &date)
void setAutoEnter (bool autoenter)
void setNextDueDate (const QDate &date)
void setLastPayment (const QDate &date)
void setWeekendOption (const weekendOptionE option)
void validate (bool id_check=true) const
QDate adjustedNextPayment (const QDate &refDate=QDate::currentDate()) const
QDate nextPayment (const QDate &refDate=QDate::currentDate()) const
QDate nextPaymentDate (const bool &adjust, const QDate &refDate=QDate::currentDate()) const
QValueList< QDate > paymentDates (const QDate &startDate, const QDate &endDate) const
const QString & name (void) const
void setName (const QString &nm)
bool operator== (const MyMoneySchedule &right) const
bool operator!= (const MyMoneySchedule &right) const
bool operator< (const MyMoneySchedule &right) const
MyMoneyAccount account (int cnt=1) const
MyMoneyAccount transferAccount (void) const
QDate dateAfter (int transactions) const
bool isOverdue () const
bool isFinished () const
bool hasRecordedPayment (const QDate &) const
void recordPayment (const QDate &)
QValueList< QDate > recordedPayments (void) const
void writeXML (QDomDocument &document, QDomElement &parent) const
virtual bool hasReferenceTo (const QString &id) const
QString occurenceToString () const
int variation (void) const
void setVariation (int var)

Static Public Member Functions

static QString occurenceToString (occurenceE type)
static QString occurenceToString (int mult, occurenceE type)
static QString occurencePeriodToString (occurenceE type)
static QString paymentMethodToString (MyMoneySchedule::paymentTypeE paymentType)
static QString weekendOptionToString (MyMoneySchedule::weekendOptionE weekendOption)
static QString scheduleTypeToString (MyMoneySchedule::typeE type)
static int eventsPerYear (MyMoneySchedule::occurenceE occurence)
static int daysBetweenEvents (MyMoneySchedule::occurenceE occurence)
static void simpleToCompoundOccurence (int &multiplier, occurenceE &occurence)
static void compoundToSimpleOccurence (int &multiplier, occurenceE &occurence)
static MyMoneySchedule::occurenceE stringToOccurence (const QString &text)

Private Member Functions

void fixDate (QDate &date) const
void setTransaction (const MyMoneyTransaction &transaction, bool noDateCheck)
QDate addHalfMonths (QDate date, int mult=1) const

Private Attributes

occurenceE m_occurence
 Its occurence.
int m_occurenceMultiplier
 Its occurence multiplier.
typeE m_type
 Its type.
QDate m_startDate
 The date the schedule commences.
paymentTypeE m_paymentType
 The payment type.
bool m_fixed
 Can the amount vary.
MyMoneyTransaction m_transaction
 The, possibly estimated, amount plus all other relevant details.
QDate m_endDate
 The last transaction date if the schedule does end at a fixed date.
bool m_autoEnter
 Enter the transaction into the register automatically.
QDate m_lastPayment
 Internal date used for calculations.
QString m_name
 The name.
QValueList< QDate > m_recordedPayments
 The recorded payments.
weekendOptionE m_weekendOption
 The weekend option.

Friends

class MyMoneyStorageANON


Detailed Description

Author:
Michael Edwardes This class represents a schedule. (A series of bills, deposits or transfers).
See also:
MyMoneyScheduled

Member Enumeration Documentation

This enum is used to describe all the possible schedule frequencies. The special entry, OCCUR_ANY, is used to combine all the other types.

Enumerator:
OCCUR_ANY 
OCCUR_ONCE 
OCCUR_DAILY 
OCCUR_WEEKLY 
OCCUR_FORTNIGHTLY 
OCCUR_EVERYOTHERWEEK 
OCCUR_EVERYHALFMONTH 
OCCUR_EVERYTHREEWEEKS 
OCCUR_EVERYTHIRTYDAYS 
OCCUR_MONTHLY 
OCCUR_EVERYFOURWEEKS 
OCCUR_EVERYEIGHTWEEKS 
OCCUR_EVERYOTHERMONTH 
OCCUR_EVERYTHREEMONTHS 
OCCUR_TWICEYEARLY 
OCCUR_EVERYOTHERYEAR 
OCCUR_QUARTERLY 
OCCUR_EVERYFOURMONTHS 
OCCUR_YEARLY 

This enum is used to describe the schedule type.

Enumerator:
TYPE_ANY 
TYPE_BILL 
TYPE_DEPOSIT 
TYPE_TRANSFER 
TYPE_LOANPAYMENT 

This enum is used to describe the schedule's payment type.

Enumerator:
STYPE_ANY 
STYPE_DIRECTDEBIT 
STYPE_DIRECTDEPOSIT 
STYPE_MANUALDEPOSIT 
STYPE_OTHER 
STYPE_WRITECHEQUE 
STYPE_STANDINGORDER 
STYPE_BANKTRANSFER 

This enum is used by the auto-commit functionality.

Depending upon the value of m_weekendOption the schedule can be entered on a different date

Enumerator:
MoveFriday 
MoveMonday 
MoveNothing 


Constructor & Destructor Documentation

MyMoneySchedule::MyMoneySchedule (  ) 

Standard constructor

MyMoneySchedule::MyMoneySchedule ( const QString &  name,
typeE  type,
occurenceE  occurence,
int  occurenceMultiplier,
paymentTypeE  paymentType,
const QDate &  startDate,
const QDate &  endDate,
bool  fixed,
bool  autoEnter 
)

Constructor for initialising the object.

Please note that the optional fields are not set and the transaction MUST be set before it can be used.

startDate is not used anymore and internally set to QDate()

MyMoneySchedule::MyMoneySchedule ( const QDomElement &  node  ) 

MyMoneySchedule::MyMoneySchedule ( const QString &  id,
const MyMoneySchedule right 
)

MyMoneySchedule::~MyMoneySchedule (  )  [inline]

Standard destructor


Member Function Documentation

occurenceE MyMoneySchedule::occurence ( void   )  const

Simple get method that returns the occurence frequency.

Returns:
occurenceE The instance frequency.

occurenceE MyMoneySchedule::occurencePeriod ( void   )  const [inline]

Simple get method that returns the occurence period multiplier and occurence

Returns:
occurenceE The instance period

int MyMoneySchedule::occurenceMultiplier ( void   )  const [inline]

Simple get method that returns the occurence period multiplier.

Returns:
int The frequency multiplier

typeE MyMoneySchedule::type ( void   )  const [inline]

Simple get method that returns the schedule type.

Returns:
typeE The instance type.

const QDate& MyMoneySchedule::startDate ( void   )  const

Simple get method that returns the schedule startDate. If the schedule has been executed once, the date of the first execution is returned. Otherwise, the next due date is returned.

Returns:
reference to QDate containing the start date.

paymentTypeE MyMoneySchedule::paymentType ( void   )  const [inline]

Simple get method that returns the schedule paymentType.

Returns:
paymentTypeE The instance paymentType.

bool MyMoneySchedule::isFixed ( void   )  const [inline]

Simple get method that returns true if the schedule is fixed.

Returns:
bool To indicate whether the instance is fixed.

bool MyMoneySchedule::willEnd ( void   )  const [inline]

Simple get method that returns true if the schedule will end at some time.

Returns:
bool Indicates whether the instance will end.

int MyMoneySchedule::transactionsRemaining ( void   )  const

Simple get method that returns the number of transactions remaining.

Returns:
int The number of transactions remaining for the instance.

int MyMoneySchedule::transactionsRemainingUntil ( const QDate &  endDate  )  const

Simple method that returns the number of transactions remaining until a given date.

Parameters:
endDate Date to count transactions to.
Returns:
int The number of transactions remaining for the instance.

const QDate& MyMoneySchedule::endDate ( void   )  const [inline]

Simple get method that returns the schedule end date.

Returns:
QDate The end date for the instance.

bool MyMoneySchedule::autoEnter ( void   )  const [inline]

Simple get method that returns true if the transaction should be automatically entered into the register.

Returns:
bool Indicates whether the instance will be automatically entered.

const MyMoneyTransaction& MyMoneySchedule::transaction ( void   )  const [inline]

Simple get method that returns the transaction data for the schedule.

Returns:
MyMoneyTransaction The transaction data for the instance.

const QDate& MyMoneySchedule::lastPayment ( void   )  const [inline]

Simple method that returns the schedules last payment. If the schedule has never been executed, QDate() will be returned.

Returns:
QDate The last payment for the schedule.

const QDate& MyMoneySchedule::nextDueDate ( void   )  const

Simple method that returns the next due date for the schedule.

Returns:
reference to QDate containing the next due date.
Note:
The date returned can represent a value that is past a possible end of the schedule. Make sure to consider the return value of isFinished() when using the value returned.

QDate MyMoneySchedule::adjustedNextDueDate ( void   )  const

This method adjusts returns the next due date adjusted according to the rules specified by the schedule's weekend option.

Returns:
QDate containing the adjusted next due date. If the schedule is finished (
See also:
isFinished()) then the method returns an invalid QDate.

weekendOption()

adjustedDate()

QDate MyMoneySchedule::adjustedDate ( QDate  date,
weekendOptionE  option 
) const

This method adjusts returns the date adjusted according to the rules specified by the schedule's weekend option.

Returns:
QDate containing the adjusted date.

weekendOptionE MyMoneySchedule::weekendOption ( void   )  const [inline]

Get the weekendOption that determines how the schedule check code will enter transactions that occur on a weekend.

This not used by MyMoneySchedule but by the support code.

void MyMoneySchedule::setOccurence ( occurenceE  occ  ) 

Simple method that sets the frequency for the schedule.

Parameters:
occ The new occurence (frequency).
Returns:
none

void MyMoneySchedule::setOccurencePeriod ( occurenceE  occ  ) 

Simple method that sets the schedule period

Parameters:
occ The new occurence period (frequency)
Returns:
none

void MyMoneySchedule::setOccurenceMultiplier ( int  occmultiplier  ) 

Simple method that sets the frequency multiplier for the schedule.

Parameters:
occmultiplier The new occurence (frequency) multiplier.
Returns:
none

void MyMoneySchedule::setType ( typeE  type  ) 

Simple method that sets the type for the schedule.

Parameters:
type The new type.
Returns:
none

void MyMoneySchedule::setStartDate ( const QDate &  date  ) 

Simple method that sets the start date for the schedule.

Parameters:
date The new start date.
Returns:
none

void MyMoneySchedule::setPaymentType ( paymentTypeE  type  ) 

Simple method that sets the payment type for the schedule.

Parameters:
type The new payment type.
Returns:
none

void MyMoneySchedule::setFixed ( bool  fixed  ) 

Simple method to set whether the schedule is fixed or not.

Parameters:
fixed boolean to indicate whether the instance is fixed.
Returns:
none

void MyMoneySchedule::setTransaction ( const MyMoneyTransaction transaction  ) 

Simple method that sets the transaction for the schedule. The transaction must have a valid postDate set, otherwise it will not be accepted.

Parameters:
transaction The new transaction.
Returns:
none

void MyMoneySchedule::setEndDate ( const QDate &  date  ) 

Simple set method to set the end date for the schedule.

Parameters:
date The new end date.
Returns:
none

void MyMoneySchedule::setAutoEnter ( bool  autoenter  ) 

Simple set method to set whether this transaction should be automatically entered into the journal whenever it is due.

Parameters:
autoenter boolean to indicate whether we need to automatically enter the transaction.
Returns:
none

void MyMoneySchedule::setNextDueDate ( const QDate &  date  ) 

Simple set method to set the schedule's next payment date.

Parameters:
date The next payment date.
Returns:
none

void MyMoneySchedule::setLastPayment ( const QDate &  date  ) 

Simple set method to set the schedule's last payment. If this method is called for the first time on the object, the m_startDate member will be set to date as well.

This method should be called whenever a schedule is entered or skipped.

Parameters:
date The last payment date.
Returns:
none

void MyMoneySchedule::setWeekendOption ( const weekendOptionE  option  ) 

Set the weekendOption that determines how the schedule check code will enter transactions that occur on a weekend. The following values are valid:

  • MoveNothing: don't modify date
  • MoveFriday: modify the date to the previous friday
  • MoveMonday: modify the date to the following monday

If an invalid option is given, the option is set to MoveNothing.

Parameters:
option See list in description
Returns:
none
Note:
This not used by MyMoneySchedule but by the support code.

void MyMoneySchedule::validate ( bool  id_check = true  )  const

Validates the schedule instance.

Makes sure the paymentType matches the type and that the required fields have been set.

Parameters:
id_check if true, the method will check for an empty id. if false, this check is skipped. Default is true.
Returns:
If this method returns, all checks are passed. Otherwise, it will throw a MyMoneyException object.
Exceptions:
MyMoneyException with detailed error information is thrown in case of failure of any check.

QDate MyMoneySchedule::adjustedNextPayment ( const QDate &  refDate = QDate::currentDate()  )  const

Calculates the date of the next payment adjusted according to the rules specified by the schedule's weekend option.

Parameters:
refDate The reference date from which the next payment date will be calculated (defaults to current date)
Returns:
QDate The adjusted date the next payment is due. This date is always past refDate. In case of an error or if there are no more payments then an empty/invalid QDate() will be returned.

QDate MyMoneySchedule::nextPayment ( const QDate &  refDate = QDate::currentDate()  )  const

Calculates the date of the next payment.

Parameters:
refDate The reference date from which the next payment date will be calculated (defaults to current date)
Returns:
QDate The date the next payment is due. This date is always past refDate. In case of an error or if there is no more payments then an empty/invalid QDate() will be returned.

QDate MyMoneySchedule::nextPaymentDate ( const bool &  adjust,
const QDate &  refDate = QDate::currentDate() 
) const

Calculates the date of the next payment and adjusts if asked.

Parameters:
adjust Whether to adjust the calculated date according to the rules specified by the schedule's weekend option.
refDate The reference date from which the next payment date will be calculated (defaults to current date)
Returns:
QDate The date the next payment is due. This date is always past refDate. In case of an error or if there is no more payments then an empty/invalid QDate() will be returned.

QValueList<QDate> MyMoneySchedule::paymentDates ( const QDate &  startDate,
const QDate &  endDate 
) const

Calculates the dates of the payment over a certain period of time.

An empty list is returned for no payments or error.

Parameters:
startDate The start date for the range calculations
endDate The end date for the range calculations.
Returns:
QValueList<QDate> The dates on which the payments are due.

const QString& MyMoneySchedule::name ( void   )  const [inline]

Returns the instances name

Returns:
The name

void MyMoneySchedule::setName ( const QString &  nm  ) 

Changes the instance name

Parameters:
nm The new name
Returns:
none

bool MyMoneySchedule::operator== ( const MyMoneySchedule right  )  const

bool MyMoneySchedule::operator!= ( const MyMoneySchedule right  )  const [inline]

bool MyMoneySchedule::operator< ( const MyMoneySchedule right  )  const

MyMoneyAccount MyMoneySchedule::account ( int  cnt = 1  )  const

MyMoneyAccount MyMoneySchedule::transferAccount ( void   )  const [inline]

QDate MyMoneySchedule::dateAfter ( int  transactions  )  const

bool MyMoneySchedule::isOverdue (  )  const

bool MyMoneySchedule::isFinished (  )  const

bool MyMoneySchedule::hasRecordedPayment ( const QDate &   )  const

void MyMoneySchedule::recordPayment ( const QDate &   ) 

QValueList<QDate> MyMoneySchedule::recordedPayments ( void   )  const [inline]

void MyMoneySchedule::writeXML ( QDomDocument &  document,
QDomElement &  parent 
) const [virtual]

This method creates a QDomElement for the document under the parent node parent.

Parameters:
document reference to QDomDocument
parent reference to QDomElement parent node

Implements MyMoneyObject.

virtual bool MyMoneySchedule::hasReferenceTo ( const QString &  id  )  const [virtual]

This method checks if a reference to the given object exists. It returns, a true if the object is referencing the one requested by the parameter id. If it does not, this method returns false.

Parameters:
id id of the object to be checked for references
Return values:
true This object references object with id id.
false This object does not reference the object with id id.

Implements MyMoneyObject.

QString MyMoneySchedule::occurenceToString (  )  const

Returns the human-readable format of Schedule's occurence

Returns:
QString representing the human readable format

static QString MyMoneySchedule::occurenceToString ( occurenceE  type  )  [static]

This method is used to convert the occurence type from it's internal representation into a human readable format.

Parameters:
type numerical representation of the MyMoneySchedule occurence type
Returns:
QString representing the human readable format

static QString MyMoneySchedule::occurenceToString ( int  mult,
occurenceE  type 
) [static]

This method is used to convert a multiplier and base occurence type from it's internal representation into a human readable format. When multiplier * occurence is equivalent to a simple occurence the method returns the same as occurenceToString of the simple occurence

Parameters:
mult occurence multiplier
type occurence period
Returns:
QString representing the human readable format

static QString MyMoneySchedule::occurencePeriodToString ( occurenceE  type  )  [static]

This method is used to convert an occurence period from it's internal representation into a human-readable format.

Parameters:
type numerical representation of the MyMoneySchedule occurence type
Returns:
QString representing the human readable format

static QString MyMoneySchedule::paymentMethodToString ( MyMoneySchedule::paymentTypeE  paymentType  )  [static]

This method is used to convert the payment type from it's internal representation into a human readable format.

Parameters:
paymentType numerical representation of the MyMoneySchedule payment type
Returns:
QString representing the human readable format

static QString MyMoneySchedule::weekendOptionToString ( MyMoneySchedule::weekendOptionE  weekendOption  )  [static]

This method is used to convert the schedule weekend option from it's internal representation into a human readable format.

Parameters:
weekendOption numerical representation of the MyMoneySchedule weekend option
Returns:
QString representing the human readable format

static QString MyMoneySchedule::scheduleTypeToString ( MyMoneySchedule::typeE  type  )  [static]

This method is used to convert the schedule type from it's internal representation into a human readable format.

Parameters:
type numerical representation of the MyMoneySchedule schedule type
Returns:
QString representing the human readable format

int MyMoneySchedule::variation ( void   )  const

void MyMoneySchedule::setVariation ( int  var  ) 

static int MyMoneySchedule::eventsPerYear ( MyMoneySchedule::occurenceE  occurence  )  [static]

Convert an occurence to the maximum number of events possible during a single calendar year. A fortnight is treated as 15 days.

Parameters:
occurence The occurence
Returns:
int Number of days between events

static int MyMoneySchedule::daysBetweenEvents ( MyMoneySchedule::occurenceE  occurence  )  [static]

Convert an occurence to the number of days between events Treats a month as 30 days. Treats a fortnight as 15 days.

Parameters:
occurence The occurence
Returns:
int Number of days between events

static void MyMoneySchedule::simpleToCompoundOccurence ( int &  multiplier,
occurenceE occurence 
) [static]

Helper method to convert simple occurence to compound occurence + multiplier

Parameters:
multiplier Returned by reference. Adjusted multiplier
occurence Returned by reference. Occurence type

static void MyMoneySchedule::compoundToSimpleOccurence ( int &  multiplier,
occurenceE occurence 
) [static]

Helper method to convert compound occurence + multiplier to simple occurence

Parameters:
multiplier Returned by reference. Adjusted multiplier
occurence Returned by reference. Occurence type

static MyMoneySchedule::occurenceE MyMoneySchedule::stringToOccurence ( const QString &  text  )  [static]

This method is used to convert the occurence type from the human readable form into it's internal representation.

Parameters:
text reference to QString representing the human readable format
Returns:
numerical representation of the occurence

void MyMoneySchedule::fixDate ( QDate &  date  )  const [private]

This method forces the day of the passed date to be the day of the start date of this schedule kept in m_startDate. It is internally used when calculating the payment dates over several periods.

Parameters:
date reference to QDate object to be checked and adjusted

void MyMoneySchedule::setTransaction ( const MyMoneyTransaction transaction,
bool  noDateCheck 
) [private]

Simple method that sets the transaction for the schedule. The transaction must have a valid postDate set, otherwise it will not be accepted. This test is bypassed, if noDateCheck is set to true

Parameters:
transaction The new transaction.
noDateCheck if true, the date check is bypassed
Returns:
none

QDate MyMoneySchedule::addHalfMonths ( QDate  date,
int  mult = 1 
) const [private]

This method adds a number of Half Months to the given Date. This is used for OCCUR_EVERYHALFMONTH occurences. The addition uses the following rules to add a half month: Day 1-13: add 15 days Day 14: add 15 days (except February: the last day of the month) Day 15: last day of the month Day 16-29 (not last day in February): subtract 15 days and add 1 month 30 and last day: 15th of next month

This calculation pairs days 1 to 12 with 16 to 27. Day 15 is paired with the last day of every month. Repeated addition has issues in the following cases:

  • Days 13 to 14 are paired with 28 to 29 until addition hits the last day of February after which the (15,last) pair will be used.
  • Addition from Day 30 leads immediately to the (15th,last) day pair.

Parameters:
date The date
mult The number of half months to add. Default is 1.
Returns:
QDate date with mult half months added


Friends And Related Function Documentation

friend class MyMoneyStorageANON [friend]


Member Data Documentation

bool MyMoneySchedule::m_fixed [private]

QDate MyMoneySchedule::m_endDate [private]

QString MyMoneySchedule::m_name [private]


The documentation for this class was generated from the following file:

Generated on Wed Jan 26 13:09:23 2011 for KMyMoney by  doxygen 1.5.6