summaryrefslogtreecommitdiffstats
path: root/kmymoney2/mymoney/mymoneyforecasttest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kmymoney2/mymoney/mymoneyforecasttest.cpp')
-rw-r--r--kmymoney2/mymoney/mymoneyforecasttest.cpp270
1 files changed, 135 insertions, 135 deletions
diff --git a/kmymoney2/mymoney/mymoneyforecasttest.cpp b/kmymoney2/mymoney/mymoneyforecasttest.cpp
index dc829cd..ffcd232 100644
--- a/kmymoney2/mymoney/mymoneyforecasttest.cpp
+++ b/kmymoney2/mymoney/mymoneyforecasttest.cpp
@@ -78,7 +78,7 @@ void MyMoneyForecastTest::setUp () {
acGrandChild2 = makeAccount(TQString("Grand Child 2"),MyMoneyAccount::Expense,0,TQDate(2004,2,11),acChild, "USD");
//this account added to have an account to test opening date calculations
- acCash = makeAccount(TQString("Cash"),MyMoneyAccount::Cash,moCreditOpen,TQDate::currentDate().addDays(-2),acAsset, "USD");
+ acCash = makeAccount(TQString("Cash"),MyMoneyAccount::Cash,moCreditOpen,TQDate::tqcurrentDate().addDays(-2),acAsset, "USD");
MyMoneyInstitution i("Bank of the World","","","","","","");
@@ -97,18 +97,18 @@ void MyMoneyForecastTest::testEmptyConstructor() {
MyMoneyForecast a;
MyMoneyAccount b;
- int f = a.forecastBalance(b, TQDate::currentDate());
+ int f = a.forecastBalance(b, TQDate::tqcurrentDate());
CPPUNIT_ASSERT(f == 0);
CPPUNIT_ASSERT(!a.isForecastAccount(b));
- CPPUNIT_ASSERT(a.forecastBalance(b, TQDate::currentDate()) == MyMoneyMoney(0,1));
+ CPPUNIT_ASSERT(a.forecastBalance(b, TQDate::tqcurrentDate()) == MyMoneyMoney(0,1));
CPPUNIT_ASSERT(a.daysToMinimumBalance(b) == -1);
CPPUNIT_ASSERT(a.daysToZeroBalance(b) == -2);
CPPUNIT_ASSERT(a.forecastDays() == KMyMoneyGlobalSettings::forecastDays());
CPPUNIT_ASSERT(a.accountsCycle() == KMyMoneyGlobalSettings::forecastAccountCycle());
CPPUNIT_ASSERT(a.forecastCycles() == KMyMoneyGlobalSettings::forecastCycles());
- CPPUNIT_ASSERT(a.historyStartDate() == TQDate::currentDate().addDays(-KMyMoneyGlobalSettings::forecastCycles()*KMyMoneyGlobalSettings::forecastAccountCycle()));
- CPPUNIT_ASSERT(a.historyEndDate() == TQDate::currentDate().addDays(-1));
+ CPPUNIT_ASSERT(a.historyStartDate() == TQDate::tqcurrentDate().addDays(-KMyMoneyGlobalSettings::forecastCycles()*KMyMoneyGlobalSettings::forecastAccountCycle()));
+ CPPUNIT_ASSERT(a.historyEndDate() == TQDate::tqcurrentDate().addDays(-1));
CPPUNIT_ASSERT(a.historyDays() == KMyMoneyGlobalSettings::forecastAccountCycle() * KMyMoneyGlobalSettings::forecastCycles());
}
@@ -177,9 +177,9 @@ void MyMoneyForecastTest::testDoForecast() {
a.doForecast(); //this is just to check nothing goes wrong if forecast is run agains an empty template
//setup some transactions
- TransactionHelper t1( TQDate::currentDate().addDays(-1), MyMoneySplit::ActionWithdrawal, this->moT1, acChecking, acSolo);
- TransactionHelper t2( TQDate::currentDate().addDays(-1), MyMoneySplit::ActionDeposit, -(this->moT2), acCredit, acParent);
- TransactionHelper t3( TQDate::currentDate().addDays(-1), MyMoneySplit::ActionTransfer, this->moT1, acCredit, acChecking);
+ TransactionHelper t1( TQDate::tqcurrentDate().addDays(-1), MyMoneySplit::ActionWithdrawal, this->moT1, acChecking, acSolo);
+ TransactionHelper t2( TQDate::tqcurrentDate().addDays(-1), MyMoneySplit::ActionDeposit, -(this->moT2), acCredit, acParent);
+ TransactionHelper t3( TQDate::tqcurrentDate().addDays(-1), MyMoneySplit::ActionTransfer, this->moT1, acCredit, acChecking);
a.setForecastMethod(1);
a.setForecastDays(3);
@@ -190,32 +190,32 @@ void MyMoneyForecastTest::testDoForecast() {
a.doForecast();
//checking didn't have balance variations, so the forecast should be equal to the current balance
- MyMoneyMoney b_checking = file->balance(a_checking.id(), TQDate::currentDate());
+ MyMoneyMoney b_checking = file->balance(a_checking.id(), TQDate::tqcurrentDate());
- CPPUNIT_ASSERT(a.forecastBalance(a_checking, TQDate::currentDate().addDays(1))==b_checking);
- CPPUNIT_ASSERT(a.forecastBalance(a_checking, TQDate::currentDate().addDays(2))==b_checking);
- CPPUNIT_ASSERT(a.forecastBalance(a_checking, TQDate::currentDate().addDays(3))==b_checking);
- CPPUNIT_ASSERT(a.forecastBalance(a_checking, TQDate::currentDate())==b_checking);
+ CPPUNIT_ASSERT(a.forecastBalance(a_checking, TQDate::tqcurrentDate().addDays(1))==b_checking);
+ CPPUNIT_ASSERT(a.forecastBalance(a_checking, TQDate::tqcurrentDate().addDays(2))==b_checking);
+ CPPUNIT_ASSERT(a.forecastBalance(a_checking, TQDate::tqcurrentDate().addDays(3))==b_checking);
+ CPPUNIT_ASSERT(a.forecastBalance(a_checking, TQDate::tqcurrentDate())==b_checking);
//credit had a variation so the forecast should be different for each day
- MyMoneyMoney b_credit = file->balance(a_credit.id(), TQDate::currentDate());
+ MyMoneyMoney b_credit = file->balance(a_credit.id(), TQDate::tqcurrentDate());
CPPUNIT_ASSERT(a.forecastBalance(a_credit, 0) == b_credit);
- CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::currentDate().addDays(1)) == (b_credit+(moT2-moT1)));
- CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::currentDate().addDays(2)) == (b_credit+((moT2-moT1)*2)));
- CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::currentDate().addDays(3)) == b_credit+((moT2-moT1)*3));
+ CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::tqcurrentDate().addDays(1)) == (b_credit+(moT2-moT1)));
+ CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::tqcurrentDate().addDays(2)) == (b_credit+((moT2-moT1)*2)));
+ CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::tqcurrentDate().addDays(3)) == b_credit+((moT2-moT1)*3));
a.setHistoryMethod(1); //weighted moving average
a.doForecast();
CPPUNIT_ASSERT(a.forecastBalance(a_credit, 0) == b_credit);
- CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::currentDate().addDays(1)) == (b_credit+(moT2-moT1)));
- CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::currentDate().addDays(2)) == (b_credit+((moT2-moT1)*2)));
- CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::currentDate().addDays(3)) == b_credit+((moT2-moT1)*3));
+ CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::tqcurrentDate().addDays(1)) == (b_credit+(moT2-moT1)));
+ CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::tqcurrentDate().addDays(2)) == (b_credit+((moT2-moT1)*2)));
+ CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::tqcurrentDate().addDays(3)) == b_credit+((moT2-moT1)*3));
//insert transactions outside the forecast period. The calculation should be the same.
- TransactionHelper t4( TQDate::currentDate().addDays(-2), MyMoneySplit::ActionDeposit, -moT2, acCredit, acParent );
- TransactionHelper t5( TQDate::currentDate().addDays(-10), MyMoneySplit::ActionDeposit, -moT2, acCredit, acParent );
- TransactionHelper t6( TQDate::currentDate().addDays(-3), MyMoneySplit::ActionDeposit, -moT2, acCredit, acParent );
+ TransactionHelper t4( TQDate::tqcurrentDate().addDays(-2), MyMoneySplit::ActionDeposit, -moT2, acCredit, acParent );
+ TransactionHelper t5( TQDate::tqcurrentDate().addDays(-10), MyMoneySplit::ActionDeposit, -moT2, acCredit, acParent );
+ TransactionHelper t6( TQDate::tqcurrentDate().addDays(-3), MyMoneySplit::ActionDeposit, -moT2, acCredit, acParent );
a.setForecastMethod(1);
a.setForecastDays(3);
@@ -225,14 +225,14 @@ void MyMoneyForecastTest::testDoForecast() {
a.setHistoryMethod(0); //moving average
a.doForecast();
//check forecast
- b_credit = file->balance(a_credit.id(), TQDate::currentDate());
+ b_credit = file->balance(a_credit.id(), TQDate::tqcurrentDate());
MyMoneyMoney b_credit_1_exp = (b_credit+((moT2-moT1)));
- MyMoneyMoney b_credit_2 = a.forecastBalance(a_credit, TQDate::currentDate().addDays(2));
+ MyMoneyMoney b_credit_2 = a.forecastBalance(a_credit, TQDate::tqcurrentDate().addDays(2));
MyMoneyMoney b_credit_2_exp = (b_credit+((moT2-moT1)*2));
- CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::currentDate())==file->balance(a_credit.id(), TQDate::currentDate()));
- CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::currentDate().addDays(1))==b_credit+(moT2-moT1));
- CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::currentDate().addDays(2))==b_credit+((moT2-moT1)*2));
- CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::currentDate().addDays(3))==b_credit+((moT2-moT1)*3));
+ CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::tqcurrentDate())==file->balance(a_credit.id(), TQDate::tqcurrentDate()));
+ CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::tqcurrentDate().addDays(1))==b_credit+(moT2-moT1));
+ CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::tqcurrentDate().addDays(2))==b_credit+((moT2-moT1)*2));
+ CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::tqcurrentDate().addDays(3))==b_credit+((moT2-moT1)*3));
//test weighted moving average
a.setForecastMethod(1);
@@ -244,7 +244,7 @@ void MyMoneyForecastTest::testDoForecast() {
a.doForecast();
CPPUNIT_ASSERT(a.forecastBalance(a_credit, 0) == b_credit);
- CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::currentDate().addDays(1)) == (b_credit+(((moT2-moT1)*3+moT2*2+moT2)/MyMoneyMoney(6,1))));
+ CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::tqcurrentDate().addDays(1)) == (b_credit+(((moT2-moT1)*3+moT2*2+moT2)/MyMoneyMoney(6,1))));
}
@@ -265,7 +265,7 @@ void MyMoneyForecastTest::testGetForecastAccountList()
void MyMoneyForecastTest::testCalculateAccountTrend()
{
//set up environment
- TransactionHelper t1( TQDate::currentDate().addDays(-3), MyMoneySplit::ActionDeposit, -moT2, acChecking, acSolo );
+ TransactionHelper t1( TQDate::tqcurrentDate().addDays(-3), MyMoneySplit::ActionDeposit, -moT2, acChecking, acSolo );
MyMoneyAccount a_checking = file->account(acChecking);
//test invalid arguments
@@ -296,8 +296,8 @@ void MyMoneyForecastTest::testCalculateAccountTrend()
//test that it does not take into account the transactions of the opening date of the account
MyMoneyAccount a_cash = file->account(acCash);
- TransactionHelper t2( TQDate::currentDate().addDays(-2), MyMoneySplit::ActionDeposit, moT2, acCash, acParent );
- TransactionHelper t3( TQDate::currentDate().addDays(-1), MyMoneySplit::ActionDeposit, moT1, acCash, acParent );
+ TransactionHelper t2( TQDate::tqcurrentDate().addDays(-2), MyMoneySplit::ActionDeposit, moT2, acCash, acParent );
+ TransactionHelper t3( TQDate::tqcurrentDate().addDays(-1), MyMoneySplit::ActionDeposit, moT1, acCash, acParent );
CPPUNIT_ASSERT(MyMoneyForecast::calculateAccountTrend(a_cash,3) == -moT1);
}
@@ -307,9 +307,9 @@ void MyMoneyForecastTest::testGetForecastBalance()
//set up environment
MyMoneyForecast a;
- TransactionHelper t1( TQDate::currentDate().addDays(-1), MyMoneySplit::ActionWithdrawal, this->moT1, acChecking, acSolo);
- TransactionHelper t2( TQDate::currentDate().addDays(-1), MyMoneySplit::ActionDeposit, -(this->moT2), acCredit, acParent);
- TransactionHelper t3( TQDate::currentDate().addDays(-1), MyMoneySplit::ActionTransfer, this->moT1, acCredit, acChecking);
+ TransactionHelper t1( TQDate::tqcurrentDate().addDays(-1), MyMoneySplit::ActionWithdrawal, this->moT1, acChecking, acSolo);
+ TransactionHelper t2( TQDate::tqcurrentDate().addDays(-1), MyMoneySplit::ActionDeposit, -(this->moT2), acCredit, acParent);
+ TransactionHelper t3( TQDate::tqcurrentDate().addDays(-1), MyMoneySplit::ActionTransfer, this->moT1, acCredit, acChecking);
a.setForecastMethod(1);
a.setForecastDays(3);
@@ -322,23 +322,23 @@ void MyMoneyForecastTest::testGetForecastBalance()
MyMoneyAccount a_credit = file->account(acCredit);
//test invalid arguments
- CPPUNIT_ASSERT(a.forecastBalance(a_checking, TQDate::currentDate().addDays(-1))==MyMoneyMoney(0,1));
- CPPUNIT_ASSERT(a.forecastBalance(a_checking, TQDate::currentDate().addDays(-10))==MyMoneyMoney(0,1));
+ CPPUNIT_ASSERT(a.forecastBalance(a_checking, TQDate::tqcurrentDate().addDays(-1))==MyMoneyMoney(0,1));
+ CPPUNIT_ASSERT(a.forecastBalance(a_checking, TQDate::tqcurrentDate().addDays(-10))==MyMoneyMoney(0,1));
CPPUNIT_ASSERT(a.forecastBalance(a_checking, -1)==MyMoneyMoney(0,1));
CPPUNIT_ASSERT(a.forecastBalance(a_checking, -100)==MyMoneyMoney(0,1));
//test a date outside the forecast days
- CPPUNIT_ASSERT(a.forecastBalance(a_checking, TQDate::currentDate().addDays(4))==MyMoneyMoney(0,1));
+ CPPUNIT_ASSERT(a.forecastBalance(a_checking, TQDate::tqcurrentDate().addDays(4))==MyMoneyMoney(0,1));
CPPUNIT_ASSERT(a.forecastBalance(a_checking, 4)==MyMoneyMoney(0,1));
- CPPUNIT_ASSERT(a.forecastBalance(a_checking, TQDate::currentDate().addDays(10))==MyMoneyMoney(0,1));
+ CPPUNIT_ASSERT(a.forecastBalance(a_checking, TQDate::tqcurrentDate().addDays(10))==MyMoneyMoney(0,1));
CPPUNIT_ASSERT(a.forecastBalance(a_checking, 10)==MyMoneyMoney(0,1));
//test it returns valid results
- MyMoneyMoney b_credit = file->balance(a_credit.id(), TQDate::currentDate());
- CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::currentDate())==file->balance(a_credit.id(), TQDate::currentDate()));
- CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::currentDate().addDays(1))==b_credit+(moT2-moT1));
- CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::currentDate().addDays(2))==b_credit+((moT2-moT1)*2));
- CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::currentDate().addDays(3))==b_credit+((moT2-moT1)*3));
+ MyMoneyMoney b_credit = file->balance(a_credit.id(), TQDate::tqcurrentDate());
+ CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::tqcurrentDate())==file->balance(a_credit.id(), TQDate::tqcurrentDate()));
+ CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::tqcurrentDate().addDays(1))==b_credit+(moT2-moT1));
+ CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::tqcurrentDate().addDays(2))==b_credit+((moT2-moT1)*2));
+ CPPUNIT_ASSERT(a.forecastBalance(a_credit, TQDate::tqcurrentDate().addDays(3))==b_credit+((moT2-moT1)*3));
}
void MyMoneyForecastTest::testIsForecastAccount()
@@ -364,10 +364,10 @@ void MyMoneyForecastTest::testDoFutureScheduledForecast()
MyMoneyForecast a;
MyMoneyAccount a_cash = file->account(acCash);
- TransactionHelper t1( TQDate::currentDate().addDays(1), MyMoneySplit::ActionDeposit, -moT1, acCash, acParent );
- TransactionHelper t2( TQDate::currentDate().addDays(2), MyMoneySplit::ActionDeposit, -moT2, acCash, acParent );
- TransactionHelper t3( TQDate::currentDate().addDays(3), MyMoneySplit::ActionDeposit, -moT3, acCash, acParent );
- TransactionHelper t4( TQDate::currentDate().addDays(10), MyMoneySplit::ActionDeposit, -moT4, acCash, acParent );
+ TransactionHelper t1( TQDate::tqcurrentDate().addDays(1), MyMoneySplit::ActionDeposit, -moT1, acCash, acParent );
+ TransactionHelper t2( TQDate::tqcurrentDate().addDays(2), MyMoneySplit::ActionDeposit, -moT2, acCash, acParent );
+ TransactionHelper t3( TQDate::tqcurrentDate().addDays(3), MyMoneySplit::ActionDeposit, -moT3, acCash, acParent );
+ TransactionHelper t4( TQDate::tqcurrentDate().addDays(10), MyMoneySplit::ActionDeposit, -moT4, acCash, acParent );
a.setForecastMethod(0);
a.setForecastDays(3);
@@ -375,13 +375,13 @@ void MyMoneyForecastTest::testDoFutureScheduledForecast()
a.setForecastCycles(1);
a.doForecast();
- MyMoneyMoney b_cash = file->balance(a_cash.id(), TQDate::currentDate());
+ MyMoneyMoney b_cash = file->balance(a_cash.id(), TQDate::tqcurrentDate());
//test valid results
- CPPUNIT_ASSERT(a.forecastBalance(a_cash, TQDate::currentDate())==b_cash);
- CPPUNIT_ASSERT(a.forecastBalance(a_cash, TQDate::currentDate().addDays(1))==b_cash+moT1);
- CPPUNIT_ASSERT(a.forecastBalance(a_cash, TQDate::currentDate().addDays(2))==b_cash+moT1+moT2);
- CPPUNIT_ASSERT(a.forecastBalance(a_cash, TQDate::currentDate().addDays(3))==b_cash+moT1+moT2+moT3);
+ CPPUNIT_ASSERT(a.forecastBalance(a_cash, TQDate::tqcurrentDate())==b_cash);
+ CPPUNIT_ASSERT(a.forecastBalance(a_cash, TQDate::tqcurrentDate().addDays(1))==b_cash+moT1);
+ CPPUNIT_ASSERT(a.forecastBalance(a_cash, TQDate::tqcurrentDate().addDays(2))==b_cash+moT1+moT2);
+ CPPUNIT_ASSERT(a.forecastBalance(a_cash, TQDate::tqcurrentDate().addDays(3))==b_cash+moT1+moT2+moT3);
}
void MyMoneyForecastTest::testScheduleForecast()
@@ -395,14 +395,14 @@ void MyMoneyForecastTest::testScheduleForecast()
MyMoneySchedule::TYPE_BILL,
MyMoneySchedule::OCCUR_WEEKLY, 1,
MyMoneySchedule::STYPE_DIRECTDEBIT,
- TQDate::currentDate().addDays(1),
+ TQDate::tqcurrentDate().addDays(1),
TQDate(),
true,
true);
MyMoneyTransaction t;
- t.setPostDate(TQDate::currentDate().addDays(1));
- t.setEntryDate(TQDate::currentDate().addDays(1));
+ t.setPostDate(TQDate::tqcurrentDate().addDays(1));
+ t.setEntryDate(TQDate::tqcurrentDate().addDays(1));
//t.setId("T000000000000000001");
t.setBankID("BID");
t.setMemo("Wohnung:Miete");
@@ -437,18 +437,18 @@ void MyMoneyForecastTest::testScheduleForecast()
MyMoneySchedule::TYPE_BILL,
MyMoneySchedule::OCCUR_WEEKLY, 1,
MyMoneySchedule::STYPE_DIRECTDEBIT,
- TQDate::currentDate().addDays(5),
+ TQDate::tqcurrentDate().addDays(5),
TQDate(),
true,
true);
- //sch.setLastPayment(TQDate::currentDate());
- //sch.recordPayment(TQDate::currentDate().addDays(1));
+ //sch.setLastPayment(TQDate::tqcurrentDate());
+ //sch.recordPayment(TQDate::tqcurrentDate().addDays(1));
//sch.setId("SCH0001");
MyMoneyTransaction t3;
- t3.setPostDate(TQDate::currentDate().addDays(5));
- t3.setEntryDate(TQDate::currentDate().addDays(5));
+ t3.setPostDate(TQDate::tqcurrentDate().addDays(5));
+ t3.setEntryDate(TQDate::tqcurrentDate().addDays(5));
//t.setId("T000000000000000001");
t3.setBankID("BID");
t3.setMemo("Wohnung:Miete");
@@ -484,18 +484,18 @@ void MyMoneyForecastTest::testScheduleForecast()
MyMoneySchedule::TYPE_BILL,
MyMoneySchedule::OCCUR_WEEKLY, 1,
MyMoneySchedule::STYPE_DIRECTDEBIT,
- TQDate::currentDate().addDays(2),
+ TQDate::tqcurrentDate().addDays(2),
TQDate(),
true,
true);
- //sch.setLastPayment(TQDate::currentDate());
- //sch.recordPayment(TQDate::currentDate().addDays(1));
+ //sch.setLastPayment(TQDate::tqcurrentDate());
+ //sch.recordPayment(TQDate::tqcurrentDate().addDays(1));
//sch.setId("SCH0001");
MyMoneyTransaction t2;
- t2.setPostDate(TQDate::currentDate().addDays(2));
- t2.setEntryDate(TQDate::currentDate().addDays(2));
+ t2.setPostDate(TQDate::tqcurrentDate().addDays(2));
+ t2.setEntryDate(TQDate::tqcurrentDate().addDays(2));
//t.setId("T000000000000000001");
t2.setBankID("BID");
t2.setMemo("Wohnung:Miete");
@@ -535,13 +535,13 @@ void MyMoneyForecastTest::testScheduleForecast()
a.doForecast();
//check result for single schedule
- MyMoneyMoney b_cash = file->balance(a_cash.id(), TQDate::currentDate());
- MyMoneyMoney b_cash1 = a.forecastBalance(a_cash, TQDate::currentDate().addDays(1));
+ MyMoneyMoney b_cash = file->balance(a_cash.id(), TQDate::tqcurrentDate());
+ MyMoneyMoney b_cash1 = a.forecastBalance(a_cash, TQDate::tqcurrentDate().addDays(1));
//test valid results
- CPPUNIT_ASSERT(a.forecastBalance(a_cash, TQDate::currentDate())==b_cash);
- CPPUNIT_ASSERT(a.forecastBalance(a_cash, TQDate::currentDate().addDays(1))==b_cash-moT2);
- CPPUNIT_ASSERT(a.forecastBalance(a_cash, TQDate::currentDate().addDays(2))==b_cash-moT2-moT1);
+ CPPUNIT_ASSERT(a.forecastBalance(a_cash, TQDate::tqcurrentDate())==b_cash);
+ CPPUNIT_ASSERT(a.forecastBalance(a_cash, TQDate::tqcurrentDate().addDays(1))==b_cash-moT2);
+ CPPUNIT_ASSERT(a.forecastBalance(a_cash, TQDate::tqcurrentDate().addDays(2))==b_cash-moT2-moT1);
}
@@ -555,10 +555,10 @@ void MyMoneyForecastTest::testDaysToMinimumBalance()
MyMoneyAccount a_parent = file->account(acParent);
a_cash.setValue("minBalanceAbsolute", "50");
a_credit.setValue("minBalanceAbsolute", "50");
- TransactionHelper t1( TQDate::currentDate().addDays(-1), MyMoneySplit::ActionDeposit, -moT1, acCash, acParent );
- TransactionHelper t2( TQDate::currentDate().addDays(2), MyMoneySplit::ActionDeposit, moT2, acCash, acParent );
- TransactionHelper t3( TQDate::currentDate().addDays(-1), MyMoneySplit::ActionWithdrawal, -moT1, acCredit, acParent );
- TransactionHelper t4( TQDate::currentDate().addDays(4), MyMoneySplit::ActionWithdrawal, moT5, acCredit, acParent );
+ TransactionHelper t1( TQDate::tqcurrentDate().addDays(-1), MyMoneySplit::ActionDeposit, -moT1, acCash, acParent );
+ TransactionHelper t2( TQDate::tqcurrentDate().addDays(2), MyMoneySplit::ActionDeposit, moT2, acCash, acParent );
+ TransactionHelper t3( TQDate::tqcurrentDate().addDays(-1), MyMoneySplit::ActionWithdrawal, -moT1, acCredit, acParent );
+ TransactionHelper t4( TQDate::tqcurrentDate().addDays(4), MyMoneySplit::ActionWithdrawal, moT5, acCredit, acParent );
a.setForecastMethod(0);
a.setForecastDays(3);
@@ -588,9 +588,9 @@ void MyMoneyForecastTest::testDaysToZeroBalance()
MyMoneyAccount a_Credit = file->account(acCredit);
//MyMoneyFileTransaction ft;
- TransactionHelper t1( TQDate::currentDate().addDays(2), MyMoneySplit::ActionWithdrawal, -moT1, acChecking, acSolo );
- TransactionHelper t2( TQDate::currentDate().addDays(2), MyMoneySplit::ActionTransfer, (moT5), acCash, acCredit );
- TransactionHelper t3( TQDate::currentDate().addDays(2), MyMoneySplit::ActionWithdrawal, (moT5*100), acCredit, acParent );
+ TransactionHelper t1( TQDate::tqcurrentDate().addDays(2), MyMoneySplit::ActionWithdrawal, -moT1, acChecking, acSolo );
+ TransactionHelper t2( TQDate::tqcurrentDate().addDays(2), MyMoneySplit::ActionTransfer, (moT5), acCash, acCredit );
+ TransactionHelper t3( TQDate::tqcurrentDate().addDays(2), MyMoneySplit::ActionWithdrawal, (moT5*100), acCredit, acParent );
//ft.commit();
MyMoneyForecast a;
@@ -618,7 +618,7 @@ void MyMoneyForecastTest::testDaysToZeroBalance()
//test it warns when inside the forecast period
- MyMoneyMoney fCash = a.forecastBalance(a_Cash, TQDate::currentDate().addDays(2));
+ MyMoneyMoney fCash = a.forecastBalance(a_Cash, TQDate::tqcurrentDate().addDays(2));
CPPUNIT_ASSERT(a.daysToZeroBalance(a_Cash) == 2);
@@ -631,8 +631,8 @@ void MyMoneyForecastTest::testSkipOpeningDate()
//set up environment
MyMoneyForecast a;
- TransactionHelper t1( TQDate::currentDate().addDays(-2), MyMoneySplit::ActionWithdrawal, this->moT1, acCash, acSolo);
- TransactionHelper t2( TQDate::currentDate().addDays(-1), MyMoneySplit::ActionWithdrawal, this->moT2, acCash, acSolo);
+ TransactionHelper t1( TQDate::tqcurrentDate().addDays(-2), MyMoneySplit::ActionWithdrawal, this->moT1, acCash, acSolo);
+ TransactionHelper t2( TQDate::tqcurrentDate().addDays(-1), MyMoneySplit::ActionWithdrawal, this->moT2, acCash, acSolo);
a.setForecastMethod(1);
a.setForecastDays(3);
@@ -644,12 +644,12 @@ void MyMoneyForecastTest::testSkipOpeningDate()
MyMoneyAccount a_cash = file->account(acCash);
//test it has no variation because it skipped the variation of the opening date
- MyMoneyMoney b_cash = file->balance(a_cash.id(), TQDate::currentDate());
+ MyMoneyMoney b_cash = file->balance(a_cash.id(), TQDate::tqcurrentDate());
CPPUNIT_ASSERT(a.skipOpeningDate() == true);
- CPPUNIT_ASSERT(a.forecastBalance(a_cash, TQDate::currentDate())==b_cash);
- CPPUNIT_ASSERT(a.forecastBalance(a_cash, TQDate::currentDate().addDays(1))==b_cash);
- CPPUNIT_ASSERT(a.forecastBalance(a_cash, TQDate::currentDate().addDays(2))==b_cash-moT2);
- CPPUNIT_ASSERT(a.forecastBalance(a_cash, TQDate::currentDate().addDays(3))==b_cash-moT2);
+ CPPUNIT_ASSERT(a.forecastBalance(a_cash, TQDate::tqcurrentDate())==b_cash);
+ CPPUNIT_ASSERT(a.forecastBalance(a_cash, TQDate::tqcurrentDate().addDays(1))==b_cash);
+ CPPUNIT_ASSERT(a.forecastBalance(a_cash, TQDate::tqcurrentDate().addDays(2))==b_cash-moT2);
+ CPPUNIT_ASSERT(a.forecastBalance(a_cash, TQDate::tqcurrentDate().addDays(3))==b_cash-moT2);
}
void MyMoneyForecastTest::testAccountMinimumBalanceDateList() {
@@ -657,15 +657,15 @@ void MyMoneyForecastTest::testAccountMinimumBalanceDateList() {
//set up environment
MyMoneyForecast a;
- TransactionHelper t1( TQDate::currentDate().addDays(-2), MyMoneySplit::ActionWithdrawal, this->moT1, acCash, acSolo);
- TransactionHelper t2( TQDate::currentDate().addDays(-1), MyMoneySplit::ActionWithdrawal, this->moT2, acCash, acSolo);
+ TransactionHelper t1( TQDate::tqcurrentDate().addDays(-2), MyMoneySplit::ActionWithdrawal, this->moT1, acCash, acSolo);
+ TransactionHelper t2( TQDate::tqcurrentDate().addDays(-1), MyMoneySplit::ActionWithdrawal, this->moT2, acCash, acSolo);
a.setForecastMethod(1);
a.setForecastDays(6);
a.setAccountsCycle(2);
a.setForecastCycles(3);
a.setHistoryMethod(0);
- a.setBeginForecastDay(TQDate::currentDate().addDays(1).day());
+ a.setBeginForecastDay(TQDate::tqcurrentDate().addDays(1).day());
a.doForecast();
MyMoneyAccount a_cash = file->account(acCash);
@@ -678,13 +678,13 @@ void MyMoneyForecastTest::testAccountMinimumBalanceDateList() {
TQDate minDate = *it;
- CPPUNIT_ASSERT(minDate==TQDate::currentDate().addDays(2));
+ CPPUNIT_ASSERT(minDate==TQDate::tqcurrentDate().addDays(2));
it++;
minDate = *it;
- CPPUNIT_ASSERT(minDate==TQDate::currentDate().addDays(4));
+ CPPUNIT_ASSERT(minDate==TQDate::tqcurrentDate().addDays(4));
it++;
minDate = *it;
- CPPUNIT_ASSERT(minDate==TQDate::currentDate().addDays(6));
+ CPPUNIT_ASSERT(minDate==TQDate::tqcurrentDate().addDays(6));
}
@@ -692,15 +692,15 @@ void MyMoneyForecastTest::testAccountMaximumBalanceDateList() {
//set up environment
MyMoneyForecast a;
- TransactionHelper t1( TQDate::currentDate().addDays(-2), MyMoneySplit::ActionWithdrawal, this->moT1, acCash, acSolo);
- TransactionHelper t2( TQDate::currentDate().addDays(-1), MyMoneySplit::ActionWithdrawal, this->moT2, acCash, acSolo);
+ TransactionHelper t1( TQDate::tqcurrentDate().addDays(-2), MyMoneySplit::ActionWithdrawal, this->moT1, acCash, acSolo);
+ TransactionHelper t2( TQDate::tqcurrentDate().addDays(-1), MyMoneySplit::ActionWithdrawal, this->moT2, acCash, acSolo);
a.setForecastMethod(1);
a.setForecastDays(6);
a.setAccountsCycle(2);
a.setForecastCycles(3);
a.setHistoryMethod(0);
- a.setBeginForecastDay(TQDate::currentDate().addDays(1).day());
+ a.setBeginForecastDay(TQDate::tqcurrentDate().addDays(1).day());
a.doForecast();
MyMoneyAccount a_cash = file->account(acCash);
@@ -713,13 +713,13 @@ void MyMoneyForecastTest::testAccountMaximumBalanceDateList() {
TQDate maxDate = *it;
- CPPUNIT_ASSERT(maxDate==TQDate::currentDate().addDays(1));
+ CPPUNIT_ASSERT(maxDate==TQDate::tqcurrentDate().addDays(1));
it++;
maxDate = *it;
- CPPUNIT_ASSERT(maxDate==TQDate::currentDate().addDays(3));
+ CPPUNIT_ASSERT(maxDate==TQDate::tqcurrentDate().addDays(3));
it++;
maxDate = *it;
- CPPUNIT_ASSERT(maxDate==TQDate::currentDate().addDays(5));
+ CPPUNIT_ASSERT(maxDate==TQDate::tqcurrentDate().addDays(5));
}
@@ -728,8 +728,8 @@ void MyMoneyForecastTest::testAccountAverageBalance() {
//set up environment
MyMoneyForecast a;
- TransactionHelper t1( TQDate::currentDate().addDays(-2), MyMoneySplit::ActionWithdrawal, this->moT1, acCash, acSolo);
- TransactionHelper t2( TQDate::currentDate().addDays(-1), MyMoneySplit::ActionWithdrawal, this->moT2, acCash, acSolo);
+ TransactionHelper t1( TQDate::tqcurrentDate().addDays(-2), MyMoneySplit::ActionWithdrawal, this->moT1, acCash, acSolo);
+ TransactionHelper t2( TQDate::tqcurrentDate().addDays(-1), MyMoneySplit::ActionWithdrawal, this->moT2, acCash, acSolo);
a.setForecastMethod(1);
a.setForecastDays(3);
@@ -741,9 +741,9 @@ void MyMoneyForecastTest::testAccountAverageBalance() {
MyMoneyAccount a_cash = file->account(acCash);
//test
- MyMoneyMoney b_cash1 = a.forecastBalance(a_cash, TQDate::currentDate().addDays(1));
- MyMoneyMoney b_cash2 = a.forecastBalance(a_cash, TQDate::currentDate().addDays(2));
- MyMoneyMoney b_cash3 = a.forecastBalance(a_cash, TQDate::currentDate().addDays(3));
+ MyMoneyMoney b_cash1 = a.forecastBalance(a_cash, TQDate::tqcurrentDate().addDays(1));
+ MyMoneyMoney b_cash2 = a.forecastBalance(a_cash, TQDate::tqcurrentDate().addDays(2));
+ MyMoneyMoney b_cash3 = a.forecastBalance(a_cash, TQDate::tqcurrentDate().addDays(3));
MyMoneyMoney average = (b_cash1 + b_cash2 +b_cash3)/MyMoneyMoney(3,1);
@@ -765,7 +765,7 @@ void MyMoneyForecastTest::testBeginForecastDate() {
a.doForecast();
//test when using old method without begin day
- CPPUNIT_ASSERT(TQDate::currentDate() == a.beginForecastDate());
+ CPPUNIT_ASSERT(TQDate::tqcurrentDate() == a.beginForecastDate());
//setup begin to last day of month
a.setBeginForecastDay(31);
@@ -773,22 +773,22 @@ void MyMoneyForecastTest::testBeginForecastDate() {
a.doForecast();
//test
- if(TQDate::currentDate().day() < beginDay)
+ if(TQDate::tqcurrentDate().day() < beginDay)
{
- if(TQDate::currentDate().daysInMonth() < beginDay)
- beginDay = TQDate::currentDate().daysInMonth();
+ if(TQDate::tqcurrentDate().daysInMonth() < beginDay)
+ beginDay = TQDate::tqcurrentDate().daysInMonth();
- beginDate = TQDate(TQDate::currentDate().year(), TQDate::currentDate().month(), beginDay);
+ beginDate = TQDate(TQDate::tqcurrentDate().year(), TQDate::tqcurrentDate().month(), beginDay);
CPPUNIT_ASSERT(beginDate == a.beginForecastDate());
}
//setup begin day to same date
- a.setBeginForecastDay(TQDate::currentDate().day());
+ a.setBeginForecastDay(TQDate::tqcurrentDate().day());
beginDay = a.beginForecastDay();
a.doForecast();
- CPPUNIT_ASSERT(TQDate::currentDate() == a.beginForecastDate());
+ CPPUNIT_ASSERT(TQDate::tqcurrentDate() == a.beginForecastDate());
//setup to first day of month with small interval
a.setBeginForecastDay(1);
@@ -797,14 +797,14 @@ void MyMoneyForecastTest::testBeginForecastDate() {
a.doForecast();
//test
- if(TQDate::currentDate() == a.beginForecastDate()) {
- CPPUNIT_ASSERT(TQDate::currentDate() == a.beginForecastDate());
+ if(TQDate::tqcurrentDate() == a.beginForecastDate()) {
+ CPPUNIT_ASSERT(TQDate::tqcurrentDate() == a.beginForecastDate());
} else {
- beginDay = ((((TQDate::currentDate().day() - beginDay)/a.accountsCycle()) + 1) * a.accountsCycle()) + beginDay;
- if(beginDay > TQDate::currentDate().daysInMonth())
- beginDay = TQDate::currentDate().daysInMonth();
- beginDate = TQDate(TQDate::currentDate().year(), TQDate::currentDate().month(), beginDay);
- if(TQDate::currentDate().day() == TQDate::currentDate().daysInMonth() ) {
+ beginDay = ((((TQDate::tqcurrentDate().day() - beginDay)/a.accountsCycle()) + 1) * a.accountsCycle()) + beginDay;
+ if(beginDay > TQDate::tqcurrentDate().daysInMonth())
+ beginDay = TQDate::tqcurrentDate().daysInMonth();
+ beginDate = TQDate(TQDate::tqcurrentDate().year(), TQDate::tqcurrentDate().month(), beginDay);
+ if(TQDate::tqcurrentDate().day() == TQDate::tqcurrentDate().daysInMonth() ) {
std::cout << std::endl << "testBeginForecastDate(): test of first day of month with small interval skipped because it is the last day of month" << std::endl;
} else {
CPPUNIT_ASSERT(beginDate == a.beginForecastDate());
@@ -813,9 +813,9 @@ void MyMoneyForecastTest::testBeginForecastDate() {
//setup to test when current date plus cycle equals begin day
a.setAccountsCycle(14);
- beginDay = TQDate::currentDate().addDays(14).day();
+ beginDay = TQDate::tqcurrentDate().addDays(14).day();
a.setBeginForecastDay(beginDay);
- beginDate = TQDate::currentDate().addDays(14);
+ beginDate = TQDate::tqcurrentDate().addDays(14);
a.doForecast();
//test
@@ -826,10 +826,10 @@ void MyMoneyForecastTest::testBeginForecastDate() {
a.setAccountsCycle(40);
a.doForecast();
- beginDate = TQDate(TQDate::currentDate().addMonths(1).year(), TQDate::currentDate().addMonths(1).month(), 1);
+ beginDate = TQDate(TQDate::tqcurrentDate().addMonths(1).year(), TQDate::tqcurrentDate().addMonths(1).month(), 1);
//test
- if(TQDate::currentDate().day() > 1) {
+ if(TQDate::tqcurrentDate().day() > 1) {
CPPUNIT_ASSERT(beginDate == a.beginForecastDate());
} else {
//test is not valid if today is 1st of month
@@ -841,8 +841,8 @@ void MyMoneyForecastTest::testBeginForecastDate() {
{
MyMoneyForecast a;
- CPPUNIT_ASSERT(a.historyStartDate() == TQDate::currentDate().addDays(-a.forecastCycles()*a.accountsCycle()) );
- CPPUNIT_ASSERT(a.historyEndDate() == TQDate::currentDate().addDays(-1) );
+ CPPUNIT_ASSERT(a.historyStartDate() == TQDate::tqcurrentDate().addDays(-a.forecastCycles()*a.accountsCycle()) );
+ CPPUNIT_ASSERT(a.historyEndDate() == TQDate::tqcurrentDate().addDays(-1) );
CPPUNIT_ASSERT(a.historyDays() == a.forecastCycles()*a.accountsCycle());
a.setForecastMethod(1);
@@ -852,9 +852,9 @@ void MyMoneyForecastTest::testBeginForecastDate() {
a.setBeginForecastDay(0);
a.doForecast();
- CPPUNIT_ASSERT(a.historyStartDate() == TQDate::currentDate().addDays(-14*3) );
+ CPPUNIT_ASSERT(a.historyStartDate() == TQDate::tqcurrentDate().addDays(-14*3) );
CPPUNIT_ASSERT(a.historyDays() == (14*3));
- CPPUNIT_ASSERT(a.historyEndDate() == (TQDate::currentDate().addDays(-1)) );
+ CPPUNIT_ASSERT(a.historyEndDate() == (TQDate::tqcurrentDate().addDays(-1)) );
}
void MyMoneyForecastTest::testCreateBudget()
@@ -910,14 +910,14 @@ void MyMoneyForecastTest::testCreateBudget()
MyMoneySchedule::TYPE_BILL,
MyMoneySchedule::OCCUR_MONTHLY, 1,
MyMoneySchedule::STYPE_DIRECTDEBIT,
- TQDate::currentDate(),
+ TQDate::tqcurrentDate(),
TQDate(),
true,
true);
MyMoneyTransaction t10;
- t10.setPostDate(TQDate::currentDate().addMonths(1));
- t10.setEntryDate(TQDate::currentDate().addMonths(1));
+ t10.setPostDate(TQDate::tqcurrentDate().addMonths(1));
+ t10.setEntryDate(TQDate::tqcurrentDate().addMonths(1));
//t.setId("T000000000000000001");
t10.setBankID("BID");
t10.setMemo("Wohnung:Miete");
@@ -951,12 +951,12 @@ void MyMoneyForecastTest::testCreateBudget()
MyMoneyForecast c;
c.setForecastMethod(0);
c.setForecastCycles(1);
- c.createBudget(budget, TQDate::currentDate().addYears(-2), TQDate::currentDate().addYears(-1), TQDate::currentDate().addMonths(-2), TQDate::currentDate().addMonths(6), true);
+ c.createBudget(budget, TQDate::tqcurrentDate().addYears(-2), TQDate::tqcurrentDate().addYears(-1), TQDate::tqcurrentDate().addMonths(-2), TQDate::tqcurrentDate().addMonths(6), true);
- MyMoneyMoney c_parent = c.forecastBalance(a_parent, TQDate(TQDate::currentDate().addMonths(1).year(), TQDate::currentDate().addMonths(1).month(), 1) );
+ MyMoneyMoney c_parent = c.forecastBalance(a_parent, TQDate(TQDate::tqcurrentDate().addMonths(1).year(), TQDate::tqcurrentDate().addMonths(1).month(), 1) );
//test valid results
- CPPUNIT_ASSERT(c.forecastBalance(a_parent, TQDate(TQDate::currentDate().addMonths(1).year(), TQDate::currentDate().addMonths(1).month(), 1) ) == (moT2));
+ CPPUNIT_ASSERT(c.forecastBalance(a_parent, TQDate(TQDate::tqcurrentDate().addMonths(1).year(), TQDate::tqcurrentDate().addMonths(1).month(), 1) ) == (moT2));
}
void MyMoneyForecastTest::testLinearRegression() {
@@ -967,9 +967,9 @@ void MyMoneyForecastTest::testLinearRegression() {
MyMoneyAccount a_credit = file->account(acCredit);
//setup some transactions
- TransactionHelper t1( TQDate::currentDate().addDays(-1), MyMoneySplit::ActionWithdrawal, this->moT1, acChecking, acSolo);
- TransactionHelper t2( TQDate::currentDate().addDays(-1), MyMoneySplit::ActionDeposit, -(this->moT2), acCredit, acParent);
- TransactionHelper t3( TQDate::currentDate().addDays(-1), MyMoneySplit::ActionTransfer, this->moT1, acCredit, acChecking);
+ TransactionHelper t1( TQDate::tqcurrentDate().addDays(-1), MyMoneySplit::ActionWithdrawal, this->moT1, acChecking, acSolo);
+ TransactionHelper t2( TQDate::tqcurrentDate().addDays(-1), MyMoneySplit::ActionDeposit, -(this->moT2), acCredit, acParent);
+ TransactionHelper t3( TQDate::tqcurrentDate().addDays(-1), MyMoneySplit::ActionTransfer, this->moT1, acCredit, acChecking);
//TODO Add tests specific for linear regression