-- complemento de pago Revisión B
This commit is contained in:
@@ -654,134 +654,131 @@ Public Class Timbrado
|
|||||||
Return retorno
|
Return retorno
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function PreparaTimbrePago(EmisorRFC As String, EmisorNombre As String, EmisorRegimenFiscal As String,
|
'Public Function PreparaTimbrePago(EmisorRFC As String, EmisorNombre As String, EmisorRegimenFiscal As String,
|
||||||
ReceptorRFC As String, ReceptorNombre As String, Serie As String, Folio As String, FechaTimbrado As DateTime,
|
' ReceptorRFC As String, ReceptorNombre As String, Serie As String, Folio As String, FechaTimbrado As DateTime,
|
||||||
CuentaPago As String, FechaPago As DateTime, FormaPago As String, MonedaPago As String, Monto As Decimal, LugarExpedicion As String,
|
' CuentaPago As String, FechaPago As DateTime, FormaPago As String, MonedaPago As String, Monto As Decimal, LugarExpedicion As String,
|
||||||
CuentaBeneficiario As String, TipoCambioP As Decimal, dttpagos As Data.DataTable,
|
' CuentaBeneficiario As String, TipoCambioP As Decimal, dttpagos As Data.DataTable,
|
||||||
Optional UsoCFDI As String = "P01", Optional CFDIRelacionado As String = "", Optional EsCancelacion As Boolean = False) As CFDITimbre
|
' Optional UsoCFDI As String = "P01", Optional CFDIRelacionado As String = "", Optional EsCancelacion As Boolean = False) As CFDITimbre
|
||||||
' validación extra para cuando es cancelación requiere el folio relacionado
|
' ' validación extra para cuando es cancelación requiere el folio relacionado
|
||||||
If EsCancelacion AndAlso CFDIRelacionado = "" Then
|
' If EsCancelacion AndAlso CFDIRelacionado = "" Then
|
||||||
Return Nothing
|
' Return Nothing
|
||||||
End If
|
' End If
|
||||||
|
|
||||||
Dim Timbre As New CFDITimbre
|
' Dim Timbre As New CFDITimbre
|
||||||
|
|
||||||
Timbre.Comprobante.TipoComprobante = "P"
|
' Timbre.Comprobante.TipoComprobante = "P"
|
||||||
Timbre.Comprobante.Folio = Folio
|
' Timbre.Comprobante.Folio = Folio
|
||||||
Timbre.Comprobante.Serie = Serie
|
' Timbre.Comprobante.Serie = Serie
|
||||||
Timbre.Comprobante.Fecha = FechaTimbrado
|
' Timbre.Comprobante.Fecha = FechaTimbrado
|
||||||
Timbre.Comprobante.FormadePago = ""
|
' Timbre.Comprobante.FormadePago = ""
|
||||||
Timbre.Comprobante.CondicionesdePago = ""
|
' Timbre.Comprobante.CondicionesdePago = ""
|
||||||
Timbre.Comprobante.MetodoPago = ""
|
' Timbre.Comprobante.MetodoPago = ""
|
||||||
Timbre.Comprobante.SubTotal = 0
|
' Timbre.Comprobante.SubTotal = 0
|
||||||
Timbre.Comprobante.Descuentos = 0
|
' Timbre.Comprobante.Descuentos = 0
|
||||||
Timbre.Comprobante.Moneda = "XXX"
|
' Timbre.Comprobante.Moneda = "XXX"
|
||||||
Timbre.Comprobante.TipoCambio = ""
|
' Timbre.Comprobante.TipoCambio = ""
|
||||||
Timbre.Comprobante.Total = 0
|
' Timbre.Comprobante.Total = 0
|
||||||
|
|
||||||
Timbre.Comprobante.LugarExpedicion = LugarExpedicion
|
' Timbre.Comprobante.LugarExpedicion = LugarExpedicion
|
||||||
|
' Timbre.Emisor.RegimenFiscal = EmisorRegimenFiscal
|
||||||
|
' Timbre.Emisor.Nombre = EmisorNombre
|
||||||
|
' Timbre.Emisor.RFC = EmisorRFC
|
||||||
|
|
||||||
Timbre.Emisor.RegimenFiscal = EmisorRegimenFiscal
|
' Timbre.Receptor.RFC = ReceptorRFC
|
||||||
Timbre.Emisor.Nombre = EmisorNombre
|
' Timbre.Receptor.Nombre = ReceptorNombre
|
||||||
Timbre.Emisor.RFC = EmisorRFC
|
' Timbre.Receptor.UsoCFDI = UsoCFDI
|
||||||
|
|
||||||
Timbre.Receptor.RFC = ReceptorRFC
|
' If CFDIRelacionado <> "-1" And CFDIRelacionado <> "" Then
|
||||||
Timbre.Receptor.Nombre = ReceptorNombre
|
' Timbre.CFDIRelacionados.TipoRelacion = "04"
|
||||||
Timbre.Receptor.UsoCFDI = UsoCFDI
|
' Timbre.CFDIRelacionados.UUID.Add(CFDIRelacionado)
|
||||||
|
' End If
|
||||||
|
|
||||||
If CFDIRelacionado <> "-1" And CFDIRelacionado <> "" Then
|
' 'detalles
|
||||||
Timbre.CFDIRelacionados.TipoRelacion = "04"
|
' Dim concepto As New CFDIConceptos With {.Cantidad = 1,
|
||||||
Timbre.CFDIRelacionados.UUID.Add(CFDIRelacionado)
|
' .Descripcion = "Pago",
|
||||||
End If
|
' .ValorUnitario = 0,
|
||||||
|
' .Importe = 0,
|
||||||
|
' .Unidad = "",
|
||||||
|
' .ClaveUnidad = "ACT",
|
||||||
|
' .ClaveProdServ = "84111506",
|
||||||
|
' .Noidentificacion = ""}
|
||||||
|
' Timbre.Conceptos.Add(concepto)
|
||||||
|
|
||||||
'detalles
|
' Select Case FormaPago
|
||||||
|
' Case "01"
|
||||||
|
' CuentaPago = ""
|
||||||
|
' CuentaBeneficiario = ""
|
||||||
|
' End Select
|
||||||
|
|
||||||
Dim concepto As New CFDIConceptos With {.Cantidad = 1,
|
' Dim ImporteCancelacion As Decimal = 1
|
||||||
.Descripcion = "Pago",
|
' Dim MonedaCancelacion As String = "MXN"
|
||||||
.ValorUnitario = 0,
|
' Dim TipoCambioCancelacion As Decimal = 1
|
||||||
.Importe = 0,
|
' If EsCancelacion Then MonedaPago = MonedaCancelacion
|
||||||
.Unidad = "",
|
' 'como registra un peso por cada fatura que se cancele, se tiene que multiplicar por el numero de facturas, para que se pueda emitir el timbre
|
||||||
.ClaveUnidad = "ACT",
|
' If dttpagos IsNot Nothing AndAlso dttpagos.Rows.Count > 0 Then ImporteCancelacion = ImporteCancelacion * dttpagos.Rows.Count
|
||||||
.ClaveProdServ = "84111506",
|
' Timbre.ComplementoPagos.CtaOrdenante = CuentaPago
|
||||||
.Noidentificacion = ""}
|
' Timbre.ComplementoPagos.CtaBeneficiario = CuentaBeneficiario
|
||||||
Timbre.Conceptos.Add(concepto)
|
' Timbre.ComplementoPagos.FechaPago = FechaPago
|
||||||
|
' Timbre.ComplementoPagos.FormaDePagoP = FormaPago
|
||||||
Select Case FormaPago
|
' Timbre.ComplementoPagos.MonedaP = MonedaPago
|
||||||
Case "01"
|
' Timbre.ComplementoPagos.Monto = If(EsCancelacion, ImporteCancelacion, Monto).RoundSQL
|
||||||
CuentaPago = ""
|
' Timbre.ComplementoPagos.TipoCambioP = If(EsCancelacion, TipoCambioCancelacion, TipoCambioP)
|
||||||
CuentaBeneficiario = ""
|
|
||||||
|
|
||||||
End Select
|
|
||||||
|
|
||||||
Dim ImporteCancelacion As Decimal = 1
|
|
||||||
Dim MonedaCancelacion As String = "MXN"
|
|
||||||
Dim TipoCambioCancelacion As Decimal = 1
|
|
||||||
If EsCancelacion Then MonedaPago = MonedaCancelacion
|
|
||||||
'como registra un peso por cada fatura que se cancele, se tiene que multiplicar por el numero de facturas, para que se pueda emitir el timbre
|
|
||||||
If dttpagos IsNot Nothing AndAlso dttpagos.Rows.Count > 0 Then ImporteCancelacion = ImporteCancelacion * dttpagos.Rows.Count
|
|
||||||
Timbre.ComplementoPagos.CtaOrdenante = CuentaPago
|
|
||||||
Timbre.ComplementoPagos.CtaBeneficiario = CuentaBeneficiario
|
|
||||||
Timbre.ComplementoPagos.FechaPago = FechaPago
|
|
||||||
Timbre.ComplementoPagos.FormaDePagoP = FormaPago
|
|
||||||
Timbre.ComplementoPagos.MonedaP = MonedaPago
|
|
||||||
Timbre.ComplementoPagos.Monto = If(EsCancelacion, ImporteCancelacion, Monto).RoundSQL
|
|
||||||
Timbre.ComplementoPagos.TipoCambioP = If(EsCancelacion, TipoCambioCancelacion, TipoCambioP)
|
|
||||||
|
|
||||||
|
|
||||||
Dim VentaFolioFiscal, VentaSerie, VentaFolio, VentaAbreviaturaSAT, VentaMetodoPago As String
|
' Dim VentaFolioFiscal, VentaSerie, VentaFolio, VentaAbreviaturaSAT, VentaMetodoPago As String
|
||||||
Dim VentaImportePago, VentaImporteSaldoInsoluto, VentaImporteSaldoAnterior, VentaTipoCambio, PorcentajeIVA, PorcentajeIEPS As Decimal
|
' Dim VentaImportePago, VentaImporteSaldoInsoluto, VentaImporteSaldoAnterior, VentaTipoCambio, PorcentajeIVA, PorcentajeIEPS As Decimal
|
||||||
Dim VentaNumParcialidad As Integer
|
' Dim VentaNumParcialidad As Integer
|
||||||
|
|
||||||
If dttpagos IsNot Nothing AndAlso dttpagos.Rows.Count > 0 Then
|
' If dttpagos IsNot Nothing AndAlso dttpagos.Rows.Count > 0 Then
|
||||||
|
|
||||||
For Each dr As Data.DataRow In dttpagos.Rows
|
' For Each dr As Data.DataRow In dttpagos.Rows
|
||||||
VentaFolioFiscal = dr("FolioFiscal").ToString
|
' VentaFolioFiscal = dr("FolioFiscal").ToString
|
||||||
VentaSerie = dr("VentaSerie").ToString
|
' VentaSerie = dr("VentaSerie").ToString
|
||||||
VentaFolio = dr("VentaFolio").ToString
|
' VentaFolio = dr("VentaFolio").ToString
|
||||||
VentaAbreviaturaSAT = dr("VentaAbreviaturaSAT").ToString
|
' VentaAbreviaturaSAT = dr("VentaAbreviaturaSAT").ToString
|
||||||
VentaMetodoPago = dr("MetodoPago").ToString
|
' VentaMetodoPago = dr("MetodoPago").ToString
|
||||||
VentaImportePago = dr("VentaImportePagado").ToString.ToDecimal
|
' VentaImportePago = dr("VentaImportePagado").ToString.ToDecimal
|
||||||
VentaImporteSaldoInsoluto = dr("ImpSaldoInsoluto").ToString.ToDecimal
|
' VentaImporteSaldoInsoluto = dr("ImpSaldoInsoluto").ToString.ToDecimal
|
||||||
VentaImporteSaldoAnterior = dr("ImpSaldoAnterior").ToString.ToDecimal
|
' VentaImporteSaldoAnterior = dr("ImpSaldoAnterior").ToString.ToDecimal
|
||||||
VentaTipoCambio = dr("TipoCambio").ToString.ToDecimal
|
' VentaTipoCambio = dr("TipoCambio").ToString.ToDecimal
|
||||||
VentaNumParcialidad = dr("NumParcialidad").ToString.ToEntero
|
' VentaNumParcialidad = dr("NumParcialidad").ToString.ToEntero
|
||||||
PorcentajeIVA = dr("PorcentajeIVA").ToString.ToDecimal
|
' PorcentajeIVA = dr("PorcentajeIVA").ToString.ToDecimal
|
||||||
PorcentajeIEPS = dr("PorcentajeIEPS").ToString.ToDecimal
|
' PorcentajeIEPS = dr("PorcentajeIEPS").ToString.ToDecimal
|
||||||
' si la moneda es igual, se omite el tipo de cambio de la venta
|
' ' si la moneda es igual, se omite el tipo de cambio de la venta
|
||||||
If MonedaPago = VentaAbreviaturaSAT Then VentaTipoCambio = 0
|
' If MonedaPago = VentaAbreviaturaSAT Then VentaTipoCambio = 0
|
||||||
|
|
||||||
'condiciones especiales para el pago en pesos, facturas en moneda extranjera
|
' 'condiciones especiales para el pago en pesos, facturas en moneda extranjera
|
||||||
If MonedaPago = "MXN" AndAlso VentaAbreviaturaSAT <> "MXN" Then
|
' If MonedaPago = "MXN" AndAlso VentaAbreviaturaSAT <> "MXN" Then
|
||||||
VentaTipoCambio = 1 / VentaTipoCambio
|
' VentaTipoCambio = 1 / VentaTipoCambio
|
||||||
End If
|
' End If
|
||||||
|
|
||||||
' For Each drr As Data.DataRow In DtFacturasPagadas.Rows
|
' ' For Each drr As Data.DataRow In DtFacturasPagadas.Rows
|
||||||
Dim doc As New CFDIComplementoPagosDocsRelacionados With {.IdDocumento = VentaFolioFiscal,
|
' Dim doc As New CFDIComplementoPagosDocsRelacionados With {.IdDocumento = VentaFolioFiscal,
|
||||||
.Serie = VentaSerie,
|
' .Serie = VentaSerie,
|
||||||
.Folio = VentaFolio,
|
' .Folio = VentaFolio,
|
||||||
.MonedaDR = VentaAbreviaturaSAT,
|
' .MonedaDR = VentaAbreviaturaSAT,
|
||||||
.MetodoDePagoDR = VentaMetodoPago,
|
' .MetodoDePagoDR = VentaMetodoPago,
|
||||||
.ImpPagado = If(EsCancelacion, 1, VentaImportePago),
|
' .ImpPagado = If(EsCancelacion, 1, VentaImportePago),
|
||||||
.ImpSaldoInsoluto = If(EsCancelacion, VentaImporteSaldoAnterior - 1, VentaImporteSaldoInsoluto),
|
' .ImpSaldoInsoluto = If(EsCancelacion, VentaImporteSaldoAnterior - 1, VentaImporteSaldoInsoluto),
|
||||||
.ImpSaldoAnt = VentaImporteSaldoAnterior,
|
' .ImpSaldoAnt = VentaImporteSaldoAnterior,
|
||||||
.TipoCambioDR = VentaTipoCambio,
|
' .TipoCambioDR = VentaTipoCambio,
|
||||||
.NumParcialidad = VentaNumParcialidad} 'If(drr("MetodoPago").ToString = "PUE", 0, drr("NumParcialidad").ToString.ToEntero)}
|
' .NumParcialidad = VentaNumParcialidad} 'If(drr("MetodoPago").ToString = "PUE", 0, drr("NumParcialidad").ToString.ToEntero)}
|
||||||
Timbre.ComplementoPagos.DocumentosRelacionados.Add(doc)
|
' Timbre.ComplementoPagos.DocumentosRelacionados.Add(doc)
|
||||||
|
|
||||||
Next
|
' Next
|
||||||
End If
|
' End If
|
||||||
'If drr("IVA").ToString.ToDouble > 0 Then
|
' 'If drr("IVA").ToString.ToDouble > 0 Then
|
||||||
If PorcentajeIVA > 0 Then Timbre.ComplementoPagos.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = VentaImportePago * PorcentajeIVA, .TasaOCuota = PorcentajeIVA, .Impuesto = "002"})
|
' If PorcentajeIVA > 0 Then Timbre.ComplementoPagos.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = VentaImportePago * PorcentajeIVA, .TasaOCuota = PorcentajeIVA, .Impuesto = "002"})
|
||||||
'Timbre.ComplementoPagos.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "R", .Base = 0, .TasaOCuota = 0, .Impuesto = "002"})
|
' 'Timbre.ComplementoPagos.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "R", .Base = 0, .TasaOCuota = 0, .Impuesto = "002"})
|
||||||
|
|
||||||
If PorcentajeIEPS > 0 Then Timbre.ComplementoPagos.Impuestos.Add(New CFDIConceptosImpuestos With {.Base = VentaImportePago * PorcentajeIEPS, .TasaOCuota = PorcentajeIEPS, .Impuesto = "003"})
|
' If PorcentajeIEPS > 0 Then Timbre.ComplementoPagos.Impuestos.Add(New CFDIConceptosImpuestos With {.Base = VentaImportePago * PorcentajeIEPS, .TasaOCuota = PorcentajeIEPS, .Impuesto = "003"})
|
||||||
|
|
||||||
|
|
||||||
'Next
|
' 'Next
|
||||||
|
|
||||||
Return Timbre
|
' Return Timbre
|
||||||
|
|
||||||
End Function
|
'End Function
|
||||||
|
|
||||||
Public Function PreparaTimbrePago40(EmisorRFC As String, EmisorNombre As String, EmisorRegimenFiscal As String,
|
Public Function PreparaTimbrePago40(EmisorRFC As String, EmisorNombre As String, EmisorRegimenFiscal As String,
|
||||||
ReceptorRFC As String, ReceptorNombre As String, ReceptorDomicilioFiscal As String, ReceptorRegimenFiscal As String,
|
ReceptorRFC As String, ReceptorNombre As String, ReceptorDomicilioFiscal As String, ReceptorRegimenFiscal As String,
|
||||||
@@ -2732,8 +2729,8 @@ Public Class Timbrado
|
|||||||
doc.ImpPagado,
|
doc.ImpPagado,
|
||||||
doc.ImpSaldoInsoluto,
|
doc.ImpSaldoInsoluto,
|
||||||
doc.ObjetoImpuesto)
|
doc.ObjetoImpuesto)
|
||||||
If doc.Impuestos IsNot Nothing Then
|
|
||||||
|
|
||||||
|
If doc.Impuestos IsNot Nothing Then
|
||||||
''retenciones
|
''retenciones
|
||||||
If (doc.Impuestos).Where(Function(x) x.TrasladooRetencion = "R").Count > 0 Then
|
If (doc.Impuestos).Where(Function(x) x.TrasladooRetencion = "R").Count > 0 Then
|
||||||
Dim j As Integer = 0
|
Dim j As Integer = 0
|
||||||
@@ -2744,7 +2741,6 @@ Public Class Timbrado
|
|||||||
j += 1
|
j += 1
|
||||||
Next
|
Next
|
||||||
End If
|
End If
|
||||||
|
|
||||||
''traslados
|
''traslados
|
||||||
If (doc.Impuestos).Where(Function(x) x.TrasladooRetencion = "T").Count > 0 Then
|
If (doc.Impuestos).Where(Function(x) x.TrasladooRetencion = "T").Count > 0 Then
|
||||||
Dim j As Integer = 0
|
Dim j As Integer = 0
|
||||||
@@ -2756,7 +2752,6 @@ Public Class Timbrado
|
|||||||
Next
|
Next
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Next
|
Next
|
||||||
|
|
||||||
If (docp.Retenciones).Count > 0 Then
|
If (docp.Retenciones).Count > 0 Then
|
||||||
@@ -2974,8 +2969,6 @@ Public Class Timbrado
|
|||||||
Alert($"Error al leer la llave privada: {ex.Message}", TipoMensaje.MsgError)
|
Alert($"Error al leer la llave privada: {ex.Message}", TipoMensaje.MsgError)
|
||||||
Return "Error al leer la llave privada"
|
Return "Error al leer la llave privada"
|
||||||
End Try
|
End Try
|
||||||
|
|
||||||
|
|
||||||
Try
|
Try
|
||||||
certByte = System.IO.File.ReadAllBytes(ArchivoCertificado)
|
certByte = System.IO.File.ReadAllBytes(ArchivoCertificado)
|
||||||
certBase64 = Convert.ToBase64String(certByte)
|
certBase64 = Convert.ToBase64String(certByte)
|
||||||
@@ -2986,13 +2979,11 @@ Public Class Timbrado
|
|||||||
End Try
|
End Try
|
||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
|
|
||||||
sw.Stop()
|
sw.Stop()
|
||||||
swTiempo.AppendFormat("Verificado : ({0}) {1} ", sw.ElapsedMilliseconds - swmili, sw.ElapsedMilliseconds)
|
swTiempo.AppendFormat("Verificado : ({0}) {1} ", sw.ElapsedMilliseconds - swmili, sw.ElapsedMilliseconds)
|
||||||
swmili = sw.ElapsedMilliseconds
|
swmili = sw.ElapsedMilliseconds
|
||||||
sw.Start()
|
sw.Start()
|
||||||
|
|
||||||
|
|
||||||
Dim RespGeneracionXML As String = GenerarXMLGoCFDIv40(cfdi, EmisorRFC, ArchivoCertificado, llaveBase64, Clave, Ventas, UsuarioActual, CvePACEspecial)
|
Dim RespGeneracionXML As String = GenerarXMLGoCFDIv40(cfdi, EmisorRFC, ArchivoCertificado, llaveBase64, Clave, Ventas, UsuarioActual, CvePACEspecial)
|
||||||
|
|
||||||
sw.Stop()
|
sw.Stop()
|
||||||
@@ -3012,7 +3003,6 @@ Public Class Timbrado
|
|||||||
'Verifica el error
|
'Verifica el error
|
||||||
If cfdi.Mensaje = "" Then
|
If cfdi.Mensaje = "" Then
|
||||||
Dim SelloCfdi As String
|
Dim SelloCfdi As String
|
||||||
|
|
||||||
UUID = cfdi.CfdiInfo.UUID
|
UUID = cfdi.CfdiInfo.UUID
|
||||||
SelloCfdi = cfdi.CfdiInfo.SelloCfdi
|
SelloCfdi = cfdi.CfdiInfo.SelloCfdi
|
||||||
|
|
||||||
|
|||||||
BIN
Bin/GoCfdi.dll
BIN
Bin/GoCfdi.dll
Binary file not shown.
Reference in New Issue
Block a user