moneyfunx 1.0.14 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lib/loan.d.ts +5 -4
- package/build/lib/loan.js +3 -2
- package/package.json +1 -1
- package/src/lib/loan.ts +6 -5
package/build/lib/loan.d.ts
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
export interface ILoan {
|
|
16
16
|
id: string;
|
|
17
|
+
name: string;
|
|
17
18
|
principal: number;
|
|
18
19
|
annualRate: number;
|
|
19
20
|
periodsPerYear: number;
|
|
@@ -23,10 +24,10 @@ export interface ILoan {
|
|
|
23
24
|
minPayment: number;
|
|
24
25
|
currentBalance: number;
|
|
25
26
|
fees: number;
|
|
26
|
-
name?: string;
|
|
27
27
|
}
|
|
28
28
|
export declare class Loan implements ILoan {
|
|
29
29
|
id: string;
|
|
30
|
+
name: string;
|
|
30
31
|
principal: number;
|
|
31
32
|
annualRate: number;
|
|
32
33
|
periodsPerYear: number;
|
|
@@ -36,17 +37,17 @@ export declare class Loan implements ILoan {
|
|
|
36
37
|
minPayment: number;
|
|
37
38
|
currentBalance: number;
|
|
38
39
|
fees: number;
|
|
39
|
-
name?: string;
|
|
40
40
|
/**
|
|
41
41
|
* @constructor
|
|
42
42
|
* @param {number} principal The amount borrowed
|
|
43
43
|
* @param {number} annualRate The yearly rate the loan accrues interest at
|
|
44
44
|
* @param {number} periodsPerYear The number of times the interest is accrued in a year
|
|
45
45
|
* @param {number} termInYears The number of years the loan is repaid over
|
|
46
|
-
* @param {number} name
|
|
46
|
+
* @param {number} name The name for the loan
|
|
47
47
|
* @param {number} currentBalance (Optional) The current balance of the loan, if different from the principal
|
|
48
|
+
* @param {number} fees (Optional) The fees on the loan
|
|
48
49
|
*/
|
|
49
|
-
constructor(principal: number, annualRate: number, periodsPerYear: number, termInYears: number, name
|
|
50
|
+
constructor(principal: number, annualRate: number, periodsPerYear: number, termInYears: number, name: string, currentBalance?: number, fees?: number);
|
|
50
51
|
/**
|
|
51
52
|
* Verifies a payment amount is valid
|
|
52
53
|
* Throws a PaymentTooLowError if the payment amount is less than the loan's minimum payment
|
package/build/lib/loan.js
CHANGED
|
@@ -18,11 +18,13 @@ export class Loan {
|
|
|
18
18
|
* @param {number} annualRate The yearly rate the loan accrues interest at
|
|
19
19
|
* @param {number} periodsPerYear The number of times the interest is accrued in a year
|
|
20
20
|
* @param {number} termInYears The number of years the loan is repaid over
|
|
21
|
-
* @param {number} name
|
|
21
|
+
* @param {number} name The name for the loan
|
|
22
22
|
* @param {number} currentBalance (Optional) The current balance of the loan, if different from the principal
|
|
23
|
+
* @param {number} fees (Optional) The fees on the loan
|
|
23
24
|
*/
|
|
24
25
|
constructor(principal, annualRate, periodsPerYear, termInYears, name, currentBalance, fees) {
|
|
25
26
|
this.id = String(Math.floor(Math.random() * Date.now()));
|
|
27
|
+
this.name = name;
|
|
26
28
|
this.principal = principal;
|
|
27
29
|
this.annualRate = annualRate;
|
|
28
30
|
this.periodsPerYear = periodsPerYear;
|
|
@@ -30,7 +32,6 @@ export class Loan {
|
|
|
30
32
|
this.periodicRate = this.annualRate / this.periodsPerYear;
|
|
31
33
|
this.periods = this.periodsPerYear * this.termInYears;
|
|
32
34
|
this.minPayment = this.calculateMinPayment();
|
|
33
|
-
this.name = name;
|
|
34
35
|
this.currentBalance = currentBalance || principal;
|
|
35
36
|
this.fees = fees || 0;
|
|
36
37
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "moneyfunx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.16",
|
|
5
5
|
"description": "MoneyFunx is a small library of functions for financial computations, with a focus on personal finance",
|
|
6
6
|
"main": "build/index.js",
|
|
7
7
|
"types": "build/index.d.ts",
|
package/src/lib/loan.ts
CHANGED
|
@@ -18,6 +18,7 @@ import * as helpers from './helperFunctions';
|
|
|
18
18
|
*/
|
|
19
19
|
export interface ILoan {
|
|
20
20
|
id: string;
|
|
21
|
+
name: string;
|
|
21
22
|
principal: number;
|
|
22
23
|
annualRate: number;
|
|
23
24
|
periodsPerYear: number;
|
|
@@ -27,11 +28,11 @@ export interface ILoan {
|
|
|
27
28
|
minPayment: number;
|
|
28
29
|
currentBalance: number;
|
|
29
30
|
fees: number;
|
|
30
|
-
name?: string;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export class Loan implements ILoan {
|
|
34
34
|
id: string;
|
|
35
|
+
name: string;
|
|
35
36
|
principal: number;
|
|
36
37
|
annualRate: number;
|
|
37
38
|
periodsPerYear: number;
|
|
@@ -41,7 +42,6 @@ export class Loan implements ILoan {
|
|
|
41
42
|
minPayment: number;
|
|
42
43
|
currentBalance: number;
|
|
43
44
|
fees: number;
|
|
44
|
-
name?: string;
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* @constructor
|
|
@@ -49,19 +49,21 @@ export class Loan implements ILoan {
|
|
|
49
49
|
* @param {number} annualRate The yearly rate the loan accrues interest at
|
|
50
50
|
* @param {number} periodsPerYear The number of times the interest is accrued in a year
|
|
51
51
|
* @param {number} termInYears The number of years the loan is repaid over
|
|
52
|
-
* @param {number} name
|
|
52
|
+
* @param {number} name The name for the loan
|
|
53
53
|
* @param {number} currentBalance (Optional) The current balance of the loan, if different from the principal
|
|
54
|
+
* @param {number} fees (Optional) The fees on the loan
|
|
54
55
|
*/
|
|
55
56
|
constructor(
|
|
56
57
|
principal: number,
|
|
57
58
|
annualRate: number,
|
|
58
59
|
periodsPerYear: number,
|
|
59
60
|
termInYears: number,
|
|
60
|
-
name
|
|
61
|
+
name: string,
|
|
61
62
|
currentBalance?: number,
|
|
62
63
|
fees?: number,
|
|
63
64
|
) {
|
|
64
65
|
this.id = String(Math.floor(Math.random() * Date.now()));
|
|
66
|
+
this.name = name;
|
|
65
67
|
this.principal = principal;
|
|
66
68
|
this.annualRate = annualRate;
|
|
67
69
|
this.periodsPerYear = periodsPerYear;
|
|
@@ -69,7 +71,6 @@ export class Loan implements ILoan {
|
|
|
69
71
|
this.periodicRate = this.annualRate / this.periodsPerYear;
|
|
70
72
|
this.periods = this.periodsPerYear * this.termInYears;
|
|
71
73
|
this.minPayment = this.calculateMinPayment();
|
|
72
|
-
this.name = name;
|
|
73
74
|
this.currentBalance = currentBalance || principal;
|
|
74
75
|
this.fees = fees || 0;
|
|
75
76
|
}
|