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)
bun add loan-schedule
yarn add loan-schedule
npm i loan-schedule
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 },
)
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)
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,
)
})
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,
)
})
import { calculateAnnuityPaymentAmount } from 'loan-schedule'
const payment = calculateAnnuityPaymentAmount({
amount: 110000,
term: 60,
rate: 12.9,
})
import { calculateBubbleLoanSchedule } from 'loan-schedule'
const schedule = calculateBubbleLoanSchedule({
amount: 50000,
rate: 11.5,
term: 12,
paymentOnDay: 25,
issueDate: new Date(2016, 9, 25),
})
import { calculateDifferentiatedLoanSchedule } from 'loan-schedule'
const schedule = calculateDifferentiatedLoanSchedule({
amount: 50000,
rate: 11.5,
term: 12,
paymentOnDay: 25,
issueDate: new Date(2016, 9, 25),
})
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,
})
import { calculateMaxLoanAmount } from 'loan-schedule'
const loanAmount = calculateMaxLoanAmount({
paymentAmount: 2497.21,
term: 60,
rate: 12.9,
})