Beispiel #1
0
        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);
        }
Beispiel #2
0
        public void CancelFormaPago_CD()
        {
            var sucursal = "01";

            //var sucursalId = 1;
            using (ShimsContext.Create())
            {
                System.Fakes.ShimDateTime.NowGet = () => { return(DateTime.Parse("2019-09-01")); };

                var data = new List <DataAccess.SirCoControl.Sucursal> {
                    new DataAccess.SirCoControl.Sucursal {
                        idsucursal = 1, sucursal = "01", cajas = 434045
                    }
                }.AsQueryable();

                var mockSet = new Mock <DbSet <DataAccess.SirCoControl.Sucursal> >();
                mockSet.As <IQueryable <DataAccess.SirCoControl.Sucursal> >().Setup(m => m.Provider).Returns(data.Provider);
                mockSet.As <IQueryable <DataAccess.SirCoControl.Sucursal> >().Setup(m => m.Expression).Returns(data.Expression);
                mockSet.As <IQueryable <DataAccess.SirCoControl.Sucursal> >().Setup(m => m.ElementType).Returns(data.ElementType);
                mockSet.As <IQueryable <DataAccess.SirCoControl.Sucursal> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());

                DataAccess.Fakes.ShimSirCoControlDataContext.AllInstances.SucursalesGet = (sctx) => {
                    return(mockSet.Object);
                };

                var pserie  = "0000003668367";
                var distrib = "005961";
                var prod    = _sale.ScanProducto(pserie, sucursal);
                Assert.IsNotNull(prod);

                var ctx = new DataAccess.SirCoDataContext();
                ctx.UpdateSerieStatus("0000003668367", Status.CA, Status.AC, 0);

                var dis = _sale.FindTarjetahabiente(distrib);

                var ncliente = new Common.Entities.Cliente
                {
                    DistribuidorId = 5730
                };

                //var cid = _process.AddCliente(ncliente);
                //Assert.IsNotNull(cid);

                var model = new Common.Entities.SaleRequest()
                {
                    Sucursal   = sucursal,
                    VendedorId = 0,
                    Cliente    = ncliente
                };
                model.Productos = new Common.Entities.SerieFormasPago[] {
                    new Common.Entities.SerieFormasPago {
                        Serie = pserie, FormasPago = new Common.Constants.FormaPago[] { Common.Constants.FormaPago.VA }
                    }
                };
                model.Pagos = new List <Common.Entities.Pago> {
                    new Common.Entities.Pago {
                        FormaPago    = FormaPago.CD,
                        Importe      = prod.Producto.Precio.Value,
                        Distribuidor = distrib,
                        Plazos       = 3
                    }
                };

                var ctxc = new SirCoPOS.DataAccess.SirCoCreditoDataContext();
                var ds   = ctxc.Distribuidores.Where(i => i.distrib == distrib).Single();
                Assert.AreEqual(11564.00M, ds.disponible);
                Assert.AreEqual(3436.00M, ds.saldo);

                var folio = _context.Sale(model, 0);

                Assert.AreEqual("434046", folio.Folio);
                ctxc.Entry(ds).Reload();
                Assert.AreEqual(11564.00M - prod.Producto.Precio.Value, ds.disponible);
                Assert.AreEqual(3436.00M + prod.Producto.Precio.Value, ds.saldo);

                var crequest = new Common.Entities.CancelSaleRequest
                {
                    Sucursal = sucursal,
                    Folio    = "434046"
                };
                _context.CancelSale(crequest, 0);

                ctxc.Entry(ds).Reload();
                Assert.AreEqual(11564.00M, ds.disponible);
                Assert.AreEqual(3436.00M, ds.saldo);
            }
        }
Beispiel #3
0
        public void CancelFormaPago_VD()
        {
            var sucursal = "01";

            using (ShimsContext.Create())
            {
                System.Fakes.ShimDateTime.NowGet = () => { return(DateTime.Parse("2019-09-01")); };

                var data = new List <DataAccess.SirCoControl.Sucursal> {
                    new DataAccess.SirCoControl.Sucursal {
                        idsucursal = 1, sucursal = "01", cajas = 434045
                    }
                }.AsQueryable();

                var mockSet = new Mock <DbSet <DataAccess.SirCoControl.Sucursal> >();
                mockSet.As <IQueryable <DataAccess.SirCoControl.Sucursal> >().Setup(m => m.Provider).Returns(data.Provider);
                mockSet.As <IQueryable <DataAccess.SirCoControl.Sucursal> >().Setup(m => m.Expression).Returns(data.Expression);
                mockSet.As <IQueryable <DataAccess.SirCoControl.Sucursal> >().Setup(m => m.ElementType).Returns(data.ElementType);
                mockSet.As <IQueryable <DataAccess.SirCoControl.Sucursal> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());

                DataAccess.Fakes.ShimSirCoControlDataContext.AllInstances.SucursalesGet = (sctx) => {
                    return(mockSet.Object);
                };

                var pserie = "0000003668367";
                var nvale  = "123";
                var prod   = _sale.ScanProducto(pserie, sucursal);
                Assert.IsNotNull(prod);
                //var vale = _context.CheckVale(nvale);

                var ctx = new DataAccess.SirCoDataContext();
                ctx.UpdateSerieStatus("0000003668367", Status.CA, Status.AC, 0);

                var ncliente = new Common.Entities.Cliente
                {
                    Id = 810374
                };

                //var cid = _process.AddCliente(ncliente);
                //Assert.IsNotNull(cid);

                var model = new Common.Entities.SaleRequest()
                {
                    Sucursal   = sucursal,
                    VendedorId = 0,
                    Cliente    = ncliente
                };
                model.Productos = new Common.Entities.SerieFormasPago[] {
                    new Common.Entities.SerieFormasPago {
                        Serie = pserie, FormasPago = new Common.Constants.FormaPago[] { Common.Constants.FormaPago.VA }
                    }
                };
                model.Pagos = new List <Common.Entities.Pago> {
                    new Common.Entities.Pago {
                        FormaPago    = FormaPago.VD,
                        Importe      = prod.Producto.Precio.Value,
                        Vale         = nvale,
                        Plazos       = 13,
                        FechaAplicar = DateTime.Parse("2019-11-05")
                                       //ClienteId = cid,
                    }
                };

                var ctxa = new DataAccess.SirCoAPPDataContext();
                var vd   = ctxa.ValesDigital.Where(i => i.idvaledigital == 2).Single();
                Assert.AreEqual(2000, vd.disponible);

                var ctxc = new DataAccess.SirCoCreditoDataContext();
                var dis  = ctxc.Distribuidores.Where(i => i.distrib == "003763").Single();
                Assert.AreEqual(24057.39m, dis.saldo);
                Assert.AreEqual(73442.61m, dis.disponible);

                var folio = _context.Sale(model, 0);

                Assert.AreEqual("434046", folio.Folio);

                ctxa.Entry(vd).Reload();
                Assert.AreEqual(2000 - prod.Producto.Precio.Value, vd.disponible);
                ctxc.Entry(dis).Reload();
                Assert.AreEqual(24057.39m + prod.Producto.Precio.Value, dis.saldo);
                Assert.AreEqual(73442.61m - prod.Producto.Precio.Value, dis.disponible);

                var crequest = new Common.Entities.CancelSaleRequest
                {
                    Sucursal = sucursal,
                    Folio    = "434046"
                };
                _context.CancelSale(crequest, 0);

                ctxa.Entry(vd).Reload();
                Assert.AreEqual(2000, vd.disponible);
                ctxc.Entry(dis).Reload();
                Assert.AreEqual(24057.39m, dis.saldo);
                Assert.AreEqual(73442.61m, dis.disponible);
            }
        }
