Exemplo n.º 1
0
 public static void Regresar9500DeCompletar(Cotizacion9500 o9500)
 {
     // Se restaura el dato de la venta y el estatus del 9500
     o9500.VentaID           = null;
     o9500.EstatusGenericoID = Cat.EstatusGenericos.Pendiente;
     Datos.Guardar <Cotizacion9500>(o9500);
 }
Exemplo n.º 2
0
        private void MostrarDetalle(int iCotizacion9500ID)
        {
            this.o9500.ctlComDetalle.LimpiarDetalle();
            ProductoVenta oProductoV;
            var           Detalle = Datos.GetListOf <Cotizaciones9500DetalleView>(q => q.Cotizacion9500ID == iCotizacion9500ID);

            foreach (var Producto in Detalle)
            {
                oProductoV = new ProductoVenta()
                {
                    ParteID        = Producto.ParteID,
                    NumeroDeParte  = Producto.NumeroParte,
                    NombreDeParte  = Producto.NombreParte,
                    Cantidad       = Producto.Cantidad,
                    PrecioUnitario = UtilTheos.ObtenerPrecioSinIva(Producto.PrecioAlCliente, 3),
                    Iva            = UtilTheos.ObtenerIvaDePrecio(Producto.PrecioAlCliente, 3)
                                     // PrecioConIva = Producto.PrecioAlCliente
                };
                this.o9500.ctlComDetalle.AgregarProducto(oProductoV);
            }
            this.o9500.ctlComDetalle.VerExistenciaLista();

            // Se actualiza el Cliente
            this.oCotizacion9500 = Datos.GetEntity <Cotizacion9500>(q => q.Cotizacion9500ID == iCotizacion9500ID && q.Estatus);
            this.ComCliente      = Datos.GetEntity <ClientesDatosView>(q => q.ClienteID == oCotizacion9500.ClienteID);
            this.o9500.ClienteCompletar(this.ComCliente);
            // Se guarda el anticipo
            this.ComAnticipoSel = oCotizacion9500.Anticipo;
        }
Exemplo n.º 3
0
        public static void Completar9500(Cotizacion9500 o9500, decimal mSobrante, bool bDevolverEfectivo)
        {
            // Se cancela la venta del anticipo
            var oVentaAnt = Datos.GetEntity <Venta>(q => q.VentaID == o9500.AnticipoVentaID && q.VentaEstatusID != Cat.VentasEstatus.Cancelada &&
                                                    q.VentaEstatusID != Cat.VentasEstatus.CanceladaSinPago && q.Estatus);

            if (oVentaAnt != null)
            {
                oVentaAnt.VentaEstatusID = Cat.VentasEstatus.Cancelada;
                Datos.Guardar <Venta>(oVentaAnt);
                // Se genera una devolución de efectivo (si se realizó un pago) de la venta cancelada, pues se generará una nueva venta con el importe total
                if (Datos.Exists <VentaPago>(q => q.VentaID == o9500.AnticipoVentaID && q.Estatus))
                {
                    VentasProc.GenerarDevolucionDeEfectivo(o9500.AnticipoVentaID.Valor(), o9500.Anticipo - (mSobrante > 0 ? mSobrante : 0));
                }
            }

            // Si hubo un sobrante, se genera nota de crédito o se devuelve efectivo
            if (mSobrante > 0)
            {
                if (bDevolverEfectivo)
                {
                    VentasProc.GenerarDevolucionDeEfectivo(oVentaAnt.VentaID, mSobrante);
                }
                else
                {
                    VentasProc.GenerarNotaDeCredito(o9500.ClienteID, mSobrante, "", Cat.OrigenesNotaDeCredito.Anticipo9500, oVentaAnt.VentaID);
                }
            }

            // Se modifica el Estatus del 9500
            o9500.EstatusGenericoID = Cat.EstatusGenericos.Completada;
            Datos.Guardar <Cotizacion9500>(o9500);
        }
