From 481b3b299444112772c15b27c60bf1c567ba9f75 Mon Sep 17 00:00:00 2001 From: rrene Date: Mon, 30 Dec 2024 07:38:45 -0700 Subject: [PATCH] -- solicitud de anticipos y mejoras GDIaz --- Ventas/CatAutorizacionLimites.aspx.vb | 2 + Ventas/PVCobranza.aspx | 8 ++-- Ventas/PVCobranza.aspx.vb | 50 ++++++++++++++++---- Ventas/Ventas.aspx | 16 ++++--- Ventas/Ventas.aspx.vb | 66 ++++++++++++++++----------- 5 files changed, 94 insertions(+), 48 deletions(-) diff --git a/Ventas/CatAutorizacionLimites.aspx.vb b/Ventas/CatAutorizacionLimites.aspx.vb index 3783e7562..8d8a0bc50 100644 --- a/Ventas/CatAutorizacionLimites.aspx.vb +++ b/Ventas/CatAutorizacionLimites.aspx.vb @@ -213,6 +213,8 @@ Partial Class Ventas_CatAutorizacionLimites Dim CveCliente As Integer = gvRow.DataKey("CveCliente").ToEntero() Dim CveVendedor As Integer = gvRow.DataKey("CveVendedor").ToEntero() Dim CveEstatusAutorizacion As Integer = 1 + 'cuando es la modalidad 3, es autorización directa sobre la venta ya asociada a la solicitud. + If UsuarioActual.Empresa.Funcionalidad(595) = "3" Then CveEstatusAutorizacion = 2 Dim Importe As Decimal = gvRow.DataKey("Importe").ToDecimal().RoundSQL(2) 'AUTORIZACION DE IMPORTE, diff --git a/Ventas/PVCobranza.aspx b/Ventas/PVCobranza.aspx index d23c3b2fb..eb932618b 100644 --- a/Ventas/PVCobranza.aspx +++ b/Ventas/PVCobranza.aspx @@ -371,7 +371,6 @@ -
@@ -399,9 +398,7 @@
-
- -   +
Nombre:
         
