simulador_aplicacao 0.2.0 → 0.3.0
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.
- checksums.yaml +4 -4
- data/exe/simulador_aplicacao +30 -18
- data/lib/simulador_aplicacao/version.rb +1 -1
- data/lib/simulador_aplicacao.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0914b840d3cc8b5966a22dc4c91e16fdc3c20197b6dbf94f67fab5c31f519eb
|
4
|
+
data.tar.gz: 760ba4d353a4495ea9d458fbc0923b01fdf2f686a9f299ef46effc6aa3ae8e97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b76e8ac3807326b7b809a6dcb1e37573496e371a5d0764421e1aeb8f88035b5f1d4ebeae34a67d40c43c67d64cdeaa73d5342f402742ec658434e51cf9b038d5
|
7
|
+
data.tar.gz: 1c2a8729340d6dcf8cc60b0722a875d1209359601abf8156fe76bfc5f6d30fd66e501188451df6b7c0465a9d7e3d7fda8f63bd10a92056f47b289f274ed719de
|
data/exe/simulador_aplicacao
CHANGED
@@ -6,26 +6,37 @@ require "simulador_aplicacao"
|
|
6
6
|
|
7
7
|
prompt = TTY::Prompt.new
|
8
8
|
|
9
|
-
parametros = {
|
10
|
-
|
11
|
-
|
9
|
+
parametros = {}
|
10
|
+
|
11
|
+
parametros[:aporte_inicial] = prompt.ask(
|
12
|
+
"Informe o valor da aplicação inicial:",
|
13
|
+
convert: :float,
|
14
|
+
default: 1000.0,
|
15
|
+
required: true
|
16
|
+
)
|
17
|
+
|
18
|
+
parametros[:indice] = prompt.select("Qual vai ser o indice da aplicação?") do |menu|
|
19
|
+
SimuladorAplicacao::URL_API_BACEN.keys.map do |k|
|
20
|
+
menu.choice k.to_s.upcase, k
|
21
|
+
end
|
22
|
+
menu.choice "Custom", :custom
|
23
|
+
menu.default 1
|
24
|
+
end
|
25
|
+
|
26
|
+
if parametros[:indice] == :custom
|
27
|
+
parametros[:taxa_custom] = prompt.ask(
|
28
|
+
"Informe o valor do índice a ser utilizado (% ao ano):",
|
12
29
|
convert: :float,
|
13
|
-
default: 1000.0,
|
14
|
-
required: true
|
15
|
-
),
|
16
|
-
indice: prompt.select("Qual vai ser o indice da aplicação?") do |menu|
|
17
|
-
SimuladorAplicacao::URL_API_BACEN.keys.map do |k|
|
18
|
-
menu.choice k.to_s.upcase, k
|
19
|
-
end
|
20
|
-
menu.default 1
|
21
|
-
end,
|
22
|
-
periodo: prompt.ask(
|
23
|
-
"Informe o tempo de aplicação (em meses):",
|
24
|
-
convert: :int,
|
25
|
-
default: 12,
|
26
30
|
required: true
|
27
31
|
)
|
28
|
-
|
32
|
+
end
|
33
|
+
|
34
|
+
parametros[:periodo] = prompt.ask(
|
35
|
+
"Informe o tempo de aplicação (em meses):",
|
36
|
+
convert: :int,
|
37
|
+
default: 12,
|
38
|
+
required: true
|
39
|
+
)
|
29
40
|
|
30
41
|
tera_aporte_mensal = prompt.yes?("Deseja fazer aportes mensais?") do |q|
|
31
42
|
q.default false
|
@@ -74,7 +85,8 @@ simulacao = SimuladorAplicacao.simulacao(
|
|
74
85
|
parametros[:indice],
|
75
86
|
parametros[:aporte_mensal],
|
76
87
|
parametros[:resgate_mensal],
|
77
|
-
parametros[:inicio_resgate]
|
88
|
+
parametros[:inicio_resgate],
|
89
|
+
parametros[:taxa_custom]
|
78
90
|
)
|
79
91
|
|
80
92
|
tabela_simulacao = TTY::Table.new(
|
data/lib/simulador_aplicacao.rb
CHANGED
@@ -13,8 +13,8 @@ module SimuladorAplicacao
|
|
13
13
|
ipca: "https://api.bcb.gov.br/dados/serie/bcdata.sgs.13522/dados/ultimos/1?formato=json"
|
14
14
|
}.freeze
|
15
15
|
|
16
|
-
def self.simulacao(aporte_inicial, periodo, indice, aporte_mensal, resgate_mensal, inicio_resgate)
|
17
|
-
taxa_anual = obter_taxa_anual_atualizada(indice)
|
16
|
+
def self.simulacao(aporte_inicial, periodo, indice, aporte_mensal, resgate_mensal, inicio_resgate, taxa_custom)
|
17
|
+
taxa_anual = indice == :custom ? taxa_custom / 100.0 : obter_taxa_anual_atualizada(indice)
|
18
18
|
taxa_juros_mensal = taxa_anual_para_mensal(taxa_anual)
|
19
19
|
total_acumulado = aporte_inicial
|
20
20
|
total_investido = aporte_inicial
|
@@ -26,7 +26,7 @@ module SimuladorAplicacao
|
|
26
26
|
{
|
27
27
|
mes: 0,
|
28
28
|
inicial: total_acumulado,
|
29
|
-
taxa: "#{taxa_juros_mensal * 100}% a.m",
|
29
|
+
taxa: "#{format("%.2f", taxa_juros_mensal * 100)}% a.m",
|
30
30
|
rendimento_bruto: 0.0,
|
31
31
|
aliquota_imposto_renda: 0.0,
|
32
32
|
imposto_renda: 0.0,
|
@@ -59,7 +59,7 @@ module SimuladorAplicacao
|
|
59
59
|
resultado_mensal << {
|
60
60
|
mes: mes,
|
61
61
|
inicial: total_acumulado,
|
62
|
-
taxa: "#{taxa_juros_mensal * 100}% a.m",
|
62
|
+
taxa: "#{format("%.2f", taxa_juros_mensal * 100)}% a.m",
|
63
63
|
rendimento_bruto: rendimento,
|
64
64
|
aliquota_imposto_renda: aliquota_ir(mes),
|
65
65
|
imposto_renda: imposto_renda,
|