MyMoneyTransactionFilter Class Reference

#include <mymoneytransactionfilter.h>

Inheritance diagram for MyMoneyTransactionFilter:

MyMoneyReport
Collaboration diagram for MyMoneyTransactionFilter:

Collaboration graph
[legend]

List of all members.

Public Types

enum  typeOptionE {
  allTypes = 0, payments, deposits, transfers,
  typeOptionCount
}
enum  stateOptionE {
  allStates = 0, notReconciled, cleared, reconciled,
  frozen, stateOptionCount
}
enum  validityOptionE { anyValidity = 0, valid, invalid, validityOptionCount }
enum  dateOptionE {
  allDates = 0, asOfToday, currentMonth, currentYear,
  monthToDate, yearToDate, yearToMonth, lastMonth,
  lastYear, last7Days, last30Days, last3Months,
  last6Months, last12Months, next7Days, next30Days,
  next3Months, next6Months, next12Months, userDefined,
  last3ToNext3Months, last11Months, currentQuarter, lastQuarter,
  nextQuarter, currentFiscalYear, lastFiscalYear, today,
  dateOptionCount
}

Public Member Functions

 MyMoneyTransactionFilter ()
 MyMoneyTransactionFilter (const QString &id)
 ~MyMoneyTransactionFilter ()
void clear (void)
void clearAccountFilter (void)
void setTextFilter (const QRegExp &exp, bool invert=false)
void addAccount (const QString &id)
void addAccount (const QStringList &ids)
void addCategory (const QString &id)
void addCategory (const QStringList &ids)
void setDateFilter (const QDate &from, const QDate &to)
void setDateFilter (dateOptionE range)
void setAmountFilter (const MyMoneyMoney &from, const MyMoneyMoney &to)
void addPayee (const QString &id)
void addType (const int type)
void addValidity (const int type)
void addState (const int state)
void setNumberFilter (const QString &from, const QString &to)
bool match (const MyMoneyTransaction &transaction)
bool matchText (const MyMoneySplit *const sp) const
bool matchAmount (const MyMoneySplit *const sp) const
bool match (const MyMoneySplit *const sp) const
void setReportAllSplits (const bool report=true)
void setConsiderCategory (const bool check=true)
const QValueList< MyMoneySplit > & matchingSplits (void) const
const QDate fromDate (void) const
const QDate toDate (void) const
bool includesCategory (const QString &cat) const
bool includesAccount (const QString &acc) const
bool includesPayee (const QString &pye) const
bool dateFilter (QDate &from, QDate &to) const
bool amountFilter (MyMoneyMoney &from, MyMoneyMoney &to) const
bool numberFilter (QString &from, QString &to) const
bool payees (QStringList &list) const
bool accounts (QStringList &list) const
bool categories (QStringList &list) const
bool firstType (int &i) const
bool types (QValueList< int > &list) const
bool firstState (int &i) const
bool states (QValueList< int > &list) const
bool textFilter (QRegExp &text) const
bool isInvertingText (void) const
FilterSet filterSet (void) const
void removeReference (const QString &id)

Static Public Member Functions

static bool translateDateRange (dateOptionE range, QDate &start, QDate &end)
static void setFiscalYearStart (int firstMonth, int firstDay)

Protected Attributes

FilterSet m_filterSet
bool m_reportAllSplits
bool m_considerCategory
QRegExp m_text
bool m_invertText
QAsciiDict< char > m_accounts
QAsciiDict< char > m_payees
QAsciiDict< char > m_categories
QIntDict< char > m_states
QIntDict< char > m_types
QIntDict< char > m_validity
QString m_fromNr
QString m_toNr
QDate m_fromDate
QDate m_toDate
MyMoneyMoney m_fromAmount
MyMoneyMoney m_toAmount
QValueList< MyMoneySplitm_matchingSplits

Private Member Functions

int splitState (const MyMoneySplit &split) const
int splitType (const MyMoneyTransaction &t, const MyMoneySplit &split) const
validityOptionE validTransaction (const MyMoneyTransaction &transaction) const

Classes

union  FilterSet


Detailed Description

Author:
Thomas Baumgart

Member Enumeration Documentation

Enumerator:
allTypes 
payments 
deposits 
transfers 
typeOptionCount 

Enumerator:
allStates 
notReconciled 
cleared 
reconciled 
frozen 
stateOptionCount 

