@scrapiloo/apr
v0.1.4
Published
## @scrapiloo/apr
Downloads
4
Readme
Effective Interest (APR) Calculator
@scrapiloo/apr
A simple Javascript implementation of the annual percentage rate formula described in the EU directive (2008/48/EC) on credit agreements for consumers.
Installation
# using yarn
yarn add @scrapiloo/apr
# using npm
npm i @scrapiloo/apr
Usage
import calculate from "@scrapiloo/apr"
const calculation = calculate({
creditAmount: 50_000,
months: 12 * 8, // 8 years
nominalInterestRate: 0.0618, // 6.18 %
monthlyAdminFee: 0,
setupFee: 395,
});
console.log("APR:", calculation.getAPR()); // ~6.58 %
console.log("Monthly payment:", calculation.getMonthlyPayment()); // ~661
console.log("Payment breakdown:", calculation.getPayments());