@apmyp/kredito.js
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

kredito.js

kredito.js logo

npm version Build Status License

A tiny (~498 bytes) and fast module to calculate loan for JavaScript. May be used in both CommonJS and ES module systems.

First, you install it:

$ npm i @apmyp/kredito.js

Then, you just use it like this for annuity payment type:

import { Annuity } from "@apmyp/kredito.js";

const principal = 100000;
const interestRate = 0.12 / 12; // 12% per year we should convert to 1% per month
const installments = 24;
const annuity = new Annuity(principal, interestRate, installments);

annuity.payment(); //=> 4707.35
annuity.percentageInPayment(1); //=> 1000
annuity.bodyInPayment(1); //=> 3707.35
annuity.totalCost(); //=> 112976.33
annuity.overpayment(); //=> 12976.33

Or like this for linear payment type:

import { Linear } from "@apmyp/kredito.js";

const principal = 100000;
const interestRate = 0.12 / 12; // 12% per year we should convert to 1% per month
const installments = 24;
const linear = new Linear(principal, interestRate, installments);

linear.payment(1); //=> 5166.67
linear.percentageInPayment(1); //=> 1000
linear.bodyInPayment(); //=> 4166.67
linear.totalCost(); //=> 112500
linear.overpayment(); //=> 12500

If you want to use CommonJS modules:

const { Annuity, Linear } = require('@apmyp/kredito.js');

Package Sidebar

Install

npm i @apmyp/kredito.js

Weekly Downloads

1

Version

1.0.5

License

MIT

Unpacked Size

19.3 kB

Total Files

6

Last publish

Collaborators

  • apmyp