We have a web app that among other things, allow users to leave a cash balance on their account (which can be cashed out anytime or used to purchase items on the site). Users can withdraw and deposit funds to their account anytime. It was never intended for it, but we now have users who leave large sums on their account and they’re now requesting that we provide some interest on their account balance which is totally reasonable. Problem is we have no idea how to calculate interest on an account where users can withdraw and deposit funds anytime, but all the banks obviously do it so I was wondering if there’s a standard way (or ruby gem) to calculate interest. Any pointers or help is greatly appreciated.
The db table setup is pretty simple.
User has one Account
Accounts(user_id, balance)
Account has many activities
Activities(account_id, type, amount, description, created_at)
Where type can be either “Deposit” or “Withdrawal”.
For the answer on what interest calculation to use I agree with Ray Toal that you are going to have to ask your client what interest calculation to use and what their payment scheme is like.
Usually speaking, financial institutions that offer interest on a chequing account are calculated with compounding interest calculated daily [at the close?] of each business day and paid monthly at the end of each month by a deposit directly into the account.
Notably, banks and other financial institutions will tell their clients the interest rate on a yearly basis (APR) and not the interest rate per-day. It is an elementary mistake that I have made in the past.