Beispiel #1
0
        public void TestGuardarVenta()

        {
            bool                datoEsperado    = true;
            DetalleOrden        unDetalleOrden  = new DetalleOrden();
            OrdenDeVenta        objOrdenDeVenta = new OrdenDeVenta();
            List <Producto>     ListaProducto   = ProductoBLL.BuscarProducto("Vino");
            List <DetalleOrden> ListaDetalles   = new List <DetalleOrden>();
            Efectivo            objEfectivo     = new Efectivo();
            Usuario             unUSuario       = new Usuario();
            Producto            objProducto     = ListaProducto[0];

            unDetalleOrden.Producto = objProducto;
            unDetalleOrden.Cantidad = 2;
            ListaDetalles.Add(unDetalleOrden);
            objOrdenDeVenta.Detalles = ListaDetalles;

            objOrdenDeVenta.MetodoDePago = objEfectivo;
            List <Cliente> Clientes = ClienteBLL.BuscarClientesPorDNI("38567566");

            Cliente ObjCliente = Clientes[0];

            objOrdenDeVenta.Cliente = ObjCliente;

            unUSuario.ID = 1;
            objOrdenDeVenta.UsuarioCreador = unUSuario;
            Assert.AreEqual(datoEsperado, VentaBLL.GuardaOrdenVenta(objOrdenDeVenta));
        }
Beispiel #2
0
        public void TestGuardarVenta2()

        {
            bool                datoEsperado    = true;
            DetalleOrden        unDetalleOrden  = new DetalleOrden();
            OrdenDeVenta        objOrdenDeVenta = new OrdenDeVenta();
            List <Producto>     ListaProducto   = ProductoBLL.BuscarProducto("Vino");
            List <DetalleOrden> ListaDetalles   = new List <DetalleOrden>();
            Tarjeta             objTarjeta      = new Tarjeta();
            Usuario             unUSuario       = new Usuario();

            objTarjeta.CVC = "121";
            objTarjeta.FechaVencimiento = "1/1/2022";
            objTarjeta.NumeroTarjeta    = "9898989898989899";
            objTarjeta.NombreTarjeta    = "Denis Lemes";
            Producto objProducto = ListaProducto[0];

            unDetalleOrden.Producto = objProducto;
            unDetalleOrden.Cantidad = 2;

            ListaDetalles.Add(unDetalleOrden);
            objOrdenDeVenta.Detalles = ListaDetalles;

            objOrdenDeVenta.MetodoDePago = objTarjeta;
            List <Cliente> Clientes = ClienteBLL.BuscarClientesPorDNI("23564500");

            Cliente ObjCliente = Clientes[0];

            objOrdenDeVenta.Cliente = ObjCliente;

            unUSuario.ID = 1;
            objOrdenDeVenta.UsuarioCreador = unUSuario;
            Assert.AreEqual(datoEsperado, VentaBLL.GuardaOrdenVenta(objOrdenDeVenta));
        }
Beispiel #3
0
        public void EliminarTest()
        {
            bool paso;

            paso = VentaBLL.Eliminar(1);
            Assert.AreEqual(paso, true);
        }
Beispiel #4
0
        public void BuscarTest()
        {
            Venta ventas;

            ventas = VentaBLL.Buscar(2);
            Assert.IsNotNull(ventas);
        }
Beispiel #5
0
        public void TestGenerarReporteDeVentasPorMes()
        {
            Efectivo            objEfectivo = new Efectivo();
            List <OrdenDeVenta> unaVenta    = VentaBLL.GenerarReporteDeVentasPorMes(6, 2021);

            Assert.AreEqual(objEfectivo.GetType(), unaVenta[0].MetodoDePago.GetType());
        }
Beispiel #6
0
        public void GetListTest()
        {
            var lista = new List <Venta>();

            lista = VentaBLL.GetList(p => true);
            Assert.IsNotNull(lista);
        }
        public void EliminarTest()
        {
            bool paso = false;

            paso = VentaBLL.Eliminar(1);
            Assert.AreEqual(true, paso);
        }
Beispiel #8
0
        public void TestGenerarReporteDeVentasPorSemana()
        {
            Efectivo            objEfectivo = new Efectivo();
            var                 fechatest   = new DateTime(2021, 6, 17, 0, 0, 0);
            List <OrdenDeVenta> unaVenta    = VentaBLL.GenerarReporteDeVentasPorSemana(fechatest);

            Assert.AreEqual(objEfectivo.GetType(), unaVenta[0].MetodoDePago.GetType());
        }
