MyMoneyTransaction Class Reference

#include <mymoneytransaction.h>

Inheritance diagram for MyMoneyTransaction:

MyMoneyObject MyMoneyKeyValueContainer KMyMoneyTransaction test::TransactionHelper test::InvTransactionHelper
Collaboration diagram for MyMoneyTransaction:

Collaboration graph

List of all members.

Public Member Functions

 MyMoneyTransaction ()
 MyMoneyTransaction (const QString id, const MyMoneyTransaction &transaction)
 MyMoneyTransaction (const QDomElement &node, const bool forceId=true)
 ~MyMoneyTransaction ()
const QDate & entryDate (void) const
const QDate & postDate (void) const
const QString & memo (void) const
const QValueList< MyMoneySplit > & splits (void) const
QValueList< MyMoneySplit > & splits (void)
unsigned int splitCount (void) const
const QString & commodity (void) const
const QString & bankID (void) const
void setPostDate (const QDate &date)
void setEntryDate (const QDate &date)
void setMemo (const QString &memo)
void setCommodity (const QString &commodityId)
void setBankID (const QString &bankID)
bool operator== (const MyMoneyTransaction &) const
bool operator!= (const MyMoneyTransaction &r) const
bool operator< (const MyMoneyTransaction &r) const
bool operator<= (const MyMoneyTransaction &r) const
bool operator> (const MyMoneyTransaction &r) const
const MyMoneySplitsplitByAccount (const QString &accountId, const bool match=true) const
const MyMoneySplitsplitByAccount (const QStringList &accountIds, const bool match=true) const
const MyMoneySplitsplitById (const QString &splitId) const
const MyMoneySplitsplitByPayee (const QString &payeeId) const
bool accountReferenced (const QString &id) const
void addSplit (MyMoneySplit &split)
void modifySplit (MyMoneySplit &split)
void removeSplit (const MyMoneySplit &split)
void removeSplits (void)
const MyMoneyMoney splitSum (void) const
bool isLoanPayment (void) const
const MyMoneySplitamortizationSplit (void) const
const MyMoneySplitinterestSplit (void) const
bool isDuplicate (const MyMoneyTransaction &transaction) const
bool isStockSplit (void) const
bool isImported (void) const
void setImported (bool state=true)
void writeXML (QDomDocument &document, QDomElement &parent) const
virtual bool hasReferenceTo (const QString &id) const
bool hasAutoCalcSplit (void) const
QString accountSignature (bool includeSplitCount=false) const
QString uniqueSortKey (void) const

Static Public Member Functions

static const QString firstSplitID (void)
static unsigned long hash (const QString &txt, unsigned long h=0)

Private Member Functions

const QString nextSplitID (void)

Private Attributes

QDate m_entryDate
QDate m_postDate
QString m_memo
QValueList< MyMoneySplitm_splits
unsigned int m_nextSplitID
QString m_commodity
QString m_bankID

Static Private Attributes

static const int SPLIT_ID_SIZE = 4
static const int YEAR_SIZE = 4
static const int MONTH_SIZE = 2
static const int DAY_SIZE = 2


QDataStream & operator<< (QDataStream &, MyMoneyTransaction &)
QDataStream & operator>> (QDataStream &, MyMoneyTransaction &)

Detailed Description

This class represents a transaction within the MyMoneyEngine. A transaction contains none, one or more splits of type MyMoneySplit. They are stored in a QValueList<MyMoneySplit> within this object. A transaction containing only a single split with an amount not equal to 0 is an unbalanced transaction. It is tolerated by the engine, but in general not a good idea as it is financially wrong.

Constructor & Destructor Documentation

MyMoneyTransaction::MyMoneyTransaction (  ) 

