Пример #1
0
        public void FakePisIsValid()
        {
            var doc = new Pis();

            doc.GerarFake();
            Assert.IsTrue(doc.DocumentoValido());
        }
Пример #2
0
        private List <SqlParametros> PreencheCondicoes(Pis pis)
        {
            List <SqlParametros> lstParametrosCondicionais = new List <SqlParametros>();

            lstParametrosCondicionais.Add(new SqlParametros("PisId", pis.PisId));

            return(lstParametrosCondicionais);
        }
Пример #3
0
 public static bool DefinirDescricaoPisScopeEhValido(this Pis pis, string descricao)
 {
     return(AssertionConcern.IsSatisfiedBy
            (
                AssertionConcern.AssertNotNullOrEmpty(descricao, ErrorMessage.DescricaoObrigatorio),
                AssertionConcern.AssertLength(descricao, Pis.DescricaoMinLength, Pis.DescricaoMaxLength, ErrorMessage.DescricaoTamanhoInvalido)
            ));
 }
Пример #4
0
        public void QuandoForCalculadoOValorDePis()
        {
            var pis = new Pis();

            pis = (Pis)pis.ObterPis(_valorDaOperacao);
            pis.CalcularValorDeImposto();

            _valorDePisCalculado = pis.ValorApurado;
        }
Пример #5
0
        private List <SqlParametros> PreencheParametros(Pis pis)
        {
            List <SqlParametros> lstParametros = new List <SqlParametros>();

            lstParametros.Add(new SqlParametros("PisCst", pis.PisCst));
            lstParametros.Add(new SqlParametros("Descricao", pis.Descricao));
            lstParametros.Add(new SqlParametros("Tipo", pis.Tipo));

            return(lstParametros);
        }
Пример #6
0
        public static void DecoratorImpostos()
        {
            Orcamento  orcamento = new Orcamento(5000d);
            ClsImposto pis       = new Pis(new Acpp(new TaxVeryHigh(new Ikcv(new ICPP()))));

            double valor = pis.Calcula(orcamento);

            Console.WriteLine(valor);
            Console.ReadKey();
        }
Пример #7
0
 public NFeDetImposto()
 {
     Ipi        = new Ipi();
     II         = new II();
     Pis        = new Pis();
     PisSt      = new PisSt();
     Cofins     = new Cofins();
     CofinsSt   = new CofinsSt();
     IcmsUfDest = new IcmsUfDest();
 }
Пример #8
0
        public void Pis_DeveSerValido_True(string numeroPis)
        {
            // Arrange
            Pis pis;

            // Act
            pis = Pis.Factory(numeroPis);

            // Assert
            Assert.NotNull(pis);
            Assert.True(pis.EstaValido());
        }
Пример #9
0
        public void Pis_QuandoPisSaoDiferentes_DeveGerarHashCodeDiferentes()
        {
            // Arrange
            Pis pis1 = Pis.Factory("108.558.158-57");
            Pis pis2 = Pis.Factory("120.844.879-53");

            // Act
            var hashcode1 = pis1.GetHashCode();
            var hashcode2 = pis2.GetHashCode();

            // Assert
            Assert.NotEqual(hashcode1, hashcode2);
        }
Пример #10
0
        public void Pis_QuandoPisSaoIguais_DeveGerarMesmoHashCode()
        {
            // Arrange
            Pis pis1 = Pis.Factory("108.558.158-57");
            Pis pis2 = Pis.Factory("108.558.158-57");

            // Act
            var hashcode1 = pis1.GetHashCode();
            var hashcode2 = pis2.GetHashCode();

            // Assert
            Assert.Equal(hashcode1, hashcode2);
        }
Пример #11
0
        public void Pis_DeveFormatarCorretamente()
        {
            // Arrange
            string numeroPisEsperado = "108.558.158-57";
            Pis    pis;

            pis = Pis.Factory(numeroPisEsperado);

            // Act
            string pisFormatado = pis.ToPisFormat();

            // Assert
            Assert.Equal(numeroPisEsperado, pisFormatado);
        }
Пример #12
0
        public void Pis_DeveSerDiferente_True()
        {
            // Arrange
            Pis pis1;
            Pis pis2;
            Pis pis3;

            // Act
            pis1 = Pis.Factory("108.558.158-57");
            pis2 = Pis.Factory("120.844.879-53");
            pis3 = pis1;

            // Assert
            Assert.True(pis1 != pis2);
            Assert.True(pis2 != pis3);
        }
