MyMoneyForecast Class Reference

#include <mymoneyforecast.h>

Collaboration diagram for MyMoneyForecast:

Collaboration graph

List of all members.

Public Member Functions

 MyMoneyForecast ()
 ~MyMoneyForecast ()
void doForecast ()
QValueList< MyMoneyAccountaccountList (void)
MyMoneyMoney forecastBalance (const MyMoneyAccount &acc, QDate forecastDate)
MyMoneyMoney forecastBalance (const MyMoneyAccount &acc, int offset)
bool isForecastAccount (const MyMoneyAccount &acc)
int daysToMinimumBalance (const MyMoneyAccount &acc)
int daysToZeroBalance (const MyMoneyAccount &acc)
MyMoneyMoney accountCycleVariation (const MyMoneyAccount &acc)
MyMoneyMoney accountTotalVariation (const MyMoneyAccount &acc)
QValueList< QDate > accountMinimumBalanceDateList (const MyMoneyAccount &acc)
QValueList< QDate > accountMaximumBalanceDateList (const MyMoneyAccount &acc)
MyMoneyMoney accountAverageBalance (const MyMoneyAccount &acc)
void createBudget (MyMoneyBudget &budget, QDate historyStart, QDate historyEnd, QDate budgetStart, QDate budgetEnd, const bool returnBudget)
int historyDays (void) const
void setAccountsCycle (int accountsCycle)
void setForecastCycles (int forecastCycles)
void setForecastDays (int forecastDays)
void setBeginForecastDate (QDate beginForecastDate)
void setBeginForecastDay (int beginDay)
void setForecastMethod (int forecastMethod)
void setHistoryStartDate (QDate historyStartDate)
void setHistoryEndDate (QDate historyEndDate)
void setHistoryStartDate (int daysToStartDate)
void setHistoryEndDate (int daysToEndDate)
void setForecastStartDate (QDate _startDate)
void setForecastEndDate (QDate _endDate)
void setSkipOpeningDate (bool _skip)
void setHistoryMethod (int historyMethod)
void setIncludeUnusedAccounts (bool _bool)
void setForecastDone (bool _bool)
void setIncludeFutureTransactions (bool _bool)
void setIncludeScheduledTransactions (bool _bool)
int accountsCycle (void) const
int forecastCycles (void) const
int forecastDays (void) const
QDate beginForecastDate (void) const
int beginForecastDay (void) const
int forecastMethod (void) const
QDate historyStartDate (void) const
QDate historyEndDate (void) const
QDate forecastStartDate (void) const
QDate forecastEndDate (void) const
bool skipOpeningDate (void) const
int historyMethod (void) const
bool isIncludingUnusedAccounts (void) const
bool isForecastDone (void) const
bool isIncludingFutureTransactions (void) const
bool isIncludingScheduledTransactions (void) const

Static Public Member Functions

static MyMoneyMoney calculateAccountTrend (const MyMoneyAccount &acc, int forecastDays)
static void calculateAutoLoan (const MyMoneySchedule &schedule, MyMoneyTransaction &transaction, const QMap< QString, MyMoneyMoney > &balances)

Private Types

enum  EForecastMethod { eScheduled = 0, eHistoric = 1 }
typedef QMap< QDate, MyMoneyMoneydailyBalances
typedef QMap< int, MyMoneyMoneytrendBalances

Private Member Functions

QValueList< MyMoneyAccountbudgetAccountList (void)
void calculateHistoricDailyBalances (void)
void calculateHistoricMonthlyBalances ()
void calculateScheduledMonthlyBalances ()
void doFutureScheduledForecast (void)
void addFutureTransactions (void)
void addScheduledTransactions (void)
void calculateScheduledDailyBalances (void)
void setStartingBalance (const MyMoneyAccount &acc)
MyMoneyMoney accountMovingAverage (const MyMoneyAccount &acc, const int trendDay, const int forecastTerms)
MyMoneyMoney accountWeightedMovingAverage (const MyMoneyAccount &acc, const int trendDay, const int totalWeight)
MyMoneyMoney accountLinearRegression (const MyMoneyAccount &acc, const int trendDay, const int totalWeight, const MyMoneyMoney meanTerms)
void calculateAccountTrendList (void)
void setForecastAccountList (void)
void setBudgetAccountList (void)
void pastTransactions (void)
int calculateBeginForecastDay ()
void purgeForecastAccountsList (QMap< QString, dailyBalances > &accountList)

