From 2da9b4b78b6b0a42bc2de3f89798a683bc2c4de0 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Fri, 19 Aug 2022 11:22:05 -0700 Subject: [PATCH] BDH. Verificar si tiene credito restante aun si la autorizacion no es suficiente --- Ventas/Ventas.aspx.vb | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) 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