summaryrefslogtreecommitdiffstats
path: root/kmymoney2/mymoney/mymoneyforecast.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-07-05 06:00:29 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-07-05 06:00:29 +0000
commitfecb0e67b23e8b83ba7fc881bb57bc48c0852d62 (patch)
tree6b8614802f0d01b353bc9ba78aff2090846c198e /kmymoney2/mymoney/mymoneyforecast.cpp
parentdadc34655c3ab961b0b0b94a10eaaba710f0b5e8 (diff)
downloadkmymoney-fecb0e67b23e8b83ba7fc881bb57bc48c0852d62.tar.gz
kmymoney-fecb0e67b23e8b83ba7fc881bb57bc48c0852d62.zip
TQt4 port kmymoney
This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kmymoney@1239855 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kmymoney2/mymoney/mymoneyforecast.cpp')
-rw-r--r--kmymoney2/mymoney/mymoneyforecast.cpp306
1 files changed, 153 insertions, 153 deletions
diff --git a/kmymoney2/mymoney/mymoneyforecast.cpp b/kmymoney2/mymoney/mymoneyforecast.cpp
index 56125ea..59a565d 100644
--- a/kmymoney2/mymoney/mymoneyforecast.cpp
+++ b/kmymoney2/mymoney/mymoneyforecast.cpp
@@ -22,8 +22,8 @@
// ----------------------------------------------------------------------------
// QT Includes
-#include <qstring.h>
-#include <qdatetime.h>
+#include <tqstring.h>
+#include <tqdatetime.h>
// ----------------------------------------------------------------------------
// KDE Includes
@@ -47,8 +47,8 @@ MyMoneyForecast::MyMoneyForecast() :
{
setForecastCycles(KMyMoneyGlobalSettings::forecastCycles());
setAccountsCycle(KMyMoneyGlobalSettings::forecastAccountCycle());
- setHistoryStartDate(QDate::currentDate().addDays(-forecastCycles()*accountsCycle()));
- setHistoryEndDate(QDate::currentDate().addDays(-1));
+ setHistoryStartDate(TQDate::tqcurrentDate().addDays(-forecastCycles()*accountsCycle()));
+ setHistoryEndDate(TQDate::tqcurrentDate().addDays(-1));
setForecastDays(KMyMoneyGlobalSettings::forecastDays());
setBeginForecastDay(KMyMoneyGlobalSettings::beginForecastDay());
setForecastMethod(KMyMoneyGlobalSettings::forecastMethod());
@@ -75,12 +75,12 @@ void MyMoneyForecast::doForecast()
//initialize global variables
setForecastDays(fDays);
- setForecastStartDate(QDate::currentDate().addDays(1));
- setForecastEndDate(QDate::currentDate().addDays(fDays));
+ setForecastStartDate(TQDate::tqcurrentDate().addDays(1));
+ setForecastEndDate(TQDate::tqcurrentDate().addDays(fDays));
setAccountsCycle(fAccCycle);
setForecastCycles(fCycles);
setHistoryStartDate(forecastCycles() * accountsCycle());
- setHistoryEndDate(QDate::currentDate().addDays(-1)); //yesterday
+ setHistoryEndDate(TQDate::tqcurrentDate().addDays(-1)); //yesterday
//clear all data before calculating
m_accountListPast.clear();
@@ -120,22 +120,22 @@ void MyMoneyForecast::pastTransactions()
filter.setDateFilter(historyStartDate(), historyEndDate());
filter.setReportAllSplits(false);
- QValueList<MyMoneyTransaction> transactions = file->transactionList(filter);
- QValueList<MyMoneyTransaction>::const_iterator it_t = transactions.begin();
+ TQValueList<MyMoneyTransaction> transactions = file->transactionList(filter);
+ TQValueList<MyMoneyTransaction>::const_iterator it_t = transactions.begin();
//Check past transactions
for(; it_t != transactions.end(); ++it_t ) {
- const QValueList<MyMoneySplit>& splits = (*it_t).splits();
- QValueList<MyMoneySplit>::const_iterator it_s = splits.begin();
+ const TQValueList<MyMoneySplit>& splits = (*it_t).splits();
+ TQValueList<MyMoneySplit>::const_iterator it_s = splits.begin();
for(; it_s != splits.end(); ++it_s ) {
if(!(*it_s).shares().isZero()) {
MyMoneyAccount acc = file->account((*it_s).accountId());
//workaround for stock accounts which have faulty opening dates
- QDate openingDate;
+ TQDate openingDate;
if(acc.accountType() == MyMoneyAccount::Stock) {
- MyMoneyAccount parentAccount = file->account(acc.parentAccountId());
- openingDate = parentAccount.openingDate();
+ MyMoneyAccount tqparentAccount = file->account(acc.tqparentAccountId());
+ openingDate = tqparentAccount.openingDate();
} else {
openingDate = acc.openingDate();
}
@@ -163,11 +163,11 @@ void MyMoneyForecast::pastTransactions()
purgeForecastAccountsList(m_accountListPast);
//calculate running sum
- QMap<QString, QString>::Iterator it_n;
+ TQMap<TQString, TQString>::Iterator it_n;
for(it_n = m_nameIdx.begin(); it_n != m_nameIdx.end(); ++it_n) {
MyMoneyAccount acc = file->account(*it_n);
m_accountListPast[acc.id()][historyStartDate().addDays(-1)] = file->balance(acc.id(), historyStartDate().addDays(-1));
- for(QDate it_date = historyStartDate(); it_date <= historyEndDate(); ) {
+ for(TQDate it_date = historyStartDate(); it_date <= historyEndDate(); ) {
m_accountListPast[acc.id()][it_date] += m_accountListPast[acc.id()][it_date.addDays(-1)]; //Running sum
it_date = it_date.addDays(1);
}
@@ -185,7 +185,7 @@ void MyMoneyForecast::pastTransactions()
MyMoneyMoney rate = MyMoneyMoney ( 1, 1 ); //set the default value
MyMoneyPrice price;
- for ( QDate it_date = historyStartDate().addDays(-1) ; it_date <= historyEndDate();) {
+ for ( TQDate it_date = historyStartDate().addDays(-1) ; it_date <= historyEndDate();) {
//get the price for the tradingCurrency that day
price = file->price ( undersecurity.id(), undersecurity.tradingCurrency(), it_date );
if ( price.isValid() )
@@ -207,7 +207,7 @@ bool MyMoneyForecast::isForecastAccount(const MyMoneyAccount& acc)
{
setForecastAccountList();
}
- QMap<QString, QString>::Iterator it_n;
+ TQMap<TQString, TQString>::Iterator it_n;
for(it_n = m_nameIdx.begin(); it_n != m_nameIdx.end(); ++it_n) {
if(*it_n == acc.id())
{
@@ -224,7 +224,7 @@ void MyMoneyForecast::calculateAccountTrendList()
int totalWeight = 0;
//Calculate account trends
- QMap<QString, QString>::Iterator it_n;
+ TQMap<TQString, TQString>::Iterator it_n;
for(it_n = m_nameIdx.begin(); it_n != m_nameIdx.end(); ++it_n) {
MyMoneyAccount acc = file->account(*it_n);
m_accountTrendList[acc.id()][0] = MyMoneyMoney(0,1); // for today, the trend is 0
@@ -232,10 +232,10 @@ void MyMoneyForecast::calculateAccountTrendList()
auxForecastTerms = forecastCycles();
if(skipOpeningDate()) {
- QDate openingDate;
+ TQDate openingDate;
if(acc.accountType() == MyMoneyAccount::Stock) {
- MyMoneyAccount parentAccount = file->account(acc.parentAccountId());
- openingDate = parentAccount.openingDate();
+ MyMoneyAccount tqparentAccount = file->account(acc.tqparentAccountId());
+ openingDate = tqparentAccount.openingDate();
} else {
openingDate = acc.openingDate();
}
@@ -284,14 +284,14 @@ void MyMoneyForecast::calculateAccountTrendList()
}
}
-QValueList<MyMoneyAccount> MyMoneyForecast::forecastAccountList(void)
+TQValueList<MyMoneyAccount> MyMoneyForecast::forecastAccountList(void)
{
MyMoneyFile* file = MyMoneyFile::instance();
- QValueList<MyMoneyAccount> accList;
+ TQValueList<MyMoneyAccount> accList;
//Get all accounts from the file and check if they are of the right type to calculate forecast
file->accountList(accList);
- QValueList<MyMoneyAccount>::iterator accList_t = accList.begin();
+ TQValueList<MyMoneyAccount>::iterator accList_t = accList.begin();
for(; accList_t != accList.end(); ) {
MyMoneyAccount acc = *accList_t;
if(acc.isClosed() //check the account is not closed
@@ -306,15 +306,15 @@ QValueList<MyMoneyAccount> MyMoneyForecast::forecastAccountList(void)
return accList;
}
-QValueList<MyMoneyAccount> MyMoneyForecast::accountList(void)
+TQValueList<MyMoneyAccount> MyMoneyForecast::accountList(void)
{
MyMoneyFile* file = MyMoneyFile::instance();
- QValueList<MyMoneyAccount> accList;
- QStringList emptyStringList;
+ TQValueList<MyMoneyAccount> accList;
+ TQStringList emptyStringList;
//Get all accounts from the file and check if they are present
file->accountList(accList, emptyStringList, false);
- QValueList<MyMoneyAccount>::iterator accList_t = accList.begin();
+ TQValueList<MyMoneyAccount>::iterator accList_t = accList.begin();
for(; accList_t != accList.end(); ) {
MyMoneyAccount acc = *accList_t;
if(!isForecastAccount( acc ) ) {
@@ -332,8 +332,8 @@ MyMoneyMoney MyMoneyForecast::calculateAccountTrend(const MyMoneyAccount& acc, i
MyMoneyFile* file = MyMoneyFile::instance();
MyMoneyTransactionFilter filter;
MyMoneyMoney netIncome;
- QDate startDate;
- QDate openingDate = acc.openingDate();
+ TQDate startDate;
+ TQDate openingDate = acc.openingDate();
//validate arguments
if(trendDays < 1)
@@ -343,14 +343,14 @@ MyMoneyMoney MyMoneyForecast::calculateAccountTrend(const MyMoneyAccount& acc, i
//If it is a new account, we don't take into account the first day
//because it is usually a weird one and it would mess up the trend
- if(openingDate.daysTo(QDate::currentDate())<trendDays){
+ if(openingDate.daysTo(TQDate::tqcurrentDate())<trendDays){
startDate = (acc.openingDate()).addDays(1);
}
else {
- startDate = QDate::currentDate().addDays(-trendDays);
+ startDate = TQDate::tqcurrentDate().addDays(-trendDays);
}
//get all transactions for the period
- filter.setDateFilter(startDate, QDate::currentDate());
+ filter.setDateFilter(startDate, TQDate::tqcurrentDate());
if(acc.accountGroup() == MyMoneyAccount::Income
|| acc.accountGroup() == MyMoneyAccount::Expense) {
filter.addCategory(acc.id());
@@ -359,13 +359,13 @@ MyMoneyMoney MyMoneyForecast::calculateAccountTrend(const MyMoneyAccount& acc, i
}
filter.setReportAllSplits(false);
- QValueList<MyMoneyTransaction> transactions = file->transactionList(filter);
- QValueList<MyMoneyTransaction>::const_iterator it_t = transactions.begin();
+ TQValueList<MyMoneyTransaction> transactions = file->transactionList(filter);
+ TQValueList<MyMoneyTransaction>::const_iterator it_t = transactions.begin();
//add all transactions for that account
for(; it_t != transactions.end(); ++it_t ) {
- const QValueList<MyMoneySplit>& splits = (*it_t).splits();
- QValueList<MyMoneySplit>::const_iterator it_s = splits.begin();
+ const TQValueList<MyMoneySplit>& splits = (*it_t).splits();
+ TQValueList<MyMoneySplit>::const_iterator it_s = splits.begin();
for(; it_s != splits.end(); ++it_s ) {
if(!(*it_s).shares().isZero()) {
if(acc.id()==(*it_s).accountId()) netIncome += (*it_s).value();
@@ -377,8 +377,8 @@ MyMoneyMoney MyMoneyForecast::calculateAccountTrend(const MyMoneyAccount& acc, i
MyMoneyMoney accTrend;
//don't take into account the first day of the account
- if(openingDate.daysTo(QDate::currentDate())<trendDays) {
- accTrend = netIncome/MyMoneyMoney(openingDate.daysTo(QDate::currentDate())-1,1);
+ if(openingDate.daysTo(TQDate::tqcurrentDate())<trendDays) {
+ accTrend = netIncome/MyMoneyMoney(openingDate.daysTo(TQDate::tqcurrentDate())-1,1);
} else {
accTrend = netIncome/MyMoneyMoney(trendDays,1);
}
@@ -463,7 +463,7 @@ void MyMoneyForecast::calculateHistoricDailyBalances()
calculateAccountTrendList();
//Calculate account daily balances
- QMap<QString, QString>::ConstIterator it_n;
+ TQMap<TQString, TQString>::ConstIterator it_n;
for(it_n = m_nameIdx.begin(); it_n != m_nameIdx.end(); ++it_n) {
MyMoneyAccount acc = file->account(*it_n);
@@ -474,7 +474,7 @@ void MyMoneyForecast::calculateHistoricDailyBalances()
case 0:
case 1:
{
- for(QDate f_day = forecastStartDate(); f_day <= forecastEndDate(); ) {
+ for(TQDate f_day = forecastStartDate(); f_day <= forecastEndDate(); ) {
for(int t_day = 1; t_day <= accountsCycle(); ++t_day) {
MyMoneyMoney balanceDayBefore = m_accountList[acc.id()][(f_day.addDays(-1))];//balance of the day before
MyMoneyMoney accountDailyTrend = m_accountTrendList[acc.id()][t_day]; //trend for that day
@@ -490,10 +490,10 @@ void MyMoneyForecast::calculateHistoricDailyBalances()
break;
case 2:
{
- QDate baseDate = QDate::currentDate().addDays(-accountsCycle());
+ TQDate baseDate = TQDate::tqcurrentDate().addDays(-accountsCycle());
for(int t_day = 1; t_day <= accountsCycle(); ++t_day) {
int f_day = 1;
- QDate fDate = baseDate.addDays(accountsCycle()+1);
+ TQDate fDate = baseDate.addDays(accountsCycle()+1);
while (fDate <= forecastEndDate()) {
//the calculation is based on the balance for the last month, that is then multiplied by the trend
@@ -509,7 +509,7 @@ void MyMoneyForecast::calculateHistoricDailyBalances()
}
}
-MyMoneyMoney MyMoneyForecast::forecastBalance(const MyMoneyAccount& acc, QDate forecastDate)
+MyMoneyMoney MyMoneyForecast::forecastBalance(const MyMoneyAccount& acc, TQDate forecastDate)
{
dailyBalances balance;
@@ -522,7 +522,7 @@ MyMoneyMoney MyMoneyForecast::forecastBalance(const MyMoneyAccount& acc, QDate f
}
balance = m_accountList[acc.id() ];
- if ( balance.contains ( forecastDate ) )
+ if ( balance.tqcontains ( forecastDate ) )
{ //if the date is not in the forecast, it returns 0
MM_amount = m_accountList[acc.id() ][forecastDate];
}
@@ -536,7 +536,7 @@ MyMoneyMoney MyMoneyForecast::forecastBalance(const MyMoneyAccount& acc, QDate f
*/
MyMoneyMoney MyMoneyForecast::forecastBalance (const MyMoneyAccount& acc, int offset )
{
- QDate forecastDate = QDate::currentDate().addDays(offset);
+ TQDate forecastDate = TQDate::tqcurrentDate().addDays(offset);
return forecastBalance(acc, forecastDate);
}
@@ -555,7 +555,7 @@ void MyMoneyForecast::doFutureScheduledForecast(void)
purgeForecastAccountsList(m_accountList);
//adjust value of investments to deep currency
- QMap<QString, QString>::ConstIterator it_n;
+ TQMap<TQString, TQString>::ConstIterator it_n;
for ( it_n = m_nameIdx.begin(); it_n != m_nameIdx.end(); ++it_n ) {
MyMoneyAccount acc = file->account ( *it_n );
@@ -570,7 +570,7 @@ void MyMoneyForecast::doFutureScheduledForecast(void)
MyMoneyMoney rate = MyMoneyMoney ( 1, 1 );
MyMoneyPrice price;
- for (QDate it_day = QDate::currentDate(); it_day <= forecastEndDate(); ) {
+ for (TQDate it_day = TQDate::tqcurrentDate(); it_day <= forecastEndDate(); ) {
//get the price for the tradingCurrency that day
price = file->price ( undersecurity.id(), undersecurity.tradingCurrency(), it_day );
if ( price.isValid() )
@@ -596,12 +596,12 @@ void MyMoneyForecast::addFutureTransactions(void)
filter.setDateFilter(forecastStartDate(), forecastEndDate());
filter.setReportAllSplits(false);
- QValueList<MyMoneyTransaction> transactions = file->transactionList(filter);
- QValueList<MyMoneyTransaction>::const_iterator it_t = transactions.begin();
+ TQValueList<MyMoneyTransaction> transactions = file->transactionList(filter);
+ TQValueList<MyMoneyTransaction>::const_iterator it_t = transactions.begin();
for(; it_t != transactions.end(); ++it_t ) {
- const QValueList<MyMoneySplit>& splits = (*it_t).splits();
- QValueList<MyMoneySplit>::const_iterator it_s = splits.begin();
+ const TQValueList<MyMoneySplit>& splits = (*it_t).splits();
+ TQValueList<MyMoneySplit>::const_iterator it_s = splits.begin();
for(; it_s != splits.end(); ++it_s ) {
if(!(*it_s).shares().isZero()) {
MyMoneyAccount acc = file->account((*it_s).accountId());
@@ -621,17 +621,17 @@ void MyMoneyForecast::addFutureTransactions(void)
}
#if 0
- QFile trcFile("forecast.csv");
+ TQFile trcFile("forecast.csv");
trcFile.open(IO_WriteOnly);
- QTextStream s(&trcFile);
+ TQTextStream s(&trcFile);
{
s << "Already present transactions\n";
- QMap<QString, dailyBalances>::Iterator it_a;
- QMap<QString, QString>::ConstIterator it_n;
+ TQMap<TQString, dailyBalances>::Iterator it_a;
+ TQMap<TQString, TQString>::ConstIterator it_n;
for(it_n = m_nameIdx.begin(); it_n != m_nameIdx.end(); ++it_n) {
MyMoneyAccount acc = file->account(*it_n);
- it_a = m_accountList.find(*it_n);
+ it_a = m_accountList.tqfind(*it_n);
s << "\"" << acc.name() << "\",";
for(int i = 0; i < 90; ++i) {
s << "\"" << (*it_a)[i].formatMoney("") << "\",";
@@ -648,12 +648,12 @@ void MyMoneyForecast::addScheduledTransactions (void)
MyMoneyFile* file = MyMoneyFile::instance();
// now process all the schedules that may have an impact
- QValueList<MyMoneySchedule> schedule;
+ TQValueList<MyMoneySchedule> schedule;
schedule = file->scheduleList("", MyMoneySchedule::TYPE_ANY, MyMoneySchedule::OCCUR_ANY, MyMoneySchedule::STYPE_ANY,
- QDate::currentDate(), forecastEndDate());
+ TQDate::tqcurrentDate(), forecastEndDate());
if(schedule.count() > 0) {
- QValueList<MyMoneySchedule>::Iterator it;
+ TQValueList<MyMoneySchedule>::Iterator it;
do {
qBubbleSort(schedule);
it = schedule.begin();
@@ -665,13 +665,13 @@ void MyMoneyForecast::addScheduledTransactions (void)
continue;
}
- QDate date = (*it).nextPayment((*it).lastPayment());
+ TQDate date = (*it).nextPayment((*it).lastPayment());
if(!date.isValid()) {
schedule.remove(it);
continue;
}
- QDate nextDate = (*it).adjustedNextPayment((*it).lastPayment());
+ TQDate nextDate = (*it).adjustedNextPayment((*it).lastPayment());
if (nextDate > forecastEndDate()) {
// We're done with this schedule, let's move on to the next
schedule.remove(it);
@@ -688,22 +688,22 @@ void MyMoneyForecast::addScheduledTransactions (void)
MyMoneyTransaction t = (*it).transaction();
// only process the entry, if it is still active
- if(!(*it).isFinished() && nextDate != QDate()) {
+ if(!(*it).isFinished() && nextDate != TQDate()) {
// make sure we have all 'starting balances' so that the autocalc works
- QValueList<MyMoneySplit>::const_iterator it_s;
- QMap<QString, MyMoneyMoney> balanceMap;
+ TQValueList<MyMoneySplit>::const_iterator it_s;
+ TQMap<TQString, MyMoneyMoney> balanceMap;
for(it_s = t.splits().begin(); it_s != t.splits().end(); ++it_s ) {
MyMoneyAccount acc = file->account((*it_s).accountId());
if(isForecastAccount(acc)) {
// collect all overdues on the first day
- QDate forecastDate = nextDate;
- if(QDate::currentDate() >= nextDate)
- forecastDate = QDate::currentDate().addDays(1);
+ TQDate forecastDate = nextDate;
+ if(TQDate::tqcurrentDate() >= nextDate)
+ forecastDate = TQDate::tqcurrentDate().addDays(1);
dailyBalances balance;
balance = m_accountList[acc.id()];
- for(QDate f_day = QDate::currentDate(); f_day < forecastDate; ) {
+ for(TQDate f_day = TQDate::tqcurrentDate(); f_day < forecastDate; ) {
balanceMap[acc.id()] += m_accountList[acc.id()][f_day];
f_day = f_day.addDays(1);
}
@@ -719,14 +719,14 @@ void MyMoneyForecast::addScheduledTransactions (void)
if(isForecastAccount(acc)) {
dailyBalances balance;
balance = m_accountList[acc.id()];
- //int offset = QDate::currentDate().daysTo(nextDate);
+ //int offset = TQDate::tqcurrentDate().daysTo(nextDate);
//if(offset <= 0) { // collect all overdues on the first day
// offset = 1;
//}
// collect all overdues on the first day
- QDate forecastDate = nextDate;
- if(QDate::currentDate() >= nextDate)
- forecastDate = QDate::currentDate().addDays(1);
+ TQDate forecastDate = nextDate;
+ if(TQDate::tqcurrentDate() >= nextDate)
+ forecastDate = TQDate::tqcurrentDate().addDays(1);
if(acc.accountType() == MyMoneyAccount::Income) {
balance[forecastDate] += ((*it_s).shares() * MyMoneyMoney(-1, 1));
@@ -757,11 +757,11 @@ void MyMoneyForecast::addScheduledTransactions (void)
#if 0
{
s << "\n\nAdded scheduled transactions\n";
- QMap<QString, dailyBalances>::Iterator it_a;
- QMap<QString, QString>::ConstIterator it_n;
+ TQMap<TQString, dailyBalances>::Iterator it_a;
+ TQMap<TQString, TQString>::ConstIterator it_n;
for(it_n = m_nameIdx.begin(); it_n != m_nameIdx.end(); ++it_n) {
MyMoneyAccount acc = file->account(*it_n);
- it_a = m_accountList.find(*it_n);
+ it_a = m_accountList.tqfind(*it_n);
s << "\"" << acc.name() << "\",";
for(int i = 0; i < 90; ++i) {
s << "\"" << (*it_a)[i].formatMoney("") << "\",";
@@ -777,14 +777,14 @@ void MyMoneyForecast::calculateScheduledDailyBalances (void)
MyMoneyFile* file = MyMoneyFile::instance();
//Calculate account daily balances
- QMap<QString, QString>::ConstIterator it_n;
+ TQMap<TQString, TQString>::ConstIterator it_n;
for(it_n = m_nameIdx.begin(); it_n != m_nameIdx.end(); ++it_n) {
MyMoneyAccount acc = file->account(*it_n);
//set the starting balance of the account
setStartingBalance(acc);
- for(QDate f_day = forecastStartDate(); f_day <= forecastEndDate(); ) {
+ for(TQDate f_day = forecastStartDate(); f_day <= forecastEndDate(); ) {
MyMoneyMoney balanceDayBefore = m_accountList[acc.id()][(f_day.addDays(-1))];//balance of the day before
m_accountList[acc.id()][f_day] += balanceDayBefore; //running sum
f_day = f_day.addDays(1);
@@ -796,7 +796,7 @@ void MyMoneyForecast::calculateScheduledDailyBalances (void)
int MyMoneyForecast::daysToMinimumBalance(const MyMoneyAccount& acc)
{
- QString minimumBalance = acc.value("minBalanceAbsolute");
+ TQString minimumBalance = acc.value("minBalanceAbsolute");
MyMoneyMoney minBalance = MyMoneyMoney(minimumBalance);
dailyBalances balance;
@@ -807,9 +807,9 @@ int MyMoneyForecast::daysToMinimumBalance(const MyMoneyAccount& acc)
balance = m_accountList[acc.id()];
- for(QDate it_day = QDate::currentDate() ; it_day <= forecastEndDate(); ) {
+ for(TQDate it_day = TQDate::tqcurrentDate() ; it_day <= forecastEndDate(); ) {
if(minBalance > balance[it_day]) {
- return QDate::currentDate().daysTo(it_day);
+ return TQDate::tqcurrentDate().daysTo(it_day);
}
it_day = it_day.addDays(1);
}
@@ -828,20 +828,20 @@ int MyMoneyForecast::daysToZeroBalance(const MyMoneyAccount& acc)
balance = m_accountList[acc.id()];
if (acc.accountGroup() == MyMoneyAccount::Asset) {
- for (QDate it_day = QDate::currentDate() ; it_day <= forecastEndDate(); )
+ for (TQDate it_day = TQDate::tqcurrentDate() ; it_day <= forecastEndDate(); )
{
if ( balance[it_day] < MyMoneyMoney ( 0, 1 ) )
{
- return QDate::currentDate().daysTo(it_day);
+ return TQDate::tqcurrentDate().daysTo(it_day);
}
it_day = it_day.addDays(1);
}
} else if (acc.accountGroup() == MyMoneyAccount::Liability) {
- for (QDate it_day = QDate::currentDate() ; it_day <= forecastEndDate(); )
+ for (TQDate it_day = TQDate::tqcurrentDate() ; it_day <= forecastEndDate(); )
{
if ( balance[it_day] > MyMoneyMoney ( 0, 1 ) )
{
- return QDate::currentDate().daysTo(it_day);
+ return TQDate::tqcurrentDate().daysTo(it_day);
}
it_day = it_day.addDays(1);
}
@@ -853,10 +853,10 @@ void MyMoneyForecast::setForecastAccountList(void)
{
//get forecast accounts
- QValueList<MyMoneyAccount> accList;
+ TQValueList<MyMoneyAccount> accList;
accList = forecastAccountList();
- QValueList<MyMoneyAccount>::const_iterator accList_t = accList.begin();
+ TQValueList<MyMoneyAccount>::const_iterator accList_t = accList.begin();
for(; accList_t != accList.end(); ++accList_t ) {
MyMoneyAccount acc = *accList_t;
// check if this is a new account for us
@@ -882,24 +882,24 @@ MyMoneyMoney MyMoneyForecast::accountTotalVariation(const MyMoneyAccount& acc)
{
MyMoneyMoney totalVariation;
- totalVariation = forecastBalance(acc, forecastEndDate()) - forecastBalance(acc, QDate::currentDate());
+ totalVariation = forecastBalance(acc, forecastEndDate()) - forecastBalance(acc, TQDate::tqcurrentDate());
return totalVariation;
}
-QValueList<QDate> MyMoneyForecast::accountMinimumBalanceDateList(const MyMoneyAccount& acc)
+TQValueList<TQDate> MyMoneyForecast::accountMinimumBalanceDateList(const MyMoneyAccount& acc)
{
- QValueList<QDate> minBalanceList;
+ TQValueList<TQDate> minBalanceList;
int daysToBeginDay;
- daysToBeginDay = QDate::currentDate().daysTo(beginForecastDate());
+ daysToBeginDay = TQDate::tqcurrentDate().daysTo(beginForecastDate());
for(int t_cycle = 0; ((t_cycle * accountsCycle()) + daysToBeginDay) < forecastDays() ; ++t_cycle) {
MyMoneyMoney minBalance = forecastBalance(acc, (t_cycle * accountsCycle() + daysToBeginDay));
- QDate minDate = QDate::currentDate().addDays(t_cycle * accountsCycle() + daysToBeginDay);
+ TQDate minDate = TQDate::tqcurrentDate().addDays(t_cycle * accountsCycle() + daysToBeginDay);
for(int t_day = 1; t_day <= accountsCycle() ; ++t_day) {
if( minBalance > forecastBalance(acc, (t_cycle * accountsCycle()) + daysToBeginDay + t_day) ) {
minBalance = forecastBalance(acc, (t_cycle * accountsCycle()) + daysToBeginDay + t_day );
- minDate = QDate::currentDate().addDays( (t_cycle * accountsCycle()) + daysToBeginDay + t_day);
+ minDate = TQDate::tqcurrentDate().addDays( (t_cycle * accountsCycle()) + daysToBeginDay + t_day);
}
}
minBalanceList.append(minDate);
@@ -907,21 +907,21 @@ QValueList<QDate> MyMoneyForecast::accountMinimumBalanceDateList(const MyMoneyAc
return minBalanceList;
}
-QValueList<QDate> MyMoneyForecast::accountMaximumBalanceDateList(const MyMoneyAccount& acc)
+TQValueList<TQDate> MyMoneyForecast::accountMaximumBalanceDateList(const MyMoneyAccount& acc)
{
- QValueList<QDate> maxBalanceList;
+ TQValueList<TQDate> maxBalanceList;
int daysToBeginDay;
- daysToBeginDay = QDate::currentDate().daysTo(beginForecastDate());
+ daysToBeginDay = TQDate::tqcurrentDate().daysTo(beginForecastDate());
for(int t_cycle = 0; ((t_cycle * accountsCycle()) + daysToBeginDay) < forecastDays() ; ++t_cycle) {
MyMoneyMoney maxBalance = forecastBalance(acc, ((t_cycle * accountsCycle()) + daysToBeginDay));
- QDate maxDate = QDate::currentDate().addDays((t_cycle * accountsCycle()) + daysToBeginDay);
+ TQDate maxDate = TQDate::tqcurrentDate().addDays((t_cycle * accountsCycle()) + daysToBeginDay);
for(int t_day = 0; t_day < accountsCycle() ; ++t_day) {
if( maxBalance < forecastBalance(acc, (t_cycle * accountsCycle()) + daysToBeginDay + t_day) ) {
maxBalance = forecastBalance(acc, (t_cycle * accountsCycle()) + daysToBeginDay + t_day );
- maxDate = QDate::currentDate().addDays((t_cycle * accountsCycle()) + daysToBeginDay + t_day);
+ maxDate = TQDate::tqcurrentDate().addDays((t_cycle * accountsCycle()) + daysToBeginDay + t_day);
}
}
maxBalanceList.append(maxDate);
@@ -943,53 +943,53 @@ int MyMoneyForecast::calculateBeginForecastDay()
int fDays = forecastDays();
int beginDay = beginForecastDay();
int accCycle = accountsCycle();
- QDate beginDate;
+ TQDate beginDate;
//if 0, beginDate is current date and forecastDays remains unchanged
if(beginDay == 0) {
- setBeginForecastDate(QDate::currentDate());
+ setBeginForecastDate(TQDate::tqcurrentDate());
return fDays;
}
//adjust if beginDay more than days of current month
- if(QDate::currentDate().daysInMonth() < beginDay)
- beginDay = QDate::currentDate().daysInMonth();
+ if(TQDate::tqcurrentDate().daysInMonth() < beginDay)
+ beginDay = TQDate::tqcurrentDate().daysInMonth();
//if beginDay still to come, calculate and return
- if(QDate::currentDate().day() <= beginDay) {
- beginDate = QDate( QDate::currentDate().year(), QDate::currentDate().month(), beginDay);
- fDays += QDate::currentDate().daysTo(beginDate);
+ if(TQDate::tqcurrentDate().day() <= beginDay) {
+ beginDate = TQDate( TQDate::tqcurrentDate().year(), TQDate::tqcurrentDate().month(), beginDay);
+ fDays += TQDate::tqcurrentDate().daysTo(beginDate);
setBeginForecastDate(beginDate);
return fDays;
}
//adjust beginDay for next month
- if(QDate::currentDate().addMonths(1).daysInMonth() < beginDay)
- beginDay = QDate::currentDate().addMonths(1).daysInMonth();
+ if(TQDate::tqcurrentDate().addMonths(1).daysInMonth() < beginDay)
+ beginDay = TQDate::tqcurrentDate().addMonths(1).daysInMonth();
//if beginDay of next month comes before 1 interval, use beginDay next month
- if(QDate::currentDate().addDays(accCycle) >=
- (QDate(QDate::currentDate().addMonths(1).year(), QDate::currentDate().addMonths(1).month(), 1).addDays(beginDay-1) ) )
+ if(TQDate::tqcurrentDate().addDays(accCycle) >=
+ (TQDate(TQDate::tqcurrentDate().addMonths(1).year(), TQDate::tqcurrentDate().addMonths(1).month(), 1).addDays(beginDay-1) ) )
{
- beginDate = QDate(QDate::currentDate().addMonths(1).year(), QDate::currentDate().addMonths(1).month(), 1).addDays(beginDay-1);
- fDays += QDate::currentDate().daysTo(beginDate);
+ beginDate = TQDate(TQDate::tqcurrentDate().addMonths(1).year(), TQDate::tqcurrentDate().addMonths(1).month(), 1).addDays(beginDay-1);
+ fDays += TQDate::tqcurrentDate().daysTo(beginDate);
}
else //add intervals to current beginDay and take the first after current date
{
- beginDay = ((((QDate::currentDate().day()-beginDay)/accCycle) + 1) * accCycle) + beginDay;
- beginDate = QDate::currentDate().addDays(beginDay - QDate::currentDate().day());
- fDays += QDate::currentDate().daysTo(beginDate);
+ beginDay = ((((TQDate::tqcurrentDate().day()-beginDay)/accCycle) + 1) * accCycle) + beginDay;
+ beginDate = TQDate::tqcurrentDate().addDays(beginDay - TQDate::tqcurrentDate().day());
+ fDays += TQDate::tqcurrentDate().daysTo(beginDate);
}
setBeginForecastDate(beginDate);
return fDays;
}
-void MyMoneyForecast::purgeForecastAccountsList(QMap<QString, dailyBalances>& accountList)
+void MyMoneyForecast::purgeForecastAccountsList(TQMap<TQString, dailyBalances>& accountList)
{
- QMap<QString, QString>::Iterator it_n;
+ TQMap<TQString, TQString>::Iterator it_n;
for ( it_n = m_nameIdx.begin(); it_n != m_nameIdx.end(); ) {
- if(!accountList.contains(*it_n)) {
+ if(!accountList.tqcontains(*it_n)) {
m_nameIdx.remove(it_n);
it_n = m_nameIdx.begin();
} else
@@ -997,10 +997,10 @@ void MyMoneyForecast::purgeForecastAccountsList(QMap<QString, dailyBalances>& ac
}
}
-void MyMoneyForecast::createBudget ( MyMoneyBudget& budget, QDate historyStart, QDate historyEnd, QDate budgetStart, QDate budgetEnd, const bool returnBudget )
+void MyMoneyForecast::createBudget ( MyMoneyBudget& budget, TQDate historyStart, TQDate historyEnd, TQDate budgetStart, TQDate budgetEnd, const bool returnBudget )
{
// clear all data except the id and name
- QString name = budget.name();
+ TQString name = budget.name();
budget = MyMoneyBudget(budget.id(), MyMoneyBudget());
budget.setName(name);
@@ -1016,10 +1016,10 @@ void MyMoneyForecast::createBudget ( MyMoneyBudget& budget, QDate historyStart,
int fMethod = forecastMethod();
//set start date to 1st of month and end dates to last day of month, since we deal with full months in budget
- historyStart = QDate ( historyStart.year(), historyStart.month(), 1 );
- historyEnd = QDate ( historyEnd.year(), historyEnd.month(), historyEnd.daysInMonth() );
- budgetStart = QDate ( budgetStart.year(), budgetStart.month(), 1 );
- budgetEnd = QDate ( budgetEnd.year(), budgetEnd.month(), budgetEnd.daysInMonth() );
+ historyStart = TQDate ( historyStart.year(), historyStart.month(), 1 );
+ historyEnd = TQDate ( historyEnd.year(), historyEnd.month(), historyEnd.daysInMonth() );
+ budgetStart = TQDate ( budgetStart.year(), budgetStart.month(), 1 );
+ budgetEnd = TQDate ( budgetEnd.year(), budgetEnd.month(), budgetEnd.daysInMonth() );
//set forecast parameters
setHistoryStartDate ( historyStart );
@@ -1069,7 +1069,7 @@ void MyMoneyForecast::createBudget ( MyMoneyBudget& budget, QDate historyStart,
budget.setBudgetStart ( budgetStart );
//go through all the accounts and add them to budget
- QMap<QString, QString>::ConstIterator it_nc;
+ TQMap<TQString, TQString>::ConstIterator it_nc;
for ( it_nc = m_nameIdx.begin(); it_nc != m_nameIdx.end(); ++it_nc ) {
MyMoneyAccount acc = file->account ( *it_nc );
@@ -1077,7 +1077,7 @@ void MyMoneyForecast::createBudget ( MyMoneyBudget& budget, QDate historyStart,
budgetAcc.setId ( acc.id() );
budgetAcc.setBudgetLevel ( MyMoneyBudget::AccountGroup::eMonthByMonth );
- for ( QDate f_date = forecastStartDate(); f_date <= forecastEndDate(); ) {
+ for ( TQDate f_date = forecastStartDate(); f_date <= forecastEndDate(); ) {
MyMoneyBudget::PeriodGroup period;
//add period to budget account
@@ -1097,10 +1097,10 @@ void MyMoneyForecast::createBudget ( MyMoneyBudget& budget, QDate historyStart,
void MyMoneyForecast::setBudgetAccountList(void)
{
//get budget accounts
- QValueList<MyMoneyAccount> accList;
+ TQValueList<MyMoneyAccount> accList;
accList = budgetAccountList();
- QValueList<MyMoneyAccount>::const_iterator accList_t = accList.begin();
+ TQValueList<MyMoneyAccount>::const_iterator accList_t = accList.begin();
for(; accList_t != accList.end(); ++accList_t ) {
MyMoneyAccount acc = *accList_t;
// check if this is a new account for us
@@ -1110,15 +1110,15 @@ void MyMoneyForecast::setBudgetAccountList(void)
}
}
-QValueList<MyMoneyAccount> MyMoneyForecast::budgetAccountList(void)
+TQValueList<MyMoneyAccount> MyMoneyForecast::budgetAccountList(void)
{
MyMoneyFile* file = MyMoneyFile::instance();
- QValueList<MyMoneyAccount> accList;
- QStringList emptyStringList;
+ TQValueList<MyMoneyAccount> accList;
+ TQStringList emptyStringList;
//Get all accounts from the file and check if they are of the right type to calculate forecast
file->accountList(accList, emptyStringList, false);
- QValueList<MyMoneyAccount>::iterator accList_t = accList.begin();
+ TQValueList<MyMoneyAccount>::iterator accList_t = accList.begin();
for(; accList_t != accList.end(); ) {
MyMoneyAccount acc = *accList_t;
if(acc.isClosed() //check the account is not closed
@@ -1137,17 +1137,17 @@ void MyMoneyForecast::calculateHistoricMonthlyBalances()
MyMoneyFile* file = MyMoneyFile::instance();
//Calculate account monthly balances
- QMap<QString, QString>::ConstIterator it_n;
+ TQMap<TQString, TQString>::ConstIterator it_n;
for(it_n = m_nameIdx.begin(); it_n != m_nameIdx.end(); ++it_n) {
MyMoneyAccount acc = file->account(*it_n);
- for( QDate f_date = forecastStartDate(); f_date <= forecastEndDate(); ) {
+ for( TQDate f_date = forecastStartDate(); f_date <= forecastEndDate(); ) {
for(int f_day = 1; f_day <= accountsCycle() && f_date <= forecastEndDate(); ++f_day) {
MyMoneyMoney accountDailyTrend = m_accountTrendList[acc.id()][f_day]; //trend for that day
//check for leap year
if(f_date.month() == 2 && f_date.day() == 29)
f_date = f_date.addDays(1); //skip 1 day
- m_accountList[acc.id()][QDate(f_date.year(), f_date.month(), 1)] += accountDailyTrend; //movement trend for that particular day
+ m_accountList[acc.id()][TQDate(f_date.year(), f_date.month(), 1)] += accountDailyTrend; //movement trend for that particular day
f_date = f_date.addDays(1);
}
}
@@ -1159,18 +1159,18 @@ void MyMoneyForecast::calculateScheduledMonthlyBalances()
MyMoneyFile* file = MyMoneyFile::instance();
//Calculate account monthly balances
- QMap<QString, QString>::ConstIterator it_n;
+ TQMap<TQString, TQString>::ConstIterator it_n;
for(it_n = m_nameIdx.begin(); it_n != m_nameIdx.end(); ++it_n) {
MyMoneyAccount acc = file->account(*it_n);
- for( QDate f_date = forecastStartDate(); f_date <= forecastEndDate(); f_date = f_date.addDays(1) ) {
+ for( TQDate f_date = forecastStartDate(); f_date <= forecastEndDate(); f_date = f_date.addDays(1) ) {
//get the trend for the day
MyMoneyMoney accountDailyBalance = m_accountList[acc.id()][f_date];
//do not add if it is the beginning of the month
//otherwise we end up with duplicated values as reported by Marko Käning
- if(f_date != QDate(f_date.year(), f_date.month(), 1) )
- m_accountList[acc.id()][QDate(f_date.year(), f_date.month(), 1)] += accountDailyBalance;
+ if(f_date != TQDate(f_date.year(), f_date.month(), 1) )
+ m_accountList[acc.id()][TQDate(f_date.year(), f_date.month(), 1)] += accountDailyBalance;
}
}
}
@@ -1190,24 +1190,24 @@ void MyMoneyForecast::setStartingBalance(const MyMoneyAccount &acc)
//set the default value
MyMoneyMoney rate = MyMoneyMoney ( 1, 1 );
//get te
- MyMoneyPrice price = file->price ( undersecurity.id(), undersecurity.tradingCurrency(), QDate::currentDate() );
+ MyMoneyPrice price = file->price ( undersecurity.id(), undersecurity.tradingCurrency(), TQDate::tqcurrentDate() );
if ( price.isValid() )
{
rate = price.rate ( undersecurity.tradingCurrency() );
}
- m_accountList[acc.id()][QDate::currentDate()] = file->balance(acc.id(), QDate::currentDate()) * rate;
+ m_accountList[acc.id()][TQDate::tqcurrentDate()] = file->balance(acc.id(), TQDate::tqcurrentDate()) * rate;
}
} else {
- m_accountList[acc.id()][QDate::currentDate()] = file->balance(acc.id(), QDate::currentDate());
+ m_accountList[acc.id()][TQDate::tqcurrentDate()] = file->balance(acc.id(), TQDate::tqcurrentDate());
}
//if the method is linear regression, we have to add the opening balance to m_accountListPast
if(forecastMethod() == eHistoric && historyMethod() == 2) {
//FIXME workaround for stock opening dates
- QDate openingDate;
+ TQDate openingDate;
if(acc.accountType() == MyMoneyAccount::Stock) {
- MyMoneyAccount parentAccount = file->account(acc.parentAccountId());
- openingDate = parentAccount.openingDate();
+ MyMoneyAccount tqparentAccount = file->account(acc.tqparentAccountId());
+ openingDate = tqparentAccount.openingDate();
} else {
openingDate = acc.openingDate();
}
@@ -1220,7 +1220,7 @@ void MyMoneyForecast::setStartingBalance(const MyMoneyAccount &acc)
openingBalance = file->balance(acc.id(), openingDate);
//calculate running sum
- for(QDate it_date = openingDate; it_date <= historyEndDate(); it_date = it_date.addDays(1) ) {
+ for(TQDate it_date = openingDate; it_date <= historyEndDate(); it_date = it_date.addDays(1) ) {
//investments require special treatment
if ( acc.isInvest() ) {
//get the security id of that account
@@ -1248,7 +1248,7 @@ void MyMoneyForecast::setStartingBalance(const MyMoneyAccount &acc)
}
}
-void MyMoneyForecast::calculateAutoLoan(const MyMoneySchedule& schedule, MyMoneyTransaction& transaction, const QMap<QString, MyMoneyMoney>& balances)
+void MyMoneyForecast::calculateAutoLoan(const MyMoneySchedule& schedule, MyMoneyTransaction& transaction, const TQMap<TQString, MyMoneyMoney>& balances)
{
if (schedule.type() == MyMoneySchedule::TYPE_LOANPAYMENT) {
@@ -1259,7 +1259,7 @@ void MyMoneyForecast::calculateAutoLoan(const MyMoneySchedule& schedule, MyMoney
if(!amortizationSplit.id().isEmpty() && !interestSplit.id().isEmpty()) {
MyMoneyAccountLoan acc(MyMoneyFile::instance()->account(amortizationSplit.accountId()));
MyMoneyFinancialCalculator calc;
- QDate dueDate;
+ TQDate dueDate;
// FIXME: setup dueDate according to when the interest should be calculated
// current implementation: take the date of the next payment according to
@@ -1267,8 +1267,8 @@ void MyMoneyForecast::calculateAutoLoan(const MyMoneySchedule& schedule, MyMoney
// the payment is overdue then take the current date
dueDate = schedule.nextDueDate();
if(acc.interestCalculation() == MyMoneyAccountLoan::paymentReceived) {
- if(dueDate < QDate::currentDate())
- dueDate = QDate::currentDate();
+ if(dueDate < TQDate::tqcurrentDate())
+ dueDate = TQDate::tqcurrentDate();
}
// we need to calculate the balance at the time the payment is due
@@ -1280,12 +1280,12 @@ void MyMoneyForecast::calculateAutoLoan(const MyMoneySchedule& schedule, MyMoney
balance = balances[acc.id()];
/*
- QValueList<MyMoneyTransaction> list;
- QValueList<MyMoneyTransaction>::ConstIterator it;
+ TQValueList<MyMoneyTransaction> list;
+ TQValueList<MyMoneyTransaction>::ConstIterator it;
MyMoneySplit split;
MyMoneyTransactionFilter filter(acc.id());
- filter.setDateFilter(QDate(), dueDate.addDays(-1));
+ filter.setDateFilter(TQDate(), dueDate.addDays(-1));
list = MyMoneyFile::instance()->transactionList(filter);
for(it = list.begin(); it != list.end(); ++it) {