Пример #13
0
        public void Pis_DeveSerIgual_True()
        {
            // Arrange
            Pis pis1;
            Pis pis2;
            Pis pis3;

            // Act
            pis1 = Pis.Factory("108.558.158-57");
            pis2 = Pis.Factory("10855815857");
            pis3 = pis1;

            // Assert
            Assert.True(pis1 == pis2);
            Assert.True(pis2 == pis3);
        }
Пример #14
0
        private void EnviarCadastro(Rede rede, int Terminal, int Funcionario)
        {
            DB         db = new DB();
            List <int> FuncionariosAtualizados = new List <int>();

            GetDadosTerminal(Terminal, out IP, out PORTA, out TERMINALNOME);

            string Pis;

            SqlCommand comm = db.Conn.CreateCommand();

            comm.CommandText = "SELECT FUNC_NOME, FUNC_PIS, CRA_NUMERO " +
                               "FROM Funcionarios " +
                               "LEFT JOIN Crachas ON CRA_FUNC = FUNC_IND " +
                               "WHERE FUNC_IND = " + Funcionario + " " +
                               "ORDER BY FUNC_NOME";
            SqlDataReader reader = comm.ExecuteReader();

            while (reader.Read())
            {
                Pis = reader["FUNC_PIS"].ToString().Trim();

                if (Pis[0] == Convert.ToChar("0"))
                {
                    Pis = Pis.Substring(1);
                }

                if (Pis != string.Empty)
                {
                    if (EnviarFuncionario(
                            rede,
                            reader["CRA_NUMERO"].ToString().Trim(),
                            Pis,
                            string.Empty,
                            reader["FUNC_NOME"].ToString().Trim(),
                            Funcionario
                            ) == 0)
                    {
                        FuncionariosAtualizados.Add(Funcionario);
                    }
                }
            }

            reader.Close();

            db.Atualizar_TerminaisFuncionarios(Terminal, FuncionariosAtualizados);
        }
Пример #15
0
        private void EnviarCadastro(int Terminal, int Funcionario)
        {
            DB db = new DB();

            string IP;
            int    Porta;
            string TerminalNome;
            int    Senha;
            int    CartaoDigitos;

            GetDadosTerminal(Terminal, out IP, out Porta, out TerminalNome, out Senha, out CartaoDigitos);

            string Pis;

            SqlCommand comm = db.Conn.CreateCommand();

            comm.CommandText = "SELECT FUNC_NOME, FUNC_PIS, CRA_NUMERO " +
                               "FROM Funcionarios " +
                               "LEFT JOIN Crachas ON CRA_FUNC = FUNC_IND " +
                               "WHERE FUNC_IND = " + Funcionario + " " +
                               "ORDER BY FUNC_NOME";
            SqlDataReader reader = comm.ExecuteReader();

            while (reader.Read())
            {
                Pis = reader["FUNC_PIS"].ToString().Trim();

                if (Pis[0] == Convert.ToChar("0"))
                {
                    Pis = Pis.Substring(1);
                }

                if (Pis != string.Empty)
                {
                    EnviarFuncionario(
                        Terminal,
                        IP, Porta, Senha,
                        reader["CRA_NUMERO"].ToString().PadLeft(CartaoDigitos, '0'),
                        Pis,
                        reader["FUNC_NOME"].ToString().Trim(),
                        Convert.ToInt32(Funcionario)
                        );
                }
            }
        }
Пример #16
0
 protected override ValidationResult IsValid(object value, ValidationContext validationContext)
 {
     return(value == null || Pis.Validar(value.ToString()) ? ValidationResult.Success : new ValidationResult("PIS em formato inválido"));
 }
Пример #17
0
 public void Adicionar(Pis pis)
 {
     _context.Pises.Add(pis);
 }
 public static bool IsPIS(this string text)
 {
     return(Pis.Validate(text));
 }
Пример #19
0
 public Boolean Excluir(Pis pis)
 {
     return(conexao.Excluir(nomeTabela, PreencheCondicoes(pis)));
 }
Пример #20
0
 public void Atualizar(Pis pis)
 {
     _context.Entry(pis).State = EntityState.Modified;
 }
Пример #21
0
        public void PisIsValid()
        {
            var doc = new Pis("657.59730.12-6");

            Assert.IsTrue(doc.DocumentoValido());
        }
Пример #22
0
 public Boolean Inserir(Pis pis)
 {
     return(conexao.Inserir(nomeTabela, PreencheParametros(pis)));
 }
