Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

MyMoneyTransaction Class Reference

#include <mymoneytransaction.h>

Inheritance diagram for MyMoneyTransaction:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 MyMoneyTransaction ()
 MyMoneyTransaction (const QCString 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 QCString & 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 QCString &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 QCString &accountId, const bool match=true) const
const MyMoneySplitsplitByAccount (const QCStringList &accountIds, const bool match=true) const
const MyMoneySplitsplitById (const QCString &splitId) const
const MyMoneySplitsplitByPayee (const QCString &payeeId) const
bool accountReferenced (const QCString &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
bool isDuplicate (const MyMoneyTransaction &transaction) const
bool isStockSplit (void) const
bool isImported (void) const
void writeXML (QDomDocument &document, QDomElement &parent) const
virtual bool hasReferenceTo (const QCString &id) const
bool hasAutoCalcSplit (void) const
QString accountSignature (bool includeSplitCount=false) const
QCString uniqueSortKey (void) const

Static Public Member Functions

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

Private Member Functions

const QCString nextSplitID (void)

Private Attributes

QDate m_entryDate
QDate m_postDate
QString m_memo
QValueList< MyMoneySplitm_splits
unsigned int m_nextSplitID
QCString 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

Friends

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 QCString  id,
const MyMoneyTransaction transaction
 

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

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

MyMoneyTransaction::~MyMoneyTransaction  ) 
 


Member Function Documentation

bool MyMoneyTransaction::accountReferenced const QCString &  id  )  const
 

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

Parameters:
id account id that should be checked for usage

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 . 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.

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

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.

Parameters:
split reference to the split that should be added

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 QString& MyMoneyTransaction::bankID void   )  const [inline]
 

const QCString& MyMoneyTransaction::commodity void   )  const [inline]
 

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

static const QCString 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.

Returns:
QCString with ID of the first split of transactions

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

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.

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

virtual bool MyMoneyTransaction::hasReferenceTo const QCString &  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.

Parameters:
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::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

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

bool MyMoneyTransaction::isImported void   )  const
 

returns true if this is an imported transaction

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
Note:
Upon internal failures, the return value false will be used.

bool MyMoneyTransaction::isStockSplit void   )  const
 

returns true if this is a stock split transaction

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

void MyMoneyTransaction::modifySplit MyMoneySplit split  ) 
 

This method is used to modify a split in a transaction

const QCString MyMoneyTransaction::nextSplitID void   )  [private]
 

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

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  )  const
 

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

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

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

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

void MyMoneyTransaction::setCommodity const QCString &  commodityId  )  [inline]
 

void MyMoneyTransaction::setEntryDate const QDate &  date  ) 
 

void MyMoneyTransaction::setMemo const QString &  memo  ) 
 

void MyMoneyTransaction::setPostDate const QDate &  date  ) 
 

const MyMoneySplit& MyMoneyTransaction::splitByAccount const QCStringList 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.

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

const MyMoneySplit& MyMoneyTransaction::splitByAccount const QCString &  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.

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

const MyMoneySplit& MyMoneyTransaction::splitById const QCString &  splitId  )  const
 

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

Parameters:
splitId the split to look for
Returns:
reference to split within the transaction is returned

const MyMoneySplit& MyMoneyTransaction::splitByPayee const QCString &  payeeId  )  const
 

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

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

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

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

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

const MyMoneyMoney MyMoneyTransaction::splitSum void   )  const
 

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

Returns:
MyMoneyMoney value of sum of all splits

QCString MyMoneyTransaction::uniqueSortKey void   )  const
 

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

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

Parameters:
document reference to QDomDocument
parent reference to QDomElement parent node

Reimplemented from MyMoneyKeyValueContainer.


Friends And Related Function Documentation

QDataStream& operator<< QDataStream &  ,
MyMoneyTransaction
[friend]
 

QDataStream& operator>> QDataStream &  ,
MyMoneyTransaction
[friend]
 


Member Data Documentation

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

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.

QCString MyMoneyTransaction::m_commodity [private]
 

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

QDate MyMoneyTransaction::m_entryDate [private]
 

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

QString MyMoneyTransaction::m_memo [private]
 

This member keeps the memo text associated with 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.

QDate MyMoneyTransaction::m_postDate [private]
 

This member contains the date the transaction was posted

QValueList<MyMoneySplit> MyMoneyTransaction::m_splits [private]
 

This member contains the splits for this transaction

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

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

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

constants for unique sort key


The documentation for this class was generated from the following file:
Generated on Mon Oct 13 12:16:33 2008 for KMyMoney by  doxygen 1.4.1