Static Private Member Functions

static QValueList< MyMoneyAccountforecastAccountList (void)

Private Attributes

QMap< QString, dailyBalancesm_accountList
QMap< QString, dailyBalancesm_accountListPast
QMap< QString, trendBalancesm_accountTrendList
QMap< QString, QString > m_nameIdx
int m_accountsCycle
int m_forecastCycles
int m_forecastDays
QDate m_beginForecastDate
int m_beginForecastDay
int m_forecastMethod
int m_historyMethod
QDate m_historyStartDate
QDate m_historyEndDate
QDate m_forecastStartDate
QDate m_forecastEndDate
bool m_skipOpeningDate
bool m_includeUnusedAccounts
bool m_forecastDone
bool m_includeFutureTransactions
bool m_includeScheduledTransactions

Detailed Description

Alvaro Soliverez <>

Member Typedef Documentation

daily balances of an account

map of trends of an account

Member Enumeration Documentation


Constructor & Destructor Documentation

MyMoneyForecast::MyMoneyForecast (  ) 

MyMoneyForecast::~MyMoneyForecast (  ) 

Member Function Documentation

void MyMoneyForecast::doForecast (  ) 

calculate forecast based on historic transactions

QValueList<MyMoneyAccount> MyMoneyForecast::accountList ( void   ) 

Returns the list of accounts to be forecast.

static MyMoneyMoney MyMoneyForecast::calculateAccountTrend ( const MyMoneyAccount acc,
int  forecastDays 
) [static]

Returns the balance trend for account acc based on a number of days forecastDays Collects and processes all transactions in the past for the same period of forecast and calculates the balance trend

