MyMoneyFinancialCalculator Class Reference

#include <mymoneyfinancialcalculator.h>

Collaboration diagram for MyMoneyFinancialCalculator:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 MyMoneyFinancialCalculator ()
 ~MyMoneyFinancialCalculator ()
FCALC_DOUBLE numPayments ()
FCALC_DOUBLE payment ()
FCALC_DOUBLE presentValue ()
FCALC_DOUBLE futureValue ()
FCALC_DOUBLE interestRate ()
FCALC_DOUBLE interestDue (void) const
void setPrec (const unsigned short prec=2)
void setNpp (const FCALC_DOUBLE npp)
FCALC_DOUBLE npp (void) const
void setPF (const unsigned short PF=12)
void setCF (const unsigned short CF=12)
void setBep (const bool bep=false)
void setDisc (const bool disc=true)
void setIr (const FCALC_DOUBLE ir)
FCALC_DOUBLE ir (void) const
void setPv (const FCALC_DOUBLE pv)
FCALC_DOUBLE pv (void) const
void setPmt (const FCALC_DOUBLE pmt)
FCALC_DOUBLE pmt (void) const
void setFv (const FCALC_DOUBLE fv)
FCALC_DOUBLE fv (void) const

Private Member Functions

FCALC_DOUBLE eff_int (void) const
FCALC_DOUBLE nom_int (const FCALC_DOUBLE eint) const
FCALC_DOUBLE rnd (const FCALC_DOUBLE x) const
FCALC_DOUBLE _Ax (const FCALC_DOUBLE eint) const
FCALC_DOUBLE _Bx (const FCALC_DOUBLE eint) const
FCALC_DOUBLE _Cx (const FCALC_DOUBLE eint) const
FCALC_DOUBLE _fi (const FCALC_DOUBLE eint) const
FCALC_DOUBLE _fip (const FCALC_DOUBLE eint) const

Private Attributes

FCALC_DOUBLE m_ir
FCALC_DOUBLE m_pv
FCALC_DOUBLE m_pmt
FCALC_DOUBLE m_fv
FCALC_DOUBLE m_npp
unsigned short m_CF
unsigned short m_PF
unsigned short m_prec
bool m_bep
bool m_disc
unsigned short m_mask


Detailed Description

Author:
Thomas Baumgart This class implements the financial calculator as found in GNUCash. For a detailed description of the algorithms see gnucash-1.8.5/src/doc/finutil.html.

Constructor & Destructor Documentation

MyMoneyFinancialCalculator::MyMoneyFinancialCalculator (  ) 

MyMoneyFinancialCalculator::~MyMoneyFinancialCalculator (  ) 


Member Function Documentation

FCALC_DOUBLE MyMoneyFinancialCalculator::numPayments (  ) 

This method calculates the number of payments required to amortize the loan. ir, pv, fv and pmt must be set. It sets the member variable m_npp with the calculated value.

Returns:
number of periodic payments
Exceptions:
If one of the required values is not set, a MyMoneyException will be thrown

FCALC_DOUBLE MyMoneyFinancialCalculator::payment (  ) 

This method calculates the amount of the payment (amortization and interest) for the loan. ir, pv, fv and npp must be set. It sets the member variable m_pmt with the calculated value.

Returns:
amount of payment
Exceptions:
If one of the required values is not set, a MyMoneyException will be thrown

FCALC_DOUBLE MyMoneyFinancialCalculator::presentValue (  ) 

This method calculates the present value for the loan. ir, pmt, fv and npp must be set. It sets the member variable m_pv with the calculated value.

Returns:
present value of loan
Exceptions:
If one of the required values is not set, a MyMoneyException will be thrown

FCALC_DOUBLE MyMoneyFinancialCalculator::futureValue (  ) 

This method calculates the future value for the loan. ir, pmt, pv and npp must be set. It sets the member variable m_fv with the calculated value.

Returns:
future value of loan
Exceptions:
If one of the required values is not set, a MyMoneyException will be thrown

FCALC_DOUBLE MyMoneyFinancialCalculator::interestRate (  ) 

This method calculates the nominal interest rate for the loan. fv, pmt, pv and npp must be set. It sets the member variable m_ir with the calculated value.

Returns:
interest rate of the loan
Exceptions:
If one of the required values is not set, a MyMoneyException will be thrown

FCALC_DOUBLE MyMoneyFinancialCalculator::interestDue ( void   )  const

This method calculates the interest due for the next payment according to the equation

id[n] = (pv[n-1] + (X * pmt)) * i

with

  • pv[n-1]
    the present value at the end of the last period
  • X
    0 for end of period payments, 1 for beginning of period payments
  • pmt
    the periodic payment amount and
  • i
    the effective interest rate

pv[n-1] will be the value as set with setPv(), i will be calculated from the nominal interest rate as set with setIr(), pmt will be the value as set with setPmt() and X is determined by the argument to setBep().

Returns:
the interest amount

void MyMoneyFinancialCalculator::setPrec ( const unsigned short  prec = 2  ) 

