loan-schedule
v1.2.0
Published
Library for loan amortization schedule manipulation
Downloads
17
Maintainers
Readme
Library for loan amortization schedule manipulation
Credit to the original author from with this library was forked: https://github.com/timmson/loan-schedule.js
My main goals with this fork is to reduce dependencies (mainly moment.js and ProdCal), as well as open up customizations to the payment schedule (such as the ability to provide payments manually)
Install
Bun
bun add loan-schedule
Yarn
yarn add loan-schedule
NPM
npm i loan-schedule
Annuity
import { calculateAnnuityLoanSchedule } from 'loan-schedule'
const schedule = calculateAnnuityLoanSchedule(
{
amount: 500000,
rate: 11.5,
term: 12,
paymentOnDay: 25,
issueDate: new Date(2018, 9, 25),
},
{ decimalDigit: 2 },
)
Provide payments manually
import { calculateSchedule, generateAnnuityPayments } from 'loan-schedule'
const config = {
amount: 500000,
rate: 11.5,
term: 12,
paymentOnDay: 25,
issueDate: new Date(2018, 9, 25),
}
const payments = generateAnnuityPayments(config)
const schedule = calculateSchedule(config, payments)
Annuity loan schedule (payment amount will be calculated)
import { calculateAnnuityLoanSchedule } from 'loan-schedule'
calculateAnnuityLoanSchedule({
amount: 50000,
rate: 11.5,
term: 12,
paymentOnDay: 25,
issueDate: new Date(2016, 9, 24),
}).payments.forEach((pay) => {
console.log(
pay.paymentDate +
'\t|\t\t' +
pay.initialBalance +
'\t|\t\t' +
pay.paymentAmount +
'\t|\t\t' +
pay.principalAmount +
'\t|\t\t' +
pay.interestAmount +
'\t|\t\t' +
pay.finalBalance,
)
})
Annuity loan schedule (payment amount is set)
import { calculateAnnuityLoanSchedule } from 'loan-schedule'
calculateAnnuityLoanSchedule({
amount: 50000,
rate: 11.5,
term: 12,
paymentAmount: 40000, // Configure your custom payment here
paymentOnDay: 25,
issueDate: new Date(2016, 9, 24),
}).payments.forEach((pay) => {
console.log(
pay.paymentDate +
'\t|\t\t' +
pay.initialBalance +
'\t|\t\t' +
pay.paymentAmount +
'\t|\t\t' +
pay.principalAmount +
'\t|\t\t' +
pay.interestAmount +
'\t|\t\t' +
pay.finalBalance,
)
})
Payment
import { calculateAnnuityPaymentAmount } from 'loan-schedule'
const payment = calculateAnnuityPaymentAmount({
amount: 110000,
term: 60,
rate: 12.9,
})
Other Schedule Types
Bubble Loan
import { calculateBubbleLoanSchedule } from 'loan-schedule'
const schedule = calculateBubbleLoanSchedule({
amount: 50000,
rate: 11.5,
term: 12,
paymentOnDay: 25,
issueDate: new Date(2016, 9, 25),
})
Differentiated Loan
import { calculateDifferentiatedLoanSchedule } from 'loan-schedule'
const schedule = calculateDifferentiatedLoanSchedule({
amount: 50000,
rate: 11.5,
term: 12,
paymentOnDay: 25,
issueDate: new Date(2016, 9, 25),
})
General Utilities
Interest By Period
import { calculateInterestByPeriod } from 'loan-schedule'
const interest = calculateInterestByPeriod({
from: new Date(2015, 11, 10),
to: new Date(2016, 0, 10),
amount: 1000,
rate: 16.7,
})
Max Loan Amount
import { calculateMaxLoanAmount } from 'loan-schedule'
const loanAmount = calculateMaxLoanAmount({
paymentAmount: 2497.21,
term: 60,
rate: 12.9,
})