From 8f75a1442725e787f87d3c4e6a80e04883ac6bfd Mon Sep 17 00:00:00 2001 From: JPerez Date: Fri, 20 Jun 2025 17:42:55 -0700 Subject: [PATCH] --FIX descuentos generales --- Ventas/PV.aspx.vb | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Ventas/PV.aspx.vb b/Ventas/PV.aspx.vb index 20af6ed08..e09397b17 100644 --- a/Ventas/PV.aspx.vb +++ b/Ventas/PV.aspx.vb @@ -3603,6 +3603,41 @@ Partial Class PV End If + 'VALIDA DESCUENTOS GENERALES + If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso DdlTipoComprobante.SelectedValue.Contiene("Rem") Then + + Dim ValidoDescuentos As Boolean = True + Dim DtTamanios As DataTable = GlobalDTAcumTamaños(UsuarioActual.CveEmpresa).FiltraParametros($" CvePSCargo > 0") + + For Each Row As DataRow In TmpDT.Rows + Dim CvePS As Integer = Row("CvePS").ToString().ToEntero() + Dim Cantidad As Decimal = Row("Cantidad").ToString().ToDecimal() + Dim PU As Decimal = Row("PU").ToString().ToDecimal() + Dim Descuento As Decimal = Row("Descuento").ToString().ToDecimal() + + Dim EsGarantia As Boolean = ObjFactura.EsGarantia OrElse Row("Obs").ToString().Contains("Descuento por garantía") + + Dim EsCargo As Boolean = DtTamanios IsNot Nothing AndAlso DtTamanios.FiltraParametros($"CvePSCargo = {CvePS}").Rows.Count = 1 + + If Not EsGarantia AndAlso Not EsCargo Then + Dim porcentaje = ((Descuento) / (Cantidad * PU).RoundSQL(2)) * 100D + + If porcentaje > 41 Then + Alert($"El producto '{Row("CodigoPS")}' no puede tener un descuento mayor al 40%", TipoMensaje.MsgAdvertencia) + ValidoDescuentos = False + Exit For + End If + + End If + + Next + + If Not ValidoDescuentos Then + Exit Sub + End If + + End If + If ObjFactura.CveCliente > 0 Then If TmpDT.Rows.Count > 0 Then