Beispiel #9
0
    public int hacerFacturaPagaTerminada(int ventaId)
    {
        int facturaId = 0;
        List <FoodGood.Factura.Factura> listaFactura      = FacturaBLL.GetFacturaListForSearch("");
        List <Dosificacion>             listaDosificacion = DosificacionBLL.GetCarritoListForSearch("");

        FoodGood.Factura.Factura objFactura = new FoodGood.Factura.Factura();
        Venta objventa = VentaBLL.GetVentaById(ventaId);

        listaDosificacion = listaDosificacion.OrderByDescending(p => p.DosificacionId).ToList();
        string numeroFacturaString = "";

        if (listaFactura != null && listaFactura.Count > 0)
        {
            listaFactura = listaFactura.OrderByDescending(p => p.FacturaId).ToList();
            int numeroFactura = Convert.ToInt32(listaFactura[0].Numero) + 1;
            if (numeroFactura <= listaDosificacion[0].Hasta)
            {
                numeroFacturaString           = Convert.ToString(numeroFactura);
                objFactura.Numero             = numeroFacturaString;
                objFactura.Nombre             = Resources.InitMasterPage.NombreFactura;
                objFactura.Nit                = Resources.InitMasterPage.Nit;
                objFactura.Fecha              = objventa.FechaPedido;
                objFactura.FechaLimiteEmision = listaDosificacion[0].FechaFinal;
                objFactura.CodigoAutorizacion = listaDosificacion[0].NumeroAutorizacion;
                //me faltaria llenar el codigo de control y la ventaId
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, GetType(), "alertMessage", @"alert('tu pedido no pudo ser exitoso intentelo mas tarde.Gracias ')", true);
                return(facturaId);
            }
        }
        else
        {
            int numeroFactura = Convert.ToInt32(listaDosificacion[0].Desde) + 1;
            numeroFacturaString           = Convert.ToString(numeroFactura);
            objFactura.Numero             = numeroFacturaString;
            objFactura.Nombre             = Resources.InitMasterPage.NombreFactura;
            objFactura.Nit                = Resources.InitMasterPage.Nit;
            objFactura.Fecha              = objventa.FechaPedido;
            objFactura.FechaLimiteEmision = listaDosificacion[0].FechaFinal;
            objFactura.CodigoAutorizacion = listaDosificacion[0].NumeroAutorizacion;
            //me faltaria llenar el codigo de control y la ventaId
        }
        objFactura.VentaId = ventaId;
        string codigoControlGenerador = CodigoControl.generateControlCode(listaDosificacion[0].NumeroAutorizacion,
                                                                          objFactura.Numero, objFactura.Nit,
                                                                          objventa.FechaPedido.ToString("yyyyMMdd"),
                                                                          Convert.ToString(objventa.MontoTotal),
                                                                          listaDosificacion[0].LlaveDosificacion);
        string letraMonto = NumeroALetra.ConvertirNumeroAPalabras(objventa.MontoTotal);

        objFactura.MontoPalabra  = letraMonto;
        objFactura.CodigoControl = codigoControlGenerador;
        facturaId = FacturaBLL.InsertFactura(objFactura);
        return(facturaId);
    }
Beispiel #10
0
        public void GuardarTest()
        {
            Venta ventas = new Venta();

            ventas.VentaId   = 0;
            ventas.ClienteId = 1;
            ventas.Nombres   = "Frandy";
            ventas.Apellidos = "Mota";
            ventas.Total     = 100;

            Assert.IsTrue(VentaBLL.Guardar(ventas));
        }
 // GET: api/Venta
 public IHttpActionResult GetVentas(int id)
 {
     try
     {
         List <Venta> todos = VentaBLL.GetList(id);
         return(Content(HttpStatusCode.OK, todos));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.BadRequest, ex));
     }
 }
 public IHttpActionResult Delete(int id)
 {
     try
     {
         VentaBLL.Delete(id);
         return(Ok("Venta eliminado correctamente"));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.BadRequest, ex));
     }
 }
 public IHttpActionResult Post(Venta venta)
 {
     try
     {
         VentaBLL.Create(venta);
         return(Content(HttpStatusCode.Created, "Venta creado correctamente"));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
 public IHttpActionResult GetVenta(int id)
 {
     try
     {
         Venta result = VentaBLL.Get(id);
         if (result == null)
         {
             return(NotFound());
         }
         return(Content(HttpStatusCode.OK, result));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.BadRequest, ex));
     }
 }
 public IHttpActionResult GetUltimaVenta()
 {
     try
     {
         int result = VentaBLL.Get();
         if (result == 0)
         {
             return(NotFound());
         }
         return(Content(HttpStatusCode.OK, result));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.BadRequest, ex));
     }
 }
