diff --git a/App_Code/ClsContabilidad.vb b/App_Code/ClsContabilidad.vb
index e9188b31e..02e5ca963 100644
--- a/App_Code/ClsContabilidad.vb
+++ b/App_Code/ClsContabilidad.vb
@@ -4198,7 +4198,7 @@ Public Class ClsContabilidad
Return Retorno
End Function
- Public Function GetAnexoCatalagoCC(CveCuenta As Integer, Ejercicio As Integer, CveSubproyecto As Integer, CveEmpresa As Integer, Divisor As Integer, Periodo As Integer) As Boolean
+ Public Function GetAnexoCatalagoCC(CveCuenta As Integer, Ejercicio As Integer, CveSubproyecto As Integer, CveEmpresa As Integer, Divisor As Integer, Periodo As Integer, CveUsuario As Integer ) As Boolean
Dim Retorno = False
DataAdapter("PA_Conta_AnexoCatalogoCCGet")
diff --git a/Compras/eFacturas.aspx b/Compras/eFacturas.aspx
index f6675b947..74f71680a 100644
--- a/Compras/eFacturas.aspx
+++ b/Compras/eFacturas.aspx
@@ -66,6 +66,9 @@
Bitácora Facturas
+
+ Vinculación Masiva Complementos
+
@@ -374,7 +377,7 @@
diff --git a/Compras/eFacturas.aspx.vb b/Compras/eFacturas.aspx.vb
index f59eed405..64b14396c 100644
--- a/Compras/eFacturas.aspx.vb
+++ b/Compras/eFacturas.aspx.vb
@@ -2770,23 +2770,7 @@ Partial Class Compras_eFacturas
Next
Next
- 'ImportePago
- 'For Each node As XmlNode In nodePago
- ' Dim Nrow As DataRow = DTDocumentosRelacionados.NewRow
-
- ' Nrow("Serie") = ValorXML(node, "Serie")
- ' Nrow("Folio") = ValorXML(node, "Folio").ToEntero
- ' Nrow("SerieFolio") = ValorXML(node, "Serie") & "-" & ValorXML(node, "Folio").ToEntero
- ' Nrow("IdDocumento") = ValorXML(node, "IdDocumento")
- ' Nrow("MonedaDR") = ValorXML(node, "MonedaDR")
- ' Nrow("MetodoDePagoDR") = ValorXML(node, "MetodoDePagoDR")
- ' Nrow("ImpPagado") = ValorXML(node, "ImpPagado").ToDecimal
- ' Nrow("Fecha") = FechaPago
-
- ' DTDocumentosRelacionados.Rows.Add(Nrow)
- ' StrUUID.AppendFormat("'{0}',", ValorXML(node, "IdDocumento").Replace("'", ""))
- 'Next
Dim ObjCompraFolios As New ClsCompras
If ObjCompraFolios.GetCompararComplementoPago(gvRow.DataKey("CveProveedor").ToEntero, Monto, nodePagos2.InnerXml.Replace("pago10:", ""), UsuarioActual.CveEmpresa, OP:=2) Then
@@ -3031,12 +3015,10 @@ Partial Class Compras_eFacturas
If HdnCveIE.Value.ToEntero > 0 Then
-
For Each dRow As DataRow In DT_ComprasSinIE.Rows
objEventos.AddEventoBitacora($"Complemento { dRow("SerieFolioPago").ToString } vinculado manualmente a compra {dRow("SerieFolioCompra").ToString}", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=dRow("CveCompra").ToString.ToEntero)
Next
-
End If
@@ -3452,4 +3434,361 @@ Partial Class Compras_eFacturas
Alert("no se pudo procesar el archivo xml")
End If
End Sub
+
+
+ Private Sub VinculacionMasivaComplementos()
+
+ Dim CountVinculados As Integer = 0
+ Dim ValidadoSAT As Boolean = False
+ Dim VinculacionValida As Boolean = False
+
+ For Each gvRow As GridViewRow In GvPagos.Rows
+
+ Dim DTDocumentosRelacionados As New DataTable
+ Dim DTVinculacion As New DataTable
+
+ Dim ObjValidacion As New ClsValidaCFDi(gvRow.DataKey("UUID"), gvRow.DataKey("RFCDe"), gvRow.DataKey("RFCPara"), 0)
+
+ If ObjValidacion.EsValida > 0 Then
+
+ If ObjValidacion.EsValida = 2 Then
+ ValidadoSAT = False
+ Else
+ Dim ObjDatos As New ClsCompras
+ ValidadoSAT = ObjDatos.UpdateEstatus(ObjValidacion.EsValida, gvRow.DataKey("CveFactura").ToEntero)
+ ObjDatos.Dispose()
+ End If
+
+ Else
+ ValidadoSAT = False
+ End If
+ ObjValidacion.Dispose()
+
+ If Not ValidadoSAT Then
+ Continue For
+ End If
+
+ Dim sbSinIE As New StringBuilder
+
+ HdnCveIE.Value = ""
+ MSGComplemento = ""
+ ViculacionConPUE = False
+ ListaComprasPUE.Clear()
+ ComplementoConPUE = ""
+
+ DT_ComprasSinIE = New DataTable
+
+ Dim ListaComprasPUEInterna As New List(Of Integer)
+
+ Dim CveComplementoPagoCompra As Integer = gvRow.DataKey("CveComplementoPagoCompra").ToString.ToEntero
+
+ If CveComplementoPagoCompra > 0 Then
+ Continue For
+ End If
+
+ Dim SerieFolioIE As String = ""
+ Dim UUIDPago As String = ""
+ 'Dim ImportePago As Decimal = 0
+ Dim StrUUID As New StringBuilder
+ Dim Monto As Decimal = 0
+ Dim nodePagos As XmlNode = Nothing
+ Dim nodePagos2 As XmlNode = Nothing
+ Dim nodeComp As XmlNode = Nothing
+ Dim nodeaGral As XmlNode = Nothing
+ Dim nodeTFD As XmlNode = Nothing
+ Dim ImporteIES As Double = 0
+ Dim DiferenciaImportes As Double = 0
+ Dim TextoDiferenciaImporte As String = ""
+ Dim FechaPago As Date
+ Dim PagosCantidad As Integer = 0
+
+
+
+ Dim XMLDoc As New XmlDocument
+ Dim Archivo As String = String.Format("{0}Empresas\{1}\Compras\{2}\{3}", ModExtensiones.DirectorioBaseEmpresas, UsuarioActual.CveEmpresa, gvRow.DataKey("RFCDe"), gvRow.DataKey("XML"))
+ If IO.File.Exists(Archivo) Then
+
+
+ Dim SXML As String = File.ReadAllText(Archivo).Replace(vbLf, " ").Replace(vbCrLf, " ")
+
+ SXML = SXML.Trim((Convert.ToChar(0)))
+
+ XMLDoc.LoadXml(SXML)
+
+ Dim Xml As New StringBuilder
+ Dim namespaces As New XmlNamespaceManager(XMLDoc.NameTable)
+
+ namespaces.AddNamespace(XMLDoc.DocumentElement.Prefix, "http://www.sat.gob.mx/cfd/3")
+ namespaces.AddNamespace("tfd", "http://www.sat.gob.mx/TimbreFiscalDigital")
+ namespaces.AddNamespace("pago10", "http://www.sat.gob.mx/Pagos")
+ nodeComp = XMLDoc.SelectSingleNode(String.Format("//{0}:Complemento", XMLDoc.DocumentElement.Prefix), namespaces)
+
+ nodeaGral = XMLDoc.SelectSingleNode(String.Format("//{0}:Comprobante", XMLDoc.DocumentElement.Prefix), namespaces)
+
+ nodeTFD = nodeComp.SelectSingleNode(String.Format("//{0}:TimbreFiscalDigital", "tfd"), namespaces)
+ nodePagos = nodeComp.SelectSingleNode(String.Format("//{0}:Pagos/{0}:Pago", "pago10"), namespaces)
+ nodePagos2 = nodeComp.SelectSingleNode(String.Format("//{0}:Pagos", "pago10"), namespaces)
+ 'Monto = ValorXML(nodePagos, "Monto").ToDecimal
+
+ Dim nodePago As XmlNodeList = nodePagos.SelectNodes(String.Format("//{0}:DoctoRelacionado", "pago10"), namespaces)
+
+ SeriePago = ValorXML(nodeaGral, "Serie")
+ FolioPago = ValorXML(nodeaGral, "Folio")
+
+ UUIDPago = ValorXML(nodeTFD, "UUID")
+ LblUUID.Text = UUIDPago
+
+
+ DTDocumentosRelacionados.Columns.Add("Serie")
+ DTDocumentosRelacionados.Columns.Add("SerieFolio")
+
+ DTDocumentosRelacionados.Columns.Add("IdDocumento")
+ DTDocumentosRelacionados.Columns.Add("Folio", GetType(Integer))
+ DTDocumentosRelacionados.Columns.Add("MonedaDR")
+ DTDocumentosRelacionados.Columns.Add("MetodoDePagoDR")
+ DTDocumentosRelacionados.Columns.Add("ImpPagado", GetType(Decimal))
+
+ DTDocumentosRelacionados.Columns.Add("CveFactura", GetType(Integer))
+ DTDocumentosRelacionados.Columns.Add("CveCompra", GetType(Integer))
+ DTDocumentosRelacionados.Columns.Add("CveIE", GetType(Integer))
+ DTDocumentosRelacionados.Columns.Add("Fecha", GetType(Date))
+
+ DTDocumentosRelacionados.Columns.Add("FolioPago")
+ DTDocumentosRelacionados.Columns.Add("ImportePago", GetType(Decimal))
+ DTDocumentosRelacionados.Columns.Add("FechaPago", GetType(Date))
+ DTDocumentosRelacionados.Columns.Add("CveMetodoPago", GetType(Integer))
+ DTDocumentosRelacionados.Columns.Add("SerieFolioCompra")
+
+
+
+ Dim nodePagosN As XmlNodeList
+ nodePagosN = nodeComp.SelectNodes(String.Format("//{0}:Pagos", "pago10"), namespaces)
+
+
+
+ For Each NodosPagos As XmlNode In nodePagosN
+ For Each innernode As XmlNode In NodosPagos
+
+ FechaPago = ValorXML(innernode, "FechaPago").ToDate
+ PagosCantidad = PagosCantidad + 1
+
+ For Each node As XmlNode In innernode
+
+ Dim Nrow As DataRow = DTDocumentosRelacionados.NewRow
+
+ Nrow("Serie") = ValorXML(node, "Serie")
+ Nrow("Folio") = ValorXML(node, "Folio").ToEntero
+ Nrow("SerieFolio") = ValorXML(node, "Serie") & "-" & ValorXML(node, "Folio").ToEntero
+ Nrow("IdDocumento") = ValorXML(node, "IdDocumento")
+ Nrow("MonedaDR") = ValorXML(node, "MonedaDR")
+ Nrow("MetodoDePagoDR") = ValorXML(node, "MetodoDePagoDR")
+
+ Monto = Monto + ValorXML(node, "ImpPagado").ToDecimal
+
+ Nrow("ImpPagado") = ValorXML(node, "ImpPagado").ToDecimal
+ Nrow("Fecha") = FechaPago
+
+ DTDocumentosRelacionados.Rows.Add(Nrow)
+ StrUUID.AppendFormat("'{0}',", ValorXML(node, "IdDocumento").Replace("'", ""))
+ Next
+
+ Next
+ Next
+
+
+
+ Dim ObjCompraFolios As New ClsCompras
+ If ObjCompraFolios.GetCompararComplementoPago(gvRow.DataKey("CveProveedor").ToEntero, Monto, nodePagos2.InnerXml.Replace("pago10:", ""), UsuarioActual.CveEmpresa, OP:=2) Then
+ '
+ '.GetCompararComplementoPago(gvRow.DataKey("CveProveedor").ToEntero, Monto, nodePagos2.InnerXml.Replace("pago10:", ""), UsuarioActual.CveEmpresa) Then
+ If ObjCompraFolios.DtResultados.Rows.Count > 0 Then
+ For Each drow As DataRow In ObjCompraFolios.DtResultados.Rows
+
+ For Each dRow2 As DataRow In DTDocumentosRelacionados.Rows
+
+ If dRow2("IdDocumento").ToString.ToUpper = drow("IdDocumento").ToString.ToUpper Then
+
+ dRow2("CveCompra") = drow("CveCompra").ToString.ToEntero
+ dRow2("CveFactura") = drow("CveFactura").ToString.ToEntero
+ dRow2("CveMetodoPago") = drow("CveMetodoPago").ToString.ToEntero
+ dRow2("SerieFolioCompra") = drow("SerieFolioCompra").ToString
+
+
+ If drow("CveIE").ToString.ToEntero > 0 Then
+
+ dRow2("CveIE") = drow("CveIE").ToString.ToEntero
+ dRow2("ImportePago") = drow("Importe").ToString.ToDecimal
+
+
+ End If
+
+ dRow2("FolioPago") = drow("FolioIE")
+ dRow2("FechaPago") = drow("FechaDocumento")
+
+
+
+
+ End If
+ Next
+ Next
+ End If
+ End If
+
+ ObjCompraFolios.Dispose()
+
+ 'GVPDocumentosRelacionadosPagos.DataSource = DTDocumentosRelacionados
+ 'GVPDocumentosRelacionadosPagos.DataBind()
+
+
+ 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
+
+
+ DT_ComprasSinIE.Columns.Add("CveCompra", GetType(Integer))
+ DT_ComprasSinIE.Columns.Add("CveFactura", GetType(Integer))
+ DT_ComprasSinIE.Columns.Add("SerieFolioPago")
+ DT_ComprasSinIE.Columns.Add("SerieFolioCompra")
+
+ For Each dRow As DataRow In DTDocumentosRelacionados.Rows
+ Dim nRow As DataRow = DT_ComprasSinIE.NewRow
+ nRow("CveCompra") = dRow("CveCompra").ToString.ToEntero
+ ' nRow("CveFactura") = dRow("CveFactura").ToString.ToEntero
+ nRow("SerieFolioPago") = $"{SeriePago}-{FolioPago}"
+ nRow("SerieFolioCompra") = dRow("SerieFolioCompra").ToString
+
+ DT_ComprasSinIE.Rows.Add(nRow)
+
+
+ Next
+
+
+
+ Else
+ VinculacionValida = False
+ End If
+
+ CveFacturaPago = gvRow.DataKey("CveFactura").ToEntero
+ CveProveedor = gvRow.DataKey("CveProveedor").ToEntero
+ Dim ObjCompras As New ClsCompras
+
+
+ Dim TieneRegistros As Boolean = False
+
+ If ObjCompras.GetCompararComplementoPago(gvRow.DataKey("CveProveedor").ToEntero, Monto, nodePagos2.InnerXml.Replace("pago10:", ""), UsuarioActual.CveEmpresa) Then
+ ' GvVincularPago.DataSource = ObjCompras.DtResultados
+ DTVinculacion = ObjCompras.DtResultados
+ If ObjCompras.DtResultados.Rows.Count > 0 Then
+ SerieFolioIE = ObjCompras.DtResultados.Rows(0)("SerieFolio").ToString
+ 'DivVincularPagoManualmente.Visible = False
+ VinculacionValida = True
+ TieneRegistros = True
+ Else
+ 'DivVincularPagoManualmente.Visible = True
+ VinculacionValida = False
+ End If
+ 'ImportePago = ObjCompras.DtResultados.SUMD("Monto")
+ Else
+ 'DivVincularPagoManualmente.Visible = False
+ VinculacionValida = False
+ End If
+
+
+ For Each dRow As DataRow In DTDocumentosRelacionados.Rows
+
+ Dim FechaDocumento As Date = dRow("FechaPago").ToString.ToDate
+ Dim FechaDoRecibo As Date = dRow("Fecha").ToString.ToDate
+ Dim CveIEDocumento As Integer = dRow("CveIE").ToString.ToEntero
+
+ If CveIEDocumento > 0 And FechaDocumento > New Date(1, 1, 1) Then
+
+ Dim FT1 As Date = FechaDocumento
+
+ If FechaDocumento <> New Date(1, 1, 1) Then
+ FT1 = FechaDocumento.AddDays(-6)
+ End If
+
+ Dim FT2 As Date = FechaDocumento.AddDays(7)
+
+ If Not (FechaDoRecibo >= FT1 And FechaDoRecibo < FT2) Then
+
+ VinculacionValida = False
+ 'MSGComplemento = MSGComplemento & " Existen mas de 3 días de diferencia entre la fecha del documento y la fecha de complemento. "
+ Exit For
+
+ End If
+
+ End If
+
+ Next
+
+ ObjCompras.Dispose()
+
+
+
+ If VinculacionValida Then
+
+ Dim TieneError = False
+ Dim ObjCompra As New ClsCompras
+ ObjCompra.IniciaTransacSQL()
+
+
+ For Each DTRow As DataRow In DTVinculacion.Rows
+
+ If Not ObjCompra.AddComplementoPago(DTRow("CveIE").ToString.ToEntero, DTRow("CveCompra").ToString.ToEntero, DTRow("Monto").ToString.ToDecimal, DTRow("CvePrePolizaDetalle").ToString.ToEntero, CveFacturaPago) > 0 Then
+ TieneError = True
+ End If
+
+
+ Next
+
+ If Not TieneError AndAlso Not ObjCompra.AddVincularPago(CveFacturaPago) Then
+ TieneError = True
+ Else
+ CountVinculados = CountVinculados + 1
+ End If
+
+
+ If Not TieneError Then
+ ObjCompra.Commit()
+ Else
+ ObjCompra.RollBack()
+ End If
+
+ ObjCompra.Dispose()
+
+
+
+ End If
+
+
+ Next
+
+
+ If CountVinculados > 0 Then
+
+ Alert($"Se vincularon {CountVinculados} complementos")
+ CargaDatos()
+
+ End If
+
+
+
+ End Sub
+
+
+ Protected Sub LnkVinculacionMasivaComplementos_Click(sender As Object, e As EventArgs)
+ VinculacionMasivaComplementos()
+ End Sub
+
+
End Class
\ No newline at end of file
diff --git a/Contabilidad2/RepAnexoCatalogoCC.aspx b/Contabilidad2/RepAnexoCatalogoCC.aspx
index 3f633936e..03e4cd9ec 100644
--- a/Contabilidad2/RepAnexoCatalogoCC.aspx
+++ b/Contabilidad2/RepAnexoCatalogoCC.aspx
@@ -1,4 +1,4 @@
-<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RepAnexoCatalogoCC.aspx.vb" Inherits="Contabilidad2_RepAnexoCatalogoCC" %>
+<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RepAnexoCatalogoCC.aspx.vb" Inherits="Contabilidad2_RepAnexoCatalogoCC" EnableEventValidation="false" %>
diff --git a/Contabilidad2/RepAnexoCatalogoCC.aspx.vb b/Contabilidad2/RepAnexoCatalogoCC.aspx.vb
index 2ea0fd95b..a41f8dcde 100644
--- a/Contabilidad2/RepAnexoCatalogoCC.aspx.vb
+++ b/Contabilidad2/RepAnexoCatalogoCC.aspx.vb
@@ -115,7 +115,7 @@ Partial Class Contabilidad2_RepAnexoCatalogoCC
Private Sub CargaDatos()
Dim Conta As New ClsContabilidad
- If Conta.GetAnexoCatalagoCC(CveCuenta, DdlEjercicio.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlDivisor.SelectedValue.ToEntero, DdlPeriodo.SelectedValue.ToEntero) Then
+ If Conta.GetAnexoCatalagoCC(CveCuenta, DdlEjercicio.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlDivisor.SelectedValue.ToEntero, DdlPeriodo.SelectedValue.ToEntero, UsuarioActual.CveUsuario) Then
Dim DtHeaders As DataTable = Conta.DSResultados.Tables(0)
GvCC.DataSource = Conta.DSResultados.Tables(1)
diff --git a/Contabilidad2/RepEstadoResultadosHorizontal.aspx b/Contabilidad2/RepEstadoResultadosHorizontal.aspx
index 06612d679..ef097ec74 100644
--- a/Contabilidad2/RepEstadoResultadosHorizontal.aspx
+++ b/Contabilidad2/RepEstadoResultadosHorizontal.aspx
@@ -1,4 +1,4 @@
-<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RepEstadoResultadosHorizontal.aspx.vb" Inherits="Contabilidad_RepEstadoResultadosHorizontal" %>
+<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RepEstadoResultadosHorizontal.aspx.vb" Inherits="Contabilidad_RepEstadoResultadosHorizontal" EnableEventValidation="false" %>