I'm new to ruby on rails and my doubt is how to do recurring deposit calculations. i have used one formula to calculate monthly interest and that is working for first month and not calculating accurate interest for the upcoming months(2nd month, 3rd month ... n months).
Formula i used is given below.
total = depositamount * rate of interest * 30 / 365
Kindly help me to solve this issue.
-Thanks.
If the first month calculation is correct and subsequent months are wrong, are you saying that you want a compound interest formula? (i.e. in month 2 you calculate interest on principle + previous months' interest)
toal = deposit_amount * (rate_of_interest*30/365)**month_number
Let's assume that you're looking for an iteration : you want a simple calculation ( with a rate of interest which doesn't change ) to apply on a depositamount which changes every months. As your asking is quite unclear ( that's why you're getting these downvotes ), you might want to clarify it a lot if the following is not answering your question.
monthly_deposits = [deposit1, deposit2, deposit3... ]
Ruby
monthly_deposits.each do |deposit|
puts deposit * rate of interest * 30/365
end
Rails
<% monthly_deposits.each do |deposit| %>
<%= deposit * rate of interest * 30/365 %>
<% end %>
But if that's what you were asking, you probably need to read some tutoriels.