financial_maths 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWNhYzEyYWUzOGFlYTAxZjA2MzJlZmI3MWZhZWM4MDEyYjhhMmNiZQ==
4
+ NWU2OWEwODIyOTFkZmVmMTg1NWViOGJhZDRmYWRlZjQ4OTM3YzQ4YQ==
5
5
  data.tar.gz: !binary |-
6
- NjAzZmRiYjg2ZjhjNmQ2ODdmZWNlMjA0Y2ZiMGQyOTgyODlmNjc1NA==
6
+ MzQxOWFlZTE5M2MyYWFjNjE1MTg4MTViNDhmOTk5NmNjYTZkMjU3NQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YTk3ZDQ1NTdhYWU3YjY2ZDBkY2Y4MzBlZDNlZTYzOTJjNzc1ZTc0M2FhMWVh
10
- ZTJjNjBlNDQwZGQxMDE2ZWRiNjlkN2NkM2IzNmIwMzIzYTZhNTBmYzRlYmEw
11
- ZDk2M2FiYmM1MDNkNmRmZDIzOGEyMGRjMTExMWZmZDI2OTEwNGE=
9
+ M2Q0MjQzZTA3M2Q5OTBkNTdlZTQ4NmFiMTFmOThlYWY2NTk3ODgzNzBlNDY2
10
+ MzZhOGZjNTMyN2JkNmRlNGRlZWJmZjAzMjQ1MjU3OGJjNjc1OGIwZTI1NDA3
11
+ OWU5ZmUyM2M1MGJjZjBiMWZkNTMzNzE1MDQwZmEyNDJjODFmNGM=
12
12
  data.tar.gz: !binary |-
13
- ZWI0MTM5YTdiNzdhYWE3ZWQ3ZWYzZDIzMjJkMDQyYmY3NzNkZWUxMTBlY2Q3
14
- NWNjNmI5MTBhMDdmNWQxMjE1NGU2ZTFlMGU2YzU1ZWJhMTdhYThiNTlhOWFh
15
- N2E5NTU5ZjZmYjA2YmEwMzc3ZGFiZWM3NWM3ZjVlMGQ3ZTk3YmM=
13
+ YTRkMDkzZmY4Y2Y1YTEwNzY4MjM2ZTQ0YjRhOTk2ZjAyMjg1NmI3ZTA1ZTAy
14
+ YzA2NTVjOTEwMjk1OWFiOGYwODk3YmNhZGEzYWU3NmYwMzVmMWJmYjY0Mjlj
15
+ YTRhY2Q3MTM5NDQwNDQ3MmE1OWIwNzc5MjNkZjJhYjY4YTdkM2Y=
data/README.md CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  more functions will be added soon
4
4
 
5
+ #### New in version 0.0.3
6
+
7
+ 1. future_given_present
8
+ 2. present_given_future
9
+ 3. annuity_given_present
10
+ 4. annuity_given_future
11
+ 5. present_given_annuity(
12
+ 6. future_given_annuity
13
+
14
+ #### Pending
15
+ 1. include more functions
16
+ 3. add some test units
17
+
5
18
  ## Installation
6
19
 
7
20
  Add this line to your application's Gemfile:
@@ -22,7 +35,6 @@ require "financial_maths"
22
35
 
23
36
  include FinancialMaths
24
37
 
25
- calculate = Credit.new
26
38
  ```
27
39
 
28
40
  ### Calculate Fixed payment equity
@@ -30,7 +42,7 @@ A credit in a period of 15 years, the amount is $100.000.000 and the interest is
30
42
  call the method following the next instruction.
31
43
 
32
44
  ```ruby
33
- calculate.fixed_payment_equity(15,100000000,0.0144594763)
45
+ fixed_payment_equity(15,100000000,0.0144594763)
34
46
  ```
35
47
  The result is a hash with the plan of payments, it looks like that
36
48
 
@@ -42,6 +54,14 @@ The result is a hash with the plan of payments, it looks like that
42
54
  .
43
55
  ]
44
56
 
57
+ The lists of the methods and they params
58
+
59
+ future_given_present(present_value, interest, term)
60
+ present_given_future(future_value, interest, term)
61
+ annuity_given_present(present_value, interest, term)
62
+ annuity_given_future(future_value, interest, term)
63
+ present_given_annuity(annuity, interest, term)
64
+ future_given_annuity(annuity, interest, term)
45
65
 
46
66
  ## Contributing
47
67
 
@@ -1,3 +1,3 @@
1
1
  module FinancialMaths
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,22 +1,61 @@
1
1
  require "financial_maths/version"
2
2
 
3
3
  module FinancialMaths
4
- class Credit
5
- def fixed_payment_equity(year, amount, year_interest)
6
- years = year*12
7
- monthly_payments = amount/years
8
- result = []
9
- result << {:period=> 0, :monthly_payment => nil, :interest => nil, :payment => nil, :balance => amount}
10
-
11
- for i in 1..years
12
- interest = amount * year_interest
13
- month_payment = monthly_payments + interest
14
- amount -= monthly_payments
15
- #date += 1
16
- result << {:period=> i, :payment => month_payment, :interest => interest, :monthly_payment => monthly_payments, :balance => amount}
17
- end
18
- result
4
+
5
+ def fixed_payment_equity(year, amount, year_interest)
6
+ years = year*12
7
+ monthly_payments = amount/years
8
+ result = []
9
+ result << {:period=> 0, :monthly_payment => nil, :interest => nil, :payment => nil, :balance => amount}
10
+
11
+ for i in 1..years
12
+ interest = amount * year_interest
13
+ month_payment = monthly_payments + interest
14
+ amount -= monthly_payments
15
+ #date += 1
16
+ result << {:period=> i,
17
+ :payment => month_payment,
18
+ :interest => interest,
19
+ :monthly_payment => monthly_payments,
20
+ :balance => amount}
19
21
  end
22
+ result
23
+ end
24
+
25
+ def fixed_payment_amortization(year, amount, year_interest)
26
+
27
+ end
28
+
29
+ # hallar futuro dado el valor presente
30
+ def future_given_present(present_value, interest, term)
31
+ (present_value.to_f * (1 + interest.to_f) ** term).round(4)
32
+ end
33
+
34
+ # hallar presente dado el futuro
35
+ def present_given_future(future_value, interest, term)
36
+ (future_value.to_f / (1 +interest.to_f) ** term).round(4)
37
+ end
38
+
39
+ # hallar Anualidad dado el valor presente
40
+ def annuity_given_present(present_value, interest, term)
41
+ (present_value.to_f * ((interest *(1+interest.to_f) ** term) / ((1 + interest.to_f) ** term) -1)).round(4)
42
+ end
43
+
44
+ # hallar anualidad dado el valor futuro
45
+ def annuity_given_future(future_value, interest, term)
46
+ (future_value.to_f * (interest.to_f / ((1 + interest) ** term)-1)).round(4)
47
+ end
48
+
49
+ # hallar presente dado la anualidad
50
+ def present_given_annuity(annuity, interest, term)
51
+ (annuity.to_f * (((1 + interest.to_f) ** term) -1) / (interest.to_f * (1 + interest.to_f) ** term )).round(4)
20
52
  end
21
-
53
+
54
+ # hallar futuro dado la anualidad
55
+ def future_given_annuity(annuity, interest, term)
56
+ (annuity * (((1 + interest.to_f) ** term) -1) / interest.to_f ).round(4)
57
+ end
58
+
22
59
  end
60
+
61
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: financial_maths
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruben Espinosa