npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jquery.loan-calculator

v3.1.3

Published

Amortized Loan Calculator jQuery Plugin

Downloads

45

Readme

jQuery Loan Calculator

Build Status Code Climate License

Basic Example

  • Create basic html with the following structure:
<div id="widget">
    <input type="range" id="loan-amount" min="50000" max="250000" step="1000">
    <input type="range" id="loan-duration" min="12" max="36" step="1">
    <input id="credit-score" value="A">
    <h4 id="loan-total"></h4>
    <h4 id="payment"></h4>
</div>
  • Create new instance:
var $calculator = $('#widget').loanCalculator();
  • You can initialize with an options object:
$('#widget').loanCalculator({
  loanAmount: 50000,
  loanDuration: 12,
  ...
});

Event handling

The plugin automatically handles all the mousemove and change input events for you.

update

  • If you need to force the plugin to recalculate values use the update method:
$calculator.loanCalculator('update');
  • If you need to respond to other events you can call the update method inside your own event handler:
$('#selector').on('myEvent', function(){
  $calculator.loanCalculator('update');
});
  • You can pass overrides object as a second argument:
$calculator.loanCalculator('update', {
  loanAmount: $('#other-loan-amount').val(),
  creditScore: 'A',
  valueAddedTax: '16%'
});

loan:update

  • The plugin fires loan:update event when update method is called.
// Event handler for the update method.
$calculator.on('loan:update', function(e) {
  //...
});

Amortization Schedule

You can generate the amortization schedule as a json object:

var json = $calculator.loanCalculator('schedule');

Example output:

[
   {
      "balance": "$5,042.89",
      "payment": "$5,130.15",
      "principal": "$4,957.11",
      "interest": "$149.17",
      "tax": "$23.87"
   },
   {
      "balance": "$0.00",
      "payment": "$5,130.15",
      "principal": "$5,042.89",
      "interest": "$75.22",
      "tax": "$12.04"
   }
]

Options

  • loanAmount
    • Default: 50000
    • Type: Number|String
    • Default Input: #loan-amount
    • Description: The loan amount.
  • loanDuration
    • Default: 12
    • Type: Number|String
    • Default Input: #loan-duration
    • Description: The loan duration expressed in months.
  • creditScore
    • Default: A
    • Type: String
    • Default Input: #credit-score
    • Description: If no interest rate is provided, we search the creditScore key in the CREDIT_RATES object and use that interest rate.
  • creditRates
    • Default: See default credit rates table
    • Type: Object
    • Description: The credit rates that will be used for the given creditScore
  • interestRate
    • Default: None
    • Type: Number|String
    • Description: (Number) The annual interest rate for the loan.
    • Note: This value will override the creditScore option.
  • paymentFrequency
    • Default: 'monthly'
    • Type: String
    • Description: (String) The frequency of payments for the loan.
    • Note: This option changes the interpretation what loanDuration means (12 weeks or 12 months)
  • valueAddedTax
    • Default: 0
    • Type: Number|String
    • Description: Value-added tax (VAT).
  • serviceFee
    • Default: 0
    • Type: Number|String
    • Description: (Number) The loan fees and commissions total.
  • loanAmountSelector
    • Default: #loan-amount
    • Type: String (CSS selector)
    • Description: Input where the user will choose the loan amount.
  • loanDurationSelector
    • Default: #loan-duration
    • Type: String (CSS selector)
    • Description: Input where the user will choose the loan duration.
  • creditScoreSelector
    • Default: #credit-score
    • Type: String (CSS selector)
    • Description: Input where the user will choose the credit score.
  • selectedAmount
    • Default: #selected-amount
    • Type: String (CSS selector)
    • Description: Element to display the selected amount.
  • selectedDuration
    • Default: #selected-duration
    • Type: String (CSS selector)
    • Description: Element to display the selected duration.
  • selectedScore
    • Default: #selected-score
    • Type: String (CSS selector)
    • Description: Element to display the selected credit score.
  • loanTotalSelector
    • Default: #loan-total
    • Type: String (CSS selector)
    • Description: Element to display the resulting total loan cost.
  • interestTotalSelector
    • Default: #interest-total
    • Type: String (CSS selector)
    • Description: Element to display the resulting total interest amount paid for the loan.
  • taxTotalSelector
    • Default: #tax-total
    • Type: String (CSS selector)
    • Description: Element to display the resulting total tax amount paid for the loan.
  • paymentSelector
    • Default: #payment
    • Type: String (CSS selector)
    • Description: Element to display the periodic payment amount.
  • totalAnnualCostSelector
    • Default: #total-annual-cost
    • Type: String (CSS selector)
    • Description: Element to display the resulting total annual cost (CAT).
  • serviceFeeSelector
    • Default: #service-fee
    • Type: String (CSS selector)
    • Description: Element to display the service fee total.

Default credit rates

| Grade | Value | | ----- | ----- | | A | 5.32 | A1 | | B | 8.18 | B1 | | C | 12.29 | C1 | | D | 15.61 | D1 | | E | 18.25 | E1 | | F | 21.99 | F1 | | G | 26.77 | G1 |

Development Setup

  • Clone the repository
git clone [email protected]:scrubmx/jquery.loan-calculator.git

cd jquery.loan-calculator
  • Install dependencies:
npm install
  • Run the tests:
npm test

Todo

  • Accept the following as options:
    • creditScores (URL)
    • minimumLoan
    • minimumDuration

License

jQuery Loan Calculator is open-sourced software licensed under the MIT license