Пример #1
0
        public void CancelFormaPago_DV_CancelDV()
        {
            /*
             * 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);

            var sctx   = new DataAccess.SirCoDataContext();
            var oserie = sctx.Series.Where(i => i.serie == "0000003678429").Single();

            Assert.AreEqual("CA", oserie.status);

            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);

            sctx.Entry(oserie).Reload();
            Assert.AreEqual("BA", oserie.status);

            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);

            sctx.Entry(oserie).Reload();
            Assert.AreEqual("AC", oserie.status);

            var ctx = new DataAccess.SirCoPVDataContext();
            var dev = ctx.Devoluciones.Where(i => i.sucursal == "08" && i.devolvta == "023287").Single();

            Assert.AreEqual(0, dev.disponible);

            var cancel = new Common.Entities.CancelSaleRequest
            {
                Sucursal = "08",
                Folio    = "295595"
            };

            using (ShimsContext.Create())
            {
                System.Fakes.ShimDateTime.NowGet = () => { return(DateTime.Parse("2019-03-07")); };
                _context.CancelSale(cancel, 0);
            }

            ctx.Entry(dev).Reload();
            Assert.AreEqual(539, dev.disponible);

            using (ShimsContext.Create())
            {
                System.Fakes.ShimDateTime.NowGet = () => { return(DateTime.Parse("2019-03-07")); };
                _context.CancelReturn(dev.sucursal, dev.devolvta, 0);
            }
            ctx.Entry(dev).Reload();
            Assert.AreEqual("ZC", dev.estatus);

            sctx.Entry(oserie).Reload();
            Assert.AreEqual("BA", oserie.status);
        }
Пример #2
0
        public ActionResult Detalle(string sucursal, string folio)
        {
            var ctx  = new DataAccess.SirCoPVDataContext();
            var ctxc = new DataAccess.SirCoCreditoDataContext();
            var item = ctx.Devoluciones.Where(i => i.sucursal == sucursal && i.devolvta == folio).SingleOrDefault();

            if (item == null)
            {
                return(HttpNotFound());
            }

            var model = new Models.Devolucion
            {
                Sucursal   = item.sucursal,
                Folio      = item.devolvta,
                Fecha      = item.fecha,
                Estatus    = item.estatus,
                Disponible = item.disponible,
                Total      = item.Detalles.Sum(i => i.precdesc)
            };

            model.VentaSucursal = item.referencia.Substring(0, 2);
            model.VentaFolio    = item.referencia.Substring(2);

            Persona cliente = null;

            if (item.idcliente.HasValue)
            {
                var cli = ctxc.Clientes.Where(i => i.idcliente == item.idcliente).SingleOrDefault();
                if (cli == null)
                {
                    cliente = new Persona {
                        Id = item.idcliente.Value
                    }
                }
                ;
                else
                {
                    cliente = new Persona
                    {
                        Id        = cli.idcliente,
                        Nombre    = cli.nombre,
                        ApPaterno = cli.appaterno,
                        ApMaterno = cli.apmaterno
                    };
                }
            }
            model.Cliente = cliente;

            var plist = new List <Models.Producto>();

            foreach (var i in item.Detalles)
            {
                if (i.idrazon.HasValue)
                {
                    ctx.Entry(i).Reference(k => k.Razon).Load();
                }

                plist.Add(new Models.Producto
                {
                    Renglon = i.renglon,
                    Marca   = i.marca,
                    Modelo  = i.estilon,
                    Serie   = i.serie,
                    Precio  = i.precio,
                    Pago    = i.precdesc,

                    Notas     = i.notas,
                    NotaRazon = i.idrazon.HasValue ? i.Razon.descripcion : null
                });
            }
            model.Detalle = plist;

            var ctxi = new DataAccess.SirCoImgDataContext();

            foreach (var det in model.Detalle)
            {
                var q = ctxi.Imagenes.Where(i => i.Marca == det.Marca && i.Estilon == det.Modelo);
                det.HasImage = q.Any();
            }

            var dev = $"{model.Sucursal}{model.Folio}";
            var qpd = ctx.PagosDetalle.Where(i => i.idformapago == (int)Common.Constants.FormaPago.DV &&
                                             i.referencia == dev);

            model.Ventas = qpd.Select(i => new Models.DevolucionVenta
            {
                Sucursal = i.sucursal,
                Folio    = i.pago,
                Importe  = i.importe
            });
            return(View(model));
        }
Пример #3
0
        public ActionResult Detalle(string sucursal, string folio)
        {
            var ctx  = new DataAccess.SirCoPVDataContext();
            var ctxc = new DataAccess.SirCoCreditoDataContext();
            var item = ctx.Ventas.Where(i => i.sucursal == sucursal && i.venta == folio).SingleOrDefault();

            if (item == null)
            {
                return(HttpNotFound());
            }

            Persona cliente = null;

            if (item.idcliente.HasValue)
            {
                var cli = ctxc.Clientes.Where(i => i.idcliente == item.idcliente).SingleOrDefault();
                if (cli == null)
                {
                    cliente = new Persona {
                        Id = item.idcliente.Value
                    }
                }
                ;
                else
                {
                    cliente = new Persona
                    {
                        Id        = cli.idcliente,
                        Nombre    = cli.nombre,
                        ApPaterno = cli.appaterno,
                        ApMaterno = cli.apmaterno
                    };
                }
            }

            var model = new Models.Venta
            {
                Sucursal = item.sucursal,
                Folio    = item.venta,
                Fecha    = item.fum,
                Estatus  = item.estatus,
                Cajero   = this.GetEmpleado(item.idcajero),
                Vendedor = this.GetEmpleado(item.idvendedor),
                Cliente  = cliente
            };
            var plist = new List <Models.Producto>();

            foreach (var i in item.Detalles)
            {
                if (i.idrazon.HasValue)
                {
                    ctx.Entry(i).Reference(k => k.NotaRazon).Load();
                }
                plist.Add(new Models.Producto
                {
                    Renglon   = i.renglon,
                    Marca     = i.marca,
                    Modelo    = i.estilon,
                    Serie     = i.serie,
                    Precio    = i.precio,
                    Pago      = i.precdesc,
                    Comments  = i.descuentoespecialdesc,
                    Notas     = i.notas,
                    NotaRazon = i.idrazon.HasValue ? i.NotaRazon.descripcion : null
                });
            }
            model.Detalle = plist;

            var ctxi = new DataAccess.SirCoImgDataContext();

            foreach (var det in model.Detalle)
            {
                var q = ctxi.Imagenes.Where(i => i.Marca == det.Marca && i.Estilon == det.Modelo);
                det.HasImage = q.Any();
            }

            model.ContraVales = ctxc.ContraVales.Where(i => i.sucursal == item.sucursal && i.referenc == item.venta)
                                .Select(i => new Models.ContraVale {
                Folio = i.cvale, Disponible = i.saldo, Importe = i.importe
            });

            model.Devoluciones = ctx.Devoluciones.Where(i => i.referencia == item.sucursal + item.venta)
                                 .Select(i => new Models.DevolucionVenta {
                Sucursal = i.sucursal,
                Folio    = i.devolvta,
                Importe  = i.disponible
            });

            model.Pago = new Models.Pago
            {
                Fecha   = item.Pago.fum,
                Estatus = item.Pago.estatus
            };
            var pagos = new List <Models.PagoDetalle>();

            foreach (var i in item.Pago.Detalle)
            {
                var pd = new Models.PagoDetalle
                {
                    FormaPago = i.idformapago,
                    Importe   = i.importe
                };
                if (pd.FormaPago == (int)Common.Constants.FormaPago.DV &&
                    i.referencia != null)
                {
                    pd.Sucursal = i.referencia.Substring(0, 2);
                    pd.Folio    = i.referencia.Substring(2);
                }
                else if ((pd.FormaPago == (int)Common.Constants.FormaPago.TC || pd.FormaPago == (int)Common.Constants.FormaPago.TD) &&
                         i.terminacion != null)
                {
                    pd.Terminacion = i.terminacion;
                    pd.Transaccion = i.transaccion;
                }
                else if (pd.FormaPago == (int)Common.Constants.FormaPago.VA)
                {
                    pd.Folio = i.vale;
                    var qpp = ctxc.PlanPagos.Where(k => k.sucursal == sucursal && k.nota == folio && k.vale == i.vale);
                    if (qpp.Any())
                    {
                        ViewBag.hasPlanPagos = true;
                        var list = new List <Models.PlanPago>();
                        model.PlanPago = list;
                        foreach (var pp in qpp)
                        {
                            //pd.Sucursal = pp.sucursal;
                            //pd.Folio = pp.vale;

                            list.Add(new Models.PlanPago
                            {
                                Vale    = pp.vale,
                                Detalle = pp.Detalle.Select(k => new Models.PlanPagoDetalle
                                {
                                    Fecha   = k.fechaaplicar,
                                    Importe = k.importe,
                                    Number  = k.pago
                                })
                            });
                        }
                    }
                }
                pagos.Add(pd);
            }
            model.Pago.Detalle = pagos;

            return(View(model));
        }