Exemplo n.º 1
0
        public void ReturnClienteTest()
        {
            var items = new string[] {
                "0000003445034",
                "0000003506774"
            };

            var request = new Common.Entities.ReturnRequest
            {
                Sucursal = "01",
                Folio    = "414628",
                Items    = items,
                Comments = "CAMBIO POR MODELO",
                Cliente  = new Common.Entities.Cliente {
                    Id = 810374
                }
            };
            string folio = null;

            using (ShimsContext.Create())
            {
                System.Fakes.ShimDateTime.NowGet = () => { return(DateTime.Parse("2018-06-16")); };
                folio = _context.Return(request, 0, request.Sucursal);
            }
            Assert.IsNotNull(folio);
        }
Exemplo n.º 2
0
        protected override void RegisterMessages()
        {
            Messenger.Default.Register <Utilities.Messages.ApprovedResponse>(this, this.GID, async p => {
                this.IsBusy = true;
                var request = new Common.Entities.ReturnRequest
                {
                    Sucursal = this.Venta.Sucursal,
                    Folio    = this.Venta.Folio,
                    Comments = "",
                    Items    = this.Productos.Select(i => i.Item.Serie),
                    Razones  = this.Productos.ToDictionary(i => i.Item.Serie,
                                                           i => new Common.Entities.RazonItem
                    {
                        TipoRazon = i.RazonId.Value,
                        Notas     = i.Razon
                    })
                };
                request.Cliente = Helpers.Parsers.PaseCliente(this.NuevoCliente, this.Cliente, this.Sucursal);
                this.Folio      = await _client.ReturnAsync(request);
                this.IsBusy     = false;
            });

            Messenger.Default.Register <Messages.ProductoDevolucionMessage>(this, this.GID, p => {
                this.Productos.Add(p.Item);
            });
            Messenger.Default.Register <Messages.ClienteMessage>(this, this.GID, m => {
                this.Cliente      = m.Cliente;
                this.NuevoCliente = null;
                if (this.Cliente != null)
                {
                    this.NuevoCliente = new Models.NuevoCliente
                    {
                        Id        = this.Cliente.Id,
                        Nombre    = this.Cliente.Nombre,
                        ApPaterno = this.Cliente.ApPaterno,
                        ApMaterno = this.Cliente.ApMaterno
                    };
                }
            });
            Messenger.Default.Register <Messages.NuevoClienteMessage>(this, this.GID, m => {
                this.NuevoCliente = m.Cliente;
                this.Cliente      = null;
            });
        }
Exemplo n.º 3
0
        public void ReturnTest2()
        {
            var items = new string[] {
                "0000003487207"
            };

            var request = new Common.Entities.ReturnRequest
            {
                Sucursal = "01",
                Folio    = "424749",
                Items    = items,
                Comments = "POR MODELO"
            };
            string folio = null;

            using (ShimsContext.Create())
            {
                System.Fakes.ShimDateTime.NowGet = () => { return(DateTime.Parse("2018-12-18")); };
                folio = _context.Return(request, 0, request.Sucursal);
            }
            Assert.IsNotNull(folio);
        }
