public InvestmentHandlerTest() { _sut = new InvestmentHandler(_mockTesouroDireto.Object, _mockLicis.Object, _mockFundos.Object, _mockCalculation.Object); _lciResponse = new LciResponse { Lcis = new List <Lcis> { new Lcis { DataOperacao = Convert.ToDateTime("2015-03-01T00:00:00"), CapitalInvestido = 10000m, CapitalAtual = 12000m, Nome = "Selic", Vencimento = Convert.ToDateTime("2022-03-01T00:00:00"), } } }; _tesouroDireto = new TesouroDiretoResponse { TesourosDireto = new List <TesouroDireto> { new TesouroDireto { DataDeCompra = Convert.ToDateTime("2015-03-01T00:00:00"), ValorInvestido = 10000m, ValorTotal = 12000m, Nome = "Selic", Vencimento = Convert.ToDateTime("2022-03-01T00:00:00"), } } }; _fundosResponse = new FundosResponse { Fundos = new List <Fundos> { new Fundos { DataCompra = Convert.ToDateTime("2015-03-01T00:00:00"), CapitalInvestido = 10000m, ValorAtual = 12000m, Nome = "Selic", DataResgate = Convert.ToDateTime("2022-03-01T00:00:00"), } } }; }
private async Task <InvestimentosResponse> Investimentos() { DateTime dataConsulta = DateTime.Now; TesouroDiretoResponse tesouro = await _tesouroDiretoService.Get(); RendaFixaResponse rendaFixa = await _rendaFixaService.Get(); FundosResponse fundos = await _fundosService.Get(); InvestimentosResponse investimentos = new InvestimentosResponse(); PopulaTsouro(dataConsulta, tesouro, investimentos); PopulaRendaFixa(dataConsulta, rendaFixa, investimentos); PopulaFundos(dataConsulta, fundos, investimentos); return(investimentos); }
private static void PopulaTsouro(DateTime dataConsulta, TesouroDiretoResponse tesouro, InvestimentosResponse response) { foreach (var investimento in tesouro.Tds) { decimal taxa = VerificaTaxaPeriodo(dataConsulta, investimento.DataDeCompra, investimento.Vencimento); decimal valorResgate = CalcularValorMenosTaxa(investimento.ValorTotal, taxa); response.ValorTotal += investimento.ValorTotal; response.Investimentos.Add(new Investimento() { Nome = investimento.Nome, ValorInvestido = investimento.ValorInvestido, ValorTotal = investimento.ValorTotal, Vencimento = investimento.Vencimento, Ir = CalcularIr(investimento.ValorInvestido, investimento.ValorTotal, taxaInvestimentoTesouroDireto), ValorResgate = valorResgate }); } }