コード例 #1
0
        private InvestimentosResponse mapInvestimentos(Carteira carteira)
        {
            //este mapeamento é utilizado para gerar o objeto de retorno totalmente formatado
            //e apartado de regra de negocio do dominio

            InvestimentosResponse     investimentoResponse = new InvestimentosResponse();
            InfoInvestimentosResponse info;

            investimentoResponse.valorTotal = carteira.ValorTotal;

            foreach (var item in carteira.investimentos)
            {
                info = new InfoInvestimentosResponse();
                //utilizamos a abstração da interface dos investimentos IInvestimento
                // para percorrer e armazenar as informações do investimento
                info.nome           = item.RetornarNome();
                info.valorInvestido = item.RetornarValorInvestido();
                info.valorTotal     = item.RetornarTotal();
                info.vencimento     = item.RetornarVencimento();
                info.Ir             = item.CalcularIR();
                info.valorResgate   = item.CalcularResgate();

                investimentoResponse.investimentos.Add(info);
            }



            return(investimentoResponse);
        }
コード例 #2
0
        public async System.Threading.Tasks.Task <InvestimentosResponse> RetornarInvestimentosAsync()
        {
            InvestimentosResponse response = new InvestimentosResponse();

            carteira.investimentos = await serviceAgent.ObtemInvestimentosAsync();


            response = mapInvestimentos(carteira);
            return(response);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 private static void PopulaRendaFixa(DateTime dataConsulta, RendaFixaResponse rendaFixa, InvestimentosResponse response)
 {
     foreach (var investimento in rendaFixa.Lcis)
     {
         decimal taxa         = VerificaTaxaPeriodo(dataConsulta, investimento.DataOperacao, investimento.Vencimento);
         decimal valorResgate = CalcularValorMenosTaxa(investimento.CapitalAtual, taxa);
         response.ValorTotal += investimento.CapitalAtual;
         response.Investimentos.Add(new Investimento()
         {
             Nome           = investimento.Nome,
             ValorInvestido = investimento.CapitalInvestido,
             ValorTotal     = investimento.CapitalAtual,
             Vencimento     = investimento.Vencimento,
             Ir             = CalcularIr(investimento.CapitalInvestido, investimento.CapitalAtual, taxaInvestimentoRendaFixa),
             ValorResgate   = valorResgate
         });
     }
 }
コード例 #5
0
 private static void PopulaFundos(DateTime dataConsulta, FundosResponse fundos, InvestimentosResponse response)
 {
     foreach (var investimento in fundos.Fundos)
     {
         decimal taxa         = VerificaTaxaPeriodo(dataConsulta, investimento.DataCompra, investimento.DataResgate);
         decimal valorResgate = CalcularValorMenosTaxa((investimento.ValorAtual), taxa);
         response.ValorTotal += investimento.ValorAtual;
         response.Investimentos.Add(new Investimento()
         {
             Nome           = investimento.Nome,
             ValorInvestido = investimento.CapitalInvestido,
             ValorTotal     = investimento.ValorAtual,
             Vencimento     = investimento.DataResgate,
             Ir             = CalcularIr(investimento.CapitalInvestido, investimento.ValorAtual, taxaInvestimentoFundos),
             ValorResgate   = valorResgate
         });
     }
 }
コード例 #6
0
 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
         });
     }
 }