Enumerator:
anyValidity 
valid 
invalid 
validityOptionCount 

Enumerator:
allDates 
asOfToday 
currentMonth 
currentYear 
monthToDate 
yearToDate 
yearToMonth 
lastMonth 
lastYear 
last7Days 
last30Days 
last3Months 
last6Months 
last12Months 
next7Days 
next30Days 
next3Months 
next6Months 
next12Months 
userDefined 
last3ToNext3Months 
last11Months 
currentQuarter 
lastQuarter 
nextQuarter 
currentFiscalYear 
lastFiscalYear 
today 
dateOptionCount 


Constructor & Destructor Documentation

MyMoneyTransactionFilter::MyMoneyTransactionFilter (  ) 

This is the standard constructor for a transaction filter. It creates the object and calls setReportAllSplits() to report all matching splits as separate entries. Use setReportAllSplits() to override this behaviour.

MyMoneyTransactionFilter::MyMoneyTransactionFilter ( const QString &  id  ) 

This is a convenience constructor to allow construction of a simple account filter. It is basically the same as the following:

 :
   MyMoneyTransactionFilter filter;
   filter.setReportAllSplits(false);
   filter.addAccount(id);
 :

Parameters:
id reference to account id

MyMoneyTransactionFilter::~MyMoneyTransactionFilter (  ) 


Member Function Documentation

void MyMoneyTransactionFilter::clear ( void   ) 

This method is used to clear the filter. All settings will be removed.

Reimplemented in MyMoneyReport.

void MyMoneyTransactionFilter::clearAccountFilter ( void   ) 

This method is used to clear the accounts filter only.

void MyMoneyTransactionFilter::setTextFilter ( const QRegExp &  exp,
bool  invert = false 
)

This method is used to set the regular expression filter to the value specified as parameter exp. The following text based fields are searched:

  • Memo
  • Payee
  • Category
  • Shares / Value
  • Number

Parameters:
exp The regular expression that must be found in a transaction before it is included in the result set.
invert If true, value must not be contained in any of the above mentioned fields

void MyMoneyTransactionFilter::addAccount ( const QString &  id  ) 

This method will add the account with id id to the list of matching accounts. If the list is empty, any transaction will match.

Parameters:
id internal ID of the account

void MyMoneyTransactionFilter::addAccount ( const QStringList &  ids  ) 

This is a convenience method and behaves exactly like the above method but for a list of id's.

void MyMoneyTransactionFilter::addCategory ( const QString &  id  ) 

This method will add the category with id id to the list of matching categories. If the list is empty, only transaction with a single asset/liability account will match.

Parameters:
id internal ID of the account

void MyMoneyTransactionFilter::addCategory ( const QStringList &  ids  ) 

This is a convenience method and behaves exactly like the above method but for a list of id's.

void MyMoneyTransactionFilter::setDateFilter ( const QDate &  from,
const QDate &  to 
)

This method sets the date filter to match only transactions with posting dates in the date range specified by from and to. If from equal QDate() all transactions with dates prior to to match. If to equals QDate() all transactions with posting dates past from match. If from and to are equal QDate() the filter is not activated and all transactions match.

Parameters:
from from date
to to date

Reimplemented in MyMoneyReport.

void MyMoneyTransactionFilter::setDateFilter ( dateOptionE  range  ) 

void MyMoneyTransactionFilter::setAmountFilter ( const MyMoneyMoney from,
const MyMoneyMoney to 
)

This method sets the amount filter to match only transactions with an amount in the range specified by from and to. If a specific amount should be searched, from and to should be the same value.

Parameters:
from smallest value to match
to largest value to match

void MyMoneyTransactionFilter::addPayee ( const QString &  id  ) 

This method will add the payee with id id to the list of matching payees. If the list is empty, any transaction will match.

Parameters:
id internal id of the payee

void MyMoneyTransactionFilter::addType ( const int  type  ) 

void MyMoneyTransactionFilter::addValidity ( const int  type  ) 

void MyMoneyTransactionFilter::addState ( const int  state  ) 

void MyMoneyTransactionFilter::setNumberFilter ( const QString &  from,
const QString &  to 
)

This method sets the number filter to match only transactions with a number in the range specified by from and to. If a specific number should be searched, from and to should be the same value.

Parameters:
from smallest value to match
to largest value to match
Note:
from and to can contain alphanumeric text

bool MyMoneyTransactionFilter::match ( const MyMoneyTransaction transaction  ) 

