MyMoneyFile Class Reference

#include <mymoneyfile.h>

Inheritance diagram for MyMoneyFile:

QObject
Collaboration diagram for MyMoneyFile:

Collaboration graph
[legend]

List of all members.

Signals

void dataChanged (void)

Public Member Functions

 ~MyMoneyFile ()
 MyMoneyFile (IMyMoneyStorage *storage)
const MyMoneyPayee user (void) const
void setUser (const MyMoneyPayee &user)
void attachStorage (IMyMoneyStorage *const storage)
void detachStorage (IMyMoneyStorage *const storage=0)
bool storageAttached (void) const
IMyMoneyStoragestorage (void) const
void startTransaction (void)
bool hasTransaction (void) const
void commitTransaction (void)
void rollbackTransaction (void)
const MyMoneyAccountliability (void) const
const MyMoneyAccountasset (void) const
const MyMoneyAccountexpense (void) const
const MyMoneyAccountincome (void) const
const MyMoneyAccountequity (void) const
const MyMoneyAccount openingBalanceAccount (const MyMoneySecurity &security)
const MyMoneyAccount openingBalanceAccount (const MyMoneySecurity &security) const
MyMoneyTransaction createOpeningBalanceTransaction (const MyMoneyAccount &acc, const MyMoneyMoney &balance)
QString openingBalanceTransaction (const MyMoneyAccount &acc) const
bool dirty (void) const
void setDirty (void) const
void addInstitution (MyMoneyInstitution &institution)
void modifyInstitution (const MyMoneyInstitution &institution)
void removeInstitution (const MyMoneyInstitution &institution)
void addAccount (MyMoneyAccount &account, MyMoneyAccount &parent)
void modifyAccount (const MyMoneyAccount &account)
void reparentAccount (MyMoneyAccount &account, MyMoneyAccount &parent)
unsigned int moveSplits (const QString &oldAccount, const QString &newAccount)
bool hasActiveSplits (const QString &id) const
bool isStandardAccount (const QString &id) const
bool isTransfer (const MyMoneyTransaction &t) const
void setAccountName (const QString &id, const QString &name) const
void removeAccount (const MyMoneyAccount &account)
void removeAccountList (const QStringList &account_list, unsigned int level=0)
bool hasOnlyUnusedAccounts (const QStringList &account_list, unsigned int level=0)
void addTransaction (MyMoneyTransaction &transaction)
void modifyTransaction (const MyMoneyTransaction &transaction)
const MyMoneyTransaction transaction (const QString &id) const
const MyMoneyTransaction transaction (const QString &account, const int idx) const
const QValueList
< MyMoneyTransaction
transactionList (MyMoneyTransactionFilter &filter) const
void transactionList (QValueList< MyMoneyTransaction > &list, MyMoneyTransactionFilter &filter) const
void transactionList (QValueList< QPair< MyMoneyTransaction, MyMoneySplit > > &list, MyMoneyTransactionFilter &filter) const
void removeTransaction (const MyMoneyTransaction &transaction)
const MyMoneyMoney balance (const QString &id, const QDate &date=QDate()) const
const MyMoneyMoney totalBalance (const QString &id, const QDate &date=QDate()) const
unsigned int transactionCount (const QString &account=QString()) const
const QMap< QString, unsigned
long > 
transactionCountMap (void) const
unsigned int institutionCount (void) const
unsigned int accountCount (void) const
const MyMoneyInstitutioninstitution (const QString &id) const
void institutionList (QValueList< MyMoneyInstitution > &list) const
const QValueList
< MyMoneyInstitution
institutionList (void) const
const MyMoneyAccountaccount (const QString &id) const
const MyMoneyAccountaccountByName (const QString &name) const
const MyMoneyAccountsubAccountByName (const MyMoneyAccount &acc, const QString &name) const
void accountList (QValueList< MyMoneyAccount > &list, const QStringList &idlist=QStringList(), const bool recursive=false) const
QString accountToCategory (const QString &accountId, bool includeStandardAccounts=false) const
QString categoryToAccount (const QString &category, MyMoneyAccount::accountTypeE type=MyMoneyAccount::UnknownAccountType) const
QString nameToAccount (const QString &name) const
QString parentName (const QString &name) const
void addPayee (MyMoneyPayee &payee)
const MyMoneyPayeepayee (const QString &id) const
const MyMoneyPayeepayeeByName (const QString &payee) const
void modifyPayee (const MyMoneyPayee &payee)
void removePayee (const MyMoneyPayee &payee)
const QValueList< MyMoneyPayeepayeeList (void) const
QString value (const QString &key) const
void setValue (const QString &key, const QString &val)
void deletePair (const QString &key)
void addSchedule (MyMoneySchedule &sched)
void modifySchedule (const MyMoneySchedule &sched)
void removeSchedule (const MyMoneySchedule &sched)
const MyMoneySchedule schedule (const QString &id) const
const QValueList< MyMoneySchedulescheduleList (const QString &accountId=QString(), const MyMoneySchedule::typeE type=MyMoneySchedule::TYPE_ANY, const MyMoneySchedule::occurenceE occurence=MyMoneySchedule::OCCUR_ANY, const MyMoneySchedule::paymentTypeE paymentType=MyMoneySchedule::STYPE_ANY, const QDate &startDate=QDate(), const QDate &endDate=QDate(), const bool overdue=false) const
const QStringList consistencyCheck (void)
QString createCategory (const MyMoneyAccount &base, const QString &name)
const QValueList< MyMoneySchedulescheduleListEx (int scheduleTypes, int scheduleOcurrences, int schedulePaymentTypes, QDate startDate, const QStringList &accounts=QStringList()) const
void addSecurity (MyMoneySecurity &security)
void modifySecurity (const MyMoneySecurity &security)
void removeSecurity (const MyMoneySecurity &security)
const MyMoneySecuritysecurity (const QString &id) const
const QValueList< MyMoneySecuritysecurityList (void) const
void addCurrency (const MyMoneySecurity &currency)
void modifyCurrency (const MyMoneySecurity &currency)
void removeCurrency (const MyMoneySecurity &currency)
const MyMoneySecuritycurrency (const QString &id) const
const QValueList< MyMoneySecuritycurrencyList (void) const
const MyMoneySecuritybaseCurrency (void) const
const QString & foreignCurrency (const QString &first, const QString &second) const
void setBaseCurrency (const MyMoneySecurity &currency)
void addPrice (const MyMoneyPrice &price)
void removePrice (const MyMoneyPrice &price)
const MyMoneyPrice price (const QString &fromId, const QString &toId=QString(), const QDate &date=QDate::currentDate(), const bool exactDate=false) const
const MyMoneyPriceList priceList (void) const
bool hasAccount (const QString &id, const QString &name) const
const QValueList< MyMoneyReportreportList (void) const
void addReport (MyMoneyReport &report)
void modifyReport (const MyMoneyReport &report)
unsigned countReports (void) const
const MyMoneyReport report (const QString &id) const
void removeReport (const MyMoneyReport &report)
const QValueList< MyMoneyBudgetbudgetList (void) const
void addBudget (MyMoneyBudget &budget)
const MyMoneyBudget budgetByName (const QString &budget) const
void modifyBudget (const MyMoneyBudget &budget)
unsigned countBudgets (void) const
const MyMoneyBudget budget (const QString &id) const
void removeBudget (const MyMoneyBudget &budget)
bool isReferenced (const MyMoneyObject &obj, const MyMoneyFileBitArray &skipCheck=MyMoneyFileBitArray()) const
bool referencesClosedAccount (const MyMoneyTransaction &t) const
bool referencesClosedAccount (const MyMoneySplit &s) const
bool checkNoUsed (const QString &accId, const QString &no) const
QString highestCheckNo (const QString &accId) const
void clearCache (void)
void forceDataChanged (void)
void preloadCache (void)

