code: function numberOfPayments(loan, cb) {
      var d = Q.defer();
      if (!loan) d.reject('loan object not provided');
      else if (!loan.term) d.reject('loan term not provided');
      else if (!loan.frequency) d.reject('loan frequency not provided');
      else {
        var frequency = loan.frequency.toLowerCase();
        var term = loan.term ? Number(loan.term) : 0;
  
        if (frequency === 'semimonthly') {
          (loan.payments = parseInt(term * 2));
        } else if (frequency === 'bimonthly') {
          loan.payments = (parseInt(term / 2));
        } else if (frequency === 'quarterly') {
          loan.payments = (parseInt(term / 4));
        } else if (frequency === 'semiannually') {
          loan.payments = (parseInt(term / 6));
        } else if (frequency === 'annually') {
          loan.payments = (parseInt(term / 12));
        } else if (frequency === 'none' || frequency === 'one') {
          loan.payments = 1;
        } else {
          loan.payments = term;
        }
  
        d.resolve(loan);
        if (cb) return cb(loan);
      }
      return d.promise;
    }
docs: /*
  Payments
  --------
  Calculates the number of payments for a loan. This is different than NPER.
  NPER calculates the number of periods used in an annuity or loan from
  a financial perspective. This function looks at how frequently a customer
  chooses to make payments. This function has the following arguments within params:
  term (required) - the number of periods used in calculating interest for a loan
  frequency (required): the payment frequency, which can be any of the following:
  - semimonthly - twice a month
  - monthly - once each month
  - bimonthly - every two months
  - quarterly - every quarter
  - semiannually - ever 6 months
  - annually - ever 12 months
  - none or one - only one payment at the end of the loan - typically don't mix this with balloonDate
  callback (optional) - function of CommonJs/NodeJs return, e.g., function(err, result)