diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb
index b92c5eca9..f2142985f 100644
--- a/Ventas/Ventas.aspx.vb
+++ b/Ventas/Ventas.aspx.vb
@@ -2562,15 +2562,13 @@ Partial Class Ventas
thPoliza2.Visible = True
End If
- If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso UsuarioActual.CveUsuario = 100 Then
- DivPenalizacion.Visible = True
- End If
+ If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso UsuarioActual.CveUsuario = 100 Then DivPenalizacion.Visible = True
+ End If
- If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
+ If UsuarioActual.Empresa.Funcionalidad(595) = "2" Then
LnkSolicitarCredito.Visible = True
End If
-
DdlSATPS.setEsWebService(True) : DdlSATPS.Attributes.Add("data-metodo", "getpssat")
DivPSSAT.Visible = True
@@ -2881,8 +2879,6 @@ Partial Class Ventas
BtnCrearApartirDe.Visible = True
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then BtnCrearApartirDe.Visible = False
-
-
If DdlTipoComprobante.SelectedValue = "Ped" Then
BtnPermisoEditarRemision.Text = "Editar Pedido"
BtnEditarRemision.Text = "Actualizar Pedido"
@@ -3969,7 +3965,7 @@ Partial Class Ventas
Alert("Se ha cerrado el turno correctamente.", TipoMensaje.MsgInformacion, Liga)
End If
Else
- Alert("Debe especificar el efectivo en caja", TipoMensaje.MsgAdvertencia)
+ Alert("Debe especificar el efectivo en caja", TipoMensaje.ToastAdventencia)
RegistraScript("window.onload = function MuestraPantallaBloqueo() { document.getElementById(""C_btnShowBloqueo"").click(); }")
End If
ObjPVenta.Dispose()
@@ -7208,7 +7204,6 @@ Partial Class Ventas
Alert("Ocurrió un error al cargar los datos del cliente. Por favor vuelva a intentar.", TipoMensaje.MsgError)
End If
-
CveAlmacenAsignado = ObjCliente.CveAlmacenAsignado
End If
@@ -7565,7 +7560,7 @@ Partial Class Ventas
RBLPago.Items(0).Enabled = False
RBLPago_SelectedIndexChanged(Nothing, Nothing)
'GENERAR UNA AUTORIZACIÓN SI EL CLIENTE NO PERMITE CREDITO
- If UsuarioActual.Empresa.Funcionalidad(595) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(268) Then
+ If ValorAutorizacion = "1" AndAlso Not UsuarioActual.TienePermisoProceso(268) Then
'SI LLEGÓ POR LA OPCIÓN DE COTIZACIÓN NO DEBE DE RESTRINGUIR
If IfNull(Request("Op"), "").ToString() = "Cot" OrElse (DdlTipoComprobante.SelectedValue = "Cot" AndAlso CveVenta > 0) Then
DdlTipoComprobante.SelectedValue = "Cot"
@@ -7615,7 +7610,6 @@ Partial Class Ventas
UPCondicionesPago.Update()
End If
-
Dim CreditoDispo As Decimal = CargaCreditoDisponible(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero())
If CreditoDispo > 0 Then
@@ -7652,7 +7646,7 @@ Partial Class Ventas
If IfNull(Request("Op"), "").ToString() = "Cot" OrElse (DdlTipoComprobante.SelectedValue = "Cot" AndAlso CveVenta > 0) Then DdlTipoComprobante.SelectedValue = "Cot"
'quito remisión y factura
- If UsuarioActual.Empresa.Funcionalidad(531) <> "1" Then
+ If UsuarioActual.Empresa.Funcionalidad(595) <> "2" Then
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing"))
If Not UsuarioActual.TienePermisoProceso(325) Then
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant"))
@@ -7671,7 +7665,7 @@ Partial Class Ventas
Bloqueo = True
End If
- If Bloqueo AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
+ If Bloqueo AndAlso ValorAutorizacion = "2" Then
Dim Autorizacion As Integer = 0
Dim ObjVentas As New ClsVentas
@@ -7694,7 +7688,7 @@ Partial Class Ventas
If Autorizacion > 0 Then
Bloqueo = False
TieneBloqueoPorCreditoVencimiento = 0
- Alert("El cliente tiene una autorización aprobada")
+ Alert("El cliente tiene una autorización aprobada", TipoMensaje.ToastInformacion)
End If
End If
@@ -7713,10 +7707,8 @@ Partial Class Ventas
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
TieneBloqueoPorCreditoVencimiento = 1
End If
-
End If
-
Else
' el cliente tiene crédito disponible, no tiene bloqueo
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("PA"))
@@ -7837,15 +7829,54 @@ Partial Class Ventas
Case "2" 'Autorizacion desde una solicitud del catalogo de autorizaciones
'RMF. validacion temporal
'verifica si tiene autorizaciones de Nota de crédito autorizadas
- Dim ObjVentas As New ClsVentas
- If ObjVentas.GetAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, -1, "Ing", CveEstatus:=1) Then
- Dim RowAutorizacion As DataRow = ObjVentas.DtResultados.FiltroPrimero($"CveVenta IS NULL AND CveTipoDocumento='Egs'", Orderby:="TipoAutorizacion")
- If RowAutorizacion IsNot Nothing Then
- DdlTipoComprobante.SelectedValueExistInsert("Egs", "Egresos")
- End If
+ 'Dim ObjVentas As New ClsVentas
+ 'If ObjVentas.GetAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, -1, "Ing", CveEstatus:=1) Then
+ ' Dim RowAutorizacion As DataRow = ObjVentas.DtResultados.FiltroPrimero($"CveVenta IS NULL AND CveTipoDocumento='Egs'", Orderby:="TipoAutorizacion")
+ ' If RowAutorizacion IsNot Nothing Then
+ ' DdlTipoComprobante.SelectedValueExistInsert("Egs", "Egresos")
+ ' End If
+ 'End If
+ 'ObjVentas.Dispose()
+ 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)
+ Vta.Dispose()
+ If Opcion > 0 Then
+ If Alertas Then Alert(OpcionMsg, TipoMensaje.MsgAdvertencia)
+ Else
+ If Alertas Then Alert("El cliente tiene su límite de crédito agotado.", TipoMensaje.MsgAdvertencia)
End If
- ObjVentas.Dispose()
- Case Else 'SI NO TIENE NINGUN TIPO DE AUTORIZACION CONFIGURADO
+ LnkSolicitarCredito.Visible = True
+ DdlTipoAutorizacion.SelectedValueExist("1")
+
+ If Not UsuarioActual.TienePermisoProceso(268) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "PA") Then
+ Dim Autorizacion As Integer = 0
+
+ Dim ObjVentas As New ClsVentas
+ If ObjVentas.GetAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, DdlVendedor.SelectedValue.ToEntero, "Ing", CveEstatus:=1) Then
+ Dim RowAutorizacion As DataRow = Nothing
+ 'SI TIENE DIAS VENCIDOS BUSCAR POR TIPO VENCIMIENTO
+ If TieneDiasVencidos Then
+ RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion IN(1,2) AND CveVenta IS NULL AND CveTipoDocumento='Ing'", Orderby:="Importe DESC")
+ Else
+ RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion = 1 AND CveVenta IS NULL AND CveTipoDocumento='Ing'", Orderby:="Importe DESC")
+ End If
+
+ If RowAutorizacion IsNot Nothing Then
+ Autorizacion = RowAutorizacion("CveAutorizacion").ToString().ToEntero()
+ End If
+ End If
+ ObjVentas.Dispose()
+
+ 'SI NO TIENE AUTORIZACION, MANTIENE EL BLOQUEO POR CONDICIONES DE CREDITO
+ If Autorizacion <= 0 Then
+ BtnEmitirImprimir.Visible = False
+ TieneBloqueoPorCreditoVencimiento = 1
+ End If
+
+ End If
+
+ Case Else 'SI NO TIENE NINGUN TIPO DE AUTORIZACION CONFIGURADO
'VERIFICAR CANDADOS DE VENTA
If DdlTipoComprobante.SelectedValue = "Cot" AndAlso CveVenta > 0 Then
Dim Vta As New ClsVentas
@@ -7871,37 +7902,6 @@ Partial Class Ventas
'este codigo no es temporal
If Alertas Then Alert("El cliente tiene su límite de crédito agotado.", TipoMensaje.MsgAdvertencia)
- If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
- LnkSolicitarCredito.Visible = True
- DdlTipoAutorizacion.SelectedValueExist("1")
-
- If Not UsuarioActual.TienePermisoProceso(268) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "PA") Then
- Dim Autorizacion As Integer = 0
-
- Dim ObjVentas As New ClsVentas
- If ObjVentas.GetAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, DdlVendedor.SelectedValue.ToEntero, "Ing", CveEstatus:=1) Then
- Dim RowAutorizacion As DataRow = Nothing
- 'SI TIENE DIAS VENCIDOS BUSCAR POR TIPO VENCIMIENTO
- If TieneDiasVencidos Then
- RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion IN(1,2) AND CveVenta IS NULL AND CveTipoDocumento='Ing'", Orderby:="Importe DESC")
- Else
- RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion = 1 AND CveVenta IS NULL AND CveTipoDocumento='Ing'", Orderby:="Importe DESC")
- End If
-
- If RowAutorizacion IsNot Nothing Then
- Autorizacion = RowAutorizacion("CveAutorizacion").ToString().ToEntero()
- End If
- End If
- ObjVentas.Dispose()
-
- 'SI NO TIENE AUTORIZACION, MANTIENE EL BLOQUEO POR CONDICIONES DE CREDITO
- If Autorizacion <= 0 Then
- BtnEmitirImprimir.Visible = False
- TieneBloqueoPorCreditoVencimiento = 1
- End If
-
- End If
- End If
End If
End Select
@@ -8063,25 +8063,19 @@ Partial Class Ventas
End If
End If
- 'CUANDO SEA COTIZACION Y SEA COMPUPROVEEDORES (EMPRESA 72) NO DEBE ENVIAR CORREO AL CLIENTE
- If UsuarioActual.CveEmpresa = 72 AndAlso DdlTipoComprobante.SelectedValue = "Cot" Then
+ If DdlTipoComprobante.SelectedValue.Contiene("Rem", "PeC", "PA", "Ped") Then
+ 'ENVIO DE FACTURA
ChkEnviarFactura.Checked = False
- ChkEnviarFactura.Visible = False
- LblEnviarMail.Visible = False
+ ChkEnviarFactura.Visible = True
+ LblEnviarMail.Visible = True
+ If CveVenta > 0 AndAlso EnviarCorreoCliente Then ChkEnviarFactura.Checked = EnviarCorreoCliente
Else
- If DdlTipoComprobante.SelectedValue.Contiene("Rem", "PeC", "PA", "Ped") Then
- 'ENVIO DE FACTURA
- ChkEnviarFactura.Checked = False
- ChkEnviarFactura.Visible = True
- LblEnviarMail.Visible = True
- If CveVenta > 0 AndAlso EnviarCorreoCliente Then ChkEnviarFactura.Checked = EnviarCorreoCliente
- Else
- ChkEnviarFactura.Checked = EnviarCorreoCliente
- ChkEnviarFactura.Visible = True
- LblEnviarMail.Visible = True
- End If
+ ChkEnviarFactura.Checked = EnviarCorreoCliente
+ ChkEnviarFactura.Visible = True
+ LblEnviarMail.Visible = True
End If
+
End Sub
@@ -9711,46 +9705,38 @@ Partial Class Ventas
Me.CveAutorizacion = -1
'SI ES A CREDITO DEBE VERIFICAR SI TIENE AUTORIZACIONES
- If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso CveCliente > 0 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing") AndAlso RBLPago.SelectedValue = "1" Then
+ If UsuarioActual.Empresa.Funcionalidad(595) = "2" AndAlso CveCliente > 0 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing") AndAlso RBLPago.SelectedValue = "1" Then
Dim TipoDocumentoAutorizacion As String = ""
Dim ImporteAutorizacion As Decimal = 0
Dim TipoAutorizacion As Integer = 0
Dim DiasVencidosAutorizacion As Integer = 0
Dim CveVendedor As Integer = DdlVendedor.SelectedValue.ToEntero()
Dim ObjVentas As New ClsVentas
- Try
- If ObjVentas.GetAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, CveVendedor, "Ing", CveEstatus:=1) Then
- Dim RowAutorizacion As DataRow = Nothing
- 'SI TIENE DIAS VENCIDOS BUSCAR POR TIPO VENCIMIENTO
- If TieneDiasVencidos Then
- RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion IN(1,2) AND CveVenta IS NULL AND CveTipoDocumento='Ing'", Orderby:="Importe DESC")
- Else
- RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion = 1 AND CveVenta IS NULL AND CveTipoDocumento='Ing'", Orderby:="Importe DESC")
- End If
-
- If RowAutorizacion IsNot Nothing Then
- TipoDocumentoAutorizacion = RowAutorizacion("CveTipoDocumento").ToString()
- ImporteAutorizacion = RowAutorizacion("Importe").ToString().ToDecimal()
- CveAutorizacion = RowAutorizacion("CveAutorizacion").ToString().ToEntero()
- TipoAutorizacion = RowAutorizacion("TipoAutorizacion").ToString().ToEntero()
- DiasVencidosAutorizacion = RowAutorizacion("DiasVencidos").ToString().ToEntero()
- End If
+ If ObjVentas.GetAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, CveVendedor, "Ing", CveEstatus:=1) Then
+ Dim RowAutorizacion As DataRow = Nothing
+ 'SI TIENE DIAS VENCIDOS BUSCAR POR TIPO VENCIMIENTO
+ If TieneDiasVencidos Then
+ RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion IN(1,2) AND CveVenta IS NULL AND CveTipoDocumento='Ing'", Orderby:="Importe DESC")
+ Else
+ RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion = 1 AND CveVenta IS NULL AND CveTipoDocumento='Ing'", Orderby:="Importe DESC")
End If
- Catch ex As Exception
- OnError("Ocurrió un error al obtener las autorizaciones", ex)
- End Try
+
+ If RowAutorizacion IsNot Nothing Then
+ TipoDocumentoAutorizacion = RowAutorizacion("CveTipoDocumento").ToString()
+ ImporteAutorizacion = RowAutorizacion("Importe").ToString().ToDecimal()
+ CveAutorizacion = RowAutorizacion("CveAutorizacion").ToString().ToEntero()
+ TipoAutorizacion = RowAutorizacion("TipoAutorizacion").ToString().ToEntero()
+ DiasVencidosAutorizacion = RowAutorizacion("DiasVencidos").ToString().ToEntero()
+ End If
+
+ End If
+
ObjVentas.Dispose()
If TipoDocumentoAutorizacion = "Ing" Then
If TipoAutorizacion = 1 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
-
If ImporteAutorizacion < TxtTotal.Text.ToDecimal() Then
Dim BloquearCredito As Boolean = True
CveAutorizacion = -1
@@ -9850,7 +9836,6 @@ Partial Class Ventas
End If
End If
-
'VALIDA PRECIO AL AGREGAR A ALMACEN
If Not UsuarioActual.TienePermisoProceso(169) Then
If (DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing", "PA") AndAlso NuevaFactura <> 1) Or (DdlTipoComprobante.SelectedValue = "Cot" AndAlso BtnEmitirImprimir.Text = "Facturar") Or (DdlTipoComprobante.SelectedValue.Contiene("Cot") And UsuarioActual.CveEmpresa.Contiene(119)) Then
@@ -10781,10 +10766,10 @@ Partial Class Ventas
OnError("Ocurrió un error al generar el directorio de xml", ex)
End Try
-
Dim SeTimbro As Boolean = False
Dim SeTimbroNC As Boolean = False
Dim EstatusSMS As Integer = 0
+ Dim MsgErrorTimbrado As String = ""
Dim MsgCancelacionRefacturacion As Modelos.Factura.MCancelacionVentaMensaje = Nothing
@@ -10808,8 +10793,6 @@ Partial Class Ventas
DebeTimbrar = False
End If
-
-
If DebeTimbrar AndAlso ObjFactura.TipoDocto.Contiene("Ing", "Egs", "Ant", "Dev") Then
If UsuarioActual.Empresa.TipoFacturacion = "CFDi" AndAlso (UsuarioActual.Empresa.FacturaProduccion OrElse UsuarioActual.CveEmpresa = 1) Then
@@ -10842,7 +10825,7 @@ Partial Class Ventas
End Try
Dim FolioFiscalFactura As String = ObjTimbrado.UUID
- Dim MsgErrorTimbrado As String = ObjTimbrado.MensajeErrorCFDI
+ MsgErrorTimbrado = ObjTimbrado.MensajeErrorCFDI
ObjTimbrado = Nothing
'NOTA DE CREDITO - REFACTURADA - CASO ESPECIAL, TIMBRADO E IMPRESION
@@ -10872,9 +10855,9 @@ Partial Class Ventas
EstatusSMS = EnviarSMSTimbrado(ObjEventos)
End If
- If Not SeTimbro Then
- Alert(MsgErrorTimbrado, TipoMensaje.MsgError)
- End If
+ 'If Not SeTimbro Then
+ ' Alert(MsgErrorTimbrado, TipoMensaje.MsgError)
+ 'End If
'CANCELAR FACTURA ANTERIOR
Try
@@ -10955,6 +10938,12 @@ Partial Class Ventas
OnError("Ocurrió un error al enviar el PDF", ex)
End Try
Else
+
+ 'ERROR DE NO TIMBRADO
+ If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Egs", "Dev") Then
+ Dim StrEr As String = $"