MyMoneyMoney MyMoneyForecast::forecastBalance ( const MyMoneyAccount acc,
QDate  forecastDate 

Returns the forecast balance trend for account acc for day QDate

MyMoneyMoney MyMoneyForecast::forecastBalance ( const MyMoneyAccount acc,
int  offset 

Returns the forecast balance trend for account acc for offset int offset is days from current date, inside forecast days. Returns 0 if offset not in range of forecast days.

bool MyMoneyForecast::isForecastAccount ( const MyMoneyAccount acc  ) 

Returns true if an account acc is an account to be forecast

int MyMoneyForecast::daysToMinimumBalance ( const MyMoneyAccount acc  ) 

returns the number of days when a given account is forecast to be below minimum balance returns -1 if it will not be below minimum balance in the forecast period

int MyMoneyForecast::daysToZeroBalance ( const MyMoneyAccount acc  ) 

returns the number of days when a given account is forecast to be below zero if it is an asset accounts or above zero if it is a liability account returns -1 if it will not happen in the forecast period

MyMoneyMoney MyMoneyForecast::accountCycleVariation ( const MyMoneyAccount acc  ) 

amount of variation of a given account in one cycle

MyMoneyMoney MyMoneyForecast::accountTotalVariation ( const MyMoneyAccount acc  ) 

amount of variation of a given account for the whole forecast period

QValueList<QDate> MyMoneyForecast::accountMinimumBalanceDateList ( const MyMoneyAccount acc  ) 

returns a list of the dates where the account was on its lowest balance in each cycle

QValueList<QDate> MyMoneyForecast::accountMaximumBalanceDateList ( const MyMoneyAccount acc  ) 

returns a list of the dates where the account was on its highest balance in each cycle

MyMoneyMoney MyMoneyForecast::accountAverageBalance ( const MyMoneyAccount acc  ) 

returns the average balance of the account within the forecast period

void MyMoneyForecast::createBudget ( MyMoneyBudget budget,
QDate  historyStart,
QDate  historyEnd,
QDate  budgetStart,
QDate  budgetEnd,
const bool  returnBudget 

creates a budget based on the history of a given timeframe

int MyMoneyForecast::historyDays ( void   )  const [inline]

number of days to go back in history to calculate forecast

void MyMoneyForecast::setAccountsCycle ( int  accountsCycle  )  [inline]

void MyMoneyForecast::setForecastCycles ( int  forecastCycles  )  [inline]

void MyMoneyForecast::setForecastDays ( int  forecastDays  )  [inline]

void MyMoneyForecast::setBeginForecastDate ( QDate  beginForecastDate  )  [inline]

void MyMoneyForecast::setBeginForecastDay ( int  beginDay  )  [inline]

void MyMoneyForecast::setForecastMethod ( int  forecastMethod  )  [inline]

void MyMoneyForecast::setHistoryStartDate ( QDate  historyStartDate  )  [inline]

void MyMoneyForecast::setHistoryEndDate ( QDate  historyEndDate  )  [inline]

void MyMoneyForecast::setHistoryStartDate ( int  daysToStartDate  )  [inline]

void MyMoneyForecast::setHistoryEndDate ( int  daysToEndDate  )  [inline]

void MyMoneyForecast::setForecastStartDate ( QDate  _startDate  )  [inline]

void MyMoneyForecast::setForecastEndDate ( QDate  _endDate  )  [inline]

void MyMoneyForecast::setSkipOpeningDate ( bool  _skip  )  [inline]

void MyMoneyForecast::setHistoryMethod ( int  historyMethod  )  [inline]

void MyMoneyForecast::setIncludeUnusedAccounts ( bool  _bool  )  [inline]

void MyMoneyForecast::setForecastDone ( bool  _bool  )  [inline]

void MyMoneyForecast::setIncludeFutureTransactions ( bool  _bool  )  [inline]

void MyMoneyForecast::setIncludeScheduledTransactions ( bool  _bool  )  [inline]

int MyMoneyForecast::accountsCycle ( void   )  const [inline]

int MyMoneyForecast::forecastCycles ( void   )  const [inline]

int MyMoneyForecast::forecastDays ( void   )  const [inline]

QDate MyMoneyForecast::beginForecastDate ( void   )  const [inline]

int MyMoneyForecast::beginForecastDay ( void   )  const [inline]

int MyMoneyForecast::forecastMethod ( void   )  const [inline]

QDate MyMoneyForecast::historyStartDate ( void   )  const [inline]

QDate MyMoneyForecast::historyEndDate ( void   )  const [inline]

QDate MyMoneyForecast::forecastStartDate ( void   )  const [inline]

QDate MyMoneyForecast::forecastEndDate ( void   )  const [inline]

bool MyMoneyForecast::skipOpeningDate ( void   )  const [inline]

int MyMoneyForecast::historyMethod ( void   )  const [inline]

bool MyMoneyForecast::isIncludingUnusedAccounts ( void   )  const [inline]

bool MyMoneyForecast::isForecastDone ( void   )  const [inline]

bool MyMoneyForecast::isIncludingFutureTransactions ( void   )  const [inline]

bool MyMoneyForecast::isIncludingScheduledTransactions ( void   )  const [inline]

static void MyMoneyForecast::calculateAutoLoan ( const MyMoneySchedule schedule,
MyMoneyTransaction transaction,
const QMap< QString, MyMoneyMoney > &  balances 
) [static]

This method modifies a scheduled loan transaction such that all references to automatic calculated values are resolved to actual values.

schedule const reference to the schedule the transaction is based on
transaction reference to the transaction to be checked and modified
balances QMap of (account-id,balance) pairs to be used as current balance for the calculation of interest. If map is empty, the engine will be interrogated for current balances.

static QValueList<MyMoneyAccount> MyMoneyForecast::forecastAccountList ( void   )  [static, private]

Returns the list of accounts to be forecast. Only Asset and Liability are returned.

QValueList<MyMoneyAccount> MyMoneyForecast::budgetAccountList ( void   )  [private]

Returns the list of accounts to create a budget. Only Income and Expenses are returned.

void MyMoneyForecast::calculateHistoricDailyBalances ( void   )  [private]

calculate daily forecast balance based on historic transactions

void MyMoneyForecast::calculateHistoricMonthlyBalances (  )  [private]

calculate monthly budget balance based on historic transactions

void MyMoneyForecast::calculateScheduledMonthlyBalances (  )  [private]

calculate monthly budget balance based on historic transactions

void MyMoneyForecast::doFutureScheduledForecast ( void   )  [private]

calculate forecast based on future and scheduled transactions

void MyMoneyForecast::addFutureTransactions ( void   )  [private]

add future transactions to forecast

void MyMoneyForecast::addScheduledTransactions ( void   )  [private]

add scheduled transactions to forecast

void MyMoneyForecast::calculateScheduledDailyBalances ( void   )  [private]

calculate daily forecast balance based on future and scheduled transactions

void MyMoneyForecast::setStartingBalance ( const MyMoneyAccount acc  )  [private]

set the starting balance for an accounts

MyMoneyMoney MyMoneyForecast::accountMovingAverage ( const MyMoneyAccount acc,
const int  trendDay,
const int  forecastTerms 
) [private]

Returns the day moving average for the account acc based on the daily balances of a given number of forecastTerms It returns the moving average for a given trendDay of the forecastTerm With a term of 1 month and 3 terms, it calculates the trend taking the transactions occured at that day and the day before,for the last 3 months

MyMoneyMoney MyMoneyForecast::accountWeightedMovingAverage ( const MyMoneyAccount acc,
const int  trendDay,
const int  totalWeight 
) [private]

Returns the weighted moving average for a given trendDay

MyMoneyMoney MyMoneyForecast::accountLinearRegression ( const MyMoneyAccount acc,
const int  trendDay,
const int  totalWeight,
const MyMoneyMoney  meanTerms 
) [private]

Returns the linear regression for a given trendDay

void MyMoneyForecast::calculateAccountTrendList ( void   )  [private]

calculate daily forecast trend based on historic transactions

void MyMoneyForecast::setForecastAccountList ( void   )  [private]

set the internal list of accounts to be forecast

void MyMoneyForecast::setBudgetAccountList ( void   )  [private]

set the internal list of accounts to create a budget

void MyMoneyForecast::pastTransactions ( void   )  [private]

get past transactions for the accounts to be forecast

int MyMoneyForecast::calculateBeginForecastDay (  )  [private]

calculate the day to start forecast and sets the begin date The quantity of forecast days will be counted from this date Depends on the values of begin day and accounts cycle The rules to calculate begin day are as follows:

  • if beginDay is 0, begin date is current date
  • if the day of the month set by beginDay has not passed, that will be used
  • if adding an account cycle to beginDay, will not go past the beginDay of next month, that date will be used, otherwise it will add account cycle to beginDay until it is past current date It returns the total amount of Forecast Days from current date.

void MyMoneyForecast::purgeForecastAccountsList ( QMap< QString, dailyBalances > &  accountList  )  [private]

remove accounts from the list if the accounts has no transactions in the forecast timeframe. Used for scheduled-forecast method.

Member Data Documentation

daily forecast balance of accounts

daily past balance of accounts

daily forecast trends of accounts

QMap<QString, QString> MyMoneyForecast::m_nameIdx [private]

list of forecast accounts

cycle of accounts in days

number of cycles to use in forecast

number of days to forecast

date to start forecast

day to start forecast

forecast method

history method

start date of history

end date of history

start date of forecast

end date of forecast

skip opening date when fetching transactions of an account

include accounts with no transactions in the forecast timeframe. default is false.

forecast already done

include future transactions when doing a scheduled-based forecast

include scheduled transactions when doing a scheduled-based forecast

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

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