Exemplo n.º 1
0
        protected async Task <Models.Pagos.Pago> ParsePago(Utilities.Messages.Pago o, Guid?id = null)
        {
            Models.Pagos.Pago p = null;
            switch (o.FormaPago)
            {
            case FormaPago.EF:
                p = new Models.Pagos.Pago
                {
                    FormaPago = o.FormaPago,
                    Importe   = o.Importe
                };
                break;

            case FormaPago.MD:
                p = new Models.Pagos.Pago
                {
                    FormaPago = o.FormaPago,
                    Importe   = o.Importe,
                    ClientId  = o.Cliente
                };
                break;

            case FormaPago.DV:
                p = new Models.Pagos.PagoDevolucion
                {
                    FormaPago = o.FormaPago,
                    Importe   = o.Importe,
                    Sucursal  = o.Sucursal,
                    Folio     = o.Folio
                };
                break;

            case FormaPago.TC:
            case FormaPago.TD:
                p = new Models.Pagos.PagoTarjeta
                {
                    FormaPago   = o.FormaPago,
                    Importe     = o.Importe,
                    Terminacion = o.Terminacion,
                    Referencia  = o.Referencia
                };
                break;

            case FormaPago.VA:
            {
                var pv = new Models.Pagos.PagoVale
                {
                    FormaPago         = o.FormaPago,
                    Importe           = o.Importe,
                    Vale              = o.Vale,
                    Plazos            = o.Plazos,
                    Promociones       = o.Promociones,
                    SelectedPlazo     = o.SelectedPlazo,
                    SelectedPromocion = o.SelectedPromocion,
                    ContraVale        = o.ContraVale,
                    Limite            = o.Limite,
                    ClientId          = o.Cliente,
                    ProductosPlazos   = o.PlazosProductos
                };

                if (!this.IsInDesignMode)
                {
                    var promos = await _proxy.FindPromocionesValeAsync(this.Sucursal.Clave);

                    //pv.Plazos = promos.Plazos;
                    pv.Promociones = promos.Promociones;

                    var vale = await _proxy.FindValeAsync(o.Vale);

                    pv.Info = new Models.Pagos.PagoValeInfo
                    {
                        Distribuidor = vale.Distribuidor.Nombre,
                        Promocion    = vale.Distribuidor.Promocion,
                        Electronica  = vale.Distribuidor.Electronica
                    };

                    if (o.Cliente.HasValue)
                    {
                        var cli = _proxy.FindCliente(o.Cliente.Value);
                        Messenger.Default.Send(new Messages.ClienteMessage {
                                Cliente = cli
                            }, this.GID);
                    }
                }
                p = pv;
            }
            break;

            case FormaPago.VD:
            {
                var pv = new Models.Pagos.PagoVale
                {
                    FormaPago         = o.FormaPago,
                    Importe           = o.Importe,
                    Vale              = o.Vale,
                    Plazos            = o.Plazos,
                    Promociones       = o.Promociones,
                    SelectedPlazo     = o.SelectedPlazo,
                    SelectedPromocion = o.SelectedPromocion,
                    ClientId          = o.Cliente
                };

                if (!this.IsInDesignMode)
                {
                    var promos = await _proxy.FindPromocionesValeAsync(this.Sucursal.Clave);

                    //pv.Plazos = promos.Plazos;
                    pv.Promociones = promos.Promociones;

                    var vale = await _proxy.FindValeDigitalAsync(o.Vale);

                    pv.Info = new Models.Pagos.PagoValeInfo
                    {
                        Distribuidor = vale.Distribuidor.Nombre,
                        Promocion    = vale.Distribuidor.Promocion,
                        Electronica  = vale.Distribuidor.Electronica
                    };

                    if (o.Cliente.HasValue)
                    {
                        var cli = _proxy.FindCliente(o.Cliente.Value);
                        Messenger.Default.Send(new Messages.ClienteMessage {
                                Cliente = cli
                            }, this.GID);
                    }
                }
                p = pv;
            }
            break;

            case FormaPago.VE:
            {
                var pv = new Models.Pagos.PagoVale
                {
                    FormaPago         = o.FormaPago,
                    Importe           = o.Importe,
                    Vale              = o.Vale,
                    Negocio           = o.Negocio,
                    NoCuenta          = o.NoCuenta,
                    Plazos            = o.Plazos,
                    Promociones       = o.Promociones,
                    SelectedPlazo     = o.SelectedPlazo,
                    SelectedPromocion = o.SelectedPromocion,
                    ClientId          = o.Cliente
                };

                if (!this.IsInDesignMode)
                {
                    var promos = await _proxy.FindPromocionesValeAsync(this.Sucursal.Clave);

                    //pv.Plazos = promos.Plazos;
                    pv.Promociones = promos.Promociones;

                    //var vale = await _proxy.FindValeDigitalAsync(o.Vale);
                    //pv.Info = new Models.Pagos.PagoValeInfo
                    //{
                    //    Distribuidor = vale.Distribuidor.Nombre,
                    //    Promocion = vale.Distribuidor.Promocion,
                    //    SoloCalzado = vale.Distribuidor.SoloCalzado
                    //};

                    //if (o.Cliente.HasValue)
                    //{
                    //    var cli = _proxy.FindCliente(o.Cliente.Value);
                    //    Messenger.Default.Send(new Messages.ClienteMessage { Cliente = cli }, this.GID);
                    //}
                }
                p = pv;
            }
            break;

            case FormaPago.CP:
            {
                var cp = new Models.Pagos.PagoCredito
                {
                    FormaPago         = o.FormaPago,
                    Importe           = o.Importe,
                    Vale              = o.Vale,
                    Plazos            = o.Plazos,
                    Promociones       = o.Promociones,
                    SelectedPlazo     = o.SelectedPlazo,
                    SelectedPromocion = o.SelectedPromocion,
                    ContraVale        = o.ContraVale,
                    Limite            = o.Limite,
                    ClientId          = o.Cliente
                };

                if (!this.IsInDesignMode)
                {
                    var promos = await _proxy.FindPromocionesValeAsync(this.Sucursal.Clave);

                    //pv.Plazos = promos.Plazos;
                    cp.Promociones = promos.Promociones;

                    var vale = await _proxy.FindTarjetahabienteAsync(o.Vale);

                    cp.Info = new Models.Pagos.PagoValeInfo
                    {
                        Distribuidor = vale.Distribuidor.Nombre,
                        Promocion    = vale.Distribuidor.Promocion,
                        Electronica  = vale.Distribuidor.Electronica
                    };

                    if (o.Cliente.HasValue)
                    {
                        var cli = _proxy.FindCliente(o.Cliente.Value);
                        Messenger.Default.Send(new Messages.ClienteMessage {
                                Cliente = cli
                            }, this.GID);
                    }
                    else
                    {
                        this.Cliente = new Cliente {
                            DistribuidorId = o.DistribuidorId
                        };
                    }
                }
                p = cp;
            }
            break;

            case FormaPago.CD:
            {
                var cp = new Models.Pagos.PagoCredito
                {
                    FormaPago         = o.FormaPago,
                    Importe           = o.Importe,
                    Vale              = o.Vale,
                    Plazos            = o.Plazos,
                    Promociones       = o.Promociones,
                    SelectedPlazo     = o.SelectedPlazo,
                    SelectedPromocion = o.SelectedPromocion,
                    ContraVale        = o.ContraVale,
                    Limite            = o.Limite,
                    ClientId          = o.Cliente
                };

                if (!this.IsInDesignMode)
                {
                    var promos = await _proxy.FindPromocionesValeAsync(this.Sucursal.Clave);

                    //pv.Plazos = promos.Plazos;
                    cp.Promociones = promos.Promociones;

                    var vale = await _proxy.FindDistribuidorAsync(o.Vale);

                    cp.Info = new Models.Pagos.PagoValeInfo
                    {
                        Distribuidor = vale.Distribuidor.Nombre,
                        Promocion    = vale.Distribuidor.Promocion,
                        Electronica  = vale.Distribuidor.Electronica
                    };

                    if (o.Cliente.HasValue)
                    {
                        var cli = _proxy.FindCliente(o.Cliente.Value);
                        Messenger.Default.Send(new Messages.ClienteMessage {
                                Cliente = cli
                            }, this.GID);
                    }
                    else
                    {
                        this.Cliente = new Cliente {
                            DistribuidorId = o.DistribuidorId
                        };
                    }
                }
                p = cp;
            }
            break;

            case FormaPago.CV:
                var cv = new Models.Pagos.PagoContraVale
                {
                    FormaPago         = o.FormaPago,
                    Importe           = o.Importe,
                    Vale              = o.Vale,
                    Plazos            = o.Plazos,
                    Promociones       = o.Promociones,
                    SelectedPlazo     = o.SelectedPlazo,
                    SelectedPromocion = o.SelectedPromocion,
                    ContraVale        = o.ContraVale,
                    Limite            = o.Limite,
                    Sucursal          = o.Sucursal,
                    ClientId          = o.Cliente
                };

                if (!this.IsInDesignMode)
                {
                    var promos = await _proxy.FindPromocionesValeAsync(this.Sucursal.Clave);

                    //pv.Plazos = promos.Plazos;
                    cv.Promociones = promos.Promociones;

                    var vale = await _proxy.FindContraValeAsync(o.Sucursal, o.Vale);

                    cv.Info = new Models.Pagos.PagoValeInfo
                    {
                        Distribuidor = vale.Distribuidor.Nombre,
                        Promocion    = vale.Distribuidor.Promocion,
                        Electronica  = vale.Distribuidor.Electronica
                    };

                    if (o.Cliente.HasValue)
                    {
                        var cli = _proxy.FindCliente(o.Cliente.Value);
                        Messenger.Default.Send(new Messages.ClienteMessage {
                            Cliente = cli
                        }, this.GID);
                    }
                }
                p = cv;
                break;

            default:
                throw new NotSupportedException();
            }
            p.Id = id ?? Guid.NewGuid();
            return(p);
        }
