#include <mymoneyscheduled.h>
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 MyMoneyTransaction & | transaction (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 |
This enum is used to describe all the possible schedule frequencies. The special entry, OCCUR_ANY, is used to combine all the other types.
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
occurenceE MyMoneySchedule::occurence | ( | void | ) | const |
Simple get method that returns the occurence frequency.
occurenceE MyMoneySchedule::occurencePeriod | ( | void | ) | const [inline] |
Simple get method that returns the occurence period multiplier and occurence
int MyMoneySchedule::occurenceMultiplier | ( | void | ) | const [inline] |
Simple get method that returns the occurence period multiplier.
typeE MyMoneySchedule::type | ( | void | ) | const [inline] |
Simple get method that returns the schedule 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.
paymentTypeE MyMoneySchedule::paymentType | ( | void | ) | const [inline] |
Simple get method that returns the schedule paymentType.
bool MyMoneySchedule::isFixed | ( | void | ) | const [inline] |
Simple get method that returns true if the schedule is fixed.
bool MyMoneySchedule::willEnd | ( | void | ) | const [inline] |
Simple get method that returns true if the schedule will end at some time.
int MyMoneySchedule::transactionsRemaining | ( | void | ) | const |
Simple get method that returns the number of transactions remaining.
int MyMoneySchedule::transactionsRemainingUntil | ( | const QDate & | endDate | ) | const |
Simple method that returns the number of transactions remaining until a given date.
endDate | Date to count transactions to. |
const QDate& MyMoneySchedule::endDate | ( | void | ) | const [inline] |
Simple get method that returns the schedule end date.
bool MyMoneySchedule::autoEnter | ( | void | ) | const [inline] |
Simple get method that returns true if the transaction should be automatically entered into the register.
const MyMoneyTransaction& MyMoneySchedule::transaction | ( | void | ) | const [inline] |
Simple get method that returns the transaction data for the schedule.
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.
const QDate& MyMoneySchedule::nextDueDate | ( | void | ) | const |
Simple method that returns the next due date for the schedule.
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.
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.
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.
occ | The new occurence (frequency). |
void MyMoneySchedule::setOccurencePeriod | ( | occurenceE | occ | ) |
Simple method that sets the schedule period
occ | The new occurence period (frequency) |
void MyMoneySchedule::setOccurenceMultiplier | ( | int | occmultiplier | ) |
Simple method that sets the frequency multiplier for the schedule.
occmultiplier | The new occurence (frequency) multiplier. |
void MyMoneySchedule::setType | ( | typeE | type | ) |
Simple method that sets the type for the schedule.
type | The new type. |
void MyMoneySchedule::setStartDate | ( | const QDate & | date | ) |
Simple method that sets the start date for the schedule.
date | The new start date. |
void MyMoneySchedule::setPaymentType | ( | paymentTypeE | type | ) |
Simple method that sets the payment type for the schedule.
type | The new payment type. |
void MyMoneySchedule::setFixed | ( | bool | fixed | ) |
Simple method to set whether the schedule is fixed or not.
fixed | boolean to indicate whether the instance is fixed. |
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.
transaction | The new transaction. |
void MyMoneySchedule::setEndDate | ( | const QDate & | date | ) |
Simple set method to set the end date for the schedule.
date | The new end date. |
void MyMoneySchedule::setAutoEnter | ( | bool | autoenter | ) |
Simple set method to set whether this transaction should be automatically entered into the journal whenever it is due.
autoenter | boolean to indicate whether we need to automatically enter the transaction. |
void MyMoneySchedule::setNextDueDate | ( | const QDate & | date | ) |
Simple set method to set the schedule's next payment date.
date | The next payment date. |
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.
date | The last payment date. |
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:
If an invalid option is given, the option is set to MoveNothing.
option | See list in description |
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.
id_check | if true , the method will check for an empty id. if false , this check is skipped. Default is true . |
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.
refDate | The reference date from which the next payment date will be calculated (defaults to current date) |
QDate MyMoneySchedule::nextPayment | ( | const QDate & | refDate = QDate::currentDate() |
) | const |
Calculates the date of the next payment.
refDate | The reference date from which the next payment date will be calculated (defaults to current date) |
QDate MyMoneySchedule::nextPaymentDate | ( | const bool & | adjust, | |
const QDate & | refDate = QDate::currentDate() | |||
) | const |
Calculates the date of the next payment and adjusts if asked.
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) |
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.
startDate | The start date for the range calculations | |
endDate | The end date for the range calculations. |
const QString& MyMoneySchedule::name | ( | void | ) | const [inline] |
Returns the instances name
void MyMoneySchedule::setName | ( | const QString & | nm | ) |
Changes the instance name
nm | The new name |
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
.
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
.
id | id of the object to be checked for references |
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
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.
type | numerical representation of the MyMoneySchedule occurence type |
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
mult | occurence multiplier | |
type | occurence period |
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.
type | numerical representation of the MyMoneySchedule occurence type |
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.
paymentType | numerical representation of the MyMoneySchedule payment type |
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.
weekendOption | numerical representation of the MyMoneySchedule weekend option |
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.
type | numerical representation of the MyMoneySchedule schedule type |
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.
occurence | The occurence |
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.
occurence | The occurence |
static void MyMoneySchedule::simpleToCompoundOccurence | ( | int & | multiplier, | |
occurenceE & | occurence | |||
) | [static] |
Helper method to convert simple occurence to compound occurence + multiplier
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
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.
text | reference to QString representing the human readable format |
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.
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
transaction | The new transaction. | |
noDateCheck | if true, the date check is bypassed |
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:
date | The date | |
mult | The number of half months to add. Default is 1. |
friend class MyMoneyStorageANON [friend] |
occurenceE MyMoneySchedule::m_occurence [private] |
int MyMoneySchedule::m_occurenceMultiplier [private] |
typeE MyMoneySchedule::m_type [private] |
QDate MyMoneySchedule::m_startDate [private] |
paymentTypeE MyMoneySchedule::m_paymentType [private] |
bool MyMoneySchedule::m_fixed [private] |
QDate MyMoneySchedule::m_endDate [private] |
bool MyMoneySchedule::m_autoEnter [private] |
QDate MyMoneySchedule::m_lastPayment [private] |
QString MyMoneySchedule::m_name [private] |
QValueList<QDate> MyMoneySchedule::m_recordedPayments [private] |