Exemplo n.º 1
0
 public IEnumerable<PreparacaoPagamento> BuscarGrid(PreparacaoPagamento entity, DateTime de = default(DateTime), DateTime ate = default(DateTime))
 {
     var result = _repository.FetchForGrid(entity, de, ate).ToList();
     var tipos = _preparacaoPagamentoTipo.Listar(new PreparacaoPagamentoTipo());
     result.ForEach(x => x.PreparacaoPagamentoTipo = tipos.FirstOrDefault(t => t.Id == x.PreparacaoPagamentoTipoId));
     return result;
 }
        public object PreparacaoArquivoRemessa(string key, string password, PreparacaoPagamento objModel, string impressora)
        {
            try
            {
                var result = DataHelperProdespPagementoContaDer.Procedure_PreparacaoArquiRemessa(key, password, objModel, impressora);
                var resultItem = result.FirstOrDefault();





                if (!string.IsNullOrEmpty(resultItem?.outErro))
                    throw new Exception($"Prodesp - {resultItem?.outErro}");
                return resultItem;

            }
            catch (Exception ex)
            {

                throw new Exception(ex.Message.Contains("EntradaCICS_Fora")
                    ? "Erro na comunicação com WebService Prodesp."
                    : ex.Message);
            }

        }
Exemplo n.º 3
0
        public void Inserir_PreparacaoPagamento(string key, string password, ref PreparacaoPagamento entity, Regional orgao)
        {
            if (entity.PreparacaoPagamentoTipoId == 1)
            {
                var result = DataHelperProdespPagamentoContaUnica.Procedure_PreparacaoPagtoOrgao(key, password, entity, orgao) ?? new Procedure_PreparacaoPagtoOrgaoRecordType[] { };

                var resultItem = result[0] ?? new Procedure_PreparacaoPagtoOrgaoRecordType();

                if (!string.IsNullOrEmpty(resultItem?.outErro))
                {
                    throw new SidsException($"Prodesp - {resultItem?.outErro}");
                }

                entity.ValorTotal            = Convert.ToDecimal(resultItem.outTotal);
                entity.NumeroOpFinal         = resultItem.outNumOPFinal.Replace("-", string.Empty);
                entity.NumeroOpInicial       = resultItem.outNumOPInicial.Replace("-", string.Empty);
                entity.QuantidadeOpPreparada = Convert.ToInt32(resultItem.outQuantidadeOPs.Replace(",", "").Replace(".", ""));
            }
            else
            {
                var result = DataHelperProdespPagamentoContaUnica.Procedure_PreparacaoPagtoDocGerador(key, password, entity) ?? new Procedure_PreparacaoPagtoDocGeradorRecordType[] { };

                var resultItem = result[0] ?? new Procedure_PreparacaoPagtoDocGeradorRecordType();

                if (!string.IsNullOrEmpty(resultItem?.outErro))
                {
                    throw new SidsException($"Prodesp - {resultItem?.outErro}");
                }

                entity.ValorTotal            = Convert.ToDecimal(resultItem.outTotal);
                entity.NumeroOpFinal         = resultItem.outNumeroOPFinal.Replace("-", "");
                entity.NumeroOpInicial       = resultItem.outNumeroOPInicial.Replace("-", "");
                entity.QuantidadeOpPreparada = Convert.ToInt32(resultItem.outQtdadeOP.Replace(",", "").Replace(".", ""));
            }
        }
        public FiltroViewModel CreateInstance(PreparacaoPagamento objModel, IEnumerable <PreparacaoPagamentoTipo> preparacaoPagamentoTipos, DateTime de, DateTime ate)
        {
            var filtro = new FiltroViewModel();


            filtro.StatusProdesp          = Convert.ToString(objModel.TransmitidoProdesp && objModel.DataTransmitidoProdesp > default(DateTime)).ToLower();
            filtro.StatusProdespListItems = new List <SelectListItem> {
                new SelectListItem {
                    Text = "Sucesso", Value = "S"
                },
                new SelectListItem {
                    Text = "Erro", Value = "E"
                },
                new SelectListItem {
                    Text = "Não transmitido", Value = "N"
                }
            };

            filtro.PreparacaoPagamentoTipoListItems = preparacaoPagamentoTipos?.
                                                      Select(s => new SelectListItem
            {
                Text     = s.Descricao,
                Value    = s.Id.ToString(),
                Selected = s.Id == objModel.PreparacaoPagamentoTipoId
            });

            filtro.DataCadastramentoDe  = null;
            filtro.DataCadastramentoAte = null;


            return(filtro);
        }