Exemplo n.º 2
0
        public VerificarValeViewModel()
        {
            this.PropertyChanged += VerificarValeViewModel_PropertyChanged;
            if (!IsInDesignMode)
            {
                _client   = new Helpers.ServiceClient();
                _proxy    = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
                _pcredito = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.ICreditoValeServiceAsync>();
            }
            this.FindValeCommand = new RelayCommand(async() => {
                this.IsBusy = true;
                this.Vale   = await _proxy.FindValeAsync(this.ValeSearch);
                if (this.Vale != null)
                {
                    this.TotalVale    = null;
                    this.Cliente      = null;
                    this.NuevoCliente = null;
                    if (this.Vale.WithLimite)
                    {
                        this.TotalVale = this.Vale.Limite;
                        this.Cliente   = new Cliente
                        {
                            Id = this.Vale.ClienteId
                        };
                    }
                }
                this.IsBusy = false;
            }, () => !String.IsNullOrEmpty(this.ValeSearch));
            this.RegistrarValeCommand = new RelayCommand(async() =>
            {
                this.IsBusy = true;
                var request = new Common.Entities.RegisterValeRequest
                {
                    Vale        = this.Vale.Vale,
                    Cantidad    = this.TotalVale,
                    Electronica = false,
                    Cliente     = Helpers.Parsers.PaseCliente(this.NuevoCliente, this.Cliente, this.Sucursal)
                };
                var res     = await _client.RegisterValeAsync(request);
                this.IsBusy = false;
            }, () => this.Vale != null && this.TotalVale.HasValue &&
                                                         (this.Cliente != null || this.NuevoCliente != null) &&
                                                         !this.Vale.WithLimite);
            this.SolicitarCreditoCommand = new RelayCommand(async() =>
            {
                this.IsBusy = true;
                var request = new Common.Entities.SolicitudCreditoRequest
                {
                    Electronica = this.SolicitudElectronica,
                    Vale        = this.Vale.Vale,
                    idusuario   = this.Cajero.Id,
                    Monto       = this.Solicitud.Value,
                    Sucursal    = this.Sucursal.Clave
                };
                var res = await _pcredito.RequestAsync(request);
                if (res.Processing.HasValue)
                {
                    MessageBox.Show($"Result: {res.Processing}");
                }
                this.IsBusy = false;
            }, () => this.Vale != null && this.Solicitud.HasValue);
            this.CreditoCommand = new RelayCommand(() =>
            {
                this.Credito = true;
            }, () => !this.Credito);
            this.LoadClienteCommand = new RelayCommand(() =>
            {
                Messenger.Default.Send(
                    new Utilities.Messages.OpenModal
                {
                    Name = Utilities.Constants.Modals.cliente,
                    GID  = this.GID
                });
            }, () => {
                if (this.Vale != null)
                {
                    return(!this.Vale.WithLimite);
                }
                return(false);
            });
            this.ClearClienteCommand = new RelayCommand(() =>
            {
                this.NuevoCliente = null;
                this.Cliente      = null;
            }, () => {
                if (this.Vale != null)
                {
                    return(!this.Vale.WithLimite);
                }
                return(false);
            });

            if (this.IsInDesignMode)
            {
                this.NuevoCliente = new Models.NuevoCliente
                {
                    Nombre    = "nom",
                    ApMaterno = "mat",
                    ApPaterno = "pat",
                    Id        = 999
                };
                this.ValeSearch = "search";
                this.Vale       = new ValeResponse
                {
                    Cancelado       = true,
                    CanceladoMotivo = "motivo",
                    Disponible      = 100,
                    Vale            = "123",
                    Distribuidor    = new Distribuidor
                    {
                        Id          = 1,
                        Nombre      = "nombre",
                        ApMaterno   = "materno",
                        ApPaterno   = "paterno",
                        Status      = Common.Constants.StatusDistribuidor.SOBREGIRADO,
                        Electronica = true,
                        Firmas      = new short[] { 1, 2, 3 }
                    }
                };

                this.Solicitud = 30000m;
                this.TotalVale = 10000m;
            }
        }
