R/loanStep.R

#' Compute evolution of borrowed capital over a month.
#' 
#' @param rate
#' @param transfer
#' @param capital
#' @return 
loanStep <- function(rate,
                     transfer,
                     capital)
{
  interest <- rate * capital
  if (interest > transfer)
  {
    stop("Monthly repay inferior to interest.")
  }
  capPaid <- min(capital,
                 transfer - interest) # test if the current payment is enough to end the capital repay
  # remCap <- capital - capPaid # remaining capital at the end of the period, ie money that can not be invested
  return (list(capPaid = capPaid,
               interest = interest))
}
vkubicki/rfinance documentation built on May 14, 2019, 7:22 p.m.