Beispiel #16
0
 public int InsertVenta(Venta objVenta)
 {
     try
     {
         int VentaId = 0;
         if (objVenta != null)
         {
             VentaId = VentaBLL.InsertVenta(objVenta);
         }
         return(VentaId);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public void GuardarTest()
        {
            bool   paso = false;
            Ventas v    = new Ventas();

            v.VentaId   = 0;
            v.Cliente   = "Jenry";
            v.Modo      = "Tarjeta";
            v.Itbis     = 18;
            v.Subtotal  = 90;
            v.Total     = 90;
            v.Fecha     = DateTime.Now;
            v.UsuarioId = 1;
            v.Clienteid = 1;
            paso        = VentaBLL.Guardar(v);
            Assert.AreEqual(paso, true);
        }
Beispiel #18
0
        private void Eliminarbutton_Click(object sender, EventArgs e)
        {
            MyErrorProvider.Clear();
            int id;

            int.TryParse(IDnumericUpDown.Text, out id);

            Limpiar();

            if (VentaBLL.Eliminar(id))
            {
                MessageBox.Show("Eliminado");
            }
            else
            {
                MyErrorProvider.SetError(IDnumericUpDown, "No existe.");
            }
        }
        protected void GuardarButton_Click(object sender, EventArgs e)
        {
            Ventas ventas;
            bool   paso = false;
            RepositorioBase <Ventas> db = new RepositorioBase <Ventas>();

            if (Validar())
            {
                Utilitarios.Utils.ShowToastr(this.Page, "El Campo Nombre no puede estar vacio", "Error", "error");
                return;
            }
            ventas = db.Buscar(Convert.ToInt32(VentaIdTextBox.Text));



            ventas = LlenaClase();


            if (VentaIdTextBox.Text == 0.ToString())
            {
                paso = VentaBLL.Guardar(ventas);
            }
            else
            {
                if (!ExisteEnLaBaseDeDatos())
                {
                    Utilitarios.Utils.ShowToastr(this.Page, "Se ha podido modificar", "Error", "error");
                    return;
                }
                paso = VentaBLL.Modificar(ventas);
            }

            if (paso)
            {
                Utilitarios.Utils.ShowToastr(this.Page, " Se ha Guardado", "Exito", "success");
            }
            else
            {
                Utilitarios.Utils.ShowToastr(this.Page, "Se profujo un error al guardar", "Error", "error");
            }
            Limpiar();
        }
        protected void EliminarButton_Click(object sender, EventArgs e)
        {
            if (Utilitarios.Utils.ToInt(VentaIdTextBox.Text) > 0)
            {
                int id = Convert.ToInt32(VentaIdTextBox.Text);

                if (VentaBLL.Eliminar(id))
                {
                    Utilitarios.Utils.ShowToastr(this.Page, "Eliminado con exito!!", "Eliminado", "info");
                }
                else
                {
                    Utilitarios.Utils.ShowToastr(this.Page, "Fallo al Eliminar :(", "Error", "error");
                }
                Limpiar();
            }
            else
            {
                Utilitarios.Utils.ShowToastr(this.Page, "No se pudo eliminar, Venta existe", "error", "error");
            }
        }
Beispiel #21
0
        private void Guardarbutton_Click(object sender, EventArgs e)
        {
            Ventas v    = new Ventas();
            bool   paso = false;


            if (!Validar())
            {
                return;
            }

            v = LlenaClase();

            if (IDnumericUpDown.Value == 0)
            {
                paso = VentaBLL.Guardar(v);
            }
            else
            {
                if (!ExisteEnLaBaseDeDatos())
                {
                    MessageBox.Show("No se puede guardar.", "Supermarket Software", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                paso = VentaBLL.Modificar(v);
            }

            if (paso)
            {
                MessageBox.Show("Guardado", "Supermarket Software", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("No fue posible guardar", "Supermarket Software", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            Factura r = new Factura(Detalle);

            r.ShowDialog();
            Limpiar();
        }
Beispiel #22
0
        private void Guardarbutton_Click(object sender, EventArgs e)
        {
            Ventas venta;
            bool   paso = false;

            if (!Validar())
            {
                return;
            }

            venta = LlenaClase();


            if (VentaIdnumericUpDown.Value == 0)
            {
                paso = VentaBLL.Guardar(venta);
            }
            else
            {
                if (!ExisteEnLaBaseDeDatos())
                {
                    MessageBox.Show("No se puede modificar una venta que no existe", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                paso = VentaBLL.Modificar(venta);
            }

            if (paso)
            {
                MessageBox.Show("Guardado!!", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("No fue posible guardar!!", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            Limpiar();
        }
Beispiel #23
0
        private void Eliminarbutton_Click(object sender, EventArgs e)
        {
            RepositorioBase <Ventas> db = new RepositorioBase <Ventas>();

            try
            {
                if (VentaIdnumericUpDown.Value > 0)
                {
                    if (VentaBLL.Eliminar(Convert.ToInt32(VentaIdnumericUpDown.Value)))
                    {
                        MessageBox.Show("Eliminado", "Atencion!!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Limpiar();
                    }
                    else
                    {
                        MessageBox.Show("No se puede eliminar", "Atencion!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("No se pudo eliminar", "Error!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #24
0
        public bool Edit(Venta Venta)
        {
            VentaBLL VentaBLL = new VentaBLL();

            return(VentaBLL.Edit(Venta));
        }
Beispiel #25
0
        public Venta GetByID(int ID)
        {
            VentaBLL VentaBLL = new VentaBLL();

            return(VentaBLL.GetByID(ID));
        }
Beispiel #26
0
        public bool Delete(int ID)
        {
            VentaBLL VentaBLL = new VentaBLL();

            return(VentaBLL.Delete(ID));
        }
Beispiel #27
0
        public Venta Create(Venta Venta)
        {
            VentaBLL VentaBLL = new VentaBLL();

            return(VentaBLL.Create(Venta));
        }
    private int cargarQRCode(int facturaId)
    {
        string Nit                          = "";
        string numeroFactura                = "";
        string numeroAutorizacion           = "";
        string fechapedido                  = "";
        string montototal                   = "";
        string importeCreditoFiscal         = "";
        string codigocontrol                = "";
        string nitcomprador                 = "";
        string importeICE                   = "";
        string importeVentaNoGuardada       = "";
        string importeNoSujetoCreditoFiscal = "";
        string descuento                    = "";

        FoodGood.Factura.Factura objfactura = FacturaBLL.GetFacturaById(facturaId);
        Venta objventa = VentaBLL.GetVentaById(objfactura.VentaId);

        Nit                          = objfactura.Nit;
        numeroFactura                = objfactura.Numero;
        numeroAutorizacion           = objfactura.CodigoAutorizacion;
        fechapedido                  = objfactura.Fecha.ToString("yyyyMMdd");
        montototal                   = objventa.MontoTotal.ToString();
        importeCreditoFiscal         = objventa.MontoTotal.ToString();
        codigocontrol                = objfactura.CodigoControl;
        nitcomprador                 = objventa.Nit.ToString();
        importeVentaNoGuardada       = "0";
        importeICE                   = "0";
        importeNoSujetoCreditoFiscal = "0";
        descuento                    = "0";


        string codeQRArmado = Nit + "|" + numeroFactura + "|" + numeroAutorizacion + "|" + fechapedido + "|" + montototal
                              + "|" + importeCreditoFiscal + "|" + codigocontrol + "|" + nitcomprador + "|" + importeICE
                              + "|" + importeVentaNoGuardada + "|" + importeNoSujetoCreditoFiscal + "|" + descuento;

        //Nit | numeroFactura | numeroAutorizacion | fechapedido(dd / mm / yyyy) |
        //montototal | importeCreditoFiscal(montoTotal) | codigocontrol | nitcomprador |
        //importeICE(“0”) | importeVentaNoGuardada(“0”) | importeNoSujetoCreditoFiscal(if ((montoTotal - montoPagado) > 0.001))| descuento(“0”)
        ImageQRCode.ImageUrl = "~/GeneradoQR/QRGenerator.aspx?qrcode=" + codeQRArmado;

        //lleno los campos de la factura
        //lleno el precio total
        totalFacturaLabel.Text = Convert.ToString(objventa.MontoTotal);

        //lleno el nombre del cliente,fecha,nit
        nombreCliente.Text = objventa.NombreCliente + " " + objventa.ApellidoCliente;
        nitCliente.Text    = Convert.ToString(objventa.Nit);
        fechaCliente.Text  = objfactura.Fecha.ToString();

        //llenar dato de la empresa FoodGood
        numeroNitLabel.Text          = objfactura.Nit;
        numeroFacturaLabel.Text      = "000" + objfactura.Numero;
        numeroAurotizacionLabel.Text = objfactura.CodigoAutorizacion;


        //llenar el monto en palabras
        montoPalabraLabel.Text = objfactura.MontoPalabra;

        //llenar codigo control

        codigoControlLabel.Text = objfactura.CodigoControl;

        fechaLimiteEmisionLabel.Text = objfactura.FechaLimiteEmision.ToShortDateString();

        return(objfactura.VentaId);
    }
Beispiel #29
0
        public List <Venta> ListarTodos()
        {
            VentaBLL VentaBLL = new VentaBLL();

            return(VentaBLL.ListarTodos());
        }