JSPM

amortizejs

1.0.1
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 391
    • Score
      100M100P100Q88003F
    • License MIT

    Loan calculation and amortization schedule utility with support for multiple amortization methods.

    Package Exports

    • amortizejs

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (amortizejs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    AmortizeJS

    Website Version Bower npm license

    Loan calculation and amortization schedule utility with support for multiple amortization methods.

    AmortizeJS.calculate({
        method:   'mortgage', 
        apr:      3.5, 
        balance:  280350, 
        loanTerm: 60,
        startDate: new Date('December 24 2017')
    });

    Table of Contents

    1. Features
    2. Installation
    3. Quickstart
    4. API Docs
    5. Formatting of results in examples
    6. Contributing

    Features

    • Periodic payment calculation
    • Total interest calculation
    • Total payment calculation
    • Calculate a payment's interest amount, principal amount and remaining balance
    • Amortization schedule creation with optional payment date support
    • Easily customize and create new amortization methods

    Supported amortization methods

    • Mortgage-Style/Constant-Payment method

    Installation

    In a browser:

    <script src="amortize.js"></script>

    Using Bower:

    $ bower install ArmotizeJS
    
    <script src="./bower_components/AmortizeJS/dist/web/bundle.js"></script>

    Using npm:

    $ npm install amortizejs

    In Node.js

    var AmortizeJS = require('amortizejs').Calculator;

    Quickstart

    To calculate a mortgage amortization schedule including payment dates:

    let mortgage = AmortizeJS.calculate({
        method:   'mortgage',
        apr:      3.5, 
        balance:  280350,    
        loanTerm: 60,         
        startDate: new Date('December 24 2017')
    });
    
    console.log( mortgage.periodicPayment );    // 5100.06
    console.log( mortgage.periodicInterest );   // 0.00292
    console.log( mortgage.totalInterest );      // 25653.34
    console.log( mortgage.totalPayment );       // 306003.34
    console.log( mortgage.endDate );            // Sat Dec 24 2022 00:00:00 GMT-0500 (EST)
    console.log( mortgage.schedule );           // [{"interest": 817.69, "principal": 4282.37, "remainingBalance": 276067.63, "date":"2017-12-24T05:00:00.000Z"} ...]
    

    To retrieve list of available amortization methods:

    AmortizeJS.availableMethods(); // ['mortgage']

    API Docs

    AmortizeJS

    Command Params Return Description
    calculate(config) calculatorConfig AmortizationMethod Calculates amortization details and schedule.
    availableMethods() none string[] Returns the amortization methods that are available.

    AmortizationMethod

    An object conforming to the AmortizationMethod Interface is returned when calling AmortizeJS.calculate(config), the following attributes are available on it:

    Attribute Type Description
    balance number The loan amount.
    periods number The total number of periods.
    periodicInterest number The interest payed per period, if the period is month then the APR will be divided by 12 (ex: APR = 3.5%, i = 0.035/12).
    periodicPayment number The total payment that needs to be made per period.
    schedule Payment[] Array of payments required to pay off the balance.
    totalPayment number The total amount of all payments over the term.
    totalInterest number The total amount of interest spend over the term.
    startDate Date (Optional) The start date of the loan.
    endDate Date (Optional) The pay off date (Will only be calculated if startDate was given).

    CalculatorConfig

    An object conforming to the CalculatorConfig Interface is required when calling AmortizeJS.calculate(config), the following options are available:

    Attribute Type Description
    method string The amortization method to use. See Calculator.availableMethods()
    balance number The loan amount.
    loanTerm number Loan term in month.
    apr number The Anual Percentage Rate (ex: 3.5%)
    startDate Date (Optional) Optional start date, will cause monthly payments to have dates attached to them.

    Payment

    A payment for the loan, will include the following:

    Attribute Type Description
    interest number Portion of the payment that goes to interest.
    principal number Portion of the payment that goes to principal.
    remainingBalance number Remaining balance after this payment.
    date Date The date of the payment.

    Formatting of results in examples

    Results are not truncated or formatted in any way, the results in the examples are truncated for clarity.

    Contributing

    TODO: Describe contribution of custom AmortizationMethods.