Exemplo n.º 5
0
        private void TransmitirProdesp(PreparacaoPagamento entity, int recursoId)
        {
            var cicsmo = new ChaveCicsmo();
            try
            {
                cicsmo = _chave.ObterChave(recursoId);

                _prodespContaUnica.Inserir_PreparacaoPagamento(cicsmo.Chave, cicsmo.Senha, ref entity);
                
                entity.TransmitidoProdesp = true;
                entity.StatusProdesp = "S";
                entity.DataTransmitidoProdesp = DateTime.Now;
                entity.MensagemServicoProdesp = null;
            }
            catch (Exception ex)
            {
                entity.StatusProdesp = "E";
                entity.MensagemServicoProdesp = ex.Message;
                throw ;
            }
            finally
            {
                _chave.LiberarChave(cicsmo.Codigo);
                SalvarOuAlterar(entity, 0, (short)EnumAcao.Transmitir);
            }
        }
        public void Inserir_PreparacaoPagamento(string key, string password, ref PreparacaoPagamento entity)
        {
            var orgao = _regional.Buscar(new Regional {
                Id = entity.RegionalId
            }).FirstOrDefault();

            _contaUnica.Inserir_PreparacaoPagamento(key, password, ref entity, orgao);
        }
        public object ImpressaoRelacaoOD(PreparacaoPagamento entity, string key, string password)
        {
            var usuario = _uService.Buscar(new Usuario {
                Codigo = GetUserIdLogado()
            }).FirstOrDefault();

            return(_contaDer.ImpressaoRelacaoOD(key, password, entity, usuario?.Impressora132));
        }
 public PreparacaoPagamentoServiceTests()
 {
     _user = new Usuario {
         Codigo = 1, RegionalId = 16
     };
     _entities = new List <PreparacaoPagamento>();
     _entity   = CreateEntityFactory();
 }
        private int SalvarService(PreparacaoPagamento preparacaoPagamento, int funcionalidade)
        {
            var acao = preparacaoPagamento.Id > 0 ? EnumAcao.Alterar : EnumAcao.Inserir;

            return(App.PreparacaoPagamentoService.SalvarOuAlterar(
                       preparacaoPagamento,
                       funcionalidade,
                       Convert.ToInt16(acao)));
        }
Exemplo n.º 10
0
 private void Transmissao(Usuario user, PreparacaoPagamento entity, int recursoId)
 {
     try
     {
         if (entity.TransmitirProdesp && !entity.TransmitidoProdesp) TransmitirProdesp(entity, recursoId);
     }
     catch
     {
         throw;
     }
 }
Exemplo n.º 11
0
 public IEnumerable <PreparacaoPagamento> FetchForGrid(PreparacaoPagamento entity, DateTime since, DateTime until)
 {
     return(DataHelper.List <PreparacaoPagamento>("PR_PREPARACAO_PAGAMENTO_CONSULTA_GRID",
                                                  new SqlParameter("@id_preparacao_pagamento", entity.Id),
                                                  new SqlParameter("@nr_op_inicial", entity.NumeroOpInicial),
                                                  new SqlParameter("@id_tipo_preparacao_pagamento", entity.PreparacaoPagamentoTipoId),
                                                  new SqlParameter("@ds_status_prodesp", entity.StatusProdesp),
                                                  new SqlParameter("@dt_cadastramento_de", since.ValidateDBNull()),
                                                  new SqlParameter("@dt_cadastramento_ate", until.ValidateDBNull()),
                                                  new SqlParameter("@id_regional", entity.RegionalId)));
 }
 public ActionResult Save(PreparacaoPagamento preparacaoPagamento)
 {
     try
     {
         return(Json(new { Status = "Sucesso", Id = SalvarService(preparacaoPagamento, Convert.ToInt32(_funcId)) }));
     }
     catch (Exception ex)
     {
         return(Json(new { Status = "Falha", Msg = ex.Message }));
     }
 }
        public ActionResult Imprimir(PreparacaoPagamento preparacaoPagamento)
        {
            try
            {
                var objModel = App.PreparacaoPagamentoService.ImprimirProdesp(preparacaoPagamento);

                return(Json(new { Status = "Sucesso", objModel }));
            }
            catch (Exception ex)
            {
                return(Json(new { Status = "Falha", Msg = ex.Message }));
            }
        }
 public DadoPreparacaoPagamentoCredorViewModel CreateInstance(PreparacaoPagamento entity)
 {
     return(new DadoPreparacaoPagamentoCredorViewModel()
     {
         CodigoCredorOrganizacao = entity.CodigoCredorOrganizacaoId,
         NumeroCNPJCPFCredor = entity.NumeroCnpjcpfCredor,
         TipoDespesaCredor = entity.CodigoDespesaCredor,
         NumeroContrato = entity.NumeroContrato,
         Credor1 = entity.Credor1,
         Credor2 = entity.Credor2,
         DescricaoLogradouroEntrega = entity.Endereco,
         NumeroCEPEntrega = entity.Cep
     });
 }
