Payment(IR, PV, FV, NP)
Last updated August 2, 2001
Version: 1 | Requires: ColdFusion 5 | Library: FinancialLib
Description:
Calculate the payment on a loan given the interest rate, periods, and present value. The value returned is negative since the payment represents a reduction in the account. To get the simple value, call Abs on the result.
Return Values:
Returns a numeric value.
Example:
Parameters:
| Name | Description | Required |
|---|---|---|
| IR | Interest rate per year (8.5% = 0.085) | Yes |
| PV | Present Value | Yes |
| FV | Future Value (Generally zero for calculating payments. Non zero for pay down to ammount.) | Yes |
| NP | Number of periods. | Yes |
Full UDF Source:
<cfscript>
/**
* Calculate payment on loan.
*
* @param IR Interest rate per year (8.5% = 0.085)
* @param PV Present Value
* @param FV Future Value (Generally zero for calculating payments. Non zero for pay down to ammount.)
* @param NP Number of periods.
* @return Returns a numeric value.
* @author Raymond Thompson (rayt@qsystems.net)
* @version 1, August 2, 2001
*/
function Payment(IR,PV,FV,NP) {
var tir = abs(ir) / 12;
var tfv = abs(fv);
var tpv = abs(pv);
var scale = 0;
var pmt=0;
var q = (1 + tir)^ abs(np);
if(ArrayLen(Arguments) gt 4) {
scale = 10^abs(Arguments[5]);
}
pmt = (tir * (tfv + q * tpv)) / (-1 + q);
if (scale NEQ 0)
pmt = int(pmt * scale + 0.5) / scale;
return(-pmt);
}
</cfscript>
Search CFLib.org
Latest Additions
Tayo Akinmade added
arrayTrim
10 day(s) ago
Will Belden added
longTime
15 day(s) ago
James Sleeman added
quickSort
25 day(s) ago
Ben Forta added
GetHostAddress
28 day(s) ago
Top Rated
EksporSQLData
Rated 5.0, 16 time(s)
backupDatabase
Rated 5.0, 13 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)