497 lines
26 KiB
Plaintext
497 lines
26 KiB
Plaintext
<%@ WebHandler Language="VB" Class="GenerarPDFFactura" %>
|
|
|
|
Imports System
|
|
Imports System.Web
|
|
Imports System.Data
|
|
Imports Newtonsoft.Json
|
|
Imports Newtonsoft.Json.Linq
|
|
Imports Extensiones
|
|
Imports System.IO
|
|
Imports Microsoft.Reporting.WebForms
|
|
|
|
Imports ADSistemaLibrary.SatXml
|
|
Imports ADSistemaLibrary.SatXml.XmlSatCFDI
|
|
|
|
Public Class GenerarPDFFactura : Implements IHttpHandler
|
|
|
|
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
|
|
Get
|
|
Return False
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property EsProduccion As Boolean
|
|
Get
|
|
If IsNothing(System.Configuration.ConfigurationManager.AppSettings("EsProduccion")) Then
|
|
Return False
|
|
Else
|
|
Return (System.Configuration.ConfigurationManager.AppSettings("EsProduccion").ToString() = "1")
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
|
|
Dim retorno As String = "no se encontro la variable"
|
|
|
|
Try
|
|
Dim datos As ParametroWS = Nothing
|
|
If context.Request.Headers("Content-Type") IsNot Nothing AndAlso context.Request.Headers("Content-Type").Contains("json") AndAlso context.Request.InputStream IsNot Nothing Then
|
|
context.Response.ContentType = "application/json"
|
|
Using reader As New StreamReader(context.Request.InputStream)
|
|
Dim json = reader.ReadToEnd()
|
|
datos = JsonConvert.DeserializeObject(Of ParametroWS)(json)
|
|
End Using
|
|
End If
|
|
|
|
If datos IsNot Nothing Then
|
|
Dim ListaDS = New List(Of ReportDataSource)
|
|
Dim Parametros As New List(Of ReportParameter)
|
|
|
|
Dim Formato As String = ""
|
|
|
|
Dim Xml = New System.Xml.XmlDocument()
|
|
Xml.LoadXml(datos.XML)
|
|
Dim ArchivoXML = $"{context.Server.MapPath("/")}/Temp/{DateTime.UtcNow.Ticks}_{datos.Factura.Serie}-{datos.Factura.Folio}.xml"
|
|
Xml.Save(ArchivoXML)
|
|
|
|
ImprimirbytesPDF(context, GenerarCFDi(context, ArchivoXML, datos), "Factura")
|
|
|
|
'If datos.API_SALI Then
|
|
' Dim Xml = New System.Xml.XmlDocument()
|
|
' Xml.LoadXml(datos.XML)
|
|
' Dim ArchivoXML = $"{context.Server.MapPath("/")}/Temp/{DateTime.UtcNow.Ticks}_{datos.Factura.Serie}-{datos.Factura.Folio}.xml"
|
|
' Xml.Save(ArchivoXML)
|
|
|
|
' ImprimirbytesPDF(context, GenerarCFDi(context, ArchivoXML, datos), "Factura")
|
|
'Else
|
|
' Formato = ModExtensiones.DirectorioBaseEmpresas + "Empresas/Grales/ReporteAPI.rdlc"
|
|
|
|
' Parametros.Add(New ReportParameter("Empresa", datos.Empresa.Empresa))
|
|
' Parametros.Add(New ReportParameter("RFC", datos.Empresa.RFC))
|
|
' Parametros.Add(New ReportParameter("DomicilioExpedicion", datos.Empresa.DomicilioFiscal))
|
|
' Parametros.Add(New ReportParameter("Serie", datos.Factura.Serie))
|
|
' Parametros.Add(New ReportParameter("Folio", datos.Factura.Folio))
|
|
' Parametros.Add(New ReportParameter("Fecha", datos.Factura.Fecha))
|
|
' Parametros.Add(New ReportParameter("ClienteNombre", datos.Cliente.NombreComercial))
|
|
' Parametros.Add(New ReportParameter("ClienteDireccion", datos.Cliente.Calle + " Colonia " + datos.Cliente.Colonia + " " + datos.Cliente.Ciudad + ", " + datos.Cliente.Estado))
|
|
' Parametros.Add(New ReportParameter("ClienteLugar", datos.Cliente.Ciudad))
|
|
' Parametros.Add(New ReportParameter("ClienteRFC", datos.Cliente.RFC))
|
|
' Parametros.Add(New ReportParameter("ImporteLetra", datos.Factura.Total.Texto2Letras()))
|
|
' Parametros.Add(New ReportParameter("FormaPago", datos.Factura.FormaPago))
|
|
' Parametros.Add(New ReportParameter("MetodoPago", datos.Factura.MetodoPago))
|
|
' Parametros.Add(New ReportParameter("SelloCFDI", datos.Timbrado.SelloCFDI))
|
|
' Parametros.Add(New ReportParameter("SelloSAT", datos.Timbrado.SelloSAT))
|
|
' Parametros.Add(New ReportParameter("CadenaOriginal", datos.Timbrado.CadenaOriginal))
|
|
' Parametros.Add(New ReportParameter("FolioFiscal", datos.Factura.UUID))
|
|
' Parametros.Add(New ReportParameter("SerieCertificadoSAT", datos.Timbrado.SerieCertificadoSAT))
|
|
' Parametros.Add(New ReportParameter("FechaCertificado", datos.Timbrado.FechaCertificado))
|
|
' Parametros.Add(New ReportParameter("CertificadoContribuyente", datos.Timbrado.CertificadoContribuyente))
|
|
' Parametros.Add(New ReportParameter("UsoCFDI", datos.Factura.UsoCFDI))
|
|
' Parametros.Add(New ReportParameter("Vencimiento", datos.Factura.FechaVencimiento))
|
|
' Parametros.Add(New ReportParameter("SubTotal", datos.Factura.SubTotal))
|
|
' Parametros.Add(New ReportParameter("Descuentos", datos.Factura.Descuentos))
|
|
' Parametros.Add(New ReportParameter("IVA", datos.Factura.IVA))
|
|
' Parametros.Add(New ReportParameter("IEPS", datos.Factura.IEPS))
|
|
' Parametros.Add(New ReportParameter("Total", datos.Factura.Total))
|
|
' Parametros.Add(New ReportParameter("QR", datos.Timbrado.QR))
|
|
|
|
' Dim DtDatos As New DataTable
|
|
' DtDatos.Columns.Add(New DataColumn("Cantidad", GetType(Decimal)))
|
|
' DtDatos.Columns.Add(New DataColumn("UnidadMedida", GetType(String)))
|
|
' DtDatos.Columns.Add(New DataColumn("PS", GetType(String)))
|
|
' DtDatos.Columns.Add(New DataColumn("PU", GetType(Decimal)))
|
|
' DtDatos.Columns.Add(New DataColumn("IVA", GetType(Decimal)))
|
|
' DtDatos.Columns.Add(New DataColumn("IEPS", GetType(Decimal)))
|
|
' DtDatos.Columns.Add(New DataColumn("Descuento", GetType(Decimal)))
|
|
' DtDatos.Columns.Add(New DataColumn("Total", GetType(Decimal)))
|
|
|
|
' Dim DtImpuestos As New DataTable
|
|
' DtImpuestos.Columns.Add(New DataColumn("Impuesto", GetType(String)))
|
|
' DtImpuestos.Columns.Add(New DataColumn("Tipo", GetType(String)))
|
|
' DtImpuestos.Columns.Add(New DataColumn("Base", GetType(Decimal)))
|
|
' DtImpuestos.Columns.Add(New DataColumn("TipoFactor", GetType(String)))
|
|
' DtImpuestos.Columns.Add(New DataColumn("TasaOCuota", GetType(String)))
|
|
' DtImpuestos.Columns.Add(New DataColumn("Importe", GetType(Decimal)))
|
|
|
|
' For Each PS In datos.Factura.ListaProductos
|
|
' Dim Row = DtDatos.NewRow()
|
|
' Row("Cantidad") = PS.Cantidad
|
|
' Row("UnidadMedida") = PS.UnidadMedida
|
|
' Row("PS") = PS.CodigoPS
|
|
' Row("PU") = PS.PU
|
|
' Row("IVA") = PS.IVA
|
|
' Row("IEPS") = PS.IEPS
|
|
' Row("Descuento") = PS.Descuento
|
|
' Row("Total") = (PS.Cantidad * PS.PU) + PS.IVA + PS.IEPS
|
|
|
|
' DtDatos.Rows.Add(Row)
|
|
' Next
|
|
|
|
' Dim RowImpuesto = DtImpuestos.NewRow()
|
|
' RowImpuesto("Impuesto") = "IVA"
|
|
' RowImpuesto("Tipo") = "Traslado"
|
|
' RowImpuesto("Base") = datos.Factura.SubTotal
|
|
' RowImpuesto("TipoFactor") = "Tasa"
|
|
' RowImpuesto("TasaOCuota") = "16%"
|
|
' RowImpuesto("Importe") = datos.Factura.IVA
|
|
|
|
' DtImpuestos.Rows.Add(RowImpuesto)
|
|
|
|
' ListaDS.Add(New ReportDataSource("DsProductos", DtDatos))
|
|
' ListaDS.Add(New ReportDataSource("DsImpuestos", DtImpuestos))
|
|
|
|
' ImprimirbytesPDF(context, StreamPDF(context, Formato, ListaDS, Parametros), "Factura")
|
|
'End If
|
|
Else
|
|
retorno = "no hay datossss"
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
retorno = ex.ToString()
|
|
ex.GuardaLog(ex.ToString())
|
|
context.Response.Write(retorno)
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
Private Function GenerarCFDi(ByVal context As HttpContext, RutaXml As String, datos As ParametroWS) As Byte()
|
|
Dim bytes As Byte() = Nothing
|
|
|
|
Dim objxml As XmlSatCFDI = XmlSatCFDI.readXML(RutaXml)
|
|
|
|
Dim rutaReporte As String = "Empresas\Grales\Formatos\FacturaSALI.rdlc"
|
|
|
|
' Dim QR As Byte() 'ClbNegBICFDv3_2.ClsNegCBBGenerar = New ClbNegBICFDv3_2.ClsNegCBBGenerar()
|
|
Dim cQr As Byte() = Nothing ' = QR.GenerarCBBBytes(objxml.emisor.Rfc, objxml.receptor.Rfc, objxml.comprobante.Total, objxml.complemento.UUID)
|
|
Dim parametros As List(Of ReportParameter) = New List(Of ReportParameter)()
|
|
parametros.Add(New ReportParameter("comprobante_Certificado", objxml.comprobante.Certificado))
|
|
parametros.Add(New ReportParameter("comprobante_CondicionesDePago", objxml.comprobante.CondicionesDePago))
|
|
parametros.Add(New ReportParameter("comprobante_Confirmacion", objxml.comprobante.Confirmacion))
|
|
parametros.Add(New ReportParameter("comprobante_Fecha", objxml.comprobante.Fecha))
|
|
parametros.Add(New ReportParameter("comprobante_Serie", objxml.comprobante.Serie))
|
|
parametros.Add(New ReportParameter("comprobante_Folio", objxml.comprobante.Folio))
|
|
parametros.Add(New ReportParameter("comprobante_Descuento", objxml.comprobante.Descuento.ToString("N2")))
|
|
parametros.Add(New ReportParameter("comprobante_SubTotal", objxml.comprobante.SubTotal.ToString("N2")))
|
|
parametros.Add(New ReportParameter("comprobante_Total", objxml.comprobante.Total.ToString("N2")))
|
|
parametros.Add(New ReportParameter("comprobante_Version", objxml.comprobante.Version))
|
|
parametros.Add(New ReportParameter("comprobante_TipoDeComprobante", objxml.comprobante.TipoDeComprobanteTexto))
|
|
parametros.Add(New ReportParameter("comprobante_FormaPago", objxml.comprobante.FormaPagoTexto))
|
|
parametros.Add(New ReportParameter("comprobante_LugarExpedicion", objxml.comprobante.LugarExpedicion))
|
|
parametros.Add(New ReportParameter("comprobante_NoCertificado", objxml.comprobante.NoCertificado))
|
|
parametros.Add(New ReportParameter("comprobante_Sello", objxml.comprobante.Sello))
|
|
parametros.Add(New ReportParameter("comprobante_Moneda", objxml.comprobante.Moneda))
|
|
parametros.Add(New ReportParameter("comprobante_TipoCambio", objxml.comprobante.TipoCambio.ToString("N2")))
|
|
parametros.Add(New ReportParameter("comprobante_MetodoPago", objxml.comprobante.MetodoPagoTexto))
|
|
parametros.Add(New ReportParameter("emisor_Rfc", objxml.emisor.Rfc))
|
|
parametros.Add(New ReportParameter("emisor_Nombre", objxml.emisor.Nombre))
|
|
parametros.Add(New ReportParameter("emisor_RegimenFiscal", objxml.emisor.RegimenFiscalTexto))
|
|
parametros.Add(New ReportParameter("emisor_Direccion", datos.Empresa.DomicilioFiscal))
|
|
parametros.Add(New ReportParameter("receptor_Rfc", objxml.receptor.Rfc))
|
|
parametros.Add(New ReportParameter("receptor_Nombre", objxml.receptor.Nombre))
|
|
parametros.Add(New ReportParameter("receptor_NumRegIdTrib", objxml.receptor.NumRegIdTrib))
|
|
parametros.Add(New ReportParameter("receptor_ResidenciaFiscal", objxml.receptor.ResidenciaFiscal))
|
|
parametros.Add(New ReportParameter("receptor_UsoCFDI", objxml.receptor.UsoCFDITexto))
|
|
parametros.Add(New ReportParameter("complemento_FechaTimbrado", objxml.complemento.FechaTimbrado))
|
|
parametros.Add(New ReportParameter("complemento_NoCertificadoSAT", objxml.complemento.NoCertificadoSAT))
|
|
parametros.Add(New ReportParameter("complemento_RfcProvCertif", objxml.complemento.RfcProvCertif))
|
|
parametros.Add(New ReportParameter("complemento_SelloCFD", objxml.complemento.SelloCFD))
|
|
parametros.Add(New ReportParameter("complemento_SelloSAT", objxml.complemento.SelloSAT))
|
|
parametros.Add(New ReportParameter("complemento_UUID", objxml.complemento.UUID))
|
|
parametros.Add(New ReportParameter("complemento_CadenaOriginal", objxml.complemento.CadenaOriginal))
|
|
parametros.Add(New ReportParameter("Observaciones", datos.Factura.Observaciones))
|
|
|
|
If datos.CFDIVersion = "4.0" Then
|
|
rutaReporte = "Empresas\Grales\Formatos\FacturaSALI40.rdlc"
|
|
parametros.Add(New ReportParameter("receptor_RegimenFiscal", objxml.receptor.RegimenFiscalReceptorTexto))
|
|
End If
|
|
|
|
Dim ds As New List(Of ReportDataSource)
|
|
|
|
Dim rdsTotales As ReportDataSource = New ReportDataSource()
|
|
Dim ltotales As List(Of utilValores) = New List(Of utilValores)()
|
|
ltotales.Add(New utilValores("Subtotal", objxml.comprobante.SubTotal.ToString("N2")))
|
|
|
|
If objxml.comprobante.Descuento > 0 Then
|
|
ltotales.Add(New utilValores("Descuento", objxml.comprobante.Descuento.ToString("N2")))
|
|
End If
|
|
|
|
For Each item As CFDIImpuesto In objxml.Impuestos
|
|
|
|
If item.Importe > 0 Then
|
|
Dim TasaOCuota As Decimal = 0
|
|
Decimal.TryParse(item.TasaOCuota, TasaOCuota)
|
|
ltotales.Add(New utilValores($"Impuestos {item.Tipo} {item.ImpuestoTexto} {(If(item.TipoFactor = "Tasa", (TasaOCuota * 100).ToString("N4"), item.TasaOCuota))} {(If(item.TipoFactor = "Tasa", "%", ""))}", item.Importe.ToString("N2")))
|
|
End If
|
|
Next
|
|
|
|
ltotales.Add(New utilValores("Total", objxml.comprobante.Total.ToString("N2")))
|
|
rdsTotales.Name = "dsTotales"
|
|
rdsTotales.Value = ltotales.QueryToDataTable(True)
|
|
ds.Add(rdsTotales)
|
|
|
|
Dim rds2 As ReportDataSource = New ReportDataSource()
|
|
Dim limagenes As List(Of utilImage) = New List(Of utilImage)()
|
|
limagenes.Add(New utilImage(cQr))
|
|
rds2.Name = "dsImagenes"
|
|
rds2.Value = limagenes.QueryToDataTable(True)
|
|
ds.Add(rds2)
|
|
|
|
Dim rdsrelacionados As ReportDataSource = New ReportDataSource()
|
|
rdsrelacionados.Name = "dsRelacionados"
|
|
rdsrelacionados.Value = objxml.cFDIRelacionados.QueryToDataTable(True)
|
|
ds.Add(rdsrelacionados)
|
|
|
|
Dim rds1 As ReportDataSource = New ReportDataSource()
|
|
rds1.Name = "dsConceptos"
|
|
rds1.Value = objxml.GetConceptosforpdf().QueryToDataTable(True)
|
|
|
|
ds.Add(rds1)
|
|
|
|
bytes = StreamPDF(context, rutaReporte, ds, parametros)
|
|
|
|
System.IO.File.Delete(RutaXml)
|
|
|
|
Return bytes
|
|
|
|
End Function
|
|
|
|
Public Function StreamPDF(ByVal context As HttpContext, RutaReporte As String, DataSource As List(Of ReportDataSource), Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional MR As ReportViewer = Nothing) As Byte()
|
|
'limpio ReportViwer
|
|
Dim sw As New System.Diagnostics.Stopwatch()
|
|
sw.Start()
|
|
Dim Bytes As Byte() = Nothing
|
|
|
|
Dim bdir As String = If(RutaReporte.Contains("Empresas"), ModExtensiones.DirectorioBaseEmpresas, AppDomain.CurrentDomain.BaseDirectory)
|
|
RutaReporte.Replace("/", "\")
|
|
If Not RutaReporte.ToUpper().StartsWith(bdir.ToUpper()) Then
|
|
RutaReporte = String.Format("{0}{1}", bdir, RutaReporte)
|
|
End If
|
|
|
|
If EsProduccion Then
|
|
|
|
Dim CveUsuario As Integer = 100
|
|
Dim CveEmpresa As Integer = 1
|
|
|
|
Dim wsreport As New WSRDLC.WebServiceSoapClient
|
|
Dim params As New List(Of WSRDLC.ReportParameter)
|
|
Dim ds As New DataSet
|
|
For Each rpds As ReportDataSource In DataSource
|
|
Dim dt As DataTable = DirectCast(rpds.Value, Data.DataTable)
|
|
If dt Is Nothing Then
|
|
dt = New DataTable()
|
|
Else
|
|
dt = dt.Copy()
|
|
End If
|
|
dt.TableName = rpds.Name
|
|
ds.Tables.Add(dt)
|
|
Next
|
|
|
|
For Each rpds As ReportParameter In Parametros
|
|
Dim param As New WSRDLC.ReportParameter
|
|
param.Name = rpds.Name
|
|
param.Values = {rpds.Values(0)}
|
|
params.Add(param)
|
|
Next
|
|
|
|
Bytes = wsreport.StreamPDFBytes(RutaReporte, ds, params.ToArray(), NombreArchivo, Formato, CveEmpresa, CveUsuario)
|
|
wsreport = Nothing
|
|
params = Nothing
|
|
|
|
Else
|
|
If IsNothing(MR) Then MR = New ReportViewer
|
|
Try
|
|
' MasterReporteador.LocalReport.DataSources.Clear()
|
|
For Each RDS As ReportDataSource In DataSource
|
|
MR.LocalReport.DataSources.Add(RDS)
|
|
Next
|
|
|
|
MR.LocalReport.ReportPath = RutaReporte
|
|
MR.ProcessingMode = ProcessingMode.Local
|
|
MR.LocalReport.EnableExternalImages = True
|
|
MR.LocalReport.SetParameters(Parametros)
|
|
MR.LocalReport.Refresh()
|
|
Dim Warnings As Warning() = Nothing
|
|
Dim StreamIds As String() = Nothing
|
|
Dim MimeType As String = Nothing
|
|
Dim Encoding As String = Nothing
|
|
Dim Extension As String = Nothing
|
|
Bytes = MR.LocalReport.Render(Formato, Nothing, MimeType, Encoding, Extension, StreamIds, Warnings)
|
|
Catch ex As Microsoft.Reporting.WebForms.ScriptManagerNotFoundException
|
|
GuardaLog($"Error: { If(ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, ex.Message) } | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} - Ruta {RutaReporte}")
|
|
'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017
|
|
'GuardaLog($"Error: {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}")
|
|
Catch ex As Exception
|
|
GuardaLog($"Error: { If(ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, ex.Message) } | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} - Ruta {RutaReporte}")
|
|
'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017
|
|
'GuardaLog($"Error {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}")
|
|
End Try
|
|
MR.Dispose()
|
|
|
|
End If
|
|
sw.Stop()
|
|
|
|
If sw.Elapsed.TotalSeconds > 5 Then
|
|
GuardaLog($"Reporte:{RutaReporte} | Tiempo Renderizado Milisegundos: {sw.ElapsedMilliseconds},Total Segundos: {sw.Elapsed.TotalSeconds} ")
|
|
End If
|
|
|
|
Return Bytes
|
|
End Function
|
|
|
|
|
|
|
|
Public Sub ImprimirbytesPDF(ByVal context As HttpContext, bytes As Byte(), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional Descarga As Boolean = False)
|
|
'limpio ReportViwer
|
|
Dim mimeType As String = Nothing
|
|
Dim extension As String = Nothing
|
|
|
|
'If Descarga Then
|
|
' Try
|
|
' bytes = bytes
|
|
' File.WriteAllBytes(String.Format("{0}PDF/whatever.gif", UsuarioActual.Empresa.Ruta), img)
|
|
' Catch ex As Exception
|
|
' If UsuarioActual.CveRol = 1 Then
|
|
' Alert(ex.Message, TipoMensaje.MsgAdvertencia)
|
|
' Else
|
|
' Alert("Ocurrió un error al generar la descarga. Favor de contactar a soporte tecnico cod'IMPDFclspag'", TipoMensaje.MsgAdvertencia)
|
|
' End If
|
|
' End Try
|
|
'End If
|
|
|
|
Try
|
|
|
|
bytes = bytes
|
|
context.Response.Buffer = True
|
|
context.Response.Clear()
|
|
context.Response.ContentType = mimeType
|
|
context.Response.AddHeader("content-disposition", String.Format("attachment; filename={0}.{1}", NombreArchivo, If(Formato = "PDF", "pdf", "xls")))
|
|
context.Response.BinaryWrite(bytes) ' create the file
|
|
context.Response.Flush() ' send it to the client to download
|
|
context.Response.SuppressContent = True
|
|
context.ApplicationInstance.CompleteRequest()
|
|
context.Response.End()
|
|
|
|
Catch ex As Exception
|
|
End Try
|
|
End Sub
|
|
|
|
|
|
Public Class FacturaWS
|
|
Public Property Id As Integer
|
|
Public Property CveVenta As Integer
|
|
Public Property CveCliente As Integer
|
|
Public Property NombreCliente As String
|
|
Public Property Fecha As DateTime
|
|
Public Property FechaVencimiento As DateTime
|
|
Public Property CveSubCentroCosto As Integer
|
|
Public Property CveTipoDocumento As Integer
|
|
Public Property TipoDocumento As String
|
|
Public Property Serie As String
|
|
Public Property Folio As Integer
|
|
Public Property CveVendedor As Integer
|
|
Public Property CveUsuario As Integer
|
|
Public Property CveEstatusVenta As Integer
|
|
Public Property EstatusVenta As String
|
|
Public Property UUID As String
|
|
Public Property ListaProductos As List(Of ProductoWS)
|
|
Public Property CveUsoCFDI As Integer
|
|
Public Property UsoCFDI As String
|
|
Public Property CveMetodoPago As Integer
|
|
Public Property MetodoPago As String
|
|
Public Property ClaveMetodoPagoSAT As String
|
|
Public Property CveFormaPago As Integer
|
|
Public Property FormaPago As String
|
|
Public Property ClaveFormaPagoSAT As String
|
|
Public Property Observaciones As String
|
|
Public Property CveMoneda As Integer
|
|
Public Property TipoCambio As Double
|
|
Public Property FechaIng As DateTime
|
|
Public Property CveEmpresa As Integer
|
|
Public Property SubTotal As Double
|
|
Public Property Descuentos As Double
|
|
Public Property IVA As Double
|
|
Public Property IEPS As Double
|
|
Public Property Total As Double
|
|
End Class
|
|
|
|
Public Class ProductoWS
|
|
Public Property Id As Integer
|
|
Public Property CveVentaDetalle As Integer
|
|
Public Property CveVenta As Integer
|
|
Public Property CveProductoServicio As Integer
|
|
Public Property CodigoPS As String
|
|
Public Property CveUnidadMedida As Integer
|
|
Public Property UnidadMedida As String
|
|
Public Property Cantidad As Double
|
|
Public Property Observacion As String
|
|
Public Property PU As Double
|
|
Public Property Descuento As Double
|
|
Public Property IVA As Double
|
|
Public Property IEPS As Double
|
|
Public Property IVAPorcentaje As Double
|
|
Public Property IEPSPorcentaje As Double
|
|
Public Property CveSubCentroCosto As Integer
|
|
Public Property SubCentroCosto As String
|
|
End Class
|
|
|
|
Public Class ClienteWS
|
|
Public Property Id As Integer
|
|
Public Property CveCliente As Integer
|
|
Public Property RazonSocial As String
|
|
Public Property NombreComercial As String
|
|
Public Property RFC As String
|
|
Public Property Codigo As String
|
|
Public Property Calle As String
|
|
Public Property NoExterior As String
|
|
Public Property Colonia As String
|
|
Public Property Ciudad As String
|
|
Public Property Municipio As String
|
|
Public Property Estado As String
|
|
Public Property CodigoPostal As Integer
|
|
Public Property Contacto As String
|
|
Public Property ContactoTelefono As String
|
|
Public Property Correo As String
|
|
Public Property CveVendedor As Integer
|
|
Public Property Estatus As Boolean
|
|
Public Property CveUsuario As Integer
|
|
Public Property CveEmpresa As Integer
|
|
Public Property CveRegimenFiscal As Integer
|
|
Public Property RegimenFiscal As String
|
|
Public Property CodigoRegimenFiscal As String
|
|
End Class
|
|
|
|
Public Class EmpresaWS
|
|
Public Property Id As Integer
|
|
Public Property CveEmpresa As Integer
|
|
Public Property Empresa As String
|
|
Public Property RFC As String
|
|
Public Property DomicilioFiscal As String
|
|
Public Property ArchivoCER As String
|
|
Public Property ArchivoKEY As String
|
|
Public Property FieldPassword As String
|
|
Public Property CveRegimenFiscal As Integer
|
|
Public Property RegimenFiscal As String
|
|
End Class
|
|
|
|
Public Class DatosSATWS
|
|
Public Property SelloCFDI As String
|
|
Public Property SelloSAT As String
|
|
Public Property CadenaOriginal As String
|
|
Public Property SerieCertificadoSAT As String
|
|
Public Property FechaCertificado As String
|
|
Public Property CertificadoContribuyente As String
|
|
Public Property QR As String
|
|
End Class
|
|
|
|
Public Class ParametroWS
|
|
Public Property CFDIVersion As String
|
|
Public Property Factura As FacturaWS
|
|
Public Property Cliente As ClienteWS
|
|
Public Property Empresa As EmpresaWS
|
|
Public Property API_SALI As Boolean
|
|
Public Property Timbrado As DatosSATWS
|
|
|
|
Public Property XML As String
|
|
End Class
|
|
|
|
|
|
End Class |