Static Public Member Functions

static MyMoneyFileinstance ()

Static Public Attributes

static const QString OpeningBalancesPrefix
static const QString AccountSeperator

Protected Member Functions

 MyMoneyFile ()

Private Member Functions

MyMoneyFileoperator= (MyMoneyFile &)
 MyMoneyFile (const MyMoneyFile &)
QString locateSubAccount (const MyMoneyAccount &base, const QString &category) const
void ensureDefaultCurrency (MyMoneyAccount &acc) const
void warningMissingRate (const QString &fromId, const QString &toId) const
const MyMoneyAccount createOpeningBalanceAccount (const MyMoneySecurity &security)
const MyMoneyAccount openingBalanceAccount_internal (const MyMoneySecurity &security) const
void addNotification (const QString &id, bool reload=true)
void clearNotification (void)
void notify (void)
void checkStorage (void) const
void checkTransaction (const char *txt) const

Private Attributes

IMyMoneyStoragem_storage
Private *const d

Static Private Attributes

static MyMoneyFile file
static MyMoneyFile_instance

Friends

class MyMoneyNotifier

Classes

class  MyMoneyNotifier


Detailed Description

This class represents the interface to the MyMoney engine. For historical reasons it is still called MyMoneyFile. It is implemented using the singleton pattern and thus only exists once for each running instance of an application.

The instance of the MyMoneyFile object is accessed as follows:

 MyMoneyFile *file = MyMoneyFile::instance();
 file->anyMemberFunction();

The first line of the above code creates a unique MyMoneyFile object if it is called for the first time ever. All subsequent calls to this functions return a pointer to the object created during the first call.

As the MyMoneyFile object represents the business logic, a storage manager must be attached to it. This mechanism allows to use different access methods to store the objects. The interface to access such an storage manager is defined in the class IMyMoneyStorage. The methods attachStorage() and detachStorage() are used to attach/detach a storage manager object. The following code can be used to create a functional MyMoneyFile instance:

 IMyMoneyStorage *storage = ....
 MyMoneyFile *file = MyMoneyFile::instance();
 file->attachStorage(storage);

The methods addAccount(), modifyAccount() and removeAccount() implement the general account maintenance functions. The method reparentAccount() is available to move an account from one superordinate account to another. account() and accountList() are used to retrieve a single instance or a QValueList of MyMoneyAccount objects.

The methods addInstitution(), modifyInstitution() and removeInstitution() implement the general institution maintenance functions. institution() and institutionList() are used to retrieve a single instance or a QValueList of MyMoneyInstitution objects.

The methods addPayee(), modifyPayee() and removePayee() implement the general institution maintenance functions. payee() and payeeList() are used to retrieve a single instance or a QValueList of MyMoneyPayee objects.

The methods addTransaction(), modifyTransaction() and removeTransaction() implement the general transaction maintenance functions. transaction() and transactionList() are used to retrieve a single instance or a QValueList of MyMoneyTransaction objects.

The methods addSecurity(), modifySecurity() and removeSecurity() implement the general access to equities held in the engine.

The methods addCurrency(), modifyCurrency() and removeCurrency() implement the general access to multiple currencies held in the engine. The methods baseCurrency() and setBaseCurrency() allow to retrieve/set the currency selected by the user as base currency. If a currency reference is emtpy, it will usually be interpreted as baseCurrency().

The methods liability(), asset(), expense(), income() and equity() are used to retrieve the five standard accounts. isStandardAccount() checks if a given accountId references one of the or not. setAccountName() is used to specify a name for the standard accounts from the GUI.

The MyMoneyFile object emits the dataChanged() signal when data has been changed.

For abritrary values that have to be stored with the storage object but are of importance to the application only, the object is derived for MyMoneyKeyValueContainer which provides a container to store these values indexed by an alphanumeric key.

Exceptions:
MyMoneyException is thrown whenever an error occurs while the engine code is running. The MyMoneyException:: object describes the problem.

Constructor & Destructor Documentation

MyMoneyFile::~MyMoneyFile (  ) 

This is the destructor for any MyMoneyFile object

MyMoneyFile::MyMoneyFile ( IMyMoneyStorage storage  ) 

Deprecated:
This is a convenience constructor. Do not use it anymore. It will be deprecated in a future version of the engine.
Parameters:
storage pointer to object that implements the IMyMoneyStorage interface.

MyMoneyFile::MyMoneyFile (  )  [protected]

