#include <transactionmatcher.h>
Public Types | |
enum | autoMatchResultE { notMatched = 0, matched, matchedExact, matchedDuplicate } |
Public Member Functions | |
TransactionMatcher (const MyMoneyAccount &acc) | |
void | match (MyMoneyTransaction tm, MyMoneySplit sm, MyMoneyTransaction ti, MyMoneySplit si, bool allowImportedTransactions=false) |
void | unmatch (const MyMoneyTransaction &t, const MyMoneySplit &s) |
void | accept (const MyMoneyTransaction &t, const MyMoneySplit &s) |
MyMoneyObject const * | findMatch (const MyMoneyTransaction &ti, const MyMoneySplit &si, MyMoneySplit &sm, autoMatchResultE &result) |
void | setMatchWindow (int days) |
Private Member Functions | |
void | checkTransaction (const MyMoneyTransaction &tm, const MyMoneyTransaction &ti, const MyMoneySplit &si, QPair< MyMoneyTransaction, MyMoneySplit > &lastMatch, autoMatchResultE &result, int variation=0) const |
Private Attributes | |
MyMoneyAccount | m_account |
int | m_days |
TransactionMatcher::TransactionMatcher | ( | const MyMoneyAccount & | acc | ) |
void TransactionMatcher::match | ( | MyMoneyTransaction | tm, | |
MyMoneySplit | sm, | |||
MyMoneyTransaction | ti, | |||
MyMoneySplit | si, | |||
bool | allowImportedTransactions = false | |||
) |
This method matches the manual entered transaction tm
with the imported transaction ti
based on the splits sm
and si
. If the match can be applied, MyMoneyTransaction::addMatch() is used to include ti
inside tm
and the engine data (MyMoneyFile) is updated. A possible bankid found in the imported split is carried over into the manual transaction.
The following things will be done in case of a match:
The application of the match depends on the following items:
sm
and si
must be identicaltm
must be a non-imported (see below), non-matched transactionti
must be an imported transaction
If allowImportedTransactions
is true, tm
may be an imported transaction. The default of allowImportedTransactions
is false
.
In case of errors, an exception is thrown.
void TransactionMatcher::unmatch | ( | const MyMoneyTransaction & | t, | |
const MyMoneySplit & | s | |||
) |
This method is used to unmatch a previously matched transaction (see match() and findMatch() ) and restore the original and imported transaction in the engine.
The following things will be done in case t
is a matched transaction:
In case of errors, an exception is thrown.
void TransactionMatcher::accept | ( | const MyMoneyTransaction & | t, | |
const MyMoneySplit & | s | |||
) |
This method is used to accept a previously matched transaction (see match() and findMatch())
The following things will be done in case _t
is a matched transaction
In case of errors, an exception is thrown
MyMoneyObject const* TransactionMatcher::findMatch | ( | const MyMoneyTransaction & | ti, | |
const MyMoneySplit & | si, | |||
MyMoneySplit & | sm, | |||
autoMatchResultE & | result | |||
) |
This method is used to automatically find a matching transaction in the ledger or the schedules. It should also detect duplicate imports according to the splits bankid.
To be designed
ti | the imported transaction we want to match | |
si | the split of that transaction referencing the account we import into | |
sm | the split of the object returned that matches the split si. In case the returned pointer is not 0 this object contains the split. In other cases it contains an empty MyMoneySplit. | |
result | reference to the result details |
void TransactionMatcher::setMatchWindow | ( | int | days | ) | [inline] |
Sets the number of days to look for matching transactions. The default after object creation is 3 days.
void TransactionMatcher::checkTransaction | ( | const MyMoneyTransaction & | tm, | |
const MyMoneyTransaction & | ti, | |||
const MyMoneySplit & | si, | |||
QPair< MyMoneyTransaction, MyMoneySplit > & | lastMatch, | |||
autoMatchResultE & | result, | |||
int | variation = 0 | |||
) | const [private] |
MyMoneyAccount TransactionMatcher::m_account [private] |
int TransactionMatcher::m_days [private] |