public void ChangeTest() { var request = new Common.Entities.ChangeRequest { Sucursal = "01", Folio = "422168", Items = new Common.Entities.ChangeItem[] { new Common.Entities.ChangeItem { OldItem = "0000003518445", NewItem = "0000003518435" }, new Common.Entities.ChangeItem { OldItem = "0000003583185", NewItem = "0000003579528" }, new Common.Entities.ChangeItem { OldItem = "0000003584922", NewItem = "0000003584920" } } }; var ctx = new DataAccess.SirCoDataContext(); ctx.UpdateSerieStatus("0000003518435", Status.CA, Status.AC, 0); ctx.UpdateSerieStatus("0000003579528", Status.CA, Status.AC, 0); ctx.UpdateSerieStatus("0000003584920", Status.CA, Status.AC, 0); var res = _context.Change(request, 0, request.Sucursal); Assert.AreEqual("027852", res.Devolucion); Assert.AreEqual("434054", res.Venta); }
public Response <ChangeResponse> Change(Common.Entities.ChangeRequest model) { var uid = this.GetUserId(); var suc = this.GetSucursal(); return(this.Reply(() => _process.Change(model, uid, suc))); }
public void CambioPromoDifCorridaPrecioMayor() { /* * 1 NULL 0000003678429 AC 539.00 CTA 682 16- A 15 17 324 * 2 NULL 0000003522471 AC 539.00 CTA 682 15 A 15 17 324 * 3 NULL 0000003776476 AC 589.00 CTA 682 19- B 17- 21 324 * 4 NULL 0000003776472 AC 589.00 CTA 682 18- B 17- 21 324 * 5 NULL 0000003678238 AC 649.00 CTA 682 24 C 21- 26 324 * 6 NULL 0000003676610 AC 649.00 CTA 682 25 C 21- 26 324 */ var compro = "0000003776476"; var pago = 412.3m;//589m; var disponible = 0; var cambio = "0000003678238"; var model = new Common.Entities.SaleRequest() { Sucursal = "01", VendedorId = 132, PromocionesCupones = new Common.Entities.PromocionCuponItem[] { new Common.Entities.PromocionCuponItem { PromocionId = 200 } } }; model.Productos = new Common.Entities.SerieFormasPago[] { new Common.Entities.SerieFormasPago { Serie = compro, FormasPago = new Common.Constants.FormaPago[] { Common.Constants.FormaPago.EF } } }; model.Pagos = new Common.Entities.Pago[] { new Common.Entities.Pago { FormaPago = Common.Constants.FormaPago.EF, Importe = pago } }; _context.RequestProducto(compro, 0); Common.Entities.SaleResponse folio = null; using (ShimsContext.Create()) { System.Fakes.ShimDateTime.UtcNowGet = () => DateTime.Parse("2019-10-20").ToUniversalTime(); folio = _context.Sale(model, 0); } Assert.AreEqual("434054", folio.Folio); var crequest = new Common.Entities.ChangeRequest { Sucursal = "01", Folio = "434054", Items = new Common.Entities.ChangeItem[] { new Common.Entities.ChangeItem { OldItem = compro, NewItem = cambio } }, Pagos = new Common.Entities.Pago[] { new Common.Entities.Pago { FormaPago = FormaPago.EF, Importe = 60 } } }; _context.RequestProducto(cambio, 0); Common.Entities.ChangeResponse cres = null; using (ShimsContext.Create()) { System.Fakes.ShimDateTime.UtcNowGet = () => DateTime.Parse("2019-10-21").ToUniversalTime(); cres = _context.Change(crequest, 0, "08"); } Assert.AreEqual("295595", cres.Venta); Assert.AreEqual("023287", cres.Devolucion); var ctx = new DataAccess.SirCoPVDataContext(); var dev = ctx.Devoluciones.Where(i => i.sucursal == "08" && i.devolvta == "023287").Single(); Assert.AreEqual(disponible, dev.disponible); }
public void ReturnMismaCorrida2() { /* * 1 NULL 0000003678429 AC 539.00 CTA 682 16- A 15 17 324 * 2 NULL 0000003522471 AC 539.00 CTA 682 15 A 15 17 324 * 3 NULL 0000003776476 AC 589.00 CTA 682 19- B 17- 21 324 * 4 NULL 0000003776472 AC 589.00 CTA 682 18- B 17- 21 324 * 5 NULL 0000003678238 AC 649.00 CTA 682 24 C 21- 26 324 * 6 NULL 0000003676610 AC 649.00 CTA 682 25 C 21- 26 324 */ var model = new Common.Entities.SaleRequest() { Sucursal = "01", VendedorId = 132 }; model.Productos = new Common.Entities.SerieFormasPago[] { new Common.Entities.SerieFormasPago { Serie = "0000003678429", FormasPago = new Common.Constants.FormaPago[] { Common.Constants.FormaPago.EF } } }; model.Pagos = new Common.Entities.Pago[] { new Common.Entities.Pago { FormaPago = Common.Constants.FormaPago.EF, Importe = 539 } }; _context.RequestProducto("0000003678429", 0); Common.Entities.SaleResponse folio = null; using (ShimsContext.Create()) { System.Fakes.ShimDateTime.NowGet = () => { return(DateTime.Parse("2019-03-06")); }; folio = _context.Sale(model, 0); } Assert.AreEqual("434054", folio.Folio); var crequest = new Common.Entities.ChangeRequest { Sucursal = "01", Folio = "434054", Items = new Common.Entities.ChangeItem[] { new Common.Entities.ChangeItem { OldItem = "0000003678429", NewItem = "0000003522471" } } }; _context.RequestProducto("0000003522471", 0); Common.Entities.ChangeResponse cres = null; using (ShimsContext.Create()) { System.Fakes.ShimDateTime.NowGet = () => { return(DateTime.Parse("2019-03-07")); }; cres = _context.Change(crequest, 0, "08"); } Assert.AreEqual("295595", cres.Venta); Assert.AreEqual("023287", cres.Devolucion); var ctx = new DataAccess.SirCoPVDataContext(); var dev = ctx.Devoluciones.Where(i => i.sucursal == "08" && i.devolvta == "023287").Single(); Assert.AreEqual(0, dev.disponible); }
public void CambioMismaCorridaCambioPrecioMayorPromocion() { /* * 1 NULL 0000003678429 AC 539.00 CTA 682 16- A 15 17 324 * 2 NULL 0000003522471 AC 539.00 CTA 682 15 A 15 17 324 * 3 NULL 0000003776476 AC 589.00 CTA 682 19- B 17- 21 324 * 4 NULL 0000003776472 AC 589.00 CTA 682 18- B 17- 21 324 * 5 NULL 0000003678238 AC 649.00 CTA 682 24 C 21- 26 324 * 6 NULL 0000003676610 AC 649.00 CTA 682 25 C 21- 26 324 */ var model = new Common.Entities.SaleRequest() { Sucursal = "01", VendedorId = 132 }; model.Productos = new Common.Entities.SerieFormasPago[] { new Common.Entities.SerieFormasPago { Serie = "0000003678429", FormasPago = new Common.Constants.FormaPago[] { Common.Constants.FormaPago.EF } } }; model.Pagos = new Common.Entities.Pago[] { new Common.Entities.Pago { FormaPago = Common.Constants.FormaPago.EF, Importe = 539 } }; _context.RequestProducto("0000003678429", 0); Common.Entities.SaleResponse folio = null; using (ShimsContext.Create()) { System.Fakes.ShimDateTime.NowGet = () => { return(DateTime.Parse("2019-03-06")); }; folio = _context.Sale(model, 0); } Assert.AreEqual("434054", folio.Folio); var ctx = new DataAccess.SirCoPVDataContext(); var det = ctx.VentasDetalle.Where(i => i.sucursal == model.Sucursal && i.venta == "434054" && i.serie == "0000003678429").Single(); det.idpromocion = 18; //prueba det.precdesc = 269.5m; //539 / 2 = 50% ctx.SaveChanges(); var sctx = new DataAccess.SirCoDataContext(); var cor = sctx.Corridas.Where(i => i.marca == "CTA" && i.estilon.Trim() == "682" && i.corrida == "A").Single(); cor.precio = 600; sctx.SaveChanges(); var crequest = new Common.Entities.ChangeRequest { Sucursal = "01", Folio = "434054", Items = new Common.Entities.ChangeItem[] { new Common.Entities.ChangeItem { OldItem = "0000003678429", NewItem = "0000003522471" } } }; _context.RequestProducto("0000003522471", 0); Common.Entities.ChangeResponse cres = null; using (ShimsContext.Create()) { System.Fakes.ShimDateTime.NowGet = () => { return(DateTime.Parse("2019-03-07")); }; cres = _context.Change(crequest, 0, "08"); } Assert.AreEqual("295595", cres.Venta); Assert.AreEqual("023287", cres.Devolucion); var dev = ctx.Devoluciones.Where(i => i.sucursal == "08" && i.devolvta == "023287").Single(); Assert.AreEqual(0m, dev.disponible); var vdet = ctx.VentasDetalle.Where(i => i.sucursal == "08" && i.venta == "295595" && i.serie == "0000003522471").Single(); Assert.AreEqual(539m, vdet.precio); Assert.AreEqual(269.5m, vdet.precdesc); }
public CambioViewModel() { this.PropertyChanged += CambioViewModel_PropertyChanged; _common = new Helpers.CommonHelper(); this.Productos = new ObservableCollection <Models.ProductoCambio>(); this.Productos.CollectionChanged += Productos_CollectionChanged; this.Pagos.CollectionChanged += Pagos_CollectionChanged; if (!this.IsInDesignMode) { _reports = new Helpers.ReportsHelper(); _client = new Helpers.ServiceClient(); _proxy = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>(); _mapper = CommonServiceLocator.ServiceLocator.Current.GetInstance <AutoMapper.IMapper>(); } //this.PagarCommand = new RelayCommand(() => { // this.ShowPagos = true; //}, () => this.Total > 0 && this.Remaining > 0); //this.AddFormaCommand = new RelayCommand<FormaPago>(fp => { // this.ShowPagos = false; // Messenger.Default.Send( // new Messages.OpenPago // { // GID = this.GID, // FormaPago = fp, // Total = this.Remaining, // Caja = this, // ClientId = this.Cliente?.Id, // ProductosPlazos = this.Productos.Where(i => i.MaxPlazos.HasValue && i.MaxPlazos > 0) // }); //}, p => { // var q = this._formas.Where(i => i.Key == p); // return q.Any() && this.Total > 0 && this.Remaining > 0 && q.Single().Value.Enabled; //}); this.AddPagoCommand = new RelayCommand(() => { this.ShowPagos = true; }, () => this.Remaining > 0); this.ScanCommand = new GalaSoft.MvvmLight.Command.RelayCommand(async() => { this.IsBusy = true; var ser = _common.PrepareSerie(this.SerieSearch); await this.Scan(ser); this.AddPagoCommand.RaiseCanExecuteChanged(); this.SaveCommand.RaiseCanExecuteChanged(); this.IsBusy = false; }, () => !string.IsNullOrEmpty(this.SerieSearch)); this.SaveCommand = new GalaSoft.MvvmLight.Command.RelayCommand(async() => { this.IsBusy = true; var request = new Common.Entities.ChangeRequest { Sucursal = this.Venta.Sucursal, Folio = this.Venta.Folio, Items = this.Productos.Select(i => new Common.Entities.ChangeItem { OldItem = i.OldItem.Serie, NewItem = i.NewItem.Serie }), Pagos = this.PreparePagos(), Razones = this.Productos.ToDictionary(i => i.OldItem.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.Result = await _client.ChangeAsync(request); this.IsBusy = false; }, () => this.Productos.Any() && !this.Productos.Where(i => !i.Complete).Any() && this.Remaining <= 0); this.RemovePagoCommand = new RelayCommand(() => { //if (!_formas[this.SelectedPago.FormaPago].Duplicate) //{ // _formas[this.SelectedPago.FormaPago].Enabled = true; // this.FormasPago.Refresh(); //} //_ls.RemovePago(this.SelectedPago.Id); this.Pagos.Remove(this.SelectedPago); }, () => this.SelectedPago != null); this.LoadClienteCommand = new RelayCommand(() => { Messenger.Default.Send( new Utilities.Messages.OpenModal { Name = Utilities.Constants.Modals.cliente, GID = this.GID }); }); this.ClearClienteCommand = new RelayCommand(() => { this.Cliente = null; this.NuevoCliente = null; 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(); }); this.PrintCommand = new RelayCommand <string>(rpt => { if (rpt == "venta") { _reports.Compra(this.Sucursal.Clave, this.Result.Venta); } if (rpt == "devolucion") { _reports.Devolucion(this.Sucursal.Clave, this.Result.Devolucion); } }, rpt => this.IsComplete); if (this.IsInDesignMode) { this.Result = new ChangeResponse { Devolucion = "111", Venta = "222", Cliente = 333 }; this.SerieSearch = "0000003342601"; this.Venta = new Models.SucursalFolio { Sucursal = "01", Folio = "000123" }; this.Productos.Add(new Models.ProductoCambio { OldItem = new ProductoDevolucion { Sucursal = "01", Folio = "123", Serie = "0000003413693", Marca = "FFF", Modelo = "2608", Talla = "27.5", Precio = 799 }, NewItem = new Models.Producto { Serie = "0000003420542", Marca = "AAA", Modelo = "1234", Talla = "28", Precio = 123.45m } }); this.Productos.Add(new Models.ProductoCambio { OldItem = null, NewItem = new Models.Producto { Serie = "0000003420542", Marca = "AAA", Modelo = "1234", Talla = "28", Precio = 123.45m } }); this.Productos.Add(new Models.ProductoCambio { OldItem = new ProductoDevolucion { Sucursal = "01", Folio = "123", Serie = "0000003413693", Marca = "FFF", Modelo = "2608", Talla = "27.5", Precio = 799 }, NewItem = null }); this.NuevoCliente = new Models.NuevoCliente { Nombre = "nom", ApPaterno = "ap pa", ApMaterno = "ap ma" }; } }
public void ReturnDifCorridaDifPrecioDevolucion() { /* * ('0000003391871', 'venta') * ,('0000003391872', 'misma corrida') * ,('0000003485731', 'dif corrida, mismo precio') * ,('0000003556980', 'dif corrida, precio mayor') */ var sctx = new DataAccess.SirCoDataContext(); sctx.Database.ExecuteSqlCommand("update serie set status = 'AC' where serie = @serie", new System.Data.SqlClient.SqlParameter("@serie", "0000003556980")); var model = new Common.Entities.SaleRequest() { Sucursal = "01", VendedorId = 132 }; model.Productos = new Common.Entities.SerieFormasPago[] { new Common.Entities.SerieFormasPago { Serie = "0000003556980", FormasPago = new Common.Constants.FormaPago[] { Common.Constants.FormaPago.EF } } }; model.Pagos = new Common.Entities.Pago[] { new Common.Entities.Pago { FormaPago = Common.Constants.FormaPago.EF, Importe = 359 } }; _context.RequestProducto("0000003556980", 0); Common.Entities.SaleResponse folio = null; using (ShimsContext.Create()) { System.Fakes.ShimDateTime.NowGet = () => { return(DateTime.Parse("2019-03-06")); }; folio = _context.Sale(model, 0); } Assert.AreEqual("434054", folio.Folio); var crequest = new Common.Entities.ChangeRequest { Sucursal = "01", Folio = "434054", Items = new Common.Entities.ChangeItem[] { new Common.Entities.ChangeItem { OldItem = "0000003556980", NewItem = "0000003391871" } } }; _context.RequestProducto("0000003391871", 0); Common.Entities.ChangeResponse cres = null; using (ShimsContext.Create()) { System.Fakes.ShimDateTime.NowGet = () => { return(DateTime.Parse("2019-03-07")); }; cres = _context.Change(crequest, 0, "08"); } Assert.AreEqual("295595", cres.Venta); Assert.AreEqual("023287", cres.Devolucion); var ctx = new DataAccess.SirCoPVDataContext(); var dev = ctx.Devoluciones.Where(i => i.sucursal == "08" && i.devolvta == "023287").Single(); Assert.AreEqual(30, dev.disponible); }
public void ReturnDifCorridaMismoPrecio() { /* * ('0000003391871', 'venta') * ,('0000003391872', 'misma corrida') * ,('0000003485731', 'dif corrida, mismo precio') * ,('0000003556980', 'dif corrida, precio mayor') */ var ctx = new DataAccess.SirCoPVDataContext(); var sctx = new DataAccess.SirCoDataContext(); var cor = sctx.Corridas.Where(i => i.marca == "KLI" && i.estilon == " 1" && i.corrida == "D").Single(); cor.precio = 339; sctx.SaveChanges(); var model = new Common.Entities.SaleRequest() { Sucursal = "01", VendedorId = 132 }; model.Productos = new Common.Entities.SerieFormasPago[] { new Common.Entities.SerieFormasPago { Serie = "0000003391871", FormasPago = new Common.Constants.FormaPago[] { Common.Constants.FormaPago.EF } } }; model.Pagos = new Common.Entities.Pago[] { new Common.Entities.Pago { FormaPago = Common.Constants.FormaPago.EF, Importe = 339 } }; _context.RequestProducto("0000003391871", 0); Common.Entities.SaleResponse folio = null; using (ShimsContext.Create()) { System.Fakes.ShimDateTime.NowGet = () => { return(DateTime.Parse("2019-03-06")); }; folio = _context.Sale(model, 0); } Assert.AreEqual("434054", folio.Folio); var crequest = new Common.Entities.ChangeRequest { Sucursal = "01", Folio = "434054", Items = new Common.Entities.ChangeItem[] { new Common.Entities.ChangeItem { OldItem = "0000003391871", NewItem = "0000003485731" } } }; _context.RequestProducto("0000003485731", 0); Common.Entities.ChangeResponse cres = null; using (ShimsContext.Create()) { System.Fakes.ShimDateTime.NowGet = () => { return(DateTime.Parse("2019-03-07")); }; cres = _context.Change(crequest, 0, "08"); } Assert.AreEqual("295595", cres.Venta); Assert.AreEqual("023287", cres.Devolucion); var dev = ctx.Devoluciones.Where(i => i.sucursal == "08" && i.devolvta == "023287").Single(); Assert.AreEqual(0, dev.disponible); }