This is the constructor for a new empty file description

MyMoneyFile::MyMoneyFile ( const MyMoneyFile  )  [private]


Member Function Documentation

static MyMoneyFile* MyMoneyFile::instance (  )  [inline, static]

This is the function to access the MyMoneyFile object. It returns a pointer to the single instance of the object.

const MyMoneyPayee MyMoneyFile::user ( void   )  const

void MyMoneyFile::setUser ( const MyMoneyPayee user  ) 

void MyMoneyFile::attachStorage ( IMyMoneyStorage *const   storage  ) 

This method is used to attach a storage object to the MyMoneyFile object Without an attached storage object, the MyMoneyFile object is of no use.

After successful completion, the dataChanged() signal is emitted.

In case of an error condition, an exception is thrown. The following error conditions are checked:

Parameters:
storage pointer to object that implements the IMyMoneyStorage interface.
See also:
detachStorage()

void MyMoneyFile::detachStorage ( IMyMoneyStorage *const   storage = 0  ) 

This method is used to detach a previously attached storage object from the MyMoneyFile object. If no storage object is attached to the engine, this is a NOP.

Parameters:
storage pointer to object that implements the IMyMoneyStorage interface.
See also:
attachStorage()

bool MyMoneyFile::storageAttached ( void   )  const [inline]

This method returns whether a storage is currently attached to the engine or not.

Returns:
true if storage object is attached, false otherwise

IMyMoneyStorage* MyMoneyFile::storage ( void   )  const [inline]

This method returns a pointer to the storage object

Returns:
const pointer to the current attached storage object. If no object is attached, returns 0.

void MyMoneyFile::startTransaction ( void   ) 

This method must be called before any single change or a series of changes in the underlying storage area is performed. Once all changes are complete (i.e. the transaction is completed), commitTransaction() must be called to finalize all changes. If an error occurs during the processing of the changes call rollbackTransaction() to undo the changes done so far.

bool MyMoneyFile::hasTransaction ( void   )  const

This method returns whether a transaction has been started (true) or not (false).

void MyMoneyFile::commitTransaction ( void   ) 

void MyMoneyFile::rollbackTransaction ( void   ) 

const MyMoneyAccount& MyMoneyFile::liability ( void   )  const

This method is used to return the standard liability account

Returns:
MyMoneyAccount liability account(group)

const MyMoneyAccount& MyMoneyFile::asset ( void   )  const

This method is used to return the standard asset account

Returns:
MyMoneyAccount asset account(group)

const MyMoneyAccount& MyMoneyFile::expense ( void   )  const

This method is used to return the standard expense account

Returns:
MyMoneyAccount expense account(group)

const MyMoneyAccount& MyMoneyFile::income ( void   )  const

This method is used to return the standard income account

Returns:
MyMoneyAccount income account(group)

const MyMoneyAccount& MyMoneyFile::equity ( void   )  const

This method is used to return the standard equity account

Returns:
MyMoneyAccount equity account(group)

const MyMoneyAccount MyMoneyFile::openingBalanceAccount ( const MyMoneySecurity security  ) 

This method returns the account information for the opening balances account for the given security. If the respective account does not exist, it will be created. The name is constructed using MyMoneyFile::OpeningBalancesPrefix and appending " (xxx)" in case the security is not the baseCurrency(). The account created will be a sub-account of the standard equity account provided by equity().

Parameters:
security Security for which the account is searched
Returns:
The opening balance account
Note:
No notifications will be sent!

const MyMoneyAccount MyMoneyFile::openingBalanceAccount ( const MyMoneySecurity security  )  const

This method is essentially the same as the above, except it works on const objects. If there is no opening balance account, this method WILL NOT create one. Instead it will thrown an exception.

Parameters:
security Security for which the account is searched
Returns:
The opening balance account
Note:
No notifications will be sent!

MyMoneyTransaction MyMoneyFile::createOpeningBalanceTransaction ( const MyMoneyAccount acc,
const MyMoneyMoney balance 
)

Create an opening balance transaction for the account acc with a value of balance. If the corresponding opening balance account for the account's currency does not exist it will be created. If it exists and it's opening date is later than the opening date of acc, the opening date of the opening balances account will be adjusted to the one of acc.

Parameters:
acc reference to account for which the opening balance transaction should be created
balance reference to the value of the opening balance transaction
Returns:
The created MyMoneyTransaction object. In case no transaction has been created, the id of the object is empty.

QString MyMoneyFile::openingBalanceTransaction ( const MyMoneyAccount acc  )  const

Retrieve the opening balance transaction for the account acc. If there is no opening balance transaction, QString() will be returned.

Parameters:
acc reference to account for which the opening balance transaction should be retrieved
Returns:
QString id for the transaction, or QString() if no transaction exists

bool MyMoneyFile::dirty ( void   )  const

This method returns an indicator if the MyMoneyFile object has been changed after it has last been saved to permanent storage.

Returns:
true if changed, false if not

void MyMoneyFile::setDirty ( void   )  const

This method is used to force the attached storage object to be dirty. This is used by the application to re-set the dirty flag after a failed upload to a server when the save operation to a local temp file was OK.

void MyMoneyFile::addInstitution ( MyMoneyInstitution institution  ) 

Adds an institution to the file-global institution pool. A respective institution-ID will be generated for this object. The ID is stored as QString in the object passed as argument.

An exception will be thrown upon error conditions.

Parameters:
institution The complete institution information in a MyMoneyInstitution object

void MyMoneyFile::modifyInstitution ( const MyMoneyInstitution institution  ) 

Modifies an already existing institution in the file global institution pool.

An exception will be thrown upon error conditions.

Parameters:
institution The complete new institution information

void MyMoneyFile::removeInstitution ( const MyMoneyInstitution institution  ) 

Deletes an existing institution from the file global institution pool Also modifies the accounts that reference this institution as their institution.

An exception will be thrown upon error conditions.

Parameters:
institution institution to be deleted.

void MyMoneyFile::addAccount ( MyMoneyAccount account,
MyMoneyAccount parent 
)

Adds an account to the file-global account pool. A respective account-ID will be generated within this record. The modified members of account will be updated.

