org.eclipse.birt.core.script
Class Finance

java.lang.Object
  extended by org.eclipse.birt.core.script.Finance

public class Finance
extends java.lang.Object

Defines a set of static methods that support a number of widely-used financial functions.


Method Summary
static double ddb(double cost, double salvage, double life, int period)
           
static double fv(double rate, int nPer, double pmt, double pv, int due)
           
static double ipmt(double rate, int per, int nPer, double pv, double fv, int due)
           
static double irr(double[] cash, double intrate)
           
static double mirr(double[] arptr, double frate, double rrate)
           
static double nper(double rate, double pmt, double pv, double fv, int due)
          *
static double nPer(double rate, double pmt, double pv, double fv, int due)
          Deprecated. use nper instead
static double npv(double rate, double[] arptr)
           
static double percent(double denom, double num, double valueIfZero)
           
static double pmt(double rate, int nper, double pv, double fv, int due)
           
static double ppmt(double rate, int per, int nPer, double pv, double fv, int due)
           
static double pv(double rate, int nPer, double pmt, double fv, int due)
           
static double rate(int nPer, double pmt, double pv, double fv, int due, double guess)
           
static double sln(double cost, double salvage, double life)
           
static double syd(double cost, double salvage, double life, int period)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

ddb

public static double ddb(double cost,
                         double salvage,
                         double life,
                         int period)
                  throws java.lang.IllegalArgumentException
Parameters:
Cost - the initial cost of the asset.
salvage - the value at the end of the depreciation (sometimes called the salvage value of the asset).
life - the number of periods over which the asset is being depreciated (sometimes called the useful life of the asset).
period - the period for which you want to calculate the depreciation. Period must use the same units as life.
Returns:
the depreciation of an asset for a given , single period using the double-declning balance method Remarks The double-declining balance method computes depreciation at an accelerated rate. Depreciation is highest in the first period and decreases in successive periods. DDB uses the following formula to calculate depreciation for a period: ((cost-salvage) - total depreciation from prior periods) * (factor/life) Change factor if you do not want to use the double-declining balance method. Use the VDB function if you want to switch to the straight-line depreciation method when depreciation is greater than the declining balance calculation.
Throws:
java.lang.IllegalArgumentException

sln

public static double sln(double cost,
                         double salvage,
                         double life)
                  throws java.lang.IllegalArgumentException
Parameters:
cost - the initial cost of the asset.
salvage - the value at the end of the depreciation (sometimes called the salvage value of the asset).
life - the number of periods over which the asset is depreciated (sometimes called the useful life of the asset).
Returns:
the straight-line depreciation of an asset for a single period
Throws:
java.lang.IllegalArgumentException

syd

public static double syd(double cost,
                         double salvage,
                         double life,
                         int period)
                  throws java.lang.IllegalArgumentException
Parameters:
cost - the initial cost of the asset.
salvage - the value at the end of the depreciation (sometimes called the salvage value of the asset).
life - the number of periods over which the asset is depreciated (sometimes called the useful life of the asset).
period - the period and must use the same units as life.
Returns:
sum-of-years'-digits deprciation of an asset for a specified period Remark SYD is calculated as follows: SYD=(cost-salvage)*(life-per+1)*2/(life*(life+1))
Throws:
java.lang.IllegalArgumentException

fv

public static double fv(double rate,
                        int nPer,
                        double pmt,
                        double pv,
                        int due)
                 throws java.lang.IllegalArgumentException
Parameters:
rate - the interest rate per period.
nPer - the total number of payment periods in an annuity.
pmt - the payment made each period; it cannot change over the life of the annuity. Typically, pmt contains principal and interest but no other fees or taxes. If pmt is omitted, you must include the pv argument.
pv - the present value, or the lump-sum amount that a series of future payments is worth right now. If pv is omitted, it is assumed to be 0 (zero), and you must include the pmt argument.
due - the number 0 or 1 and indicates when payments are due. If type is omitted, it is assumed to be 0.
Returns:
the future value of an annuity based on periodic , constant payments,and on an unvarying interest rate Make sure that you are consistent about the units you use for specifying rate and nper. Remarks Make sure that you are consistent about the units you use for specifying rate and nper. If you make monthly payments on a four-year loan at 12 percent annual interest, use 12%/12 for rate and 4*12 for nper. If you make annual payments on the same loan, use 12% for rate and 4 for nper. For all the arguments, cash you pay out, such as deposits to savings, is represented by negative numbers; cash you receive, such as dividend checks, is represented by positive numbers.
Throws:
java.lang.IllegalArgumentException

pmt

public static double pmt(double rate,
                         int nper,
                         double pv,
                         double fv,
                         int due)
                  throws java.lang.IllegalArgumentException
