diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb
index ef6c31f2f..8a04f4559 100644
--- a/Ventas/Ventas.aspx.vb
+++ b/Ventas/Ventas.aspx.vb
@@ -2289,6 +2289,15 @@ Partial Class Ventas
End Set
End Property
+ Private Property TieneBloqueoPorCreditoVencimiento As Integer
+ Get
+ Return IfNull(ViewState("TieneBloqueoPorCreditoVencimiento"), "0", ViewState("TieneBloqueoPorCreditoVencimiento")).ToString().ToEntero()
+ End Get
+ Set(value As Integer)
+ ViewState("TieneBloqueoPorCreditoVencimiento") = value
+ End Set
+ End Property
+
Private Property EsNCDevolucionEfectivo As Boolean
Get
Return If(IsNothing(ViewState("EsNCDevolucionEfectivo")), False, CType(ViewState("EsNCDevolucionEfectivo"), Boolean))
@@ -2442,6 +2451,8 @@ Partial Class Ventas
Me.CveVendedorContrato = -1
Me.CveVendedorEmpresaCRM = -1
Me.EsGarantia = False
+ Me.TieneBloqueoPorCreditoVencimiento = 0
+ Me.ClienteEsDistribuidor = False
CveEmpresaCRM = 0
CveAcercamientoCRM = 0
EstatusCliente = False
@@ -5908,7 +5919,7 @@ Partial Class Ventas
End If
'ACTIVA BOTONERA | DEBE TENER CONCEPTOS PENDIENTES DE FACTURAR
- If TmpDT.SUM("CantidadFacturadaRem") < TmpDT.SUM("Cantidad") Then
+ If (TmpDT.SUM("CantidadFacturadaRem") < TmpDT.SUM("Cantidad")) AndAlso TieneBloqueoPorCreditoVencimiento = 0 Then
BtnsFacturar.Visible = True
'E119, bloquear la facturación de remisiones que no estén surtidas
@@ -5938,48 +5949,51 @@ Partial Class Ventas
'Si es Empresa de Acumuladores
If CveVenta > 0 AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso DbRowVenta("TipoDocto").ToString() = "Rem" AndAlso (GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() <> 5) Then
- BtnsFacturar.Visible = False
-
- Dim DtUsadosPendientes As DataTable = Nothing
- Dim DtGarantiasPendientes As DataTable = Nothing
-
- Dim ObjUsados As New ClsVentas
-
- If ObjUsados.GetVentasUsados(CveVenta, -1, DbRowVenta("Fecha").ToString().ToDateTime, UsuarioActual.CveEmpresa) Then
- DtUsadosPendientes = ObjUsados.DtResultados.Copy()
- End If
-
- If ObjUsados.GetVentasGarantiaPendiente(CveVenta, NowADS(), UsuarioActual.CveEmpresa) Then
- DtGarantiasPendientes = ObjUsados.DtResultados.Copy()
- End If
-
- 'If ObjUsados.GetVentasGarantiaPendiente(CveVenta, -1, NowADS(), UsuarioActual.CveEmpresa) Then
- ' DtGarantiasPendientes = ObjUsados.DtResultados.Copy()
- 'End If
-
- ObjUsados.Dispose()
-
- BtnsFacturar.Visible = True
-
- 'VERIFICA SI YA SE FACTURO COMPLETAMENTE
- If TmpDT.SUM("CantidadFacturadaRem") = TmpDT.SUM("Cantidad") Then
+ If TieneBloqueoPorCreditoVencimiento = 0 Then
BtnsFacturar.Visible = False
- End If
- 'VERIFICA SI TIENE USADOS O GARANTIAS PENDIENTES
- If BtnsFacturar.Visible Then
- If (Not EsGarantia AndAlso (DtUsadosPendientes IsNot Nothing AndAlso DtUsadosPendientes.Rows.Count > 0)) Then
- BtnsFacturar.Visible = False
- Alert("Tiene usados pendiente de recibir", TipoMensaje.MsgAdvertencia)
+ Dim DtUsadosPendientes As DataTable = Nothing
+ Dim DtGarantiasPendientes As DataTable = Nothing
+
+ Dim ObjUsados As New ClsVentas
+
+ If ObjUsados.GetVentasUsados(CveVenta, -1, DbRowVenta("Fecha").ToString().ToDateTime, UsuarioActual.CveEmpresa) Then
+ DtUsadosPendientes = ObjUsados.DtResultados.Copy()
End If
- If (EsGarantia AndAlso (DtGarantiasPendientes IsNot Nothing AndAlso DtGarantiasPendientes.Rows.Count > 0)) Then
- Alert("Tiene garantías pendientes de recibir", TipoMensaje.MsgAdvertencia)
+ If ObjUsados.GetVentasGarantiaPendiente(CveVenta, NowADS(), UsuarioActual.CveEmpresa) Then
+ DtGarantiasPendientes = ObjUsados.DtResultados.Copy()
+ End If
+
+ 'If ObjUsados.GetVentasGarantiaPendiente(CveVenta, -1, NowADS(), UsuarioActual.CveEmpresa) Then
+ ' DtGarantiasPendientes = ObjUsados.DtResultados.Copy()
+ 'End If
+
+ ObjUsados.Dispose()
+
+ BtnsFacturar.Visible = True
+
+ 'VERIFICA SI YA SE FACTURO COMPLETAMENTE
+ If TmpDT.SUM("CantidadFacturadaRem") = TmpDT.SUM("Cantidad") Then
BtnsFacturar.Visible = False
End If
+
+ 'VERIFICA SI TIENE USADOS O GARANTIAS PENDIENTES
+ If BtnsFacturar.Visible Then
+ If (Not EsGarantia AndAlso (DtUsadosPendientes IsNot Nothing AndAlso DtUsadosPendientes.Rows.Count > 0)) Then
+ BtnsFacturar.Visible = False
+ Alert("Tiene usados pendiente de recibir", TipoMensaje.MsgAdvertencia)
+ End If
+
+ If (EsGarantia AndAlso (DtGarantiasPendientes IsNot Nothing AndAlso DtGarantiasPendientes.Rows.Count > 0)) Then
+ Alert("Tiene garantías pendientes de recibir", TipoMensaje.MsgAdvertencia)
+ BtnsFacturar.Visible = False
+ End If
+ End If
+
+ LBFacturarAnticipo.Visible = UsuarioActual.TienePermisoProceso(274)
End If
- LBFacturarAnticipo.Visible = UsuarioActual.TienePermisoProceso(274)
End If
'SI ES COMPLEMENTARIA, NO DEBE PERMITIR FACTURAR
@@ -6074,7 +6088,7 @@ Partial Class Ventas
CargaPS(-1, DdlPS)
'Verifico si tiene la funcionalidad (135)
- If DdlTipoComprobante.SelectedValue = "Cot" AndAlso UsuarioActual.Empresa.Funcionalidad(135).Contiene("1", "2") Then
+ If DdlTipoComprobante.SelectedValue = "Cot" AndAlso UsuarioActual.Empresa.Funcionalidad(135).Contiene("1", "2") AndAlso TieneBloqueoPorCreditoVencimiento = 0 Then
Select Case UsuarioActual.Empresa.Funcionalidad(135)
Case "1" ' POR SUPERVISOR
@@ -7593,7 +7607,7 @@ Partial Class Ventas
If Not EsCreaApartirDe AndAlso (DdlTipoComprobante.SelectedValue = "Cot" AndAlso CveVenta > 0) Then
DdlTipoComprobante.SelectedValueExist("Cot")
Else
- If UsuarioActual.Empresa.Funcionalidad(531) <> "1" Then
+ If UsuarioActual.Empresa.Funcionalidad(595) = "1" Then
DdlTipoComprobante.SelectedValueExistInsert("PA", "Autorización")
DdlTipoComprobante.SelectedValue = "PA"
@@ -7614,9 +7628,19 @@ Partial Class Ventas
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem"))
End If
+ Dim Bloqueo As Boolean = False
+
+ If Not DdlTipoComprobante.SelectedValue.Contiene("PA") AndAlso UsuarioActual.Empresa.Funcionalidad(531) <> "1" Then
+ Bloqueo = True
+ End If
+
+ 'SI EL CLIENTE ES DISTRIBUIDOR Y TIENE FACTURAS VENCIDAS, DEBE BLOQUEAR
+ If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso ClienteEsDistribuidor AndAlso Opcion = 2 Then
+ Bloqueo = True
+ End If
'SI ES AUTORIZACION DEBE PERMITIR GENERARLA
- If (Not DdlTipoComprobante.SelectedValue.Contiene("PA")) AndAlso UsuarioActual.Empresa.Funcionalidad(531) <> "1" Then
+ If Bloqueo Then
BtnEmitirImprimir.Visible = False
BtnsFacturar.Visible = False
LBFacturarAnticipo.Visible = UsuarioActual.TienePermisoProceso(274)
@@ -7624,6 +7648,11 @@ Partial Class Ventas
LnkPedido2SinFacturar.Visible = False
LnkCotizaciones.Visible = False
LnkOCs.Visible = False
+
+ If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
+ TieneBloqueoPorCreditoVencimiento = 1
+ End If
+
End If
If DdlTipoComprobante.SelectedValue = "Cot" AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
@@ -7648,6 +7677,7 @@ Partial Class Ventas
'SI NO TIENE AUTORIZACION, MANTIENE EL BLOQUEO POR CONDICIONES DE CREDITO
If Autorizacion > 0 Then
BtnsFacturar.Visible = True
+ TieneBloqueoPorCreditoVencimiento = 0
End If
End If
@@ -7691,6 +7721,7 @@ Partial Class Ventas
'SI NO TIENE AUTORIZACION, MANTIENE EL BLOQUEO POR CONDICIONES DE CREDITO
If Autorizacion > 0 Then
BtnsFacturar.Visible = True
+ TieneBloqueoPorCreditoVencimiento = 0
End If
End If
@@ -7761,6 +7792,10 @@ Partial Class Ventas
BtnsFacturar.Visible = False
BtnGenerarRemision.Visible = False
Alert(OpcionMsg, TipoMensaje.MsgAdvertencia)
+
+ If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
+ TieneBloqueoPorCreditoVencimiento = 1
+ End If
End If
End If
End If
@@ -7797,6 +7832,9 @@ Partial Class Ventas
BtnsFacturar.Visible = False
BtnGenerarRemision.Visible = False
Alert(OpcionMsg, TipoMensaje.MsgAdvertencia)
+ If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
+ TieneBloqueoPorCreditoVencimiento = 1
+ End If
End If
End If
@@ -7825,13 +7863,32 @@ Partial Class Ventas
'VERIFICAR RESTRICCIONES DEL CLIENTE
If Not UsuarioActual.Empresa.Funcionalidad(702).ToEntero() > 0 Then
- If (DdlTipoComprobante.SelectedValue = "Cot" AndAlso CveVenta > 0 AndAlso RBLPago.SelectedValue = "2") Then
- Dim Valida As Boolean = True
- If UsuarioActual.Empresa.Funcionalidad(109) = "1" AndAlso (Me.CveCliente = UsuarioActual.Empresa.Funcionalidad(714).ToEntero() OrElse Me.PermiteCredito) Then
- Valida = False
+
+ Dim ValidaRemision As Boolean = False
+ If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
+ ValidaRemision = True
+ End If
+
+ Dim ValidaCondicionesCredito As Boolean = False
+
+ 'SI ES UNA VENTA EXISTENTE
+ If CveVenta > 0 Then
+ If (DdlTipoComprobante.SelectedValue = "Cot") AndAlso RBLPago.SelectedValue = "2" Then
+ ValidaCondicionesCredito = True
End If
- If Valida Then
+ If (ValidaRemision AndAlso DdlTipoComprobante.SelectedValue = "Rem") Then
+ ValidaCondicionesCredito = True
+ End If
+ End If
+
+ If ValidaCondicionesCredito Then
+ Dim ValidaCliente As Boolean = True
+ If UsuarioActual.Empresa.Funcionalidad(109) = "1" AndAlso (Me.CveCliente = UsuarioActual.Empresa.Funcionalidad(714).ToEntero() OrElse Me.PermiteCredito) Then
+ ValidaCliente = False
+ End If
+
+ If ValidaCliente Then
Dim Vta As New ClsVentas
Dim Opcion As Integer = Vta.ObtenerClienteLimitesVenta(CveCliente, UsuarioActual.CveEmpresa)
Dim OpcionMsg As String = String.Format("El Cliente se encuentra bloqueado por la siguiente razón:
{0}", Vta.SerieVenta)
@@ -7861,6 +7918,10 @@ Partial Class Ventas
Alert(OpcionMsg, TipoMensaje.MsgAdvertencia)
BtnsFacturar.Visible = False
BtnGenerarRemision.Visible = False
+
+ If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
+ TieneBloqueoPorCreditoVencimiento = 1
+ End If
End If
Else
@@ -7868,6 +7929,10 @@ Partial Class Ventas
Alert(OpcionMsg, TipoMensaje.MsgAdvertencia)
BtnsFacturar.Visible = False
BtnGenerarRemision.Visible = False
+
+ If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
+ TieneBloqueoPorCreditoVencimiento = 1
+ End If
End If
End If
End If