Exemplo n.º 1
0
 public void Verify(PessoaJuridica item)
 {
     if (!CNPJ.Validar(item.NumCNPJ))
     {
         var msg = string.Format(Descricoes.MSG022, "CNPJ");
         throw new CoreException(msg, CoreExceptionType.Alert);
     }
 }
Exemplo n.º 2
0
        public void CNPJ_Infraestrutura_Validar_NumeroPequeno_Falha()
        {
            CNPJ cnpj = new CNPJ();

            cnpj.NumeroComPontuacao = "35253445";
            Action resultado = () => cnpj.Validar();

            resultado.Should().Throw <ExcecaoCNPJNaoPossuiQuatorzeNumeros>();
        }
Exemplo n.º 3
0
 public static bool DefinirCNPJPessoaJuridicaScopeEhValido(this PessoaJuridica pessoaJuridica, CNPJ cnpj)
 {
     return(AssertionConcern.IsSatisfiedBy
            (
                AssertionConcern.AssertFixedLength(cnpj.Codigo, CNPJ.ValorMaxCnpj, ErrorMessage.CNPJTamanhoInvalido),
                AssertionConcern.AssertNotNullOrEmpty(cnpj.Codigo, ErrorMessage.CNPJObrigatorio),
                AssertionConcern.AssertTrue(CNPJ.Validar(cnpj.Codigo), ErrorMessage.CNPJInvalido)
            ));
 }
Exemplo n.º 4
0
        public void CNPJ_Infraestrutura_Validar_ObterDigitoVerificador_Sucesso()
        {
            CNPJ cnpj = new CNPJ();

            cnpj.NumeroComPontuacao = "11.222.333/0001-81";

            Action resultado = () => cnpj.Validar();

            resultado.Should().NotThrow <Exception>();
        }
Exemplo n.º 5
0
        public void CNPJ_Infraestrutura_Validar_NumeroInvalido_Falha()
        {
            CNPJ cnpj = new CNPJ();

            cnpj.NumeroComPontuacao = "00.000.000/0000-45";

            Action resultado = () => cnpj.Validar();

            resultado.Should().Throw <ExcecaoNumeroCNPJInvalido>();
        }
Exemplo n.º 6
0
        public void CNPJ_Infraestrutura_Validar_Sucesso()
        {
            CNPJ cnpj = new CNPJ();

            cnpj.NumeroComPontuacao = "99.327.235/0001-50";

            Action resultado = () => cnpj.Validar();

            resultado.Should().NotThrow <Exception>();
            cnpj.Numero.Should().Be("99327235000150");
            cnpj.NumeroComPontuacao.Should().Be("99.327.235/0001-50");
        }
Exemplo n.º 7
0
        private bool AtribuirCnpj(string cnpjNumero)
        {
            var cnpj = new CNPJ(cnpjNumero);

            if (!cnpj.Validar())
            {
                RuleFor(c => c.Cnpj)
                .Equal(c => c.Cnpj).WithMessage("O número do CNPJ é Inválido");
                return(false);
            }
            else
            {
                Cnpj = cnpj.Numero;
            }
            return(true);
        }
        protected override ValidationResult IsValid(
            object value,
            ValidationContext validationContext)
        {
            if (value != null)
            {
                var cnpj = value.ToString().Replace(".", "").Replace("/", "").Replace("-", "");

                if (!CNPJ.Validar(cnpj))
                {
                    return(new ValidationResult(FormatErrorMessage(validationContext.DisplayName)));
                }
            }

            return(null);
        }
Exemplo n.º 9
0
        public void Verify(PessoaJuridica item)
        {
            if (!CNPJ.Validar(item.NumCNPJ))
            {
                var msg = string.Format(Descricoes.MSG022, "CNPJ");
                throw new CoreException(msg, CoreExceptionType.Alert);
            }

            var pj = DbConnection.PessoaJuridica
                     .Where(x => x.NumCNPJ == item.NumCNPJ &&
                            x.IdePessoaJuridica != item.IdePessoaJuridica)
                     .FirstOrDefault();

            if (pj != null)
            {
                throw new CoreException(Descricoes.MSG036, CoreExceptionType.Alert);
            }
        }
Exemplo n.º 10
0
        public override void Validar()
        {
            if (Endereco == null)
            {
                throw new ExcecaoEnderecoEmBranco();
            }

            Endereco.Validar();

            if (String.IsNullOrEmpty(NomeFantasia))
            {
                throw new ExcecaoNomeEmBranco();
            }


            if (CNPJ == null)
            {
                throw new ExcecaoCNPJInvalido();
            }

            CNPJ.Validar();

            if (String.IsNullOrEmpty(RazaoSocial))
            {
                throw new ExcecaoRazaoSocialInvalida();
            }

            if (String.IsNullOrEmpty(InscricaoEstadual))
            {
                throw new ExcecaoInscricaoEstadualInvalido();
            }

            if (String.IsNullOrEmpty(InscricaoMunicipal))
            {
                throw new ExcecaoInscricaoMunicipalInvalido();
            }
        }
 public bool IsSatisfiedBy(Transportadora transportadora)
 {
     return(CNPJ.Validar(transportadora.CNPJ));
 }
Exemplo n.º 12
0
 public bool IsSatisfiedBy(Agencia entity)
 {
     return(CNPJ.Validar(entity.CNPJ.Codigo));
 }
Exemplo n.º 13
0
 public void CPF_ValidarCPF_CnpjEhValido()
 {
     var numero = "81667443000132";
     var result = CNPJ.Validar(numero);
     Assert.True(result);
 }
Exemplo n.º 14
0
 public void CPF_ValidarCPF_CnpjInvalido()
 {
     var numero = "21857261000103";
     var result = CNPJ.Validar(numero);
     Assert.False(result);
 }
Exemplo n.º 15
0
        public virtual void Validar()
        {
            if (string.IsNullOrEmpty(NomeFantasia))
            {
                throw new ExcecaoEmitenteSemNome();
            }

            if (NomeFantasia.Length < 5)
            {
                throw new ExcecaoNomeEmitentePequeno();
            }

            if (string.IsNullOrEmpty(RazaoSocial))
            {
                throw new ExcecaoEmitenteSemRazaoSocial();
            }

            if (RazaoSocial.Length < 5)
            {
                throw new ExcecaoRazaoSocialEmitentePequeno();
            }

            if (CNPJ == null)
            {
                throw new ExcecaoEmitenteSemCNPJ();
            }

            if (string.IsNullOrEmpty(InscricaoEstadual))
            {
                throw new ExcecaoEmitenteSemInscricaoEstadual();
            }

            if (!InscricaoEstadual.All(char.IsDigit) && !InscricaoEstadual.Contains("."))
            {
                throw new ExcecaoInscricacaoEstadualEmitenteComLetras();
            }

            if (InscricaoEstadual.Length > 15)
            {
                throw new ExcecaoEmitenteComInscricaoEstadualAcimaDoLimite();
            }

            if (string.IsNullOrEmpty(InscricaoMunicipal))
            {
                throw new ExcecaoEmitenteSemInscricaoMunicipal();
            }

            if (!InscricaoMunicipal.All(char.IsDigit))
            {
                throw new ExcecaoInscricacaoMunicipalEmitenteComLetras();
            }

            if (Endereco == null)
            {
                throw new ExcecaoEmitenteSemEndereco();
            }

            CNPJ.Validar();

            Endereco.Validar();
        }