Amortization Calculator Formula With JS

Hello Everyone :wave:

Thought to share this with you’ll that I posted for another user’s question!

This script calculates the Monthly Payment with amount , term and interest rate.

Made a video : Loom | Free Screen & Video Recording Software | Loom

And the JS :

var Rate = "5" / 100;
var Term = "48";
var Price = "67890";
var value = Price * (Rate/12) * (Math.pow((1 + (Rate/12)), Term))/ ((Math.pow((1 + (Rate/12)), Term)) - 1);
var value = Math.round(100*value)/100;
return value;

In here change the rate inside double quotes with the drop down’s rate and for the term, term drop-down value and for the price add the input that user type the amount.

Instructions to download components from Pragmaflow website : PragmaFlow's Adalo Marketplace Reopened - YouTube

Pragmaflow website : https://adalo.pragmaflowservers.com/install-component

The component you need :

image

And also you can hide the inputs and the JS component!

Hope this helps!

Thank you

1 Like

Hi every one, lots of thanks to @dilon_perera for taking time to do this, I recently implemented this to my PWA and it works perfectly, @dilon_perera how can I have user enter loan down payment, instead of the loan amount and second how do I format the result.
Here the link to the app.
https://www.motokaa.app/?target=576wdn4w9wjvo7c7kvd5bkxrz&params={"bnknx6sh0w4jmj9xciskgi1uf.t_5dfnpet6b2s1b6rzq8ezw1wlr"%3A5%2C"bnknx6sh0w4jmj9xciskgi1uf.t_acen80tob88ol44797vpc55su"%3A9%2C"bnknx6sh0w4jmj9xciskgi1uf.t_f232b6d2d321404195993aeb6aadd14e"%3A22%2C"bnknx6sh0w4jmj9xciskgi1uf.t_6swqslb6dt1a0uiwghuxvbuld"%3A18%2C"bnknx6sh0w4jmj9xciskgi1uf.t_bv2vdwijzwbgcd80f2vkgqpjb"%3A1%2C"bnknx6sh0w4jmj9xciskgi1uf.t_ehb6hs32s4uuvd2m4ibp4bv29"%3A1%2C"bnknx6sh0w4jmj9xciskgi1uf.t_3d0cyao0up168kn5m3g7rhfff"%3A7%2C"bnknx6sh0w4jmj9xciskgi1uf.t_0yu4001c3l8sztvthw23oq7dj"%3A1%2C"bnknx6sh0w4jmj9xciskgi1uf.t_5vdwf5cxexr6vxhvabn103azx"%3A13%2C"bnknx6sh0w4jmj9xciskgi1uf.t_duco5u9wqimrtq633bhxh9n2z"%3A119%2C"bnknx6sh0w4jmj9xciskgi1uf.t_bsamhjddmgn5s1qz38nvscl79"%3A38%2C"bnknx6sh0w4jmj9xciskgi1uf.t_eehktcshlvhnqy0d6s6vhb191"%3A85}

Thanks

1 Like

https://www.motokaa.app/?target=2y45vgoc063h6glkdd4ab8p63&params={"bnknx6sh0w4jmj9xciskgi1uf.t_5dfnpet6b2s1b6rzq8ezw1wlr"%3A5%2C"bnknx6sh0w4jmj9xciskgi1uf.t_acen80tob88ol44797vpc55su"%3A9%2C"bnknx6sh0w4jmj9xciskgi1uf.t_f232b6d2d321404195993aeb6aadd14e"%3A22%2C"bnknx6sh0w4jmj9xciskgi1uf.t_6swqslb6dt1a0uiwghuxvbuld"%3A18%2C"bnknx6sh0w4jmj9xciskgi1uf.t_bv2vdwijzwbgcd80f2vkgqpjb"%3A1%2C"bnknx6sh0w4jmj9xciskgi1uf.t_ehb6hs32s4uuvd2m4ibp4bv29"%3A1%2C"bnknx6sh0w4jmj9xciskgi1uf.t_3d0cyao0up168kn5m3g7rhfff"%3A7%2C"bnknx6sh0w4jmj9xciskgi1uf.t_0yu4001c3l8sztvthw23oq7dj"%3A1%2C"bnknx6sh0w4jmj9xciskgi1uf.t_5vdwf5cxexr6vxhvabn103azx"%3A13%2C"bnknx6sh0w4jmj9xciskgi1uf.t_duco5u9wqimrtq633bhxh9n2z"%3A119%2C"bnknx6sh0w4jmj9xciskgi1uf.t_bsamhjddmgn5s1qz38nvscl79"%3A38%2C"bnknx6sh0w4jmj9xciskgi1uf.t_eehktcshlvhnqy0d6s6vhb191"%3A85}

Can you give me an example?

In your text component select custom formula from the options when you click the magic text and then add the input inside the custom formula and then you can format it to the currency. Or I can add that to the JS code if you tell me which format you need!

And also nice app Peter! Good luck with your app!

Hi @dilon_perera ,
Thank you for your help. When you click under the car photo you will link to listing detail where there is “buy this” button, click it and will take you to how to pay. So here I need the price of a car to be default loan amount so user just enter what down payment they going to put down so the loan amount is car price minus downpayment the user entered.

The format for results I can’t follow how to do it, could you add it to the formula please,
Thanks @dilon_perera
Appreciated.

Is it possible to give an example calculation with the results?

I have shown this on that video! What’s the format you need?

The format is the number punctuated by comma without the decimal places like this,
123,345,678

1 Like

Something like this? : Loom | Free Screen & Video Recording Software | Loom ( I’m sorry that I said Paul to you and you are Peter :man_facepalming: :sweat_smile: )

Or round that number?

Thanks for the video! Nicely explained!

Need to confirm the result! :slightly_smiling_face:

Based on your values does your result would be this?

image

:rofl:Thats ok, no problem.
So let me put it this way.

The car price is 10,000
Buyer has to deposit 2,000 so he has to enter 2,000 into downpayment input
So bank gives buyer a 8,000 loan which become the loan amount

So the formula should take 8,000 as the loan amount which comes from deducting 2,000 from 10,000 . So the formula take has the price of a car, wait user to enter amount he wants to put down and the formular take that number and deduct from the car price before it calculate monthly payment for loan of 8,000. I hope that help

1 Like

Correct?

var Rate = "rate from dropdown" / 100;
var Term = "term from dropdown";
var Price = "car price"-"downpayment input";
var value = Price * (Rate/12) * (Math.pow((1 + (Rate/12)), Term))/ ((Math.pow((1 + (Rate/12)), Term)) - 1);
var value = Math.round(100*value)/100;
var formatvalue = Math.trunc(value).toLocaleString();
return formatvalue;

Hi @dilon_perera,
I just implemented the new formula and it works exactly the way I wanted.
thank you so much.
Check it out and share if you want
www.motokaa.app

1 Like

Awesome @peterkilaba!

Wishing you the best of luck with your app!