MyMoneyTransaction::MyMoneyTransaction ( const QString  id,
const MyMoneyTransaction transaction 

MyMoneyTransaction::MyMoneyTransaction ( const QDomElement &  node,
const bool  forceId = true 

node reference to QDomNode
forceId see MyMoneyObject(const QDomElement&, const bool)

MyMoneyTransaction::~MyMoneyTransaction (  ) 

Member Function Documentation

const QDate& MyMoneyTransaction::entryDate ( void   )  const [inline]

const QDate& MyMoneyTransaction::postDate ( void   )  const [inline]

const QString& MyMoneyTransaction::memo ( void   )  const [inline]

const QValueList<MyMoneySplit>& MyMoneyTransaction::splits ( void   )  const [inline]

QValueList<MyMoneySplit>& MyMoneyTransaction::splits ( void   )  [inline]

unsigned int MyMoneyTransaction::splitCount ( void   )  const [inline]

const QString& MyMoneyTransaction::commodity ( void   )  const [inline]

const QString& MyMoneyTransaction::bankID ( void   )  const [inline]

void MyMoneyTransaction::setPostDate ( const QDate &  date  ) 

void MyMoneyTransaction::setEntryDate ( const QDate &  date  ) 

void MyMoneyTransaction::setMemo ( const QString &  memo  ) 

void MyMoneyTransaction::setCommodity ( const QString &  commodityId  )  [inline]

void MyMoneyTransaction::setBankID ( const QString &  bankID  )  [inline]

bool MyMoneyTransaction::operator== ( const MyMoneyTransaction  )  const

bool MyMoneyTransaction::operator!= ( const MyMoneyTransaction r  )  const [inline]

bool MyMoneyTransaction::operator< ( const MyMoneyTransaction r  )  const [inline]

bool MyMoneyTransaction::operator<= ( const MyMoneyTransaction r  )  const [inline]

bool MyMoneyTransaction::operator> ( const MyMoneyTransaction r  )  const [inline]

const MyMoneySplit& MyMoneyTransaction::splitByAccount ( const QString &  accountId,
const bool  match = true 
) const

This method is used to extract a split for a given accountId from a transaction. A parameter controls, whether the accountId should match or not. In case of 'not match', the first not-matching split is returned.

accountId the account to look for
match if true, the account Id must match if false, the account Id must not match
reference to split within the transaction is returned

const MyMoneySplit& MyMoneyTransaction::splitByAccount ( const QStringList &  accountIds,
const bool  match = true 
) const

This method is essentially the same as the previous method, except that takes a list of accounts instead of just one.

accountIds the list of accounts to look for
match if true, the account Id must match if false, the account Id must not match
reference to split within the transaction is returned

const MyMoneySplit& MyMoneyTransaction::splitById ( const QString &  splitId  )  const

This method is used to extract a split from a transaction.

splitId the split to look for
reference to split within the transaction is returned

const MyMoneySplit& MyMoneyTransaction::splitByPayee ( const QString &  payeeId  )  const

This method is used to extract a split for a given payeeId from a transaction.

payeeId the payee to look for
reference to split within the transaction is returned

bool MyMoneyTransaction::accountReferenced ( const QString &  id  )  const

This method is used to check if the given account is used in any of the splits of this transation

id account id that should be checked for usage

void MyMoneyTransaction::addSplit ( MyMoneySplit split  ) 

This method is used to add a split to the transaction. The split will be assigned an id. The id member must be empty and the accountId member must be filled.

split reference to the split that should be added

void MyMoneyTransaction::modifySplit ( MyMoneySplit split  ) 

This method is used to modify a split in a transaction

void MyMoneyTransaction::removeSplit ( const MyMoneySplit split  ) 

This method is used to remove a split from a transaction

void MyMoneyTransaction::removeSplits ( void   ) 

This method is used to remove all splits from a transaction

const MyMoneyMoney MyMoneyTransaction::splitSum ( void   )  const

This method is used to return the sum of all splits of this transaction

MyMoneyMoney value of sum of all splits

bool MyMoneyTransaction::isLoanPayment ( void   )  const

This method returns information if the transaction contains information of a loan payment or not. Loan payment transactions have at least one split that is identified with a MyMoneySplit::action() of type MyMoneySplit::ActionAmortization.

Return values:
false transaction is no loan payment transaction
true transaction is a loan payment transaction
Upon internal failures, the return value false will be used.

const MyMoneySplit& MyMoneyTransaction::amortizationSplit ( void   )  const

This method returns a const reference to the amortization split. In case none is found, a reference to an empty split will be returned.

const MyMoneySplit& MyMoneyTransaction::interestSplit ( void   )  const

This method returns a const reference to the interest split. In case none is found, a reference to an empty split will be returned.

bool MyMoneyTransaction::isDuplicate ( const MyMoneyTransaction transaction  )  const

This method is used to check if two transactions are identical. Identical transactions have:

  • the same number of splits
  • reference the same accounts
  • have the same values in the splits
  • have a postDate wihtin 3 days

transaction reference to the transaction to be checked against this transaction
Return values:
true transactions are identical
false transactions are not identical

bool MyMoneyTransaction::isStockSplit ( void   )  const

returns true if this is a stock split transaction

bool MyMoneyTransaction::isImported ( void   )  const

returns true if this is an imported transaction

void MyMoneyTransaction::setImported ( bool  state = true  ) 

Sets the imported state of this transaction to be the value of state . state defaults to true.

static const QString MyMoneyTransaction::firstSplitID ( void   )  [static]

This static method returns the id which will be assigned to the first split added to a transaction. This ID can be used to figure out the split that references the account through which a transaction was entered.

QString with ID of the first split of transactions

void MyMoneyTransaction::writeXML ( QDomDocument &  document,
QDomElement &  parent 
) const

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

document reference to QDomDocument
parent reference to QDomElement parent node

Reimplemented from MyMoneyKeyValueContainer.

virtual bool MyMoneyTransaction::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
Return values:
true This object references object with id id.
false This object does not reference the object with id id.

Implements MyMoneyObject.

bool MyMoneyTransaction::hasAutoCalcSplit ( void   )  const

Checks whether any split contains an autocalc split.

Return values:
true at least one split has an autocalc value
false all splits have fixed values

QString MyMoneyTransaction::accountSignature ( bool  includeSplitCount = false  )  const

Returns a signature consisting of the account ids and the number of times they occur in the transaction if includeSplitCount is true. The signature is independant from the order of splits.

Example: Having splits referencing the account B, A and B, the returned value will be "A-B" if includeSplitCount is false or A*1-B*2 if it is true.

The same result will be returned if the list of splits is A, B, B.

includeSplitCount if true, the string *n with n being the number of splits referencing this account. The default for this parameter is false.

QString MyMoneyTransaction::uniqueSortKey ( void   )  const

static unsigned long MyMoneyTransaction::hash ( const QString &  txt,
unsigned long  h = 0 
) [static]

This module implements an algorithm used by P.J. Weinberger for fast hashing. Source: COMPILERS by Alfred V. Aho, pages 435-437.

It converts the string passed in txt into a non-unique unsigned long integer value.

txt the text to be hashed
h initial hash value (default 0)
non-unique hash value of the text txt

const QString MyMoneyTransaction::nextSplitID ( void   )  [private]

This method returns the next id to be used for a split

Friends And Related Function Documentation

QDataStream& operator<< ( QDataStream &  ,
) [friend]

QDataStream& operator>> ( QDataStream &  ,
) [friend]

Member Data Documentation

const int MyMoneyTransaction::SPLIT_ID_SIZE = 4 [static, private]

This member contains the date when the transaction was entered into the engine

This member contains the date the transaction was posted

QString MyMoneyTransaction::m_memo [private]

This member keeps the memo text associated with this transaction

This member contains the splits for this transaction

unsigned int MyMoneyTransaction::m_nextSplitID [private]

This member keeps the unique numbers of splits within this transaction. Upon creation of a MyMoneyTransaction object this value will be set to 1.

This member keeps the base commodity (e.g. currency) for this transaction

QString MyMoneyTransaction::m_bankID [private]

This member keeps the bank's unique ID for the transaction, so we can avoid duplicates. This is only used for electronic statement downloads.

Note this is now deprecated! Bank ID's should be set on splits, not transactions.

const int MyMoneyTransaction::YEAR_SIZE = 4 [static, private]

constants for unique sort key

const int MyMoneyTransaction::MONTH_SIZE = 2 [static, private]

const int MyMoneyTransaction::DAY_SIZE = 2 [static, private]

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