@@ -538,7 +535,8 @@
- + +
$ diff --git a/Ventas/PVCobranza.aspx.vb b/Ventas/PVCobranza.aspx.vb index e95f16c1a..941d85578 100644 --- a/Ventas/PVCobranza.aspx.vb +++ b/Ventas/PVCobranza.aspx.vb @@ -3,12 +3,16 @@ Option Strict On Imports System.Data Imports System.IO +Imports System.Net.Http Imports Extensiones Imports Modelos.Factura Partial Class Ventas_PVCobranza Inherits ClsPaginas + +#Region "Propiedades" + Private Property CveCliente As Integer Get If ViewState("CveCliente") Is Nothing Then @@ -93,10 +97,29 @@ Partial Class Ventas_PVCobranza Set(value As DataTable) ViewState("DtCortesVentas") = value End Set - End Property - + End Property + +#End Region + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then + Dim Arr As New ArrayList + 'Arr.Add("autorizada") + 'If EnviarNotificacionWhatsApp("526621430964", "solicitud_autorizacion_anticipo_respuesta", Arr) Then + ' Alert("bien") + 'Else + ' Alert("mal", TipoMensaje.MsgAdvertencia) + 'End If + 'Arr.Add("suc") + 'Arr.Add("cliente") + 'Arr.Add("10") + 'Arr.Add("$ 15.11") + 'If EnviarNotificacionWhatsApp("526621430964", "solicitud_autorizacion_anticipo", Arr, "autoriza") Then + ' Alert("bien") + 'Else + ' Alert("mal", TipoMensaje.MsgAdvertencia) + 'End If + 'Exit Sub CveCorte = 0 CargaFiltros() CargaDdlPagos() @@ -340,8 +363,6 @@ Partial Class Ventas_PVCobranza End Sub - - Private Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then @@ -360,8 +381,16 @@ Partial Class Ventas_PVCobranza ScriptManager.GetCurrent(Me).RegisterPostBackControl(e.Row.FCLinkButton("LnkImprimir")) End If If e.Row.DBCampo("CondicionesPago") = "1" Then ' remis de crédito - e.Row.FCLinkButton("BtnPagar").CssClass = "btn btn-xs btn-warning" - e.Row.FCLinkButton("BtnPagar").Text = "Crédito" + ' si es de crédito debe de estar autorizado. + e.Row.FCLinkButton("BtnPagar").Text = "Crédito" + If e.Row.DBCampo("CveEstatusAutorizacion") = "2" Then ' si es autorizada + e.Row.FCLinkButton("BtnPagar").CssClass = "btn btn-xs btn-warning" + e.Row.FCLinkButton("BtnPagar").Enabled = True + Else + e.Row.FCLinkButton("BtnPagar").CssClass = "btn btn-xs btn-danger" + e.Row.FCLinkButton("BtnPagar").Enabled = False + e.Row.FCLinkButton("BtnPagar").ToolTip = "Solicitud de crédito no autorizada." + End If End If If e.Row.DBCampo("AplicaImpresionPorAnt") = "1" Then @@ -369,10 +398,10 @@ Partial Class Ventas_PVCobranza If e.Row.DBCampo("Saldo").ToDecimal() > 0 Then e.Row.FCLinkButton("BtnPagar").Visible = True If Not e.Row.DBCampo("TipoEntrega") = "2" Then - e.Row.FCLinkButton("LnkImprimir").Visible = False - End If - Else - e.Row.FCLinkButton("BtnPagar").Visible = False + e.Row.FCLinkButton("LnkImprimir").Visible = False + End If + Else + e.Row.FCLinkButton("BtnPagar").Visible = False End If End If @@ -1867,6 +1896,7 @@ Partial Class Ventas_PVCobranza UpAnticipos.Update() End Sub + Protected Sub GVAnticipos_RowCreated(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVAnticipos.RowCreated If e.Row.RowType = DataControlRowType.Header Then e.Row.ClientIDMode = ClientIDMode.Static diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index cdad14650..87d14695f 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -451,7 +451,7 @@ Nombre:  - Enviar Mail: + Envía Mail: @@ -578,6 +578,11 @@ + + + + + Médico: @@ -1266,7 +1271,7 @@ <%--1--%> - +
@@ -1288,7 +1293,7 @@ - + @@ -1472,7 +1477,7 @@ <%--18--%> - +
@@ -1486,7 +1491,7 @@ <%--19--%> - + @@ -8824,7 +8829,6 @@
-
diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 39adff7c8..cfdd48d6f 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -1665,7 +1665,6 @@ Partial Class Ventas ViewState("CveOC") = value End Set End Property - Private Property RegistroxOC As Boolean Get Return CBool(IfNull(ViewState("RegistroxOC"), False)) @@ -1674,8 +1673,6 @@ Partial Class Ventas ViewState("RegistroxOC") = value End Set End Property - - Private Property EnviarCorreoCliente As Boolean Get Return CBool(IfNull(ViewState("EnviarCorreoCliente"), False)) @@ -2598,10 +2595,6 @@ Partial Class Ventas CargaGestionCobranza() End If - If UsuarioActual.Empresa.Funcionalidad(595) = "2" Then - LnkSolicitarCredito.Visible = True - End If - DdlSATPS.setEsWebService(True) : DdlSATPS.Attributes.Add("data-metodo", "getpssat") DivPSSAT.Visible = True @@ -7709,6 +7702,8 @@ Partial Class Ventas Private Sub CargaRestriccionesCreditoCliente(Optional Alertas As Boolean = False, Optional CveVenta As Integer = -1) Dim ValorAutorizacion As String = UsuarioActual.Empresa.Funcionalidad(595) + 'solo para bdh, que se generen NC + If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then DdlSolCreditoTipoDocto.Items.Add(New ListItem("Nota de crédito", "Egs")) 'OBLIGAR PAGO DE CONTADO SI EL CLIENTE NO PERMITE CREDITO If Not EsFilial AndAlso (Not UsuarioActual.Empresa.Funcionalidad(702).Contiene("1")) AndAlso Me.PermiteCredito = False AndAlso ((DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot") AndAlso CveVenta < 1) OrElse (DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot", "PA") AndAlso EsCreaApartirDe) OrElse (DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso CveVenta > 0)) Then @@ -7750,7 +7745,7 @@ Partial Class Ventas If Me.PermiteCredito Then If IfNull(Request("Op"), "").ToString() = "Cot" OrElse (DdlTipoComprobante.SelectedValue = "Cot" AndAlso CveVenta > 0) Then - Dim CreditoDispo As Decimal = CargaCreditoDisponible(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero()) + Dim CreditoDispo As Decimal = GetSaldoCreditoDisponible(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero()) If CreditoDispo > 0 Then TrCreditoDisponible.Visible = True LblCreditoDisponible.Text = String.Format("{0:C}", CreditoDispo) @@ -7778,7 +7773,7 @@ Partial Class Ventas UPCondicionesPago.Update() End If - Dim CreditoDispo As Decimal = CargaCreditoDisponible(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero()) + Dim CreditoDispo As Decimal = GetSaldoCreditoDisponible(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero()) If CreditoDispo > 0 Then TrCreditoDisponible.Visible = True @@ -7801,7 +7796,7 @@ Partial Class Ventas If Not EsCreaApartirDe AndAlso (DdlTipoComprobante.SelectedValue = "Cot" AndAlso CveVenta > 0) Then DdlTipoComprobante.SelectedValueExist("Cot") Else - If UsuarioActual.Empresa.Funcionalidad(595) = "1" Then + If ValorAutorizacion = "1" Then DdlTipoComprobante.SelectedValueExistInsert("PA", "Autorización") DdlTipoComprobante.SelectedValue = "PA" @@ -7814,7 +7809,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(595) <> "2" Then + If ValorAutorizacion = "1" Then DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing")) If Not UsuarioActual.TienePermisoProceso(325) Then DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant")) @@ -7839,7 +7834,6 @@ Partial Class Ventas If Bloqueo AndAlso ValorAutorizacion = "2" 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 @@ -7862,6 +7856,13 @@ Partial Class Ventas TieneBloqueoPorCreditoVencimiento = 0 Alert("El cliente tiene una autorización aprobada", TipoMensaje.ToastInformacion) End If + LnkSolicitarCredito.Visible = True + DdlTipoAutorizacion.SelectedValueExist("1") + End If + + If Bloqueo AndAlso ValorAutorizacion = "3" Then ' autorización con vinculación a una venta registrada + If UsuarioActual.CveRol = 1 Then TrCredito1.Visible = True + ChkSolicitudAutorizacionCredito.Checked = True End If 'SI ES AUTORIZACION DEBE PERMITIR GENERARLA @@ -7999,16 +8000,7 @@ Partial Class Ventas End If End If 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 - '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) @@ -8128,7 +8120,7 @@ Partial Class Ventas 'CREDITO NO SUFICIENTE If Opcion = 3 Then - 'Dim CreditoDispo As Decimal = CargaCreditoDisponible(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero()) + 'Dim CreditoDispo As Decimal = GetSaldoCreditoDisponible(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero()) 'If CreditoDispo < 0 AndAlso RBLPago.SelectedValue = "1" Then ' BloquearCliente = True 'End If @@ -8295,7 +8287,7 @@ Partial Class Ventas Alert("La Sucursal/Departamento del cliente se encuentra inactivo", TipoMensaje.MsgAdvertencia) Else RBLPago.Items(0).Enabled = True - Dim CreditoDispo As Decimal = CargaCreditoDisponible(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero(), ObjVentas) + Dim CreditoDispo As Decimal = GetSaldoCreditoDisponible(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero(), ObjVentas) TrCreditoDisponible.Visible = True LblCreditoDisponible.Text = String.Format("{0:C}", CreditoDispo) @@ -8435,7 +8427,7 @@ Partial Class Ventas UpCliente.Update() UpEmitirTransitorio.Update() End Sub - Private Function CargaCreditoDisponible(tCveCliente As Integer, tCveSucursalCliente As Integer, Optional ByRef ObjVentas As ClsVentas = Nothing) As Decimal + Private Function GetSaldoCreditoDisponible(tCveCliente As Integer, tCveSucursalCliente As Integer, Optional ByRef ObjVentas As ClsVentas = Nothing) As Decimal Dim Retorno As Decimal = 0 Dim ObjVentasAplciar As ClsVentas = Nothing If ObjVentas IsNot Nothing Then @@ -10904,6 +10896,23 @@ Partial Class Ventas End If End If End If + If ErrorList.Count = 0 AndAlso ObjFactura.CveVenta > 0 AndAlso ChkSolicitudAutorizacionCredito.Checked Then + ' crea la solicitud de autorización de crédito + Dim tCveTipoAutorizacion As Integer = 1 + If ObjVentas.AddAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, DdlVendedor.SelectedValue.ToEntero(), TxtTotal.Text.ToDecimal(), 0, UsuarioActual.CveUsuario, tCveTipoAutorizacion, TipoDocumento:=DdlTipoComprobante.SelectedValue, DiasVencidos:=25, CveVenta:=ObjFactura.CveVenta) Then + Alert("La autorización se agregó correctamente.", TipoMensaje.MsgInformacion) + Dim Arr As New ArrayList + + Arr.Add(NombreCliente) + Arr.Add($" $ {TxtTotal.Text.ToDecimal}") + Arr.Add(DdlSubProyectoDatos.SelectedItem.Text) + EnviarNotificacionWhatsAppPlantilla("526621430964", "solicitud_autorizacion_credito2", Arr) + ' Alert("bien") + 'Else + ' Alert("mal", TipoMensaje.MsgAdvertencia) + 'End If + End If + End If 'Paso CRM actualizar importe de acercamiento y guardar en bitacora If DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso CveEmpresaCRM > 0 AndAlso CveAcercamientoCRM > 0 Then @@ -37340,8 +37349,11 @@ Partial Class Ventas UpModalSolicitud.Update() End Sub Protected Sub DdlTipoAutorizacion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoAutorizacion.SelectedIndexChanged - DivImporteSolicitud.Visible = DdlTipoAutorizacion.SelectedValue.ToEntero() = 1 - DivDiasVencidos.Visible = DdlTipoAutorizacion.SelectedValue.ToEntero() = 2 + DivImporteSolicitud.Visible = DdlTipoAutorizacion.SelectedValue = "1" + DivDiasVencidos.Visible = DdlTipoAutorizacion.SelectedValue = "2" + If Not UsuarioActual.Empresa.Funcionalidad(382) = "1" Then + TxtDiasVencidos.Text = "25" + End If UpModalSolicitud.Update() End Sub