code: function paymentAmount(loan, cb) {
      var d = Q.defer();
      if (!loan) d.reject('no loan object provided');
      else if (!loan.loanAmount) d.reject('loan amount not provided');
      else if (!loan.term) d.reject('loan term not provided');
      else if (!loan.interestRate) d.reject('loan interest rate not provided');
      else {
        var interestRate = loan.interestRate ? Number(loan.interestRate) / 1200 : 0;
        var term = loan.term ? Number(loan.term) : 0;
        var loanAmount = loan.loanAmount ? Number(loan.loanAmount) : 0;
        var type = loan.type != null ? Number(loan.type) : 0;
        var interestOnly = loan.interestOnly ? Boolean(loan.interestOnly) : false;
  
        if (interestRate === 0) {
          if (term > 0) {
            loan.paymentAmount = loanAmount / term;
          } else {
            loan.paymentAmount = 0;
          }
        } else {
          if (interestOnly) {
            loan.paymentAmount = (loanAmount * (interestRate * Math.pow(1 + interestRate, term)) / (Math.pow(1 + interestRate, term) - 1)) - loanAmount;
          } else {
            loan.paymentAmount = loanAmount * (interestRate * Math.pow(1 + interestRate, term)) / (Math.pow(1 + interestRate, term) - 1);
          }
        }
        d.resolve(loan);
        if (cb) return cb(loan);
      }
      return d.promise;
    }
docs: /*
  paymentAmount
  ---
  calculates the payment for a loan with the following parameters:
  loanAmount (required) - loan amount
  NPER (required) - the number of periods
  rate (required) - the rate per period
  interestOnly (optional) - boolean indicating if the loan is an interest only loan
  type (optional) - whether the payment is made at the beginning (1) or the end (0) of a period