This method is used to check a specific transaction against the filter. The transaction will match the whole filter, if all specified filters match. If the filter is cleared using the clear() method, any transaciton matches.

Parameters:
transaction A transaction
Return values:
true The transaction matches the filter set
false The transaction does not match at least one of the filters in the filter set

bool MyMoneyTransactionFilter::matchText ( const MyMoneySplit *const   sp  )  const

This method is used to check a specific split against the text filter. The split will match if all specified and checked filters match. If the filter is cleared using the clear() method, any split matches.

Parameters:
sp pointer to the split to be checked
Return values:
true The split matches the filter set
false The split does not match at least one of the filters in the filter set

bool MyMoneyTransactionFilter::matchAmount ( const MyMoneySplit *const   sp  )  const

This method is used to check a specific split against the amount filter. The split will match if all specified and checked filters match. If the filter is cleared using the clear() method, any split matches.

Parameters:
sp pointer to the split to be checked
Return values:
true The split matches the filter set
false The split does not match at least one of the filters in the filter set

bool MyMoneyTransactionFilter::match ( const MyMoneySplit *const   sp  )  const

Convenience method which actually returns matchText(sp) && matchAmount(sp).

void MyMoneyTransactionFilter::setReportAllSplits ( const bool  report = true  ) 

This method is used to switch the amount of splits reported by matchingSplits(). If the argument report is true (the default if no argument specified) then matchingSplits() will return all matching splits of the transaction. If report is set to false, then only the very first matching split will be returned by matchingSplits().

Parameters:
report controls the behaviour of matchingsSplits() as explained above.

void MyMoneyTransactionFilter::setConsiderCategory ( const bool  check = true  ) 

const QValueList<MyMoneySplit>& MyMoneyTransactionFilter::matchingSplits ( void   )  const

This method returns a list of the matching splits for the filter. If m_reportAllSplits is set to false, then only the very first split will be returned. Use setReportAllSplits() to change the behaviour.

Returns:
reference list of MyMoneySplit objects containing the matching splits. If multiple splits match, only the first one will be returned.
Note:
an empty list will be returned, if the filter only required to check the data contained in the MyMoneyTransaction object (e.g. posting-date, state, etc.).

The constructors set m_reportAllSplits differently. Please see the documentation of the constructors MyMoneyTransactionFilter() and MyMoneyTransactionFilter(const QString&) for details.

const QDate MyMoneyTransactionFilter::fromDate ( void   )  const [inline]

This method returns the from date set in the filter. If no value has been set up for this filter, then QDate() is returned.

Returns:
returns m_fromDate

const QDate MyMoneyTransactionFilter::toDate ( void   )  const [inline]

This method returns the to date set in the filter. If no value has been set up for this filter, then QDate() is returned.

Returns:
returns m_toDate

bool MyMoneyTransactionFilter::includesCategory ( const QString &  cat  )  const

This method is used to return information about the presence of a specific category in the category filter. The category in question is included in the filter set, if it has been set or no category filter is set.

Parameters:
cat id of category in question
Returns:
true if category is in filter set, false otherwise

bool MyMoneyTransactionFilter::includesAccount ( const QString &  acc  )  const

This method is used to return information about the presence of a specific account in the account filter. The account in question is included in the filter set, if it has been set or no account filter is set.

Parameters:
acc id of account in question
Returns:
true if account is in filter set, false otherwise

bool MyMoneyTransactionFilter::includesPayee ( const QString &  pye  )  const

This method is used to return information about the presence of a specific payee in the account filter. The payee in question is included in the filter set, if it has been set or no account filter is set.

Parameters:
pye id of payee in question
Returns:
true if payee is in filter set, false otherwise

bool MyMoneyTransactionFilter::dateFilter ( QDate &  from,
QDate &  to 
) const

This method is used to return information about the presence of a date filter.

Parameters:
from result value for the beginning of the date range
to result value for the end of the date range
Returns:
true if an amount filter is set

bool MyMoneyTransactionFilter::amountFilter ( MyMoneyMoney from,
MyMoneyMoney to 
) const

This method is used to return information about the presence of an amount filter.

Parameters:
from result value for the low end of the amount range
to result value for the high end of the amount range
Returns:
true if an amount filter is set

bool MyMoneyTransactionFilter::numberFilter ( QString &  from,
QString &  to 
) const

