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
Jose Diaz-Salcedo added
cfRssFeed
3 day(s) ago
Raymond Compton added
structBlend
23 day(s) ago
Duncan added
IsZIPUK
23 day(s) ago
Todd Sharp added
getTagContentAll
29 day(s) ago
Gerald Guido added
ListReturnDuplicat...
1 month(s) ago