financial_maths 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/financial_maths/version.rb +1 -1
- data/lib/financial_maths.rb +13 -17
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bbd02c7bf4024c740d7d75a566d285665c96c03
|
4
|
+
data.tar.gz: dd22d4cec4aca97f2090ea5284a4f80262705a2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9266448a212e1ae9930d7cbf61c602c3ecbd0a8b94106a95c50cd231385d8e69f917680b4157f659dbc30eacf39ac534386889ecf15f35c9c15c5571089b7ba0
|
7
|
+
data.tar.gz: 227e513b3dd9e2b7b84caccbded7de61f5665447d25ca95e0ee500675418dcf1ae43c46b158677ed1b19252a1ea5416c4ca13f777f4b4c27d0afeac632906f21
|
data/lib/financial_maths.rb
CHANGED
@@ -7,13 +7,11 @@ module FinancialMaths
|
|
7
7
|
result << {:period=> 0, :monthly_payment => nil, :interest => nil, :payment => nil, :balance => amount}
|
8
8
|
|
9
9
|
for i in 1..periods
|
10
|
+
interest = amount * rate
|
11
|
+
month_payment = payment + interest
|
10
12
|
if i == periods
|
11
|
-
|
12
|
-
month_payment = payment + interest
|
13
|
-
amount -= payment
|
13
|
+
amount -= amount
|
14
14
|
else
|
15
|
-
interest = amount * rate
|
16
|
-
month_payment = payment + interest
|
17
15
|
amount -= payment
|
18
16
|
end
|
19
17
|
result << {:period=> i,
|
@@ -30,16 +28,15 @@ module FinancialMaths
|
|
30
28
|
#result << {:period=> 0, :monthly_payment => nil, :interest => nil, :payment => nil, :balance => amount}
|
31
29
|
|
32
30
|
for i in 0..periods-1
|
31
|
+
interest = amount * rate
|
32
|
+
month_payment = payment + interest
|
33
33
|
if i == periods
|
34
|
-
|
35
|
-
month_payment = payment + interest
|
36
|
-
amount -= payment
|
34
|
+
amount -= amount
|
37
35
|
else
|
38
|
-
interest = amount * rate
|
39
|
-
month_payment = payment + interest
|
40
36
|
amount -= payment
|
41
37
|
end
|
42
38
|
|
39
|
+
#date += 1
|
43
40
|
result << {:period=> i,
|
44
41
|
:payment => month_payment,
|
45
42
|
:interest => interest,
|
@@ -55,16 +52,15 @@ module FinancialMaths
|
|
55
52
|
result << {:period=> 0, :monthly_payment => nil, :interest => nil, :payment => nil, :balance => amount}
|
56
53
|
|
57
54
|
for i in 1..periods
|
55
|
+
interest = amount * rate
|
56
|
+
month_payment = payment - interest
|
58
57
|
if i == periods
|
59
|
-
|
60
|
-
month_payment = payment - interest
|
61
|
-
amount -= payment
|
58
|
+
amount -= amount
|
62
59
|
else
|
63
|
-
|
64
|
-
month_payment = payment - interest
|
65
|
-
amount -= payment
|
60
|
+
amount -= month_payment
|
66
61
|
end
|
67
|
-
|
62
|
+
|
63
|
+
#date += 1
|
68
64
|
result << {:period=> i,
|
69
65
|
:payment => payment,
|
70
66
|
:interest => interest,
|