diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 6980c1b5f..bdd3a5681 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -8591,17 +8591,41 @@ Partial Class Ventas 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 + + If ImporteAutorizacion < TxtTotal.Text.ToDecimal() Then + Dim BloquearCredito As Boolean = True + CveAutorizacion = -1 + + 'VERIFICA SI TIENE CREDITO DISPONIBLE DENTRO DEL CLIENTE + Dim ObjCred As New ClsVentas + If ObjCred.ObtenerCreditoRestante(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero()) AndAlso ObjCred.DtResultados.Rows.Count > 0 Then + 'SI TIENE CREDITO DISPONIBLE NO BLOQUEAR AUNQUE LA AUTORIZACION NO TENGA EL IMPORTE DEL DOCUMENTO + If DdlSucursalCliente.SelectedValue.ToEntero() > 0 Then + If (ObjCred.DtResultados(0)("LimiteRestanteSucursal").ToString().ToDecimal - If(TxtTipoCambio.Visible, TxtTotal.Text.ToDecimal * TxtTipoCambio.Text.ToDecimal, TxtTotal.Text.ToDecimal)) > 0 Then + BloquearCredito = False + End If + Else + If (ObjCred.DtResultados(0)("LimiteRestanteCliente").ToString().ToDecimal - If(TxtTipoCambio.Visible, TxtTotal.Text.ToDecimal * TxtTipoCambio.Text.ToDecimal, TxtTotal.Text.ToDecimal)) > 0 Then + BloquearCredito = False + End If + End If + End If + ObjCred.Dispose() + + + If BloquearCredito Then + Alert($"El crédito autorizado es insuficiente. Crédito Disponible:{ImporteAutorizacion:N2}", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + End If + End If 'If TipoAutorizacion = 2 Then