Exemplo n.º 4
0
        public Cotizacion9500 Generar9500()
        {
            var o9500 = new Cotizacion9500()
            {
                EstatusGenericoID = Cat.EstatusGenericos.Pendiente,
                Fecha             = DateTime.Now,
                ClienteID         = this.Cliente.ClienteID,
                SucursalID        = GlobalClass.SucursalID,
                Anticipo          = Util.Decimal(this.txtAnticipo.Text.SoloNumeric())
            };

            return(o9500);
        }
Exemplo n.º 5
0
        public static ResAcc c9500(Cotizacion9500 o9500, List<Cotizacion9500Detalle> Detalle)
        {
            // Se guarda la cotización 9500
            Datos.Guardar<Cotizacion9500>(o9500);

            // Se guarda el detalle
            foreach (var Parte in Detalle)
            {
                Parte.Cotizacion9500ID = o9500.Cotizacion9500ID;
                Datos.Guardar<Cotizacion9500Detalle>(Parte);
            }

            return new ResAcc(true);
        }
Exemplo n.º 6
0
        public static ResAcc c9500(Cotizacion9500 o9500, List <Cotizacion9500Detalle> Detalle)
        {
            // Se guarda la cotización 9500
            Datos.Guardar <Cotizacion9500>(o9500);

            // Se guarda el detalle
            foreach (var Parte in Detalle)
            {
                Parte.Cotizacion9500ID = o9500.Cotizacion9500ID;
                Datos.Guardar <Cotizacion9500Detalle>(Parte);
            }

            return(new ResAcc(true));
        }
Exemplo n.º 7
0
        private void BorrarVenta(int iVentaID)
        {
            // Para ver si la venta es un anticipo de 9500
            var o9500Ant = Datos.GetEntity <Cotizacion9500>(q => q.AnticipoVentaID == iVentaID && q.EstatusGenericoID == Cat.EstatusGenericos.Pendiente &&
                                                            q.Estatus);
            // Para ver si la venta es de un 9500
            Cotizacion9500 o9500 = null;

            if (o9500Ant == null)
            {
                o9500 = Datos.GetEntity <Cotizacion9500>(q => q.VentaID == iVentaID && q.Estatus);
            }

            string sPregunta = "¿Estás seguro que deseas eliminar la venta seleccionada?";

            if (o9500Ant != null)
            {
                sPregunta = "La venta seleccionada pertenece a un anticipo de 9500. ¿Estás seguro que deseas eliminarla?";
            }
            else if (o9500 != null)
            {
                sPregunta = "La venta seleccionada pertenece a un 9500. ¿Estás seguro que deseas eliminarla?";
            }

            if (UtilLocal.MensajePregunta(sPregunta) == DialogResult.Yes)
            {
                // Si es un anticipo de 9500, éste se cancela y se borran las partes, si no han sido usadas
                if (o9500Ant != null)
                {
                    VentasProc.Cancelar9500(o9500Ant.Cotizacion9500ID, "POR BORRAR VENTA SIN COBRAR", GlobalClass.UsuarioGlobal.UsuarioID);
                }
                // Si es un 9500, éste se regresa a los 9500 pendientes
                else if (o9500 != null)
                {
                    VentasProc.Regresar9500DeCompletar(o9500);
                }

                // Se elimina la venta
                VentasProc.EliminarVenta(iVentaID);
                this.ActualizarDatos();
            }
        }
