E140. Solicitud de descuento por autorizacion

This commit is contained in:
2022-04-13 15:46:11 -07:00
parent 3b9cd42f80
commit 7583974bc7
5 changed files with 426 additions and 203 deletions

View File

@@ -701,6 +701,14 @@ Partial Class PV
}
End Get
End Property
Private Property CveAutorizacion As Integer
Get
Return (IfNull(ViewState("CveAutorizacion"), "-1", ViewState("CveAutorizacion"))).ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveAutorizacion") = value
End Set
End Property
#End Region
#Region "PROPIEDADES DE PUNTO DE VENTA"
@@ -1027,6 +1035,7 @@ Partial Class PV
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
ViewState("CveVenta") = -1
Me.CveAutorizacion = -1
'VERIFICAR SI LA SESION SE ENCUENTRA BLOQUEADA
If UsuarioActual.Empresa.Funcionalidad(599) = "1" Then
Dim DrUsuario As DataRow = GlobalDTUsuarios(CveUsuario:=UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).Rows(0)
@@ -1135,11 +1144,15 @@ Partial Class PV
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
ImgDescPU.Attributes.Add("onclick", "javascript:AbrirModalDescuentoAdicional();")
ImgDescPU.Visible = False
LnkDescPU.Visible = True
TxtPorDescP.Attributes.Add("onKeyUp", "CalculaDescuentoAdicional();")
TxtDescP.Attributes.Add("onKeyUp", "CalculaDescuentoMontoAdicional();")
TrDescuentoIncluido.Visible = True
TrDescuentoAdicional.Visible = True
Else
ImgDescPU.Visible = True
LnkDescPU.Visible = False
ImgDescPU.Attributes.Add("onclick", "javascript:$('#ModalDescuento').modal(); $get('LblTitulo1').style.display = ''; $get('LblTitulo2').style.display = 'none'; $get('LblTituloTipo1').style.display = ''; $get('LblTituloTipo2').style.display = 'none'; $get('HdnTipoDescuento').value = '0'; $get('LblPrecio1').style.display = ''; $get('LblTotalPS1').style.display = 'none'; $get('LblSubTotal1').style.display = 'none'; $get('LblAmort').style.display = 'none'; $get('BtnAplicarDescP').style.display = ''; $get('BtnAplicarDescG').style.display = 'none'; $get('TrMotivoDescuento').style.display = '';")
TxtPorDescP.Attributes.Add("onKeyUp", "CalculaDescuento();")
TxtDescP.Attributes.Add("onKeyUp", "CalculaDescuentoMonto();")
@@ -1189,7 +1202,7 @@ Partial Class PV
If UsuarioActual.Empresa.Funcionalidad(531).ToString = "1" Then
CargaAjuste()
RVPorDesc.MaximumValue = UsuarioActual.DescuentoAutorizado.ToString
RVPorDesc.ErrorMessage = $"El rango para el % de descuento debe de estar entre <b>0</b> y <b>{UsuarioActual.DescuentoAutorizado.ToString}</b>."
RVPorDesc.ErrorMessage = $"El rango para el % de descuento debe de estar entre <b>0</b> y <b>{UsuarioActual.DescuentoAutorizado.ToString}</b>."
End If
LimpiaEscondeContado()
@@ -3425,6 +3438,7 @@ Partial Class PV
Dim TieneError As Boolean = False
Dim ObjAcum As New ClsAcumuladores
Dim ObjVentas As New ClsVentas(ObjAcum.IniciaTransacSQL())
Dim ObjContPaq As ClsContPAQi = Nothing
If UsuarioActual.Empresa.UsaAC OrElse UsuarioActual.Empresa.Funcionalidad(200) = "1" Then
ObjContPaq = New ClsContPAQi(UsuarioActual.Empresa)
@@ -3462,6 +3476,12 @@ Partial Class PV
'End If
If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso Me.CveAutorizacion > 0 Then
If Not ObjVentas.UpdateAutorizacionLimite(Me.CveAutorizacion, ObjFactura.CveCliente, Retorno.CveVenta) Then
ErrorList.Add("Error al guardar los limites de la autorizacion")
End If
End If
If ObjAcum.GetGarantiasDetalle(Retorno.CveVenta) Then
Dim RowGarantia As DataRow = ObjAcum.DtResultados.FiltroPrimero("")
If RowGarantia IsNot Nothing Then
@@ -3489,13 +3509,15 @@ Partial Class PV
If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack()
ObjAcum.Dispose()
ObjVentas.Dispose()
If ObjContPaq IsNot Nothing Then ObjContPaq.Dispose()
Me.CveAutorizacion = -1
Else
ObjAcum.Commit()
If ObjContPaq IsNot Nothing Then ObjContPaq.Commit()
ObjAcum.Dispose()
ObjVentas.Dispose()
If ObjContPaq IsNot Nothing Then ObjContPaq.Dispose()
RegistraScript($"descargarPDF('{urlFactura}','{urlAjuste}');", "Imprimir")
@@ -4145,7 +4167,8 @@ Partial Class PV
If PrecioSugerido > 0 Then
TxtPrecio.Text = PrecioSugerido.FormatoNumero()
RegistraScript("$get('LblPrecio1').innerText = formato_numero(" + PrecioSugerido.ToString + ", 2, '.', ',');")
LblPrecio1.Text = PrecioSugerido.FormatoNumero()
'RegistraScript("$get('LblPrecio1').innerText = formato_numero(" + PrecioSugerido.ToString + ", 2, '.', ',');")
End If
@@ -4183,7 +4206,8 @@ Partial Class PV
If PrecioSugerido > 0 AndAlso TxtDescuento.Text.ToDecimal() > 0 Then
TxtPrecio.Text = PrecioSugerido.FormatoNumero()
RegistraScript("$get('LblPrecio1').innerText = formato_numero(" + PrecioSugerido.ToString() + ", 2, '.', ',');", "A1")
LblPrecio1.Text = PrecioSugerido.FormatoNumero()
'RegistraScript("$get('LblPrecio1').innerText = formato_numero(" + PrecioSugerido.ToString() + ", 2, '.', ',');", "A1")
End If
If ChkAjuste.Checked Then
@@ -8305,4 +8329,62 @@ Partial Class PV
UpAgregarCliente.Update()
End Sub
Protected Sub LnkSolicitarDesc_Click(sender As Object, e As EventArgs)
If Me.CveCliente <= 0 Then
Alert("Debe seleccionar un cliente.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If DdlVendedor.SelectedValue.ToEntero() <= 0 Then
Alert("Debe seleccionar un vendedor.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
LtlClienteDescuento.Text = LblCliente.Text
LtlVendedorDescuento.Text = DdlVendedor.SelectedItem.Text
UpSolicitarDescuento.Update()
RegistraScript("$('#ModalSolicitudDescuento').modal()")
End Sub
Protected Sub BtnSolicitarDescuento_Click(sender As Object, e As EventArgs)
Dim DiasVencidos As Integer = 0
Dim CveEstatus As Integer = 0
Dim CveTipoAutorizacion As Integer = 3
Dim Motivo As String = TxtMotivo.Text.Trim
Dim ObjPS As New ClsVentas
If ObjPS.AddAutorizacionLimite(UsuarioActual.CveEmpresa, Me.CveCliente, DdlVendedor.SelectedValue.ToEntero(), 0, CveEstatus, UsuarioActual.CveUsuario, CveTipoAutorizacion, "Rem", DiasVencidos, Motivo:=Motivo, PorcentajeDescuento:=TxtPorcentaje.Text.ToDecimal()) Then
RegistraScript("$('#ModalSolicitudDescuento').modal('hide')")
Alert("La autorización se agregó correctamente.", TipoMensaje.MsgInformacion)
End If
ObjPS.Dispose()
End Sub
Protected Sub LnkDescPU_Click(sender As Object, e As EventArgs)
Dim ObjVentas As New ClsVentas
If ObjVentas.GetAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, DdlVendedor.SelectedValue.ToEntero, "Rem", CveEstatus:=1) Then
Dim RowAutorizacion As DataRow = Nothing
'SI TIENE DIAS VENCIDOS BUSCAR POR TIPO VENCIMIENTO
RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion = 3 AND CveVenta IS NULL AND CveTipoDocumento='Rem'", Orderby:="Importe DESC")
If RowAutorizacion IsNot Nothing Then
Me.CveAutorizacion = RowAutorizacion("CveAutorizacion").ToString().ToEntero()
HdnPorcentajeDescuentoMaximo.Value = RowAutorizacion("PorcentajeDescuento").ToString()
RVPorDesc.MaximumValue = HdnPorcentajeDescuentoMaximo.Value
RVPorDesc.ErrorMessage = $"El rango para el % de descuento debe de estar entre <b>0</b> y <b>{HdnPorcentajeDescuentoMaximo.Value.ToDecimal().FormatoNumero}</b>."
End If
End If
ObjVentas.Dispose()
TxtPorDescP.Attributes.Clear()
TxtPorDescP.Attributes.Add("onKeyUp", "CalculaDescuentoAdicional();")
TxtDescP.Attributes.Clear()
TxtDescP.Attributes.Add("onKeyUp", "CalculaDescuentoMontoAdicional();")
UPPDescuento.Update()
RegistraScript("AbrirModalDescuentoAdicional();")
End Sub
End Class