#include <mymoneytransactionfilter.h>
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< MyMoneySplit > | m_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 |
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); :
id | reference to account id |
MyMoneyTransactionFilter::~MyMoneyTransactionFilter | ( | ) |
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:
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.
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.
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.
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.
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.
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.
from | smallest value to match | |
to | largest value to match |
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.
transaction | A transaction |
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.
sp | pointer to the split to be checked |
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.
sp | pointer to the split to be checked |
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().
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.
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.
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.
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.
cat | id of category in question |
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.
acc | id of account in question |
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.
pye | id of payee in question |
bool MyMoneyTransactionFilter::dateFilter | ( | QDate & | from, | |
QDate & | to | |||
) | const |
This method is used to return information about the presence of a date filter.
from | result value for the beginning of the date range | |
to | result value for the end of the date range |
bool MyMoneyTransactionFilter::amountFilter | ( | MyMoneyMoney & | from, | |
MyMoneyMoney & | to | |||
) | const |
This method is used to return information about the presence of an amount filter.
from | result value for the low end of the amount range | |
to | result value for the high end of the amount range |
bool MyMoneyTransactionFilter::numberFilter | ( | QString & | from, | |
QString & | to | |||
) | const |
This method is used to return information about the presence of an number filter.
from | result value for the low end of the number range | |
to | result value for the high end of the number range |
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.
list | list to append payees into |
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.
list | list to append accounts into |
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.
list | list to append categories into |
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.
i | int to replace with first type filter, untouched otherwise |
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.
i | reference to int to replace with first state filter, untouched otherwise |
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.
text | regexp to replace with text filter, or blank if none 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
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 |
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
split | reference to split in question |
int MyMoneyTransactionFilter::splitType | ( | const MyMoneyTransaction & | t, | |
const MyMoneySplit & | split | |||
) | const [private] |
This is a conversion tool from MyMoneySplit::action to MyMoneyTransactionFilter::typeE types
t | reference to transaction | |
split | reference to split in question |
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.
transaction | reference to transaction to be checked |
valid | transaction is valid | |
invalid | transaction is invalid |
FilterSet MyMoneyTransactionFilter::m_filterSet [protected] |
bool MyMoneyTransactionFilter::m_reportAllSplits [protected] |
bool MyMoneyTransactionFilter::m_considerCategory [protected] |
QRegExp MyMoneyTransactionFilter::m_text [protected] |
bool MyMoneyTransactionFilter::m_invertText [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_fromNr [protected] |
QString MyMoneyTransactionFilter::m_toNr [protected] |
QDate MyMoneyTransactionFilter::m_fromDate [protected] |
QDate MyMoneyTransactionFilter::m_toDate [protected] |
MyMoneyMoney MyMoneyTransactionFilter::m_fromAmount [protected] |
MyMoneyMoney MyMoneyTransactionFilter::m_toAmount [protected] |