Parameters:
rate - the interest rate per period.
nPer - the total number of payment periods in an annuity.
pv - the present value, or the lump-sum amount that a series of future payments is worth right now. If pv is omitted, it is assumed to be 0 (zero), and you must include the pmt argument.
due - the number 0 or 1 and indicates when payments are due. If type is omitted, it is assumed to be 0.
Returns:
the payment for an annuity, based on periodic , constant payments, and on an unvarying interest rate. The payment returned by PMT includes principal and interest but no taxes, reserve payments, or fees sometimes associated with loans. Make sure that you are consistent about the units you use for specifying rate and nper. If you make monthly payments on a four-year loan at an annual interest rate of 12 percent, use 12%/12 for rate and 4*12 for nper. If you make annual payments on the same loan, use 12 percent for rate and 4 for nper.
Throws:
java.lang.IllegalArgumentException

ipmt

public static double ipmt(double rate,
                          int per,
                          int nPer,
                          double pv,
                          double fv,
                          int due)
                   throws java.lang.IllegalArgumentException
Parameters:
rate - the interest rate per period.
nPer - the total number of payment periods in an annuity.
pv - the present value, or the lump-sum amount that a series of future payments is worth right now. If pv is omitted, it is assumed to be 0 (zero), and you must include the pmt argument.
due - the number 0 or 1 and indicates when payments are due. If type is omitted, it is assumed to be 0.
per - the period for which you want to find the interest and must be in the range 1 to nper.
fv - the future value, or a cash balance you want to attain after the last payment is made. If fv is omitted, it is assumed to be 0 (the future value of a loan, for example, is 0).
Returns:
the interest payment for a given period of an annuity, based on periodic , constant payments, and on an unvarying interest rate Remarks Make sure that you are consistent about the units you use for specifying rate and nper. If you make monthly payments on a four-year loan at 12 percent annual interest, use 12%/12 for rate and 4*12 for nper. If you make annual payments on the same loan, use 12% for rate and 4 for nper. For all the arguments, cash you pay out, such as deposits to savings, is represented by negative numbers; cash you receive, such as dividend checks, is represented by positive numbers.
Throws:
java.lang.IllegalArgumentException

ppmt

public static double ppmt(double rate,
                          int per,
                          int nPer,
                          double pv,
                          double fv,
                          int due)
                   throws java.lang.IllegalArgumentException
Parameters:
rate - the interest rate per period.
nPer - the total number of payment periods in an annuity.
pv - the present value, or the lump-sum amount that a series of future payments is worth right now. If pv is omitted, it is assumed to be 0 (zero), and you must include the pmt argument.
due - the number 0 or 1 and indicates when payments are due. If type is omitted, it is assumed to be 0.
per - the period for which you want to find the interest and must be in the range 1 to nper.
fv - the future value, or a cash balance you want to attain after the last payment is made. If fv is omitted, it is assumed to be 0 (the future value of a loan, for example, is 0).
Returns:
the principal payment for a given period of an annuity, based on periodic, constant payments, and on an unvarying interest rate Remark Make sure that you are consistent about the units you use for specifying rate and nper. If you make monthly payments on a four-year loan at 12 percent annual interest, use 12%/12 for rate and 4*12 for nper. If you make annual payments on the same loan, use 12% for rate and 4 for nper.
Throws:
java.lang.IllegalArgumentException

nper

public static double nper(double rate,
                          double pmt,
                          double pv,
                          double fv,
                          int due)
                   throws java.lang.IllegalArgumentException
*

Parameters:
rate - the interest rate per period.
pv - the present value, or the lump-sum amount that a series of future payments is worth right now. If pv is omitted, it is assumed to be 0 (zero), and you must include the pmt argument.
due - the number 0 or 1 and indicates when payments are due. If type is omitted, it is assumed to be 0.
fv - the future value, or a cash balance you want to attain after the last payment is made. If fv is omitted, it is assumed to be 0 (the future value of a loan, for example, is 0).
pmt - the payment made each period; it cannot change over the life of the annuity. Typically, pmt contains principal and interest but no other fees or taxes.
Returns:
the number of periods for an annuity based on periodic , constant payments, and on an unvarying interest rate
Throws:
java.lang.IllegalArgumentException

nPer

public static double nPer(double rate,
                          double pmt,
                          double pv,
                          double fv,
                          int due)
                   throws java.lang.IllegalArgumentException
Deprecated. use nper instead

Throws:
java.lang.IllegalArgumentException

pv

public static double pv(double rate,
                        int nPer,
                        double pmt,
                        double fv,
                        int due)
                 throws java.lang.IllegalArgumentException