A few parameters of the account to be added are checked against the following conditions. If they do not match, an exception is thrown.

An account must match the following conditions:

a) the account must have a name with length > 0 b) the account must not have an id assigned c) the transaction list must be empty d) the account must not have any sub-ordinate accounts e) the account must have no parent account f) the account must not have any reference to a MyMoneyFile object

An exception will be thrown upon error conditions.

Parameters:
account The complete account information in a MyMoneyAccount object
parent The complete account information of the parent account

void MyMoneyFile::modifyAccount ( const MyMoneyAccount account  ) 

Modifies an already existing account in the file global account pool.

An exception will be thrown upon error conditions.

Parameters:
account reference to the new account information

void MyMoneyFile::reparentAccount ( MyMoneyAccount account,
MyMoneyAccount parent 
)

This method re-parents an existing account

An exception will be thrown upon error conditions.

Parameters:
account MyMoneyAccount reference to account to be re-parented
parent MyMoneyAccount reference to new parent account

unsigned int MyMoneyFile::moveSplits ( const QString &  oldAccount,
const QString &  newAccount 
)

moves splits from one account to another

Parameters:
oldAccount id of the current account
newAccount if of the new account
Returns:
the number of modified splits

bool MyMoneyFile::hasActiveSplits ( const QString &  id  )  const

This method is used to determince, if the account with the given ID is referenced by any split in m_transactionList.

Parameters:
id id of the account to be checked for
Returns:
true if account is referenced, false otherwise

bool MyMoneyFile::isStandardAccount ( const QString &  id  )  const

This method is used to check whether a given account id references one of the standard accounts or not.

An exception will be thrown upon error conditions.

Parameters:
id account id
Returns:
true if account-id is one of the standards, false otherwise

bool MyMoneyFile::isTransfer ( const MyMoneyTransaction t  )  const

Returns true, if transaction t is a transfer transaction. A transfer transaction has two splits, both referencing either an asset, a liability or an equity account.

void MyMoneyFile::setAccountName ( const QString &  id,
const QString &  name 
) const

This method is used to set the name for the specified standard account within the storage area. An exception will be thrown, if an error occurs

Parameters:
id QString reference to one of the standard accounts.
name QString reference to the name to be set

void MyMoneyFile::removeAccount ( const MyMoneyAccount account  ) 

Deletes an existing account from the file global account pool This method only allows to remove accounts that are not referenced by any split. Use moveSplits() to move splits to another account. An exception is thrown in case of a problem.

Parameters:
account reference to the account to be deleted.

void MyMoneyFile::removeAccountList ( const QStringList &  account_list,
unsigned int  level = 0 
)

Deletes existing accounts and their subaccounts recursivly from the global account pool. This method expects that all accounts and their subaccounts are no longer assigned to any transactions or splits. An exception is thrown in case of a problem deleting an account.

The optional parameter level is used to keep track of the recursion level. If the recursion level exceeds 100 (some arbitrary number which seems a good maximum), an exception is thrown.

Parameters:
account_list Reference to a list of account IDs to be deleted.
level Parameter to keep track of recursion level (do not pass a value here).

bool MyMoneyFile::hasOnlyUnusedAccounts ( const QStringList &  account_list,
unsigned int  level = 0 
)

This member function checks all accounts identified by account_list and their subaccounts wether they are assigned to transactions/splits or not. The function calls itself recursively with the list of sub-accounts of the currently processed account.

The optional parameter level is used to keep track of the recursion level. If the recursion level exceeds 100 (some arbitrary number which seems a good maximum), an exception is thrown.

Parameters:
account_list A QStringList with account IDs that need to be checked.
level (optional) Optional parameter to indicate recursion level.
Returns:
Returns 'false' if at least one account has been found that is still referenced by a transaction.

void MyMoneyFile::addTransaction ( MyMoneyTransaction transaction  ) 

Adds a transaction to the file-global transaction pool. A respective transaction-ID will be generated for this object. The ID is stored as QString in the object passed as argument. Splits must reference valid accounts and valid payees. The payee id can be empty.

An exception will be thrown upon error conditions.

Parameters:
transaction reference to the transaction

void MyMoneyFile::modifyTransaction ( const MyMoneyTransaction transaction  ) 

This method is used to update a specific transaction in the transaction pool of the MyMoneyFile object. Splits must reference valid accounts and valid payees. The payee id can be empty.

An exception will be thrown upon error conditions.

Parameters:
transaction reference to transaction to be changed

const MyMoneyTransaction MyMoneyFile::transaction ( const QString &  id  )  const

This method is used to extract a transaction from the file global transaction pool through an id. In case of an invalid id, an exception will be thrown.

Parameters:
id id of transaction as QString.
Returns:
reference to the requested transaction

const MyMoneyTransaction MyMoneyFile::transaction ( const QString &  account,
const int  idx 
) const

This method is used to extract a transaction from the file global transaction pool through an index into an account.

Parameters:
account id of the account as QString
idx number of transaction in this account
Returns:
reference to MyMoneyTransaction object

const QValueList<MyMoneyTransaction> MyMoneyFile::transactionList ( MyMoneyTransactionFilter filter  )  const

This method is used to pull a list of transactions from the file global transaction pool. It returns all those transactions that match the filter passed as argument. If the filter is empty, the whole journal will be returned. The list returned is sorted according to the transactions posting date. If more than one transaction exists for the same date, the order among them is undefined.

Parameters:
filter MyMoneyTransactionFilter object with the match criteria
Returns:
set of transactions in form of a QValueList<MyMoneyTransaction>

void MyMoneyFile::transactionList ( QValueList< MyMoneyTransaction > &  list,
MyMoneyTransactionFilter filter 
) const

void MyMoneyFile::transactionList ( QValueList< QPair< MyMoneyTransaction, MyMoneySplit > > &  list,
MyMoneyTransactionFilter filter 
) const

void MyMoneyFile::removeTransaction ( const MyMoneyTransaction transaction  ) 

This method is used to remove a transaction from the transaction pool (journal).

Parameters:
transaction const reference to transaction to be deleted