This method sets the rounding precision to prec fractional digits. The default of is 2. Rounding is applied to pv, pmt and fv.

Parameters:
prec Number of fractional digits after rounding.

void MyMoneyFinancialCalculator::setNpp ( const FCALC_DOUBLE  npp  ) 

This method sets the number of payment periods to the value passed in parameter npp. The length of a period is controlled via setPF().

Parameters:
npp number of payment periods

FCALC_DOUBLE MyMoneyFinancialCalculator::npp ( void   )  const [inline]

void MyMoneyFinancialCalculator::setPF ( const unsigned short  PF = 12  ) 

This method sets the payment frequency. The parameter PF specifies the payments per year.

  • 1 == annual
  • 2 == semi-annual
  • 3 == tri-annual
  • 4 == quaterly
  • 6 == bi-monthly
  • 12 == monthly
  • 24 == semi-monthly
  • 26 == bi-weekly
  • 52 == weekly
  • 360 == daily
  • 365 == daily

Parameters:
PF length of payment period (default is 12 - monthly)

void MyMoneyFinancialCalculator::setCF ( const unsigned short  CF = 12  ) 

This method sets the compounding frequency. The parameter CF specifies the compounding period per year.

  • 1 == annual
  • 2 == semi-annual
  • 3 == tri-annual
  • 4 == quaterly
  • 6 == bi-monthly
  • 12 == monthly
  • 24 == semi-monthly
  • 26 == bi-weekly
  • 52 == weekly
  • 360 == daily
  • 365 == daily

Parameters:
CF length of compounding period (default is 12 - monthly)

void MyMoneyFinancialCalculator::setBep ( const bool  bep = false  ) 

This method controls whether the interest will be calculated at the end of the payment period of at it's beginning.

Parameters:
bep if false (default) then the interest is due at the end of the payment period, if true at it's beginning.

void MyMoneyFinancialCalculator::setDisc ( const bool  disc = true  ) 

This method controls whether the interest is compounded in periods or continously.

Parameters:
disc if true (default) then the interest is compounded in periods, if false continously.

void MyMoneyFinancialCalculator::setIr ( const FCALC_DOUBLE  ir  ) 

This method sets the nominal interest rate to the value passed in the argument ir.

Parameters:
ir nominal interest rate

FCALC_DOUBLE MyMoneyFinancialCalculator::ir ( void   )  const [inline]

void MyMoneyFinancialCalculator::setPv ( const FCALC_DOUBLE  pv  ) 

This method sets the present value to the value passed in the argument pv.

Parameters:
pv present value

FCALC_DOUBLE MyMoneyFinancialCalculator::pv ( void   )  const [inline]

void MyMoneyFinancialCalculator::setPmt ( const FCALC_DOUBLE  pmt  ) 

This method sets the payment amount to the value passed in the argument pmt.

Parameters:
pmt payment amount

FCALC_DOUBLE MyMoneyFinancialCalculator::pmt ( void   )  const [inline]

void MyMoneyFinancialCalculator::setFv ( const FCALC_DOUBLE  fv  ) 

This method sets the future value to the value passed in the argument fv.

Parameters:
fv future value

FCALC_DOUBLE MyMoneyFinancialCalculator::fv ( void   )  const [inline]

FCALC_DOUBLE MyMoneyFinancialCalculator::eff_int ( void   )  const [private]

FCALC_DOUBLE MyMoneyFinancialCalculator::nom_int ( const FCALC_DOUBLE  eint  )  const [private]

FCALC_DOUBLE MyMoneyFinancialCalculator::rnd ( const FCALC_DOUBLE  x  )  const [private]

FCALC_DOUBLE MyMoneyFinancialCalculator::_Ax ( const FCALC_DOUBLE  eint  )  const [private]

FCALC_DOUBLE MyMoneyFinancialCalculator::_Bx ( const FCALC_DOUBLE  eint  )  const [private]

FCALC_DOUBLE MyMoneyFinancialCalculator::_Cx ( const FCALC_DOUBLE  eint  )  const [private]

FCALC_DOUBLE MyMoneyFinancialCalculator::_fi ( const FCALC_DOUBLE  eint  )  const [private]

FCALC_DOUBLE MyMoneyFinancialCalculator::_fip ( const FCALC_DOUBLE  eint  )  const [private]


Member Data Documentation

FCALC_DOUBLE MyMoneyFinancialCalculator::m_ir [private]

FCALC_DOUBLE MyMoneyFinancialCalculator::m_pv [private]

FCALC_DOUBLE MyMoneyFinancialCalculator::m_pmt [private]

FCALC_DOUBLE MyMoneyFinancialCalculator::m_fv [private]

FCALC_DOUBLE MyMoneyFinancialCalculator::m_npp [private]

unsigned short MyMoneyFinancialCalculator::m_CF [private]

unsigned short MyMoneyFinancialCalculator::m_PF [private]

unsigned short MyMoneyFinancialCalculator::m_prec [private]

unsigned short MyMoneyFinancialCalculator::m_mask [private]


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