Parameters:
rate - the interest rate per period.
due - the number 0 or 1 and indicates when payments are due. If type is omitted, it is assumed to be 0.
fv - the future value, or a cash balance you want to attain after the last payment is made. If fv is omitted, it is assumed to be 0 (the future value of a loan, for example, is 0).
pmt - the payment made each period; it cannot change over the life of the annuity. Typically, pmt contains principal and interest but no other fees or taxes.
nPer - the total number of payment periods in an annuity. For example, if you get a four-year car loan and make monthly payments, your loan has 4*12 (or 48) periods. You would enter 48 into the formula for nper.
Returns:
the present value of an annuity based on periodic, constant payments to be paid in the future,and on an unvarying interest rate Remarks Make sure that you are consistent about the units you use for specifying rate and nper. If you make monthly payments on a four-year loan at 12 percent annual interest, use 12%/12 for rate and 4*12 for nper. If you make annual payments on the same loan, use 12% for rate and 4 for nper. The following functions apply to annuities:
Throws:
java.lang.IllegalArgumentException

rate

public static double rate(int nPer,
                          double pmt,
                          double pv,
                          double fv,
                          int due,
                          double guess)
                   throws java.lang.IllegalArgumentException
Parameters:
due - the number 0 or 1 and indicates when payments are due. If type is omitted, it is assumed to be 0.
fv - the future value, or a cash balance you want to attain after the last payment is made. If fv is omitted, it is assumed to be 0 (the future value of a loan, for example, is 0).
pmt - the payment made each period; it cannot change over the life of the annuity. Typically, pmt contains principal and interest but no other fees or taxes.
nPer - the total number of payment periods in an annuity. For example, if you get a four-year car loan and make monthly payments, your loan has 4*12 (or 48) periods. You would enter 48 into the formula for nper.
pv - the present value of the total amount that a series of future payments is worth now.
guess - is your guess for what the rate will be. If you omit guess, it is assumed to be 10 percent. If RATE does not converge, try different values for guess. RATE usually converges if guess is between 0 and 1.
Returns:
the interest rate per period for an annuity Remark Make sure that you are consistent about the units you use for specifying guess and nper. If you make monthly payments on a four-year loan at 12 percent annual interest, use 12%/12 for guess and 4*12 for nper. If you make annual payments on the same loan, use 12% for guess and 4 for nper.
Throws:
java.lang.IllegalArgumentException

percent

public static double percent(double denom,
                             double num,
                             double valueIfZero)
Parameters:
denom - the denominator
num - the numerator
valueIfZero - The percent value to return if the numerator is zero. The default is null.
Returns:
the percentage of two numbers

npv

public static double npv(double rate,
                         double[] arptr)
                  throws java.lang.IllegalArgumentException
Parameters:
arptr - array of Doubles that specifies the name of an existing array of cash flow values. Rule for : Array must contain at least one positive value (receipt) and one negative value (payment)
rate - the rate of discount over the length of one period.
Returns:
the net present value of a varying series of periodic cash flows, both positive and negative, at a given interest rate Remarks The NPV investment begins one period before the date of the value1 cash flow and ends with the last cash flow in the list. The NPV calculation is based on future cash flows. If your first cash flow occurs at the beginning of the first period, the first value must be added to the NPV result, not included in the values arguments. For more information, see the examples below. If n the number of cash flows in the list of values, the formula for NPV is: NPV is similar to the PV function (present value). The primary difference between PV and NPV is that PV allows cash flows to begin either at the end or at the beginning of the period. Unlike the variable NPV cash flow values, PV cash flows must be constant throughout the investment. For information about annuities and financial functions, see PV. NPV is also related to the IRR function (internal rate of return). IRR is the rate for which NPV equals zero: NPV(IRR(...), ...) = 0.
Throws:
java.lang.IllegalArgumentException

irr

public static double irr(double[] cash,
                         double intrate)
                  throws java.lang.IllegalArgumentException
Parameters:
cash - specifies the name of an existing array of Doubles representing cash flow values
intrate - is a number that you guess is close to the result of IRR.
Returns:
This function takes the initial guess and scales it up and down to see if a solution IRR can be found. It also checks for 'more than 1 sign change' type of errors. Remarks IRR is closely related to NPV, the net present value function. The rate of return calculated by IRR is the interest rate corresponding to a 0 (zero) net present value. The following formula demonstrates how NPV and IRR are related
Throws:
java.lang.IllegalArgumentException

mirr

public static double mirr(double[] arptr,
                          double frate,
                          double rrate)
                   throws java.lang.IllegalArgumentException
Parameters:
arptr - array of Doubles that specifies the name of an existing array of cash flow values
frate - the interest rate you pay on the money used in the cash flows.
rrate - the interest rate you receive on the cash flows as you reinvest them.
Returns:
the modified internal rate of return for a series of periodic cash flows (payments and receipts) in an existing array Remarks MIRR uses the order of values to interpret the order of cash flows. Be sure to enter your payment and income values in the sequence you want and with the correct signs (positive values for cash received, negative values for cash paid). If n is the number of cash flows in values, frate is the finance_rate, and rrate is the reinvest_rate.
Throws:
java.lang.IllegalArgumentException


Copyright © 2008 Actuate Corp. All rights reserved.