From 30eca403e7c08a2d75d054c697e1b7abf6bd3cd9 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Fri, 12 Jul 2024 17:36:21 -0700 Subject: [PATCH] --FIX validacion de costo para cotizaciones --- Ventas/Ventas.aspx.vb | 65 ++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index c9326985c..1b81cae90 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -8915,8 +8915,18 @@ Partial Class Ventas End If If CveUM <> CveUMInicial Then ValidaExistencia = True + 'SOLO VALIDA EXISTENCIAS Y COSTO: SI USA INVENTARIOS, SOLO PRODUCTOS TIPO PRODUCTO, SOLO REMISIONES E INGRESOS - If UsuarioActual.Empresa.UsaInventarios AndAlso CveTipoPS = 2 AndAlso (DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing", "PA") Or (DdlTipoComprobante.SelectedValue.Contiene("Cot") And UsuarioActual.CveEmpresa.Contiene(119))) Then + Dim ValidaExistenciasCosto As Boolean = UsuarioActual.Empresa.UsaInventarios AndAlso CveTipoPS = 2 AndAlso (DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing", "PA") Or (DdlTipoComprobante.SelectedValue.Contiene("Cot") And UsuarioActual.CveEmpresa.Contiene(119))) + + 'VALIDA COSTO PARA LAS COTIZACIONES + If Not ValidaExistenciasCosto Then + If DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso (UsuarioActual.Empresa.Funcionalidad(382) = "1" OrElse UsuarioActual.CveEmpresa = 1) Then + ValidaExistenciasCosto = True + End If + End If + + If ValidaExistenciasCosto Then Dim ObjInventarios As New ClsInventarios Dim Existencia As Decimal If ValidaExistencia Then @@ -18839,33 +18849,24 @@ Partial Class Ventas ' NO VALIDA EXISTENCIAS NI COSTO - PERMISO PARA NO VALIDAR If Not UsuarioActual.TienePermisoProceso(169) AndAlso RBLTipoVenta.SelectedValue.ToEntero <> 5 Then 'SOLO VALIDA EXISTENCIAS Y COSTO: SI USA INVENTARIOS, SOLO PRODUCTOS TIPO PRODUCTO, SOLO REMISIONES E INGRESOS - If UsuarioActual.Empresa.UsaInventarios AndAlso CveTipoPS = 2 AndAlso (DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing", "PA") OrElse ((DdlTipoComprobante.SelectedValue.Contiene("Cot") And UsuarioActual.CveEmpresa.Contiene(119)) OrElse (DdlTipoComprobante.SelectedValue.Contiene("Ped") And UsuarioActual.CveEmpresa.Contiene(186)))) Then + Dim ValidaExistenciasCosto As Boolean = UsuarioActual.Empresa.UsaInventarios AndAlso CveTipoPS = 2 AndAlso (DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing", "PA") OrElse ((DdlTipoComprobante.SelectedValue.Contiene("Cot") And UsuarioActual.CveEmpresa.Contiene(119)) OrElse (DdlTipoComprobante.SelectedValue.Contiene("Ped") And UsuarioActual.CveEmpresa.Contiene(186)))) + + 'VALIDA COSTO PARA LAS COTIZACIONES + If Not ValidaExistenciasCosto Then + If DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso (UsuarioActual.Empresa.Funcionalidad(382) = "1" OrElse UsuarioActual.CveEmpresa = 1) Then + ValidaExistenciasCosto = True + End If + End If + + If ValidaExistenciasCosto Then Dim ObjInventarios As New ClsInventarios - Dim BuscarEnTabla As Boolean = If(UsuarioActual.Empresa.Funcionalidad(715) = "1", True, False) - - - Dim Existencia As Decimal = 0D - - If RBLTipoVenta.SelectedValue.ToEntero = 6 Then - Existencia = ObjInventarios.GetExistenciasPS(CvePS, CveUM, UsuarioActual.CveEmpresa, CveAlamcenFiltroDdl, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=-1, - CveVendedor:=DdlVendedor.SelectedValue.ToEntero(), CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeAdelantado:=0, PendientePorSurtir:=1, - RestringirAlmacenes:=1, ExcluyeApartados:=-1, BuscarEnTabla:=BuscarEnTabla) - Else - Existencia = ObjInventarios.GetExistenciasPS(CvePS, CveUM, UsuarioActual.CveEmpresa, -1, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(), - CveVendedor:=DdlVendedor.SelectedValue.ToEntero(), CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeAdelantado:=1, PendientePorSurtir:=1, - RestringirAlmacenes:=1, ExcluyeApartados:=-1, BuscarEnTabla:=BuscarEnTabla) - End If - - - - Dim Costo As Decimal = ObjInventarios.GetCostoPS(CvePS, TxtCantidad.Text.Trim.ToDecimal, -1, "-1", TxtFecha.Text.ToDate, DdlSubProyectoDatos.SelectedValue.ToEntero(), CveTipoAlmacen:=1) - 'si el costo es cero, puede ser que no halla movimientos del producto, en esa sucursal. y se volverá a sacar sin especificar sucursal If Costo <= 0 Then Costo = ObjInventarios.GetCostoPS(CvePS, TxtCantidad.Text.Trim.ToDecimal, -1, "-1", TxtFecha.Text.ToDate, -1, CveTipoAlmacen:=1) ObjInventarios.Dispose() + Dim PrecioMinimo As Decimal = 0 'RMF. condicion temporal, para reubicación, precio mínimo If UsuarioActual.CveEmpresa = 119 Then @@ -18881,9 +18882,29 @@ Partial Class Ventas End If - If DdlTipoComprobante.SelectedValue <> "Cot" And ChkSinExistencia.Checked = False Or UsuarioActual.Empresa.Funcionalidad(578).ToEntero = 1 Then + Dim ValidaExistencia As Boolean = (DdlTipoComprobante.SelectedValue <> "Cot" And ChkSinExistencia.Checked = False) Or UsuarioActual.Empresa.Funcionalidad(578).ToEntero = 1 + + If ValidaExistencia Then + 'VALIDA EXISTENCIA If UsuarioActual.CveEmpresa.Contiene({72, 80, 119, 153, 140, 186, 190}) Then + + Dim BuscarEnTabla As Boolean = If(UsuarioActual.Empresa.Funcionalidad(715) = "1", True, False) + + Dim Existencia As Decimal = 0D + + Using ObjInv2 As New ClsInventarios + If RBLTipoVenta.SelectedValue.ToEntero = 6 Then + Existencia = ObjInv2.GetExistenciasPS(CvePS, CveUM, UsuarioActual.CveEmpresa, CveAlamcenFiltroDdl, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=-1, + CveVendedor:=DdlVendedor.SelectedValue.ToEntero(), CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeAdelantado:=0, PendientePorSurtir:=1, + RestringirAlmacenes:=1, ExcluyeApartados:=-1, BuscarEnTabla:=BuscarEnTabla) + Else + Existencia = ObjInv2.GetExistenciasPS(CvePS, CveUM, UsuarioActual.CveEmpresa, -1, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(), + CveVendedor:=DdlVendedor.SelectedValue.ToEntero(), CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeAdelantado:=1, PendientePorSurtir:=1, + RestringirAlmacenes:=1, ExcluyeApartados:=-1, BuscarEnTabla:=BuscarEnTabla) + End If + End Using + If CveVenta <= 0 OrElse Me.EsCreaApartirDe Then If Existencia - TmpDT.SUM("Cantidad", $"CvePS = {CvePS} AND (EntregaDirecta IS NULL OR EntregaDirecta < 1)") < (If(CantidadModal > 0, CantidadModal, TxtCantidad.Text.ToDouble)) Then Alert("No cuenta con la cantidad suficiente en inventario. Cuenta con " + Existencia.FormatoNumero(2) + ".", TipoMensaje.MsgAdvertencia)