private int VerificarIdServicoLancamentosCompra(int idlan, int idColigada, ComprasEacessoService comprasEacessoService) { var result = comprasEacessoService.ObterIdServicoidClienteIdCelulaPorIdLanIdColigada(idlan, idColigada); if (result != null && result.IdServico.HasValue) { return(result.IdServico.Value); } return(0); }
private void ObterTipoDespesaPorColigada(ComprasEacessoService comprasEacessoService, RootLancamentoFinanceiro lancamentoAgrupado) { if (lancamentoAgrupado.DescricaoOrigemLancamento != "FT") { var tipoDespesa = comprasEacessoService.ObterTipoDespesaPorIdColigadaIdLan(int.Parse(lancamentoAgrupado.CodigoColigada), lancamentoAgrupado.IdLan.Value); if (tipoDespesa != null) { lancamentoAgrupado.IdTipoDespesa = _tipoDespesaRepository.ObterTipoDespesaPorSigla(tipoDespesa.TipoDespesa); lancamentoAgrupado.DescOrigemCompraEacesso = tipoDespesa.OrigemEacesso; } } }
private void VerificarTipoDespesa(ComprasEacessoService comprasEacessoService, RootLancamentoFinanceiro lancamento, ItemLancamentoFinanceiro item) { if (lancamento.DescricaoOrigemLancamento != "FT") { var tipoDespesa = comprasEacessoService.ObterTipoDespesaPorIdServicoIdLan(item.IdServicoContratado.Value, lancamento.IdLan.Value); if (tipoDespesa == null) { tipoDespesa = comprasEacessoService.ObterTipoDespesaPorIdColigadaIdLan(int.Parse(lancamento.CodigoColigada), lancamento.IdLan.Value); } if (tipoDespesa != null) { lancamento.IdTipoDespesa = _tipoDespesaRepository.ObterTipoDespesaPorSigla(tipoDespesa.TipoDespesa); lancamento.DescOrigemCompraEacesso = tipoDespesa.OrigemEacesso; } } }
private List <RootLancamentoFinanceiro> VerificarValoresLancamentoFinanceiroAgrupados(IEnumerable <IGrouping <dynamic, RootLancamentoFinanceiro> > rootLancamentos) { var comprasEacessoService = new ComprasEacessoService(_connectionStrings.Value.EacessoConnection); var servicosEacessoService = new ClienteServicoEacessoService(_connectionStrings.Value.EacessoConnection); var lancamentosResult = new List <RootLancamentoFinanceiro>(); foreach (var lancamento in rootLancamentos) { var lancamentoAgrupado = lancamento.FirstOrDefault(); var itensLancamento = lancamento.SelectMany(x => x.ItensLancamentoFinanceiro).ToList(); lancamentoAgrupado.ItensLancamentoFinanceiro = new List <ItemLancamentoFinanceiro>(); ObterTipoDespesaPorColigada(comprasEacessoService, lancamentoAgrupado); if (lancamentoAgrupado.IdTipoDespesa == 0) { lancamentoAgrupado.IdTipoDespesa = null; } lancamentoAgrupado.LgUsuario = "EACESSO"; foreach (var itemLancamento in itensLancamento) { try { PrepararItemLancamento(servicosEacessoService, lancamentoAgrupado, itemLancamento); } catch (Exception e) { continue; } } lancamentosResult.Add(lancamentoAgrupado); if (lancamentosResult.Count % 200 == 0) { Console.WriteLine("Lancamentos RM Montados: " + lancamentosResult.Count + " - " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss")); } } return(lancamentosResult); }
private List <RootLancamentoFinanceiro> VerificarValoresLancamentoFinanceiro(List <RootLancamentoFinanceiro> rootLancamentos) { _variables.UserName = "******"; var comprasEacessoService = new ComprasEacessoService(_connectionStrings.Value.EacessoConnection); var notasEacessoService = new NotasFiscaisEacessoService(_connectionStrings.Value.EacessoConnection); var servicosEacessoService = new ClienteServicoEacessoService(_connectionStrings.Value.EacessoConnection); var lancamentosResult = new List <RootLancamentoFinanceiro>(); foreach (var lancamento in rootLancamentos) { try { if (lancamento.IdLan.HasValue) { var item = lancamento.ItensLancamentoFinanceiro.FirstOrDefault(); var idServico = item.IdServicoContratado; if (item.CodigoCusto != null && item.CodigoCusto.Any()) { var servicoPeloCodigo = item.CodigoCusto.Split('.'); item.IdServicoContratado = int.Parse(servicoPeloCodigo[2]); idServico = item.IdServicoContratado; } item.IdServicoContratado = ObterServicoContratadoPorIdServicoEacesso(item.IdServicoContratado.Value); item.IdServicoContratado = _lancamentoFinanceiroRepository.ObterIdServicoContratado(item.IdServicoContratado.Value); if (item.IdServicoContratado == 0) { if (idServico == 0) { continue; } else { var novoServico = ObterServicoEacesso(idServico.Value, servicosEacessoService); VerificarTipoDespesa(comprasEacessoService, lancamento, item); item.IdServicoContratado = _servicoContratadoService.PersistirServicoEacesso(novoServico); } } else { VerificarTipoDespesa(comprasEacessoService, lancamento, item); } lancamento.ItensLancamentoFinanceiro = new List <ItemLancamentoFinanceiro> { item }; if (lancamento.IdTipoDespesa == 0) { lancamento.IdTipoDespesa = null; } lancamento.LgUsuario = "EACESSO"; lancamentosResult.Add(lancamento); } } catch (Exception e) { continue; } } return(lancamentosResult); }