1.0.2 • Published 1 year ago

loan-calc2 v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

Loan Calculator

A JavaScript library for calculating mortgages, car loans, and personal loans with advanced features.

Installation

npm  install  loan-calc2

Usage

import { MortgageLoan, CarLoan, StudentLoan, HomeEquityLoan, CreditCardDebt } from 'loan-calc2';

  

const mortgage = new MortgageLoan(200000, 5, 30, {

hoa: { amount: 100, frequency: 'monthly' },

taxes: { amount: 2400, frequency: 'yearly' },

insurance: { amount: 600, frequency: 'yearly' }

});

const carLoan = new CarLoan(30000, 3, 5);

const studentLoan = new StudentLoan(50000, 4.5, 10);

const homeEquityLoan = new HomeEquityLoan(50000, 4, 15);

const creditCardDebt = new CreditCardDebt(10000, 18, 3);

  

// Calculate Monthly Payments

console.log('Mortgage Payment:', mortgage.calculateMonthlyPayment());

console.log('Car Loan Payment:', carLoan.calculateMonthlyPayment());

console.log('Student Loan Payment:', studentLoan.calculateMonthlyPayment());

console.log('Home Equity Loan Payment:', homeEquityLoan.calculateMonthlyPayment());

console.log('Credit Card Debt Payment:', creditCardDebt.calculateMonthlyPayment());

  

// Calculate Amortization Schedule

const prepayments = { 12: 10000, 24: 5000 };

const schedule = mortgage.calculateAmortizationSchedule(prepayments);

console.log('Amortization Schedule:', schedule);

  

// Calculate Overall Interest

const overallInterest = mortgage.calculateOverallInterest(schedule);

console.log('Overall Interest:', overallInterest);

  

// Example Schedule Output

schedule.forEach(payment => {

console.log(`Month: ${payment.month}, Date: ${payment.date.toISOString().slice(0, 10)}, Total Payment: ${payment.totalPayment}, Remaining Principal: ${payment.remainingPrincipal}`);

});
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago