Ejemplo n.º 1
0
        private Boleto CriarRetornoBoleto(XDocument xml)
        {
            var codigoBanco    = xml.Descendants("codBanco")?.FirstOrDefault()?.Value;
            var codigoConvenio = xml.Descendants("codConv")?.FirstOrDefault()?.Value;

            var convenio = new Convenio(int.Parse(codigoBanco), int.Parse(codigoConvenio));

            #region Pagador

            var tipoDocumento   = int.Parse(xml.Descendants("tpDoc")?.FirstOrDefault()?.Value);
            var numeroDocumento = xml.Descendants("numDoc")?.FirstOrDefault()?.Value;
            var nome            = xml.Descendants("nome")?.FirstOrDefault()?.Value;
            var endereco        = xml.Descendants("ender")?.FirstOrDefault()?.Value;
            var bairro          = xml.Descendants("bairro")?.FirstOrDefault()?.Value;
            var cidade          = xml.Descendants("cidade")?.FirstOrDefault()?.Value;
            var uf  = xml.Descendants("uf")?.FirstOrDefault()?.Value;
            var cep = xml.Descendants("cep")?.FirstOrDefault()?.Value;

            if (tipoDocumento == 1)
            {
                numeroDocumento = numeroDocumento?.Substring(4, 11);
            }

            #endregion

            #region Titulo

            var dataEmissao        = StringParaData(xml.Descendants("dtEmissao")?.FirstOrDefault()?.Value);
            var dataLimiteDesconto = StringParaData(xml.Descendants("dtLimiDesc")?.FirstOrDefault()?.Value);
            var dataVencimento     = StringParaData(xml.Descendants("dtVencto")?.FirstOrDefault()?.Value);
            var especie            = (Especie)int.Parse(xml.Descendants("especie")?.FirstOrDefault()?.Value);
            var nossoNumero        = xml.Descendants("nossoNumero")?.FirstOrDefault()?.Value;
            var juros         = StringParaDouble(xml.Descendants("pcJuro")?.FirstOrDefault()?.Value);
            var multa         = StringParaDouble(xml.Descendants("pcMulta")?.FirstOrDefault()?.Value);
            var baixarApos    = int.Parse(xml.Descendants("qtDiasBaixa")?.FirstOrDefault()?.Value);
            var multaApos     = int.Parse(xml.Descendants("qtDiasMulta")?.FirstOrDefault()?.Value);
            var protestarApos = int.Parse(xml.Descendants("qtDiasProtesto")?.FirstOrDefault()?.Value);
            var quantidadePagamentosPossiveis = int.Parse(xml.Descendants("qtdParciais")?.FirstOrDefault()?.Value);
            var seuNumero        = xml.Descendants("seuNumero")?.FirstOrDefault()?.Value;
            var tipoPagamento    = (TipoPagamento)int.Parse(xml.Descendants("tipoPagto")?.FirstOrDefault()?.Value);
            var tipoValor        = (TipoValor)int.Parse(xml.Descendants("tipoValor")?.FirstOrDefault()?.Value);
            var tipoDesconto     = (TipoDesconto)int.Parse(xml.Descendants("tpDesc")?.FirstOrDefault()?.Value);
            var tipoProtesto     = (TipoProtesto)int.Parse(xml.Descendants("tpProtesto")?.FirstOrDefault()?.Value);
            var percentualMaximo = StringParaDouble(xml.Descendants("valorMaximo")?.FirstOrDefault()?.Value);
            var percentualMinimo = StringParaDouble(xml.Descendants("valorMinimo")?.FirstOrDefault()?.Value);
            var valorAbatimento  = StringParaDouble(xml.Descendants("vlAbatimento")?.FirstOrDefault()?.Value);
            var valorDesconto    = StringParaDouble(xml.Descendants("vlDesc")?.FirstOrDefault()?.Value);
            var valor            = StringParaDouble(xml.Descendants("vlNominal")?.FirstOrDefault()?.Value);

            #endregion

            var pagador    = new Pagador(numeroDocumento, nome, endereco, bairro, cidade, uf, cep);
            var instrucoes = new InstrucoesDoTitulo(multa, multaApos, juros, tipoDesconto, valorDesconto, dataLimiteDesconto, valorAbatimento, tipoProtesto, protestarApos, baixarApos, tipoPagamento, quantidadePagamentosPossiveis, tipoValor, percentualMinimo, percentualMaximo);
            var titulo     = new Titulo(valor, especie, nossoNumero, seuNumero, dataVencimento.Value, dataEmissao.Value, "", instrucoes, false);

            return(new Boleto(convenio, pagador, titulo));
        }
Ejemplo n.º 2
0
        public Titulo(double valor, Especie especie, string nossoNumero, string seuNumero, DateTime dataVencimento,
                      DateTime dataEmissao, InstrucoesDoTitulo instrucoesDoTitulo, bool digitoVerificador = true)
        {
            Valor              = valor;
            Especie            = especie;
            NossoNumero        = nossoNumero + (digitoVerificador ? CalcularDigitoVerificador(nossoNumero).ToString() : "");
            SeuNumero          = seuNumero;
            DataVencimento     = dataVencimento;
            DataEmissao        = dataEmissao;
            InstrucoesDoTitulo = instrucoesDoTitulo;

            Validar();
        }