diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index f58c09d83..877c8c85d 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -9103,7 +9103,7 @@ Partial Class Ventas If CveCicloComercial > 0 Then For Each gvrcd As GridViewRow In GvContratoDetalles.Rows If gvrcd.RowType = DataControlRowType.DataRow Then - If gvrcd.DataKey("Cantidad").ToString().ToDecimal() = gvr.DataKey("Cantidad").ToString().ToDecimal() AndAlso gvrcd.DataKey("CvePS").ToString().ToEntero() = gvr.DataKey("CvePS").ToString().ToEntero() Then + If gvrcd.DataKey("Cantidad").ToString().ToDecimal() = gvr.DataKey("Cantidad").ToDecimal() AndAlso gvrcd.DataKey("CvePS").ToEntero() = gvr.DataKey("CvePS").ToEntero() Then If gvrcd.DataKey("LimitarCantidad").ToString() = "False" Then gvr.FCTextBox("TxtCantidad").Enabled = True Exit For @@ -9115,7 +9115,7 @@ Partial Class Ventas End If If UsuarioActual.CveEmpresa = 189 Then - Dim DrPS = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=TmpDT.Rows(e.NewEditIndex)("CvePS").ToString().ToEntero()).FiltroPrimero("") + Dim DrPS = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=gvr.DataKey("CvePS").ToEntero()).FiltroPrimero("") If DrPS IsNot Nothing Then gvr.FCTextBox("TxtPrecio").Enabled = CBool(DrPS("PrecioLibre")) @@ -18381,7 +18381,7 @@ Partial Class Ventas If EsVentaMedica Then TxtPrecio.Enabled = False - If UsuarioActual.CveUsuario = 3986 OrElse RBLTipoVenta.SelectedValue = "2" Then + If UsuarioActual.CveUsuario = 3986 Or RBLTipoVenta.SelectedValue.ToEntero = 2 Then TxtPrecio.Enabled = True End If @@ -18400,7 +18400,11 @@ Partial Class Ventas End If End If - If UsuarioActual.TienePermisoProceso(68) AndAlso Not drPS("SATClavePS").ToString.Contiene("84111506", "80141610") Then TxtPrecio.Enabled = False + + + Dim PSCodigoSAT As String = drPS("SATClavePS").ToString + + If UsuarioActual.TienePermisoProceso(68) AndAlso Not PSCodigoSAT.Contiene("84111506", "80141610") Then TxtPrecio.Enabled = False If TmpDT IsNot Nothing AndAlso TmpDT.Rows.Count = 0 AndAlso Not ChkEmitirComercioExterior.Checked Then DdlMoneda.SelectedValueExist(drPS("CveMoneda").ToString()) @@ -18734,6 +18738,31 @@ Partial Class Ventas End If End If + If UsuarioActual.CveEmpresa = 189 AndAlso CveCliente = 1555244 Then + Dim Costo As Decimal + If UsuarioActual.Empresa.Funcionalidad(602) = "UC" Then 'validación sobre el último costo + Dim ObjInventarios As New ClsInventarios + If ObjInventarios.GetUltimoCosto(UsuarioActual.CveEmpresa, CvePSParametro) Then + Dim dr As DataRow = ObjInventarios.DtResultados.FiltroPrimero("") + If dr IsNot Nothing Then + Costo = dr("UltimoCosto").ToString.ToDecimal + End If + End If + ObjInventarios.Dispose() + Else + Dim ObjInventarios As New ClsInventarios + Costo = ObjInventarios.GetCostoPS(CvePSParametro, 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(CvePSParametro, TxtCantidad.Text.Trim.ToDecimal, -1, "-1", TxtFecha.Text.ToDate, -1, CveTipoAlmacen:=1) + ObjInventarios.Dispose() + End If + + If CveCliente = 1555244 Then + PrecioSugerido = Costo * 1.07D + 'TxtPrecio.Text = PrecioSugerido.ToString("#,##0.####") + End If + End If + Retorno.PrecioSugerido = PrecioSugerido Return Retorno @@ -19667,7 +19696,7 @@ Partial Class Ventas objPS.Dispose() End If - Dim ValidaExistencia As Boolean = (DdlTipoComprobante.SelectedValue <> "Cot" And ChkSinExistencia.Checked = False) OrElse UsuarioActual.Empresa.Funcionalidad(578).ToEntero = 1 + Dim ValidaExistencia As Boolean = (DdlTipoComprobante.SelectedValue <> "Cot" And ChkSinExistencia.Checked = False) Or UsuarioActual.Empresa.Funcionalidad(578).ToEntero = 1 If CantidadOriginal > 0 Then 'SI NO HAY CAMBIOS EN LAS CANTIDADES, NO VALIDAR EXISTENCIA @@ -19704,7 +19733,8 @@ Partial Class Ventas 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, Cantidad)) Then + Dim tCantValidar As Decimal = TmpDT.SUM("Cantidad", $"CvePS = {CvePS} AND (EntregaDirecta IS NULL OR EntregaDirecta < 1)") - CantidadOriginal + (If(CantidadModal > 0, CantidadModal, Cantidad)) + If Existencia - tCantValidar < 0 Then Dim CveAlmacenConsulta As Integer = -1 Dim StrAlmacen As New StringBuilder @@ -19716,12 +19746,12 @@ Partial Class Ventas StrAlmacen.AppendFormat("
Almacén: {0}", Almacen) End If End If - Alert("No cuenta con la cantidad suficiente en inventario. Cuenta con " + Existencia.FormatoNumero(2) + "." + StrAlmacen.ToString(), TipoMensaje.MsgAdvertencia) + Alert("No cuenta con la cantidad suficiente en inventario. Cuenta con " + Existencia.ToString("#,##0.####") + "." + StrAlmacen.ToString(), TipoMensaje.MsgAdvertencia) Return False End If Else If DdlTipoComprobante.SelectedValue = "Rem" Then - Dim CantidadVenta As Double = 0 + Dim CantidadVenta As Decimal = 0 Using ObjVentasE As New ClsVentas If ObjVentasE.GetVentaDetalle(CveVenta) Then CantidadVenta = ObjVentasE.DtResultados.SUM("Cantidad", $"CvePS = {CvePS}") @@ -19731,7 +19761,7 @@ Partial Class Ventas '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)") < (If(CantidadModal > 0, CantidadModal, Cantidad)) Then - Alert("No cuenta con la cantidad suficiente en inventario. Cuenta con " + Existencia.FormatoNumero(2) + ".", TipoMensaje.MsgAdvertencia) + Alert("No cuenta con la cantidad suficiente en inventario. Cuenta con " + Existencia.ToString("#,##0.####") + ".", TipoMensaje.MsgAdvertencia) Return False End If End If @@ -19744,6 +19774,9 @@ Partial Class Ventas If CveCliente = 1555244 Then ' GDIAZ - DICA VerificarCostos = False End If + + If UsuarioActual.TienePermisoProceso(253) Then VerificarCostos = False + If ObjDescuento IsNot Nothing Then If ObjDescuento.CvePromocionDetalle > 0 Then VerificarCostos = False @@ -19835,7 +19868,13 @@ Partial Class Ventas Dim TienePermisoImportes As Boolean = UsuarioActual.TienePermisoProceso(201) If Not EsValido Then - MensajeCosto.AppendFormat("El Producto {0}-{1}. No se puede vender a un precio menor de su Costo
", HdnCodigoPS.Value, HdnPS.Value) + Dim tNomPS As String = "" + Dim DrPS As DataRow = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") + 'valida sino tiene promocion la clasificacion + If DrPS IsNot Nothing Then + tNomPS = DrPS("PSCodigo").ToString + End If + MensajeCosto.AppendFormat("El Producto {0}. No se puede vender a un precio menor de su Costo
", tNomPS) If TienePermisoImportes Then MensajeCosto.AppendFormat("El costo del producto es: ${0:#,###.00}
", Costo) MensajeCosto.AppendFormat("El rango menor aceptado es: {0}% ${1:#,###.00}
", PorcentajeMinimoCostoEmpresa, CostoMenor) @@ -19848,7 +19887,13 @@ Partial Class Ventas 'NO DEJA REGISTRAR MAS AL PRECIO MAXIMO If Not EsValidoMayor Then - MensajeCosto.AppendFormat("El Producto {0}. No se puede vender a un precio mayor de su rango aceptado
", HdnPS.Value) + Dim tNomPS As String = "" + Dim DrPS As DataRow = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") + 'valida sino tiene promocion la clasificacion + If DrPS IsNot Nothing Then + tNomPS = DrPS("PSCodigo").ToString + End If + MensajeCosto.AppendFormat("El Producto {0}. No se puede vender a un precio mayor de su rango aceptado
", tNomPS) If TienePermisoImportes Then MensajeCosto.AppendFormat("El costo del producto es: ${0:#,###.00}
", Costo) MensajeCosto.AppendFormat("El rango mayor aceptado es: {0}% ${1:#,###.00}
", UsuarioActual.Empresa.Funcionalidad(133).ToEntero(), CostoMayor)