Boleto.Net Component Generating Wrong Code

Asked

Viewed 1,197 times

0

I am working with the boleto.net library, I am generating billets from the bank of Brazil and I am experiencing the following problem.

I am generating the billet but the barcode of the billet is coming with the end, where would be the area of MATURITY FACTOR + VALUE OF BILLET wrong.

Below code returned from the property Boletobancario.Boleto.Codigobarra.Codigo 00196.88472 32677.473001 00000.085183 1 550000000002

Below code returned from the property Boletobancario.Boleto.Codigobarra.Linhadigitavelformatada 00190.00009 02688.473269 77473.0000000085187 1 67830000055000

If you look at the codes above, if you take the final stretch(550000000002) of the first and insert the end of the second code(67830000055000) the billet is generated correctly.

string convenio = "2677473";

var contaBancaria = new ContaBancaria()
                {
                    Agencia = "4175",
                    DigitoAgencia = "2",
                    Conta = "6141",
                    DigitoConta = "5",
                    OperacaConta = "019"
                };

var cedente = new Cedente()
                {
                    Codigo = convenio, //ced.ID.ToString().PadLeft(7, '0'),
                    //Convenio = Convert.ToInt32(convenio),
                    CPFCNPJ = ced.CPF_CNPJ,
                    Nome = ced.RAZAO_SOCIAL.ToUpper(),
                    ContaBancaria = contaBancaria                  
                };

var sacado = new Sacado()
                {
                    CPFCNPJ = "",
                    Nome = "",
                    Endereco = new Endereco()
                    {
                        End = "",
                        Bairro = "",
                        Cidade = "",
                        UF = "",
                        CEP = ""
                    }
                };

var boleto = new Boleto()
                {                
                    ContaBancaria = contaBancaria,
                    DataVencimento = "2016-05-03",
                    ValorBoleto = "550.00",
                    NossoNumero = "26774730000000085",
                    NumeroDocumento = "0000000085",
                    Carteira = "18",
                    Cedente = cedente,
                    Sacado = sacado,
                    EspecieDocumento = new EspecieDocumento_BancoBrasil("4"),                    
                    LocalPagamento = "QUALQUER BANCO",
                    Instrucoes = new List<IInstrucao>() { new Instrucao_BancoBrasil() { Descricao = "" } },
                };

var boleto_bancario = new BoletoBancario()
                {
                    CodigoBanco = 001,
                    Boleto = boleto,
                    MostrarCodigoCarteira = false,
                    MostrarComprovanteEntrega = false
                };

boleto_bancario.Boleto.Valida();

boleto_bancario.MontaHtmlEmbedded();

These are the data that are filled in, there would be something wrong or that is missing?

1 answer

1

I was looking at the barcode source code here...

https://github.com/BoletoNet/boletonet/blob/master/src/Boleto.Net/Boleto/CodigoBarra.cs

Apparently the free camp is misinformed.

When you ask for the formatted line, it calculates so without the free field. So it works. When you ask for only the property Codigo, it formats the string with the free field at the end.

Tip: runs with the most current Boletonet source, it may be a bug already solved. If you’re sure your code is all right, assemble a minimal case and opens a hole.

  • Thanks Renan for the force! Look, I believe you’re right yes but I will open a vent to see that question.

  • Good morning Renan, Thanks for the help and the links you sent! I think I found the problem, I changed the wallet values and our number and ended up generating the barcode correctly! 00190.00009 02677.473269 88473.098189 1 67900000001000 I was concatenating our number + the covenant code and this was generating a number above the 17 positions which is correct. Because of this, the code was breaking and that’s why it misgenerated the barcode. Thanks for the help!

Browser other questions tagged

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