const MyMoneyMoney MyMoneyFile::balance ( const QString &  id,
const QDate &  date = QDate() 
) const

This method is used to return the actual balance of an account without it's sub-ordinate accounts. If a date is presented, the balance at the beginning of this date (not including any transaction on this date) is returned. Otherwise all recorded transactions are included in the balance.

Parameters:
id id of the account in question
date return balance for specific date (default = QDate())
Returns:
balance of the account as MyMoneyMoney object

const MyMoneyMoney MyMoneyFile::totalBalance ( const QString &  id,
const QDate &  date = QDate() 
) const

This method is used to return the actual balance of an account including it's sub-ordinate accounts. If a date is presented, the balance at the beginning of this date (not including any transaction on this date) is returned. Otherwise all recorded transactions are included in the balance.

Parameters:
id id of the account in question
date return balance for specific date (default = QDate())
Returns:
balance of the account as MyMoneyMoney object

unsigned int MyMoneyFile::transactionCount ( const QString &  account = QString()  )  const

This method returns the number of transactions currently known to file in the range 0..MAXUINT

Parameters:
account QString reference to account id. If account is empty + all transactions (the journal) will be counted. If account is not empty it returns the number of transactions that have splits in this account.
Returns:
number of transactions in journal/account

const QMap<QString, unsigned long> MyMoneyFile::transactionCountMap ( void   )  const

This method returns a QMap filled with the number of transactions per account. The account id serves as index into the map. If one needs to have all transactionCounts() for many accounts, this method is faster than calling transactionCount(const QString& account) many times.

Returns:
QMap with numbers of transactions per account

unsigned int MyMoneyFile::institutionCount ( void   )  const

This method returns the number of institutions currently known to file in the range 0..MAXUINT

Returns:
number of institutions known to file

unsigned int MyMoneyFile::accountCount ( void   )  const

This method returns the number of accounts currently known to file in the range 0..MAXUINT

Returns:
number of accounts currently known inside a MyMoneyFile object

const MyMoneyInstitution& MyMoneyFile::institution ( const QString &  id  )  const

Returns the institution of a given ID

Parameters:
id id of the institution to locate
Returns:
MyMoneyInstitution object filled with data. If the institution could not be found, an exception will be thrown

void MyMoneyFile::institutionList ( QValueList< MyMoneyInstitution > &  list  )  const

This method returns a list of the institutions inside a MyMoneyFile object

Parameters:
list reference to the list. It will be cleared by this method first

const QValueList<MyMoneyInstitution> MyMoneyFile::institutionList ( void   )  const

This method returns a list of the institutions inside a MyMoneyFile object. This is a convenience method to the one above

Returns:
QValueList containing the institution objects

const MyMoneyAccount& MyMoneyFile::account ( const QString &  id  )  const

Returns the account addressed by its id.

Parameters:
id id of the account to locate.
Returns:
MyMoneyAccount object carrying the id. An exception is thrown if the id is unknown

const MyMoneyAccount& MyMoneyFile::accountByName ( const QString &  name  )  const

Returns the account addressed by its name.

Parameters:
name name of the account to locate.
Returns:
First MyMoneyAccount object found carrying the name. An empty MyMoneyAccount object will be returned if the name is not found.

const MyMoneyAccount& MyMoneyFile::subAccountByName ( const MyMoneyAccount acc,
const QString &  name 
) const

Returns the sub-account addressed by its name.

Parameters:
acc account to search in
name name of the account to locate.
Returns:
First MyMoneyAccount object found carrying the name. An empty MyMoneyAccount object will be returned if the name is not found.

void MyMoneyFile::accountList ( QValueList< MyMoneyAccount > &  list,
const QStringList &  idlist = QStringList(),
const bool  recursive = false 
) const

This method returns a list of accounts inside a MyMoneyFile object. An optional parameter is a list of id's. If this list is emtpy (the default) the returned list contains all accounts, otherwise only those referenced in the id-list.

Parameters:
list reference to QValueList receiving the account objects
idlist QStringList of account ids of those accounts that should be returned. If this list is empty, all accounts currently known will be returned.
recursive if true, then recurse in all found accounts. The default is false

QString MyMoneyFile::accountToCategory ( const QString &  accountId,
bool  includeStandardAccounts = false 
) const

This method is used to convert an account id to a string representation of the names which can be used as a category description. If the account is part of a hierarchy, the category name will be the concatenation of the single account names seperated by MyMoneyAccount::AccountSeperator.

Parameters:
accountId QString reference of the account's id
includeStandardAccounts if true, the standard top account will be part of the name, otherwise it will not be included (default is false)
Returns:
QString of the constructed name.

QString MyMoneyFile::categoryToAccount ( const QString &  category,
MyMoneyAccount::accountTypeE  type = MyMoneyAccount::UnknownAccountType 
) const

This method is used to convert a string representing a category to an account id. A category can be the concatenation of multiple accounts representing a hierarchy of accounts. They have to be seperated by MyMoneyAccount::AccountSeperator.

Parameters:
category const reference to QString containing the category
type account type if a specific type is required (defaults to UnknownAccountType)
Returns:
QString of the corresponding account. If account was not found the return value will be an empty string.

QString MyMoneyFile::nameToAccount ( const QString &  name  )  const

This method is used to convert a string representing an asset or liability account to an account id. An account name can be the concatenation of multiple accounts representing a hierarchy of accounts. They have to be seperated by MyMoneyAccount::AccountSeperator.

Parameters:
name const reference to QString containing the account name
Returns:
QString of the corresponding account. If account was not found the return value will be an empty string.

QString MyMoneyFile::parentName ( const QString &  name  )  const

This method is used to extract the parent part of an account hierarchy name who's parts are seperated by MyMoneyAccount::AccountSeperator.

Parameters:
name full account name
Returns:
parent name (full account name excluding the last part)

void MyMoneyFile::addPayee ( MyMoneyPayee payee  ) 

This method is used to create a new payee

An exception will be thrown upon error conditions

Parameters:
payee MyMoneyPayee reference to payee information

const MyMoneyPayee& MyMoneyFile::payee ( const QString &  id  )  const

