--mejoras en descarga de pdf, cambios en factura USA

This commit is contained in:
2024-01-16 00:52:30 -07:00
parent 34fdb56260
commit 20d17f6a2a
2 changed files with 79 additions and 0 deletions

View File

@@ -7197,6 +7197,46 @@ Public Class ClsPaginas
GuardaLog("No se especifico el tipo de Impresion de venta (Venta, Remision, Cotización, Nota de Crédito).")
Return Nothing
End If
If NombreArchivo = "FacturaUSA" Then
Dim DtBaseTotales = Vta.DtDeduccion.Clone()
If Vta.DtDeduccion IsNot Nothing Then
Dim RowTotal_USA = DtBaseTotales.NewRow()
Dim RowPAYMENTS_USA = DtBaseTotales.NewRow()
Dim RowBALANCE_USA = DtBaseTotales.NewRow()
Dim TOTAL_USA As Decimal = 0
Dim PAYMENTS_USA As Decimal = 0
Dim BALANCE_USA As Decimal = 0
For Each Row As DataRow In Vta.DtDeduccion.Rows
If Row("ImpuestoLocal").ToString() = "Total" Then
TOTAL_USA += Row("Importe").ToString().ToDecimal()
End If
Next
RowTotal_USA("ImpuestoLocal") = "TOTAL"
RowTotal_USA("Importe") = TOTAL_USA
RowTotal_USA("Orden") = 1
DtBaseTotales.Rows.Add(RowTotal_USA)
RowPAYMENTS_USA("ImpuestoLocal") = "PAYMENTS/CREDITS"
RowPAYMENTS_USA("Importe") = PAYMENTS_USA
RowPAYMENTS_USA("Orden") = 2
DtBaseTotales.Rows.Add(RowPAYMENTS_USA)
BALANCE_USA = TOTAL_USA - PAYMENTS_USA
RowBALANCE_USA("ImpuestoLocal") = "BALANCE DUE"
RowBALANCE_USA("Importe") = BALANCE_USA
RowBALANCE_USA("Orden") = 3
DtBaseTotales.Rows.Add(RowBALANCE_USA)
Vta.DtDeduccion = DtBaseTotales
End If
End If
'TERMINA REGION PARAMETROS
Dim lrds As New List(Of ReportDataSource)
'Si es ECLIPSE CREAR COLUMAS PARA FIRMAS EN DtDetalle.
@@ -7273,6 +7313,7 @@ Public Class ClsPaginas
If UsuarioActual.CveEmpresa.Contiene(141, 152, 159, 160, 161, 162, 163) AndAlso (RutaFormato.Contains("Factura") Or RutaFormato.Contains("Cotizacion")) Then
params.Add(New ReportParameter("Kilometraje", Vta.Kilometraje.ToString))
End If
'Imprime los parametros
'Dim ast As New StringBuilder
'For Each par As ReportParameter In params
@@ -7550,6 +7591,7 @@ Public Class ClsPaginas
End If
End If
ObjVentas.Dispose()
If Not IsNothing(Vta) Then
PdfFactura(Vta)
Vta = Nothing

View File

@@ -6,6 +6,7 @@ Imports System.IO
Imports Extensiones
Imports Microsoft.Reporting.WebForms
Imports Newtonsoft.Json
Imports System.Net.Http
Public Class SIGDesc : Implements IHttpHandler, IRequiresSessionState
@@ -35,11 +36,47 @@ Public Class SIGDesc : Implements IHttpHandler, IRequiresSessionState
context.Response.Flush()
context.Response.WriteFile(FileInfo.FullName)
context.Response.End()
Else
DescargarPDFVentaPeticion(context, ObjFactura)
End If
FileInfo = Nothing
End If
End Sub
Private Sub DescargarPDFVentaPeticion(ByVal context As HttpContext, ObjFactura As Modelos.Factura)
Dim usuario As Usuario = UsuarioActual(context)
If Not IsNothing(usuario) Then
Dim strURLHOST = String.Format("{0}://{1}:{2}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port)
Dim Url As New Uri(String.Format("{0}/Compras/PopUpVerFactura.aspx?P={1}", strURLHOST, Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1&REGENERAR={1}", ObjFactura.CveVenta, "1"))))
Dim File As Byte() = Nothing
Try
Using httpClient As New HttpClient()
httpClient.Timeout = New TimeSpan(0, 1, 0)
Using request As New HttpRequestMessage(HttpMethod.Get, Url)
request.Headers.Add("ADSToken", Encripta(String.Format("CVEEMPRESA={0}&TICKS={1}&CveUsuario={2}", ObjFactura.CveEmpresa, DateTime.UtcNow.Ticks, ObjFactura.CveUsuario)))
Dim response = httpClient.SendAsync(request).Result
If response.StatusCode = Net.HttpStatusCode.OK Then
File = response.Content.ReadAsByteArrayAsync().Result
End If
End Using
End Using
Catch ex As Exception
File = Nothing
OnError("Ocurrió un error al descargar la factura", ex)
End Try
context.Response.Buffer = True
context.Response.Clear()
context.Response.ContentType = "application/pdf"
context.Response.ClearHeaders()
context.Response.AddHeader("content-disposition", String.Format("{0}; filename=""{1}.{2}""", "attachment", ObjFactura.SerieFolio, "pdf"))
context.Response.BinaryWrite(File) ' create the file
context.Response.End()
End If
End Sub
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False