diff --git a/Compras/eFacturas.aspx.vb b/Compras/eFacturas.aspx.vb index ef2355aba..6b8ec27dc 100644 --- a/Compras/eFacturas.aspx.vb +++ b/Compras/eFacturas.aspx.vb @@ -111,9 +111,16 @@ Partial Class Compras_eFacturas End Set End Property - Private Property Serie() As String + Private Property Serie() As String + Get - Return m_Serie + If m_Serie Is Nothing Then + Return "" + Else + Return m_Serie + End If + + End Get Set m_Serie = Value @@ -2535,15 +2542,80 @@ Partial Class Compras_eFacturas BtnOcultar.Visible = False BtnMostrar.Visible = True UpBitacora.Update() - End Sub - + End Sub + #End Region - - + + + Property MSGComplemento As String + Get + If ViewState("MSGComplemento") Is Nothing Then + Return "" + Else + Return ViewState("MSGComplemento").ToString + End If + End Get + Set(value As String) + ViewState("MSGComplemento") = value + End Set + End Property + + Property ViculacionConPUE As Boolean + Get + If ViewState("ViculacionConPUE") Is Nothing Then + Return False + Else + Return Boolean.Parse(ViewState("ViculacionConPUE").ToString) + End If + End Get + Set(value As Boolean) + ViewState("ViculacionConPUE") = value + End Set + End Property + + + Property ListaComprasPUE As List(Of Integer) + Get + If ViewState("ListaComprasPUE") Is Nothing Then + Return New List(Of Integer) + Else + Return DirectCast(ViewState("ListaComprasPUE"), List(Of Integer)) + End If + End Get + Set(value As List(Of Integer)) + ViewState("ListaComprasPUE") = value + End Set + End Property + + + Property ComplementoConPUE As String + Get + If ViewState("ComplementoConPUE") Is Nothing Then + Return "" + Else + Return ViewState("ComplementoConPUE").ToString + End If + End Get + Set(value As String) + ViewState("ComplementoConPUE") = value + End Set + End Property + + #Region "V I N C U L A R P A G O" - + Protected Sub LnkAgregarPago_Click(sender As Object, e As EventArgs) + + MSGComplemento = "" + ViculacionConPUE = False + ListaComprasPUE.Clear() + ComplementoConPUE = "" + + + Dim ListaComprasPUEInterna As New List(Of Integer) + + Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) Dim CveComplementoPagoCompra As Integer = gvRow.DataKey("CveComplementoPagoCompra").ToString.ToEntero @@ -2567,9 +2639,10 @@ Partial Class Compras_eFacturas Dim DiferenciaImportes As Double = 0 Dim TextoDiferenciaImporte As String = "" Dim FechaPago As Date - Dim PagosCantidad As Integer = 0 - Dim MSGComplemento As String = "" - + Dim PagosCantidad As Integer = 0 + + + Dim XMLDoc As New XmlDocument Dim Archivo As String = String.Format("{0}Empresas\{1}\Compras\{2}\{3}", AppDomain.CurrentDomain.BaseDirectory, UsuarioActual.CveEmpresa, gvRow.DataKey("RFCDe"), gvRow.DataKey("XML")) If IO.File.Exists(Archivo) Then @@ -2724,9 +2797,12 @@ Partial Class Compras_eFacturas For Each dRow2 As DataRow In DTDocumentosRelacionados.Rows If dRow2("CveMetodoPago").ToString.ToEntero > 0 Then If dRow2("CveMetodoPago").ToString.ToEntero = 1 Then - MSGComplemento = MSGComplemento & $" Compra {dRow2("SerieFolioCompra").ToString } bloqueado Tipo ""PUE"". " + ListaComprasPUEInterna.Add(dRow2("CveCompra").ToString.ToEntero) + + ComplementoConPUE = $"{SeriePago}-{FolioPago}" + End If End If Next @@ -2776,8 +2852,10 @@ Partial Class Compras_eFacturas Next - If MSGComplemento.Trim.Length > 0 Then - BtnVincularPago.Visible = False + If MSGComplemento.Trim.Length > 0 Then + + ' BtnVincularPago.Visible = False + ViculacionConPUE = True End If @@ -2820,8 +2898,11 @@ Partial Class Compras_eFacturas GvVincularPago.DataBind() - UpVincularPago.Update() - + UpVincularPago.Update() + + + ListaComprasPUE = ListaComprasPUEInterna + RegistraScript("$('#ModalVincularPago').modal('show')", "VincularPagoModalShow") End Sub @@ -2858,14 +2939,30 @@ Partial Class Compras_eFacturas TieneError = True End If - If Not TieneError Then - - + If Not TieneError Then + + Dim objEventos As New ClsOIEventos(ObjCompra.IniciaTransacSQL) + + If ViculacionConPUE Then + + + + + For Each CveCompraVinculada In ListaComprasPUE + + objEventos.AddEventoBitacora($"Complemento { ComplementoConPUE } vinculado manualmente (Compra PUE) ", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=CveCompraVinculada) + Next + + + + End If + + ObjCompra.Commit() Alert("El pago fue vinculado correctamente", TipoMensaje.MsgInformacion) - RegistraScript("$('#ModalVincularPago').modal('hide')", "VincularPagoModalHide") - CargaDatos() + RegistraScript("$('#ModalVincularPago').modal('hide')", "VincularPagoModalHide") + CargaDatos() Else ObjCompra.RollBack() Alert("Ocurrió un error al vincular el pago. Por favor verifique y vuelva a intentar", TipoMensaje.MsgError)