Example #1
0
        public void AdicionarPagamento(Entity.TipoPagamento tipoPagamento, decimal valorDoPagamento)
        {
            if (VendaCorrente.ValorTotalVenda <= 0)
            {
                AdicionarMensagem("Venda com valor igual ou menor que zero.",
                                  EnumStatusDoResultado.RegraDeNegocioInvalida);
            }
            else
            {
                var vendaPagamento = new VendaPagamento
                {
                    CodigoVendaPagamento = GerarCodigoUnico(),
                    TipoPagamento_CodigoTipoPagamento = tipoPagamento.CodigoTipoPagamento,
                    Venda_CodigoVenda = VendaCorrente.CodigoVenda,
                    TipoPagamento     = tipoPagamento,
                    ValorPagamento    = valorDoPagamento
                };

                VendaCorrente.VendaPagamentoes.Add(vendaPagamento);
                VendaCorrente.ValorTotalRecebimento += valorDoPagamento - (tipoPagamento.PercentualDesconto / 100 * valorDoPagamento);
                VendaCorrente.DataRecebimento        = DateTime.Today.AddDays(tipoPagamento.DiasParaPagamento);

                if (VendaCorrente.VendaPagamentoes.Sum(x => x.ValorPagamento) - VendaCorrente.ValorTotalVenda < 0)
                {
                    VendaCorrente.ValorTroco = 0;
                }
                else
                {
                    VendaCorrente.ValorTroco            = VendaCorrente.VendaPagamentoes.Sum(x => x.ValorPagamento) - VendaCorrente.ValorTotalVenda;
                    VendaCorrente.ValorTotalRecebimento = VendaCorrente.ValorTotalRecebimento - VendaCorrente.ValorTroco;
                }
            }
        }
Example #2
0
        private string GerarXmlDetalhePagamento(VendaPagamento vendaPagamento)
        {
            var xml = $@"<MP>
                            <cMP>{RecuperarCodigoDoMeioDePagamento(vendaPagamento)}</cMP>
                            <vMP>{vendaPagamento.ValorPagamento.ToString("0.00", CultureInfo.InvariantCulture)}</vMP>
                        </MP>";

            return(xml);
        }
Example #3
0
        private string RecuperarCodigoDoMeioDePagamento(VendaPagamento vp)
        {
            //01 - Dinheiro 02 - Cheque 03 - Cartão de Crédito 04 - Cartão de Débito
            //    05 - Crédito Loja 10 - Vale Alimentação 11 - Vale Refeição
            //    12 - Vale Presente 13 - Vale Combustível
            switch (vp.TipoPagamento.Nome)
            {
            case "Dinheiro":
            {
                return("01");
            }

            case "Cheque":
            {
                return("02");
            }

            case "Débito Rede":
            {
                return("04");
            }

            case "Débito Moderninha":
            {
                return("04");
            }

            case "Crédito Rede":
            {
                return("03");
            }

            case "Crédito Moderninha":
            {
                return("03");
            }

            case "Ticket":
            {
                return("11");
            }
            }

            return("99");
        }
Example #4
0
        public void RemoverPagamentoDaVenda(VendaPagamento vendaPagamento)
        {
            VendaCorrente.VendaPagamentoes.Remove(vendaPagamento);
            var tipoPagamentoDoPagamento = _caixaAberto.TipoDoPagamento.ListaDeTiposDePagamento.FirstOrDefault(x => x.CodigoTipoPagamento == vendaPagamento.TipoPagamento_CodigoTipoPagamento);

            if (tipoPagamentoDoPagamento != null)
            {
                VendaCorrente.ValorTotalRecebimento -= vendaPagamento.ValorPagamento -
                                                       (tipoPagamentoDoPagamento.PercentualDesconto / 100 *
                                                        vendaPagamento.ValorPagamento);
                VendaCorrente.DataRecebimento = DateTime.Now;
                if (VendaCorrente.VendaPagamentoes.Sum(x => x.ValorPagamento) - VendaCorrente.ValorTotalVenda < 0)
                {
                    VendaCorrente.ValorTroco = 0;
                }
                else
                {
                    VendaCorrente.ValorTroco = VendaCorrente.VendaPagamentoes.Sum(x => x.ValorPagamento) - VendaCorrente.ValorTotalVenda;
                }
            }
        }
Example #5
0
 public void RemoverVendaPagamento(VendaPagamento vendaPagamento)
 {
     VendaCorrente.RemoverPagamentoDaVenda(vendaPagamento);
     ListaDeVendaPagamentos = VendaCorrente.VendaCorrente.VendaPagamentoes.ToList();
 }