-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.js
More file actions
27 lines (21 loc) · 739 Bytes
/
lib.js
File metadata and controls
27 lines (21 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var summary = (lumpsum, sip, increase, rate, duration) => {
var numMonths = duration * 12;
var monthlyRate = Math.pow((1 + rate/100),1/12);
var expected = 100 * parseInt(lumpsum); // lumpsum is entered in lacs
var invested = 100 * parseInt(lumpsum);
var sipAmount = parseInt(sip);
for(var i = 1; i <= numMonths; i++){
if(i % 12 == 0)
sipAmount = sipAmount * (1+increase/100)
invested = invested + sipAmount;
expected = expected * monthlyRate + sipAmount;
}
return {
"expected": expected.toFixed(0) / 100,
"invested": invested.toFixed(0) / 100,
"gain": (expected - invested).toFixed(0) / 100,
};
}
module.exports = {
summary
}