Exemplo n.º 8
0
        public static void Completar9500(Cotizacion9500 o9500, decimal mSobrante, bool bDevolverEfectivo)
        {
            // Se cancela la venta del anticipo
            var oVentaAnt = Datos.GetEntity<Venta>(q => q.VentaID == o9500.AnticipoVentaID && q.VentaEstatusID != Cat.VentasEstatus.Cancelada &&
                q.VentaEstatusID != Cat.VentasEstatus.CanceladaSinPago && q.Estatus);
            if (oVentaAnt != null)
            {
                oVentaAnt.VentaEstatusID = Cat.VentasEstatus.Cancelada;
                Datos.Guardar<Venta>(oVentaAnt);
                // Se genera una devolución de efectivo (si se realizó un pago) de la venta cancelada, pues se generará una nueva venta con el importe total
                if (Datos.Exists<VentaPago>(q => q.VentaID == o9500.AnticipoVentaID && q.Estatus))
                    VentasProc.GenerarDevolucionDeEfectivo(o9500.AnticipoVentaID.Valor(), o9500.Anticipo - (mSobrante > 0 ? mSobrante : 0));
            }

            // Si hubo un sobrante, se genera nota de crédito o se devuelve efectivo
            if (mSobrante > 0)
            {
                if (bDevolverEfectivo)
                    VentasProc.GenerarDevolucionDeEfectivo(oVentaAnt.VentaID, mSobrante);
                else
                    VentasProc.GenerarNotaDeCredito(o9500.ClienteID, mSobrante, "", Cat.OrigenesNotaDeCredito.Anticipo9500, oVentaAnt.VentaID);
            }

            // Se modifica el Estatus del 9500
            o9500.EstatusGenericoID = Cat.EstatusGenericos.Completada;
            Datos.Guardar<Cotizacion9500>(o9500);
        }
Exemplo n.º 9
0
 public static void Regresar9500DeCompletar(Cotizacion9500 o9500)
 {
     // Se restaura el dato de la venta y el estatus del 9500
     o9500.VentaID = null;
     o9500.EstatusGenericoID = Cat.EstatusGenericos.Pendiente;
     Datos.Guardar<Cotizacion9500>(o9500);
 }
Exemplo n.º 10
0
 public Cotizacion9500 Generar9500()
 {
     var o9500 = new Cotizacion9500()
     {
         EstatusGenericoID = Cat.EstatusGenericos.Pendiente,
         Fecha = DateTime.Now,
         ClienteID = this.Cliente.ClienteID,
         SucursalID = GlobalClass.SucursalID,
         Anticipo = Util.Decimal(this.txtAnticipo.Text.SoloNumeric())
     };
     return o9500;
 }
Exemplo n.º 11
0
        private void MostrarDetalle(int iCotizacion9500ID)
        {
            this.o9500.ctlComDetalle.LimpiarDetalle();
            ProductoVenta oProductoV;
            var Detalle = Datos.GetListOf<Cotizaciones9500DetalleView>(q => q.Cotizacion9500ID == iCotizacion9500ID);
            foreach (var Producto in Detalle)
            {
                oProductoV = new ProductoVenta()
                {
                    ParteID = Producto.ParteID,
                    NumeroDeParte = Producto.NumeroParte,
                    NombreDeParte = Producto.NombreParte,
                    Cantidad = Producto.Cantidad,
                    PrecioUnitario = UtilTheos.ObtenerPrecioSinIva(Producto.PrecioAlCliente, 3),
                    Iva = UtilTheos.ObtenerIvaDePrecio(Producto.PrecioAlCliente, 3)
                    // PrecioConIva = Producto.PrecioAlCliente
                };
                this.o9500.ctlComDetalle.AgregarProducto(oProductoV);
            }
            this.o9500.ctlComDetalle.VerExistenciaLista();

            // Se actualiza el Cliente
            this.oCotizacion9500 = Datos.GetEntity<Cotizacion9500>(q => q.Cotizacion9500ID == iCotizacion9500ID && q.Estatus);
            this.ComCliente = Datos.GetEntity<ClientesDatosView>(q => q.ClienteID == oCotizacion9500.ClienteID);
            this.o9500.ClienteCompletar(this.ComCliente);
            // Se guarda el anticipo
            this.ComAnticipoSel = oCotizacion9500.Anticipo;
        }