This method is used to retrieve information about a payee An exception will be thrown upon error conditions.

Parameters:
id QString reference to id of payee
Returns:
MyMoneyPayee object of payee

const MyMoneyPayee& MyMoneyFile::payeeByName ( const QString &  payee  )  const

This method is used to retrieve the id to a corresponding name of a payee/receiver. An exception will be thrown upon error conditions.

Parameters:
payee QString reference to name of payee
Returns:
MyMoneyPayee object of payee

void MyMoneyFile::modifyPayee ( const MyMoneyPayee payee  ) 

This method is used to modify an existing payee

An exception will be thrown upon error conditions

Parameters:
payee MyMoneyPayee reference to payee information

void MyMoneyFile::removePayee ( const MyMoneyPayee payee  ) 

This method is used to remove an existing payee. An error condition occurs, if the payee is still referenced by a split.

An exception will be thrown upon error conditions

Parameters:
payee MyMoneyPayee reference to payee information

const QValueList<MyMoneyPayee> MyMoneyFile::payeeList ( void   )  const

This method returns a list of the payees inside a MyMoneyStorage object

Returns:
QValueList<MyMoneyPayee> containing the payee information

QString MyMoneyFile::value ( const QString &  key  )  const

This method is used to extract a value from the storage's KeyValueContainer. For details see MyMoneyKeyValueContainer::value().

Parameters:
key const reference to QString containing the key
Returns:
QString containing the value

void MyMoneyFile::setValue ( const QString &  key,
const QString &  val 
)

This method is used to set a value in the storage's KeyValueContainer. For details see MyMoneyKeyValueContainer::setValue().

Parameters:
key const reference to QString containing the key
val const reference to QString containing the value
Note:
Keys starting with the leadin kmm- are reserved for internal use by the MyMoneyFile object.

void MyMoneyFile::deletePair ( const QString &  key  ) 

This method is used to delete a key-value-pair from the storage's KeyValueContainer identified by the parameter key. For details see MyMoneyKeyValueContainer::deletePair().

Parameters:
key const reference to QString containing the key

void MyMoneyFile::addSchedule ( MyMoneySchedule sched  ) 

This method is used to add a scheduled transaction to the engine. It must be sure, that the id of the object is not filled. When the method returns to the caller, the id will be filled with the newly created object id value.

An exception will be thrown upon erronous situations.

Parameters:
sched reference to the MyMoneySchedule object

void MyMoneyFile::modifySchedule ( const MyMoneySchedule sched  ) 

This method is used to modify an existing MyMoneySchedule object. Therefor, the id attribute of the object must be set.

An exception will be thrown upon erronous situations.

Parameters:
sched const reference to the MyMoneySchedule object to be updated

void MyMoneyFile::removeSchedule ( const MyMoneySchedule sched  ) 

This method is used to remove an existing MyMoneySchedule object from the engine. The id attribute of the object must be set.

An exception will be thrown upon erronous situations.

Parameters:
sched const reference to the MyMoneySchedule object to be updated

const MyMoneySchedule MyMoneyFile::schedule ( const QString &  id  )  const

This method is used to retrieve a single MyMoneySchedule object. The id of the object must be supplied in the parameter id.

An exception will be thrown upon erronous situations.

Parameters:
id QString containing the id of the MyMoneySchedule object
Returns:
MyMoneySchedule object

const QValueList<MyMoneySchedule> MyMoneyFile::scheduleList ( const QString &  accountId = QString(),
const MyMoneySchedule::typeE  type = MyMoneySchedule::TYPE_ANY,
const MyMoneySchedule::occurenceE  occurence = MyMoneySchedule::OCCUR_ANY,
const MyMoneySchedule::paymentTypeE  paymentType = MyMoneySchedule::STYPE_ANY,
const QDate &  startDate = QDate(),
const QDate &  endDate = QDate(),
const bool  overdue = false 
) const

This method is used to extract a list of scheduled transactions according to the filter criteria passed as arguments.

Parameters:
accountId only search for scheduled transactions that reference account accountId. If accountId is the empty string, this filter is off. Default is QString().
type only schedules of type type are searched for. See MyMoneySchedule::typeE for details. Default is MyMoneySchedule::TYPE_ANY
occurence only schedules of occurence type occurence are searched for. See MyMoneySchedule::occurenceE for details. Default is MyMoneySchedule::OCCUR_ANY
paymentType only schedules of payment method paymentType are searched for. See MyMoneySchedule::paymentTypeE for details. Default is MyMoneySchedule::STYPE_ANY
startDate only schedules with payment dates after startDate are searched for. Default is all dates (QDate()).
endDate only schedules with payment dates ending prior to endDate are searched for. Default is all dates (QDate()).
overdue if true, only those schedules that are overdue are searched for. Default is false (all schedules will be returned).
Returns:
const QValueList<MyMoneySchedule> list of schedule objects.

const QStringList MyMoneyFile::consistencyCheck ( void   ) 

QString MyMoneyFile::createCategory ( const MyMoneyAccount base,
const QString &  name 
)

createCategory creates a category from a text name.

The whole account hierarchy is created if it doesnt already exist. e.g if name = Bills:Credit Card and base = expense(), Bills will first be checked to see if it exists and created if not. Credit Card will then be created with Bills as it's parent. The Credit Card account will have it's id returned.

Parameters:
base The base account (expense or income)
name The category to create
Returns:
The category account id or empty on error.
Exceptions:
An exception will be thrown, if base is not equal expense() or income().

const QValueList<MyMoneySchedule> MyMoneyFile::scheduleListEx ( int  scheduleTypes,
int  scheduleOcurrences,
int  schedulePaymentTypes,
QDate  startDate,
const QStringList &  accounts = QStringList() 
) const

void MyMoneyFile::addSecurity ( MyMoneySecurity security  ) 

This method is used to add a new security object to the engine. The ID of the object is the trading symbol, so there is no need for an additional ID since the symbol is guaranteed to be unique.

An exception will be thrown upon erronous situations.

Parameters:
security reference to the MyMoneySecurity object

void MyMoneyFile::modifySecurity ( const MyMoneySecurity security  ) 