Exemplo n.º 15
0
        public object ConsultarPreparacaoPgtoTipoDespesaDataVenc(PreparacaoPagamento entity)
        {
            var key = new ChaveCicsmo();

            try
            {
                key = _chave.ObterChave();
                return(_prodespPagamentoContaUnicaService.PreparacaoPgtoTipoDespesaDataVenc(entity, key.Chave, key.Senha));
            }
            finally
            {
                _chave.LiberarChave(key.Codigo);
            }
        }
Exemplo n.º 16
0
        public int SalvarOuAlterar(PreparacaoPagamento entity, int recursoId, short action)
        {
            try
            {
                entity.Id = _repository.Save(entity);

                if (recursoId > 0 && entity.StatusProdesp == "S") LogSucesso(action, recursoId, $"Preparação de Pagamento : Codigo {entity.Id}");

                return entity.Id;
            }
            catch (Exception ex)
            {
                throw SaveLog(ex, action, recursoId);
            }
        }
Exemplo n.º 17
0
        public AcaoEfetuada Excluir(PreparacaoPagamento entity, int recursoId, short action)
        {
            try
            {
                _repository.Remove(entity.Id);

                if (recursoId > 0) return LogSucesso(action, recursoId, $"Preparação de Pagamento : Codigo {entity.Id}");

                return AcaoEfetuada.Sucesso;
            }
            catch (Exception ex)
            {
                throw SaveLog(ex, actionId: action, functionalityId: recursoId);
            }
        }
Exemplo n.º 18
0
        public DadoPagamentoContaUnicaContasViewModel CreateInstance(PreparacaoPagamento entity)
        {
            return(new DadoPagamentoContaUnicaContasViewModel()
            {
                NumeroBancoCredor = entity.NumeroBancoCredor,
                NumeroAgenciaCredor = entity.NumeroAgenciaCredor,
                NumeroContaCredor = entity.NumeroContaCredor,

                NumeroBancoPagto = entity.NumeroBancoPagto,
                NumeroAgenciaPagto = entity.NumeroAgenciaPagto,
                NumeroContaPagto = entity.NumeroContaPagto,

                QuantidadeOpPreparada = entity.QuantidadeOpPreparada,
                ValorTotal = entity.ValorTotal
            });
        }
 public FiltroGridViewModel CreateInstance(PreparacaoPagamento entity)
 {
     return(new FiltroGridViewModel
     {
         Id = Convert.ToString(entity.Id),
         NumeroOpInicial = entity.NumeroOpInicial,
         NumeroOpFinal = entity.NumeroOpFinal,
         PreparacaoPagamentoTipo = entity.PreparacaoPagamentoTipo != null ? entity.PreparacaoPagamentoTipo.Descricao : null,
         Total = entity.ValorTotal,
         Data = entity.DataCadastro.ToShortDateString(),
         StatusProdesp = string.IsNullOrEmpty(entity.StatusProdesp) || entity.StatusProdesp.Equals("N") ? "Não Transmitido" : (entity.StatusProdesp.Equals("E") ? "Erro" : "Sucesso"),
         MensagemProdesp = entity.MensagemServicoProdesp,
         CadastroCompleto = entity.CadastroCompleto,
         TransmitirProdesp = entity.TransmitirProdesp,
         TransmitidoProdesp = entity.TransmitidoProdesp,
     });
 }
