title: how to calculate interest
body: <p>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.</p>
  
  <p>The db table setup is pretty simple.  </p>
  
  <p>User has one Account</p>
  
  <pre><code>Accounts(user_id, balance)
  </code></pre>
  
  <p>Account has many activities</p>
  
  <pre><code>Activities(account_id, type, amount, description, created_at)
  </code></pre>
  
  <p>Where type can be either "Deposit" or "Withdrawal".</p>