diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 60ba09742..39c5bc7e1 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -6231,7 +6231,13 @@ Partial Class Ventas 'SI LA VENTA YA ESTA REGISTRADA NO DEBE HABILITAR ACCIONES If CveVenta <= 0 Then - LnkRemisiones.Visible = If(UsuarioActual.TienePermisoProceso(199), True, False) : LnkOCs.Visible = True : LnkCotizaciones.Visible = True : LnkPedido2SinFacturar.Visible = True : InicializaAplicarNCMasiva() + Dim EsModuloCotizacion As Boolean = False + If Request("Op") IsNot Nothing AndAlso Request("Op").ToString() = "Cot" Then + EsModuloCotizacion = True + End If + If Not EsModuloCotizacion Then + LnkRemisiones.Visible = If(UsuarioActual.TienePermisoProceso(199), True, False) : LnkOCs.Visible = True : LnkCotizaciones.Visible = True : LnkPedido2SinFacturar.Visible = True : InicializaAplicarNCMasiva() + End If End If If UsuarioActual.Empresa.CvePlataforma = 2 Then LnkOCs.Visible = False @@ -7120,7 +7126,13 @@ Partial Class Ventas 'SI LA VENTA YA ESTA REGISTRADA NO DEBE HABILITAR ACCIONES If CveVenta <= 0 Then - LnkRemisiones.Visible = If(UsuarioActual.TienePermisoProceso(199), True, False) : LnkOCs.Visible = True : LnkCotizaciones.Visible = True : LnkPedido2SinFacturar.Visible = True : InicializaAplicarNCMasiva() + Dim EsModuloCotizacion As Boolean = False + If Request("Op") IsNot Nothing AndAlso Request("Op").ToString() = "Cot" Then + EsModuloCotizacion = True + End If + If Not EsModuloCotizacion Then + LnkRemisiones.Visible = If(UsuarioActual.TienePermisoProceso(199), True, False) : LnkOCs.Visible = True : LnkCotizaciones.Visible = True : LnkPedido2SinFacturar.Visible = True : InicializaAplicarNCMasiva() + End If End If ObjCliente.Dispose() @@ -7693,10 +7705,31 @@ Partial Class Ventas If ValidaExistencia AndAlso DdlTipoComprobante.SelectedValue <> "Cot" And ChkSinExistencia.Checked = False AndAlso Not RegistroxOC Then 'VALIDA EXISTENCIA If UsuarioActual.CveEmpresa.Contiene({72, 80, 119, 140, 153}) Then - If Existencia - TmpDT.SUM("Cantidad", $"CvePS = {CvePS} AND (EntregaDirecta IS NULL OR EntregaDirecta < 1)") < TxtCantidad.Text.ToDouble Then - Alert("No cuenta con la cantidad suficiente en inventario. Cuenta con " + Existencia.FormatoNumero(2) + ".", TipoMensaje.MsgAdvertencia) - Exit Sub + 'SI ES VENTA NUEVA TOMA EN CUENTA LO DEL TMPDT + If CveVenta <= 0 Then + If Existencia - TmpDT.SUM("Cantidad", $"CvePS = {CvePS} AND (EntregaDirecta IS NULL OR EntregaDirecta < 1)") < TxtCantidad.Text.ToDouble Then + Alert("No cuenta con la cantidad suficiente en inventario. Cuenta con " + Existencia.FormatoNumero(2) + ".", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + Else + If DdlTipoComprobante.SelectedValue = "Rem" Then + Dim CantidadVenta As Double = 0 + Using ObjVentas As New ClsVentas + If ObjVentas.GetVentaDetalle(CveVenta) Then + CantidadVenta = ObjVentas.DtResultados.SUM("Cantidad", $"CvePS = {CvePS}") + End If + End Using + + 'SUMA LO YA RESTADO EN PENDIENTE POR SURTIR QUE PERTENESCA A LA VENTA. + 'PARA QUE NO RESTE LA EXISTENCIA 2 VECES Y PUEDAS COMPARAR LO REAL + If (Existencia + CantidadVenta) - TmpDT.SUM("Cantidad", $"CvePS = {CvePS} AND (EntregaDirecta IS NULL OR EntregaDirecta < 1)") < TxtCantidad.Text.ToDouble Then + Alert("No cuenta con la cantidad suficiente en inventario. Cuenta con " + Existencia.FormatoNumero(2) + ".", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If + End If + End If End If @@ -14352,7 +14385,7 @@ Partial Class Ventas Dim DebeGenerarMovimiento As Boolean = TmpDT.COUNT("CvePS", "CveTipoPS = 2") > 0 'VERIFICA QUE SE REALIZO EL MOVIMIENTO DE ALMACEN - If DebeGenerarMovimiento AndAlso UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso UsuarioActual.Empresa.Funcionalidad(567) = "1" AndAlso factura.TipoDocto.Contiene("Ing", "Egs", "Rem") Then + If DebeGenerarMovimiento AndAlso UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso UsuarioActual.Empresa.Funcionalidad(567) = "1" AndAlso factura.TipoDocto.Contiene("Ing", "Rem") Then If Not (ObjInventario.GetInv_Mov(factura.CveVenta, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0) Then OcurrioError = True ErrorList.Add("Ocurrió un error al verificar inventario.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico") @@ -17583,10 +17616,29 @@ Partial Class Ventas If DdlTipoComprobante.SelectedValue <> "Cot" And ChkSinExistencia.Checked = False Then 'VALIDA EXISTENCIA If UsuarioActual.CveEmpresa.Contiene({72, 80, 119, 153, 140}) Then - If Existencia - TmpDT.SUM("Cantidad", $"CvePS = {CvePS} AND (EntregaDirecta IS NULL OR EntregaDirecta < 1)") < TxtCantidad.Text.ToDouble Then - Alert("No cuenta con la cantidad suficiente en inventario. Cuenta con " + Existencia.FormatoNumero(2) + ".", TipoMensaje.MsgAdvertencia) - Return False + If CveVenta <= 0 OrElse Me.EsCreaApartirDe Then + If Existencia - TmpDT.SUM("Cantidad", $"CvePS = {CvePS} AND (EntregaDirecta IS NULL OR EntregaDirecta < 1)") < TxtCantidad.Text.ToDouble Then + Alert("No cuenta con la cantidad suficiente en inventario. Cuenta con " + Existencia.FormatoNumero(2) + ".", TipoMensaje.MsgAdvertencia) + Return False + End If + Else + If DdlTipoComprobante.SelectedValue = "Rem" Then + Dim CantidadVenta As Double = 0 + Using ObjVentasE As New ClsVentas + If ObjVentasE.GetVentaDetalle(CveVenta) Then + CantidadVenta = ObjVentasE.DtResultados.SUM("Cantidad", $"CvePS = {CvePS}") + End If + End Using + + 'SUMA LO YA RESTADO EN PENDIENTE POR SURTIR QUE PERTENESCA A LA VENTA. + 'PARA QUE NO RESTE LA EXISTENCIA 2 VECES Y PUEDAS COMPARAR LO REAL + If (Existencia + CantidadVenta) - TmpDT.SUM("Cantidad", $"CvePS = {CvePS} And (EntregaDirecta Is NULL Or EntregaDirecta < 1)") < TxtCantidad.Text.ToDouble Then + Alert("No cuenta con la cantidad suficiente en inventario. Cuenta con " + Existencia.FormatoNumero(2) + ".", TipoMensaje.MsgAdvertencia) + Return False + End If + End If End If + End If End If