/// <summary> /// DETALHE do arquivo CNAB /// Gera o DETALHE do arquivo remessa de acordo com o lay-out informado /// </summary> public override string GerarDetalheRemessa(Boleto boleto, int numeroRegistro, TipoArquivo tipoArquivo) { try { string _detalhe = " "; base.GerarDetalheRemessa(boleto, numeroRegistro, tipoArquivo); switch (tipoArquivo) { case TipoArquivo.CNAB240: _detalhe = GerarDetalheRemessaCNAB240(); break; case TipoArquivo.CNAB400: _detalhe = GerarDetalheRemessaCNAB400(boleto, numeroRegistro, tipoArquivo); break; case TipoArquivo.Outro: throw new Exception("Tipo de arquivo inexistente."); } return _detalhe; } catch (Exception ex) { throw new Exception("Erro durante a geração do DETALHE arquivo de REMESSA.", ex); } }
public AbstractArquivoRemessa(TipoArquivo tipoArquivo) { switch (tipoArquivo) { case TipoArquivo.CNAB240: _arquivoRemessa = new ArquivoRemessaCNAB240(); _arquivoRemessa.LinhaDeArquivoGerada += new EventHandler<LinhaDeArquivoGeradaArgs>(_arquivoRemessa_LinhaDeArquivoGerada); break; case TipoArquivo.CNAB400: _arquivoRemessa = new ArquivoRemessaCNAB400(); _arquivoRemessa.LinhaDeArquivoGerada += new EventHandler<LinhaDeArquivoGeradaArgs>(_arquivoRemessa_LinhaDeArquivoGerada); break; default: throw new NotImplementedException("Arquivo não implementado."); } }
public AbstractArquivoRetorno(TipoArquivo tipoArquivo) { switch (tipoArquivo) { case TipoArquivo.CNAB240: _arquivoRetorno = new ArquivoRetornoCNAB240(); _arquivoRetorno.LinhaDeArquivoLida += new EventHandler <LinhaDeArquivoLidaArgs>(ArquivoRemessa_LinhaDeArquivoLidaCNAB240); break; case TipoArquivo.CNAB400: _arquivoRetorno = new ArquivoRetornoCNAB400(); _arquivoRetorno.LinhaDeArquivoLida += new EventHandler <LinhaDeArquivoLidaArgs>(ArquivoRemessa_LinhaDeArquivoLidaCNAB400); break; default: throw new NotImplementedException("Arquivo não implementado."); } }
public static TipoArquivo Obter(TipoArquivo objTipoArquivo) { string strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString; SqlConnection objConexao = new SqlConnection(strConectionString); SqlCommand objComando = new SqlCommand("SPE_L_TIPO_ARQUIVO"); objComando.Connection = objConexao; objComando.CommandType = CommandType.StoredProcedure; objComando.Parameters.Add("@tipoArquivoId", SqlDbType.Int).Value = objTipoArquivo.Id; try { //Abre Conexao objConexao.Open(); //Declara variavel de retorno TipoArquivo obj = default(TipoArquivo); IDataReader idrReader = default(IDataReader); idrReader = objComando.ExecuteReader(); obj = new TipoArquivo(); while ((idrReader.Read())) { obj.FromIDataReader(idrReader); } return(obj); } catch (Exception ex) { throw ex; } finally { //Fecha a conexao se aberta if (objConexao.State != ConnectionState.Closed) { objConexao.Close(); } } }
public AbstractArquivoRetorno(TipoArquivo tipoArquivo) { switch (tipoArquivo) { case TipoArquivo.CNAB240: _arquivoRetorno = new ArquivoRetornoCNAB240(); _arquivoRetorno.LinhaDeArquivoLida += ArquivoRemessa_LinhaDeArquivoLidaCNAB240; break; case TipoArquivo.CNAB400: _arquivoRetorno = new ArquivoRetornoCNAB400(); _arquivoRetorno.LinhaDeArquivoLida += ArquivoRemessa_LinhaDeArquivoLidaCNAB400; break; case TipoArquivo.CBR643: _arquivoRetorno = new ArquivoRetornoCrb643(); break; default: throw new NotImplementedException("Arquivo não implementado."); } }
public virtual string GerarTrailerRemessa(TipoArquivo tipoArquivo, int numeroArquivoRemessa, ref int numeroRegistroGeral, decimal valorBoletoGeral, int numeroRegistroCobrancaSimples, decimal valorCobrancaSimples, int numeroRegistroCobrancaVinculada, decimal valorCobrancaVinculada, int numeroRegistroCobrancaCaucionada, decimal valorCobrancaCaucionada, int numeroRegistroCobrancaDescontada, decimal valorCobrancaDescontada) { try { var trailer = String.Empty; switch (tipoArquivo) { case TipoArquivo.CNAB240: return(((IBancoCNAB240)this).GerarTrailerLoteRemessaCNAB240( ref numeroArquivoRemessa, numeroRegistroGeral, numeroRegistroCobrancaSimples, valorCobrancaSimples, numeroRegistroCobrancaVinculada, valorCobrancaVinculada, numeroRegistroCobrancaCaucionada, valorCobrancaCaucionada, numeroRegistroCobrancaDescontada, valorCobrancaDescontada) + Environment.NewLine + ((IBancoCNAB240)this).GerarTrailerRemessaCNAB240( numeroRegistroGeral, valorBoletoGeral, numeroRegistroCobrancaSimples, valorCobrancaSimples, numeroRegistroCobrancaVinculada, valorCobrancaVinculada, numeroRegistroCobrancaCaucionada, valorCobrancaCaucionada, numeroRegistroCobrancaDescontada, valorCobrancaDescontada)); case TipoArquivo.CNAB400: return(((IBancoCNAB400)this).GerarTrailerRemessaCNAB400( numeroRegistroGeral, valorBoletoGeral, numeroRegistroCobrancaSimples, valorCobrancaSimples, numeroRegistroCobrancaVinculada, valorCobrancaVinculada, numeroRegistroCobrancaCaucionada, valorCobrancaCaucionada, numeroRegistroCobrancaDescontada, valorCobrancaDescontada)); default: throw new Exception("Tipo de arquivo inexistente."); } } catch (Exception ex) { throw BoletoNetCoreException.ErroAoGerrarRegistroTrailerDoArquivoRemessa(ex); } }
private void GravarArquivoEmDisco(TipoArquivo tipo, string conteudoArquivo, string nomeArquivo, DateTime?data = null) { switch (tipo) { case TipoArquivo.Webservice: nomeArquivo = Path.Combine(Config.Arquivos.GetPathLote(), nomeArquivo); break; case TipoArquivo.Rps: nomeArquivo = Path.Combine(Config.Arquivos.GetPathRps(data ?? DateTime.Today), nomeArquivo); break; case TipoArquivo.NFSe: nomeArquivo = Path.Combine(Config.Arquivos.GetPathNFSe(data ?? DateTime.Today), nomeArquivo); break; } File.WriteAllText(nomeArquivo, conteudoArquivo, Encoding.UTF8); }
public override string GerarHeaderRemessa( string numeroConvenio, Cedente cedente, TipoArquivo tipoArquivo, int numeroArquivoRemessa) { try { this._convenio = numeroConvenio; this.Cedente = cedente; var header = string.Empty; base.GerarHeaderRemessa(numeroConvenio, cedente, tipoArquivo, numeroArquivoRemessa); switch (tipoArquivo) { case TipoArquivo.CNAB240: break; case TipoArquivo.CNAB400: header = this.GerarHeaderRemessaCNAB400(numeroConvenio); break; case TipoArquivo.CBR643: break; case TipoArquivo.Outro: break; default: throw new ArgumentOutOfRangeException("tipoArquivo", tipoArquivo, null); } return(header); } catch (Exception) { throw; } }
public string GerarHeaderRemessa(TipoArquivo tipoArquivo, int numeroArquivoRemessa, ref int numeroRegistroGeral) { try { var header = string.Empty; switch (tipoArquivo) { case TipoArquivo.CNAB400: header += GerarHeaderRemessaCNAB400(numeroArquivoRemessa, ref numeroRegistroGeral); break; default: throw new Exception("Header - Tipo de arquivo inexistente."); } return header; } catch (Exception ex) { throw Boleto2NetException.ErroAoGerarRegistroHeaderDoArquivoRemessa(ex); } }
private void LerDados() { TipoArquivo objTipoRelatorio = null; List <Relatorio> objDados = null; try { btnNovo.Enabled = true; btnExcluir.Enabled = true; objTipoRelatorio = new TipoArquivo(); if (ddlTipoRelatio.SelectedIndex > 0) { objTipoRelatorio.Id = Convert.ToInt32(ddlTipoRelatio.SelectedValue.ToString()); } objDados = DoRelatorio.Listar(new Relatorio() { TipoRelatorio = objTipoRelatorio }); if (objDados != null) { listPager.DataSource = objDados; listPager.DataBind(); BindGrid(); } if (objDados.Count <= 0) { btnExcluir.Enabled = false; } } catch (Exception ex) { //Chama o método para gravar erro ((Modulos_Modulos)Master).ExibirAlerta(ex); } }
public string GerarDetalheRemessa(TipoArquivo tipoArquivo, Boleto boleto, ref int numeroRegistro) { try { string detalhe = Empty, strline = Empty; switch (tipoArquivo) { case TipoArquivo.CNAB400: detalhe += GerarDetalheRemessaCNAB400Registro1(boleto, ref numeroRegistro); break; default: throw new Exception("Tipo de arquivo inexistente."); } return(detalhe); } catch (Exception ex) { throw Boleto2NetException.ErroAoGerarRegistroDetalheDoArquivoRemessa(ex); } }
public override string GerarTrailerRemessa(TipoArquivo tipoArquivo, int numeroArquivoRemessa, ref int numeroRegistroGeral, decimal valorBoletoGeral, int numeroRegistroCobrancaSimples, decimal valorCobrancaSimples, int numeroRegistroCobrancaVinculada, decimal valorCobrancaVinculada, int numeroRegistroCobrancaCaucionada, decimal valorCobrancaCaucionada, int numeroRegistroCobrancaDescontada, decimal valorCobrancaDescontada) { try { return(_IBanco.GerarTrailerRemessa(tipoArquivo, numeroArquivoRemessa, ref numeroRegistroGeral, valorBoletoGeral, numeroRegistroCobrancaSimples, valorCobrancaSimples, numeroRegistroCobrancaVinculada, valorCobrancaVinculada, numeroRegistroCobrancaCaucionada, valorCobrancaCaucionada, numeroRegistroCobrancaDescontada, valorCobrancaDescontada)); } catch (Exception ex) { throw new Exception("Erro durante a geração do registro TRAILER do arquivo de REMESSA.", ex); } }
public virtual string GerarDetalheRemessa(TipoArquivo tipoArquivo, Boleto boleto, ref int numeroRegistro) { try { switch (tipoArquivo) { case TipoArquivo.CNAB240: return(((IBancoCNAB240)this)?.GerarDetalheRemessaCNAB240(boleto, ref numeroRegistro)); case TipoArquivo.CNAB400: return(((IBancoCNAB400)this)?.GerarDetalheRemessaCNAB400(boleto, ref numeroRegistro)); default: throw new Exception("Tipo de arquivo inexistente."); } } catch (Exception ex) { throw BoletoNetCoreException.ErroAoGerarRegistroDetalheDoArquivoRemessa(ex); } }
public override string GerarTrailerRemessa(int numeroRegistro, TipoArquivo tipoArquivo, Cedente cedente, decimal vltitulostotal) { //Variavies StringBuilder _trailer = new StringBuilder(); //Tratamento try { //Montagem trailer _trailer.Append("9"); //Posição 001 _trailer.Append(new string(' ', 393)); //Posição 002 a 394 _trailer.Append(Utils.FitStringLength(numeroRegistro.ToString(), 6, 6, '0', 0, true, true, true)); //Posição 395 a 400 //Retorno return(Utils.SubstituiCaracteresEspeciais(_trailer.ToString())); } catch (Exception ex) { throw new Exception("Erro ao gerar TRAILER do arquivo de remessa do CNAB400.", ex); } }
public string GerarHeaderRemessa(TipoArquivo tipoArquivo, int numeroArquivoRemessa, ref int numeroRegistroGeral) { try { var header = Empty; switch (tipoArquivo) { case TipoArquivo.CNAB400: header += GerarHeaderRemessaCNAB400(numeroArquivoRemessa, ref numeroRegistroGeral); break; default: throw new Exception("Tipo de arquivo inexistente."); } return(header); } catch (Exception ex) { throw new Exception("Erro durante a geração do HEADER do arquivo de REMESSA.", ex); } }
public static string FormataLinhaArquivoCNAB(string strLinha, TipoArquivo tipoArquivo) { int tamanhoRegistro = 0; switch (tipoArquivo) { case TipoArquivo.CNAB240: tamanhoRegistro = 240; break; case TipoArquivo.CNAB400: tamanhoRegistro = 400; break; case TipoArquivo.POS500: tamanhoRegistro = 500; break; default: break; } strLinha = strLinha.ToUpper(); //if (Banco.RemoveAcentosArquivoRemessa) //{ // strLinha = Utils.SubstituiCaracteresEspeciais(strLinha); //} if (tamanhoRegistro != 0) { string[] strLinhas = strLinha.Split('\n'); foreach (string s in strLinhas) { if (s.Replace("\r", "").Length != tamanhoRegistro) { throw new Exception("Registro com tamanho incorreto:" + s.Replace("\r", "").Length.ToString() + " - " + s); } } } return(strLinha.ToUpper()); }
private void GravarArquivoEmDisco(TipoArquivo tipo, string conteudoArquivo, string nomeArquivo, DateTime?data = null) { switch (tipo) { case TipoArquivo.Webservice: nomeArquivo = Path.Combine(Config.Arquivos.GetPathLote(), nomeArquivo); break; case TipoArquivo.Rps: nomeArquivo = Path.Combine(Config.Arquivos.GetPathRps(data ?? DateTime.Today), nomeArquivo); break; case TipoArquivo.NFSe: nomeArquivo = Path.Combine(Config.Arquivos.GetPathNFSe(data ?? DateTime.Today), nomeArquivo); break; default: throw new ArgumentOutOfRangeException(nameof(tipo), tipo, null); } File.WriteAllText(nomeArquivo, conteudoArquivo, Encoding.UTF8); }
public string GerarDetalheRemessaCNAB400(Boleto boleto, int numeroRegistro, TipoArquivo tipoArquivo) { string detalhe = string.Empty; //Redireciona para o Detalhe da remessa Conforme o "Tipo de Documento" = "Tipo de Cobrança do CNAB400": // A = 'A' - SICREDI com Registro // C1 = 'C' - SICREDI sem Registro Impressão Completa pelo Sicredi // C2 = 'C' - SICREDI sem Registro Pedido de bloquetos pré-impressos if (boleto.VariacaoCarteira.Equals("A")) { detalhe = GerarDetalheRemessaCNAB400_A(boleto, numeroRegistro, tipoArquivo); } else if (boleto.VariacaoCarteira.Equals("C1")) { detalhe = GerarDetalheRemessaCNAB400_C1(boleto, numeroRegistro, tipoArquivo); } else if (boleto.VariacaoCarteira.Equals("C2")) { detalhe = GerarDetalheRemessaCNAB400_C2(boleto, numeroRegistro, tipoArquivo); } return(detalhe); }
public string GerarHeaderRemessa(TipoArquivo tipoArquivo, int numeroArquivoRemessa, ref int numeroRegistro) { try { numeroRegistro++; string _header = " "; switch (tipoArquivo) { case TipoArquivo.CNAB400: _header = GerarHeaderRemessaCNAB400(0, numeroArquivoRemessa); break; } return(_header); } catch (Exception ex) { throw new Exception("Erro durante a geração do HEADER do arquivo de REMESSA.", ex); } }
public string GerarTrailerRemessa(TipoArquivo tipoArquivo, int numeroArquivoRemessa, ref int numeroRegistroGeral, decimal valorBoletoGeral, int numeroRegistroCobrancaSimples, decimal valorCobrancaSimples, int numeroRegistroCobrancaVinculada, decimal valorCobrancaVinculada, int numeroRegistroCobrancaCaucionada, decimal valorCobrancaCaucionada, int numeroRegistroCobrancaDescontada, decimal valorCobrancaDescontada) { try { numeroRegistroGeral++; string trailer = " "; switch (tipoArquivo) { case TipoArquivo.CNAB400: trailer = GerarTrailerRemessa400(numeroRegistroGeral); break; } return(trailer); } catch (Exception ex) { throw new Exception("", ex); } }
public string GerarDetalheRemessa(TipoArquivo tipoArquivo, Boleto boleto, ref int numeroRegistro) { try { numeroRegistro++; string _detalhe = " "; switch (tipoArquivo) { case TipoArquivo.CNAB400: _detalhe = GerarDetalheRemessaCNAB400(boleto, numeroRegistro, tipoArquivo); break; } return(_detalhe); } catch (Exception ex) { throw new Exception("Erro durante a geração do DETALHE arquivo de REMESSA.", ex); } }
public List <TipoArquivo> ListarTodos() { var retornoLista = new List <TipoArquivo>(); var commandText = TipoArquivoSQL.Listar; var linhas = contexto.ExecutaComandoComRetorno(commandText); foreach (var row in linhas) { var retorno = new TipoArquivo { id = row["id"].ToLong(), nomeTipoArquivo = row["nomeTipoArquivo"], padraoFormatoNomeArquivo = row["padraoFormatoNomeArquivo"], descricao = row["descricao"] }; retornoLista.Add(retorno); } return(retornoLista); }
public static void CriarArquivo(TipoArquivo tipoArquivo) { string nome, conteudo; switch (tipoArquivo) { case TipoArquivo.Cartinf01: nome = ConteudoCartinfTeste.CARTINF01_NOME; conteudo = ConteudoCartinfTeste.CARTINF01; break; case TipoArquivo.Cartinf02: nome = ConteudoCartinfTeste.CARTINF02_NOME; conteudo = ConteudoCartinfTeste.CARTINF02; break; case TipoArquivo.Cartinf03: nome = ConteudoCartinfTeste.CARTINF03_NOME; conteudo = ConteudoCartinfTeste.CARTINF03; break; case TipoArquivo.Cartinf04: nome = ConteudoCartinfTeste.CARTINF04_NOME; conteudo = ConteudoCartinfTeste.CARTINF04; break; default: throw new Exception("Não existe tipo passado."); } if (!File.Exists(nome)) { File.WriteAllText(nome, conteudo); } else { Console.WriteLine("Arquivo " + nome + " já existe. Delete-o para criar um de teste."); } }
public string GerarRegistroDetalhe5(Boleto boleto, int numeroRegistro, TipoArquivo tipoArquivo) { StringBuilder detalhe = new StringBuilder(); switch (tipoArquivo) { case TipoArquivo.CNAB400: detalhe.Append("5"); // 001 detalhe.Append("99"); // 002-003 detalhe.Append("2"); // 004 (Percentual) detalhe.Append(boleto.DataMulta.ToString("ddMMyy")); // 005-010 detalhe.Append(Utils.FitStringLength(Convert.ToInt32(boleto.PercMulta * 100).ToString(), 12, 12, '0', 1, true, true, true)); // 011-022 detalhe.Append(new string(' ', 372)); // 023 a 394 detalhe.Append(Utils.FitStringLength(numeroRegistro.ToString(), 6, 6, '0', 0, true, true, true)); // 395 a 400 //Retorno return(Utils.SubstituiCaracteresEspeciais(detalhe.ToString())); default: throw new Exception("Tipo de arquivo não suportado."); } }
/// <summary> /// Efetua as Validações dentro da classe Boleto, para garantir a geração da remessa /// </summary> public override bool ValidarRemessa(TipoArquivo tipoArquivo, string numeroConvenio, IBanco banco, Cedente cedente, Boletos boletos, int numeroArquivoRemessa, out string mensagem) { bool vRetorno = true; string vMsg = string.Empty; // switch (tipoArquivo) { case TipoArquivo.CNAB240: vRetorno = ValidarRemessaCNAB240(numeroConvenio, banco, cedente, boletos, numeroArquivoRemessa, out vMsg); break; case TipoArquivo.CNAB400: vRetorno = ValidarRemessaCNAB400(numeroConvenio, banco, cedente, boletos, numeroArquivoRemessa, out vMsg); break; case TipoArquivo.Outro: throw new Exception("Tipo de arquivo inexistente."); } // mensagem = vMsg; return(vRetorno); }
/// <summary> /// Efetua as Validações dentro da classe Boleto, para garantir a geração da remessa /// </summary> public override bool ValidarRemessa(TipoArquivo tipoArquivo, string numeroConvenio, IBanco banco, Cedente cedente, Boletos boletos, int numeroArquivoRemessa, out string mensagem) { bool vRetorno = true; string vMsg = string.Empty; ////IMPLEMENTACAO PENDENTE... mensagem = vMsg; return vRetorno; }
public string GerarDetalheSegmentoRRemessaCNAB240(Boleto boleto, int numeroRegistroDetalhe, TipoArquivo CNAB240) { try { string header = Utils.FormatCode(Codigo.ToString(), "0", 3, true); // código do banco na compensação header += "0001"; // Lote de Serviço header += "3"; // Tipo de Registro header += Utils.FormatCode(numeroRegistroDetalhe.ToString(), "0", 5); // Nº Sequencial do Registro no Lote header += "R"; // Cód. Segmento do Registro Detalhe header += " "; // Uso Exclusivo FEBRABAN/CNAB header += "01"; // Código de Movimento Remessa header += Utils.FormatCode("", " ", 48); // Uso Exclusivo FEBRABAN/CNAB header += "1"; // Código da Multa '1' = Valor Fixo,'2' = Percentual,'0' = Sem Multa header += boleto.DataMulta.ToString("ddMMyyyy"); // Data da Multa header += Utils.FormatCode(boleto.ValorMulta.ToString().Replace(",", "").Replace(".", ""), "0", 13); // Valor/Percentual a Ser Aplicado header += Utils.FormatCode("", " ", 10); // Informação ao Sacado header += Utils.FormatCode("", " ", 40); // Mensagem 3 header += Utils.FormatCode("", " ", 40); // Mensagem 4 header += Utils.FormatCode("", " ", 61); // Uso Exclusivo FEBRABAN/CNAB return header; } catch (Exception e) { throw new Exception("Erro ao gerar SEGMENTO Q do arquivo de remessa.", e); } }
public string GerarDetalheRemessaCNAB400(Boleto boleto, int numeroRegistro, TipoArquivo tipoArquivo) { try { base.GerarDetalheRemessa(boleto, numeroRegistro, tipoArquivo); // USO DO BANCO - Identificação da operação no Banco (posição 87 a 107) string identificaOperacaoBanco = new string(' ', 10); string nrDeControle = new string(' ', 25); string mensagem = new string(' ', 12); string mensagem2 = new string(' ', 60); string usoBanco = new string(' ', 10); string _detalhe; //detalhe (tamanho,tipo) A= Alfanumerico, N= Numerico _detalhe = "1"; //Identificação do Registro (1, N) //Parte Não Necessaria - Parte de dados do Sacado _detalhe += "00000"; //Agencia de Debito (5, N) Não Usado _detalhe += " "; //Dig da Agencia (1, A) Não Usado _detalhe += "00000"; //Razao da Conta Corrente (5, N) Não Usado _detalhe += "0000000"; //Conta Corrente (7, N) Não Usado _detalhe += " "; //Dig da Conta Corrente (1, A) Não Usado //Identificação da Empresa Cedente no Banco (17, A) _detalhe += "0"; _detalhe += Utils.FitStringLength(boleto.Carteira, 3, 3, '0', 0, true, true, true); // Codigo da carteira (3) _detalhe += Utils.FitStringLength(boleto.Cedente.ContaBancaria.Agencia, 5, 5, '0', 0, true, true, true); //N da agencia(5) _detalhe += Utils.FitStringLength(boleto.Cedente.ContaBancaria.Conta, 7, 7, '0', 0, true, true, true); //Conta Corrente(7) _detalhe += Utils.FitStringLength(boleto.Cedente.ContaBancaria.DigitoConta, 1, 1, '0', 0, true, true, true);//D da conta(1) //Nº de Controle do Participante - uso livre da empresa (25, A) // brancos _detalhe += nrDeControle; //Código do Banco, só deve ser preenchido quando cliente cedente optar por "Débito Automático". _detalhe += "000"; //0=sem multa, 2=com multa (1, N) if (boleto.PercMulta > 0) { _detalhe += "2"; _detalhe += Utils.FitStringLength(boleto.PercMulta.ToString("0.00").Replace(",", ""), 4, 4, '0', 0, true, true, true); //Percentual Multa 9(2)V99 - (04) } else { _detalhe += "0"; _detalhe += "0000"; } //Identificação do Título no Banco (12, A) _detalhe += Utils.FitStringLength(boleto.NossoNumero, 11, 11, '0', 0, true, true, true); //Nosso Numero (11) // Força o NossoNumero a ter 11 dígitos. Alterado por Luiz Ponce 07/07/2012 _detalhe += Mod11Bradesco(boleto.Carteira + Utils.FitStringLength(boleto.NossoNumero, 11, 11, '0', 0, true, true, true), 7); // Digito de Auto Conferencia do Nosso Número (01) //Desconto Bonificação por dia (10, N) _detalhe += "0000000000"; // 1 = Banco emite e Processa o registro // 2 = Cliente emite e o Banco somente processa //Condição para Emissão da Papeleta de Cobrança(1, N) _detalhe += "2"; //Ident. se emite papeleta para Débito Automático (1, A) _detalhe += "N"; //Identificação da Operação do Banco (10, A) Em Branco _detalhe += identificaOperacaoBanco; //Indicador de Rateio de Crédito (1, A) //Somente deverá ser preenchido com a Letra “R”, se a Empresa participa da rotina // de rateio de crédito, caso não participe, informar Branco. _detalhe += " "; //Endereçamento para Aviso do Débito Automático em Conta Corrente (1, N) //1 = emite aviso, e assume o endereço do Sacado constante do Arquivo-Remessa; //2 = não emite aviso; //diferente de 1 ou 2 = emite e assume o endereço do cliente debitado, constante do nosso cadastro. _detalhe += "2"; _detalhe += " "; //Branco (2, A) //Identificação ocorrência(2, N) /* 01..Remessa 02..Pedido de baixa 04..Concessão de abatimento 05..Cancelamento de abatimento concedido 06..Alteração de vencimento 07..Alteração do controle do participante 08..Alteração de seu número 09..Pedido de protesto 18..Sustar protesto e baixar Título 19..Sustar protesto e manter em carteira 31..Alteração de outros dados 35..Desagendamento do débito automático 68..Acerto nos dados do rateio de Crédito 69..Cancelamento do rateio de crédito. */ _detalhe += "01"; _detalhe += Utils.Right(boleto.NumeroDocumento, 10, '0', true); //Nº do Documento (10, A) _detalhe += boleto.DataVencimento.ToString("ddMMyy"); //Data do Vencimento do Título (10, N) DDMMAA //Valor do Título (13, N) _detalhe += Utils.FitStringLength(boleto.ValorBoleto.ToString("0.00").Replace(",", ""), 13, 13, '0', 0, true, true, true); _detalhe += "000"; //Banco Encarregado da Cobrança (3, N) _detalhe += "00000"; //Agência Depositária (5, N) /*Espécie de Título (2,N) * 01-Duplicata 02-Nota Promissória 03-Nota de Seguro 04-Cobrança Seriada 05-Recibo 10-Letras de Câmbio 11-Nota de Débito 12-Duplicata de Serv. 99-Outros */ //_detalhe += "99"; _detalhe += Utils.FitStringLength(boleto.EspecieDocumento.Codigo.ToString(), 2, 2, '0', 0, true, true, true); _detalhe += "N"; //Identificação (1, A) A – aceito; N - não aceito _detalhe += boleto.DataProcessamento.ToString("ddMMyy"); //Data da emissão do Título (6, N) DDMMAA //Valida se tem instrução no list de instruções, repassa ao arquivo de remessa string vInstrucao1 = "00"; //1ª instrução (2, N) Caso Queira colocar um cod de uma instrução. ver no Manual caso nao coloca 00 string vInstrucao2 = "00"; //2ª instrução (2, N) Caso Queira colocar um cod de uma instrução. ver no Manual caso nao coloca 00 foreach (Instrucao_Bradesco instrucao in boleto.Instrucoes) { switch ((EnumInstrucoes_Bradesco)instrucao.Codigo) { case EnumInstrucoes_Bradesco.Protestar: vInstrucao1 = "06"; //Indicar o código “06” - (Protesto) vInstrucao2 = "00"; break; case EnumInstrucoes_Bradesco.NaoProtestar: vInstrucao1 = "00"; vInstrucao2 = "00"; break; case EnumInstrucoes_Bradesco.ProtestoFinsFalimentares: vInstrucao1 = "06"; //Indicar o código “06” - (Protesto) vInstrucao2 = "00"; break; case EnumInstrucoes_Bradesco.ProtestarAposNDiasCorridos: vInstrucao1 = "06"; //Indicar o código “06” - (Protesto) vInstrucao2 = Utils.FitStringLength(instrucao.QuantidadeDias.ToString(), 2, 2, '0', 0, true, true, true); break; case EnumInstrucoes_Bradesco.ProtestarAposNDiasUteis: vInstrucao1 = "06"; //Indicar o código “06” - (Protesto) vInstrucao2 = Utils.FitStringLength(instrucao.QuantidadeDias.ToString(), 2, 2, '0', 0, true, true, true); break; case EnumInstrucoes_Bradesco.NaoReceberAposNDias: vInstrucao1 = "00"; vInstrucao2 = "00"; break; case EnumInstrucoes_Bradesco.DevolverAposNDias: vInstrucao1 = "00"; vInstrucao2 = "00"; break; } } _detalhe += vInstrucao1; //posições: 157 a 158 do leiaute _detalhe += vInstrucao2; //posições: 159 a 160 do leiaute // // Valor a ser cobrado por Dia de Atraso (13, N) _detalhe += Utils.FitStringLength(boleto.JurosMora.ToString("0.00").Replace(",", ""), 13, 13, '0', 0, true, true, true); //Data Limite P/Concessão de Desconto (06, N) //if (boleto.DataDesconto.ToString("dd/MM/yyyy") == "01/01/0001") if (boleto.DataDesconto == DateTime.MinValue) // diegomodolo ([email protected]) { _detalhe += "000000"; //Caso nao tenha data de vencimento } else { _detalhe += boleto.DataDesconto.ToString("ddMMyy"); } //Valor do Desconto (13, N) _detalhe += Utils.FitStringLength(boleto.ValorDesconto.ToString("0.00").Replace(",", ""), 13, 13, '0', 0, true, true, true); //Valor do IOF (13, N) _detalhe += Utils.FitStringLength(boleto.IOF.ToString("0.00").Replace(",", ""), 13, 13, '0', 0, true, true, true); //Valor do Abatimento a ser concedido ou cancelado (13, N) _detalhe += Utils.FitStringLength(boleto.Abatimento.ToString("0.00").Replace(",", ""), 13, 13, '0', 0, true, true, true); /*Identificação do Tipo de Inscrição do Sacado (02, N) *01-CPF 02-CNPJ 03-PIS/PASEP 98-Não tem 99-Outros 00-Outros */ if (boleto.Sacado.CPFCNPJ.Length <= 11) _detalhe += "01"; // CPF else _detalhe += "02"; // CNPJ //Nº Inscrição do Sacado (14, N) string cpf_Cnpj = boleto.Sacado.CPFCNPJ.Replace("/", "").Replace(".", "").Replace("-", ""); _detalhe += Utils.FitStringLength(cpf_Cnpj, 14, 14, '0', 0, true, true, true); //Nome do Sacado (40, A) _detalhe += Utils.FitStringLength(boleto.Sacado.Nome.TrimStart(' '), 40, 40, ' ', 0, true, true, false).ToUpper(); //Endereço Completo (40, A) _detalhe += Utils.FitStringLength(boleto.Sacado.Endereco.End.TrimStart(' '), 40, 40, ' ', 0, true, true, false).ToUpper(); //1ª Mensagem (12, A) /*Campo livre para uso da Empresa. A mensagem enviada nesse campo será impressa somente no boleto e não será confirmada no Arquivo Retorno. */ _detalhe += Utils.FitStringLength(mensagem, 12, 12, ' ', 0, true, true, false); //CEP (5, N) + Sufixo do CEP (3, N) Total (8, N) _detalhe += Utils.FitStringLength(boleto.Sacado.Endereco.CEP.Replace("-", ""), 8, 8, '0', 0, true, true, true); //Sacador|Avalista ou 2ª Mensagem (60, A) _detalhe += Utils.FitStringLength(mensagem2, 60, 60, ' ', 0, true, true, false); //Nº Seqüencial do Registro (06, N) _detalhe += Utils.FitStringLength(numeroRegistro.ToString(), 6, 6, '0', 0, true, true, true); _detalhe = Utils.SubstituiCaracteresEspeciais(_detalhe); return _detalhe; } catch (Exception ex) { throw new Exception("Erro ao gerar DETALHE do arquivo CNAB400.", ex); } }
public override string GerarDetalheSegmentoRRemessa(Boleto boleto, int numeroRegistro, TipoArquivo tipoArquivo) { try { string _brancos110 = new string(' ', 110); string _brancos9 = new string(' ', 9); string _segmentoR; _segmentoR = "00100013"; _segmentoR += Utils.FitStringLength(numeroRegistro.ToString(), 5, 5, '0', 0, true, true, true); _segmentoR += "R 01"; // Desconto 2 _segmentoR += "000000000000000000000000"; //24 zeros // Desconto 3 _segmentoR += "000000000000000000000000"; //24 zeros if (boleto.PercMulta > 0) { // Código da multa 2 - percentual _segmentoR += "2"; } else if (boleto.ValorMulta > 0) { // Código da multa 1 - valor fixo _segmentoR += "1"; } else { // Código da multa 0 - sem multa _segmentoR += "0"; } _segmentoR += Utils.FitStringLength(boleto.DataMulta.ToString("ddMMyyyy"), 8, 8, '0', 0, true, true, false); _segmentoR += Utils.FitStringLength(boleto.ValorMulta.ToString("0.00").Replace(",", ""), 15, 15, '0', 0, true, true, true); _segmentoR += _brancos110; _segmentoR += "0000000000000000"; //16 zeros _segmentoR += " "; //1 branco _segmentoR += "000000000000"; //12 zeros _segmentoR += " "; //2 brancos _segmentoR += "0"; //1 zero _segmentoR += _brancos9; _segmentoR = Utils.SubstituiCaracteresEspeciais(_segmentoR); return _segmentoR; } catch (Exception ex) { throw new Exception("Erro durante a geração do SEGMENTO R DO DETALHE do arquivo de REMESSA.", ex); } }
public string GerarDetalheSegmentoQRemessaCNAB240(Boleto boleto, int numeroRegistro, TipoArquivo tipoArquivo) { try { string header = Utils.FormatCode(Codigo.ToString(), "0", 3, true); // código do banco na compensação header += "0001"; // Lote de Serviço header += "3"; // Tipo de Registro header += Utils.FormatCode(numeroRegistro.ToString(), "0", 5); // Nº Sequencial do Registro no Lote header += "Q"; // Cód. Segmento do Registro Detalhe header += " "; // Uso Exclusivo FEBRABAN/CNAB header += "01"; // Código de Movimento Remessa header += (boleto.Sacado.CPFCNPJ.Length == 11 ? "1" : "2"); // Tipo de Inscrição header += Utils.FormatCode(boleto.Sacado.CPFCNPJ, "0", 15); // Número de Inscrição header += Utils.FormatCode(boleto.Sacado.Nome, " ", 40); // Nome header += Utils.FormatCode(boleto.Sacado.Endereco.End, " ", 40); // Endereço header += Utils.FormatCode(boleto.Sacado.Endereco.Bairro, " ", 15); // Bairro header += boleto.Sacado.Endereco.CEP; // CEP + Sufixo do CEP header += Utils.FormatCode(boleto.Sacado.Endereco.Cidade, " ", 15); // Cidade header += boleto.Sacado.Endereco.UF; // Unidade da Federação // Estes campos deverão estar preenchidos quando não for o Cedente original do título. header += "0"; // Tipo de Inscrição header += Utils.FormatCode("", "0", 15); // Número de Inscrição CPF/CNPJ header += Utils.FormatCode("", " ", 40); // Nome do Sacador/Avalista //********* header += Utils.FormatCode("", " ", 31); // Uso Exclusivo FEBRABAN/CNAB return header; } catch (Exception e) { throw new Exception("Erro ao gerar SEGMENTO Q do arquivo de remessa.", e); } }
public override string GerarDetalheSegmentoRRemessa(Boleto boleto, int numeroRegistro, TipoArquivo tipoArquivo) { try { string _brancos90 = new string(' ', 90); string _brancos33 = new string(' ', 33); string _zeros27 = new string('0', 27); string _segmentoR; _segmentoR = "00100013"; _segmentoR += Utils.FitStringLength(numeroRegistro.ToString(), 5, 5, '0', 0, true, true, true); _segmentoR += "R "; _segmentoR += "01"; // Código do desconto 2 - percentual até a data informada // Data do desconto // Valor/Percentual do desconto // Campos: Desconto 2 e Desconto 3 _segmentoR += "000000000000000000000000"; _segmentoR += "000000000000000000000000"; // Código da multa 2 - percentual _segmentoR += "2"; _segmentoR += Utils.FitStringLength(boleto.DataMulta.ToString("ddMMyyyy"), 8, 8, '0', 0, true, true, false); _segmentoR += Utils.FitStringLength(Convert.ToString(boleto.ValorMulta * 100), 15, 15, '0', 0, true, true, true); _segmentoR += _brancos90; _segmentoR += _zeros27; _segmentoR += _brancos33; _segmentoR = Utils.SubstituiCaracteresEspeciais(_segmentoR); return _segmentoR; } catch (Exception ex) { throw new Exception("Erro durante a geração do SEGMENTO R DO DETALHE do arquivo de REMESSA.", ex); } }
/// <summary> /// TRAILER do arquivo CNAB /// Gera o TRAILER do arquivo remessa de acordo com o lay-out informado /// </summary> public override string GerarTrailerRemessa(int numeroRegistro, TipoArquivo tipoArquivo) { try { string _trailer = " "; base.GerarTrailerRemessa(numeroRegistro, tipoArquivo); switch (tipoArquivo) { case TipoArquivo.CNAB240: _trailer = GerarTrailerRemessa240(); break; case TipoArquivo.CNAB400: _trailer = GerarTrailerRemessa400(numeroRegistro); break; case TipoArquivo.Outro: throw new Exception("Tipo de arquivo inexistente."); } return _trailer; } catch (Exception ex) { throw new Exception("Erro durante a geração do TRAILER de arquivo do arquivo de REMESSA.", ex); } }
public override string GerarHeaderLoteRemessa(string numeroConvenio, Cedente cedente, int numeroArquivoRemessa, TipoArquivo tipoArquivo) { try { string header = " "; switch (tipoArquivo) { case TipoArquivo.CNAB240: header = GerarHeaderLoteRemessaCNAB240(cedente, numeroArquivoRemessa); break; case TipoArquivo.CNAB400: // não tem no CNAB 400 header = GerarHeaderLoteRemessaCNAB400(0, cedente, numeroArquivoRemessa); break; case TipoArquivo.Outro: throw new Exception("Tipo de arquivo inexistente."); } return header; } catch (Exception ex) { throw new Exception("Erro durante a geração do HEADER DO LOTE do arquivo de REMESSA.", ex); } }
public override string GerarHeaderRemessa(Cedente cedente, TipoArquivo tipoArquivo, int numeroArquivoRemessa) { return GerarHeaderRemessa("0", cedente, tipoArquivo, numeroArquivoRemessa); }
public string GerarDetalheRemessaCNAB240(Boleto boleto, int numeroRegistro, TipoArquivo tipoArquivo) { try { string detalhe = Utils.FormatCode(Codigo.ToString(), "0", 3, true); detalhe += Utils.FormatCode("", "0", 4, true); detalhe += "3"; detalhe += Utils.FormatCode(numeroRegistro.ToString(), 5); detalhe += "P 01"; detalhe += Utils.FormatCode(boleto.Cedente.ContaBancaria.Agencia, 5); detalhe += "0"; detalhe += Utils.FormatCode(boleto.Cedente.ContaBancaria.Conta, 12); detalhe += boleto.Cedente.ContaBancaria.DigitoConta; detalhe += " "; detalhe += Utils.FormatCode(boleto.NossoNumero.Replace("/", "").Replace("-", ""),20); detalhe += "1"; detalhe += (Convert.ToInt16(boleto.Carteira) == 1 ? "1" : "2"); detalhe += "122"; detalhe += Utils.FormatCode(boleto.NumeroDocumento, 15); detalhe += boleto.DataVencimento.ToString("ddMMyyyy"); string valorBoleto = boleto.ValorBoleto.ToString("f").Replace(",", "").Replace(".", ""); valorBoleto = Utils.FormatCode(valorBoleto, 13); detalhe += valorBoleto; detalhe += "00000 99A"; detalhe += boleto.DataDocumento.ToString("ddMMyyyy"); detalhe += "200000000"; valorBoleto = boleto.JurosMora.ToString("f").Replace(",", "").Replace(".", ""); valorBoleto = Utils.FormatCode(valorBoleto, 13); detalhe += valorBoleto; detalhe += "1"; detalhe += boleto.DataDesconto.ToString("ddMMyyyy"); valorBoleto = boleto.ValorDesconto.ToString("f").Replace(",", "").Replace(".", ""); valorBoleto = Utils.FormatCode(valorBoleto, 13); detalhe += valorBoleto; detalhe += Utils.FormatCode("", 26); detalhe += Utils.FormatCode("", " ", 25); detalhe += "0001060090000000000 "; detalhe = Utils.SubstituiCaracteresEspeciais(detalhe); return detalhe; } catch (Exception e) { throw new Exception("Erro ao gerar DETALHE do arquivo CNAB240.", e); } }
public string GerarDetalheRemessaCNAB400_A(Boleto boleto, int numeroRegistro, TipoArquivo tipoArquivo) { try { TRegistroEDI reg = new TRegistroEDI(); reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0001, 001, 0, "1", ' ')); //001-001 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0002, 001, 0, "A", ' ')); //002-002 'A' - SICREDI com Registro reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0003, 001, 0, "A", ' ')); //003-003 'A' - Simples reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0004, 001, 0, "A", ' ')); //004-004 'A' – Normal reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0005, 012, 0, string.Empty, ' ')); //005-016 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0017, 001, 0, "A", ' ')); //017-017 Tipo de moeda: 'A' - REAL reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0018, 001, 0, "A", ' ')); //018-018 Tipo de desconto: 'A' - VALOR reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0019, 001, 0, "A", ' ')); //019-019 Tipo de juros: 'A' - VALOR reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0020, 028, 0, string.Empty, ' ')); //020-047 #region Nosso Número + DV string vAuxNossoNumeroComDV = boleto.NossoNumero.Replace("/", "").Replace("-", ""); reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0048, 009, 0, vAuxNossoNumeroComDV, '0')); //048-056 #endregion reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0057, 006, 0, string.Empty, ' ')); //057-062 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediDataAAAAMMDD_________, 0063, 008, 0, boleto.DataProcessamento, ' ')); //063-070 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0071, 001, 0, string.Empty, ' ')); //071-071 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0072, 001, 0, "N", ' ')); //072-072 'N' - Não Postar e remeter para o beneficiário reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0073, 001, 0, string.Empty, ' ')); //073-073 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0074, 001, 0, "B", ' ')); //074-074 'B' – Impressão é feita pelo Beneficiário reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0075, 002, 0, 0, '0')); //075-076 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0077, 002, 0, 0, '0')); //077-078 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0079, 004, 0, string.Empty, ' ')); //079-082 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0083, 010, 2, boleto.ValorDesconto, '0')); //083-092 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0093, 004, 0, boleto.PercMulta, '0')); //093-096 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0097, 012, 0, string.Empty, ' ')); //097-108 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0109, 002, 0, "01", ' ')); //109-110 01 - Cadastro de título; reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0111, 010, 0, boleto.NumeroDocumento, ' ')); //111-120 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediDataDDMMAA___________, 0121, 006, 0, boleto.DataVencimento, ' ')); //121-126 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0127, 013, 2, boleto.ValorBoleto, '0')); //127-139 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0140, 009, 0, string.Empty, ' ')); //140-148 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0149, 001, 0, boleto.EspecieDocumento.Codigo, ' ')); //149-149 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0150, 001, 0, boleto.Aceite, ' ')); //150-150 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediDataDDMMAA___________, 0151, 006, 0, boleto.DataProcessamento, ' ')); //151-156 #region Instruções string vInstrucao1 = "00"; //1ª instrução (2, N) Caso Queira colocar um cod de uma instrução. ver no Manual caso nao coloca 00 string vInstrucao2 = "00"; //2ª instrução (2, N) Caso Queira colocar um cod de uma instrução. ver no Manual caso nao coloca 00 foreach (Instrucao_Sicredi instrucao in boleto.Instrucoes) { switch ((EnumInstrucoes_Sicredi)instrucao.Codigo) { case EnumInstrucoes_Sicredi.AlteracaoOutrosDados_CancelamentoProtestoAutomatico: vInstrucao1 = "00"; vInstrucao2 = "00"; break; case EnumInstrucoes_Sicredi.PedidoProtesto: vInstrucao1 = "06"; //Indicar o código “06” - (Protesto) vInstrucao2 = Utils.FitStringLength(instrucao.QuantidadeDias.ToString(), 2, 2, '0', 0, true, true, true); break; } } reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0157, 002, 0, vInstrucao1, '0')); //157-158 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0159, 002, 0, vInstrucao2, '0')); //159-160 #endregion reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0161, 013, 2, boleto.JurosMora, '0')); //161-173 #region DataDesconto string vDataDesconto = "000000"; if (!boleto.DataDesconto.Equals(DateTime.MinValue)) vDataDesconto = boleto.DataDesconto.ToString("ddMMyy"); #endregion reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0174, 006, 0, vDataDesconto, '0')); //174-179 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0180, 013, 2, boleto.ValorDesconto, '0')); //180-192 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0193, 013, 0, 0, '0')); //193-205 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0206, 013, 2, boleto.Abatimento, '0')); //206-218 #region Regra Tipo de Inscrição Sacado string vCpfCnpjSac = "0"; if (boleto.Sacado.CPFCNPJ.Length.Equals(11)) vCpfCnpjSac = "1"; //Cpf é sempre 11; else if (boleto.Sacado.CPFCNPJ.Length.Equals(14)) vCpfCnpjSac = "2"; //Cnpj é sempre 14; #endregion reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0219, 001, 0, vCpfCnpjSac, '0')); //219-219 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0220, 001, 0, "0", '0')); //220-220 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0221, 014, 0, boleto.Sacado.CPFCNPJ, '0')); //221-234 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0235, 040, 0, boleto.Sacado.Nome.ToUpper(), ' ')); //235-274 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0275, 040, 0, boleto.Sacado.Endereco.End.ToUpper(), ' ')); //275-314 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0315, 005, 0, 0, '0')); //315-319 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0320, 006, 0, 0, '0')); //320-325 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0326, 001, 0, string.Empty, ' ')); //326-326 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0327, 008, 0, boleto.Sacado.Endereco.CEP, '0')); //327-334 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0335, 005, 1, 0, '0')); //335-339 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0340, 014, 0, string.Empty, ' ')); //340-353 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0354, 041, 0, string.Empty, ' ')); //354-394 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0395, 006, 0, numeroRegistro, '0')); //395-400 // reg.CodificarLinha(); // string _detalhe = Utils.SubstituiCaracteresEspeciais(reg.LinhaRegistro); // return _detalhe; } catch (Exception ex) { throw new Exception("Erro ao gerar DETALHE do arquivo CNAB400.", ex); } }
public RetornoCnab400 ProcessarRetorno(TipoArquivo tipoArquivo) { throw new NotImplementedException(); }
public override string GerarHeaderRemessa(string numeroConvenio, Cedente cedente, TipoArquivo tipoArquivo, int numeroArquivoRemessa, Boleto boletos) { throw new NotImplementedException("Função não implementada."); }
public string GerarDetalheRemessaCNAB400(Boleto boleto, int numeroRegistro, TipoArquivo tipoArquivo) { try { //Variáveis Locais a serem Implementadas em nível de Config do Boleto... boleto.Remessa.CodigoOcorrencia = "01"; //remessa p/ BANCO DO BRASIL // base.GerarDetalheRemessa(boleto, numeroRegistro, tipoArquivo); // TRegistroEDI reg = new TRegistroEDI(); reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0001, 001, 0, "7", '0')); //001-001 #region Regra Tipo de Inscrição Cedente string vCpfCnpjEmi = "00"; if (boleto.Cedente.CPFCNPJ.Length.Equals(11)) vCpfCnpjEmi = "01"; //Cpf é sempre 11; else if (boleto.Cedente.CPFCNPJ.Length.Equals(14)) vCpfCnpjEmi = "02"; //Cnpj é sempre 14; #endregion reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0002, 002, 0, vCpfCnpjEmi, '0')); //002-003 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0004, 014, 0, boleto.Cedente.CPFCNPJ, '0')); //004-017 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0018, 004, 0, boleto.Cedente.ContaBancaria.Agencia, '0')); //018-021 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0022, 001, 0, boleto.Cedente.ContaBancaria.DigitoAgencia, ' '));//022-022 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0023, 008, 0, boleto.Cedente.ContaBancaria.Conta, '0')); //023-030 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0031, 001, 0, boleto.Cedente.ContaBancaria.DigitoConta, ' ')); //031-031 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0032, 007, 0, boleto.Cedente.Convenio, ' ')); //032-038 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0039, 025, 0, boleto.NumeroDocumento, ' ')); //039-063 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0064, 017, 0, boleto.NossoNumero, '0')); //064-080 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0081, 002, 0, "00", '0')); //081-082 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0083, 002, 0, "00", '0')); //083-084 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0085, 003, 0, string.Empty, ' ')); //085-087 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0088, 001, 0, string.Empty, ' ')); //088-088 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0089, 003, 0, string.Empty, ' ')); //089-091 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0092, 003, 0, boleto.VariacaoCarteira, '0')); //092-094 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0095, 001, 0, "0", '0')); //095-095 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0096, 006, 0, "0", '0')); //096-101 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0102, 005, 0, string.Empty, ' ')); //102-106 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0107, 002, 0, boleto.Cedente.Carteira, '0')); //107-108 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0109, 002, 0, boleto.Remessa.CodigoOcorrencia, ' ')); //109-110 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0111, 010, 0, boleto.NumeroDocumento, '0')); //111-120 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediDataDDMMAA___________, 0121, 006, 0, boleto.DataVencimento, ' ')); //121-126 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0127, 013, 2, boleto.ValorBoleto, '0')); //127-139 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0140, 003, 0, "001", '0')); //140-142 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0143, 004, 0, "0000", '0')); //143-146 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0147, 001, 0, string.Empty, ' ')); //147-147 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0148, 002, 0, boleto.Especie, '0')); //148-149 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0150, 001, 0, boleto.Aceite, ' ')); //150-150 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediDataDDMMAA___________, 0151, 006, 0, boleto.DataProcessamento, ' ')); //151-156 // #region Instruções string vInstrucao1 = "0"; string vInstrucao2 = "0"; //string vInstrucao3 = "0"; switch (boleto.Instrucoes.Count) { case 1: vInstrucao1 = boleto.Instrucoes[0].Codigo.ToString(); vInstrucao2 = "0"; //vInstrucao3 = "0"; break; case 2: vInstrucao1 = boleto.Instrucoes[0].Codigo.ToString(); vInstrucao2 = boleto.Instrucoes[1].Codigo.ToString(); //vInstrucao3 = "0"; break; case 3: vInstrucao1 = boleto.Instrucoes[0].Codigo.ToString(); vInstrucao2 = boleto.Instrucoes[1].Codigo.ToString(); //vInstrucao3 = boleto.Instrucoes[2].Codigo.ToString(); break; } #endregion // reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0157, 002, 0, vInstrucao1, '0')); //157-158 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0159, 002, 0, vInstrucao2, '0')); //159-160 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0161, 013, 2, boleto.JurosMora, '0')); //161-173 #region Instruções Conforme Código de Ocorrência... if (boleto.Remessa.CodigoOcorrencia.Equals("35") || boleto.Remessa.CodigoOcorrencia.Equals("36")) //“35” – Cobrar Multa – ou “36” - Dispensar Multa { #region Código de Multa e Valor/Percentual Multa string vCodigoMulta = "9"; //“9” = Dispensar Multa Decimal vMulta = 0; if (boleto.ValorMulta > 0) { vCodigoMulta = "1"; //“1” = Valor vMulta = boleto.ValorMulta; } else if (boleto.PercMulta > 0) { vCodigoMulta = "2"; //“2” = Percentual vMulta = boleto.PercMulta; } #endregion #region DataVencimento string vDataVencimento = "000000"; if (!boleto.DataVencimento.Equals(DateTime.MinValue)) vDataVencimento = boleto.DataVencimento.ToString("ddMMyy"); #endregion reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0174, 001, 0, vCodigoMulta, '0')); //174 a 174 Código da Multa 1=Valor reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediDataDDMMAA___________, 0175, 006, 0, vDataVencimento, ' ')); //175 a 180 Data de inicio para Cobrança da Multa reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0180, 013, 2, vMulta, '0')); //181 a 192 Valor de Multa } else { #region DataDesconto string vDataDesconto = "000000"; if (!boleto.DataDesconto.Equals(DateTime.MinValue)) vDataDesconto = boleto.DataDesconto.ToString("ddMMyy"); #endregion reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0174, 006, 0, vDataDesconto, '0')); //174-179 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0180, 013, 2, boleto.ValorDesconto, '0')); //180-192 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0193, 013, 2, boleto.IOF, '0')); //193-205 } #endregion // reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0206, 013, 2, boleto.Abatimento, '0')); //206-218 #region Regra Tipo de Inscrição Sacado string vCpfCnpjSac = "00"; if (boleto.Sacado.CPFCNPJ.Length.Equals(11)) vCpfCnpjSac = "01"; //Cpf é sempre 11; else if (boleto.Sacado.CPFCNPJ.Length.Equals(14)) vCpfCnpjSac = "02"; //Cnpj é sempre 14; #endregion reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0219, 002, 0, vCpfCnpjSac, '0')); //219-220 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0221, 014, 0, boleto.Sacado.CPFCNPJ, '0')); //221-234 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0235, 037, 0, boleto.Sacado.Nome.ToUpper(), ' ')); //235-271 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0272, 003, 0, string.Empty, ' ')); //272-274 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0275, 040, 0, boleto.Sacado.Endereco.End.ToUpper(), ' ')); //275-314 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0315, 012, 0, boleto.Sacado.Endereco.Bairro.ToUpper(), ' ')); //315-326 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0327, 008, 0, boleto.Sacado.Endereco.CEP, '0')); //327-334 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0335, 015, 0, boleto.Sacado.Endereco.Cidade.ToUpper(), ' ')); //335-349 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0350, 002, 0, boleto.Sacado.Endereco.UF.ToUpper(), ' ')); //350-351 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0352, 040, 0, string.Empty, ' ')); //352-391 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0392, 002, 0, string.Empty, ' ')); //392-393 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0394, 001, 0, string.Empty, ' ')); //394-394 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0395, 006, 0, numeroRegistro, '0')); //395-400 // reg.CodificarLinha(); // string _detalhe = Utils.SubstituiCaracteresEspeciais(reg.LinhaRegistro); // return _detalhe; } catch (Exception ex) { throw new Exception("Erro ao gerar DETALHE do arquivo CNAB400.", ex); } }
public string GerarDetalheRemessaCNAB400(Boleto boleto, int numeroRegistro, TipoArquivo tipoArquivo) { throw new NotImplementedException("Função não implementada."); }
public override string GerarTrailerRemessa(int numeroRegistro, TipoArquivo tipoArquivo, Cedente cedente, decimal vltitulostotal) { try { string _trailer = " "; switch (tipoArquivo) { case TipoArquivo.CNAB240: _trailer = GerarTrailerRemessa240(numeroRegistro); break; case TipoArquivo.CNAB400: _trailer = GerarTrailerRemessa400(numeroRegistro, cedente); break; case TipoArquivo.Outro: throw new Exception("Tipo de arquivo inexistente."); } return _trailer; } catch (Exception ex) { throw new Exception("", ex); } }
public override string GerarDetalheSegmentoQRemessa(Boleto boleto, int numeroRegistro, TipoArquivo tipoArquivo) { try { string _nossoNumero = new string('0', 20); string _zeros16 = new string('0', 16); string _brancos40 = new string(' ', 40); string _brancos28 = new string(' ', 28); string _segmentoQ; _segmentoQ = "00100013"; _segmentoQ += Utils.FitStringLength(numeroRegistro.ToString(), 5, 5, '0', 0, true, true, true); _segmentoQ += "Q 01"; if (boleto.Sacado.CPFCNPJ.Length <= 11) _segmentoQ += "1"; else _segmentoQ += "2"; _segmentoQ += Utils.FitStringLength(boleto.Sacado.CPFCNPJ, 15, 15, '0', 0, true, true, true); _segmentoQ += Utils.FitStringLength(boleto.Sacado.Nome.ToUpper(), 40, 40, ' ', 0, true, true, false); _segmentoQ += Utils.FitStringLength((boleto.Sacado.Endereco.End + " " + boleto.Sacado.Endereco.Numero + " - " + boleto.Sacado.Endereco.Complemento), 40, 40, ' ', 0, true, true, true).ToUpper(); _segmentoQ += Utils.FitStringLength(boleto.Sacado.Endereco.Bairro, 15, 15, ' ', 0, true, true, false).ToUpper(); _segmentoQ += Utils.FitStringLength(boleto.Sacado.Endereco.CEP, 8, 8, ' ', 0, true, true, false).ToUpper(); ; _segmentoQ += Utils.FitStringLength(boleto.Sacado.Endereco.Cidade, 15, 15, ' ', 0, true, true, false).ToUpper(); _segmentoQ += Utils.FitStringLength(boleto.Sacado.Endereco.UF, 2, 2, ' ', 0, true, true, false).ToUpper(); _segmentoQ += _zeros16; _segmentoQ += _brancos40; _segmentoQ += "000"; _segmentoQ += _brancos28; _segmentoQ = Utils.SubstituiCaracteresEspeciais(_segmentoQ); return _segmentoQ; } catch (Exception ex) { throw new Exception("Erro durante a geração do SEGMENTO Q DO DETALHE do arquivo de REMESSA.", ex); } }
public string GerarDetalheRemessaCNAB400(Boleto boleto, int numeroRegistro, TipoArquivo tipoArquivo) { try { //Variáveis Locais a serem Implementadas em nível de Config do Boleto... boleto.Remessa.CodigoOcorrencia = "01"; //remessa p/ bANRISUL // base.GerarDetalheRemessa(boleto, numeroRegistro, tipoArquivo); // TRegistroEDI reg = new TRegistroEDI(); reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0001, 001, 0, "1", ' ')); //001-001 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0002, 016, 0, string.Empty, ' ')); //002-017 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0018, 013, 0, boleto.Cedente.Codigo, ' ')); //018-030 (sidnei.klein 22/11/2013: No Banrisul, o Código do Cedente não é a concatenação de Número da Conta com o Dígito Verificador.) reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0031, 007, 0, string.Empty, ' ')); //031-037 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0038, 025, 0, boleto.NumeroDocumento, ' ')); //038-062 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0063, 010, 0, boleto.NossoNumero, '0')); //063-072 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0073, 032, 0, string.Empty, ' ')); //073-104 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0105, 003, 0, string.Empty, ' ')); //105-107 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0108, 001, 0, "1", ' ')); //108-108 //COBRANÇA SIMPLES reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0109, 002, 0, boleto.Remessa.CodigoOcorrencia, ' ')); //109-110 //REMESSA reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0111, 010, 0, boleto.NumeroDocumento, ' ')); //111-120 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediDataDDMMAA___________, 0121, 006, 0, boleto.DataVencimento, ' ')); //121-126 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0127, 013, 2, boleto.ValorBoleto, '0')); //127-139 // reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0140, 003, 0, "041", ' ')); //140-142 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0143, 005, 0, string.Empty, ' ')); //143-147 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0148, 002, 0, boleto.Remessa.TipoDocumento, ' ')); //148-149 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0150, 001, 0, boleto.Aceite, ' ')); //150-150 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediDataDDMMAA___________, 0151, 006, 0, boleto.DataProcessamento, ' ')); //151-156 // #region Instruções string vQtdeDiasCodigo_9_ou_15 = "0"; // string vInstrucao1 = string.Empty; string vInstrucao2 = string.Empty; switch (boleto.Instrucoes.Count) { case 1: vInstrucao1 = boleto.Instrucoes[0].Codigo.ToString().PadLeft(2, '0'); vInstrucao2 = string.Empty; //valida se é código 9 ou 15, para adicionar os dias na posição 370-371 if (boleto.Instrucoes[0].Codigo == 9 || boleto.Instrucoes[0].Codigo == 15) { vQtdeDiasCodigo_9_ou_15 = boleto.Instrucoes[0].QuantidadeDias.ToString(); } // break; case 2: vInstrucao1 += boleto.Instrucoes[0].Codigo.ToString().PadLeft(2, '0'); //valida se é código 9 ou 15, para adicionar os dias na posição 370-371 if (boleto.Instrucoes[0].Codigo == 9 || boleto.Instrucoes[0].Codigo == 15) { vQtdeDiasCodigo_9_ou_15 = boleto.Instrucoes[0].QuantidadeDias.ToString(); } // vInstrucao2 += boleto.Instrucoes[1].Codigo.ToString().PadLeft(2, '0'); //valida se é código 9 ou 15, para adicionar os dias na posição 370-371 if (boleto.Instrucoes[1].Codigo == 9 || boleto.Instrucoes[1].Codigo == 15) { vQtdeDiasCodigo_9_ou_15 = boleto.Instrucoes[1].QuantidadeDias.ToString(); } // break; } #endregion // reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0157, 002, 0, vInstrucao1, ' ')); //157-158 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0159, 002, 0, vInstrucao2, ' ')); //159-160 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0161, 001, 0, "0", ' ')); //161-161 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0162, 012, 2, boleto.JurosMora, '0')); //162-173 #region DataDesconto string vDataDesconto = "000000"; if (!boleto.DataDesconto.Equals(DateTime.MinValue)) { vDataDesconto = boleto.DataDesconto.ToString("ddMMyy"); } #endregion reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0174, 006, 0, vDataDesconto, '0')); //174-179 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0180, 013, 2, boleto.ValorDesconto, '0')); //180-192 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0193, 013, 2, boleto.IOF, '0')); //193-205 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0206, 013, 2, boleto.Abatimento, '0')); //206-218 #region Regra Tipo de Inscrição Sacado string vCpfCnpjSac = "99"; if (boleto.Sacado.CPFCNPJ.Length.Equals(11)) { vCpfCnpjSac = "01"; //Cpf é sempre 11; } else if (boleto.Sacado.CPFCNPJ.Length.Equals(14)) { vCpfCnpjSac = "02"; //Cnpj é sempre 14; } #endregion reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0219, 002, 0, vCpfCnpjSac, '0')); //219-220 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0221, 014, 0, boleto.Sacado.CPFCNPJ, '0')); //221-234 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0235, 035, 0, boleto.Sacado.Nome.ToUpper(), ' ')); //235-269 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0270, 005, 0, string.Empty, ' ')); //270-274 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0275, 040, 0, boleto.Sacado.Endereco.End.ToUpper(), ' ')); //275-314 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0315, 007, 0, string.Empty, ' ')); //315-321 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0322, 003, 0, 0, '0')); //322-324 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0325, 002, 0, 0, '0')); //325-326 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0327, 008, 0, boleto.Sacado.Endereco.CEP, '0')); //327-334 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0335, 015, 0, boleto.Sacado.Endereco.Cidade.ToUpper(), ' ')); //335-349 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0350, 002, 0, boleto.Sacado.Endereco.UF.ToUpper(), ' ')); //350-351 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0352, 004, 1, 0, '0')); //352-355 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0356, 001, 0, string.Empty, ' ')); //356-356 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0357, 013, 2, 0, '0')); //357-369 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0370, 002, 0, vQtdeDiasCodigo_9_ou_15, '0')); //370-371 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0372, 023, 0, string.Empty, ' ')); //372-394 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0395, 006, 0, numeroRegistro, '0')); //395-400 // // reg.CodificarLinha(); // string _detalhe = Utils.SubstituiCaracteresEspeciais(reg.LinhaRegistro); // return(_detalhe); } catch (Exception ex) { throw new Exception("Erro ao gerar DETALHE do arquivo CNAB400.", ex); } }
public override string GerarHeaderRemessa(Cedente cedente, TipoArquivo tipoArquivo) { try { base.GerarHeaderRemessa(cedente, tipoArquivo); string _brancos20 = new string(' ', 20); string _brancos10 = new string(' ', 10); string _header; _header = "00100000 "; if (cedente.CPFCNPJ.Length <= 11) _header += "1"; else _header += "2"; _header += Utils.FitStringLength(cedente.CPFCNPJ, 14, 14, '0', 0, true, true, true); _header += _brancos20; _header += Utils.FitStringLength(cedente.ContaBancaria.Agencia, 5, 5, '0', 0, true, true, true); _header += Utils.FitStringLength(cedente.ContaBancaria.DigitoAgencia, 1, 1, ' ', 0, true, true, false); _header += Utils.FitStringLength(cedente.ContaBancaria.Conta, 12, 12, '0', 0, true, true, true); _header += Utils.FitStringLength(cedente.ContaBancaria.DigitoConta, 1, 1, ' ', 0, true, true, false); _header += " "; // DÍGITO VERIFICADOR DA AG./CONTA _header += Utils.FitStringLength(cedente.Nome, 30, 30, ' ', 0, true, true, false); _header += Utils.FitStringLength("BANCO DO BRASIL S.A.", 30, 30, ' ', 0, true, true, false); _header += _brancos10; _header += "1"; _header += DateTime.Now.ToString("ddMMyyyy"); _header += DateTime.Now.ToString("hhMMss"); _header += "000001"; // NÚMERO SEQUENCIAL DO ARQUIVO *EVOLUIR UM NÚMERO A CADA HEADER DE ARQUIVO _header += "03000000"; _header += _brancos20; _header += _brancos20; _header += _brancos10; _header += " "; _header += "000 "; _header += _brancos10; _header = Utils.SubstituiCaracteresEspeciais(_header); return _header; } catch (Exception ex) { throw new Exception("Erro durante a geração do HEADER DE ARQUIVO do arquivo de REMESSA.", ex); } }
public override string GerarHeaderLoteRemessa(string numeroConvenio, Cedente cedente, int numeroArquivoRemessa, TipoArquivo tipoArquivo, Boleto boletos) { try { string header = " "; switch (tipoArquivo) { case TipoArquivo.CNAB240: if (boletos.Remessa.TipoDocumento.Equals("2") || boletos.Remessa.TipoDocumento.Equals("1")) header = GerarHeaderLoteRemessaCNAC240SIGCB(cedente, numeroArquivoRemessa); else header = GerarHeaderLoteRemessaCNAB240(cedente, numeroArquivoRemessa); break; case TipoArquivo.CNAB400: //header = GerarHeaderLoteRemessaCNAB400(0, cedente, numeroArquivoRemessa); break; case TipoArquivo.Outro: throw new Exception("Tipo de arquivo inexistente."); } return header; } catch (Exception ex) { throw new Exception("Erro durante a geração do HEADER DO LOTE do arquivo de REMESSA.", ex); } }
public string GerarDetalheRemessaCNAB400(Boleto boleto, int numeroRegistro, TipoArquivo tipoArquivo) { try { base.GerarDetalheRemessa(boleto, numeroRegistro, tipoArquivo); string _brancos1 = new string(' ', 20); // USO DO BANCO - Identificação da operação no Banco (posição 87 a 107) string identificaOperacaoBanco = new string(' ', 21); string usoBanco = new string(' ', 10); string _brancos = new string(' ', 40); string _detalhe; _detalhe = "1"; // Tipo de inscrição da empresa // 01 - CPF DO CEDENTE // 02 - CNPJ DO CEDENTE if (boleto.Cedente.CPFCNPJ.Length <= 11) _detalhe += "01"; else _detalhe += "02"; _detalhe += Utils.FitStringLength(boleto.Cedente.CPFCNPJ.ToString(), 14, 14, '0', 0, true, true, true); _detalhe += _brancos1; _detalhe += _brancos1 + " "; _detalhe += "000000000"; _detalhe += "00000000000 "; // Valor por dia de antecipação _detalhe += "R$ "; _detalhe += _brancos1; Carteira_BankBoston _carteira = new Carteira_BankBoston(Convert.ToInt32(boleto.Carteira)); _detalhe += _carteira.Tipo; _detalhe += "01"; _detalhe += Utils.FitStringLength(boleto.NumeroDocumento, 10, 10, ' ', 0, true, true, false); _detalhe += boleto.DataVencimento.ToString("ddMMyy"); _detalhe += Utils.FitStringLength(Convert.ToString(boleto.ValorBoleto * 100), 13, 13, '0', 0, true, true, true); _detalhe += "479 "; _detalhe += boleto.EspecieDocumento.Sigla; _detalhe += "N"; _detalhe += DateTime.Now.ToString("ddMMyy"); if (boleto.Instrucoes.Count > 1) { _detalhe += Utils.FitStringLength(boleto.Instrucoes[0].Codigo.ToString(), 2, 2, '0', 0, true, true, true); if ((boleto.Instrucoes[0].Codigo == 2) || (boleto.Instrucoes[0].Codigo == 3)) _detalhe += "05"; else _detalhe += "00"; } _detalhe += Utils.FitStringLength(Convert.ToString(boleto.JurosMora * 100), 13, 13, '0', 0, true, true, true); _detalhe += boleto.DataVencimento.ToString("ddMMyy"); _detalhe += Utils.FitStringLength(Convert.ToString(boleto.ValorDesconto * 100), 13, 13, '0', 0, true, true, true); _detalhe += Utils.FitStringLength(Convert.ToString(boleto.IOF * 100), 13, 13, '0', 0, true, true, true); _detalhe += Utils.FitStringLength(Convert.ToString(boleto.Abatimento * 100), 13, 13, '0', 0, true, true, true); if (boleto.Sacado.CPFCNPJ.Length > 11) _detalhe += "01"; // CPF else _detalhe += "02"; // CNPJ _detalhe += Utils.FitStringLength(boleto.Sacado.CPFCNPJ, 14, 14, '0', 0, true, true, true).ToUpper(); _detalhe += Utils.FitStringLength(boleto.Sacado.Nome, 30, 30, ' ', 0, true, true, false); _detalhe += Utils.FitStringLength((boleto.Sacado.Endereco.End + " " + boleto.Sacado.Endereco.Numero + " - " + boleto.Sacado.Endereco.Complemento + " " + boleto.Sacado.Endereco.Bairro), 37, 37, ' ', 0, true, true, true).ToUpper(); _detalhe += " "; _detalhe += Utils.FitStringLength(boleto.Sacado.Endereco.CEP, 8, 8, ' ', 0, true, true, false).ToUpper(); ; _detalhe += Utils.FitStringLength(boleto.Sacado.Endereco.Cidade, 15, 15, ' ', 0, true, true, false).ToUpper(); _detalhe += Utils.FitStringLength(boleto.Sacado.Endereco.UF, 2, 2, ' ', 0, true, true, false).ToUpper(); _detalhe += _brancos; _detalhe += " "; _detalhe += Utils.FitStringLength(numeroRegistro.ToString(), 6, 6, '0', 0, true, true, true); _detalhe = Utils.SubstituiCaracteresEspeciais(_detalhe); return _detalhe; } catch (Exception ex) { throw new Exception("Erro ao gerar DETALHE do arquivo CNAB400.", ex); } }
/// <summary> /// Gera o HEADER do arquivo remessa de acordo com o lay-out informado /// </summary> public override string GerarHeaderRemessa(string numeroConvenio, Cedente cedente, TipoArquivo tipoArquivo, int numeroArquivoRemessa) { try { string _header = " "; base.GerarHeaderRemessa(numeroConvenio, cedente, tipoArquivo, numeroArquivoRemessa); switch (tipoArquivo) { case TipoArquivo.CNAB240: _header = GerarHeaderRemessaCNAB240(); break; case TipoArquivo.CNAB400: _header = GerarHeaderRemessaCNAB400(int.Parse(numeroConvenio), cedente, numeroArquivoRemessa); break; case TipoArquivo.Outro: throw new Exception("Tipo de arquivo inexistente."); } return(_header); } catch (Exception ex) { throw new Exception("Erro durante a geração do HEADER do arquivo de REMESSA.", ex); } }
public void GeraDadosBradesco(TipoArquivo tipoArquivo) { Cedente objCEDENTE = new Cedente( "12345678000155", "TESTE", "1111", "11234", "1" ); objCEDENTE.Codigo = "123456"; objCEDENTE.Convenio = 9; Instrucao_Bradesco item1 = new Instrucao_Bradesco(9, 5); //Instancia de Boleto Boleto objBOLETO = new Boleto(); //O nosso-numero deve ser de 11 posi��es objBOLETO.EspecieDocumento = new EspecieDocumento(237, "12"); objBOLETO.DataVencimento = DateTime.Now.AddDays(10); objBOLETO.ValorBoleto = 90; objBOLETO.Carteira = "09"; objBOLETO.NossoNumero = ("00000012345"); objBOLETO.Cedente = objCEDENTE; //O num do documento deve ser de 10 posi��es objBOLETO.NumeroDocumento = "1234567890"; objBOLETO.NumeroControle = "100"; //A data do documento � a data de emiss�o do boleto objBOLETO.DataDocumento = DateTime.Now; //A data de processamento � a data em que foi processado o documento, portanto � da data de emissao do boleto objBOLETO.DataProcessamento = DateTime.Now; objBOLETO.Sacado = new Sacado("12345678000255", "TESTE SACADO"); objBOLETO.Sacado.Endereco.End = "END SACADO"; objBOLETO.Sacado.Endereco.Bairro = "BAIRRO SACADO"; objBOLETO.Sacado.Endereco.Cidade = "CIDADE SACADO"; objBOLETO.Sacado.Endereco.CEP = "CEP SACADO"; objBOLETO.Sacado.Endereco.UF = "RR"; objBOLETO.PercMulta = 10; objBOLETO.JurosMora = 5; objBOLETO.Instrucoes.Add(item1); objBOLETO.Banco = new Banco(237); // nao precisa desta parte no boleto do brasdesco. /*objBOLETO.Remessa = new Remessa() { Ambiente = Remessa.TipoAmbiemte.Producao, CodigoOcorrencia = "01", };*/ Boletos objBOLETOS = new Boletos(); objBOLETOS.Add(objBOLETO); objBOLETOS.Add(objBOLETO); var mem = new MemoryStream(); var objREMESSA = new ArquivoRemessa(TipoArquivo.CNAB400); switch (tipoArquivo) { case TipoArquivo.CNAB240: //GeraArquivoCNAB240(b2.Banco, c, boletos); break; case TipoArquivo.CNAB400: GeraArquivoCNAB400(objBOLETO.Banco, objCEDENTE, objBOLETOS, "09"); break; default: break; } }
public string GerarDetalheRemessaCNAB400(Boleto boleto, int numeroRegistro, TipoArquivo tipoArquivo) { string _detalhe = string.Empty; //Variáveis Locais a serem Implementadas em nível de Config do Boleto... //boleto.Remessa.CodigoOcorrencia = "01"; //remessa p/ bANRISUL // base.GerarDetalheRemessa(boleto, numeroRegistro, tipoArquivo); // //Redireciona para o Detalhe da remessa Conforme o "Tipo de Documento" = "Tipo de Cobrança do CNAB400": // A = 'A' - SICREDI com Registro // C1 = 'C' - SICREDI sem Registro Impressão Completa pelo Sicredi // C2 = 'C' - SICREDI sem Registro Pedido de bloquetos pré-impressos if (boleto.Remessa.TipoDocumento.Equals("A")) _detalhe = GerarDetalheRemessaCNAB400_A(boleto, numeroRegistro, tipoArquivo); else if (boleto.Remessa.TipoDocumento.Equals("C1")) _detalhe = GerarDetalheRemessaCNAB400_C1(boleto, numeroRegistro, tipoArquivo); else if (boleto.Remessa.TipoDocumento.Equals("C2")) _detalhe = GerarDetalheRemessaCNAB400_C2(boleto, numeroRegistro, tipoArquivo); return _detalhe; }
// public void GeraDadosItau(TipoArquivo tipoArquivo) { DateTime vencimento = new DateTime(2007, 9, 10); Instrucao_Itau item1 = new Instrucao_Itau(9, 5); Instrucao_Itau item2 = new Instrucao_Itau(81, 10); Cedente c = new Cedente("00.000.000/0000-00", "Empresa de Atacado", "0542", "13000"); //Na carteira 198 o código do Cedente é a conta bancária c.Codigo = "13000"; Boleto b = new Boleto(vencimento, 1642, "198", "92082835", c); b.NumeroDocumento = "1008073"; b.DataVencimento = Convert.ToDateTime("12-12-12"); b.Sacado = new Sacado("000.000.000-00", "Fulano de Silva"); b.Sacado.Endereco.End = "SSS 154 Bloco J Casa 23"; b.Sacado.Endereco.Bairro = "Testando"; b.Sacado.Endereco.Cidade = "Testelândia"; b.Sacado.Endereco.CEP = "70000000"; b.Sacado.Endereco.UF = "DF"; item2.Descricao += item2.QuantidadeDias.ToString() + " dias corridos do vencimento."; b.Instrucoes.Add(item1); b.Instrucoes.Add(item2); b.Cedente.ContaBancaria.DigitoAgencia = "1"; b.Cedente.ContaBancaria.DigitoAgencia = "2"; b.Banco = new Banco(341); Boletos boletos = new Boletos(); boletos.Add(b); Boleto b2 = new Boleto(vencimento, 1642, "198", "92082835", c); b2.NumeroDocumento = "1008073"; b2.DataVencimento = Convert.ToDateTime("12-12-12"); b2.Sacado = new Sacado("000.000.000-00", "Fulano de Silva"); b2.Sacado.Endereco.End = "SSS 154 Bloco J Casa 23"; b2.Sacado.Endereco.Bairro = "Testando"; b2.Sacado.Endereco.Cidade = "Testelândia"; b2.Sacado.Endereco.CEP = "70000000"; b2.Sacado.Endereco.UF = "DF"; item2.Descricao += item2.QuantidadeDias.ToString() + " dias corridos do vencimento."; b2.Instrucoes.Add(item1); b2.Instrucoes.Add(item2); b2.Cedente.ContaBancaria.DigitoAgencia = "1"; b2.Cedente.ContaBancaria.DigitoAgencia = "2"; b2.Banco = new Banco(341); boletos.Add(b2); switch (tipoArquivo) { case TipoArquivo.CNAB240: GeraArquivoCNAB240(b2.Banco, c, boletos); break; case TipoArquivo.CNAB400: GeraArquivoCNAB400(b2.Banco, c, boletos); break; default: break; } }
public string GerarDetalheRemessaCNAB400_C2(Boleto boleto, int numeroRegistro, TipoArquivo tipoArquivo) { //TODO string _detalhe = String.Empty; // return _detalhe; }
public ArquivoRetorno(IBanco banco, TipoArquivo tipoArquivo) { Banco = banco; TipoArquivo = tipoArquivo; }
public string GerarDetalheRemessaCNAB400(Boleto boleto, int numeroRegistro, TipoArquivo tipoArquivo) { try { //Variáveis Locais a serem Implementadas em nível de Config do Boleto... boleto.Remessa.CodigoOcorrencia = "01"; //remessa p/ CAIXA ECONOMICA FEDERAL // base.GerarDetalheRemessa(boleto, numeroRegistro, tipoArquivo); // TRegistroEDI reg = new TRegistroEDI(); reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0001, 001, 0, "1", '0')); //001-001 #region Regra Tipo de Inscrição Cedente string vCpfCnpjEmi = "00"; if (boleto.Cedente.CPFCNPJ.Length.Equals(11)) vCpfCnpjEmi = "01"; //Cpf é sempre 11; else if (boleto.Cedente.CPFCNPJ.Length.Equals(14)) vCpfCnpjEmi = "02"; //Cnpj é sempre 14; #endregion reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0002, 002, 0, vCpfCnpjEmi, '0')); //002-003 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0004, 014, 0, boleto.Cedente.CPFCNPJ, '0')); //004-017 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0018, 004, 0, boleto.Cedente.ContaBancaria.Agencia, '0')); //018-021 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0022, 006, 0, boleto.Cedente.Codigo, ' ')); //022-027 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0028, 001, 0, '2', ' ')); //028-028 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0029, 001, 0, '0', ' ')); //029-029 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0030, 002, 0, "00", ' ')); //030-031 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0032, 025, 0, boleto.NumeroDocumento, '0')); //032-056 //reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0057, 002, 0, boleto.Carteira, '0')); //057-058 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0059, 015, 0, boleto.NossoNumero, '0')); //059-073 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0074, 003, 0, string.Empty, ' ')); //074-076 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0077, 030, 0, string.Empty, ' ')); //077-106 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0107, 002, 0, "01", '0')); //107-108 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0109, 002, 0, boleto.Remessa.CodigoOcorrencia, ' ')); //109-110 //REMESSA reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0111, 010, 0, boleto.NumeroDocumento, '0')); //111-120 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediDataDDMMAA___________, 0121, 006, 0, boleto.DataVencimento, ' ')); //121-126 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0127, 013, 2, boleto.ValorBoleto, '0')); //127-139 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0140, 003, 0, "104", '0')); //140-142 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0143, 005, 0, "00000", '0')); //143-147 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliDireita______, 0148, 002, 0, boleto.EspecieDocumento.Codigo, '0')); //148-149 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0150, 001, 0, boleto.Aceite, ' ')); //150-150 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediDataDDMMAA___________, 0151, 006, 0, boleto.DataDocumento, ' ')); //151-156 // #region Instruções string vInstrucao1 = "0"; string vInstrucao2 = "0"; string vInstrucao3 = "0"; int prazoProtesto_Devolucao = 0; foreach (IInstrucao instrucao in boleto.Instrucoes) { switch ((EnumInstrucoes_Caixa)instrucao.Codigo) { case EnumInstrucoes_Caixa.Protestar: vInstrucao1 = "01"; prazoProtesto_Devolucao = instrucao.QuantidadeDias; break; default: break; } } #region OLD //switch (boleto.Instrucoes.Count) //{ // case 1: // vInstrucao1 = boleto.Instrucoes[0].Codigo.ToString(); // vInstrucao2 = "0"; // vInstrucao3 = "0"; // break; // case 2: // vInstrucao1 = boleto.Instrucoes[0].Codigo.ToString(); // vInstrucao2 = boleto.Instrucoes[1].Codigo.ToString(); // vInstrucao3 = "0"; // break; // case 3: // vInstrucao1 = boleto.Instrucoes[0].Codigo.ToString(); // vInstrucao2 = boleto.Instrucoes[1].Codigo.ToString(); // vInstrucao3 = boleto.Instrucoes[2].Codigo.ToString(); // break; //} #endregion OLD #endregion Instruções // reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0157, 002, 0, vInstrucao1, '0')); //157-158 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0159, 002, 0, vInstrucao2, '0')); //159-160 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0161, 013, 2, boleto.JurosMora, '0')); //161-173 #region DataDesconto string vDataDesconto = "000000"; if (!boleto.DataDesconto.Equals(DateTime.MinValue)) vDataDesconto = boleto.DataDesconto.ToString("ddMMyy"); #endregion reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0174, 006, 0, vDataDesconto, '0')); //174-179 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0180, 013, 2, boleto.ValorDesconto, '0')); //180-192 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0193, 013, 2, boleto.IOF, '0')); //193-205 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0206, 013, 2, boleto.Abatimento, '0')); //206-218 #region Regra Tipo de Inscrição Sacado string vCpfCnpjSac = "99"; if (boleto.Sacado.CPFCNPJ.Length.Equals(11)) vCpfCnpjSac = "01"; //Cpf é sempre 11; else if (boleto.Sacado.CPFCNPJ.Length.Equals(14)) vCpfCnpjSac = "02"; //Cnpj é sempre 14; #endregion reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0219, 002, 0, vCpfCnpjSac, '0')); //219-220 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0221, 014, 0, boleto.Sacado.CPFCNPJ, '0')); //221-234 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0235, 040, 0, boleto.Sacado.Nome.ToUpper(), ' ')); //235-274 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0275, 040, 0, boleto.Sacado.Endereco.End.ToUpper(), ' ')); //275-314 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0315, 012, 0, boleto.Sacado.Endereco.Bairro.ToUpper(), ' ')); //315-326 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0327, 008, 0, boleto.Sacado.Endereco.CEP, '0')); //327-334 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0335, 015, 0, boleto.Sacado.Endereco.Cidade.ToUpper(), ' ')); //335-349 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0350, 002, 0, boleto.Sacado.Endereco.UF.ToUpper(), ' ')); //350-351 #region DataMulta string vDataMulta = "000000"; if (!boleto.DataMulta.Equals(DateTime.MinValue)) vDataMulta = boleto.DataMulta.ToString("ddMMyy"); #endregion reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0352, 006, 0, vDataMulta, '0')); //352-357 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0358, 010, 2, boleto.ValorMulta, '0')); //358-367 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediAlphaAliEsquerda_____, 0368, 022, 0, string.Empty, ' ')); //368-389 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0390, 002, 0, vInstrucao3, '0')); //390-391 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0392, 002, 0, prazoProtesto_Devolucao, '0')); //392-393 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0394, 001, 0, 1, '0')); //394-394 reg.CamposEDI.Add(new TCampoRegistroEDI(TTiposDadoEDI.ediNumericoSemSeparador_, 0395, 006, 0, numeroRegistro, '0')); //395-400 // reg.CodificarLinha(); // string _detalhe = Utils.SubstituiCaracteresEspeciais(reg.LinhaRegistro); // return _detalhe; } catch (Exception ex) { throw new Exception("Erro ao gerar DETALHE do arquivo CNAB400.", ex); } }
public override string GerarHeaderRemessa(string numeroConvenio, Cedente cedente, TipoArquivo tipoArquivo, int numeroArquivoRemessa) { try { string _header = " "; base.GerarHeaderRemessa("0", cedente, tipoArquivo, numeroArquivoRemessa); switch (tipoArquivo) { case TipoArquivo.CNAB240: _header = GerarHeaderRemessaCNAB240(cedente); break; case TipoArquivo.CNAB400: _header = GerarHeaderRemessaCNAB400(0, cedente, numeroArquivoRemessa); break; case TipoArquivo.Outro: throw new Exception("Tipo de arquivo inexistente."); } return _header; } catch (Exception ex) { throw new Exception("Erro durante a geração do HEADER do arquivo de REMESSA.", ex); } }
public override string GerarDetalheSegmentoQRemessa(Boleto boleto, int numeroRegistro, TipoArquivo tipoArquivo) { return GerarDetalheSegmentoQRemessaCNAB240(boleto, numeroRegistro, tipoArquivo); }
/// <summary> /// Efetua as Validações dentro da classe Boleto, para garantir a geração da remessa /// </summary> public override bool ValidarRemessa(TipoArquivo tipoArquivo, string numeroConvenio, IBanco banco, Cedente cedente, Boletos boletos, int numeroArquivoRemessa, out string mensagem) { bool vRetorno = true; string vMsg = string.Empty; // switch (tipoArquivo) { case TipoArquivo.CNAB240: //vRetorno = ValidarRemessaCNAB240(numeroConvenio, banco, cedente, boletos, numeroArquivoRemessa, out vMsg); break; case TipoArquivo.CNAB400: vRetorno = ValidarRemessaCNAB400(numeroConvenio, banco, cedente, boletos, numeroArquivoRemessa, out vMsg); break; case TipoArquivo.Outro: throw new Exception("Tipo de arquivo inexistente."); } // mensagem = vMsg; return vRetorno; }
public override string GerarDetalheSegmentoRRemessa(Boleto boleto, int numeroRegistroDetalhe, TipoArquivo CNAB240) { return GerarDetalheSegmentoRRemessaCNAB240(boleto, numeroRegistroDetalhe, CNAB240); }