Exemplo n.º 1
0
 public PagoContraValeViewModel2()
 {
     _common = new Helpers.CommonHelper();
     if (!IsInDesignMode)
     {
         _proxy = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
     }
     this.PropertyChanged += PagoContraValeViewModel2_PropertyChanged;
     this.SearchCommand    = new GalaSoft.MvvmLight.Command.RelayCommand(async() =>
     {
         this.IsBusy = true;
         var cv      = _common.PrepareContraVale(this.Search);
         this.Vale   = await _proxy.FindContraValeAsync(this.SucursalSearch, cv);
         if (this.Vale != null)
         {
             this.SucursalSearch = null;
             this.Search         = null;
             if (!this.Vale.Distribuidor.Promocion)
             {
                 this.SelectedPromocion = this.Promocion.Promociones.FirstOrDefault();
             }
         }
         else
         {
             MessageBox.Show("not found");
         }
         this.IsBusy = false;
     }, () => !String.IsNullOrEmpty(this.Search) && !String.IsNullOrEmpty(this.SucursalSearch));
 }
Exemplo n.º 2
0
        public PagoContraValeViewModel()
        {
            _common = new Helpers.CommonHelper();
            if (!IsInDesignMode)
            {
                _proxy = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
            }
            this.PropertyChanged += PagoValeViewModel_PropertyChanged;
            this.SearchCommand    = new GalaSoft.MvvmLight.Command.RelayCommand(async() =>
            {
                this.IsBusy = true;
                var cv      = _common.PrepareContraVale(this.Search);
                this.Vale   = await _proxy.FindContraValeAsync(this.SucursalSearch, cv);
                if (this.Vale != null)
                {
                    this.Search = null;
                    if (!this.Vale.Distribuidor.Promocion)
                    {
                        this.SelectedPromocion = this.Promociones.FirstOrDefault();
                    }
                }
                else
                {
                    MessageBox.Show("not found");
                }
                this.IsBusy = false;
            }, () => !String.IsNullOrEmpty(this.Search) && !String.IsNullOrEmpty(this.SucursalSearch));

            if (!this.IsInDesignMode)
            {
                var settings  = CommonServiceLocator.ServiceLocator.Current.GetInstance <Utilities.Models.Settings>();
                var 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.SelectedPromocion = promocion.Promociones.Any() ? promocion.Promociones.Last() : (DateTime?)null;
                }
            }

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

                //this.Total = 1234.5m;
                this.Pagar              = 100m;
                this.Search             = "123";
                this.Limite             = 1000;
                this.GenerateContraVale = true;
                this.Vale = new Common.Entities.CValeResponse
                {
                    Cancelado    = false,
                    Disponible   = 199m,
                    Vigencia     = DateTime.Parse("2020-01-15"),
                    Vale         = "123",
                    ClienteId    = 1,
                    Distribuidor = new Common.Entities.Distribuidor
                    {
                        Id          = 1,
                        Nombre      = "nombre",
                        ApPaterno   = "appaterno",
                        ApMaterno   = "apmaterno",
                        Status      = Common.Constants.StatusDistribuidor.SOBREGIRADO,
                        Electronica = true,
                        Promocion   = true,
                        ContraVale  = true,
                        Firmas      = new short[] { 1, 2, 3 }
                    }
                };
            }
        }
Exemplo n.º 3
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);
        }