Exemplo n.º 4
0
        public DevolucionViewModel()
        {
            _common = new Helpers.CommonHelper();
            this.PropertyChanged             += DevolucionViewModel_PropertyChanged;
            this.Productos                    = new ObservableCollection <Models.ProductoDevolucion>();
            this.Productos.CollectionChanged += Productos_CollectionChanged;
            if (!IsInDesignMode)
            {
                _reports = new Helpers.ReportsHelper();
                _client  = new Helpers.ServiceClient();
                _proxy   = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
            }
            this.LoadCommand = new GalaSoft.MvvmLight.Command.RelayCommand(async() => {
                this.IsBusy = true;
                var ser     = _common.PrepareSerie(this.SerieSearch);

                var item = await _proxy.ScanProductoDevolucionAsync(ser, cancelacion: false);
                if (item != null && item.Success)
                {
                    if (!this.Productos.Any())
                    {
                        AddItem(item.Producto);
                        this.SerieSearch = null;
                        this.Venta       = new Models.SucursalFolio {
                            Sucursal = item.Producto.Sucursal, Folio = item.Producto.Folio
                        };

                        //var ven = _proxy.FindVentaView(this.Venta.Sucursal, this.Venta.Folio, 0);

                        var sale          = _proxy.FindSale(this.Venta.Sucursal, this.Venta.Folio);
                        this.CanSetClient = !sale.ClienteId.HasValue;
                        if (sale.ClienteId.HasValue)
                        {
                            this.Cliente = _proxy.FindCliente(sale.ClienteId.Value);
                            if (this.Cliente != null)
                            {
                                this.NuevoCliente = new Models.NuevoCliente
                                {
                                    Id        = this.Cliente.Id,
                                    Nombre    = this.Cliente.Nombre,
                                    ApPaterno = this.Cliente.ApPaterno,
                                    ApMaterno = this.Cliente.ApMaterno
                                };
                            }
                        }
                    }
                    else
                    {
                        if (this.Venta.Sucursal == item.Producto.Sucursal &&
                            this.Venta.Folio == item.Producto.Folio)
                        {
                            var current = this.Productos.Where(i => i.Item.Serie == item.Producto.Serie).SingleOrDefault();
                            if (current == null)
                            {
                                AddItem(item.Producto);
                            }
                            else
                            {
                                this.Productos.Remove(current);
                            }
                            this.SerieSearch = null;
                        }
                        else
                        {
                            MessageBox.Show($"El producto {item.Producto.Serie}, no pertenece a la misma venta.");
                        }
                    }
                }
                else
                {
                    if (item == null)
                    {
                        this.ErrorMessage = "Artículo no encontrado";
                    }
                    else
                    {
                        if (item.Status == Common.Constants.Status.BA)
                        {
                            this.ErrorMessage = "El articulo ha excedido el tiempo valido para su devolución o cambio";
                        }
                        else
                        {
                            this.ErrorMessage = "Artículo no valido";
                        }
                    }
                }
                this.IsBusy = false;
            }, () => !string.IsNullOrWhiteSpace(this.SerieSearch));
            this.ReturnCommand = new GalaSoft.MvvmLight.Command.RelayCommand(async() => {
                //Messenger.Default.Send(new Messages.RequestApproval { GID = this.GID });

                this.IsBusy = true;
                var request = new Common.Entities.ReturnRequest
                {
                    Sucursal = this.Venta.Sucursal,
                    Folio    = this.Venta.Folio,
                    Comments = "",
                    Items    = this.Productos.Select(i => i.Item.Serie),
                    Razones  = this.Productos.ToDictionary(i => i.Item.Serie,
                                                           i => new Common.Entities.RazonItem {
                        TipoRazon = i.RazonId.Value,
                        Notas     = i.Razon
                    })
                };
                request.Cliente = Helpers.Parsers.PaseCliente(this.NuevoCliente, this.Cliente, this.Sucursal);
                this.Folio      = await _client.ReturnAsync(request);
                this.IsBusy     = false;
            }, () => this.Total > 0);

            this.PrintCommand = new RelayCommand(() => {
                _reports.Devolucion(this.Sucursal.Clave, this.Folio);
            }, () => this.IsComplete);

            this.LoadClienteCommand = new RelayCommand(() =>
            {
                Messenger.Default.Send(
                    new Utilities.Messages.OpenModal
                {
                    Name = Utilities.Constants.Modals.cliente,
                    GID  = this.GID
                });
            }, () => this.CanSetClient);
            this.ClearClienteCommand = new RelayCommand(() =>
            {
                this.Cliente      = null;
                this.NuevoCliente = null;
            }, () => this.CanSetClient);
            if (this.IsInDesignMode)
            {
                this.ClienteId   = 90;
                this.Folio       = "123";
                this.SerieSearch = "0000003342601";
                this.Venta       = new Models.SucursalFolio {
                    Folio = "folio", Sucursal = "sucursal"
                };
                this.Productos.Add(new Models.ProductoDevolucion {
                    Item = new ProductoDevolucion {
                        Sucursal = "01", Folio = "123", Serie = "0000003413693", Marca = "FFF", Modelo = "2608", Talla = "27.5", Precio = 799
                    }
                });
                this.Productos.Add(new Models.ProductoDevolucion {
                    Item = new ProductoDevolucion {
                        Sucursal = "01", Folio = "124", Serie = "0000003420542", Marca = "AAA", Modelo = "1234", Talla = "28", Precio = 123.45m
                    }
                });

                this.NuevoCliente = new Client.Models.NuevoCliente {
                    Nombre = "nom", ApPaterno = "ap pa", ApMaterno = "ap ma"
                };
            }
        }