Exemplo n.º 3
0
        public PagoValeViewModel()
        {
            this.Productos            = new ObservableCollection <Utilities.Models.ProductoPlazoOpciones>();
            this.ProductosView        = CollectionViewSource.GetDefaultView(this.Productos);
            this.ProductosView.Filter = i =>
            {
                var item = (Utilities.Models.ProductoPlazoOpciones)i;
                if (item.Item.FormasPago.Where(k => k.FormaPago == this.FormaPago).Any())
                {
                    return(true);
                }
                return(false);
            };
            this.Productos.CollectionChanged += Productos_CollectionChanged;
            this.PlanPago = new ObservableCollection <Models.PlanPagoItem>();
            if (!IsInDesignMode)
            {
                _proxy = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
            }
            this.PropertyChanged += PagoValeViewModel_PropertyChanged;
            this.OpenFirma        = new RelayCommand <Models.FirmaIndex>(p =>
            {
                var ic  = new Converters.ImageUrlMultiConverter();
                var res = ic.Convert(new object[] { p.Id, p.Index }, typeof(string), "FirmaUrl", System.Globalization.CultureInfo.CurrentUICulture);
                //MessageBox.Show($"{p.Id}x{p.Index}");
                _image.OpenImage(res);
            });
            this.SearchCommand = new GalaSoft.MvvmLight.Command.RelayCommand(async() =>
            {
                this.IsBusy           = true;
                this.Vale             = await _proxy.FindValeAsync(this.Search);
                var pago              = (Models.Pagos.PagoVale) this.PagoIem;
                pago.Info.Electronica = true;
                if (this.Vale != null)
                {
                    pago.Info.Electronica = this.Vale.Distribuidor.Electronica;
                    this.Limite           = this.Vale.Limite;
                    this.Search           = null;
                    if (!this.HasPromocion)
                    {
                        this.SelectedPromocion = this.Promocion.Promociones.FirstOrDefault();
                    }
                    if (this.Vale.Distribuidor.Firmas != null && this.Vale.Distribuidor.Firmas.Any())
                    {
                        this.SelectedFirma = this.Vale.Distribuidor.Firmas.First();
                    }
                    else
                    {
                        this.SelectedFirma = null;
                    }
                    this.Caja.UpdatePagos();
                }
                else
                {
                    MessageBox.Show("El vale que ingresó no existe, por favor validelo nuevamente.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                this.IsBusy = false;
            }, () => !String.IsNullOrEmpty(this.Search));

            if (!this.IsInDesignMode)
            {
                _image = CommonServiceLocator.ServiceLocator.Current.GetInstance <Utilities.Interfaces.IImageView>();
                var settings = CommonServiceLocator.ServiceLocator.Current.GetInstance <Utilities.Models.Settings>();
                this.Promocion = _proxy.FindPromocionesVale(settings.Sucursal.Clave);
                //if (promocion != null)
                //{
                //    //this.Plazos = promocion.Plazos;
                //    //this.SelectedPlazo = promocion.Selected;
                //    this.PagosMax = promocion.PagosMax;
                //    this.Promociones = promocion.Promociones;
                //    this.Fechas = promocion.Fechas;
                //    //this.SelectedPromocion = promocion.Promociones.Any() ? promocion.Promociones.Last() : (DateTime?)null;
                //}
            }

            if (this.IsInDesignMode)
            {
                this.HasPromocionPlazos = true;
                this.Plazos             = new int[] { 1, 2, 3 };
                this.SelectedPlazo      = 3;
                this.Promocion          = new PromocionesValeResponse
                {
                    Promociones = new DateTime[] {
                        DateTime.Parse("2019-01-01"),
                        DateTime.Parse("2019-02-10"),
                        DateTime.Parse("2019-03-20")
                    },
                    Fechas = new DateTime[] {
                        DateTime.Parse("2020-01-01"),
                        DateTime.Parse("2020-02-10"),
                        DateTime.Parse("2020-03-20")
                    },
                    Blindaje = 100
                };
                this.SelectedPromocion = this.Promocion.Promociones.Last();
                this.Primero           = 123;
                this.Ultimo            = 456;

                //this.Total = 1234.5m;
                this.Pagar              = 200m;
                this.Search             = "123";
                this.Limite             = 1000;
                this.GenerateContraVale = true;
                this.Vale = new Common.Entities.ValeResponse
                {
                    Cancelado       = true,
                    CanceladoMotivo = "motivo",
                    Disponible      = 199m,
                    Vale            = "123",
                    ClienteId       = 1,
                    Distribuidor    = new Common.Entities.Distribuidor
                    {
                        Id          = 1,
                        Cuenta      = "0123",
                        Nombre      = "nombre",
                        ApPaterno   = "appaterno",
                        ApMaterno   = "apmaterno",
                        Status      = Common.Constants.StatusDistribuidor.SOBREGIRADO,
                        Electronica = true,
                        Promocion   = true,
                        ContraVale  = true,
                        Firmas      = new short[] { 1, 2, 3 }
                    }
                };


                this.Productos.Add(new Utilities.Models.ProductoPlazoOpciones(new Models.Producto {
                    MaxPlazos = 30, Id = 1, Serie = "001", Marca = "a", Modelo = "b", Talla = "c", Precio = 100, DescuentoDirecto = null, HasImage = true, Electronica = true
                }));
                this.Productos.Add(new Utilities.Models.ProductoPlazoOpciones(new Models.Producto {
                    MaxPlazos = 20, Id = 3, Serie = "003", Marca = "a", Modelo = "b", Talla = "c", Precio = 100, DescuentoDirecto = 10
                }));

                this.PlanPago.Add(new Models.PlanPagoItem {
                    Number = 1, Date = DateTime.Parse("2019-01-01"), Amount = 110.99m
                });
                this.PlanPago.Add(new Models.PlanPagoItem {
                    Number = 2, Date = DateTime.Parse("2019-01-15"), Amount = 100.99m
                });
                this.PlanPago.Add(new Models.PlanPagoItem {
                    Number = 3, Date = DateTime.Parse("2019-02-01"), Amount = 90m
                });
            }
        }