This method is used to return information about the presence of an number filter.

Parameters:
from result value for the low end of the number range
to result value for the high end of the number range
Returns:
true if a number filter is set

bool MyMoneyTransactionFilter::payees ( QStringList &  list  )  const

This method returns whether a payee filter has been set, and if so, it returns all the payees set in the filter.

Parameters:
list list to append payees into
Returns:
return true if a payee filter has been set

bool MyMoneyTransactionFilter::accounts ( QStringList &  list  )  const

This method returns whether an account filter has been set, and if so, it returns all the accounts set in the filter.

Parameters:
list list to append accounts into
Returns:
return true if an account filter has been set

bool MyMoneyTransactionFilter::categories ( QStringList &  list  )  const

This method returns whether a category filter has been set, and if so, it returns all the categories set in the filter.

Parameters:
list list to append categories into
Returns:
return true if a category filter has been set

bool MyMoneyTransactionFilter::firstType ( int &  i  )  const

This method returns whether a type filter has been set, and if so, it returns the first type in the filter.

Parameters:
i int to replace with first type filter, untouched otherwise
Returns:
return true if a type filter has been set

bool MyMoneyTransactionFilter::types ( QValueList< int > &  list  )  const

bool MyMoneyTransactionFilter::firstState ( int &  i  )  const

This method returns whether a state filter has been set, and if so, it returns the first state in the filter.

Parameters:
i reference to int to replace with first state filter, untouched otherwise
Returns:
return true if a state filter has been set

bool MyMoneyTransactionFilter::states ( QValueList< int > &  list  )  const

bool MyMoneyTransactionFilter::textFilter ( QRegExp &  text  )  const

This method returns whether a text filter has been set, and if so, it returns the text filter.

Parameters:
text regexp to replace with text filter, or blank if none set
Returns:
return true if a text filter has been set

bool MyMoneyTransactionFilter::isInvertingText ( void   )  const [inline]

This method returns whether the text filter should return that DO NOT contain the text

static bool MyMoneyTransactionFilter::translateDateRange ( dateOptionE  range,
QDate &  start,
QDate &  end 
) [static]

This method translates a plain-language date range into QDate start & end

Parameters:
range Plain-language range of dates, e.g. 'CurrentYear'
start QDate will be set to corresponding to the first date in range
end QDate will be set to corresponding to the last date in range
Returns:
return true if a range was successfully set, or false if range was invalid

static void MyMoneyTransactionFilter::setFiscalYearStart ( int  firstMonth,
int  firstDay 
) [static]

FilterSet MyMoneyTransactionFilter::filterSet ( void   )  const [inline]

void MyMoneyTransactionFilter::removeReference ( const QString &  id  ) 

This member removes all references to object identified by id. Used to remove objects which are about to be removed from the engine.

int MyMoneyTransactionFilter::splitState ( const MyMoneySplit split  )  const [private]

This is a conversion tool from MyMoneySplit::reconcileFlagE to MyMoneyTransactionFilter::stateE types

Parameters:
split reference to split in question
Returns:
converted reconcile flag of the split passed as parameter

int MyMoneyTransactionFilter::splitType ( const MyMoneyTransaction t,
const MyMoneySplit split 
) const [private]

This is a conversion tool from MyMoneySplit::action to MyMoneyTransactionFilter::typeE types

Parameters:
t reference to transaction
split reference to split in question
Returns:
converted action of the split passed as parameter

validityOptionE MyMoneyTransactionFilter::validTransaction ( const MyMoneyTransaction transaction  )  const [private]

This method checks if a transaction is valid or not. A transaction is considered valid, if the sum of all splits is zero, invalid otherwise.

Parameters:
transaction reference to transaction to be checked
Return values:
valid transaction is valid
invalid transaction is invalid


Member Data Documentation

QRegExp MyMoneyTransactionFilter::m_text [protected]

QAsciiDict<char> MyMoneyTransactionFilter::m_accounts [protected]

QAsciiDict<char> MyMoneyTransactionFilter::m_payees [protected]

QAsciiDict<char> MyMoneyTransactionFilter::m_categories [protected]

QIntDict<char> MyMoneyTransactionFilter::m_states [protected]

QIntDict<char> MyMoneyTransactionFilter::m_types [protected]

QIntDict<char> MyMoneyTransactionFilter::m_validity [protected]

QString MyMoneyTransactionFilter::m_toNr [protected]


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

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