コード例 #1
0
        public LoadClienteViewModel()
        {
            if (!this.IsInDesignMode)
            {
                _proxy = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
            }

            _common                = new Helpers.CommonHelper();
            this.Screen            = "search";
            this.ChangeViewCommand = new RelayCommand <string>(v => {
                this.Screen = v;
            });

            this.PropertyChanged += LoadClienteViewModel_PropertyChanged;

            this.SearchCommand = new RelayCommand(() => {
                if (!this.ClienteSearch.HasValue && string.IsNullOrWhiteSpace(this.ClienteTelefonoSearch))
                {
                    if (this.Cliente != null)
                    {
                        Messenger.Default.Send(new Messages.ClienteMessage
                        {
                            Cliente = this.Cliente
                        }, this.GID);
                    }
                }
                else
                {
                    var phone    = _common.PreparePhone(this.ClienteTelefonoSearch);
                    this.Cliente = _proxy.FindCliente(this.ClienteSearch, phone);
                    if (this.Cliente != null)
                    {
                        this.ClienteSearch         = null;
                        this.ClienteTelefonoSearch = null;
                    }
                    else
                    {
                        MessageBox.Show("Cliente no encontrado.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            });

            if (this.IsInDesignMode)
            {
                this.ClienteSearch         = 123;
                this.ClienteTelefonoSearch = "1234567890";
                this.NuevoCliente          = new Models.NuevoCliente
                {
                    Nombre       = "nombre",
                    ApPaterno    = "ap paterno",
                    ApMaterno    = "ap materno",
                    Calle        = "calle",
                    Celular      = "1234567890",
                    CodigoPostal = "cp",
                    Colonia      = null,
                    Email        = "email",
                    Referencia   = "entre calles",
                    Numero       = 123,
                };

                this.Colonias = new Common.Entities.Colonia[] {
                    new Common.Entities.Colonia
                    {
                        Id           = 1,
                        Nombre       = "colonia",
                        CodigoPostal = "cp",
                        CiudadId     = 2,
                        CiudadNombre = "ciudad",
                        EstadoId     = 3,
                        EstadoNombre = "estado"
                    }
                };
                this.NuevoCliente.Colonia = this.Colonias.First();
            }
        }
コード例 #2
0
        public CajaViewModel()
        {
            _skipPromociones = false;
            _common          = new Helpers.CommonHelper();
            this.Productos   = new ObservableCollection <Models.Producto>();
            this.Productos.CollectionChanged += Productos_CollectionChanged;
            this.Cupones            = new ObservableCollection <Cupon>();
            this.PromocionesCupones = new ObservableCollection <Promocion>();
            this.PromocionesCupones.CollectionChanged += PromocionesCupones_CollectionChanged;
            _promocionesCuponesUsadas = new CollectionViewSource {
                Source = this.PromocionesCupones
            };
            this.PromocionesCuponesUsadas.Filter = i => {
                var item = (Promocion)i;
                return(item.Used);
            };
            this.Pagos.CollectionChanged += Pagos_CollectionChanged;
            this.PropertyChanged         += CajaViewModel_PropertyChanged;

            if (!IsInDesignMode)
            {
                _reports = new Helpers.ReportsHelper();
                _proxy   = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
                _pproxy  = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.ICommonServiceAsync>();
                _mapper  = CommonServiceLocator.ServiceLocator.Current.GetInstance <AutoMapper.IMapper>();
                _client  = new Helpers.ServiceClient();
            }

            this.RemovePagoCommand = new RelayCommand(/*async */ () => {
                //_ls.RemovePago(this.SelectedPago.Id);
                this.Pagos.Remove(this.SelectedPago);
                //await this.UpdatePromociones();
            }, () => this.SelectedPago != null);

            this.RemoveCuponCommand = new RelayCommand(() => {
                var cupon = this.SelectedCupon;
                //_ls.RemoveCupon(cupon.Folio);
                var q = this.PromocionesCupones.OfType <PromocionCupon>().Where(i => i.Cupon == cupon.Folio).ToArray();
                foreach (var item in q)
                {
                    this.PromocionesCupones.Remove(item);
                }
                this.Cupones.Remove(this.SelectedCupon);
            }, () => this.SelectedCupon != null);

            this.SaleCommand = new RelayCommand(this.Sale, () => {
                if (this.SaleResponse == null &&
                    this.Total > 0 && this.Remaining == 0)
                {
                    if (this.IsValid())
                    {
                        var pagado = this.Productos.All(i => i.Pagado);
                        if (pagado)
                        {
                            return(true);
                        }
                    }
                }
                return(false);
            });

            this.RemoveCommand = new RelayCommand(async() =>
            {
                await this.RemoveItem(this.SelectedItem);
            }, () => this.SelectedItem != null);
            this.AddCommand = new RelayCommand(async() => {
                //this.IsBusy = true;
                await Add();
                this.IsBusy = false;
            }, () => !string.IsNullOrWhiteSpace(this.SerieSearch));

            this.AddCuponCommand = new RelayCommand(() => {
                this.IsBusy = true;
                this.AddCuponHelper();
                this.IsBusy = false;
            }, () => !string.IsNullOrWhiteSpace(this.CuponSearch));

            this.LoadClienteCommand = new RelayCommand(() => {
                Messenger.Default.Send(
                    new Utilities.Messages.OpenModal
                {
                    Name = Utilities.Constants.Modals.cliente,
                    GID  = this.GID
                });
            });
            this.LoadVendedorCommand = new RelayCommand(() => {
                Messenger.Default.Send(
                    new Utilities.Messages.OpenModal
                {
                    Name = Utilities.Constants.Modals.vendedor,
                    GID  = this.GID
                });
            }, () => this.HasCalzado);
            this.RemoveVendedorCommand = new RelayCommand(() =>
            {
                this.Vendedor = null;
            }, () => this.Vendedor != null);
            this.AddDescuentoAdicional = new RelayCommand(() => {
                if (this.SelectedItem.DescuentoAdicional != null)
                {
                    this.SelectedItem.DescuentoAdicional = null;
                }
                else
                {
                    Messenger.Default.Send(
                        new Utilities.Messages.OpenModal
                    {
                        Name = Utilities.Constants.Modals.descuento,
                        GID  = this.GID
                    });
                }
            }, () => this.SelectedItem != null);
            this.AddNotaCommand = new RelayCommand(() =>
            {
                Messenger.Default.Send(
                    new Utilities.Messages.OpenModalItem
                {
                    Name = Utilities.Constants.Modals.nota,
                    GID  = this.GID,
                    Item = this.SelectedItem
                });
            }, () => this.SelectedItem != null);
            this.ClearClienteCommand = new RelayCommand(async() => {
                this.Cliente      = null;
                this.NuevoCliente = null;
                _ls.ClearCliente();
                _skipPromociones = true;
                foreach (var item in this.PromocionesCupones.OfType <Common.Entities.PromocionCupon>().ToArray())
                {
                    if (item.Cliente.HasValue)
                    {
                        this.PromocionesCupones.Remove(item);
                        _ls.RemoveCupon(item.Cupon);
                    }
                }
                foreach (var item in this.Pagos.Where(i => i.ClientId.HasValue).ToArray())
                {
                    this.Pagos.Remove(item);
                    //_ls.RemovePago(item.Id);
                }
                this.ClientConfirmed = false;
                this.FormasPago.Refresh();
                _skipPromociones = false;
                await this.RefreshPromociones();
                this.SaleCommand.RaiseCanExecuteChanged();
            });

            MoveProductoCommand = new RelayCommand <Models.MoveDirection>(async dir => {
                this.Move(this.SelectedItem, this.Productos, dir, o => this.SelectedItem = o);
                await this.RefreshPromociones();
            }, dir => this.CanMove(this.SelectedItem, this.Productos, dir));

            MovePagoCommand = new RelayCommand <Models.MoveDirection>(async dir => {
                this.Move(this.SelectedPago, this.Pagos, dir, o => this.SelectedPago = (Models.Pagos.Pago)o);
                await this.RefreshPromociones();
            }, dir => this.CanMove(this.SelectedPago, this.Pagos, dir));

            MoveCuponCommand = new RelayCommand <Models.MoveDirection>(async dir => {
                this.Move(this.SelectedPromocion, this.PromocionesCupones, dir, o => this.SelectedPromocion = o);
                await this.RefreshPromociones();
            }, dir => this.CanMove(this.SelectedPromocion, this.PromocionesCupones, dir));

            this.PagarCommand = new RelayCommand(() => {
                this.ShowPagos = true;
            }, () => this.Total > 0 && this.Remaining > 0);


            this.ConfirmClienteCommand = new RelayCommand(() => {
            });

            if (!this.IsInDesignMode)
            {
                _scanner = CommonServiceLocator.ServiceLocator.Current.GetInstance <Utilities.Interfaces.IScanner>();
                if (_scanner != null)
                {
                    _scanner.DataReceived += Scaner_DataReceived;
                }
            }

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

            this.TestCommand = new RelayCommand <string>(p => {
                if (p == "start")
                {
                    _scanner?.Start();
                }
                if (p == "stop")
                {
                    _scanner?.Stop();
                }
            });
        }
コード例 #3
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;
            }
        }
コード例 #4
0
        public GastoViewModel()
        {
            if (!this.IsInDesignMode)
            {
                _proxy        = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IAdminServiceAsync>();
                _data         = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
                this.Opciones = _proxy.GetTiposGasto();
            }

            this.PropertyChanged       += GastoViewModel_PropertyChanged;
            this.LoadSolicitanteCommand = new RelayCommand(() =>
            {
                this.Empleado = _data.FindAuditorApertura(this.EmpleadoSearch.Value, this.Cajero.Id);
                if (this.Empleado != null)
                {
                    this.EmpleadoSearch = null;
                }
                else
                {
                    MessageBox.Show("Solicitante no valido.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }, () => this.EmpleadoSearch.HasValue);
            this.SaveCommand = new RelayCommand(() =>
            {
                var request = new Common.Entities.GastoRequest
                {
                    Tipo        = this.SelectedOption.Value,
                    Monto       = this.Monto.Value,
                    Sucursal    = this.Sucursal.Clave,
                    CajeroId    = this.Cajero.Id,
                    SolicitaId  = this.Empleado.Id,
                    Descripcion = this.Descripcion
                };
                _proxy.GenerarGasto(request);
                MessageBox.Show("Ready");
                this.CloseCommand.Execute(null);
            }, () => this.SelectedOption.HasValue && this.Monto.HasValue && this.Empleado != null);
            if (this.IsInDesignMode)
            {
                this.Descripcion    = "desc";
                this.EmpleadoSearch = 100;
                this.Monto          = 199.99m;
                this.Opciones       = new Common.Entities.Option[] {
                    new Common.Entities.Option {
                        Id = 1, Text = "a"
                    },
                    new Common.Entities.Option {
                        Id = 2, Text = "b"
                    },
                    new Common.Entities.Option {
                        Id = 3, Text = "c"
                    }
                };
                this.SelectedOption = 2;
                this.Empleado       = new Common.Entities.Empleado
                {
                    Nombre          = "aaa",
                    ApellidoMaterno = "mat",
                    ApellidoPaterno = "pat"
                };
            }
        }
コード例 #5
0
        public PuntoDeVentaViewModel()
        {
            if (!IsInDesignMode)
            {
                _proxy  = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
                _pproxy = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.ICommonServiceAsync>();
            }
            this.Productos = new ObservableCollection <Producto>();
            this.Pagos     = new ObservableCollection <Models.Pagos.Pago>();
            _formas        = new Dictionary <FormaPago, bool> {
                { FormaPago.EF, true },
                { FormaPago.TC, true },
                { FormaPago.TD, true }
            };
            this.FormasPago        = CollectionViewSource.GetDefaultView(_formas);
            this.FormasPago.Filter = i => ((KeyValuePair <FormaPago, bool>)i).Value;
            this.ShowSerie         = true;
            _common = new Helpers.CommonHelper();

            this.SaleCommand = new GalaSoft.MvvmLight.Command.RelayCommand(() =>
            {
                var sale = new SaleRequest {
                    VendedorId = 0,
                    Productos  = this.Productos.Select(i => new SerieFormasPago {
                        Serie = i.Serie
                    }),
                    Sucursal = "01",
                    Pagos    = this.Pagos.Where(i => (i.Importe ?? 0) > 0).Select(i => new Common.Entities.Pago {
                        FormaPago = i.FormaPago,
                        Importe   = i.Importe.Value
                    })
                };
                //var res = await _proxy.SaleAsync(sale);
                //MessageBox.Show($"ID: {res}");
            }, () => {
                var sum = this.Pagos.Sum(i => i.Importe) ?? 0;
                var rem = this.Total - sum;
                return(this.Total > 0 && rem == 0);
            });
            this.AddFormaCommand = new GalaSoft.MvvmLight.Command.RelayCommand(() => {
                var p = new Models.Pagos.Pago {
                    FormaPago = this.SelectedFormaPago
                };
                this.Pagos.Add(p);
                p.PropertyChanged += (s, e) => RaisePropertyChanged(nameof(this.TotalPayment));
                if (this.SelectedFormaPago == FormaPago.EF)
                {
                    _formas[FormaPago.EF] = false;
                    this.FormasPago.Refresh();
                }
            });
            this.FindVendedorCommand = new GalaSoft.MvvmLight.Command.RelayCommand(async() =>
            {
                this.Vendedor = await _pproxy.FindVendedorAsync(this.VendedorSearch.Value);
                if (this.Vendedor != null)
                {
                    this.VendedorSearch = null;
                }
            });
            this.FindCajeroCommand = new GalaSoft.MvvmLight.Command.RelayCommand(async() =>
            {
                this.Cajero = await _pproxy.FindCajeroAsync(this.CajeroSearch);
                if (this.Cajero != null)
                {
                    this.CajeroSearch = null;
                }
            });

            this.AddCommand = new GalaSoft.MvvmLight.Command.RelayCommand(async() =>
            {
                this.IsBusy = true;
                var ser     = _common.PrepareSerie(this.Serie);

                var q = this.Productos.Where(i => i.Serie == ser).SingleOrDefault();
                if (q != null)
                {
                    MessageBox.Show($"Already Added: {ser}");
                    return;
                }

                var item = await _proxy.ScanProductoAsync(ser, "01");
                if (item != null)
                {
                    if (item.Status == Status.AC || item.Status == Status.IF ||
                        item.Status == Status.CA)
                    {
                        //if(await _proxy.RequestProductoAsync(item.Producto.Serie))
                        //    this.Productos.Add(item.Producto);
                    }
                    else
                    {
                        MessageBox.Show($"{item.Producto.Serie} - {item.Status}");
                    }
                    this.Serie = null;
                }
                else
                {
                    MessageBox.Show($"Not Found: {ser}");
                }
                this.IsBusy = false;
            }, () =>
            {
                return(!string.IsNullOrWhiteSpace(this.Serie));
            });
            this.RemoveCommand = new GalaSoft.MvvmLight.Command.RelayCommand(() =>
            {
                //await _proxy.ReleaseProductoAsync(this.SelectedItem.Serie);
                //this.Productos.Remove(this.SelectedItem);
            }, () =>
            {
                return(this.SelectedItem != null);
            });

            this.PropertyChanged             += PuntoDeVenta_PropertyChanged;
            this.Productos.CollectionChanged += Productos_CollectionChanged;
            this.Pagos.CollectionChanged     += Pagos_CollectionChanged;

            if (this.IsInDesignMode)
            {
                this.Serie = "123";
                this.Productos.Add(new Producto {
                    Id = 1, Serie = "001", Marca = "a", Modelo = "b", Talla = "c", Precio = 100, Total = 100, HasImage = true
                });
                this.Productos.Add(new Producto {
                    Id = 2, Serie = "002", Marca = "a", Modelo = "b", Talla = "c", Precio = 100, Total = 1000, HasImage = true
                });
                this.Productos.Add(new Producto {
                    Id = 3, Serie = "003", Marca = "a", Modelo = "b", Talla = "c", Precio = 100, Total = 1234.25m
                });
                this.Productos.Add(new Producto {
                    Id = 4, Serie = "004", Marca = "a", Modelo = "b", Talla = "c", Precio = 100, Total = 12456
                });
                this.Productos.Add(new Producto {
                    Id = 5, Serie = "005", Marca = "a", Modelo = "b", Talla = "c", Precio = 100, Total = 9.99m
                });

                this.Pagos.Add(new Models.Pagos.Pago {
                    FormaPago = FormaPago.EF, Importe = 100
                });
                this.Pagos.Add(new Models.Pagos.Pago {
                    FormaPago = FormaPago.TD, Importe = 30
                });
                this.Pagos.Add(new Models.Pagos.Pago {
                    FormaPago = FormaPago.TD, Importe = 20
                });
            }
        }
コード例 #6
0
        public PagoCreditoViewModel()
        {
            if (!IsInDesignMode)
            {
                _common = new Helpers.CommonHelper();
                _proxy  = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
            }
            this.PropertyChanged += PagoValeViewModel_PropertyChanged;
            this.SearchCommand    = new GalaSoft.MvvmLight.Command.RelayCommand(async() =>
            {
                this.IsBusy          = true;
                this.Tarjetahabiente = await this.Find(this.Search);
                if (this.Tarjetahabiente != null)
                {
                    this.Search = null;
                    if (!this.Tarjetahabiente.Promocion)
                    {
                        this.SelectedPromocion = this.Promociones.FirstOrDefault();
                    }
                }
                else
                {
                    MessageBox.Show("not found");
                }
                this.IsBusy = false;
            }, () => !String.IsNullOrEmpty(this.Search));

            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.Tarjetahabiente    = 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 }
                };
            }
        }
コード例 #7
0
        public NotaManualViewModel()
        {
            this.IsConnected              = false;
            this.Items                    = new ObservableCollection <Models.ProductoNota>();
            this.Items.CollectionChanged += Items_CollectionChanged;
            this.RestoreCommand           = new GalaSoft.MvvmLight.Command.RelayCommand(() =>
            {
                foreach (var item in this.Items)
                {
                    item.Precio = item.Producto.Precio.Value;
                }
            });
            this.SearchCommand = new GalaSoft.MvvmLight.Command.RelayCommand(async() => {
                var item = _data.ScanProducto(this.SerieSearch, this.Sucursal.Clave);
                if (item != null)
                {
                    if (item.Status != Common.Constants.Status.AC)
                    {
                        MessageBox.Show($"status: {item.Status}");
                        return;
                    }

                    await _client.RequestProductoAsync(item.Producto.Serie);
                    this.Items.Add(new Models.ProductoNota {
                        Precio   = item.Producto.Precio.Value,
                        Producto = item.Producto
                    });
                }
                this.SerieSearch = null;
            });
            this.SaveCommand = new GalaSoft.MvvmLight.Command.RelayCommand(() => {
                var items = this.Items.Select(i =>
                                              new Common.Entities.NoteDetalle {
                    Serie    = i.Producto.Serie,
                    Amount   = i.Precio.Value,
                    Comments = i.Comentarios
                });
                var request = new Common.Entities.NoteRequest
                {
                    VendedorId = 0,
                    Sucursal   = this.Sucursal.Clave,
                    Items      = items
                };
                var res = _notes.SaveNote(request);
                MessageBox.Show($"saved: {res}");
            });
            if (this.IsInDesignMode)
            {
                this.SerieSearch = "0000003332927";
                this.Items.Add(new Models.ProductoNota {
                    Precio = 1m, Producto = new Common.Entities.Producto {
                        Id = 1, Marca = "a1", Modelo = "m1", Talla = "t", Precio = 9.99m
                    }
                });
                this.Items.Add(new Models.ProductoNota {
                    Precio = 100m, Comentarios = "comments", Producto = new Common.Entities.Producto {
                        Id = 1, Marca = "a2", Modelo = "m2", Talla = "t", Precio = 100
                    }
                });
                this.Items.Add(new Models.ProductoNota {
                    Precio = 99.9m, Producto = new Common.Entities.Producto {
                        Id = 1, Marca = "a3", Modelo = "m3", Talla = "t", Precio = 1000
                    }
                });
            }
            else
            {
                _client = CommonServiceLocator.ServiceLocator.Current.GetInstance <ServiceClient>();
                _notes  = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.INoteServiceAsync>();
                _data   = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
            }
        }
コード例 #8
0
        public ConsultaProductoViewModel()
        {
            _common            = new Helpers.CommonHelper();
            this.SearchCommand = new RelayCommand(async() =>
            {
                this.IsBusy = true;
                await this.Search();
                this.IsBusy = false;
            }, () => {
                if (string.IsNullOrEmpty(this.Serie))
                {
                    return(true);
                }
                if (string.IsNullOrEmpty(this.Marca) && string.IsNullOrEmpty(this.Modelo))
                {
                    return(true);
                }
                return(false);
            });
            this.FindMedidaCommand = new RelayCommand(async() =>
            {
                this.IsBusy      = true;
                this.Existencias = await _proxy.GetExistenciasAsync(this.Item.Id.Value, this.SelectedMedida);
                this.IsBusy      = false;
            }, () => this.Item != null && this.SelectedMedida != null);

            this.PropertyChanged += ConsultaProductoViewModel_PropertyChanged;
            if (this.IsInDesignMode)
            {
                this.Serie  = "0000003806584";
                this.Marca  = "ADD";
                this.Modelo = "1197";
                this.Item   = new Common.Entities.Producto
                {
                    Serie       = "0000003806584",
                    Marca       = "ADD",
                    Modelo      = "1197",
                    Talla       = "28.5",
                    Precio      = 1799.99m,
                    Corrida     = "A",
                    Electronica = false,
                    ParUnico    = true,
                    MaxPlazos   = 10,
                    Sucursal    = "08"
                };
                this.Corridas = new Common.Entities.MedidasCorridas
                {
                    Corridas = new Common.Entities.TallaPrecio[] {
                        new Common.Entities.TallaPrecio {
                            Corrida = "A", MedidaFin = "14-", MedidaInicio = "29-", Precio = 1099.99m
                        },
                        new Common.Entities.TallaPrecio {
                            Corrida = "B", MedidaFin = "24", MedidaInicio = "29-", Precio = 999m
                        },
                        new Common.Entities.TallaPrecio {
                            Corrida = "C", MedidaFin = "30", MedidaInicio = "39", Precio = 1234.56m
                        }
                    },
                    Medidas = new string[] { "20", "20-", "24-" }
                };
                this.SelectedMedida = "24-";
                this.Existencias    = new Common.Entities.SucursalExistencia[]
                {
                    //new Common.Entities.SucursalExistencia { Sucursal = "08", Count = 10 },
                    //new Common.Entities.SucursalExistencia { Sucursal = "01", Count = 30 },
                    //new Common.Entities.SucursalExistencia { Sucursal = "04", Count = 5 }
                };

                this.ItemStatus = Common.Constants.Status.CA;
                this.Promos     = new Common.Entities.Promocion[] {
                    new Common.Entities.Promocion {
                        PromocionId = 1, Nombre = "promo 1"
                    },
                    new Common.Entities.Promocion {
                        PromocionId = 1, Nombre = "promo 2"
                    },
                    new Common.Entities.Promocion {
                        PromocionId = 1, Nombre = "promo 3"
                    }
                };
            }
            else
            {
                _proxy = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
            }
        }
コード例 #9
0
        public TabsPagosViewModel()
        {
            this.PropertyChanged += TabsPagosViewModel_PropertyChanged;
            if (!this.IsInDesignMode)
            {
                _proxy = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
            }
            this.Pagos = new ObservableCollection <Utilities.Interfaces.IPagoItem>();
            this.Pagos.CollectionChanged += Pagos_CollectionChanged;
            _formas = new Dictionary <FormaPago, Models.FormaPagoKey>()
            {
                { FormaPago.EF, new Models.FormaPagoKey {
                      Enabled = true, Key = Key.F1, Duplicate = false, WithClient = false, ClientRequired = false, Credito = false
                  } },
                { FormaPago.TC, new Models.FormaPagoKey {
                      Enabled = true, Key = Key.F2, Duplicate = true, WithClient = false, ClientRequired = false, Credito = false
                  } },
                { FormaPago.TD, new Models.FormaPagoKey {
                      Enabled = true, Key = Key.F3, Duplicate = true, WithClient = false, ClientRequired = false, Credito = false
                  } },
                { FormaPago.DV, new Models.FormaPagoKey {
                      Enabled = true, Key = Key.F4, Duplicate = true, WithClient = false, ClientRequired = false, Credito = false
                  } },
                { FormaPago.MD, new Models.FormaPagoKey {
                      Enabled = true, Key = Key.F10, Duplicate = false, WithClient = true, ClientRequired = false, Credito = false
                  } },

                { FormaPago.VA, new Models.FormaPagoKey {
                      Enabled = true, Key = Key.F5, Duplicate = false, WithClient = false, ClientRequired = true, Credito = true
                  } },
                { FormaPago.CV, new Models.FormaPagoKey {
                      Enabled = true, Key = Key.F6, Duplicate = true, WithClient = false, ClientRequired = false, Credito = true
                  } },
                { FormaPago.CP, new Models.FormaPagoKey {
                      Enabled = true, Key = Key.F7, Duplicate = false, WithClient = false, ClientRequired = true, Credito = true
                  } },
                { FormaPago.CD, new Models.FormaPagoKey {
                      Enabled = true, Key = Key.F8, Duplicate = false, WithClient = false, ClientRequired = false, Credito = true
                  } },
                { FormaPago.VD, new Models.FormaPagoKey {
                      Enabled = true, Key = Key.F9, Duplicate = false, WithClient = false, ClientRequired = true, Credito = true
                  } },
                { FormaPago.VE, new Models.FormaPagoKey {
                      Enabled = true, Key = Key.F11, Duplicate = false, WithClient = false, ClientRequired = true, Credito = true
                  } },
                { FormaPago.CI, new Models.FormaPagoKey {
                      Enabled = true, Key = Key.F12, Duplicate = true, WithClient = false, ClientRequired = false, Credito = true
                  } },
                { FormaPago.VS, new Models.FormaPagoKey {
                      Enabled = true, Key = Key.J, Duplicate = true, WithClient = false, ClientRequired = false, Credito = true
                  } }
            };
            this.FormasPago        = CollectionViewSource.GetDefaultView(_formas);
            this.FormasPago.Filter = k => {
                var item = (KeyValuePair <FormaPago, Models.FormaPagoKey>)k;

                if (item.Value.Credito)
                {
                    if (this.Pagos.Where(i => _formas[i.FormaPago].Credito).Any())
                    {
                        return(false);
                    }
                }
                if (!item.Value.Duplicate)
                {
                    if (this.Pagos.Where(i => i.FormaPago == item.Key).Any())
                    {
                        return(false);
                    }
                }
                if (item.Value.WithClient)
                {
                    if ((this.Cliente?.Id.HasValue ?? false) && this.ClientConfirmed)
                    {
                        return(item.Value.Enabled);
                    }
                    return(false);
                }
                return(item.Value.Enabled);
            };
            //=========================================== ESTO OMITE LA EJECUCION DE CAJA Y CAMBIO ===========================
            //if (!IsInDesignMode)
            //{
            //    var proxy = CommonServiceLocator.ServiceLocator.Current.GetInstance<Common.ServiceContracts.IDataServiceAsync>();
            //    var formas = proxy.GetFormasPago();
            //    foreach (var item in _formas)
            //    {
            //        item.Value.Enabled = false;
            //    }
            //    foreach (var item in formas)
            //    {
            //        _formas[item].Enabled = true;
            //    }
            //}
            //================================================================================================================

            this.AddFormaCommand = new RelayCommand <FormaPago>(fp => {
                this.ShowPagos = false;
                this.OpenFormaPago(fp);
            }, p => {
                var q = this._formas.Where(i => i.Key == p);
                return(q.Any() && this.Total > 0 && this.Remaining > 0 && q.Single().Value.Enabled);
            });
        }
コード例 #10
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
                });
            }
        }
