Example #1
0
        public override void Editar()
        {
            Devolucao v = new Devolucao(GUID);
            //fazer um dump dos itens do objeto
            DumpElement(v.Itens);
            v.Save();

            v.MotivoDevolucao = "Motivo editado, ele devolveu porque quis.";
            v.Voucher = new NFManual(v.Voucher.GUID);
            v.Itens.RemoveAt(0);
            v.Save();
        }
Example #2
0
        /// <summary>
        /// Procura o número do voucher e preenche o valor do mesmo ao ser pressionado o Enter no campo Código do Voucher
        /// </summary>
        /// <param name="sender">Objeto que disparou o evento</param>
        /// <param name="e">Argumento do evento gerado</param>
        private void txtVoucher_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((Keys)e.KeyChar == Keys.Enter)
            {
                string codVoucher = txtVoucher.Text;

                if (!String.IsNullOrEmpty(codVoucher))
                {
                    //Procura pelo número do voucher informado
                    IList<IDevolucao> devolucoes = new Devolucao().Find<IDevolucao>(new Where
                    {
                        { "fat_lan.eguid = @eguid", new Parameter
                            {
                                ParameterName = "@eguid",
                                Value = codVoucher
                            }
                        },
                        { "fat_lan.status = @status", new Parameter
                           {
                               ParameterName = "@status",
                               Value = (int)Enuns.Faturamento.Lancamento.Status.Aberto
                           }
                        }
                    });

                    if (devolucoes.Count > 0)
                    {
                        mnValor.Value = devolucoes.FirstOrDefault().ValorTotalLiquido;
                        mnValor.Enabled = false;
                        tbHistorico.Focus();
                    }
                    else
                    {
                        MessageBox.Show("Número do voucher não localizado, ou já recebido");
                        mnValor.Clear();
                        txtVoucher.Clear();
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// Pesquisa os voucher disponíveis
        /// </summary>
        /// <param name="sender">Objeto que disparou o evento</param>
        /// <param name="e">Argumento do evento gerado</param>
        private void btnPesquisar_Click(object sender, EventArgs e)
        {
            Where where = new Where();
            where.Add("fat_lan.status = @status",
                new Parameter
                {
                    ParameterName = "@status",
                    Value = (int)Enuns.Faturamento.Lancamento.Status.Aberto
                });

            IDevolucao devolucao = new Devolucao();

            //Procura somente os vouchers no qual o status está aberto
            SearchWindowResult result = SearchWindow.Show(devolucao, where);

            //Se encontrou carrega os valores do número e valor do voucher
            if (!result.GUID.IsNullOrEmpty())
            {
                devolucao = Data.Abstract.Faturamento.Lancamento.LancamentoBase.Create(result.GUID, false) as IDevolucao;

                txtVoucher.Text = devolucao.EGUID.ToString();
                mnValor.Value = devolucao.ValorTotalLiquido;
                mnValor.Enabled = false;
            }
        }
Example #4
0
        public void GerarDevolucaoNFe()
        {
            #region variáveis

            OpenPOS.Data.Faturamento.Lancamento.Movimento.NFe.NFe nfe = null;
            Devolucao devolucao = null;
            IList<ICliente> clientes = new Cliente().Find<ICliente>(new Where() {
                    { "cad_Pessoa.nomefantasia", "NF-E EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM               "}
            });

            if (clientes.Count == 0)
                throw new Exception();

            #endregion

            #region Emitir a nfe

            nfe = new OpenPOS.Data.Faturamento.Lancamento.Movimento.NFe.NFe();
            nfe.QuantidadeVolume = 3;
            nfe.DadoPessoa = new DadoPessoa
            {
                Cliente = clientes[0]
            };

            nfe.Emitente = IndicadorProducao.Proprio;
            nfe.Situacao = SituacaoNotaFiscal.Normal;
            nfe.TabelaPreco = new OpenPOS.Data.Cadastro.TabelaPreco.TabelaPreco().Find<Model.Cadastro.TabelaPreco.ITabelaPreco>(new Where { Limit = new Limit(1) })[0];
            nfe.StatusNF = Status.LoteEmProcessamento;
            nfe.Motivo = "Teste";
            nfe.Chave = "12345678";
            nfe.InfProt = "123456";
            nfe.Modelo = "55";
            nfe.Serie = new OpenPOS.Data.Faturamento.Cadastro.Serie().Find<Model.Faturamento.Cadastro.ISerie>(new Where() { { "fat_Serie.Modelo = '55'"} })[0];
            nfe.InformacoesAdicionais.Add(new InfAdic() { Tipo = Enuns.Faturamento.Lancamento.Movimento.NF.InfCplTipo.Contribuinte, Campo = "Teste de CRUD" });
            nfe.InformacoesAdicionais.Add(new InfAdic() { Tipo = Enuns.Faturamento.Lancamento.Movimento.NF.InfCplTipo.ObsContribuinte, Campo = "Teste de CRUD Obs" });

            ITabelaPreco tabela = OpenPOS.Settings.TabelaPrecoPadrao;

            nfe.Itens.Add(new OpenPOS.Data.Faturamento.Lancamento.Movimento.Item.NFe.Item
            {
                Quantidade = 25,
                ValorUnitarioBruto = 15,
                DescricaoNF = "Produto de teste um",
                ItemMovimentado = tabela.Itens[0].Item,
                Conferido = true,
                TabelaPreco = tabela,
                InformacaoAdicional = "Informações adicionais dos produtos, mercadorias e serviços"
            });
            nfe.SaveTemp();

            #endregion

            #region enviar e autorizar a nfe

            string fileName = nfe.Chave + "-nfe.xml";
            string filePath = Path.Combine(OpenPOS.Settings.NFe.PastaEnvio, fileName);
            ((NFe.IGenerateNFe)nfe).GenerateXML().Save(filePath);

            OpenPOS.NFe.NFeResult result = ((OpenPOS.Data.Abstract.Faturamento.Lancamento.Movimento.NF.NFBase)nfe).ProcessaResposta();
            if (result.Success)
            {
                nfe.StatusNF = result.Status;
                nfe.Chave = result.Chave;
                nfe.InfProt = result.Protocolo;
                nfe.Motivo = result.Motivo;
                nfe.Save();
                MessageBox.Show(result.Motivo);
            }
            else
                nfe.Save();

            #endregion

            #region Emitir a devolução

            devolucao = new Devolucao();
            devolucao.MotivoDevolucao = "Não gostou da cor e com defeito";
            devolucao.Voucher = nfe;
            devolucao.TabelaPreco = new OpenPOS.Data.Cadastro.TabelaPreco.TabelaPreco().Find<OpenPOS.Model.Cadastro.TabelaPreco.ITabelaPreco>(new Where { Limit = new Limit(1) })[0];

            foreach (OpenPOS.Model.Faturamento.Lancamento.Movimento.Item.NF.IItem item in nfe.Itens)
            {
                Model.Faturamento.Lancamento.Movimento.Item.Devolucao.IDevolucaoItem i =
                    new OpenPOS.Data.Faturamento.Lancamento.Movimento.Item.Devolucao.Item()
                    {
                        ItemMovimentado = item.ItemMovimentado,
                        Quantidade = item.Quantidade,
                        ValorUnitarioBruto = item.ValorUnitarioBruto,
                        DescricaoNF = item.DescricaoNF,
                        MotivoDevolucao = "Com defeito",
                        QuantidadeDevol = item.Quantidade,
                        EstadoItem = Enuns.Faturamento.Lancamento.Movimento.Devolucao.EstadoItem.Defeito,
                        TabelaPreco = item.TabelaPreco
                    };
                devolucao.Itens.Add(i);
            }

            GUID = devolucao.SaveTemp();

            #endregion

            #region enviar e autorizar a devolução

            fileName = devolucao.Chave + "-nfe.xml";
            filePath = Path.Combine(OpenPOS.Settings.NFe.PastaEnvio, fileName);
            ((NFe.IGenerateNFe)devolucao).GenerateXML().Save(filePath);

            result = ((OpenPOS.Data.Abstract.Faturamento.Lancamento.Movimento.NF.NFBase)devolucao).ProcessaResposta();
            if (result.Success)
            {
                devolucao.StatusNF = result.Status;
                devolucao.Chave = result.Chave;
                devolucao.InfProt = result.Protocolo;
                devolucao.Motivo = result.Motivo;
                devolucao.Save();
                MessageBox.Show("NF-e Devolução: " + result.Motivo);
            }
            #endregion
        }
Example #5
0
 public override void Popular()
 {
     Devolucao v = new Devolucao(GUID);
     DumpElement(v);
 }
Example #6
0
        public override void Gravar()
        {
            Devolucao devolucao = new Devolucao();
            NFManualTest nfTest = new NFManualTest();
            nfTest.Gravar();
            NFManual nf = new NFManual(nfTest.GUID);

            devolucao.MotivoDevolucao = "Não gostou da cor e com defeito";
            devolucao.Voucher = nf;
            devolucao.TabelaPreco = new OpenPOS.Data.Cadastro.TabelaPreco.TabelaPreco().Find<OpenPOS.Model.Cadastro.TabelaPreco.ITabelaPreco>(new Where { Limit = new Limit(1) })[0];

            foreach (OpenPOS.Model.Faturamento.Lancamento.Movimento.Item.NF.IItem item in nf.Itens)
            {
                Model.Faturamento.Lancamento.Movimento.Item.Devolucao.IDevolucaoItem i =
                    new OpenPOS.Data.Faturamento.Lancamento.Movimento.Item.Devolucao.Item()
                {
                    ItemMovimentado = item.ItemMovimentado,
                    Quantidade = item.Quantidade,
                    ValorUnitarioBruto = item.ValorUnitarioBruto,
                    DescricaoNF = item.DescricaoNF,
                    MotivoDevolucao = "Com defeito",
                    QuantidadeDevol = item.Quantidade,
                    EstadoItem = Enuns.Faturamento.Lancamento.Movimento.Devolucao.EstadoItem.Defeito,
                    TabelaPreco = item.TabelaPreco
                };
                devolucao.Itens.Add(i);
            }

            GUID = devolucao.Save();
        }
Example #7
0
 /// <summary>
 /// Validações quando informa o número do voucher
 /// </summary>
 /// <param name="sender">Objeto que disparou o evento</param>
 /// <param name="e">Argumento do evento gerado</param>
 private void txtNSU_Leave(object sender, EventArgs e)
 {
     Wait.Show();
     IDevolucao devol = null;
     if (Tipo == TipoForma.Voucher)
     {
         IList<IDevolucao> devolucoes = new Devolucao().Find<IDevolucao>(new Where() { { "fat_LanMov.EGUID", Voucher } }).ToList();
         if (devolucoes.Count > 0)
         {
             devol = devolucoes[0] as IDevolucao;
             if (devol.Status != Enuns.Faturamento.Lancamento.Status.VoucherRecebido)
             {
                 maskValorRecebido.Value = devol.ValorTotalLiquido;
                 btnOK.Focus();
             }
             else
             {
                 MessageBox.ShowWarning("O Voucher informado já foi devolvido");
                 txtNSU.Focus();
             }
         }
     }
     Wait.Close();
 }