This method is used to modify an existing MyMoneySchedule object.

An exception will be thrown upon erronous situations.

Parameters:
security reference to the MyMoneySecurity object to be updated

void MyMoneyFile::removeSecurity ( const MyMoneySecurity security  ) 

This method is used to remove an existing MyMoneySecurity object from the engine.

An exception will be thrown upon erronous situations.

Parameters:
security reference to the MyMoneySecurity object to be removed

const MyMoneySecurity& MyMoneyFile::security ( const QString &  id  )  const

This method is used to retrieve a single MyMoneySecurity object. The id of the object must be supplied in the parameter id. If no security with the given id is found, then a corresponding currency is searched. If id is empty, the baseCurrency() is returned.

An exception will be thrown upon erronous situations.

Parameters:
id QString containing the id of the MyMoneySecurity object
Returns:
MyMoneySecurity object

const QValueList<MyMoneySecurity> MyMoneyFile::securityList ( void   )  const

This method is used to retrieve a list of all MyMoneySecurity objects.

void MyMoneyFile::addCurrency ( const MyMoneySecurity currency  ) 

This method is used to add a new currency object to the engine. The ID of the object is the trading symbol, so there is no need for an additional ID since the symbol is guaranteed to be unique.

An exception will be thrown upon erronous situations.

Parameters:
currency reference to the MyMoneySecurity object

void MyMoneyFile::modifyCurrency ( const MyMoneySecurity currency  ) 

This method is used to modify an existing MyMoneySecurity object.

An exception will be thrown upon erronous situations.

Parameters:
currency reference to the MyMoneySecurity object

void MyMoneyFile::removeCurrency ( const MyMoneySecurity currency  ) 

This method is used to remove an existing MyMoneySecurity object from the engine.

An exception will be thrown upon erronous situations.

Parameters:
currency reference to the MyMoneySecurity object

const MyMoneySecurity& MyMoneyFile::currency ( const QString &  id  )  const

This method is used to retrieve a single MyMoneySchedule object. The id of the object must be supplied in the parameter id. If id is empty, this method returns baseCurrency().

An exception will be thrown upon erronous situations.

Parameters:
id QString containing the id of the MyMoneySchedule object
Returns:
MyMoneySchedule object

const QValueList<MyMoneySecurity> MyMoneyFile::currencyList ( void   )  const

This method is used to retrieve the list of all currencies known to the engine.

An exception will be thrown upon erronous situations.

Returns:
QValueList of all MyMoneySecurity objects.

const MyMoneySecurity& MyMoneyFile::baseCurrency ( void   )  const

This method retrieves a MyMoneySecurity object representing the selected base currency. If the base currency is not selected (e.g. due to a previous call to setBaseCurrency()) a standard MyMoneySecurity object will be returned. See MyMoneySecurity() for details.

An exception will be thrown upon erronous situations.

Returns:
MyMoneySecurity describing base currency

const QString& MyMoneyFile::foreignCurrency ( const QString &  first,
const QString &  second 
) const

This method returns the foreign currency of the given two currency ids. If second is the base currency id then first is returned otherwise second is returned.

void MyMoneyFile::setBaseCurrency ( const MyMoneySecurity currency  ) 

This method allows to select the base currency. It does not perform any changes to the data in the engine. It merely stores a reference to the base currency. The currency passed as argument must exist in the engine.

An exception will be thrown upon erronous situations.

Parameters:
currency 

void MyMoneyFile::addPrice ( const MyMoneyPrice price  ) 

This method adds/replaces a price to/from the price list

void MyMoneyFile::removePrice ( const MyMoneyPrice price  ) 

This method removes a price from the price list

const MyMoneyPrice MyMoneyFile::price ( const QString &  fromId,
const QString &  toId = QString(),
const QDate &  date = QDate::currentDate(),
const bool  exactDate = false 
) const

This method is used to retrieve a price for a specific security on a specific date. If there is no price for this date, the last known price for this currency is used. If no price information is available, 1.0 will be returned as price.

Parameters:
fromId the id of the currency in question
toId the id of the currency to convert to (if emtpy, baseCurrency)
date the date for which the price should be returned (default = today)
exactDate if true, entry for date must exist, if false any price information with a date less or equal to date will be returned
Returns:
price found as MyMoneyPrice object
Note:
This throws an exception when the base currency is not set and toId is empty

const MyMoneyPriceList MyMoneyFile::priceList ( void   )  const

This method returns a list of all prices.

Returns:
MyMoneyPriceList of all MyMoneyPrice objects.

bool MyMoneyFile::hasAccount ( const QString &  id,
const QString &  name 
) const

This method allows to interrogate the engine, if a known account with id id has a subaccount with the name name.

Parameters:
id id of the account to look at
name account name that needs to be searched force
Return values:
true account with name name found as subaccounts
false no subaccount present with that name

const QValueList<MyMoneyReport> MyMoneyFile::reportList ( void   )  const

This method is used to retrieve the list of all reports known to the engine.

An exception will be thrown upon erronous situations.

Returns:
QValueList of all MyMoneyReport objects.

void MyMoneyFile::addReport ( MyMoneyReport report  ) 

Adds a report to the file-global institution pool. A respective report-ID will be generated for this object. The ID is stored as QString in the object passed as argument.

An exception will be thrown upon error conditions.

Parameters:
report The complete report information in a MyMoneyReport object

void MyMoneyFile::modifyReport ( const MyMoneyReport report  ) 

Modifies an already existing report in the file global report pool.

An exception will be thrown upon error conditions.

Parameters:
report The complete new report information

unsigned MyMoneyFile::countReports ( void   )  const

This method returns the number of reports currently known to file in the range 0..MAXUINT

Returns:
number of reports known to file

const MyMoneyReport MyMoneyFile::report ( const QString &  id  )  const

This method is used to retrieve a single MyMoneyReport object. The id of the object must be supplied in the parameter id.

An exception will be thrown upon erronous situations.

Parameters:
id QString containing the id of the MyMoneyReport object
Returns:
MyMoneyReport object

void MyMoneyFile::removeReport ( const MyMoneyReport report  ) 