Пример #23
0
        private PlugNotasApi Initialize(Invoice invoice)
        {
            var plugNotas = new PlugNotasApi();

            var address = invoice.Order.Customer.Adresses.Where(a => a.Type == AddressType.Billing).FirstOrDefault();

            plugNotas.IdIntegracao    = invoice.Id.ToString();
            plugNotas.Presencial      = true;
            plugNotas.ConsumidorFinal = true;
            plugNotas.Natureza        = invoice.OriginOperation;

            var issuer = new Emitente();

            issuer.CpfCnpj = _configuration["IssuerCnpj"];

            plugNotas.Emitente = issuer;

            var receiver = new Destinatario();

            receiver.CpfCnpj     = invoice.Order.Customer.Cnpj;
            receiver.RazaoSocial = invoice.Order.Customer.CompanyName;
            receiver.Email       = invoice.Order.Customer.Email;

            var receiverAddress = new Endereco();

            receiverAddress.Logradouro      = address.Street;
            receiverAddress.Numero          = address.Number.ToString();
            receiverAddress.Bairro          = address.Neighborhood;
            receiverAddress.CodigoCidade    = address.CodeCity;
            receiverAddress.DescricaoCidade = address.City;
            receiverAddress.Estado          = address.State;
            receiverAddress.Cep             = address.ZipCode;

            receiver.Endereco = receiverAddress;

            plugNotas.Destinatario = receiver;

            var itemsPlugNotas = new List <Iten>();

            foreach (var item in invoice.InvoiceLines)
            {
                var itemPlugNotas = new Iten();

                itemPlugNotas.Codigo    = item.ItemName;
                itemPlugNotas.Descricao = item.ItemName;
                itemPlugNotas.Ncm       = item.NcmCode;
                itemPlugNotas.Cfop      = "5101";

                var unitaryValue = new ValorUnitario();
                unitaryValue.Comercial      = (double)item.UnitaryPrice;
                unitaryValue.Tributavel     = (double)item.UnitaryPrice;
                itemPlugNotas.ValorUnitario = unitaryValue;

                var quantity = new Quantidade();
                quantity.Comercial       = item.Quantity;
                quantity.Tributavel      = item.Quantity;
                itemPlugNotas.Quantidade = quantity;

                var taxes = new Tributos();

                var icms = new Icms();
                icms.Origem = item.OriginIcms;
                icms.Cst    = item.CstIcms;
                var baseCalcIcms = new BaseCalculo();
                baseCalcIcms.ModalidadeDeterminacao = item.DeterminationMode;
                baseCalcIcms.Valor = (double)item.ValueBaseCalcIcms;
                icms.BaseCalculo   = baseCalcIcms;
                icms.Aliquota      = item.AliquotIcms;
                icms.Valor         = (double)item.ValueIcms;
                taxes.Icms         = icms;

                var pis = new Pis();
                pis.Cst = item.CstPis;
                var baseCalcPis = new BaseCalculo();
                baseCalcPis.Valor = (double)item.ValueBaseCalcPis;
                pis.BaseCalculo   = baseCalcPis;
                pis.Aliquota      = item.AliquotPis;
                pis.Valor         = (double)item.ValuePis;
                taxes.Pis         = pis;

                var cofins = new Cofins();
                cofins.Cst = item.CstCofins;
                var baseCalcCofins = new BaseCalculo();
                baseCalcCofins.Valor = (double)item.ValueBaseCalcCofins;
                cofins.BaseCalculo   = baseCalcCofins;
                cofins.Aliquota      = item.AliquotCofins;
                cofins.Valor         = (double)item.ValueCofins;
                taxes.Cofins         = cofins;

                itemPlugNotas.Tributos = taxes;

                itemsPlugNotas.Add(itemPlugNotas);
            }

            plugNotas.Itens = itemsPlugNotas;

            var payments = new List <Pagamento>();

            var payment = new Pagamento();

            payment.AVista = true;
            payment.Meio   = "18";
            payments.Add(payment);

            plugNotas.Pagamentos = payments;

            return(plugNotas);
        }
Пример #24
0
 public void Adicionar(Pis pis)
 {
     throw new NotImplementedException();
 }
Пример #25
0
 public void Atualizar(Pis pis)
 {
     throw new NotImplementedException();
 }
Пример #26
0
 public Boolean Alterar(Pis pis)
 {
     return(conexao.Atualizar(nomeTabela, PreencheParametros(pis), PreencheCondicoes(pis)));
 }
Пример #27
0
 public override int GetHashCode()
 {
     return(Pis.GetHashCode());
 }