--Descuento global para alatel

This commit is contained in:
2025-05-14 18:55:05 -07:00
parent 13ee4e900f
commit 1db5076321
2 changed files with 125 additions and 13 deletions

View File

@@ -3667,11 +3667,22 @@ Partial Class Ventas
InicializaDevolucionAlmacen()
HabilitarDescuentoGlobal()
End If
End Sub
Private Sub HabilitarDescuentoGlobal()
If UsuarioActual.CveRol = 1 AndAlso UsuarioActual.CveEmpresa.Contiene(181, 182, 183) AndAlso (CveVenta <= 0 OrElse EsCreaApartirDe) Then
ImgDescTotal.Visible = True
ImgDescTotal.Attributes.Add("onclick", "javascript:$('#ModalDescuentoGlobal').modal();")
End If
End Sub
#Region "Bloqueo Pantalla"
Private Sub ValidaUsuarioAcceso()
'VERIFICAR SI LA SESION SE ENCUENTRA BLOQUEADA
If UsuarioActual.Empresa.Funcionalidad(599) = "1" Then
@@ -17539,9 +17550,9 @@ Partial Class Ventas
saldo = (e.Row.DataKey("Saldo").ToString().ToDecimal * tipoCambio).TruncateDecimal
Else
saldo = e.Row.DataKey("Saldo").ToDecimal
End If
Else
saldo = e.Row.DataKey("Saldo").ToString().ToDecimal
End If
Else
saldo = e.Row.DataKey("Saldo").ToString().ToDecimal
If CveVenta <= 0 Then
If DdlTipoAmortizacionAnticipo.SelectedValue.Contiene("2") Then 'cuando es por NC, debe de tomar el total de su saldo respectivo
@@ -18592,6 +18603,25 @@ Partial Class Ventas
RegistraScript("$('#ModalDescuento').modal('hide')", "hidemodal")
UpPS.Update()
End Sub
Protected Sub BtnAplicarDescGlobal_Click(sender As Object, e As System.EventArgs) Handles BtnAplicarDescGlobal.Click
Dim DescuentoManual As Decimal = TxtMontoDescGlobal.Text.ToDecimal()
Dim PorcentajeDescuento As Decimal = TxtPorDescGlobal.Text.ToDecimal()
If DescuentoManual <> 0 AndAlso PorcentajeDescuento <> 0 Then
Alert("Debe elegir un solo tipo de descuento", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If PorcentajeDescuento > 100 Then
Alert("El porcentaje no puede ser mayor a 100", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
RecalculaPrecios(False, False, AplicarDescuentoGlobal:=True)
RegistraScript("$('#ModalDescuentoGlobal').modal('hide')", "hidemodal")
UpPS.Update()
End Sub
Private Sub BtnAplicarOtrosConceptos_Click(sender As Object, e As EventArgs) Handles BtnAplicarOtrosConceptos.Click
TotalOtrosConceptos = 0
@@ -40796,9 +40826,16 @@ Partial Class Ventas
RegistraScript("MuestraAnticipos();", "AE")
End Sub
Private Sub RecalculaPrecios(ByRef RecalculoPromociones As Boolean, Optional AplicarPromociones As Boolean = False)
Private Sub RecalculaPrecios(ByRef RecalculoPromociones As Boolean, Optional AplicarPromociones As Boolean = False, Optional AplicarDescuentoGlobal As Boolean = False)
Dim PuedeRecalcular As Boolean = False
Dim DescuentoManual As Decimal = 0, DescuentoPorcentaje As Decimal = 0
If AplicarDescuentoGlobal Then
DescuentoManual = TxtMontoDescGlobal.Text.ToDecimal()
DescuentoPorcentaje = TxtPorDescGlobal.Text.ToDecimal()
End If
If CveVenta <= 0 OrElse EsCreaApartirDe OrElse (ModalidadEdicion AndAlso Not DdlTipoComprobante.SelectedValue = "Cot") Then
PuedeRecalcular = True
End If
@@ -40812,19 +40849,25 @@ Partial Class Ventas
PuedeRecalcular = True
End If
If AplicarDescuentoGlobal Then
PuedeRecalcular = True
End If
If TmpDT IsNot Nothing AndAlso PuedeRecalcular Then
For Each Row As DataRow In TmpDT.Rows
Dim Cantidad As Decimal = Row("Cantidad").ToString().ToDecimal()
Dim CveClasificacion As Integer = Row("CveClasificacion").ToString().ToEntero
Dim CvePS As Integer = Row("CvePS").ToString().ToEntero
Dim CodigoPS As String = Row("CodigoPS").ToString()
Dim PUOriginal As Decimal = Row("PU").ToString().ToDecimal()
Dim CvePrecioListaSugerido As Integer = -1
Dim ObjPrecioSugerido As Modelos.MPrecioSugerido = Nothing
If AplicarPromociones Then
If AplicarPromociones OrElse AplicarDescuentoGlobal Then
ObjPrecioSugerido = New Modelos.MPrecioSugerido()
ObjPrecioSugerido.PrecioSugerido = Row("PU").ToString().ToDecimal()
ObjPrecioSugerido.PrecioSugerido = PUOriginal
ObjPrecioSugerido.CvePrecioLista = Row("CvePrecioLista").ToString().ToEntero()
Else
ObjPrecioSugerido = CalculaPrecioSugerido(CvePS, CveClasificacion)
@@ -40834,8 +40877,30 @@ Partial Class Ventas
Dim PU As Decimal = ObjPrecioSugerido.PrecioSugerido.RoundSQL(6)
Dim ObjDescuento As Modelos.VentaDescuentos = CalcularDescuentos(CvePS, Cantidad, PU)
If ObjDescuento.EsPUModificado Then
PU = ObjDescuento.PU
If AplicarDescuentoGlobal Then
If DescuentoManual > 0 Then
ObjDescuento.EsPUModificado = False
ObjDescuento.ImporteDescuento = DescuentoManual
ObjDescuento.ImporteProntoPago = 0
If ObjDescuento.ImporteDescuento > (Cantidad * PU) Then
Alert($"El producto y/o servicio '{CodigoPS}' no puede tener un descuento mayor al total", TipoMensaje.MsgAdvertencia)
Continue For
End If
End If
If DescuentoPorcentaje > 0 Then
ObjDescuento.EsPUModificado = False
ObjDescuento.ImporteDescuento = (Cantidad * PU) * (DescuentoPorcentaje / 100D)
ObjDescuento.ImporteProntoPago = 0
End If
Else
If ObjDescuento.EsPUModificado Then
PU = ObjDescuento.PU
End If
End If
'SI NO TIENE PROMOCION, NO MODIFICAR NADA