summaryrefslogtreecommitdiffstats
path: root/kmymoney2/mymoney/mymoneyforecast.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kmymoney2/mymoney/mymoneyforecast.cpp')
-rw-r--r--kmymoney2/mymoney/mymoneyforecast.cpp106
1 files changed, 53 insertions, 53 deletions
diff --git a/kmymoney2/mymoney/mymoneyforecast.cpp b/kmymoney2/mymoney/mymoneyforecast.cpp
index bfecce0..4365b47 100644
--- a/kmymoney2/mymoney/mymoneyforecast.cpp
+++ b/kmymoney2/mymoney/mymoneyforecast.cpp
@@ -47,8 +47,8 @@ MyMoneyForecast::MyMoneyForecast() :
{
setForecastCycles(KMyMoneyGlobalSettings::forecastCycles());
setAccountsCycle(KMyMoneyGlobalSettings::forecastAccountCycle());
- setHistoryStartDate(TQDate::currentDate().addDays(-forecastCycles()*accountsCycle()));
- setHistoryEndDate(TQDate::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(TQDate::currentDate().addDays(1));
- setForecastEndDate(TQDate::currentDate().addDays(fDays));
+ setForecastStartDate(TQDate::tqcurrentDate().addDays(1));
+ setForecastEndDate(TQDate::tqcurrentDate().addDays(fDays));
setAccountsCycle(fAccCycle);
setForecastCycles(fCycles);
setHistoryStartDate(forecastCycles() * accountsCycle());
- setHistoryEndDate(TQDate::currentDate().addDays(-1)); //yesterday
+ setHistoryEndDate(TQDate::tqcurrentDate().addDays(-1)); //yesterday
//clear all data before calculating
m_accountListPast.clear();
@@ -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(TQDate::currentDate())<trendDays){
+ if(openingDate.daysTo(TQDate::tqcurrentDate())<trendDays){
startDate = (acc.openingDate()).addDays(1);
}
else {
- startDate = TQDate::currentDate().addDays(-trendDays);
+ startDate = TQDate::tqcurrentDate().addDays(-trendDays);
}
//get all transactions for the period
- filter.setDateFilter(startDate, TQDate::currentDate());
+ filter.setDateFilter(startDate, TQDate::tqcurrentDate());
if(acc.accountGroup() == MyMoneyAccount::Income
|| acc.accountGroup() == MyMoneyAccount::Expense) {
filter.addCategory(acc.id());
@@ -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(TQDate::currentDate())<trendDays) {
- accTrend = netIncome/MyMoneyMoney(openingDate.daysTo(TQDate::currentDate())-1,1);
+ if(openingDate.daysTo(TQDate::tqcurrentDate())<trendDays) {
+ accTrend = netIncome/MyMoneyMoney(openingDate.daysTo(TQDate::tqcurrentDate())-1,1);
} else {
accTrend = netIncome/MyMoneyMoney(trendDays,1);
}
@@ -490,7 +490,7 @@ void MyMoneyForecast::calculateHistoricDailyBalances()
break;
case 2:
{
- TQDate baseDate = TQDate::currentDate().addDays(-accountsCycle());
+ TQDate baseDate = TQDate::tqcurrentDate().addDays(-accountsCycle());
for(int t_day = 1; t_day <= accountsCycle(); ++t_day) {
int f_day = 1;
TQDate fDate = baseDate.addDays(accountsCycle()+1);
@@ -536,7 +536,7 @@ MyMoneyMoney MyMoneyForecast::forecastBalance(const MyMoneyAccount& acc, TQDate
*/
MyMoneyMoney MyMoneyForecast::forecastBalance (const MyMoneyAccount& acc, int offset )
{
- TQDate forecastDate = TQDate::currentDate().addDays(offset);
+ TQDate forecastDate = TQDate::tqcurrentDate().addDays(offset);
return forecastBalance(acc, forecastDate);
}
@@ -570,7 +570,7 @@ void MyMoneyForecast::doFutureScheduledForecast(void)
MyMoneyMoney rate = MyMoneyMoney ( 1, 1 );
MyMoneyPrice price;
- for (TQDate it_day = TQDate::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() )
@@ -651,7 +651,7 @@ void MyMoneyForecast::addScheduledTransactions (void)
TQValueList<MyMoneySchedule> schedule;
schedule = file->scheduleList("", MyMoneySchedule::TYPE_ANY, MyMoneySchedule::OCCUR_ANY, MyMoneySchedule::STYPE_ANY,
- TQDate::currentDate(), forecastEndDate());
+ TQDate::tqcurrentDate(), forecastEndDate());
if(schedule.count() > 0) {
TQValueList<MyMoneySchedule>::Iterator it;
do {
@@ -698,12 +698,12 @@ void MyMoneyForecast::addScheduledTransactions (void)
if(isForecastAccount(acc)) {
// collect all overdues on the first day
TQDate forecastDate = nextDate;
- if(TQDate::currentDate() >= nextDate)
- forecastDate = TQDate::currentDate().addDays(1);
+ if(TQDate::tqcurrentDate() >= nextDate)
+ forecastDate = TQDate::tqcurrentDate().addDays(1);
dailyBalances balance;
balance = m_accountList[acc.id()];
- for(TQDate f_day = TQDate::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 = TQDate::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
TQDate forecastDate = nextDate;
- if(TQDate::currentDate() >= nextDate)
- forecastDate = TQDate::currentDate().addDays(1);
+ if(TQDate::tqcurrentDate() >= nextDate)
+ forecastDate = TQDate::tqcurrentDate().addDays(1);
if(acc.accountType() == MyMoneyAccount::Income) {
balance[forecastDate] += ((*it_s).shares() * MyMoneyMoney(-1, 1));
@@ -807,9 +807,9 @@ int MyMoneyForecast::daysToMinimumBalance(const MyMoneyAccount& acc)
balance = m_accountList[acc.id()];
- for(TQDate it_day = TQDate::currentDate() ; it_day <= forecastEndDate(); ) {
+ for(TQDate it_day = TQDate::tqcurrentDate() ; it_day <= forecastEndDate(); ) {
if(minBalance > balance[it_day]) {
- return TQDate::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 (TQDate it_day = TQDate::currentDate() ; it_day <= forecastEndDate(); )
+ for (TQDate it_day = TQDate::tqcurrentDate() ; it_day <= forecastEndDate(); )
{
if ( balance[it_day] < MyMoneyMoney ( 0, 1 ) )
{
- return TQDate::currentDate().daysTo(it_day);
+ return TQDate::tqcurrentDate().daysTo(it_day);
}
it_day = it_day.addDays(1);
}
} else if (acc.accountGroup() == MyMoneyAccount::Liability) {
- for (TQDate it_day = TQDate::currentDate() ; it_day <= forecastEndDate(); )
+ for (TQDate it_day = TQDate::tqcurrentDate() ; it_day <= forecastEndDate(); )
{
if ( balance[it_day] > MyMoneyMoney ( 0, 1 ) )
{
- return TQDate::currentDate().daysTo(it_day);
+ return TQDate::tqcurrentDate().daysTo(it_day);
}
it_day = it_day.addDays(1);
}
@@ -882,7 +882,7 @@ MyMoneyMoney MyMoneyForecast::accountTotalVariation(const MyMoneyAccount& acc)
{
MyMoneyMoney totalVariation;
- totalVariation = forecastBalance(acc, forecastEndDate()) - forecastBalance(acc, TQDate::currentDate());
+ totalVariation = forecastBalance(acc, forecastEndDate()) - forecastBalance(acc, TQDate::tqcurrentDate());
return totalVariation;
}
@@ -891,15 +891,15 @@ TQValueList<TQDate> MyMoneyForecast::accountMinimumBalanceDateList(const MyMoney
TQValueList<TQDate> minBalanceList;
int daysToBeginDay;
- daysToBeginDay = TQDate::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));
- TQDate minDate = TQDate::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 = TQDate::currentDate().addDays( (t_cycle * accountsCycle()) + daysToBeginDay + t_day);
+ minDate = TQDate::tqcurrentDate().addDays( (t_cycle * accountsCycle()) + daysToBeginDay + t_day);
}
}
minBalanceList.append(minDate);
@@ -912,16 +912,16 @@ TQValueList<TQDate> MyMoneyForecast::accountMaximumBalanceDateList(const MyMoney
TQValueList<TQDate> maxBalanceList;
int daysToBeginDay;
- daysToBeginDay = TQDate::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));
- TQDate maxDate = TQDate::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 = TQDate::currentDate().addDays((t_cycle * accountsCycle()) + daysToBeginDay + t_day);
+ maxDate = TQDate::tqcurrentDate().addDays((t_cycle * accountsCycle()) + daysToBeginDay + t_day);
}
}
maxBalanceList.append(maxDate);
@@ -947,38 +947,38 @@ int MyMoneyForecast::calculateBeginForecastDay()
//if 0, beginDate is current date and forecastDays remains unchanged
if(beginDay == 0) {
- setBeginForecastDate(TQDate::currentDate());
+ setBeginForecastDate(TQDate::tqcurrentDate());
return fDays;
}
//adjust if beginDay more than days of current month
- if(TQDate::currentDate().daysInMonth() < beginDay)
- beginDay = TQDate::currentDate().daysInMonth();
+ if(TQDate::tqcurrentDate().daysInMonth() < beginDay)
+ beginDay = TQDate::tqcurrentDate().daysInMonth();
//if beginDay still to come, calculate and return
- if(TQDate::currentDate().day() <= beginDay) {
- beginDate = TQDate( TQDate::currentDate().year(), TQDate::currentDate().month(), beginDay);
- fDays += TQDate::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(TQDate::currentDate().addMonths(1).daysInMonth() < beginDay)
- beginDay = TQDate::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(TQDate::currentDate().addDays(accCycle) >=
- (TQDate(TQDate::currentDate().addMonths(1).year(), TQDate::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 = TQDate(TQDate::currentDate().addMonths(1).year(), TQDate::currentDate().addMonths(1).month(), 1).addDays(beginDay-1);
- fDays += TQDate::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 = ((((TQDate::currentDate().day()-beginDay)/accCycle) + 1) * accCycle) + beginDay;
- beginDate = TQDate::currentDate().addDays(beginDay - TQDate::currentDate().day());
- fDays += TQDate::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);
@@ -1190,15 +1190,15 @@ 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(), TQDate::currentDate() );
+ MyMoneyPrice price = file->price ( undersecurity.id(), undersecurity.tradingCurrency(), TQDate::tqcurrentDate() );
if ( price.isValid() )
{
rate = price.rate ( undersecurity.tradingCurrency() );
}
- m_accountList[acc.id()][TQDate::currentDate()] = file->balance(acc.id(), TQDate::currentDate()) * rate;
+ m_accountList[acc.id()][TQDate::tqcurrentDate()] = file->balance(acc.id(), TQDate::tqcurrentDate()) * rate;
}
} else {
- m_accountList[acc.id()][TQDate::currentDate()] = file->balance(acc.id(), TQDate::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
@@ -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 < TQDate::currentDate())
- dueDate = TQDate::currentDate();
+ if(dueDate < TQDate::tqcurrentDate())
+ dueDate = TQDate::tqcurrentDate();
}
// we need to calculate the balance at the time the payment is due