Exemplo n.º 20
0
        public DadoTipoPreparacaoPagamentoViewModel CreateInstance(PreparacaoPagamento entity, IEnumerable<PreparacaoPagamentoTipo> preparacaoPagamentoTipo)
        {
            var preparacaoPagtoTipos = preparacaoPagamentoTipo as IList<PreparacaoPagamentoTipo> ?? preparacaoPagamentoTipo.ToList();

            return new DadoTipoPreparacaoPagamentoViewModel()
            {
                PreparacaoPagamentoTipoId = Convert.ToString(entity.PreparacaoPagamentoTipoId),

                PreparacaoPagamentoTipoListItens = preparacaoPagtoTipos
                  .Select(s => new SelectListItem
                  {
                      Text = s.Descricao,
                      Value = s.Id.ToString(),
                      Selected = s.Id == entity.PreparacaoPagamentoTipoId
                  }),


            };
        }
Exemplo n.º 21
0
 public object ConsultaPreparacaoPagamentoApoio(string key, string password, PreparacaoPagamento objModel)
 {
     try
     {
         var result     = DataHelperProdespPagamentoContaUnica.Procedure_PreparacaoPagtoDocGeradorApoioRecordType(key, password, objModel) ?? new Procedure_PreparacaoPagtoDocGeradorApoioRecordType[] { };
         var resultItem = result.FirstOrDefault();
         if (!string.IsNullOrEmpty(resultItem?.outErro))
         {
             throw new SidsException($"Prodesp - {resultItem?.outErro}");
         }
         return(resultItem);
     }
     catch (Exception ex)
     {
         throw new SidsException(ex.Message.Contains("EntradaCICS_Fora")
             ? "Erro na comunicação com WebService Prodesp."
             : ex.Message);
     }
 }
Exemplo n.º 22
0
        public PesquisaDocumentoGeradorViewModel CreateInstance(PreparacaoPagamento entity, IEnumerable <DocumentoTipo> tipoDocumento)
        {
            var documentoTipos = tipoDocumento as IList <DocumentoTipo> ?? tipoDocumento.ToList();

            return(new PesquisaDocumentoGeradorViewModel()
            {
                DocumentoTipoId = Convert.ToString(entity.DocumentoTipoId),

                DocumentoTipoListItems = documentoTipos.
                                         Select(s => new SelectListItem
                {
                    Text = s.Descricao,
                    Value = s.Id.ToString(),
                    Selected = s.Id == entity.DocumentoTipoId
                }),

                NumeroDocumento = entity.NumeroDocumento,
                ValorDocumento = entity.ValorDocumento
            });
        }
Exemplo n.º 23
0
 private Error Retransmissao(Usuario user, PreparacaoPagamento entity, int recursoId)
 {
     var error = new Error();
     var cicsmo = new ChaveCicsmo();
     try
     {
         try
         { if (entity.TransmitirProdesp && !entity.TransmitidoProdesp) TransmitirProdesp(entity,  recursoId); }
         catch (Exception ex)
         { error.Prodesp = ex.Message; }
     }
     catch (Exception ex)
     {
         throw ;
     }
     finally
     {
         _chave.LiberarChave(cicsmo.Codigo);
     }
     return error;
 }
        public DadoPreparacaoPagamentoViewModel CreateInstance(PreparacaoPagamento entity, IEnumerable <Regional> regional, Usuario logado)
        {
            var ano = entity.AnoExercicio > 0 ? entity.AnoExercicio : DateTime.Now.Year;
            var obj = new DadoPreparacaoPagamentoViewModel();

            obj.AnoExercicio      = entity.AnoExercicio != 0 ? entity.AnoExercicio.ToString() : null;
            obj.Regional          = entity.RegionalId > 0 ? entity.RegionalId.ToString() : default(string);
            obj.RegionalListItems = regional.Select(s => new SelectListItem
            {
                Text     = s.Descricao,
                Value    = s.Id.ToString(),
                Selected = s.Id == (logado.RegionalId == 1 ? 16 : logado.RegionalId)
            }).ToList();
            obj.CodigoConta    = entity.CodigoConta;
            obj.NumeroBanco    = entity.NumeroBanco;
            obj.NumeroAgencia  = entity.NumeroAgencia;
            obj.NumeroConta    = entity.NumeroConta;
            obj.DataVencimento = entity.DataVencimento == default(DateTime) ? null : entity.DataVencimento.ToString();
            obj.TipoDespesa    = entity.CodigoDespesa;

            return(obj);
        }
        private PreparacaoPagamento CreateInstancePreparacaoPagamento()
        {
            PreparacaoPagamento model = new PreparacaoPagamento
            {
                AnoExercicio   = 2017,
                DataVencimento = DateTime.Now,
                RegionalId     = 16,
                CodigoDespesa  = "11",

                CodigoAutorizadoAssinatura = "88888",
                CodigoAutorizadoGrupo      = "1",
                CodigoAutorizadoOrgao      = "00",

                CodigoExaminadoAssinatura = "00006",
                CodigoExaminadoGrupo      = "6",
                CodigoExaminadoOrgao      = "00",

                CodigoConta = "234",
            };

            return(model);
        }