Exemplo n.º 12
0
        private bool Completar9500()
        {
            // Se validan las partes
            if (!this.ctlComDetalle.Validar())
            {
                return(false);
            }

            //if (Util.ControlAlFrente(this.pnlCompletar) == this.ctlComDetalle)
            //{
            //}

            // Se verifica que se haya hecho el pago del anticipo
            Cotizacion9500 o9500 = this.ctlPartes.oCotizacion9500;

            if (!Datos.Exists <Venta>(c => c.VentaID == o9500.AnticipoVentaID &&
                                      (c.VentaEstatusID == Cat.VentasEstatus.Completada || c.VentaEstatusID == Cat.VentasEstatus.Cobrada)))
            {
                UtilLocal.MensajeAdvertencia("Al parecer no se ha realizado el pago correspondiente al Anticipo. No se puede continuar.");
                return(false);
            }

            // Se confirma la operación
            if (UtilLocal.MensajePregunta(string.Format("¿Estás seguro que deseas completar el 9500 con el folio {0}?\n\n{1}"
                                                        , this.ctlPartes.oCotizacion9500.Cotizacion9500ID, this.ctlPartes.o9500Sel["lisDescripcion"])) != DialogResult.Yes)
            {
                return(false);
            }

            // Se guardan los datos
            DateTime dAhora = DateTime.Now;

            // Se cancela la venta del anticipo

            /* Ya no. Ahora todo esto se hace al cobrar la venta final
             * oVenta.VentaEstatusID = Cat.VentasEstatus.Cancelada;
             * Datos.Guardar<Venta>(oVenta);
             * // Se genera una devolución de efectivo (si se realizó un pago) de la venta cancelada, pues se generará una nueva venta con el importe total
             * if (oVentaPago != null)
             *  VentasProc.GenerarDevolucionDeEfectivo(o9500.AnticipoVentaID.Valor(), o9500.Anticipo);
             */

            // Se genera la venta correspondiente al 9500
            // var o9500Detalle = General.GetListOf<Cotizacion9500Detalle>(q => q.Estatus && q.Cotizacion9500ID == oCotizacion9500.Cotizacion9500ID);
            var oCliente = Datos.GetEntity <Cliente>(q => q.ClienteID == o9500.ClienteID && q.Estatus);
            var oDetalle = this.ctlComDetalle.ProductosSel();
            var oVenta   = new Venta()
            {
                Fecha                 = dAhora,
                ClienteID             = o9500.ClienteID,
                VentaEstatusID        = Cat.VentasEstatus.Realizada,
                RealizoUsuarioID      = o9500.RealizoUsuarioID,
                ComisionistaClienteID = o9500.ComisionistaClienteID
            };
            var oVentaDetalle = new List <VentaDetalle>();

            foreach (var oParte in oDetalle)
            {
                // Se toma el precio de la tabla "PartePrecio", pues pudo haber sido cambiado por el encargado de Compras
                var     oPartePrecio = Datos.GetEntity <PartePrecio>(q => q.ParteID == oParte.ParteID);
                decimal mPrecio      = UtilDatos.PartePrecioDeVenta(oPartePrecio, oCliente.ListaDePrecios);
                // Se agrega la parte al detalle de la venta
                oVentaDetalle.Add(new VentaDetalle()
                {
                    ParteID           = oParte.ParteID,
                    Costo             = oPartePrecio.Costo.Valor(),
                    CostoConDescuento = (oPartePrecio.CostoConDescuento ?? oPartePrecio.Costo.Valor()),
                    Cantidad          = oParte.Cantidad,
                    PrecioUnitario    = UtilTheos.ObtenerPrecioSinIva(mPrecio, 3),
                    Iva = UtilTheos.ObtenerIvaDePrecio(mPrecio, 3)
                });
            }
            // Se guarda la venta
            Guardar.Venta(oVenta, oVentaDetalle);

            // Se modifica el dato de la venta correspondiente al 9500
            o9500.VentaID           = oVenta.VentaID;
            o9500.EstatusGenericoID = Cat.EstatusGenericos.PorCompletar;
            Datos.Guardar <Cotizacion9500>(o9500);

            // Se restaura
            this.ctlPartes.ComCliente = null;
            this.pnlEnTotales.Controls.Remove(this.pnlCompletar);
            this.pnlCompletar.Dispose();
            this.pnlCompletar = null;
            this.CambiarOpcion(eOpcion.Agregar);
            this.ctlPartes.tab9500.SelectedIndex = 0;

            // Se muestra una notifiación con el resultado
            UtilLocal.MostrarNotificacion("Cotización 9500 guardada correctamente.");

            // Se retorna falso para que no se quite la opción de 9500
            return(false);
        }