Autorizaciones de limite de credito

This commit is contained in:
2021-06-23 11:22:17 -07:00
parent 324744cd95
commit 61685fa0b0
9 changed files with 828 additions and 31 deletions

View File

@@ -1847,6 +1847,14 @@ Partial Class Ventas
ViewState("EsDiasCreditoFijo") = value
End Set
End Property
Private Property TieneDiasVencidos As Boolean
Get
Return CBool(IfNull(ViewState("TieneDiasVencidos"), "False", ViewState("TieneDiasVencidos")))
End Get
Set(value As Boolean)
ViewState("TieneDiasVencidos") = value
End Set
End Property
Private Property VentaSaldoAlmacen As Decimal
Get
Return ViewState("VentaSaldoAlmacen").ToString().ToDecimal
@@ -1952,6 +1960,15 @@ Partial Class Ventas
End Set
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 "AuxiliarConta"
@@ -2147,6 +2164,10 @@ Partial Class Ventas
DivPenalizacion.Visible = True
End If
If UsuarioActual.CveRol = 1 Then
LnkSolicitarCredito.Visible = True
End If
DdlSATPS.setEsWebService(True) : DdlSATPS.Attributes.Add("data-metodo", "getpssat")
DivPSSAT.Visible = True
@@ -4245,6 +4266,11 @@ Partial Class Ventas
LblNCSaldoAnticipo.Visible = True
ChkAplicaNCAnticipo.Visible = True
ChkAplicaNCAnticipo.Checked = True
If SaldoVenta > 0 And UsuarioActual.TienePermisoProceso(100) Then
HLPagar.Visible = True
HLPagar.NavigateUrl = $"/Bancos/PopIEVentas.aspx?CveVenta={CveVenta}&TB_iframe=true&height=500&width=675"
HlCuentaTerminal.Visible = True
End If
Me.SaldoAnticipo = DbRowVenta("SaldoAnticipo").ToString().ToDecimal
If SaldoAnticipo > 0 Then
InicializaDTAnticiposAmortizacion()
@@ -5503,6 +5529,7 @@ Partial Class Ventas
LnkAgregarCliente.Visible = False
ClienteEsDistribuidor = Boolean.Parse(ObjCliente.DtResultados.Rows(0)("EsDistribuidor").ToString())
TieneDiasVencidos = Boolean.Parse(ObjCliente.DtResultados.Rows(0)("TieneDiasVencidos").ToString())
If EstatusCliente = False And Not DdlTipoComprobante.SelectedValue.Contiene("Cot", "DPe") And (CveVenta <= 0 Or EsCreaApartirDe) Then
Alert("El Cliente seleccionado no esta activo", TipoMensaje.MsgAdvertencia)
@@ -7817,6 +7844,64 @@ Partial Class Ventas
Exit Sub
End If
Me.CveAutorizacion = -1
'SI ES A CREDITO DEBE VERIFICAR SI TIENE AUTORIZACIONES
If UsuarioActual.CveRol = 1 AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso CveCliente > 0 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Egs") AndAlso RBLPago.SelectedValue = "1" Then
Dim TipoDocumentoAutorizacion As String = ""
Dim ImporteAutorizacion As Decimal = 0
Dim TipoAutorizacion As Integer = 0
Dim CveVendedor As Integer = DdlVendedor.SelectedValue.ToEntero()
Dim ObjVentas As New ClsVentas
Try
If ObjVentas.GetAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, CveVendedor, CveEstatus:=1) Then
Dim RowAutorizacion As DataRow = ObjVentas.DtResultados.FiltroPrimero($"CveVenta IS NULL AND CveTipoDocumento='{DdlTipoComprobante.SelectedValue}'", Orderby:="TipoAutorizacion")
If RowAutorizacion IsNot Nothing Then
TipoDocumentoAutorizacion = RowAutorizacion("CveTipoDocumento").ToString()
ImporteAutorizacion = RowAutorizacion("Importe").ToString().ToDecimal()
CveAutorizacion = RowAutorizacion("CveAutorizacion").ToString().ToEntero()
TipoAutorizacion = RowAutorizacion("TipoAutorizacion").ToString().ToEntero()
End If
End If
Catch ex As Exception
OnError("Ocurrió un error al obtener las autorizaciones", ex)
End Try
ObjVentas.Dispose()
If TipoDocumentoAutorizacion = "Ing" Then
If TipoAutorizacion = 1 Then
If ImporteAutorizacion < TxtTotal.Text.ToDecimal() Then
CveAutorizacion = -1
Alert($"El crédito autorizado es insuficiente. Crédito Disponible:{ImporteAutorizacion:N2}", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If TieneDiasVencidos Then
CveAutorizacion = -1
Alert($"El crédito no esta autorizado. El cliente tiene días vencidos", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
'SI NO SE ENCONTRO NINGUA AUTORIZACION
If TipoAutorizacion = 0 Then
If TieneDiasVencidos Then
CveAutorizacion = -1
Alert($"El crédito no esta autorizado. El cliente tiene días vencidos", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
End If
If DdlTipoComprobante.SelectedValue = "Egs" AndAlso CveAutorizacion <= 0 Then
CveAutorizacion = -1
Alert($"El crédito no esta autorizado. No tiene autorización para generar notas de crédito.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
EmitirImprimirNew(TipoDoctoViejo)
End Sub
@@ -10478,7 +10563,7 @@ Partial Class Ventas
End If
Dim totSubTotal As Decimal = Obj.SubTotal
Dim totSubTotal As Decimal = If(UsuarioActual.Empresa.CvePAC = 3, Obj.DtDetalle.SUMD("Total"), Obj.SubTotal) 'Obj.SubTotal
Dim totIVA As Decimal = Obj.IVA
Dim totRetIVA As Decimal = Obj.RetIVA
Dim totRetISR As Decimal = Obj.RetISR
@@ -11147,6 +11232,12 @@ Partial Class Ventas
factura.Timbre.Comprobante.Serie = ObjVentas.Serie
factura.Timbre.Comprobante.Folio = ObjVentas.Folio.ToString()
If UsuarioActual.CveRol = 1 AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso factura.TipoDocto = "Ing" AndAlso Me.CveAutorizacion > 0 Then
If Not ObjVentas.UpdateAutorizacionLimite(Me.CveAutorizacion, factura.CveCliente, factura.CveVenta) Then
ErrorList.Add("Error al guardar los limites de la autorizacion")
End If
End If
If ObjFactura.TipoDocto = "Ing" Then
If Not GuardarUsados(2, ObjVentas.IniciaTransacSQL, factura) Then
ErrorList.Add("Error al guardar usados")
@@ -31691,5 +31782,45 @@ Partial Class Ventas
BtnEliminarAdjunto.Visible = False
UpAdjuntar.Update()
End Sub
Protected Sub LnkSolicitarCredito_Click(sender As Object, e As EventArgs) Handles LnkSolicitarCredito.Click
If 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
TxtImporteSolicitud.Text = ""
RegistraScript("$('#DivModalSolicitarCredito').modal('show')")
UpModalSolicitud.Update()
End Sub
Protected Sub BtnSolicitarCredito_Click(sender As Object, e As EventArgs) Handles BtnSolicitarCredito.Click
Dim ObjPS As New ClsVentas
If ObjPS.AddAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, DdlVendedor.SelectedValue.ToEntero(), TxtImporteSolicitud.Text.ToDecimal(), 0, UsuarioActual.CveUsuario, DdlTipoAutorizacion.SelectedValue.ToEntero(), TipoDocumento:=DdlTipoDocto.SelectedValue) Then
RegistraScript("$('#DivModalSolicitarCredito').modal('hide')")
Alert("La autorización se agregó correctamente.", TipoMensaje.MsgInformacion)
End If
ObjPS.Dispose()
UpModalSolicitud.Update()
End Sub
Protected Sub DdlTipoAutorizacion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoAutorizacion.SelectedIndexChanged
DivImporteSolicitud.Visible = DdlTipoAutorizacion.SelectedValue.ToEntero() = 1
UpModalSolicitud.Update()
End Sub
Protected Sub DdlTipoDocto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoDocto.SelectedIndexChanged
Dim TipoDocto As String = DdlTipoDocto.SelectedValue.ToString()
Select Case TipoDocto
Case "Ing"
DivAutorizacion.Visible = True
DivImporteSolicitud.Visible = True
Case "Egs"
DivAutorizacion.Visible = False
DivImporteSolicitud.Visible = False
End Select
UpModalSolicitud.Update()
End Sub
End Class