@ -175,7 +175,7 @@ void MyMoneyFile::addInstitution(MyMoneyInstitution& institution)
{
// perform some checks to see that the institution stuff is OK. For
// now we assume that the institution must have a name, the ID is not set
// and it does not have a tq parent (MyMoneyFile).
// and it does not have a parent (MyMoneyFile).
if ( institution . name ( ) . length ( ) = = 0
| | institution . id ( ) . length ( ) ! = 0 )
@ -318,7 +318,7 @@ void MyMoneyFile::modifyAccount(const MyMoneyAccount& _account)
addNotification ( account . id ( ) ) ;
}
void MyMoneyFile : : reparentAccount ( MyMoneyAccount & account , MyMoneyAccount & tq parent)
void MyMoneyFile : : reparentAccount ( MyMoneyAccount & account , MyMoneyAccount & parent)
{
checkTransaction ( __PRETTY_FUNCTION__ ) ;
@ -326,27 +326,27 @@ void MyMoneyFile::reparentAccount(MyMoneyAccount &account, MyMoneyAccount& tqpar
if ( isStandardAccount ( account . id ( ) ) )
throw new MYMONEYEXCEPTION ( " Unable to reparent the standard account groups " ) ;
if ( account . accountGroup ( ) = = tq parent. accountGroup ( )
| | ( account . accountType ( ) = = MyMoneyAccount : : Income & & tq parent. accountType ( ) = = MyMoneyAccount : : Expense )
| | ( account . accountType ( ) = = MyMoneyAccount : : Expense & & tq parent. accountType ( ) = = MyMoneyAccount : : Income ) ) {
if ( account . accountGroup ( ) = = parent. accountGroup ( )
| | ( account . accountType ( ) = = MyMoneyAccount : : Income & & parent. accountType ( ) = = MyMoneyAccount : : Expense )
| | ( account . accountType ( ) = = MyMoneyAccount : : Expense & & parent. accountType ( ) = = MyMoneyAccount : : Income ) ) {
if ( account . isInvest ( ) & & tq parent. accountType ( ) ! = MyMoneyAccount : : Investment )
if ( account . isInvest ( ) & & parent. accountType ( ) ! = MyMoneyAccount : : Investment )
throw new MYMONEYEXCEPTION ( " Unable to reparent Stock to non-investment account " ) ;
if ( tq parent. accountType ( ) = = MyMoneyAccount : : Investment & & ! account . isInvest ( ) )
if ( parent. accountType ( ) = = MyMoneyAccount : : Investment & & ! account . isInvest ( ) )
throw new MYMONEYEXCEPTION ( " Unable to reparent non-stock to investment account " ) ;
// clear all changed objects from cache
MyMoneyNotifier notifier ( this ) ;
// keep a notification of the current tq parent
// keep a notification of the current parent
addNotification ( account . parentAccountId ( ) ) ;
m_storage - > reparentAccount ( account , tq parent) ;
m_storage - > reparentAccount ( account , parent) ;
// and also keep one for the account itself and the new tq parent
// and also keep one for the account itself and the new parent
addNotification ( account . id ( ) ) ;
addNotification ( tq parent. id ( ) ) ;
addNotification ( parent. id ( ) ) ;
} else
throw new MYMONEYEXCEPTION ( " Unable to reparent to different account type " ) ;
@ -429,14 +429,14 @@ void MyMoneyFile::removeAccount(const MyMoneyAccount& account)
{
checkTransaction ( __PRETTY_FUNCTION__ ) ;
MyMoneyAccount tq parent;
MyMoneyAccount parent;
MyMoneyAccount acc ;
MyMoneyInstitution institution ;
// check that the account and its tq parent exist
// check that the account and its parent exist
// this will throw an exception if the id is unknown
acc = MyMoneyFile : : account ( account . id ( ) ) ;
tq parent = MyMoneyFile : : account ( account . parentAccountId ( ) ) ;
parent = MyMoneyFile : : account ( account . parentAccountId ( ) ) ;
if ( ! acc . institutionId ( ) . isEmpty ( ) )
institution = MyMoneyFile : : institution ( acc . institutionId ( ) ) ;
@ -455,8 +455,8 @@ void MyMoneyFile::removeAccount(const MyMoneyAccount& account)
TQStringList : : ConstIterator it ;
for ( it = acc . accountList ( ) . begin ( ) ; it ! = acc . accountList ( ) . end ( ) ; + + it )
addNotification ( * it ) ;
// don't forget the tq parent and a possible institution
addNotification ( tq parent. id ( ) ) ;
// don't forget the parent and a possible institution
addNotification ( parent. id ( ) ) ;
addNotification ( account . institutionId ( ) ) ;
if ( ! institution . id ( ) . isEmpty ( ) ) {
@ -542,7 +542,7 @@ void MyMoneyFile::removeInstitution(const MyMoneyInstitution& institution)
addNotification ( institution . id ( ) , false ) ;
}
void MyMoneyFile : : addAccount ( MyMoneyAccount & account , MyMoneyAccount & tq parent)
void MyMoneyFile : : addAccount ( MyMoneyAccount & account , MyMoneyAccount & parent)
{
checkTransaction ( __PRETTY_FUNCTION__ ) ;
@ -550,7 +550,7 @@ void MyMoneyFile::addAccount(MyMoneyAccount& account, MyMoneyAccount& tqparent)
// perform some checks to see that the account stuff is OK. For
// now we assume that the account must have a name, has no
// transaction and sub-accounts and tq parent account
// transaction and sub-accounts and parent account
// it's own ID is not set and it does not have a pointer to (MyMoneyFile)
if ( account . name ( ) . length ( ) = = 0 )
@ -563,15 +563,15 @@ void MyMoneyFile::addAccount(MyMoneyAccount& account, MyMoneyAccount& tqparent)
throw new MYMONEYEXCEPTION ( " New account must have no sub-accounts " ) ;
if ( ! account . parentAccountId ( ) . isEmpty ( ) )
throw new MYMONEYEXCEPTION ( " New account must have no tq parent-id" ) ;
throw new MYMONEYEXCEPTION ( " New account must have no parent-id" ) ;
if ( account . accountType ( ) = = MyMoneyAccount : : UnknownAccountType )
throw new MYMONEYEXCEPTION ( " Account has invalid type " ) ;
// make sure, that the tq parent account exists
// make sure, that the parent account exists
// if not, an exception is thrown. If it exists,
// get a copy of the current data
MyMoneyAccount acc = MyMoneyFile : : account ( tq parent. id ( ) ) ;
MyMoneyAccount acc = MyMoneyFile : : account ( parent. id ( ) ) ;
#if 0
// TODO: remove the following code as we now can have multiple accounts
@ -589,22 +589,22 @@ void MyMoneyFile::addAccount(MyMoneyAccount& account, MyMoneyAccount& tqparent)
}
# endif
// FIXME: make sure, that the tq parent has the same type
// FIXME: make sure, that the parent has the same type
// I left it out here because I don't know, if there is
// a tight coupling between e.g. checking accounts and the
// class asset. It certainly does not make sense to create an
// expense account under an income account. Maybe it does, I don't know.
// We enforce, that a stock account can never be a tq parent and
// that the tq parent for a stock account must be an investment. Also,
// an investment cannot have another investment account as it's tq parent
if ( tq parent. isInvest ( ) )
throw new MYMONEYEXCEPTION ( " Stock account cannot be tq parent account" ) ;
// We enforce, that a stock account can never be a parent and
// that the parent for a stock account must be an investment. Also,
// an investment cannot have another investment account as it's parent
if ( parent. isInvest ( ) )
throw new MYMONEYEXCEPTION ( " Stock account cannot be parent account" ) ;
if ( account . isInvest ( ) & & tq parent. accountType ( ) ! = MyMoneyAccount : : Investment )
throw new MYMONEYEXCEPTION ( " Stock account must have investment account as tq parent " ) ;
if ( account . isInvest ( ) & & parent. accountType ( ) ! = MyMoneyAccount : : Investment )
throw new MYMONEYEXCEPTION ( " Stock account must have investment account as parent " ) ;
if ( ! account . isInvest ( ) & & tq parent. accountType ( ) = = MyMoneyAccount : : Investment )
if ( ! account . isInvest ( ) & & parent. accountType ( ) = = MyMoneyAccount : : Investment )
throw new MYMONEYEXCEPTION ( " Investment account can only have stock accounts as tqchildren " ) ;
// clear all changed objects from cache
@ -622,10 +622,10 @@ void MyMoneyFile::addAccount(MyMoneyAccount& account, MyMoneyAccount& tqparent)
account . setOpeningDate ( TQDate : : tqcurrentDate ( ) ) ;
}
account . setParentAccountId ( tq parent. id ( ) ) ;
account . setParentAccountId ( parent. id ( ) ) ;
m_storage - > addAccount ( account ) ;
m_storage - > addAccount ( tq parent, account ) ;
m_storage - > addAccount ( parent, account ) ;
if ( account . institutionId ( ) . length ( ) ! = 0 ) {
institution . addAccountId ( account . id ( ) ) ;
@ -634,7 +634,7 @@ void MyMoneyFile::addAccount(MyMoneyAccount& account, MyMoneyAccount& tqparent)
}
d - > m_cache . preloadAccount ( account ) ;
addNotification ( tq parent. id ( ) ) ;
addNotification ( parent. id ( ) ) ;
}
MyMoneyTransaction MyMoneyFile : : createOpeningBalanceTransaction ( const MyMoneyAccount & acc , const MyMoneyMoney & balance )
@ -793,8 +793,8 @@ const MyMoneyAccount MyMoneyFile::createOpeningBalanceAccount(const MyMoneySecur
acc . setAccountType ( MyMoneyAccount : : Equity ) ;
acc . setCurrencyId ( security . id ( ) ) ;
MyMoneyAccount tq parent = equity ( ) ;
this - > addAccount ( acc , tq parent) ;
MyMoneyAccount parent = equity ( ) ;
this - > addAccount ( acc , parent) ;
return acc ;
}
@ -1351,7 +1351,7 @@ const TQStringList MyMoneyFile::consistencyCheck(void)
TQMap < TQString , bool > interestAccounts ;
MyMoneyAccount tq parent;
MyMoneyAccount parent;
MyMoneyAccount child ;
MyMoneyAccount toplevel ;
@ -1408,14 +1408,14 @@ const TQStringList MyMoneyFile::consistencyCheck(void)
try {
bool dropOut = false ;
while ( ! isStandardAccount ( parentId ) & & ! dropOut ) {
tq parent = account ( parentId ) ;
if ( tq parent. id ( ) = = ( * it_a ) . id ( ) ) {
// tq parent loops, so we need to re-tq parent to toplevel account
// find tq parent account in our list
parent = account ( parentId ) ;
if ( parent. id ( ) = = ( * it_a ) . id ( ) ) {
// parent loops, so we need to re-parent to toplevel account
// find parent account in our list
problemCount + + ;
TQValueList < MyMoneyAccount > : : Iterator it_b ;
for ( it_b = list . begin ( ) ; it_b ! = list . end ( ) ; + + it_b ) {
if ( ( * it_b ) . id ( ) = = tq parent. id ( ) ) {
if ( ( * it_b ) . id ( ) = = parent. id ( ) ) {
if ( problemAccount ! = ( * it_a ) . name ( ) ) {
problemAccount = ( * it_a ) . name ( ) ;
rc < < i18n ( " * Problem with account '%1' " ) . tqarg ( problemAccount ) ;
@ -1432,51 +1432,51 @@ const TQStringList MyMoneyFile::consistencyCheck(void)
}
}
}
parentId = tq parent. parentAccountId ( ) ;
parentId = parent. parentAccountId ( ) ;
}
} catch ( MyMoneyException * e ) {
// if we don't know about a tq parent, we catch it later
// if we don't know about a parent, we catch it later
delete e ;
}
// check that the tq parent exists
// check that the parent exists
parentId = ( * it_a ) . parentAccountId ( ) ;
try {
tq parent = account ( parentId ) ;
if ( ( * it_a ) . accountGroup ( ) ! = tq parent. accountGroup ( ) ) {
parent = account ( parentId ) ;
if ( ( * it_a ) . accountGroup ( ) ! = parent. accountGroup ( ) ) {
problemCount + + ;
if ( problemAccount ! = ( * it_a ) . name ( ) ) {
problemAccount = ( * it_a ) . name ( ) ;
rc < < i18n ( " * Problem with account '%1' " ) . tqarg ( problemAccount ) ;
}
// the tq parent belongs to a different group, so we reconnect to the
// the parent belongs to a different group, so we reconnect to the
// master group account (asset, liability, etc) to which this account
// should belong and update it in the engine.
rc < < i18n ( " * Parent account '%1' belongs to a different group. " ) . tqarg ( tq parent. name ( ) ) ;
rc < < i18n ( " New tq parent account is the top level account '%1'." ) . tqarg ( toplevel . name ( ) ) ;
rc < < i18n ( " * Parent account '%1' belongs to a different group. " ) . tqarg ( parent. name ( ) ) ;
rc < < i18n ( " New parent account is the top level account '%1'." ) . tqarg ( toplevel . name ( ) ) ;
( * it_a ) . setParentAccountId ( toplevel . id ( ) ) ;
// make sure to rebuild the sub-accounts of the top account
// and the one we removed this account from
if ( accountRebuild . contains ( toplevel . id ( ) ) = = 0 )
accountRebuild < < toplevel . id ( ) ;
if ( accountRebuild . contains ( tq parent. id ( ) ) = = 0 )
accountRebuild < < tq parent. id ( ) ;
} else if ( ! tq parent. accountList ( ) . contains ( ( * it_a ) . id ( ) ) ) {
if ( accountRebuild . contains ( parent. id ( ) ) = = 0 )
accountRebuild < < parent. id ( ) ;
} else if ( ! parent. accountList ( ) . contains ( ( * it_a ) . id ( ) ) ) {
problemCount + + ;
if ( problemAccount ! = ( * it_a ) . name ( ) ) {
problemAccount = ( * it_a ) . name ( ) ;
rc < < i18n ( " * Problem with account '%1' " ) . tqarg ( problemAccount ) ;
}
// tq parent exists, but does not have a reference to the account
rc < < i18n ( " * Parent account '%1' does not contain '%2' as sub-account. " ) . tqarg ( tq parent. name ( ) , problemAccount ) ;
if ( accountRebuild . contains ( tq parent. id ( ) ) = = 0 )
accountRebuild < < tq parent. id ( ) ;
// parent exists, but does not have a reference to the account
rc < < i18n ( " * Parent account '%1' does not contain '%2' as sub-account. " ) . tqarg ( parent. name ( ) , problemAccount ) ;
if ( accountRebuild . contains ( parent. id ( ) ) = = 0 )
accountRebuild < < parent. id ( ) ;
}
} catch ( MyMoneyException * e ) {
delete e ;
// apparently, the tq parent does not exist anymore. we reconnect to the
// apparently, the parent does not exist anymore. we reconnect to the
// master group account (asset, liability, etc) to which this account
// should belong and update it in the engine.
problemCount + + ;
@ -1484,8 +1484,8 @@ const TQStringList MyMoneyFile::consistencyCheck(void)
problemAccount = ( * it_a ) . name ( ) ;
rc < < i18n ( " * Problem with account '%1' " ) . tqarg ( problemAccount ) ;
}
rc < < i18n ( " * The tq parent with id %1 does not exist anymore." ) . tqarg ( parentId ) ;
rc < < i18n ( " New tq parent account is the top level account '%1'." ) . tqarg ( toplevel . name ( ) ) ;
rc < < i18n ( " * The parent with id %1 does not exist anymore." ) . tqarg ( parentId ) ;
rc < < i18n ( " New parent account is the top level account '%1'." ) . tqarg ( toplevel . name ( ) ) ;
( * it_a ) . setParentAccountId ( toplevel . id ( ) ) ;
addNotification ( ( * it_a ) . id ( ) ) ;
@ -1777,7 +1777,7 @@ TQString MyMoneyFile::createCategory(const MyMoneyAccount& base, const TQString&
{
checkTransaction ( __PRETTY_FUNCTION__ ) ;
MyMoneyAccount tq parent = base ;
MyMoneyAccount parent = base ;
TQString categoryText ;
if ( base . id ( ) ! = expense ( ) . id ( ) & & base . id ( ) ! = income ( ) . id ( ) )
@ -1802,7 +1802,7 @@ TQString MyMoneyFile::createCategory(const MyMoneyAccount& base, const TQString&
{
TQString categoryId = categoryToAccount ( categoryText ) ;
if ( categoryId . isEmpty ( ) )
addAccount ( categoryAccount , tq parent) ;
addAccount ( categoryAccount , parent) ;
else
{
categoryAccount = account ( categoryId ) ;
@ -1812,13 +1812,13 @@ TQString MyMoneyFile::createCategory(const MyMoneyAccount& base, const TQString&
{
qDebug ( " Unable to add account %s, %s, %s: %s " ,
categoryAccount . name ( ) . latin1 ( ) ,
tq parent. name ( ) . latin1 ( ) ,
parent. name ( ) . latin1 ( ) ,
categoryText . latin1 ( ) ,
e - > what ( ) . latin1 ( ) ) ;
delete e ;
}
tq parent = categoryAccount ;
parent = categoryAccount ;
}
return categoryToAccount ( name ) ;