Recepcion y vinculacion facturas 4.0

This commit is contained in:
rakcsle
2022-01-26 15:30:13 -07:00
parent 473b813381
commit c8efadf0da
5 changed files with 174 additions and 97 deletions

View File

@@ -1118,7 +1118,7 @@ Partial Class Compras_Compras
CargaDatosAgregarPS()
TieneAnticiposXML = False
Modalidad = ""
Version = "3.3"
Version = "4.0"
CveMetodoPago = -1
RFCProv = ""
CargaDdlTipoGasto()
@@ -1638,7 +1638,7 @@ Partial Class Compras_Compras
End Sub
Private Sub ValidaIVA()
If Version <> "3.3" And CveCompra <= 0 Then
If (Version <> "3.3" And Version <> "4.0") And CveCompra <= 0 Then
Dim ImporteIVAXML As Double = (TxtSubTotal.Text.Trim.ToDouble - TxtDescuento.Text.Trim.ToDouble - TxtIEPS.Text.Trim.ToDouble) * 0.16
If Math.Abs(TxtIVA.Text.Trim.ToDouble - ImporteIVAXML) >= 1 Then
Alert("El <b>IVA</b> del <b>CFDi</b> no tiene un comportamiento normal, por favor verifique que sea correcto. <br /><br /> <b>NOTA:</b> Esta advertencia no aplica en casos de conceptos(alimentos, combustibles o servicios de comunicación) exentos de IVA o causantes de IEPS.", TipoMensaje.MsgAdvertencia)
@@ -1743,15 +1743,29 @@ Partial Class Compras_Compras
CargaComprobanteXML(XMLDoc)
If NuevaValidacionXML = 1 Or Version = "3.3" Then
If NuevaValidacionXML = 1 Or (Version = "3.3" Or Version = "4.0") Then
Dim Xml As New StringBuilder
Dim nodo As XmlNode = XMLDoc.DocumentElement
Dim Version = ValorXML(nodo, "version")
Dim Prefijo As String = If(XMLDoc.DocumentElement.Prefix = "", "cfd", XMLDoc.DocumentElement.Prefix)
Dim cfdVer As String = "http://www.sat.gob.mx/cfd/3"
Dim cfdVer As String = ""
Dim namespaces As New XmlNamespaceManager(XMLDoc.NameTable)
If Prefijo.ToLower <> "cfdi" Then cfdVer = "http://www.sat.gob.mx/cfd/2"
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
'If Prefijo.ToLower <> "cfdi" Then cfdVer = "http://www.sat.gob.mx/cfd/2"
namespaces.AddNamespace(Prefijo, cfdVer)
namespaces.AddNamespace("tfd", "http://www.sat.gob.mx/TimbreFiscalDigital")
namespaces.AddNamespace("implocal", "http://www.sat.gob.mx/implocal")
@@ -1759,7 +1773,8 @@ Partial Class Compras_Compras
Dim nodeconceptos As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Conceptos", Prefijo), namespaces)
Xml.Append(Replace(Replace(Replace(nodeconceptos.OuterXml, "<cfdi:", "<"), "</cfdi:", "</"), "xmlns:cfdi=""http://www.sat.gob.mx/cfd/3""", ""))
Xml.Append(Replace(Replace(Replace(Replace(nodeconceptos.OuterXml, "<cfdi:", "<"), "</cfdi:", "</"), "xmlns:cfdi=""http://www.sat.gob.mx/cfd/3""", ""), "xmlns:cfdi=""http://www.sat.gob.mx/cfd/4""", ""))
If ObjeFacturas.GetFacturasComparacionXML(Version, Xml.ToString, UsuarioActual.CveEmpresa) Then
TmpDT = ObjeFacturas.DtResultados
TmpDT.Columns.Add("CveSATPSActualizado")
@@ -1883,7 +1898,7 @@ Partial Class Compras_Compras
Dim Msg As String = ""
If Version = "3.3" Then
If Version = "3.3" Or Version = "4.0" Then
ValidacionesTotalesXml()
@@ -3573,11 +3588,25 @@ Partial Class Compras_Compras
'Dim DtPSTemp = TmpDT.Clone
'Dim Row As DataRow = Nothing
Dim Prefijo As String = If(XMLDoc.DocumentElement.Prefix = "", "cfd", XMLDoc.DocumentElement.Prefix)
Dim cfdVer As String = "http://www.sat.gob.mx/cfd/3"
Dim namespaces As New XmlNamespaceManager(XMLDoc.NameTable)
If Prefijo.ToLower <> "cfdi" Then cfdVer = "http://www.sat.gob.mx/cfd/2"
Dim nodo As XmlNode = XMLDoc.DocumentElement
Dim VersionCFDI As String = ValorXML(nodo, "version")
Dim Prefijo As String = If(XMLDoc.DocumentElement.Prefix = "", "cfd", XMLDoc.DocumentElement.Prefix)
Dim cfdVer As String = ""
If VersionCFDI = "3.2" Then
Prefijo = "cfd"
cfdVer = "http://www.sat.gob.mx/cfd/2"
ElseIf VersionCFDI = "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")
@@ -3714,7 +3743,7 @@ Partial Class Compras_Compras
'Alert(ValorXML(node, "ClaveProdServ").Trim)
If Version = "3.3" Then
If Version = "3.3" Or Version = "4.0" Then
If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then
'OBTENER TRASLADOS POR DETALLES
Dim ContadorTraslado = 0
@@ -5171,7 +5200,7 @@ Partial Class Compras_Compras
End If
'ACTUALIZAR PRODUCTO/SERVICIO SAT
If Version = "3.3" Then
If Version = "3.3" Or Version = "4.0" Then
If Row("CveSATPSActualizado").ToString().ToEntero() = 1 Then
If Not ObjProductosServicios.UpdateProductosServiciosSAT(Row("CvePS").ToString().ToEntero(), Row("CveSATPS").ToString().ToEntero(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
ErrorSATPS = True
@@ -10833,7 +10862,7 @@ Partial Class Compras_Compras
If Version = "3.3" Then
If Version = "3.3" Or Version = "4.0" Then
Dim drm As DataRow = GlobalDTVtaMetodoPago.FiltroPrimero(String.Format("ClaveMetodoPagoSAT = '{0}'", ValorXML(nodo, "MetodoPago")))
If drm IsNot Nothing Then
CveMetodoPago = drm("CveMetodoPago").ToString.ToEntero
@@ -10842,11 +10871,28 @@ Partial Class Compras_Compras
End If
Dim Prefijo As String = If(XMLDoc.DocumentElement.Prefix = "", "cfd", XMLDoc.DocumentElement.Prefix)
Dim cfdVer As String = "http://www.sat.gob.mx/cfd/3"
Dim namespaces As New XmlNamespaceManager(XMLDoc.NameTable)
If Prefijo.ToLower <> "cfdi" Then cfdVer = "http://www.sat.gob.mx/cfd/2"
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
'If Prefijo.ToLower <> "cfdi" Then cfdVer = "http://www.sat.gob.mx/cfd/2"
namespaces.AddNamespace(Prefijo, cfdVer)
namespaces.AddNamespace("tfd", "http://www.sat.gob.mx/TimbreFiscalDigital")
namespaces.AddNamespace("implocal", "http://www.sat.gob.mx/implocal")
@@ -10889,7 +10935,7 @@ Partial Class Compras_Compras
TotalRetenciones = ValorXML(node, "totalImpuestosRetenidos", "0").ToDecimal
If Version = "3.3" Then
If Version = "3.3" Or Version = "4.0" Then
For Each retencion As XmlNode In nodeRetenciones
If retencion.Attributes("Impuesto").Value = "002" Then
@@ -10920,7 +10966,7 @@ Partial Class Compras_Compras
TotalTraslados = ValorXML(node, "totalImpuestosTrasladados", "0").ToDecimal
Dim nodeTraslados As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:Comprobante/{0}:Impuestos/{0}:Traslados/{0}:Traslado", Prefijo), namespaces)
If Version = "3.3" Then
If Version = "3.3" Or Version = "4.0" Then
For Each traslado As XmlNode In nodeTraslados
If traslado.Attributes("Impuesto").Value = "002" Then
@@ -15639,7 +15685,7 @@ Partial Class Compras_Compras
e.Row.FCLabel("LbEstatusInv").Text = "NA"
End If
If Version = "3.3" Then
If Version = "3.3" Or Version = "4.0" Then
CargaPSSAT(e.Row.FCDropDownLost("DdlSATPS"))
If e.Row.DBCampo("CveSATPS").ToEntero > 0 Then
e.Row.FCDropDownLost("DdlSATPS").SelectedValue = e.Row.DBCampo("CveSATPS")
@@ -18305,7 +18351,7 @@ Partial Class Compras_Compras
Row("Consec") = TmpDT.Rows.Count + 1
End If
If Version = "3.3" And CveSATPS > 0 Then
If (Version = "3.3" Or Version = "4.0") And CveSATPS > 0 Then
Dim DrPSSAT As DataRow = Nothing
If CargaXml Then
DrPSSAT = GlobalDTPSATPS("-1", CveSATPS.ToString).FiltroPrimero("")
@@ -18362,7 +18408,7 @@ Partial Class Compras_Compras
Row("NoDeducible") = NoDeducible
Row("PU") = Math.Round(PU, DecimalesPermitidos)
If CargaXml And Version = "3.3" Then
If CargaXml And (Version = "3.3" Or Version = "4.0") Then
Row("IVA") = Math.Round(IVA, DecimalesPermitidos)
Row("IVAPorcentaje") = PorcentajeIVA
Row("RetIVA") = Math.Round(RetIVA, DecimalesPermitidos)

View File

@@ -2845,6 +2845,8 @@ Partial Class Compras_eFacturas
Dim XMLDoc As New XmlDocument
Dim Archivo As String = String.Format("{0}Compras\{1}\{2}", UsuarioActual.Empresa.Ruta, gvRow.DataKey("RFCDe"), gvRow.DataKey("XML"))
Dim Prefijo As String = ""
If IO.File.Exists(Archivo) Then
@@ -2855,12 +2857,27 @@ Partial Class Compras_eFacturas
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")
Dim RootDocumento As XmlElement = XMLDoc.DocumentElement
Dim VersionCFDI As String = ValorXML(RootDocumento, "version")
If VersionCFDI = "3.3" Then
Prefijo = "pago10"
namespaces.AddNamespace("pago10", "http://www.sat.gob.mx/Pagos")
namespaces.AddNamespace(XMLDoc.DocumentElement.Prefix, "http://www.sat.gob.mx/cfd/3")
ElseIf VersionCFDI = "4.0" Then
Prefijo = "pago20"
namespaces.AddNamespace("pago20", "http://www.sat.gob.mx/Pagos20")
namespaces.AddNamespace(XMLDoc.DocumentElement.Prefix, "http://www.sat.gob.mx/cfd/4")
End If
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)
@@ -2868,20 +2885,20 @@ Partial Class Compras_eFacturas
nodeTFD = nodeComp.SelectSingleNode(String.Format("//{0}:TimbreFiscalDigital", "tfd"), namespaces)
Dim PrefijoPagos As String = ""
'Dim PrefijoPagos As String = ""
For Each nodoPrefijo As XmlNode In nodeComp.ChildNodes
If nodoPrefijo.Prefix <> "tfd" And nodoPrefijo.Prefix.ToUpper.Contains("PAGO") Then
PrefijoPagos = nodoPrefijo.Prefix
End If
Next
'For Each nodoPrefijo As XmlNode In nodeComp.ChildNodes
' If nodoPrefijo.Prefix <> "tfd" And nodoPrefijo.Prefix.ToUpper.Contains("PAGO") Then
' PrefijoPagos = nodoPrefijo.Prefix
' End If
'Next
namespaces.AddNamespace(PrefijoPagos, "http://www.sat.gob.mx/Pagos")
'namespaces.AddNamespace(PrefijoPagos, "http://www.sat.gob.mx/Pagos")
nodeComp = XMLDoc.SelectSingleNode(String.Format("//{0}:Complemento", XMLDoc.DocumentElement.Prefix), namespaces)
nodePagos = nodeComp.SelectSingleNode(String.Format("//{0}:Pagos/{0}:Pago", PrefijoPagos), namespaces)
nodePagos2 = nodeComp.SelectSingleNode(String.Format("//{0}:Pagos", PrefijoPagos), namespaces)
nodePagos = nodeComp.SelectSingleNode(String.Format("//{0}:Pagos/{0}:Pago", Prefijo), namespaces)
nodePagos2 = nodeComp.SelectSingleNode(String.Format("//{0}:Pagos", Prefijo), namespaces)
@@ -2923,7 +2940,7 @@ Partial Class Compras_eFacturas
Dim nodePagosN As XmlNodeList
nodePagosN = nodeComp.SelectNodes(String.Format("//{0}:Pagos", PrefijoPagos), namespaces)
nodePagosN = nodeComp.SelectNodes(String.Format("//{0}:Pagos", Prefijo), namespaces)
For Each NodosPagos As XmlNode In nodePagosN
@@ -2964,7 +2981,7 @@ Partial Class Compras_eFacturas
MontoPago = Monto
Dim ObjCompraFolios As New ClsCompras
If ObjCompraFolios.GetCompararComplementoPago(gvRow.DataKey("CveProveedor").ToEntero, Monto, nodePagos2.InnerXml.Replace($"{PrefijoPagos}:", ""), UsuarioActual.CveEmpresa, OP:=If(CveComplementoPagoCompra > 0, 2, 1), CveFactura:=CveFacturaComplemento) Then
If ObjCompraFolios.GetCompararComplementoPago(gvRow.DataKey("CveProveedor").ToEntero, Monto, nodePagos2.InnerXml.Replace($"{Prefijo}:", ""), UsuarioActual.CveEmpresa, OP:=If(CveComplementoPagoCompra > 0, 2, 1), CveFactura:=CveFacturaComplemento) Then
'
'.GetCompararComplementoPago(gvRow.DataKey("CveProveedor").ToEntero, Monto, nodePagos2.InnerXml.Replace("pago10:", ""), UsuarioActual.CveEmpresa) Then
If ObjCompraFolios.DtResultados.Rows.Count > 0 Then