Hi
I'm trying to do a finance calculator in flash. Quite a simple application, but I have no PMT function (as you get in excel), so I need the PMT function, but can't find it anywhere.
It's for a car site, to work out what the user can afford as total price for a vehicle. There are some fixed amounts, which just gets added to the amount I'm trying to work out.
I've got the following functions from another site:
function rate(principal, periods, payment) {
myrate = 0;
increment = 0.1;
decimals = 0
while(pmt(principal,myrate,periods) != payment && decimals < 9) {
while(pmt(principal, myrate, periods) < payment) {
myrate = myrate+increment;
}
myrate = myrate-increment;
increment = increment/10;
decimals++;
}
myrate = math.round(myrate*100000000)/100000000;
return myrate;
}
function pmt(principal, rate, periods) {
if(rate == 0) {
mypayment = principal/periods;
} else {
mypayment = principal*(rate/12) / (1-1/math.pow(1+rate/12,periods));
}
return mypayment;
}
I just can't seem to work out the principal, which I think is the value I'm after. Would be grateful if anyone can have a look at this and give me the formula/function for working out the principal.
Regards
MtraX
http://mtrax.iuma.com - play
http://www.webdesignsouthafrica.co.za - work
P = payment (per period)
PV = present value of money (principal)
IR = interest rate
N = number of payments or periods
I think you're after the P (monthly payment). PV is the amount owing for the vehicle. So for example, a $25,000 with $10,000 will have $15,000 remaining.
That's equivalent to taking out a $15,000 loan. If it's paid monthly with a 3% interest rate (IR = 0.03/12) over a 2 year period (24 pay periods), then you'll have a monthly payment of $644.72 or $15473.28 after 2 years (24 x $644.72).
In that case, you can use a modified formula:
P = ((PV-DP)*IR) / (1 - (1 + IR)^(-N))
P = payment (per period)
PV = present value of car
DP = down payment
IR = interest rate (remember to divide this by 12 if monthly!)
N = number of payments or periods
or for total price with a loan:
TP = (((PV-DP)*IR) / (1 - (1 + IR)^(-N)))*N