This commit is contained in:
2022-06-18 11:21:34 -07:00
21 changed files with 7387 additions and 3383 deletions

View File

@@ -1018,8 +1018,15 @@ Partial Class PopUpVerFactura
'IMPRIME CARTA PORTE
If UrlParametros("OP").ToString = "CARPO" Then
If UrlParametros("CVEMOV") IsNot Nothing AndAlso UrlParametros("CVEMOV").ToString.ToEntero > 0 Then
ImprimeFormatoCartaPorte(UrlParametros("CVEMOV").ToString.ToEntero)
ImprimeFormatoCartaPorte(UrlParametros("CVEMOV").ToString.ToEntero, -1)
End If
If UrlParametros("CVETIMBRE") IsNot Nothing AndAlso UrlParametros("CVETIMBRE").ToString.ToEntero > 0 Then
ImprimeFormatoCartaPorte(-1, UrlParametros("CVETIMBRE").ToString.ToEntero)
End If
End If
If UrlParametros("OP").ToString = "CARPOTIMBRE" Then
@@ -1410,9 +1417,9 @@ Partial Class PopUpVerFactura
#End Region
#Region "OP = 'CARPO' - IMPRIME FORMATO CARTA PORTE TIMBRADO"
Private Sub ImprimeFormatoCartaPorte(CveMovimiento As Integer)
If CveMovimiento > 0 Then
Dim ObjInv As New ClsInventarios
Private Sub ImprimeFormatoCartaPorte(CveMovimiento As Integer, Optional CveTimbre As Integer = -1)
If CveMovimiento > 0 Or CveTimbre > 0 Then
Dim SerieFolio As String = ""
Dim DomicilioSucursal As String = ""
@@ -1435,78 +1442,292 @@ Partial Class PopUpVerFactura
Dim Licencia As String = ""
Dim SBDireccionO As New StringBuilder()
Dim SBDireccionD As New StringBuilder()
If ObjInv.GetMovimientos(CveMovimiento, -1, -1, UsuarioActual.CveEmpresa) Then
If ObjInv.DtResultados.Rows.Count > 0 Then
Dim Dr As DataRow = ObjInv.DtResultados.Rows(0)
If Dr IsNot Nothing Then
SerieFolio = Dr("Folio").ToString
DomicilioSucursal = $"{Dr("CalleOrigen").ToString} {Dr("NoExtOrigen").ToString}, Col. {Dr("ColoniaOrigen").ToString} "
LugarFecha = $"{Dr("MunicipioOrigen").ToString}, {Dr("EstadoOrigen").ToString} {Dr("FechaMovto").ToString.ToDate.ToShortDateString}"
Origen = Dr("AlmacenOrigen").ToString
Destino = Dr("AlmacenDestino").ToString
Observaciones = Dr("Observaciones").ToString
CveChofer = Dr("CveChofer").ToString
Dim Dt As DataTable = Nothing
Dim FormatoRDLC As String = ""
Dim params As New List(Of ReportParameter)
If CveMovimiento > 0 Then
FormatoRDLC = "CartaPorte.rdlc"
Dim ObjInv As New ClsInventarios
If ObjInv.GetMovimientos(CveMovimiento, -1, -1, UsuarioActual.CveEmpresa) Then
If ObjInv.DtResultados.Rows.Count > 0 Then
Dim Dr As DataRow = ObjInv.DtResultados.Rows(0)
If Dr IsNot Nothing Then
SerieFolio = Dr("Folio").ToString
DomicilioSucursal = $"{Dr("CalleOrigen").ToString} {Dr("NoExtOrigen").ToString}, Col. {Dr("ColoniaOrigen").ToString} "
LugarFecha = $"{Dr("MunicipioOrigen").ToString}, {Dr("EstadoOrigen").ToString} {Dr("FechaMovto").ToString.ToDate.ToShortDateString}"
Origen = Dr("AlmacenOrigen").ToString
Destino = Dr("AlmacenDestino").ToString
Observaciones = Dr("Observaciones").ToString
CveChofer = Dr("CveChofer").ToString
Placa = Dr("Traslado_Placa").ToString
Recibio = Dr("Recibio").ToString
FechaEntrega = Dr("FechaEntrega").ToString
EspecifUnidad = Dr("EspecificacionUnidad").ToString
If Dr("CalleOrigen").ToString.Length > 0 Then
SBDireccionO.AppendFormat("{0}", Dr("CalleOrigen").ToString)
If Dr("NoExtOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", No.Ext: {0}", Dr("NoExtOrigen").ToString)
If Dr("ColoniaOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", Col: {0}", Dr("ColoniaOrigen").ToString)
If Dr("CPOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", CP: {0}", Dr("CPOrigen").ToString)
If Dr("LocalidadOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", Loc: {0}", Dr("LocalidadOrigen").ToString)
If Dr("MunicipioOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", Cd: {0}", Dr("MunicipioOrigen").ToString)
If Dr("EstadoOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", Edo: {0}", Dr("EstadoOrigen").ToString)
If Dr("PaisOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", País: {0}", Dr("PaisOrigen").ToString)
End If
If Dr("CalleDestino").ToString.Length > 0 Then
SBDireccionD.AppendFormat("{0}", Dr("CalleDestino").ToString)
If Dr("NoExtDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", No.Ext: {0}", Dr("NoExtDestino").ToString)
If Dr("ColoniaDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", Col: {0}", Dr("ColoniaDestino").ToString)
If Dr("CPDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", CP: {0}", Dr("CPDestino").ToString)
If Dr("LocalidadDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", Loc: {0}", Dr("LocalidadDestino").ToString)
If Dr("MunicipioDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", Cd: {0}", Dr("MunicipioDestino").ToString)
If Dr("EstadoDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", Edo: {0}", Dr("EstadoDestino").ToString)
If Dr("PaisDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", País: {0}", Dr("PaisDestino").ToString)
End If
ResponsableCarga = Dr("ResponsableCarga").ToString
ResponsableRecibio = Dr("ResponsableRecibio").ToString
Identificacion = Dr("Identificacion").ToString
Domicilio = Dr("Domicilio").ToString
Telefono = Dr("Telefono1").ToString
Ciudad = Dr("Ciudad").ToString
Licencia = Dr("Licencia").ToString
Chofer = Dr("Chofer").ToString
Placa = Dr("Placa").ToString
EspecifUnidad = Dr("Especificacion").ToString
Placa = Dr("Traslado_Placa").ToString
Recibio = Dr("Recibio").ToString
FechaEntrega = Dr("FechaEntrega").ToString
EspecifUnidad = Dr("EspecificacionUnidad").ToString
If Dr("CalleOrigen").ToString.Length > 0 Then
SBDireccionO.AppendFormat("{0}", Dr("CalleOrigen").ToString)
If Dr("NoExtOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", No.Ext: {0}", Dr("NoExtOrigen").ToString)
If Dr("ColoniaOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", Col: {0}", Dr("ColoniaOrigen").ToString)
If Dr("CPOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", CP: {0}", Dr("CPOrigen").ToString)
If Dr("LocalidadOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", Loc: {0}", Dr("LocalidadOrigen").ToString)
If Dr("MunicipioOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", Cd: {0}", Dr("MunicipioOrigen").ToString)
If Dr("EstadoOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", Edo: {0}", Dr("EstadoOrigen").ToString)
If Dr("PaisOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", País: {0}", Dr("PaisOrigen").ToString)
End If
If Dr("CalleDestino").ToString.Length > 0 Then
SBDireccionD.AppendFormat("{0}", Dr("CalleDestino").ToString)
If Dr("NoExtDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", No.Ext: {0}", Dr("NoExtDestino").ToString)
If Dr("ColoniaDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", Col: {0}", Dr("ColoniaDestino").ToString)
If Dr("CPDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", CP: {0}", Dr("CPDestino").ToString)
If Dr("LocalidadDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", Loc: {0}", Dr("LocalidadDestino").ToString)
If Dr("MunicipioDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", Cd: {0}", Dr("MunicipioDestino").ToString)
If Dr("EstadoDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", Edo: {0}", Dr("EstadoDestino").ToString)
If Dr("PaisDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", País: {0}", Dr("PaisDestino").ToString)
End If
ResponsableCarga = Dr("ResponsableCarga").ToString
ResponsableRecibio = Dr("ResponsableRecibio").ToString
Identificacion = Dr("Identificacion").ToString
Domicilio = Dr("Domicilio").ToString
Telefono = Dr("Telefono1").ToString
Ciudad = Dr("Ciudad").ToString
Licencia = Dr("Licencia").ToString
Chofer = Dr("Chofer").ToString
Placa = Dr("Placa").ToString
EspecifUnidad = Dr("Especificacion").ToString
End If
End If
If ObjInv.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
Dt = ObjInv.DtResultados
End If
ObjInv.Dispose()
ElseIf CveTimbre > 0 Then
FormatoRDLC = "RecoleccionTimbrado.rdlc"
Dim ObjGral As New ClsGenerales
If ObjGral.GetGralTimbre(CveTimbre, "-1", MinFecha, MaxFecha, -1, UsuarioActual.CveEmpresa, -1) Then
Dim Dr As DataRow = ObjGral.DtResultados.Rows(0)
Dim TipoDocto As String = Dr("TipoDocto").ToString
SerieFolio = Dr("SerieFolio").ToString
DomicilioSucursal = $"{Dr("DirOriCalle").ToString} {Dr("NoExtOrigen").ToString}, Col. {Dr("ColoniaOrigen").ToString} "
LugarFecha = $"{Dr("MunicipioOrigen").ToString}, {Dr("EstadoOrigen").ToString} {Dr("FechaMovto").ToString.ToDate.ToShortDateString}"
Origen = Dr("SPOrigen").ToString
Destino = Dr("SPDestino").ToString
Observaciones = ""
CveChofer = Dr("CveChofer").ToString
Chofer = Dr("FiguraChofer").ToString
Placa = Dr("Placa").ToString
Recibio = ""
FechaEntrega = Dr("FechaEntrega").ToString
EspecifUnidad = Dr("EspecificacionUnidad").ToString
If Dr("CalleOrigen").ToString.Length > 0 Then
SBDireccionO.AppendFormat("{0}", Dr("CalleOrigen").ToString)
If Dr("NoExtOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", No.Ext: {0}", Dr("NoExtOrigen").ToString)
If Dr("ColoniaOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", Col: {0}", Dr("ColoniaOrigen").ToString)
If Dr("CPOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", CP: {0}", Dr("CPOrigen").ToString)
If Dr("LocalidadOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", Loc: {0}", Dr("LocalidadOrigen").ToString)
If Dr("MunicipioOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", Cd: {0}", Dr("MunicipioOrigen").ToString)
If Dr("EstadoOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", Edo: {0}", Dr("EstadoOrigen").ToString)
If Dr("PaisOrigen").ToString.Length > 0 Then SBDireccionO.AppendFormat(", País: {0}", Dr("PaisOrigen").ToString)
End If
If Dr("CalleDestino").ToString.Length > 0 Then
SBDireccionD.AppendFormat("{0}", Dr("CalleDestino").ToString)
If Dr("NoExtDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", No.Ext: {0}", Dr("NoExtDestino").ToString)
If Dr("ColoniaDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", Col: {0}", Dr("ColoniaDestino").ToString)
If Dr("CPDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", CP: {0}", Dr("CPDestino").ToString)
If Dr("LocalidadDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", Loc: {0}", Dr("LocalidadDestino").ToString)
If Dr("MunicipioDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", Cd: {0}", Dr("MunicipioDestino").ToString)
If Dr("EstadoDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", Edo: {0}", Dr("EstadoDestino").ToString)
If Dr("PaisDestino").ToString.Length > 0 Then SBDireccionD.AppendFormat(", País: {0}", Dr("PaisDestino").ToString)
End If
ResponsableCarga = Dr("ResponsableCarga").ToString
ResponsableRecibio = Dr("ResponsableRecibio").ToString
Identificacion = Dr("Identificacion").ToString
Domicilio = Dr("Domicilio").ToString
Telefono = Dr("Telefono1").ToString
Ciudad = Dr("Ciudad").ToString
Licencia = Dr("Licencia").ToString
Chofer = Dr("Chofer").ToString
Placa = Dr("Placa").ToString
EspecifUnidad = Dr("Especificacion").ToString
If ObjGral.GetGralMovimientosDetalleTimbre(CveTimbre, UsuarioActual.CveEmpresa) Then
Dt = ObjGral.DtResultados
End If
Dim Ruta As String = UsuarioActual.Empresa.Ruta
Dim PathXML As String = $"{Ruta}XML\{TipoDocto}\{SerieFolio }.xml"
Dim FechaEmision, FechaCertificacion As DateTime
Dim FolioFiscal, NoSerieCertificado, NoSerieCertificadoContribuyente, SelloCFDi, SelloSAT, SerieCertificadoSAT As String
FolioFiscal = ""
NoSerieCertificado = ""
SelloCFDi = ""
SelloSAT = ""
SerieCertificadoSAT = ""
If UsuarioActual.CveUsuario = 100 Then
Alert(PathXML)
End If
If System.IO.File.Exists(PathXML) Then
Dim ReceptorRFC As String = ""
Dim XmlDoc As New System.Xml.XmlDocument
XmlDoc.Load(PathXML)
Dim nodo As XmlNode = XmlDoc.DocumentElement
Dim Version = ValorXML(nodo, "version")
Dim namespaces As New XmlNamespaceManager(XmlDoc.NameTable)
Dim Prefijo As String = If(XmlDoc.DocumentElement.Prefix = "", "cfd", XmlDoc.DocumentElement.Prefix)
Dim cfdVer As String = ""
If Version = "3.2" Then
Prefijo = "cfd"
cfdVer = "http://www.sat.gob.mx/cfd/2"
ElseIf Version = "3.3" Then
cfdVer = "http://www.sat.gob.mx/cfd/3"
Else ' se considera que es la version 4.0
cfdVer = "http://www.sat.gob.mx/cfd/4"
End If
namespaces.AddNamespace(Prefijo, cfdVer)
namespaces.AddNamespace("tfd", "http://www.sat.gob.mx/TimbreFiscalDigital")
namespaces.AddNamespace("implocal", "http://www.sat.gob.mx/implocal")
namespaces.AddNamespace("registrofiscal", "http://www.sat.gob.mx/registrofiscal")
Dim node As XmlNode
node = XmlDoc.SelectSingleNode(String.Format("//{0}:Receptor", Prefijo), namespaces)
If node IsNot Nothing Then
ReceptorRFC = ValorXML(node, "RFC")
End If
If Version.Contiene("3.3", "4.0") Then
FechaEmision = XmlDoc.DocumentElement.Attributes("Fecha").InnerText.ToDate
NoSerieCertificadoContribuyente = XmlDoc.DocumentElement.Attributes("NoCertificado").InnerText
For i As Integer = 0 To XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes.Count - 1
If XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Name = "tfd:TimbreFiscalDigital" Then
FolioFiscal = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("UUID").InnerText
NoSerieCertificado = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("NoCertificadoSAT").InnerText
FechaCertificacion = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("FechaTimbrado").InnerText.ToDate
SelloCFDi = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("SelloCFD").InnerText
SelloSAT = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("SelloSAT").InnerText
SerieCertificadoSAT = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("NoCertificadoSAT").InnerText
End If
Next
Else
FechaEmision = XmlDoc.DocumentElement.Attributes("fecha").InnerText.ToDate
NoSerieCertificadoContribuyente = XmlDoc.DocumentElement.Attributes("noCertificado").InnerText
For i As Integer = 0 To XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes.Count - 1
If XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Name = "tfd:timbreFiscalDigital" Then
FolioFiscal = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("UUID").InnerText
NoSerieCertificado = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("noCertificadoSAT").InnerText
FechaCertificacion = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("fechaTimbrado").InnerText.ToDate
SelloCFDi = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("selloCFD").InnerText
SelloSAT = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("selloSAT").InnerText
SerieCertificadoSAT = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("NoCertificadoSAT").InnerText
End If
Next
End If
Dim CadenaOriginals As String = String.Format("||{0}|{1}|{2}T{3}|{4}|{5}||", If(Version.Contiene("3.3", "4.0"), "1.1", "1.0"), FolioFiscal, FechaCertificacion.ToString("yyyy-MM-dd"), FechaCertificacion.ToString("HH:mm:ss"), SelloCFDi, NoSerieCertificado)
Dim RutaCBB As String = $"{UsuarioActual.Empresa.Ruta}CBB\{SerieFolio}.jpg"
Dim ImagenCBB As New System.IO.FileInfo(RutaCBB)
If Not ImagenCBB.Exists Then
Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar()
CBB.GenerarCBB(UsuarioActual.Empresa.RFC, ReceptorRFC, 1, FolioFiscal, RutaCBB)
End If
Dim ImgCBB As String = $"file://{ImagenCBB.FullName}"
params.Add(New ReportParameter("FolioFiscal", FolioFiscal))
params.Add(New ReportParameter("CertificadoSAT", NoSerieCertificado))
params.Add(New ReportParameter("FechaCertificacion", FechaCertificacion.ToString))
params.Add(New ReportParameter("SelloCFDI", SelloCFDi))
params.Add(New ReportParameter("SelloSAT", SelloSAT))
params.Add(New ReportParameter("CertificadoContribuyente", NoSerieCertificadoContribuyente))
params.Add(New ReportParameter("QR", ImgCBB.ToString))
params.Add(New ReportParameter("SerieCertificadoSAT", SerieCertificadoSAT))
params.Add(New ReportParameter("CadenaOriginal", CadenaOriginals))
End If
End If
ObjGral.Dispose()
End If
Dim Dt As DataTable = Nothing
If ObjInv.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
Dt = ObjInv.DtResultados
End If
ObjInv.Dispose()
If Dt.Rows.Count > 0 Then
Dim params As New List(Of ReportParameter)
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
@@ -1516,8 +1737,6 @@ Partial Class PopUpVerFactura
params.Add(New ReportParameter("LogoPath", ""))
End If
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString))
@@ -1547,11 +1766,28 @@ Partial Class PopUpVerFactura
params.Add(New ReportParameter("Ciudad", Ciudad))
params.Add(New ReportParameter("Licencia", Licencia))
ImprimirPDF("Empresas/Grales/Formatos/CartaPorte.rdlc", Dt, params, String.Format("Carta Porte -{0}", Now.ToDateTime.ToShortDateString))
ImprimirPDF($"Empresas/Grales/Formatos/{FormatoRDLC}", Dt, params, String.Format("Carta Porte -{0}", Now.ToDateTime.ToShortDateString))
End If
End If
End Sub
Private Function ValorNodoXML(n As System.Xml.XmlNode, Campo As String, Optional Retorno As String = "") As String
Dim o As System.Xml.XmlNode = n.Attributes.Cast(Of System.Xml.XmlAttribute)().SingleOrDefault(Function(a) String.Compare(a.Name, Campo, True) = 0)
If o Is Nothing Then
Return Retorno
Else
Return o.Value
End If
End Function
Private Function ValorXML(n As XmlNode, Campo As String, Optional Retorno As String = "") As String
Dim o As XmlNode = n.Attributes.Cast(Of XmlAttribute)().SingleOrDefault(Function(a) String.Compare(a.Name, Campo, True) = 0)
If o Is Nothing Then