Beispiel #4
0
        public void CancelFormaPago_MD()
        {
            var sucursal = "01";

            using (ShimsContext.Create())
            {
                System.Fakes.ShimDateTime.NowGet = () => { return(DateTime.Parse("2019-09-01")); };

                var data = new List <DataAccess.SirCoControl.Sucursal> {
                    new DataAccess.SirCoControl.Sucursal {
                        idsucursal = 1, sucursal = "01", cajas = 434045
                    }
                }.AsQueryable();

                var mockSet = new Mock <DbSet <DataAccess.SirCoControl.Sucursal> >();
                mockSet.As <IQueryable <DataAccess.SirCoControl.Sucursal> >().Setup(m => m.Provider).Returns(data.Provider);
                mockSet.As <IQueryable <DataAccess.SirCoControl.Sucursal> >().Setup(m => m.Expression).Returns(data.Expression);
                mockSet.As <IQueryable <DataAccess.SirCoControl.Sucursal> >().Setup(m => m.ElementType).Returns(data.ElementType);
                mockSet.As <IQueryable <DataAccess.SirCoControl.Sucursal> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());

                DataAccess.Fakes.ShimSirCoControlDataContext.AllInstances.SucursalesGet = (sctx) => {
                    return(mockSet.Object);
                };

                var pserie = "0000003668367";
                var prod   = _sale.ScanProducto(pserie, sucursal);
                Assert.IsNotNull(prod);
                //var vale = _context.CheckVale(nvale);

                var ctx = new DataAccess.SirCoDataContext();
                ctx.UpdateSerieStatus("0000003668367", Status.CA, Status.AC, 0);

                var ncliente = new Common.Entities.Cliente
                {
                    Id = 810374
                };

                //var cid = _process.AddCliente(ncliente);
                //Assert.IsNotNull(cid);

                var model = new Common.Entities.SaleRequest()
                {
                    Sucursal   = sucursal,
                    VendedorId = 0,
                    Cliente    = ncliente
                };
                model.Productos = new Common.Entities.SerieFormasPago[] {
                    new Common.Entities.SerieFormasPago {
                        Serie = pserie, FormasPago = new Common.Constants.FormaPago[] { Common.Constants.FormaPago.VA }
                    }
                };
                model.Pagos = new List <Common.Entities.Pago> {
                    new Common.Entities.Pago {
                        FormaPago = FormaPago.MD,
                        Importe   = 149
                    }
                };

                var folio = _context.Sale(model, 0);

                Assert.AreEqual("434046", folio.Folio);

                var ctxa   = new DataAccess.SirCoAPPDataContext();
                var dinero = ctxa.Dineros.Where(i => i.idsucursal == 1 && i.cliente == "144666").Single();
                var det    = dinero.Detalles.OrderByDescending(i => i.vigencia).ToArray();

                Assert.AreEqual(151, dinero.saldo);
                Assert.AreEqual(0, det[0].saldo);
                Assert.AreEqual(51, det[1].saldo);
                Assert.AreEqual(100, det[2].saldo);

                var request = new Common.Entities.CancelSaleRequest
                {
                    Sucursal = sucursal,
                    Folio    = "434046"
                };
                _context.CancelSale(request, 0);

                var ctxa2 = new DataAccess.SirCoAPPDataContext();
                dinero = ctxa2.Dineros.Where(i => i.idsucursal == 1 && i.cliente == "144666").Single();
                det    = dinero.Detalles.OrderByDescending(i => i.vigencia).ToArray();

                Assert.AreEqual(300, dinero.saldo);
                Assert.AreEqual(100, det[0].saldo);
                Assert.AreEqual(100, det[1].saldo);
                Assert.AreEqual(100, det[2].saldo);
            }
        }