4
I have a system that generates Santander billets using a specific DLL that was downloaded from the internet. The name is "Boleto.net". I need to create a Bradesco ticket. I changed where I passed the data from Santander to the data from Bradesco, but at the time of generating the receipt of an error saying that the value was not passed to a specific object. What the TipoArquivo
of Bradesco to pass the validation in the boleto?
public BoletoBancario GerarBoletoBradesco(BoletoModel bol)
{
BoletoBancario boletoBancario = new BoletoBancario();
boletoBancario.CodigoBanco = 237;
ContaBancaria cb = new ContaBancaria();
cb.Agencia = bol.cedente.Agencia;
if (bol.cedente.DigAgencia != "")
cb.DigitoAgencia = bol.cedente.DigAgencia;
cb.Conta = bol.cedente.Conta;
if (bol.cedente.DigConta != "")
cb.DigitoConta = bol.cedente.DigConta;
Cedente c = new Cedente();
c.CPFCNPJ = bol.cedente.CNPJ;
c.Nome = bol.cedente.Nome;
c.Carteira = bol.Carteira;
c.ContaBancaria = cb;
c.Codigo = bol.cedente.Codigo;
if (bol.cedente.DigCedente != "")
c.DigitoCedente = int.Parse(bol.cedente.DigCedente);
//Até o momento o Convênio é o mesmo número do código do cedente
c.Convenio = int.Parse(c.Codigo);
BoletoNet.Boleto b = new BoletoNet.Boleto(bol.DataVencimento, bol.ValorBoleto, bol.Carteira,
bol.NossoNumero, c);
b.NumeroDocumento = bol.NumeroDocumento;
b.DataProcessamento = DateTime.Now.Date;
b.DataDocumento = bol.DataDocumento;
b.JurosMora = bol.ValorMulta;
BoletoNet.Endereco end = new BoletoNet.Endereco();
end.Bairro = "";
end.End = bol.sacado.Endereco;
end.CEP = bol.sacado.CEP;
end.Cidade = bol.sacado.Cidade;
end.Complemento = "";
end.Email = "";
end.Logradouro = "";
end.Numero = "";
end.UF = bol.sacado.UF;
BoletoNet.Sacado s = new BoletoNet.Sacado(bol.sacado.CNPJCPF, bol.sacado.Nome, end);
b.Sacado = s;
//Aqui passa o codigo do banco bradesco
//b.EspecieDocumento = new EspecieDocumento_Santander("17");
b.EspecieDocumento = new EspecieDocumento_Bradesco("13");
Instrucao objInst1 = new Instrucao(237);
objInst1.Descricao = bol.infAdicional.Instrucao1;
Instrucao objInst2 = new Instrucao(237);
objInst2.Descricao = bol.infAdicional.Instrucao2;
Instrucao objInst3 = new Instrucao(237);
objInst3.Descricao = bol.infAdicional.Instrucao3;
Instrucao objInst4 = new Instrucao(237);
objInst4.Descricao = bol.infAdicional.Instrucao4;
b.Instrucoes.Add(objInst1);
b.Instrucoes.Add(objInst2);
b.Instrucoes.Add(objInst3);
b.Instrucoes.Add(objInst4);
//Importante para o calculo do digito verificador
//b.PercentualIOS = 0;
boletoBancario.Boleto = b;
boletoBancario.MostrarCodigoCarteira = true;
boletoBancario.Boleto.Valida();
return boletoBancario;
}
public ActionResult GeraRemessa()
{
BoletoNet.Boletos lb = new BoletoNet.Boletos();
BoletoNet.Cedente cd = new BoletoNet.Cedente();
foreach (var item in listaBoletos)
{
Boleto bol = new Boleto();
BoletoNet.BoletoBancario bolBanc = new BoletoNet.BoletoBancario();
//bolBanc = bol.GerarBoleto(RetornarItemList(item.NumeroDocumento));
bolBanc = bol.GerarBoletoBradesco(RetornarItemList(item.NumeroDocumento));
cd = bolBanc.Cedente;
lb.Add(bolBanc.Boleto);
break;
}
System.IO.FileStream arq = new System.IO.FileStream("C:\\Temp\\arqRemessa.txt", System.IO.FileMode.Append);
cd.Endereco = new BoletoNet.Endereco
{
Bairro = "Teste",
CEP = "02764-020",
Cidade = "São Paulo",
End = "Teste end",
Logradouro = "Rua",
Numero= "4",
UF= "SP"
};
BoletoNet.ArquivoRemessa arqRem = new BoletoNet.ArquivoRemessa(BoletoNet.TipoArquivo.Outro);
arqRem.GerarArquivoRemessa("3480291", new BoletoNet.Banco(237), cd, lb,
arq, 1);
return View("/home/index");
}
public ActionResult ImprimirBoleto(string Fatura, string NovaDtVenc = "")
{
Boleto bol = new Boleto();
BoletoNet.BoletoBancario bolBanc = new BoletoNet.BoletoBancario();
bolBanc = bol.GerarBoletoBradesco(RetornarItemList(Fatura));
if (NovaDtVenc != "")
{
bolBanc.Boleto.DataVencimento = DateTime.Parse(NovaDtVenc);
bolBanc.Boleto.DataDocumento = DateTime.Now;
}
//HTML que monta o boleto.
// Aqui dá o erro falando que não foi passado o valor pro objeto BoletoNet.Conta
var htmlBoleto = bolBanc.MontaHtml(Server.MapPath(@"~/Content/Boletos/"), "");
htmlBoleto = htmlBoleto
.Replace(Request.ServerVariables["APPL_PHYSICAL_PATH"], "\\") // convertendo o caminho absoluto para relativo
.Replace(System.IO.Path.GetTempPath(), Url.Action("Temporario", "Faturas") + "/?filename=") // convertendo o caminho temporário em relativo
.Replace(".w666{width:666px}", ".w666{width:21cm}")
.Replace("<body>", "<body style=\"height:29cm\">")
//.Replace("</html>", "<a length=\"0\" href=\"/Faturas/PrintBoleto?Fatura=subsFatura\" >Exportar PDF</a></html>")
.Replace("</html>", "<a length=\"0\" href=\"#\" onclick=\"window.print();\">Imprimir/Exportar PDF</a></html>")
.Replace("subsFatura", Fatura.Replace("/","%2F"))
//.Replace("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">", "")
//.Replace("Imprimir em impressora jato de tinta (ink jet) ou laser em qualidade normal. (Não use modo econômico).<br>Utilize folha A4 (210 x 297 mm) ou Carta (216 x 279 mm) - Corte na linha indicada<br>","")
//.Replace(" ","")
;
ViewBag.Boleto = htmlBoleto.ToString();
return View();
}
Dude, this is not the best place to ask specific questions about
boleto.net
. But anyway, there is a project with only examples in https://github.com/BoletoNet I hope it helps you– Jéf Bueno
Enter your code, give more subsidies so we can help. Ah, I know there’s nothing better ready available, but that code is well done.
– Maniero
I’m on @Jéfersonbueno, is that guy I went to do a simple thing and complicated rs. I have this error of an object that talks that is not being passed but actually I have passed value to this object.
– AndreeH
@Andreeh put the code to try to help. By the way, you downloaded the dll from somewhere or are using the nuget?
– Jéf Bueno
@Mustache, puts is just making a mistake when it comes to riding the billet. This code was another person who did, I just need to change where today passes data from Santander to Bradesco.
– AndreeH
@Jéfersonbueno, this code was already done, I took to change the boleto de santander to Bradesco and from what I saw, was downloaded from the net this dll.
– AndreeH
If you cannot give us information to help your question will be considered unclear and will be closed. Repeating the same thing doesn’t help anyone, giving relevant information helps. We can’t guess what your problem is without seeing what you’re doing.
– Maniero
@bigown, I put the code that passes when I have the boleto printed.
– AndreeH
What error happens? Where? Give details.
– Maniero
@bigown error "The description for the Boletonet.Banco bank was not implemented.". In the "Imprimirboleto" method at the time of montarHtml of this error. But I implemented this object.
– AndreeH