Exemplo n.º 26
0
        public object ImprimirProdesp(PreparacaoPagamento entity)
        {
            var cicsmo = new ChaveCicsmo();
            try
            {

                cicsmo = _chave.ObterChave();
                                
                var result = _prodespContaDer.ImpressaoRelacaoOD(entity, cicsmo.Chave, cicsmo.Senha);

                return result;

            }
            catch (Exception ex)
            {
                throw SaveLog(ex);
            }
            finally
            {
                _chave.LiberarChave(cicsmo.Codigo);
            }
        }
        public JsonResult Transmitir(PreparacaoPagamento preparacaoPagamento)
        {
            PreparacaoPagamento objModel;

            try
            {
                var usuario = App.AutenticacaoService.GetUsuarioLogado();
                //preparacaoPagamento.RegionalId = usuario.RegionalId == 1 ? 16 : (short)usuario.RegionalId;
                ModelId = SalvarService(preparacaoPagamento, 0);
                App.PreparacaoPagamentoService.Transmitir(ModelId, usuario, (int)_funcId);
                objModel = App.PreparacaoPagamentoService.Selecionar(ModelId);

                return(Json(new { Status = "Sucesso", Codigo = objModel.Id, objModel }));
            }
            catch (Exception ex)
            {
                objModel = App.PreparacaoPagamentoService.Selecionar(ModelId);

                var result = new { Status = "Falha", Msg = ex.Message, Codigo = objModel.Id, objModel };

                return(Json(result));
            }
        }
Exemplo n.º 28
0
        public string Transmitir(IEnumerable<int> entityIdList, Usuario user, int recursoId)
        {
            var empenhos = new List<PreparacaoPagamento>();
            var result = default(string);

            foreach (var empenhoId in entityIdList)
            {
                var entity = new PreparacaoPagamento();
                try
                {
                    entity = Selecionar(empenhoId);

                    Retransmissao(user, entity, recursoId);
                    empenhos.Add(entity);
                }
                catch (Exception ex)
                {
                    throw SaveLog(ex, (short?)EnumAcao.Transmitir, recursoId);
                }
                finally
                {
                    SalvarOuAlterar(entity, recursoId, (short)EnumAcao.Transmitir);
                }
            }

            var empenhosErros = empenhos.Where(x => x.StatusProdesp == "E").ToList();

            if (empenhosErros.Count > 0)
                if (empenhos.Count == 1)
                    result += empenhos.FirstOrDefault()?.MensagemServicoProdesp;
                else
                    result += Environment.NewLine + "; / Algumas Preparação de Pagamento não puderam ser retransmitidos";


            return result;
        }
Exemplo n.º 29
0
        private static Procedure_ImpressaoRelacaoODFiltersType ImpressaoRelacaoODRecordType(string operador, string password, PreparacaoPagamento entity, string impressora)
        {
            var obj = new Procedure_ImpressaoRelacaoODFiltersType();

            obj.inOperador   = operador;
            obj.inChave      = password;
            obj.inImpressora = impressora;

            var dataPrep = entity.DataTransmitidoProdesp;

            obj.inCodigoConta       = entity.CodigoConta;
            obj.inDataPrepOPDIA     = dataPrep.Day.ToString();
            obj.inDataPrepOPMES     = dataPrep.Month.ToString();
            obj.inDataPrepOPANO     = dataPrep.Year.ToString().Substring(2, 2);
            obj.inAssinGrupo        = entity.CodigoAutorizadoGrupo;
            obj.inAssinNumero       = entity.CodigoAutorizadoAssinatura;
            obj.inAssinOrgao        = entity.CodigoAutorizadoOrgao;
            obj.inContraAssinGrupo  = entity.CodigoExaminadoGrupo;
            obj.inContraAssinNumero = entity.CodigoExaminadoAssinatura;
            obj.inContraAssinOrgao  = entity.CodigoExaminadoOrgao;

            return(obj);
        }
Exemplo n.º 30
0
 public IEnumerable<PreparacaoPagamento> Listar(PreparacaoPagamento entity)
 {
     return _repository.Fetch(entity);
 }