コード例 #11
0
        public EntregaEfectivoViewModel()
        {
            this.FormasPago       = new ObservableCollection <Models.CajaFormaPagoEntrega>();
            this.PropertyChanged += EntregaEfectivoViewModel_PropertyChanged;
            if (!this.IsInDesignMode)
            {
                _proxy    = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IAdminServiceAsync>();
                _pdata    = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
                this.Data = _proxy.GetEntrega(this.Sucursal.Clave, this.Cajero.Id);
                if (this.Data != null)
                {
                    foreach (var item in this.Data.FormasPago)
                    {
                        var fitem = new Models.CajaFormaPagoEntrega
                        {
                            CajaFormaPago = item
                        };
                        fitem.PropertyChanged += (sender, e) =>
                        {
                            this.SaveCommand.RaiseCanExecuteChanged();
                        };
                        this.FormasPago.Add(fitem);
                    }
                }
            }

            this.SaveCommand = new RelayCommand(() => {
                //var code = Microsoft.VisualBasic.Interaction.InputBox("Codigo Auditor:");
                //var isValid = _proxy.ValidarCodigo(this.Auditor.Id, code);
                //if (!isValid)
                //{
                //    MessageBox.Show("Código no valido.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                //    return;
                //}

                var request = new Common.Entities.EntregaRequest
                {
                    Sucursal   = this.Sucursal.Clave,
                    CajeroId   = this.Cajero.Id,
                    AuditorId  = this.Auditor.Id,
                    Entregar   = this.Entrega.Value,
                    FormasPago = this.FormasPago.Select(i =>
                                                        new Common.Entities.EntregaFormaPago {
                        FormaPago = i.CajaFormaPago.FormaPago,
                        Entregar  = i.Entregar.Value,
                        Amount    = i.EntregarMonto.Value
                    })
                };
                _proxy.Entrega(request);
                MessageBox.Show("ready");
                this.CloseCommand.Execute(null);
            }, () => this.Auditor != null && this.Entrega.HasValue &&
                                                this.FormasPago.All(i => i.Entregar.HasValue && i.EntregarMonto.HasValue));
            this.LoadAuditorCommand = new RelayCommand(() => {
                this.Auditor = _pdata.FindAuditorEntrega(this.SearchAuditor.Value, this.Cajero.Id);
                if (this.Auditor != null)
                {
                    this.SearchAuditor = null;
                }
            }, () => this.SearchAuditor.HasValue);

            if (this.IsInDesignMode)
            {
                this.SearchAuditor = 100;
                this.Auditor       = new Common.Entities.Empleado
                {
                    Nombre          = "nombre",
                    ApellidoMaterno = "materno",
                    ApellidoPaterno = "paterno",
                    Puesto          = (int)Common.Constants.Puesto.SUP
                };
                this.Data = new Common.Entities.CajaFormas {
                    Efectivo   = 1099m,
                    FormasPago = new Common.Entities.CajaFormaPago[] {
                        new Common.Entities.CajaFormaPago {
                            FormaPago = Common.Constants.FormaPago.TC, Unidades = 3, Monto = 299m
                        },
                        new Common.Entities.CajaFormaPago {
                            FormaPago = Common.Constants.FormaPago.VA, Unidades = 100, Monto = 10999m
                        },
                        new Common.Entities.CajaFormaPago {
                            FormaPago = Common.Constants.FormaPago.CP, Unidades = 1000, Monto = 1000000m
                        }
                    }
                };
                foreach (var item in this.Data.FormasPago)
                {
                    this.FormasPago.Add(new Models.CajaFormaPagoEntrega
                    {
                        CajaFormaPago = item
                    });
                }
                this.Entrega = 456.7m;
            }
        }
