Access to the shipment file boleto . NET

Asked

Viewed 2,514 times

7

I am using the billet . NET to generate billets in my application.

The ticket is generated, but how do I process the shipment file? This file is saved somewhere in the application?

I took the example of the project that is in Git, but I don’t know how to process the generated shipment file, I don’t even know where it is saved.

//cedente
String cedente_codigo = "1111111";
String cedente_nossoNumeroBoleto = "22222222";
String cedente_Cnpj = "000.000.000-00";
String cedente_nome = "Nome do Cendete.";
String cedente_agencia = "0000";
String cedente_conta = "00000";
String cedente_digitoConta = "0";

Cedente cedente = new Cedente(cedente_Cnpj, cedente_nome, cedente_agencia, cedente_conta);

// Na carteira 198 o código do Cedente é a conta bancária
cedente.Codigo = "13000";

Boleto boleto = new Boleto(vencimento, valorPagamento, "176", "00000001", cedente,
                           new EspecieDocumento(341, "1")); //banco 341 - Itau

boleto.NumeroDocumento = "00000001";            

boleto.Sacado = new Sacado(cliente.Cnpj, cliente.NomeFantasia);
boleto.Sacado.Endereco.End = cliente.Logradouro;
boleto.Sacado.Endereco.Bairro = cliente.Bairro;
boleto.Sacado.Endereco.Cidade = cliente.Cidade.Nome;
boleto.Sacado.Endereco.CEP = cliente.Cep;
boleto.Sacado.Endereco.UF = cliente.Estado.Sigla;
boletoBancario.GerarArquivoRemessa = true;
boletoBancario.Boleto = boleto;
boletoBancario.Boleto.Valida();

Boletos boletos = new Boletos();
boletos.Add(boleto);

// geração do arquivo de remessa - Feito com a ajuda de jbueno
var objRemessa = new ArquivoRemessa(TipoArquivo.CNAB400);
var memoryStr = new MemoryStream();

objRemessa.GerarArquivoRemessa("09", new Banco(341), cedente, boletos, memoryStr, 1000);

if (Session["boleto"] != null)
    Session.Remove("boleto");
    Session["boleto"] = boletoBancario.MontaHtmlEmbedded();
  • 2

    Hello Raul, welcome to Stack Overflow. Your question does not provide an example of enough code and information for someone to diagnose your problem. Take a look at How to ask a good question? and How to create a Minimum, Complete and Verifiable example in Help Center.

  • objRemessa.Gerararquivoremessa("09", new Bank(341), cedente, boletos, memoryStr, 1000); Which path the file is generated ?

  • @Diego if I’m not mistaken when you declare memoryStr it is possible to determine a path, like: var memoryStr = new Memorystream("C: Pasta_a"). I don’t remember and I don’t work at the company where I did the code. :/

1 answer

10


You are the one who generates the shipment file, at the time of generating it is set sets the path that will save the file.

See the example of a complete shipment file generation (from Bradesco bank, but the only thing that changes from one bank to another are the fields' business rules).

var objCedente = new Cedente("12345678000155", "TESTE", "1111", "11234", "1");
objCEDENTE.Codigo = "123456";
objCEDENTE.Convenio = 9;

//Instância de Boleto
var objBOLETO = new Boleto();
objBOLETO.EspecieDocumento = new EspecieDocumento(237,"12");
objBOLETO.DataVencimento = DateTime.Now.AddDays(10);
objBOLETO.ValorBoleto = 90;
objBOLETO.Carteira ="09";
objBOLETO.NossoNumero = ("00000012345");
objBOLETO.Cedente = objCEDENTE;
objBOLETO.NumeroDocumento = "1234567890";
objBOLETO.DataDocumento = DateTime.Now;
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;

Boletos objBOLETOS = new Boletos();
objBOLETOS.Add(objBOLETO);

var memoryStr = new MemoryStream();
var objREMESSA = new ArquivoRemessa(TipoArquivo.CNAB400);
objREMESSA.GerarArquivoRemessa("09", new Banco(237), objCEDENTE, objBOLETOS, memoryStr, 1000);
  • Okay, thank you very much. In this example you wrote you didn’t define the place where the boleto is being saved, correct? This location I define in some configuration?

  • jbuneo I tested your code with the boleto.net project and could not generate the file.

  • I managed to fix the error. Before asking to generate the shipment file, you must validate the ticket.

  • @If the jbueno’s answer answered your question mark it as "accept".

  • I generated the boleto txt (shipment file) from the memory stream reading.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.