This method is used to remove an existing MyMoneyReport object from the engine. The id attribute of the object must be set.

An exception will be thrown upon erronous situations.

Parameters:
report const reference to the MyMoneyReport object to be updated

const QValueList<MyMoneyBudget> MyMoneyFile::budgetList ( void   )  const

This method is used to retrieve the list of all budgets known to the engine.

An exception will be thrown upon erronous situations.

Returns:
QValueList of all MyMoneyBudget objects.

void MyMoneyFile::addBudget ( MyMoneyBudget budget  ) 

Adds a budget to the file-global institution pool. A respective budget-ID will be generated for this object. The ID is stored as QString in the object passed as argument.

An exception will be thrown upon error conditions.

Parameters:
budget The complete budget information in a MyMoneyBudget object

const MyMoneyBudget MyMoneyFile::budgetByName ( const QString &  budget  )  const

This method is used to retrieve the id to a corresponding name of a budget. An exception will be thrown upon error conditions.

Parameters:
budget QString reference to name of budget
Returns:
MyMoneyBudget refernce to object of budget

void MyMoneyFile::modifyBudget ( const MyMoneyBudget budget  ) 

Modifies an already existing budget in the file global budget pool.

An exception will be thrown upon error conditions.

Parameters:
budget The complete new budget information

unsigned MyMoneyFile::countBudgets ( void   )  const

This method returns the number of budgets currently known to file in the range 0..MAXUINT

Returns:
number of budgets known to file

const MyMoneyBudget MyMoneyFile::budget ( const QString &  id  )  const

This method is used to retrieve a single MyMoneyBudget object. The id of the object must be supplied in the parameter id.

An exception will be thrown upon erronous situations.

Parameters:
id QString containing the id of the MyMoneyBudget object
Returns:
MyMoneyBudget object

void MyMoneyFile::removeBudget ( const MyMoneyBudget budget  ) 

This method is used to remove an existing MyMoneyBudget object from the engine. The id attribute of the object must be set.

An exception will be thrown upon erronous situations.

Parameters:
budget const reference to the MyMoneyBudget object to be updated

bool MyMoneyFile::isReferenced ( const MyMoneyObject obj,
const MyMoneyFileBitArray skipCheck = MyMoneyFileBitArray() 
) const

This method checks, if the given object is referenced by another engine object.

Parameters:
obj const reference to object to be checked
skipCheck MyMoneyFileBitArray with ReferenceCheckBits set for which the check should be skipped
Return values:
false object is not referenced
true institution is referenced

bool MyMoneyFile::referencesClosedAccount ( const MyMoneyTransaction t  )  const

Returns true if any of the accounts referenced by the splits of transaction t is closed.

bool MyMoneyFile::referencesClosedAccount ( const MyMoneySplit s  )  const

Returns true if the accounts referenced by the split s is closed.

bool MyMoneyFile::checkNoUsed ( const QString &  accId,
const QString &  no 
) const

This method checks if the given check no &p no is used in a transaction referencing account &p accId. If accId is empty, false is returned.

Parameters:
accId id of account to checked
no check number to be verified if used or not
Return values:
false no is not in use
true no is already assigned

QString MyMoneyFile::highestCheckNo ( const QString &  accId  )  const

This method returns the highest assigned check no for account accId.

Parameters:
accId id of account to be scanned
Returns:
highest check no. used

void MyMoneyFile::clearCache ( void   ) 

Clear all internal caches (used internally for performance measurements)

void MyMoneyFile::forceDataChanged ( void   )  [inline]

void MyMoneyFile::preloadCache ( void   ) 

void MyMoneyFile::dataChanged ( void   )  [signal]

This signal is emitted whenever any data has been changed in the engine via any of the methods of this object

MyMoneyFile& MyMoneyFile::operator= ( MyMoneyFile  )  [private]

QString MyMoneyFile::locateSubAccount ( const MyMoneyAccount base,
const QString &  category 
) const [private]

void MyMoneyFile::ensureDefaultCurrency ( MyMoneyAccount acc  )  const [private]

void MyMoneyFile::warningMissingRate ( const QString &  fromId,
const QString &  toId 
) const [private]

const MyMoneyAccount MyMoneyFile::createOpeningBalanceAccount ( const MyMoneySecurity security  )  [private]

This method creates an opening balances account. The name is constructed using MyMoneyFile::OpeningBalancesPrefix and appending " (xxx)" in case the security is not the baseCurrency(). The account created will be a sub-account of the standard equity account provided by equity().

Parameters:
security Security for which the account is searched

const MyMoneyAccount MyMoneyFile::openingBalanceAccount_internal ( const MyMoneySecurity security  )  const [private]

void MyMoneyFile::addNotification ( const QString &  id,
bool  reload = true 
) [private]

This method is used to add an id to the list of objects to be removed from the cache. If id is empty, then nothing is added to the list.

Parameters:
id id of object to be notified
reload reload the object (true) or not (false). The default is true
See also:
attach, detach

void MyMoneyFile::clearNotification ( void   )  [private]

This method is used to clear the notification list

void MyMoneyFile::notify ( void   )  [private]

This method is used to clear all objects mentioned in m_notificationList from the cache.

void MyMoneyFile::checkStorage ( void   )  const [inline, private]

This method checks if a storage object is attached and throws and exception if not.

void MyMoneyFile::checkTransaction ( const char *  txt  )  const [private]

This method checks that a transaction has been started with startTransaction() and throws an exception otherwise. Calls checkStorage() to make sure a storage object is present and attached.


Friends And Related Function Documentation

friend class MyMoneyNotifier [friend]


Member Data Documentation

const QString MyMoneyFile::OpeningBalancesPrefix [static]

MyMoneyFile::OpeningBalancesPrefix is a special string used to generate the name for opening balances accounts. See openingBalanceAccount() for details.

const QString MyMoneyFile::AccountSeperator [static]

MyMoneyFile::AccountSeperator is used as the seperator between account names to form a hierarchy.

MyMoneyFile MyMoneyFile::file [static, private]

This member points to the storage strategy

Private* const MyMoneyFile::d [private]

MyMoneyFile* MyMoneyFile::_instance [static, private]


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

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