コード例 #12
0
        public CancelacionViewModel()
        {
            if (!IsInDesignMode)
            {
                _proxy  = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
                _client = new Helpers.ServiceClient();
            }
            _common = new Helpers.CommonHelper();
            this.PropertyChanged             += CancelacionViewModel_PropertyChanged;
            this.Productos                    = new ObservableCollection <Models.CancelProducto>();
            this.Productos.CollectionChanged += Productos_CollectionChanged;

            this.ScanCommand = new GalaSoft.MvvmLight.Command.RelayCommand(async() => {
                this.IsBusy = true;
                await Scan();
                this.IsBusy = false;
            }, () => !string.IsNullOrWhiteSpace(this.SerieSearch));

            this.CancelCommand = new GalaSoft.MvvmLight.Command.RelayCommand(async() => {
                this.IsBusy = true;

                var request = new Common.Entities.CancelSaleRequest
                {
                    Sucursal = this.Venta.Sucursal,
                    Folio    = this.Venta.Folio
                };
                await _client.CancelSaleAsync(request);

                this.Complete();

                this.IsBusy = false;
            }, () => this.Productos.Any() && !this.Productos.Where(i => !i.Scanned).Any());

            if (this.IsInDesignMode)
            {
                this.ErrorMessage = "error";
                this.Venta        = new Models.SucursalFolio {
                    Sucursal = "01", Folio = "414628"
                };
                this.SerieSearch = "0000003343805";
                this.Productos.Add(new Models.CancelProducto {
                    Scanned = true, Producto = new Producto {
                        Id = 1, Serie = "001", Marca = "a", Modelo = "b", Talla = "c", Precio = 100, Total = 100, HasImage = true
                    }
                });
                this.Productos.Add(new Models.CancelProducto {
                    Scanned = true, Producto = new Producto {
                        Id = 2, Serie = "002", Marca = "a", Modelo = "b", Talla = "c", Precio = 100, Total = 1000, HasImage = true
                    }
                });
                this.Productos.Add(new Models.CancelProducto {
                    Scanned = false, Producto = new Producto {
                        Id = 3, Serie = "003", Marca = "a", Modelo = "b", Talla = "c", Precio = 100, Total = 1234.25m
                    }
                });
                this.Productos.Add(new Models.CancelProducto {
                    Scanned = true, Producto = new Producto {
                        Id = 4, Serie = "004", Marca = "a", Modelo = "b", Talla = "c", Precio = 100, Total = 12456
                    }
                });
                this.Productos.Add(new Models.CancelProducto {
                    Scanned = false, Producto = new Producto {
                        Id = 5, Serie = "005", Marca = "a", Modelo = "b", Talla = "c", Precio = 100, Total = 9.99m
                    }
                });
            }
        }