From b58c59cfceb7e518b36b335f901425a475a26486 Mon Sep 17 00:00:00 2001 From: rrene Date: Fri, 12 Jan 2024 10:43:36 -0700 Subject: [PATCH 01/19] - longitud nombre proc --- Ventas/CatProcedimientoDetalle.aspx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ventas/CatProcedimientoDetalle.aspx b/Ventas/CatProcedimientoDetalle.aspx index e4b0e05dd..c1fa7608c 100644 --- a/Ventas/CatProcedimientoDetalle.aspx +++ b/Ventas/CatProcedimientoDetalle.aspx @@ -54,7 +54,7 @@
- + From 572b81e1f71add4fde58d21ce2428134fdf7c4a1 Mon Sep 17 00:00:00 2001 From: JORGE LUIS CAUDILLO ESPARZA Date: Fri, 12 Jan 2024 10:55:31 -0700 Subject: [PATCH 02/19] modificar salario imss --- RH/Personal.aspx | 9 +++------ RH/Personal.aspx.vb | 22 ++++++++++++---------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/RH/Personal.aspx b/RH/Personal.aspx index 7b6ff7988..3c9d224d2 100644 --- a/RH/Personal.aspx +++ b/RH/Personal.aspx @@ -5732,7 +5732,7 @@
- + Fecha: @@ -5751,19 +5751,16 @@
- + Salario diario(IMSS):
diff --git a/RH/Personal.aspx.vb b/RH/Personal.aspx.vb index 82e464beb..a339f499b 100644 --- a/RH/Personal.aspx.vb +++ b/RH/Personal.aspx.vb @@ -1142,11 +1142,11 @@ Partial Class RH_Personal tdCliente2.Visible = True GVAsistencia.Columns(1).Visible = True End If - - If UsuarioActual.TienePermisoProceso(372) Then - TxtSalarioDiarioImSS.Enabled = True - TxtSalarioDiarioIntegrado.Enabled = True - End If + 'no sedeben habilitar ya que solo son informativos + 'If UsuarioActual.TienePermisoProceso(372) Then + ' TxtSalarioDiarioImSS.Enabled = True + ' TxtSalarioDiarioIntegrado.Enabled = True + 'End If End Sub Private Sub SetPermisos() @@ -6961,7 +6961,7 @@ Partial Class RH_Personal Dim DiasVacaciones As Decimal = TxtFIDiasVacaciones.Text.ToDecimal() Dim diasaguinaldo As Decimal = TxtFIAguinaldo.Text.ToDecimal() Dim FI As Decimal = (365D + diasaguinaldo + (DiasVacaciones * (primav / 100D))) / 365D - Dim SDI As Decimal = (SD * FI) + Dim SDI As Decimal = Math.Round((SD * FI), 2) TxtFactordeIntegracion.Text = FI.ToString() TxtFISalarioDiarioIntegrado.Text = String.Format("{0:###0.########}", SDI) UpFactordeintegracion.Update() @@ -7044,15 +7044,17 @@ Partial Class RH_Personal Using ObjPersonal As ClsRH = New ClsRH() ObjPersonal.IniciaTransacSQL() - If ObjPersonal.UpdateSalarios(CvePersonal, TxtFechamodIMSS.Text.ToDate().ToString("yyyy/MM/dd"), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, + If ObjPersonal.UpdateSalarios(CvePersonal, TxtFechamodIMSSSalario.Text.ToDate().ToString("yyyy/MM/dd"), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, TxtSalarioDiario.Text.ToDecimal(), TxtSDI.Text.ToDecimal(), TxtMImssSalarioDiarioImSS.Text.ToDecimal(), - TxtSalarioDiario.Text.ToDecimal()) Then + -1) Then ObjPersonal.Commit() TxtSalarioCotizado.Text = TxtMImssSalarioDiarioImSS.Text - + Dim sdi As Decimal = TxtSDI.Text.ToDecimal() + Dim sbc As Decimal = TxtMImssSalarioDiarioImSS.Text.ToDecimal() + salarioVariable = If(sbc > sdi, sbc - sdi, 0) UpModSalario.Update() UpDatos.Update() Alert("Se ha actualizado el salario", TipoMensaje.ToastInformacion) @@ -7063,7 +7065,7 @@ Partial Class RH_Personal End Sub Protected Sub LnkModsalarioIMSS_Click(sender As Object, e As EventArgs) - + TxtFechamodIMSSSalario.Text = NowADS().ToString("dd/MM/yyyy") TxtMImssSalarioDiarioImSS.Text = TxtSalarioCotizado.Text RegistraScript("$('#DmodamodificarsalarioIMSS').modal()") UpModSalarioIMSS.Update() From f4ca50d8c084d0b05d8656ff116682a9df068141 Mon Sep 17 00:00:00 2001 From: JORGE LUIS CAUDILLO ESPARZA Date: Fri, 12 Jan 2024 13:23:52 -0700 Subject: [PATCH 03/19] edicion SDIManual --- RH/Personal.aspx | 4 ++++ RH/Personal.aspx.vb | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/RH/Personal.aspx b/RH/Personal.aspx index 3c9d224d2..bdfafa4e1 100644 --- a/RH/Personal.aspx +++ b/RH/Personal.aspx @@ -5754,6 +5754,10 @@ Salario diario(IMSS):
+
+ + Salario Diario Integrado(SDI): +
diff --git a/RH/Personal.aspx.vb b/RH/Personal.aspx.vb index a339f499b..20952eeca 100644 --- a/RH/Personal.aspx.vb +++ b/RH/Personal.aspx.vb @@ -7045,13 +7045,14 @@ Partial Class RH_Personal Using ObjPersonal As ClsRH = New ClsRH() ObjPersonal.IniciaTransacSQL() If ObjPersonal.UpdateSalarios(CvePersonal, TxtFechamodIMSSSalario.Text.ToDate().ToString("yyyy/MM/dd"), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, - TxtSalarioDiario.Text.ToDecimal(), TxtSDI.Text.ToDecimal(), TxtMImssSalarioDiarioImSS.Text.ToDecimal(), + TxtSalarioDiario.Text.ToDecimal(), TxtMImssSDI.Text.ToDecimal(), TxtMImssSalarioDiarioImSS.Text.ToDecimal(), -1) Then ObjPersonal.Commit() TxtSalarioCotizado.Text = TxtMImssSalarioDiarioImSS.Text + TxtSDI.Text = TxtMImssSDI.Text Dim sdi As Decimal = TxtSDI.Text.ToDecimal() Dim sbc As Decimal = TxtMImssSalarioDiarioImSS.Text.ToDecimal() salarioVariable = If(sbc > sdi, sbc - sdi, 0) @@ -7067,6 +7068,7 @@ Partial Class RH_Personal Protected Sub LnkModsalarioIMSS_Click(sender As Object, e As EventArgs) TxtFechamodIMSSSalario.Text = NowADS().ToString("dd/MM/yyyy") TxtMImssSalarioDiarioImSS.Text = TxtSalarioCotizado.Text + TxtMImssSDI.Text = TxtSDI.Text RegistraScript("$('#DmodamodificarsalarioIMSS').modal()") UpModSalarioIMSS.Update() End Sub From a9f230b9c678af80b375442d76363843a743e19f Mon Sep 17 00:00:00 2001 From: JORGE LUIS CAUDILLO ESPARZA Date: Fri, 12 Jan 2024 13:25:02 -0700 Subject: [PATCH 04/19] --- RH/Personal.aspx.vb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/RH/Personal.aspx.vb b/RH/Personal.aspx.vb index 20952eeca..0247d02d2 100644 --- a/RH/Personal.aspx.vb +++ b/RH/Personal.aspx.vb @@ -7045,8 +7045,7 @@ Partial Class RH_Personal Using ObjPersonal As ClsRH = New ClsRH() ObjPersonal.IniciaTransacSQL() If ObjPersonal.UpdateSalarios(CvePersonal, TxtFechamodIMSSSalario.Text.ToDate().ToString("yyyy/MM/dd"), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, - TxtSalarioDiario.Text.ToDecimal(), TxtMImssSDI.Text.ToDecimal(), TxtMImssSalarioDiarioImSS.Text.ToDecimal(), - -1) Then + TxtSalarioDiario.Text.ToDecimal(), TxtMImssSDI.Text.ToDecimal(), TxtMImssSalarioDiarioImSS.Text.ToDecimal(), -1) Then ObjPersonal.Commit() From 6e8294cc01122b5eb4114cdc33ef2b569215645a Mon Sep 17 00:00:00 2001 From: JORGE LUIS CAUDILLO ESPARZA Date: Fri, 12 Jan 2024 13:27:40 -0700 Subject: [PATCH 05/19] --- RH/Personal.aspx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RH/Personal.aspx b/RH/Personal.aspx index bdfafa4e1..9053f04f4 100644 --- a/RH/Personal.aspx +++ b/RH/Personal.aspx @@ -5755,8 +5755,8 @@ Salario diario(IMSS):
- - Salario Diario Integrado(SDI): + + Salario Diario Integrado(SDI):
From 8dce44280f004db7472bdc116f549002dccf0465 Mon Sep 17 00:00:00 2001 From: JORGE LUIS CAUDILLO ESPARZA Date: Fri, 12 Jan 2024 13:28:59 -0700 Subject: [PATCH 06/19] b --- RH/Personal.aspx.vb | 1 + 1 file changed, 1 insertion(+) diff --git a/RH/Personal.aspx.vb b/RH/Personal.aspx.vb index 0247d02d2..4c1d92725 100644 --- a/RH/Personal.aspx.vb +++ b/RH/Personal.aspx.vb @@ -7050,6 +7050,7 @@ Partial Class RH_Personal ObjPersonal.Commit() + RegistraScript("$('#DmodamodificarsalarioIMSS').modal('hide')") TxtSalarioCotizado.Text = TxtMImssSalarioDiarioImSS.Text TxtSDI.Text = TxtMImssSDI.Text Dim sdi As Decimal = TxtSDI.Text.ToDecimal() From 7314a278da976a87d0973cdd4c5e8f25f07ec53c Mon Sep 17 00:00:00 2001 From: rakcsle Date: Fri, 12 Jan 2024 15:58:46 -0700 Subject: [PATCH 07/19] =?UTF-8?q?SMS=20-=20Ajustes=202024.01.10=20guardar?= =?UTF-8?q?=20material=20os=20tipo=20venta=20=20Consignaci=C3=B3n=20-=20?= =?UTF-8?q?=20Uso=20material?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App_Code/ClsOS.vb | 26 +++ OS/OrdenesServicios.aspx.vb | 315 ++++++++++++++++++++++-------------- 2 files changed, 224 insertions(+), 117 deletions(-) diff --git a/App_Code/ClsOS.vb b/App_Code/ClsOS.vb index 4aaabb0e2..950871f6f 100644 --- a/App_Code/ClsOS.vb +++ b/App_Code/ClsOS.vb @@ -1871,6 +1871,32 @@ Public Class ClsOS #End Region + Public Function AddOrdenesServicioMateriales(CveOS As Integer, CvePS As Integer, Cantidad As Decimal, Serie As String, Lote As String, FechaCaducidad As Date, CveUsuario As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_OS_OrdenesServicioMaterialesAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveOS", SqlDbType.Int).Value = CveOS + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@Cantidad", SqlDbType.Decimal).Value = Cantidad + .Add("@Serie", SqlDbType.VarChar).Value = Serie + .Add("@Lote", SqlDbType.VarChar).Value = Lote + .Add("@FechaCaducidad", SqlDbType.Date).Value = FechaCaducidad + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + + Catch ex As Exception + OnError("Ocurrió un error al guardar el material.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + 'Public Function GetCveCliente(CveVenta As Integer) As Boolean ' Dim Retorno As Boolean = False ' DataAdapter("PA_OS_ClienteGet") diff --git a/OS/OrdenesServicios.aspx.vb b/OS/OrdenesServicios.aspx.vb index 36b7a9574..b7536f248 100644 --- a/OS/OrdenesServicios.aspx.vb +++ b/OS/OrdenesServicios.aspx.vb @@ -8,6 +8,8 @@ Imports Telerik.Web.UI Imports System.Data.SqlClient Imports Stimulsoft.Report.StiOptions.Export Imports Modelos +Imports System.Runtime.InteropServices.ComTypes +Imports APP_Code_CSharp Partial Class OS_OrdenesServicios Inherits ClsPaginas @@ -670,7 +672,7 @@ Partial Class OS_OrdenesServicios ' End If 'End If - ElseIf TipoEstatus = 4 Then + ElseIf TipoEstatus = 4 AndAlso Not UsuarioActual.Empresa.Funcionalidad(578).ToEntero = 1 Then 'DisableAll() If SeFacturara = "True" Then HplFacturar.Visible = True @@ -2955,6 +2957,20 @@ Partial Class OS_OrdenesServicios LnkModalMaterialUtilizado.Visible = True DTSolicitudDev = New DataTable Dim Opcion As Integer = If(DdlTipoVenta.SelectedValue.Contiene("2", "3"), 2, 1) + + + Select Case DdlTipoVenta.SelectedValue.ToEntero + Case 2, 3 + Opcion = 2 + Exit Select + Case 5 + Opcion = 3 + Exit Select + Case Else + Opcion = 1 + Exit Select + End Select + Dim ObjOS As New ClsOS If ObjOS.GetOrdenesServicioDevolucionMaterial(CveOS, CveVenta, Opcion, UsuarioActual.CveEmpresa) Then DTSolicitudDev = ObjOS.DtResultados @@ -2996,176 +3012,241 @@ Partial Class OS_OrdenesServicios Dim CveVentaPedido As Integer = DTSolicitudDev.FiltroPrimeroValor("CveVenta").ToEntero Dim CveAlmacenDestino As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, 10).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto = {CveSubProyectoPedido}").ToEntero - If Not CveAlmacenDestino > 0 Then - Alert("No se encontró almacen de entrega por adelantado", TipoMensaje.MsgAdvertencia) - Exit Sub + If DdlTipoVenta.SelectedValue.ToEntero = 5 Then + Dim TotalSeleccionado As Decimal = 0 + + For Each GVRow As GridViewRow In GvMU.Rows + TotalSeleccionado = TotalSeleccionado + GVRow.FCTextBox("TxtUtilizado").Text.ToDecimal + Next + + If TotalSeleccionado = 0 Then + Alert("No se selecciono ningun material", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + Else + + If Not CveAlmacenDestino > 0 Then + Alert("No se encontró almacen de entrega por adelantado", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If + + Dim ProcesoOK As Boolean = True Dim ObjV As New ClsVentas - Dim ClsOS As New ClsOS(ObjV.IniciaTransacSQL()) + Dim ObjOS As New ClsOS(ObjV.IniciaTransacSQL()) Dim ObjInventario As New ClsInventarios(ObjV.IniciaTransacSQL()) Dim ObjConta As New ClsContabilidad(ObjV.IniciaTransacSQL()) - Dim GenrarRemisionMovimientos As Boolean = False - If ProcesoOK Then - Dim AplicaDevolucion As Boolean = False - For Each GvRow As GridViewRow In GvMU.Rows - Dim CveVentaDetalle As Integer = GvRow.DataKey("CveVentaDetalle").ToEntero - Dim CantidadDev As Decimal = GvRow.DataKey("Cantidad").ToDecimal - GvRow.FCTextBox("TxtUtilizado").Text.ToDecimal - If CantidadDev > 0 Then - AplicaDevolucion = True - If Not ObjV.UpdateVentasDetalleCantidadDevolucion(CveVentaDetalle, CantidadDev) Then + + + If DdlTipoVenta.SelectedValue.ToEntero = 5 Then + + For Each GVRow As GridViewRow In GvMU.Rows + Dim CantidadRegistro As Decimal = GVRow.FCTextBox("TxtUtilizado").Text.ToDecimal + Dim CvePS As Integer = GVRow.DataKey("CvePS").ToEntero + + If CantidadRegistro > 0 Then + + Dim Serie As String = If(GVRow.DataKey("Serie") = "", "-1", GVRow.DataKey("Serie")) + Dim Lote As String = If(GVRow.DataKey("Lote") = "", "-1", GVRow.DataKey("Lote")) + Dim FechaCaducidad As DateTime = If(GVRow.DataKey("FechaCaducidad") = "", MinFecha, GVRow.DataKey("FechaCaducidad").ToDate) + + If Not ObjOS.AddOrdenesServicioMateriales(CveOS, CvePS, CantidadRegistro, Serie, Lote, FechaCaducidad, UsuarioActual.CveUsuario) Then + Alert("Ocurrió un error al guardar el material.", TipoMensaje.MsgAdvertencia) ProcesoOK = False - GenrarRemisionMovimientos = False - AplicaDevolucion = False Exit For End If - End If - If GvRow.FCTextBox("TxtUtilizado").Text.ToDecimal > 0 Then - GenrarRemisionMovimientos = True End If - Next - If AplicaDevolucion Then - If Not ObjV.UpdateVentasDevolucionAlmacen(1, CveVenta) Then + + If ProcesoOK Then + + Dim CveOSEstatusFinalizada As Integer = GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveEstatusOrdenServicio", "TipoEstatus = 4").ToEntero + + If CveOSEstatusFinalizada > 0 Then + If Not ObjOS.UpdateOrdenesServiciosEstatus(CveOSEstatusFinalizada, UsuarioActual.CveUsuario, CveOS) Then + ProcesoOK = False + End If + Else + Alert("No se pudo obtener el estado para finalizar la orden de servicio.") ProcesoOK = False End If + + End If - End If - Dim Respuesta As New RespuestaFacturacion() - Dim DtVentaDetalle As New DataTable - Dim CveMovimientoSalida, CveMovimientoEntrada As Integer - Dim ImporteAlmacen As Decimal - Dim Fecha As DateTime = ClsPaginas.NowADS() - - If GenrarRemisionMovimientos AndAlso ProcesoOK Then - Respuesta = GeneraRemision(CveVentaPedido, ObjV.IniciaTransacSQL()) - - If Respuesta.CveVenta > 0 Then - If ObjV.GetVentaDetalle(Respuesta.CveVenta) Then - Dim dtClon As DataTable = ObjV.DtResultados.Copy - dtClon.DefaultView.Sort = "CveVentaDetalle ASC" - DtVentaDetalle = dtClon.DefaultView.ToTable() - End If - Else - ProcesoOK = False - End If - End If - - If GenrarRemisionMovimientos AndAlso ProcesoOK Then - - CveMovimientoSalida = ObjInventario.AddMovimiento(CveAlmacenActual, 8, CveMoneda, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, Respuesta.CveVenta, CveSubProyectoPedido, -1, CveOS:=CveOS, CveAlmacenDestino:=CveAlmacenDestino, Modulo:="OS/MatUtil") - Dim Folio As Integer = ObjInventario.Folio - - If CveMovimientoSalida > 0 Then - - Dim IndexMov1 As Integer = 0 + Else + If ProcesoOK Then + Dim AplicaDevolucion As Boolean = False For Each GvRow As GridViewRow In GvMU.Rows + Dim CveVentaDetalle As Integer = GvRow.DataKey("CveVentaDetalle").ToEntero + Dim CantidadDev As Decimal = GvRow.DataKey("Cantidad").ToDecimal - GvRow.FCTextBox("TxtUtilizado").Text.ToDecimal - Dim Cantidad As Decimal = GvRow.DataKey("Cantidad").ToDecimal - Dim CantidadRegistro As Decimal = GvRow.FCTextBox("TxtUtilizado").Text.ToDecimal - Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero - Dim CveUM As Integer = GvRow.DataKey("CveUM").ToEntero - Dim PU As Decimal = GvRow.DataKey("PU").ToDecimal - - If CantidadRegistro > 0 Then - Dim CveVentaDetalle As Integer = GvRow.DataKey("CveVentaDetalle").ToEntero ' DtVentaDetalle.Rows(IndexMov1)("CveVentaDetalle").ToString.ToEntero - Dim CveMovimientoDetalle As Integer = GvRow.DataKey("CveMovimientoDetalle").ToEntero - - Dim Serie As String = GvRow.DataKey("Serie") - Dim Lote As String = GvRow.DataKey("Lote") - Dim FechaCaducidad As DateTime = GvRow.DataKey("FechaCaducidad").ToDate - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadRegistro, CveUM, CvePS, PU, CveVentaDetalle:=CveVentaDetalle, CveMovimientoDetalleEntrada:=CveMovimientoDetalle, Lote:=Lote, Serie:=Serie, FechaCaducidad:=FechaCaducidad) Then - Alert("Error al agregar detalle de movimiento.", TipoMensaje.MsgAdvertencia) + If CantidadDev > 0 Then + AplicaDevolucion = True + If Not ObjV.UpdateVentasDetalleCantidadDevolucion(CveVentaDetalle, CantidadDev) Then ProcesoOK = False + GenrarRemisionMovimientos = False + AplicaDevolucion = False Exit For End If End If - IndexMov1 = IndexMov1 + 1 + + If GvRow.FCTextBox("TxtUtilizado").Text.ToDecimal > 0 Then + GenrarRemisionMovimientos = True + End If + Next + If AplicaDevolucion Then + If Not ObjV.UpdateVentasDevolucionAlmacen(1, CveVenta) Then + ProcesoOK = False + End If + End If + End If + Dim Respuesta As New RespuestaFacturacion() + Dim DtVentaDetalle As New DataTable + Dim CveMovimientoSalida, CveMovimientoEntrada As Integer + Dim ImporteAlmacen As Decimal + Dim Fecha As DateTime = ClsPaginas.NowADS() - If ProcesoOK Then + If GenrarRemisionMovimientos AndAlso ProcesoOK Then + Respuesta = GeneraRemision(CveVentaPedido, ObjV.IniciaTransacSQL()) - CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacenDestino, 9, CveMoneda, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, Respuesta.CveVenta, CveSubProyectoPedido, -1, CveOS:=CveOS, CveMovimientoRelacionado:=CveMovimientoSalida, Modulo:="OS/MatUtil2") + If Respuesta.CveVenta > 0 Then + If ObjV.GetVentaDetalle(Respuesta.CveVenta) Then + Dim dtClon As DataTable = ObjV.DtResultados.Copy + dtClon.DefaultView.Sort = "CveVentaDetalle ASC" + DtVentaDetalle = dtClon.DefaultView.ToTable() + End If + Else + ProcesoOK = False + End If + End If - If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then - ImporteAlmacen = ObjInventario.DtResultados.SUM("Total") - Dim IndexMov2 As Integer = 0 - For Each dRow As DataRow In ObjInventario.DtResultados.Rows + If GenrarRemisionMovimientos AndAlso ProcesoOK Then - Dim Cantidad As Decimal = dRow("Cantidad").ToString.ToDecimal - Dim CvePS As Integer = dRow("CvePS").ToString.ToEntero - Dim CveUM As Integer = dRow("CveUM").ToString.ToEntero - Dim PU As Decimal = dRow("PU").ToString.ToDecimal - Dim CveVentaDetalle As Integer = dRow("CveVentaDetalle").ToString.ToEntero - Dim CveMovimientoDetalle As Integer = dRow("CveMovimientoDetalle").ToString.ToEntero + CveMovimientoSalida = ObjInventario.AddMovimiento(CveAlmacenActual, 8, CveMoneda, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, Respuesta.CveVenta, CveSubProyectoPedido, -1, CveOS:=CveOS, CveAlmacenDestino:=CveAlmacenDestino, Modulo:="OS/MatUtil") + Dim Folio As Integer = ObjInventario.Folio - Dim Lote As String = dRow("Lote").ToString - Dim Serie As String = dRow("Serie").ToString - Dim FechaCaducidad As DateTime = dRow("FechaCaducidad").ToString.ToDateTime + If CveMovimientoSalida > 0 Then - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Cantidad, CveUM, CvePS, PU, CveVentaDetalle:=CveVentaDetalle, CveMovimientoDetalleEntrada:=CveMovimientoDetalle, Lote:=Lote, Serie:=Serie, FechaCaducidad:=FechaCaducidad) Then + Dim IndexMov1 As Integer = 0 + For Each GvRow As GridViewRow In GvMU.Rows + + Dim Cantidad As Decimal = GvRow.DataKey("Cantidad").ToDecimal + Dim CantidadRegistro As Decimal = GvRow.FCTextBox("TxtUtilizado").Text.ToDecimal + Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero + Dim CveUM As Integer = GvRow.DataKey("CveUM").ToEntero + Dim PU As Decimal = GvRow.DataKey("PU").ToDecimal + + If CantidadRegistro > 0 Then + Dim CveVentaDetalle As Integer = GvRow.DataKey("CveVentaDetalle").ToEntero ' DtVentaDetalle.Rows(IndexMov1)("CveVentaDetalle").ToString.ToEntero + Dim CveMovimientoDetalle As Integer = GvRow.DataKey("CveMovimientoDetalle").ToEntero + + Dim Serie As String = GvRow.DataKey("Serie") + Dim Lote As String = GvRow.DataKey("Lote") + Dim FechaCaducidad As DateTime = GvRow.DataKey("FechaCaducidad").ToDate + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadRegistro, CveUM, CvePS, PU, CveVentaDetalle:=CveVentaDetalle, CveMovimientoDetalleEntrada:=CveMovimientoDetalle, Lote:=Lote, Serie:=Serie, FechaCaducidad:=FechaCaducidad) Then Alert("Error al agregar detalle de movimiento.", TipoMensaje.MsgAdvertencia) ProcesoOK = False Exit For End If - IndexMov2 = IndexMov2 + 1 - Next - If ProcesoOK Then - Dim ObjEventos As New ClsOIEventos(ObjInventario.IniciaTransacSQL) - Dim LigaVenta As String = String.Format("Venta {2} en Folio: {1}", CveMovimientoEntrada, Folio, "Material utilizado") + End If + IndexMov1 = IndexMov1 + 1 + Next - If Not ObjEventos.AddEventoBitacora(LigaVenta, "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=Respuesta.CveVenta, CveOS:=CveOS) Then + If ProcesoOK Then + + CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacenDestino, 9, CveMoneda, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, Respuesta.CveVenta, CveSubProyectoPedido, -1, CveOS:=CveOS, CveMovimientoRelacionado:=CveMovimientoSalida, Modulo:="OS/MatUtil2") + + If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then + ImporteAlmacen = ObjInventario.DtResultados.SUM("Total") + Dim IndexMov2 As Integer = 0 + For Each dRow As DataRow In ObjInventario.DtResultados.Rows + + Dim Cantidad As Decimal = dRow("Cantidad").ToString.ToDecimal + Dim CvePS As Integer = dRow("CvePS").ToString.ToEntero + Dim CveUM As Integer = dRow("CveUM").ToString.ToEntero + Dim PU As Decimal = dRow("PU").ToString.ToDecimal + Dim CveVentaDetalle As Integer = dRow("CveVentaDetalle").ToString.ToEntero + Dim CveMovimientoDetalle As Integer = dRow("CveMovimientoDetalle").ToString.ToEntero + + Dim Lote As String = dRow("Lote").ToString + Dim Serie As String = dRow("Serie").ToString + Dim FechaCaducidad As DateTime = dRow("FechaCaducidad").ToString.ToDateTime + + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Cantidad, CveUM, CvePS, PU, CveVentaDetalle:=CveVentaDetalle, CveMovimientoDetalleEntrada:=CveMovimientoDetalle, Lote:=Lote, Serie:=Serie, FechaCaducidad:=FechaCaducidad) Then + Alert("Error al agregar detalle de movimiento.", TipoMensaje.MsgAdvertencia) + ProcesoOK = False + Exit For + End If + IndexMov2 = IndexMov2 + 1 + Next + If ProcesoOK Then + Dim ObjEventos As New ClsOIEventos(ObjInventario.IniciaTransacSQL) + Dim LigaVenta As String = String.Format("Venta {2} en Folio: {1}", CveMovimientoEntrada, Folio, "Material utilizado") + + If Not ObjEventos.AddEventoBitacora(LigaVenta, "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=Respuesta.CveVenta, CveOS:=CveOS) Then + ProcesoOK = False + End If + End If + Else + ProcesoOK = False + End If + End If + If ProcesoOK Then + If Not ObjOS.UpdateOrdenesServiciosFinaliza(CveOS, -1, -1, UsuarioActual.CveEmpresa) Then + ProcesoOK = False + End If + End If + If ProcesoOK Then + Dim Contabilizable As Boolean = False + Dim Concepto As String = "Material utilizado" + Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("OS-MatUtil", 53, 0, 0, 1, Fecha, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + If CveMovimientoSalida > 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteAlmacen, ImporteAlmacen, 68, "", Concepto, CveMovimientoAlmacen:=CveMovimientoSalida, Contabilizable:=Contabilizable) Then ProcesoOK = False End If End If - Else - ProcesoOK = False - End If - End If - If ProcesoOK Then - If Not ClsOS.UpdateOrdenesServiciosFinaliza(CveOS, -1, -1, UsuarioActual.CveEmpresa) Then - ProcesoOK = False - End If - End If - If ProcesoOK Then - Dim Contabilizable As Boolean = False - Dim Concepto As String = "Material utilizado" - Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("OS-MatUtil", 53, 0, 0, 1, Fecha, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - If CveMovimientoSalida > 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteAlmacen, ImporteAlmacen, 68, "", Concepto, CveMovimientoAlmacen:=CveMovimientoSalida, Contabilizable:=Contabilizable) Then - ProcesoOK = False + If CveMovimientoEntrada > 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteAlmacen, ImporteAlmacen, 68, "", Concepto, CveMovimientoAlmacen:=CveMovimientoEntrada, Contabilizable:=Contabilizable) Then + ProcesoOK = False + End If End If - End If - If CveMovimientoEntrada > 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteAlmacen, ImporteAlmacen, 68, "", Concepto, CveMovimientoAlmacen:=CveMovimientoEntrada, Contabilizable:=Contabilizable) Then - ProcesoOK = False - End If - End If + End If + Else + ProcesoOK = False End If - Else - ProcesoOK = False End If End If + + If ProcesoOK Then + ObjV.Commit() - If GenrarRemisionMovimientos = False Then - Alert("El material sera recibido en almacén.") + If DdlTipoVenta.SelectedValue.ToEntero = 5 Then + Dim Liga As String = $" document.location.href=""/OS/OrdenesServicios.aspx?CveOS={CveOS}""; " + Alert("El material utilizado se guardó correctamente", TipoMensaje.MsgInformacion, Liga) Else - Alert("El material utilizado se guardó correctamente") + If GenrarRemisionMovimientos = False Then + Alert("El material sera recibido en almacén.") + Else + Alert("El material utilizado se guardó correctamente") + End If End If RegistraScript("$('#DivModalMaterialUtilizado').modal('hide');") Else ObjV.RollBack() - Alert("El material utilizado no se guardó correctamente", TipoMensaje.MsgAdvertencia) + Alert("Se presento un error al guardar el material", TipoMensaje.MsgAdvertencia) End If ObjV.Dispose() From 6071da164bb5cc72f408b0944994fdca03d1dfe2 Mon Sep 17 00:00:00 2001 From: rakcsle Date: Fri, 12 Jan 2024 17:02:46 -0700 Subject: [PATCH 08/19] Clientes Abonar activar Deducciones Pago para empresa 15 --- Ventas/ClientesAbonar.aspx.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ventas/ClientesAbonar.aspx.vb b/Ventas/ClientesAbonar.aspx.vb index acb39c93c..2bcfd0459 100644 --- a/Ventas/ClientesAbonar.aspx.vb +++ b/Ventas/ClientesAbonar.aspx.vb @@ -236,7 +236,7 @@ Partial Class Ventas_ClientesAbonar LnkAccionesModalSeleccionLayout.Visible = True End If - If UsuarioActual.CveEmpresa.Contiene(13, 1) Then + If UsuarioActual.CveEmpresa.Contiene(13, 1, 15) Then DVImporteDeduccionesPago.Visible = True End If From 8030dada808d024ae7002e6760d5e81479d05fb2 Mon Sep 17 00:00:00 2001 From: rrene Date: Fri, 12 Jan 2024 18:40:47 -0700 Subject: [PATCH 09/19] - --- OS/OrdenesServicios.aspx.vb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OS/OrdenesServicios.aspx.vb b/OS/OrdenesServicios.aspx.vb index 36b7a9574..ea383d823 100644 --- a/OS/OrdenesServicios.aspx.vb +++ b/OS/OrdenesServicios.aspx.vb @@ -3194,6 +3194,9 @@ Partial Class OS_OrdenesServicios ObjFactura.CveMedico = DdlMedico.SelectedValue.ToEntero ObjFactura.CveProcedimiento = DdlProcedimiento.SelectedValue.ToEntero ObjFactura.CveTipoVenta = DdlTipoVenta.SelectedValue.ToEntero + ObjFactura.FechaParaSurtir = TxtFechaCita.Text.ToDateTime + ObjFactura.CveClienteSucursal = DdlSucursalCliente.SelectedValue.ToEntero + ObjFactura.CveVentaRelacion = CveVentaPedido For Each GvRow As GridViewRow In GvMU.Rows From 47eee107e56dab35d8c7f46bdf4b425fde5a5033 Mon Sep 17 00:00:00 2001 From: rakcsle Date: Fri, 12 Jan 2024 18:56:34 -0700 Subject: [PATCH 10/19] SMS - 2024.01.08 enviar cveMedico y CveProcedimiento al facturar una remision desde popup --- Ventas/Ventas.aspx | 2 +- Ventas/Ventas.aspx.vb | 45 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 18d7194e5..1cbfb545a 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -586,7 +586,7 @@ Requiere Técnico: - + Fecha de Cirugia: diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 42cc735cf..b05b06ca1 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -30975,6 +30975,10 @@ Partial Class Ventas Exit Sub End If + If UsuarioActual.Empresa.Funcionalidad(578).ToEntero = 1 Then + AsignaMedicoProcedimientoFacturaRemisionesModal() + End If + DdlMoneda.SelectedValue = GlobalDTMonedas.FiltroPrimeroValor("CveMoneda", $"Abreviatura = '{dtSeleccionadas.FiltroPrimeroValor("Abreviatura")}'") DdlMoneda.Enabled = False CambiaMoneda() @@ -31245,6 +31249,9 @@ Partial Class Ventas RegistraScript("$('#DivRemisiones').modal('hide');", "DivRemisionesHide") End Sub + + + Private Function VerificaRemisiones(ByRef dt As DataTable) As Boolean Dim Valido As Boolean = True If ChkRemProductos.Checked Then @@ -35893,6 +35900,44 @@ Partial Class Ventas End Sub + Private Sub AsignaMedicoProcedimientoFacturaRemisionesModal() + + Dim CveVentaConsultar As Integer = -1 + If ChkRemProductos.Checked Then + + For Each gvRow As GridViewRow In GvRemPS.Rows + If gvRow.FCCheckBox("Chk").Checked Then + CveVentaConsultar = gvRow.DataKey("CveVenta").ToEntero + Exit For + End If + Next + + Else + For Each gvRow As GridViewRow In GvRem.Rows + If gvRow.FCCheckBox("Chk").Checked Then + CveVentaConsultar = gvRow.DataKey("CveVenta").ToEntero + Exit For + End If + Next + End If + + If CveVentaConsultar > 0 Then + Dim objVenta As New ClsVentas + If objVenta.GetVenta(CveVentaConsultar, UsuarioActual.CveEmpresa) Then + Dim dRow As DataRow = objVenta.DtResultados.Rows(0) + DdlMedico.SelectedValueExist(dRow("CveMedico").ToString.ToEntero) + DdlProcedimiento.SelectedValueExist(dRow("CveProcedimiento").ToString.ToEntero) + SeEstaFActurandoVentaMedica = True + CveTipoVenta = dRow("CveTipoVenta").ToString.ToEntero + ChkRequiereTecnico_CheckedChanged(Nothing, Nothing) + End If + objVenta.Dispose() + End If + + UpCliente.Update() + + + End Sub #Region "VENTAS MEDICAS" From 30d35df6de5b0c68930cd6139cc07fc065fe0982 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Fri, 12 Jan 2024 20:30:34 -0700 Subject: [PATCH 11/19] =?UTF-8?q?--=20mejoras=20en=20impresi=C3=B3n=20dire?= =?UTF-8?q?cta=20de=20PDF=20(libreria=20de=20PrintJS).=20--=20correci?= =?UTF-8?q?=C3=B3n=20de=20errores.=20--=20ashx=20para=20visualizacion=20de?= =?UTF-8?q?=20documentos=20pdf.=20--=20cambios=20de=20popUpVerFacturas=20a?= =?UTF-8?q?=20ClsPaginas=20para=20generacion=20de=20pdf=20de=20ventas.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App_Code/ClsPaginas.vb | 1024 +++++++++++++++++++++++++++++++ Ashx/SIGDesc.ashx | 49 ++ Compras/PopUpVerFactura.aspx.vb | 1009 +----------------------------- Scripts/PrintJS/print.min.css | 1 + Scripts/PrintJS/print.min.js | 1 + Site.master | 1 + Ventas/Ventas.aspx | 73 +-- Ventas/Ventas.aspx.vb | 117 ++-- 8 files changed, 1167 insertions(+), 1108 deletions(-) create mode 100644 Ashx/SIGDesc.ashx create mode 100644 Scripts/PrintJS/print.min.css create mode 100644 Scripts/PrintJS/print.min.js diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 5b3184493..9bfa4a90a 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -5333,6 +5333,1030 @@ Public Class ClsPaginas #End Region #Region "IMPRIMIR FACTURA" + Protected Sub GenerarPDFVenta(CveVenta As Integer, AplicaPagare As String, Optional GuardarPDF As Boolean = False, Optional RegenerarPDF As Boolean = False, Optional UsarStimul As Boolean = False, Optional DescargarArchivo As Boolean = True) + Dim ObjVentas As New ClsVentas + Dim Vta As Modelos.Factura = Nothing + + Dim PathArchivo As String = "" 'String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio) + + + Dim TmpDTImpuestos As New DataTable + TmpDTImpuestos.Columns.Add("ImpuestoLocal", GetType(String)) + TmpDTImpuestos.Columns.Add("Importe", GetType(Double)) + TmpDTImpuestos.Columns.Add("Orden", GetType(Integer)) + + Dim TmpDTImpuestosIVAIEPS As New DataTable + TmpDTImpuestosIVAIEPS.Columns.Add("Impuesto", GetType(String)) + TmpDTImpuestosIVAIEPS.Columns.Add("tasa", GetType(String)) + TmpDTImpuestosIVAIEPS.Columns.Add("Importe", GetType(Double)) + TmpDTImpuestosIVAIEPS.Columns.Add("Orden", GetType(Integer)) + + If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa, False) AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then + Dim dtVentas As DataTable = ObjVentas.DtResultados + + ' se rellenan los campos de la factura + + Vta = ObjVentas.DtResultados.Rows(0).DataRowToObject(Of Modelos.Factura) + + PathArchivo = String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio) + Dim Archivo As New System.IO.FileInfo(PathArchivo) + + 'SI EL ARCHIVO NO EXISTE O SE VA REGENERA EL PDF, SE DEBEN LLENAR LOS DATOS + If Not Archivo.Exists OrElse RegenerarPDF OrElse UsarStimul Then + Vta.MonedaAbreviatura = dtVentas(0)("Abreviatura").ToString + 'se rellena la sucursal + 'Vta.Subproyecto = ObjVentas.DtResultados.Rows(0).DataRowToObject(Of Modelos.SucursalModel) + Dim CveSubProyecto As Integer = dtVentas(0)("CveSubProyecto").ToString().ToEntero() + + Dim DtSubProyecto As DataTable = GlobalDTSubProyectos(-1, CveSubProyecto:=CveSubProyecto, CveEmpresa:=dtVentas(0)("CveEmpresa").ToString().ToEntero()) + + Vta.SubProyecto = DtSubProyecto.Rows(0).DataRowToObject(Of Modelos.SubProyectoModel) + 'Vta.SubProyecto = ObjVentas.DtResultados.Rows(0).DataRowToObject(Of Modelos.SubProyectoModel) + Vta.Cliente = New Modelos.ClienteModel + Vta.Cliente.Nombre = dtVentas(0)("ClienteNombre").ToString + Vta.Cliente.Telefono = dtVentas(0)("Telefono").ToString + Vta.Cliente.Direccion = dtVentas(0)("ClienteDireccion").ToString + Vta.Cliente.CP = dtVentas(0)("CPCliente").ToString + Vta.Cliente.Ciudad = dtVentas(0)("ClienteCiudad").ToString + Vta.Cliente.Localidad = dtVentas(0)("ClienteLocalidad").ToString + Vta.Cliente.Estado = dtVentas(0)("ClienteEstado").ToString + Vta.Cliente.Pais = dtVentas(0)("ClientePais").ToString + Vta.Cliente.RFC = dtVentas(0)("ClienteRFC").ToString + Vta.Cliente.Colonia = dtVentas(0)("ColoniaCliente").ToString + Vta.AtencionA = dtVentas(0)("AtencionA").ToString + Vta.Cliente.NoExt = dtVentas(0)("ClienteNoExt").ToString + Vta.Cliente.NoInt = dtVentas(0)("ClienteNoInt").ToString + Vta.Cliente.Codigo = dtVentas(0)("ClienteCodigo").ToString + Vta.Cliente.Mail = dtVentas(0)("Mail").ToString + Vta.Cliente.MailCotizacion = dtVentas(0)("SucClienteCorreo").ToString + Vta.Cliente.CodigoRegimenFiscal = dtVentas(0)("CodigoRegimenFiscal").ToString + Vta.Cliente.RegimenFiscal = dtVentas(0)("RegimenFiscal").ToString + Vta.Cliente.UsaProductoAlterno = CBool(dtVentas(0)("UsaProductoAlterno")) + Vta.Cliente.Documentacion = dtVentas(0)("Documentacion").ToString + + Vta.Medico = dtVentas(0)("Medico").ToString + Vta.Procedimiento = dtVentas(0)("Procedimiento").ToString + Vta.Alfa1 = dtVentas(0)("Alfa1").ToString + Vta.FechaEjecucion = dtVentas(0)("FechaEjecucion").ToString.ToDateTime + + Vta.RefDocto = dtVentas(0)("Ref").ToString + Vta.CveVenta = dtVentas(0)("CveVenta").ToString.ToEntero + Vta.NumeroCuenta = dtVentas(0)("NumCtaPago").ToString + Vta.Version = dtVentas(0)("CFDIVersion").ToString + + Vta.NumeroContrato = dtVentas(0)("NumeroContrato").ToString + Vta.DescripcionContrato = dtVentas(0)("DescripcionContrato").ToString + Vta.NumeroDescripcionContrato = If($"{dtVentas(0)("NumeroContrato").ToString} - {dtVentas(0)("NumeroLicitacion").ToString}" = " - ", "", $"{dtVentas(0)("NumeroContrato").ToString} {If(dtVentas(0)("NumeroLicitacion").ToString = "", "", $" - Licitación: {dtVentas(0)("NumeroLicitacion").ToString}")}") + + Vta.PedidoContrato = If(dtVentas(0)("PedidoContrato").ToString = "", Vta.NumeroDescripcionContrato, $"{dtVentas(0)("PedidoContrato").ToString} {If(Vta.NumeroDescripcionContrato = "", "", $" / {Vta.NumeroDescripcionContrato}") }") + Vta.Kilometraje = If(dtVentas(0)("Kilometraje").ToString = "", -1, dtVentas(0)("Kilometraje").ToString.ToDecimal) + 'Vta.PedidoContrato = dtVentas(0)("PedidoContrato").ToString + + Vta.ClienteSucursal = New Modelos.SucursalModel + Vta.ClienteSucursal.Direccion = dtVentas(0)("SucClienteDireccion").ToString + Vta.ClienteSucursal.NoExt = dtVentas(0)("SucClienteNoExt").ToString + Vta.ClienteSucursal.NoInt = dtVentas(0)("SucClienteNoInt").ToString + Vta.ClienteSucursal.Colonia = dtVentas(0)("SucClienteColonia").ToString + Vta.ClienteSucursal.CP = dtVentas(0)("SucClienteCP").ToString + Vta.ClienteSucursal.Municipio = dtVentas(0)("SucClienteCiudad").ToString + Vta.ClienteSucursal.Estado = dtVentas(0)("SucClienteEstado").ToString + Vta.ClienteSucursal.Pais = dtVentas(0)("SucClientePais").ToString + Vta.ClienteSucursal.Localidad = dtVentas(0)("SucClienteLocalidad").ToString + Vta.ClienteSucursal.CorreoSucursal = dtVentas(0)("SucClienteCorreo").ToString + Vta.ClienteSucursal.TelefonoSucursal = dtVentas(0)("SucClienteTelefono").ToString + Vta.ClienteSucursal.Sucursal = dtVentas(0)("SucursalCliente").ToString + Vta.ClienteSucursal.ImprimeNombreSucursal = dtVentas(0)("ImprimeNombreSucursal").ToString + + Vta.EnviarA = New Modelos.EnviarAModel + Vta.EnviarA.CveDireccionEnvio = dtVentas(0)("CveDireccionEnvio").ToString.ToEntero + Vta.EnviarA.EnvioDireccion = dtVentas(0)("EnvioDireccion").ToString + Vta.EnviarA.EnvioColonia = dtVentas(0)("EnvioColonia").ToString + Vta.EnviarA.EnvioCiudad = dtVentas(0)("EnvioCiudad").ToString + Vta.EnviarA.EnvioEstado = dtVentas(0)("EnvioEstado").ToString + Vta.EnviarA.EnvioCP = dtVentas(0)("EnvioCP").ToString + Vta.EnviarA.EnvioTel = dtVentas(0)("EnvioTel").ToString + + Vta.EnviarA.EnvioNoExt = dtVentas(0)("EnvioNoExt").ToString + Vta.EnviarA.EnvioNoInt = dtVentas(0)("EnvioNoInt").ToString + Vta.EnviarA.EnvioContacto = dtVentas(0)("EnvioContacto").ToString + Vta.EnviarA.EnvioDepartamento = dtVentas(0)("EnvioDepartamento").ToString + + 'Vta.EnviarA.EnvioPedidoContrato = dtVentas(0)("EnvioPedidoContrato").ToString + + 'INE COMPLEMENTO + If dtVentas(0)("TipoComite").ToString <> "" Then + Dim INE As New Modelos.ComplementoINE + INE.INETipoComite = dtVentas(0)("TipoComite").ToString + INE.INETipoProceso = dtVentas(0)("TipoProceso").ToString + INE.INEIdContabilidad = dtVentas(0)("IdContabilidad").ToString.ToEntero + Vta.ComplementoINE = INE + End If + + + Dim DR As DataRow = TmpDTImpuestos.NewRow() + If dtVentas(0)("SubTotal").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Subtotal" : DR("Importe") = dtVentas(0)("SubTotal").ToString.ToDouble : DR("Orden") = 10 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + If dtVentas(0)("Descuento").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Descuentos" : DR("Importe") = dtVentas(0)("Descuento").ToString.ToDouble : DR("Orden") = 20 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + If dtVentas(0)("Amortizacion").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Amort.Ant" : DR("Importe") = dtVentas(0)("Amortizacion").ToString.ToDouble : DR("Orden") = 30 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + If dtVentas(0)("SubTotal").ToString.ToDouble <> (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) Then DR("ImpuestoLocal") = "SubTotal2" : DR("Importe") = (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) : DR("Orden") = 40 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + If dtVentas(0)("IVA").ToString.ToDouble >= 0 Then DR("ImpuestoLocal") = "IVA" : DR("Importe") = dtVentas(0)("IVA").ToString.ToDouble : DR("Orden") = 50 : TmpDTImpuestos.Rows.Add(DR) + + 'solo para eclipse, que muesre un subtotal debajo de IVA + If UsuarioActual.CveEmpresa = 15 Then DR = TmpDTImpuestos.NewRow() : DR("ImpuestoLocal") = "Subtotal2" : DR("Importe") = (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) + dtVentas(0)("IVA").ToString.ToDouble : DR("Orden") = 51 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + If dtVentas(0)("RetIVA").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Ret.IVA" : DR("Importe") = dtVentas(0)("RetIVA").ToString.ToDouble : DR("Orden") = 60 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + If dtVentas(0)("RetISR").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Ret.ISR" : DR("Importe") = dtVentas(0)("RetISR").ToString.ToDouble : DR("Orden") = 70 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + + If dtVentas(0)("IEPS").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "IEPS" : DR("Importe") = dtVentas(0)("IEPS").ToString.ToDouble : DR("Orden") = 80 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + + If dtVentas(0)("Total").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Total" : DR("Importe") = dtVentas(0)("Total").ToString.ToDouble : DR("Orden") = 100 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + + If ObjVentas.GetVentaDetalle(CveVenta) Then 'Obtenemos el Detalle de la Oorden de Compra + Vta.DtDetalle = ObjVentas.DtResultados + End If + + If ObjVentas.GetVentaImpuestosLocales(CveVenta) Then + + Dim dtImpuesto As DataTable = ObjVentas.DtResultados + If dtImpuesto.Rows.Count > 0 Then + For Each Row As DataRow In dtImpuesto.Rows + Dim Orden As Integer = 80 + If Row("Importe").ToString.ToDouble <> 0 Then + DR("ImpuestoLocal") = Row("ImpuestoLocal").ToString + DR("Importe") = Row("Importe").ToString.ToDouble + DR("Orden") = Orden + TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + Orden = Orden + 1 + End If + Next + End If + Vta.DtDeduccion = TmpDTImpuestos.FiltraParametros("", Orderby:="Orden ASC") + + End If + + 'TmpDT DESGLOSE DE IMPUESTOS 3.3 + For Each dr1 As DataRow In Vta.DtDetalle.Rows + Dim DrIVA As DataRow = Nothing + Dim DrIEPS As DataRow = Nothing + + Try + DrIVA = TmpDTImpuestosIVAIEPS.Select("Impuesto = 'IVA'")(0) + Catch ex As Exception + DrIVA = Nothing + End Try + + If DrIVA IsNot Nothing Then + DrIVA("Importe") = DrIVA("Importe").ToString.ToDouble + dr1("ImporteIVA").ToString.ToDouble + TmpDTImpuestosIVAIEPS.AcceptChanges() + Else + Dim DR2 As DataRow = TmpDTImpuestosIVAIEPS.NewRow() + If dr1("PorcentajeIVA").ToString.ToDouble > 0 Then + DR2("Impuesto") = "IVA" : DR2("tasa") = String.Format("{0} %", dr1("PorcentajeIVA").ToString.ToDouble() * 100) : DR2("Importe") = dr1("ImporteIVA").ToString.ToDouble : DR2("Orden") = "1" + TmpDTImpuestosIVAIEPS.Rows.Add(DR2) + TmpDTImpuestosIVAIEPS.AcceptChanges() + End If + End If + + Try + DrIEPS = TmpDTImpuestosIVAIEPS.Select($"Impuesto = 'IEPS' AND tasa = '{dr1("PorcentajeIEPS").ToString.ToDouble * 100} %'")(0) + Catch ex As Exception + DrIEPS = Nothing + End Try + + If DrIEPS IsNot Nothing Then + DrIEPS("Importe") = DrIEPS("Importe").ToString.ToDouble + dr1("ImporteIEPS").ToString.ToDouble + TmpDTImpuestosIVAIEPS.AcceptChanges() + Else + Dim DR2 As DataRow = TmpDTImpuestosIVAIEPS.NewRow() + If dr1("PorcentajeIEPS").ToString.ToDouble > 0 Then + DR2("Impuesto") = "IEPS" : DR2("tasa") = String.Format("{0} {1}", dr1("PorcentajeIEPS").ToString.ToDouble * 100, "%") : DR2("Importe") = dr1("ImporteIEPS").ToString.ToDouble : DR2("Orden") = If(dr1("PorcentajeIEPS").ToString.ToDecimal = 0.03, "2", If(dr1("PorcentajeIEPS").ToString.ToDecimal = 0.06, "3", If(dr1("PorcentajeIEPS").ToString.ToDecimal = 0.07, "4", If(dr1("PorcentajeIEPS").ToString.ToDecimal = 0.09, "5", "")))) + TmpDTImpuestosIVAIEPS.Rows.Add(DR2) + TmpDTImpuestosIVAIEPS.AcceptChanges() + End If + End If + + If Vta.Version.ToEntero() = 4 AndAlso dr1("CodigoObjetoImpuesto").ToString() = "02" AndAlso NowADS().Date >= New DateTime(2022, 11, 1) AndAlso dr1("Descuento").ToString().ToDecimal().RoundSQL(2) = dr1("Total").ToString().ToDecimal().RoundSQL(2) Then + dr1("CodigoObjetoImpuesto") = "04" + End If + + Next + + Vta.DtDesgloseImpuestos = TmpDTImpuestosIVAIEPS.FiltraParametros("", Orderby:="Orden ASC") + + If ObjVentas.GetVentasFirmas(CveVenta) Then + Vta.DtFirmas = ObjVentas.DtResultados + End If + + + 'CFDI RELACIONADO + If dtVentas(0)("CveTipoRelacion").ToString.ToEntero > 0 Then + Vta.Timbre.Comprobante.TipoComprobante = If(Vta.TipoDocto.Contiene("Ing", "Ant"), "I", If(Vta.TipoDocto.Contiene("Egs", "Dev"), "E", "")) + If Vta.Timbre.Comprobante.TipoComprobante = "E" Then + If Vta.TipoDocto.Contiene("Egs") Then + Vta.Timbre.CFDIRelacionados.TipoRelacion = "01" + Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Nota de Crédito aplicada a Ingreso" + End If + If Vta.TipoDocto.Contiene("Dev") Then + Vta.Timbre.CFDIRelacionados.TipoRelacion = "03" + Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Devolución aplicada a Ingreso" + End If + Vta.Timbre.CFDIRelacionados.UUID.Add(dtVentas(0)("FolioFiscalPadre").ToString) + End If + ' cuando es refacturacoin es cfdirelacionado, con relacion 04 + If Vta.Timbre.Comprobante.TipoComprobante = "I" Then 'AndAlso (dtVentas(0)("Total").ToString.ToDouble = dtVentas(0)("TotalPadre").ToString.ToDouble) Then + Vta.Timbre.CFDIRelacionados.TipoRelacion = "04" + Vta.Timbre.CFDIRelacionados.UUID.Add(dtVentas(0)("FolioFiscalPadre").ToString) + Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Sustitución de los CFDI Previos" + End If + + If UsuarioActual.Empresa.Funcionalidad(592) = "1" Then + + Dim RowTipoRelacion As DataRow = GlobalDTVtaTiposRelacion().FiltroPrimero($"CveTipoRelacion = {dtVentas(0)("CveTipoRelacion").ToString.ToEntero}") + + Vta.Timbre.CFDIRelacionados.TipoRelacion = RowTipoRelacion("SATClaveTipoRelacion").ToString() + Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = RowTipoRelacion("SATTipoRelacion").ToString() + + If ObjVentas.GetVentasRelacionadas(CveVenta, UsuarioActual.CveEmpresa) Then + Vta.DtDocumentosRelacionados = ObjVentas.DtResultados.FiltraParametros("FolioFiscal IS NOT NULL") + End If + + End If + + End If + + 'If UsuarioActual.CveEmpresa.Contiene(72, 80, 119) Then + If Vta.Timbre.Comprobante.TipoComprobante = "I" Then 'AndAlso (dtVentas(0)("Total").ToString.ToDouble = dtVentas(0)("TotalPadre").ToString.ToDouble) Then + If ObjVentas.GetVentaRefacturacion(dtVentas(0)("CveVentaPadre").ToString.ToEntero) Then + If ObjVentas.DtResultados IsNot Nothing AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then + ObjVentas.DtResultados.Columns.Add("Importe", GetType(Decimal)) + ObjVentas.DtResultados.Rows(0)("Importe") = ObjVentas.DtResultados.Rows(0)("Total") + Vta.DtDocumentosRelacionados = ObjVentas.DtResultados.FiltraParametros("FolioFiscal IS NOT NULL") + If ObjVentas.GetVentasRelacionadas(CveVenta, UsuarioActual.CveEmpresa) Then + Vta.DtNCVinculadas = ObjVentas.DtResultados + Vta.DtDocumentosRelacionados = ObjVentas.DtResultados.FiltraParametros("FolioFiscal IS NOT NULL") + If Vta.DtDocumentosRelacionados.Rows.Count > 0 Then + If Vta.TipoDocto.Contiene("Dev") Then + Vta.Timbre.CFDIRelacionados.TipoRelacion = "03" + Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Devolución aplicada a Ingreso" + End If + End If + End If + End If + End If + Else + + If dtVentas(0)("TipoDocto").ToString.Contiene("Egs", "Dev", "Ant") Then + + If ObjVentas.GetVentasRelacionadas(CveVenta, UsuarioActual.CveEmpresa) Then + Vta.DtNCVinculadas = ObjVentas.DtResultados + Vta.DtDocumentosRelacionados = ObjVentas.DtResultados.FiltraParametros("FolioFiscal IS NOT NULL") + If Vta.DtDocumentosRelacionados.Rows.Count > 0 Then + If Vta.TipoDocto.Contiene("Dev") Then + Vta.Timbre.CFDIRelacionados.TipoRelacion = "03" + Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Devolución aplicada a Ingreso" + End If + End If + End If + End If + End If + + If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso (Vta.DtDocumentosRelacionados Is Nothing OrElse Vta.DtDocumentosRelacionados.Rows.Count = 0) Then + If ObjVentas.GetVentasRelacionadas(CveVenta, UsuarioActual.CveEmpresa) Then + Vta.DtNCVinculadas = ObjVentas.DtResultados + Vta.DtDocumentosRelacionados = ObjVentas.DtResultados '.FiltraParametros("FolioFiscal IS NOT NULL") + If Vta.DtDocumentosRelacionados.Rows.Count > 0 Then + If Vta.TipoDocto.Contiene("Ing") Then + Vta.Timbre.CFDIRelacionados.TipoRelacion = "01" + Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Nota de Crédito aplicada a Ingreso" + End If + + If Vta.TipoDocto.Contiene("Egs") Then + Vta.Timbre.CFDIRelacionados.TipoRelacion = "01" + Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Nota de Crédito aplicada a Ingreso" + End If + + If Vta.TipoDocto.Contiene("Dev") Then + Vta.Timbre.CFDIRelacionados.TipoRelacion = "03" + Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Devolución aplicada a Ingreso" + End If + End If + End If + End If + + 'SI ES TIPO RELACION 07- APLICACION DE ANTICIPOS + If dtVentas(0)("CveTipoRelacion").ToString.ToEntero = 7 Then + Dim RowTipoRelacion As DataRow = GlobalDTVtaTiposRelacion().FiltroPrimero($"CveTipoRelacion = {dtVentas(0)("CveTipoRelacion").ToString.ToEntero}") + + Vta.Timbre.CFDIRelacionados.TipoRelacion = RowTipoRelacion("SATClaveTipoRelacion").ToString() + Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = RowTipoRelacion("SATTipoRelacion").ToString() + + If ObjVentas.GetVentasRelacionadas(CveVenta, UsuarioActual.CveEmpresa) Then + Vta.DtDocumentosRelacionados = ObjVentas.DtResultados.FiltraParametros("FolioFiscal IS NOT NULL") + End If + End If + + End If + + End If + ObjVentas.Dispose() + + If Not IsNothing(Vta) Then + Dim Archivo As New System.IO.FileInfo(PathArchivo) + + Dim Guardar As Boolean = If(GuardarPDF, True, If(AplicaPagare = "1", False, True)) + + Dim CveTimbreCartaPorteVenta As Integer = -1 + Dim CartaPorte As Modelos.MSubReportData = Nothing + 'SI EL ARCHIVO NO EXISTE O SE VA REGENERA EL PDF, SE DEBEN LLENAR LOS DATOS + If Not Archivo.Exists OrElse RegenerarPDF OrElse UsarStimul Then + If UsuarioActual.CveEmpresa = 13 AndAlso Vta.TipoDocto = "Ing" Then + Using ObjGral As New ClsGenerales + If ObjGral.GetGralTimbre(-1, "Ing", MinFecha, MaxFecha, 0, UsuarioActual.CveEmpresa, -1, CveVenta:=CveVenta) AndAlso ObjGral.DtResultados.Rows.Count > 0 Then + Dim RowCP As DataRow = ObjGral.DtResultados.Rows(0) + CveTimbreCartaPorteVenta = RowCP("CveTimbre").ToString().ToEntero() + End If + End Using + + If CveTimbreCartaPorteVenta > 0 Then + CartaPorte = PreParaImpresionCartaPorte(CveTimbreCartaPorteVenta, AplicaSubReporte:=True) + Else + CartaPorte = New Modelos.MSubReportData() + CartaPorte.Parametros.Add(New ReportParameter($"TieneCartaPorte", "False")) + End If + Else + If UsuarioActual.CveEmpresa = 13 AndAlso Vta.TipoDocto.Contiene("Egs", "Ant") Then + CartaPorte = New Modelos.MSubReportData() + CartaPorte.Parametros.Add(New ReportParameter($"TieneCartaPorte", "False")) + End If + End If + Else + If UsuarioActual.CveEmpresa = 13 AndAlso Vta.TipoDocto.Contiene("Egs", "Ant") Then + CartaPorte = New Modelos.MSubReportData() + CartaPorte.Parametros.Add(New ReportParameter($"TieneCartaPorte", "False")) + End If + End If + + If UsarStimul Then + Dim bytesPDF = PdfFactura(Vta, AplicaPagare:=AplicaPagare, Guardar:=True, SubReportData:=CartaPorte, UsarStimul:=UsarStimul) + If DescargarArchivo Then + ImprimirbytesPDF(bytesPDF, Vta.SerieFolio, "PDF") + End If + + Else + If Archivo.Exists Then + If RegenerarPDF Then + Archivo.Delete() + Dim bytesPDF = PdfFactura(Vta, AplicaPagare:=AplicaPagare, Guardar:=True, SubReportData:=CartaPorte, RegenerarQR:=True) + If DescargarArchivo Then + ImprimirbytesPDF(bytesPDF, Vta.SerieFolio, "PDF") + End If + + Vta = Nothing + Else + If DescargarArchivo Then + HttpContext.Current.Response.Clear() + HttpContext.Current.Response.ClearContent() + HttpContext.Current.Response.ContentType = If(IO.Path.GetExtension(Archivo.Name) = ".txt", "text/plain", "application/pdf") + HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" & Archivo.Name) + HttpContext.Current.Response.AddHeader("Content-Length", Archivo.Length.ToString()) + HttpContext.Current.Response.TransmitFile(PathArchivo) + 'HttpContext.Current.Response.Flush() + HttpContext.Current.Response.End() + End If + + Archivo = Nothing + End If + Else + Dim bytesPDF = PdfFactura(Vta, AplicaPagare:=AplicaPagare, Guardar:=Guardar, SubReportData:=CartaPorte) + If DescargarArchivo Then + ImprimirbytesPDF(bytesPDF, Vta.SerieFolio, "PDF") + End If + + Vta = Nothing + End If + End If + End If + End Sub + Protected Sub ImprimeFormatoCartaPorteTimbrado(CveTimbre As Integer) + Dim resp As Modelos.MSubReportData = PreParaImpresionCartaPorte(CveTimbre) + If resp.DataSources.Count > 0 AndAlso resp.Parametros.Count > 0 Then + ImprimirPDF("Empresas/Grales/Formatos/CartaPorteTimbrado.rdlc", resp.DataSources, resp.Parametros, resp.SerieFolio) + End If + End Sub + Private Function PreParaImpresionCartaPorte(CveTimbre As Integer, Optional AplicaSubReporte As Boolean = False) As Modelos.MSubReportData + Dim retorno As New Modelos.MSubReportData + retorno.Nombre = "CartaPorte" + Try + If CveTimbre > 0 Then + Dim params As New List(Of ReportParameter) + '01 Autotransporte Federal + '02 Transporte Marítimo + '03 Transporte Aéreo + '04 Transporte Ferroviario + '05 Ducto + Dim HtTransporte As New Hashtable() + HtTransporte.Add("01", "Autotransporte Federal") + HtTransporte.Add("02", "Transporte Marítimo") + HtTransporte.Add("03", "Transporte Aéreo") + HtTransporte.Add("04", "Transporte Ferroviario") + HtTransporte.Add("05", "Ducto") + + 'EMISOR + Dim LugarExpedicion As String = "" + Dim ImgCBB As String = "" + Dim ImgCCP As String = "" + 'COMPROBANTE + Dim SerieFolio As String = "" + Dim Telefono As String = "" + Dim SubTotal As Decimal = 0 + Dim Descuentos As Decimal = 0 + Dim Total As Decimal = 0 + 'DATOS DEL CLIENTE + Dim ClienteRFC As String = "" + Dim ClienteNombre As String = "" + Dim ClienteUsoCFDi As String = "" + + 'TRANSPORTE + Dim MedioTransporte As String = "" + Dim TransporteInternacional As String = "" + Dim PermisoSTCC As String = "" + Dim NumPermiso As String = "" + Dim AseguradoraRespCivil As String = "" + Dim NumPolizaSeguroRespCivil As String = "" + Dim NombreAseguradoraMedioAmbiente As String = "" + Dim NumPolizaSeguroMedioAmbiente As String = "" + Dim NombreAseguradoraCarga As String = "" + Dim NumPolizaSeguroCarga As String = "" + + Dim RemolquePlaca1 As String = "" + Dim RemolquePlaca2 As String = "" + Dim RemolqueSubtimo1 As String = "" + Dim RemolqueSubtimo2 As String = "" + + Dim PlacaVM As String = "" + Dim AnioModeloVM As String = "" + Dim PesoBrutoVehicular As String = "" + 'TIMBRADO + Dim FolioFiscal As String = "" + Dim NoCertificadoSAT As String = "" + Dim CadenaOriginal As String = "" + Dim NoSerieCertificado As String = "" + Dim FechaCertificacion As DateTime = Nothing + Dim SelloCFDi As String = "" + Dim SelloSAT As String = "" + Dim TipoDocto As String = "" + Dim PermisoSCTR1 As String = "" + Dim PermisoSCTR2 As String = "" + Dim ConfATR1 As String = "" + Dim ConfATR2 As String = "" + + + Dim ObjInv As New ClsGenerales + + If ObjInv.GetGralTimbre(CveTimbre, "-1", MinFecha, MaxFecha, -1, UsuarioActual.CveEmpresa, -1) Then + If ObjInv.DtResultados.Rows.Count > 0 Then + Dim Dr As DataRow = ObjInv.DtResultados.Rows(0) + If Dr IsNot Nothing Then + SerieFolio = Dr("SerieFolio").ToString + Telefono = Dr("FiguraTelefono").ToString + TipoDocto = Dr("TipoDocto").ToString + + If UsuarioActual.CveEmpresa = 13 Then + PermisoSCTR1 = Dr("PermisoSCTR1").ToString + PermisoSCTR2 = Dr("PermisoSCTR2").ToString + ConfATR1 = Dr("ConfATR1").ToString + ConfATR2 = Dr("ConfATR2").ToString + End If + + End If + End If + End If + ObjInv.Dispose() + + retorno.SerieFolio = SerieFolio + + Dim DtConceptos As New DataTable() + DtConceptos.Columns.Add(New DataColumn("Cantidad", GetType(Decimal))) + DtConceptos.Columns.Add(New DataColumn("Unidad", GetType(String))) + DtConceptos.Columns.Add(New DataColumn("Descripcion", GetType(String))) + DtConceptos.Columns.Add(New DataColumn("ValorUnitario", GetType(Decimal))) + DtConceptos.Columns.Add(New DataColumn("Importe", GetType(Decimal))) + + Dim DtUbicaciones As New DataTable() + DtUbicaciones.Columns.Add(New DataColumn("Distancia", GetType(String))) + DtUbicaciones.Columns.Add(New DataColumn("TipoUbicacion", GetType(String))) + DtUbicaciones.Columns.Add(New DataColumn("RFC", GetType(String))) + DtUbicaciones.Columns.Add(New DataColumn("Nombre", GetType(String))) + DtUbicaciones.Columns.Add(New DataColumn("FechaHoraSalida", GetType(DateTime))) + DtUbicaciones.Columns.Add(New DataColumn("Direccion", GetType(String))) + + Dim DtMercancias As New DataTable() + DtMercancias.Columns.Add(New DataColumn("Cantidad", GetType(Decimal))) + DtMercancias.Columns.Add(New DataColumn("UnidadMedida", GetType(String))) + DtMercancias.Columns.Add(New DataColumn("Descripcion", GetType(String))) + DtMercancias.Columns.Add(New DataColumn("PesoEnKg", GetType(String))) + + DtMercancias.Columns.Add(New DataColumn("CveMaterialPeligroso", GetType(String))) + DtMercancias.Columns.Add(New DataColumn("Embalaje", GetType(String))) + + DtMercancias.Columns.Add(New DataColumn("SectorCOFEPRIS", GetType(String))) + DtMercancias.Columns.Add(New DataColumn("NombreIngredienteActivo", GetType(String))) + DtMercancias.Columns.Add(New DataColumn("NomQuimico", GetType(String))) + DtMercancias.Columns.Add(New DataColumn("DenominacionGenerica", GetType(String))) + DtMercancias.Columns.Add(New DataColumn("DenominacionDistintiva", GetType(String))) + DtMercancias.Columns.Add(New DataColumn("Fabricante", GetType(String))) + DtMercancias.Columns.Add(New DataColumn("FormaFarmaceutica", GetType(String))) + DtMercancias.Columns.Add(New DataColumn("CondicionesTransporte", GetType(String))) + DtMercancias.Columns.Add(New DataColumn("RegistroSanitarioAutorizacion", GetType(String))) + DtMercancias.Columns.Add(New DataColumn("PermisoImportacion", GetType(String))) + DtMercancias.Columns.Add(New DataColumn("FolioImportacionVUCEM", GetType(String))) + DtMercancias.Columns.Add(New DataColumn("NumCAS", GetType(String))) + DtMercancias.Columns.Add(New DataColumn("RazonSocialEmpImportacion", GetType(String))) + DtMercancias.Columns.Add(New DataColumn("NumRegistroPlagCOFEPRIS", GetType(String))) + DtMercancias.Columns.Add(New DataColumn("DatosFabricante", GetType(String))) + DtMercancias.Columns.Add(New DataColumn("DatosFormulador", GetType(String))) + DtMercancias.Columns.Add(New DataColumn("DatosMaquilador", GetType(String))) + DtMercancias.Columns.Add(New DataColumn("UsoAutorizado", GetType(String))) + + + Dim DtOperadores As New DataTable() + DtOperadores.Columns.Add(New DataColumn("RFC", GetType(String))) + DtOperadores.Columns.Add(New DataColumn("NumLicencia", GetType(String))) + DtOperadores.Columns.Add(New DataColumn("NombreOperador", GetType(String))) + + Dim DTRelacionados As New DataTable() + DTRelacionados.Columns.Add(New DataColumn("Relacion", GetType(String))) + DTRelacionados.Columns.Add(New DataColumn("UUID", GetType(String))) + + Dim XMLDoc As New XmlDocument + Dim Path As String = String.Format("{0}\{1}\{2}\{3}.{4}", UsuarioActual.Empresa.Ruta, "XML", TipoDocto, String.Format("{0}", SerieFolio), "xml") + Dim Archivo As New System.IO.FileInfo(Path) + + If Archivo.Exists Then + Try + XMLDoc.Load(Path) + Catch ex As Exception + Try + Dim oReader As New StreamReader(Path, Encoding.GetEncoding("ISO-8859-1")) + XMLDoc.Load(oReader) + oReader.Dispose() + Catch ex2 As Exception + GuardaLog("Error al intentar leer el XML del SAT. Error:" & ex2.ToString()) + End Try + End Try + End If + + If XMLDoc IsNot Nothing AndAlso Archivo.Exists Then + + Dim RutaCBB As String = String.Format("{0}\CBB\{1}.jpg", UsuarioActual.Empresa.Ruta, SerieFolio) + Dim ImagenCBB As New System.IO.FileInfo(RutaCBB) + + Dim RutaCCP As String = String.Format("{0}\CBB\{1}_CCP.jpg", UsuarioActual.Empresa.Ruta, SerieFolio) + Dim ImagenCCP As New System.IO.FileInfo(RutaCCP) + + 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) + Dim Version As String = ValorXML(XMLDoc.DocumentElement, "version") + Dim VersionCCP As String = "" + Dim PrefijoCCP As String = "" + + 'Try + + ' 'XDocument doc = XDocument.Parse(Xml); + ' 'String Version = doc.Descendants("cartaporte30:CartaPorte").First().Attribute("version").Value; + + ' Dim NodoVersionCCP As XmlNode = XMLDoc.Descendants("cartaporte30:CartaPorte") + ' If NodoVersionCCP IsNot Nothing Then + ' VersionCCP = ValorXML(NodoVersionCCP, "version") + ' Else + ' VersionCCP = "2.0" + ' End If + 'Catch ex As Exception + + 'End Try + + + If 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 + + params.Add(New ReportParameter("CFDIVersion", Version)) + + 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") + namespaces.AddNamespace("cartaporte", "http://www.sat.gob.mx/CartaPorte") + namespaces.AddNamespace("cartaporte20", "http://www.sat.gob.mx/CartaPorte20") + namespaces.AddNamespace("cartaporte30", "http://www.sat.gob.mx/CartaPorte30") + + Dim Nodos30 = XMLDoc.SelectSingleNode("//cartaporte30:CartaPorte", namespaces) + Dim Nodos20 = XMLDoc.SelectSingleNode("//cartaporte20:CartaPorte", namespaces) + + If Nodos30 IsNot Nothing Then + VersionCCP = "3.0" + PrefijoCCP = "cartaporte30" + End If + + If Nodos20 IsNot Nothing Then + VersionCCP = "2.0" + PrefijoCCP = "cartaporte20" + End If + + params.Add(New ReportParameter("CartaPorteVersion", VersionCCP)) + + Dim nodeComprobante As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Comprobante", Prefijo), namespaces) + If nodeComprobante IsNot Nothing Then + LugarExpedicion = ValorXML(nodeComprobante, "LugarExpedicion") + SubTotal = ValorXML(nodeComprobante, "SubTotal").ToDecimal() + Total = ValorXML(nodeComprobante, "Total").ToDecimal() + End If + + Dim nodeCliente As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Receptor", Prefijo), namespaces) + + If nodeCliente IsNot Nothing Then + ClienteRFC = ValorXML(nodeCliente, "RFC") + ClienteNombre = ValorXML(nodeCliente, "Nombre") + Dim UsoCFDI As String = ValorXML(nodeCliente, "UsoCFDI") + ClienteUsoCFDi = String.Format("{0} - {1}", UsoCFDI, GlobalDTSATUsosCFDI().FiltroPrimeroValor("Descripcion", String.Format("UsoCFDI = '{0}'", UsoCFDI))) + End If + + Dim nodeConceptos As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Conceptos", Prefijo), namespaces) + + If nodeConceptos IsNot Nothing Then + For Each node As XmlNode In nodeConceptos.ChildNodes + Dim Row As DataRow = DtConceptos.NewRow + + Row("Cantidad") = ValorXML(node, "Cantidad", "") + Row("Unidad") = ValorXML(node, "Unidad", "") + Row("Descripcion") = ValorXML(node, "Descripcion", "") + Row("ValorUnitario") = ValorXML(node, "ValorUnitario", "") + Row("Importe") = ValorXML(node, "Importe", "") + DtConceptos.Rows.Add(Row) + Next + End If + Dim nodeComp As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Comprobante/{0}:Complemento", Prefijo), namespaces) + + Dim nodeCartaPorte As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:CartaPorte", PrefijoCCP), namespaces) + If nodeCartaPorte IsNot Nothing Then + TransporteInternacional = ValorXML(nodeCartaPorte, "TranspInternac", "") + End If + + Dim nodeAutotransporteFederal As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:Autotransporte", PrefijoCCP), namespaces) + If nodeAutotransporteFederal IsNot Nothing Then + PermisoSTCC = ValorXML(nodeAutotransporteFederal, "PermSCT", "") + NumPermiso = ValorXML(nodeAutotransporteFederal, "NumPermisoSCT", "") + End If + + Dim nodeIdentificacionVehicular As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:IdentificacionVehicular", PrefijoCCP), namespaces) + If nodeIdentificacionVehicular IsNot Nothing Then + PlacaVM = ValorXML(nodeIdentificacionVehicular, "PlacaVM", "") + AnioModeloVM = ValorXML(nodeIdentificacionVehicular, "AnioModeloVM", "") + PesoBrutoVehicular = ValorXML(nodeIdentificacionVehicular, "PesoBrutoVehicular", "") + End If + + Dim nodeSeguros As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:Seguros", PrefijoCCP), namespaces) + If nodeIdentificacionVehicular IsNot Nothing Then + AseguradoraRespCivil = ValorXML(nodeSeguros, "AseguraRespCivil", "") + NumPolizaSeguroRespCivil = ValorXML(nodeSeguros, "PolizaRespCivil", "") + + 'Por Definir de donde sale + NombreAseguradoraMedioAmbiente = ValorXML(nodeSeguros, "AseguraMedAmbiente", "") + NumPolizaSeguroMedioAmbiente = ValorXML(nodeSeguros, "PolizaMedAmbiente", "") + NombreAseguradoraCarga = ValorXML(nodeSeguros, "AseguraCarga", "") + NumPolizaSeguroCarga = ValorXML(nodeSeguros, "PolizaCarga", "") + End If + + + Dim nodeRemolques As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:Remolques", PrefijoCCP), namespaces) + + If nodeRemolques IsNot Nothing Then + If nodeRemolques.ChildNodes.Count = 1 Then + RemolquePlaca1 = ValorXML(nodeRemolques.ChildNodes(0), "Placa", "") + RemolqueSubtimo1 = ValorXML(nodeRemolques.ChildNodes(0), "SubTipoRem", "") + ElseIf nodeRemolques.ChildNodes.Count > 1 Then + RemolquePlaca1 = ValorXML(nodeRemolques.ChildNodes(0), "Placa", "") + RemolqueSubtimo1 = ValorXML(nodeRemolques.ChildNodes(0), "SubTipoRem", "") + RemolquePlaca2 = ValorXML(nodeRemolques.ChildNodes(1), "Placa", "") + RemolqueSubtimo2 = ValorXML(nodeRemolques.ChildNodes(1), "SubTipoRem", "") + End If + End If + + 'Dim nodeFiguraTransporte As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:FiguraTransporte", "cartaporte20"), namespaces) + 'If nodeFiguraTransporte IsNot Nothing Then + ' Dim CveTransporte As String = ValorXML(nodeFiguraTransporte, "TipoFigura", "") + ' MedioTransporte = String.Format("{0} - {1}", CveTransporte, HtTransporte(CveTransporte).ToString()) + 'End If + + Dim nodeMercancias As XmlNodeList = nodeComp.SelectNodes(String.Format("//{0}:Mercancia", PrefijoCCP), namespaces) + For Each node As XmlNode In nodeMercancias + Dim Row As DataRow = DtMercancias.NewRow + + Row("Cantidad") = ValorXML(node, "Cantidad", "") + Row("UnidadMedida") = ValorXML(node, "Unidad", "") + Row("Descripcion") = ValorXML(node, "Descripcion", "") + Row("PesoEnKg") = ValorXML(node, "PesoEnKg", "") + + Row("CveMaterialPeligroso") = ValorXML(node, "CveMaterialPeligroso", "") + Row("Embalaje") = ValorXML(node, "Embalaje", "") + + Row("SectorCOFEPRIS") = ValorXML(node, "SectorCOFEPRIS", "") + Row("NombreIngredienteActivo") = ValorXML(node, "NombreIngredienteActivo", "") + Row("NomQuimico") = ValorXML(node, "NomQuimico", "") + Row("DenominacionGenerica") = ValorXML(node, "DenominacionGenerica", "") + Row("DenominacionDistintiva") = ValorXML(node, "DenominacionDistintiva", "") + Row("Fabricante") = ValorXML(node, "Fabricante", "") + Row("FormaFarmaceutica") = ValorXML(node, "FormaFarmaceutica", "") + Row("CondicionesTransporte") = ValorXML(node, "CondicionesTransporte", "") + Row("RegistroSanitarioAutorizacion") = ValorXML(node, "RegistroSanitarioAutorizacion", "") + Row("PermisoImportacion") = ValorXML(node, "PermisoImportacion", "") + Row("FolioImportacionVUCEM") = ValorXML(node, "FolioImportacionVUCEM", "") + Row("NumCAS") = ValorXML(node, "NumCAS", "") + Row("RazonSocialEmpImportacion") = ValorXML(node, "RazonSocialEmpImportacion", "") + Row("NumRegistroPlagCOFEPRIS") = ValorXML(node, "NumRegistroPlagCOFEPRIS", "") + Row("DatosFabricante") = ValorXML(node, "DatosFabricante", "") + Row("DatosFormulador") = ValorXML(node, "DatosFormulador", "") + Row("DatosMaquilador") = ValorXML(node, "DatosMaquilador", "") + Row("UsoAutorizado") = ValorXML(node, "UsoAutorizado", "") + + DtMercancias.Rows.Add(Row) + Next + + Dim nodeMercanciaPadre As XmlNodeList = nodeComp.SelectNodes(String.Format("//{0}:Mercancias", PrefijoCCP), namespaces) + If UsuarioActual.CveEmpresa = 13 AndAlso nodeMercanciaPadre IsNot Nothing Then + Dim PesoNetoTotal As String = ValorXML(nodeMercanciaPadre(0), "PesoNetoTotal", "") + Dim UnidadPeso As String = ValorXML(nodeMercanciaPadre(0), "UnidadPeso", "") + Dim NumTotalMercancias As String = ValorXML(nodeMercanciaPadre(0), "NumTotalMercancias", "") + + params.Add(New ReportParameter("PesoNetoTotal", PesoNetoTotal)) + params.Add(New ReportParameter("UnidadPeso", UnidadPeso)) + params.Add(New ReportParameter("NumTotalMercancias", NumTotalMercancias)) + End If + + Dim nodeOperadores As XmlNodeList = nodeComp.SelectNodes(String.Format("//{0}:TiposFigura", PrefijoCCP), namespaces) + For Each node As XmlNode In nodeOperadores + Dim Row As DataRow = DtOperadores.NewRow + + Row("RFC") = ValorXML(node, "RFCFigura", "") + Row("NumLicencia") = ValorXML(node, "NumLicencia", "") + Row("NombreOperador") = ValorXML(node, "NombreFigura", "") + + DtOperadores.Rows.Add(Row) + Next + + Dim DistanciaTotal As Decimal = 0 + Dim nodeUbicaciones As XmlNodeList = nodeComp.SelectNodes(String.Format("//{0}:Ubicacion", PrefijoCCP), namespaces) + For Each node As XmlNode In nodeUbicaciones + Dim Row As DataRow = DtUbicaciones.NewRow + + Row("Distancia") = ValorXML(node, "DistanciaRecorrida", "") + DistanciaTotal += Row("Distancia").ToString().ToDecimal() + Row("TipoUbicacion") = ValorXML(node, "TipoUbicacion", "") + Row("FechaHoraSalida") = ValorXML(node, "FechaHoraSalidaLlegada", "") + Row("RFC") = ValorXML(node, "RFCRemitenteDestinatario", "") + Row("Nombre") = ValorXML(node, "NombreRemitenteDestinatario", "") + + Dim nodeDomicilio As XmlNode = node.ChildNodes.Cast(Of XmlNode).FirstOrDefault(Function(x) x.Name = $"{PrefijoCCP}:Domicilio") 'node.SelectSingleNode(String.Format("//{0}:Domicilio", "cartaporte"), namespaces) + If nodeDomicilio IsNot Nothing Then + + Dim Estado As String = "" + Dim Municipio As String = "" + Dim Colonia As String = "" + Dim calle As String = ValorXML(nodeDomicilio, "Calle", "") + Dim CP As String = ValorXML(nodeDomicilio, "CodigoPostal", "") + + Dim dr As DataRow = GlobalDTGralColonias(ValorXML(nodeDomicilio, "Estado", ""), ValorXML(nodeDomicilio, "Municipio", ""), ValorXML(nodeDomicilio, "Colonia", "")).FiltroPrimero("") + If dr IsNot Nothing Then + Estado = dr("NombreEstado").ToString + Municipio = dr("NombreMunicipio").ToString + Colonia = dr("NombreAsentamiento").ToString + End If + Row("Direccion") = String.Format("{0} Col.{1},{2},{3}. CP {4}", calle, Colonia, Municipio, Estado, CP) + End If + + + DtUbicaciones.Rows.Add(Row) + Next + + If UsuarioActual.CveEmpresa = 13 Then + params.Add(New ReportParameter("DistanciaTotal", DistanciaTotal.ToString())) + End If + + Dim nodeRelacion As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:CfdiRelacionados", Prefijo), namespaces) + + If nodeRelacion IsNot Nothing Then + Dim RelacionCodigo As String = ValorXML(nodeRelacion, "TipoRelacion") + Dim Relacion As String = "" + + Select Case RelacionCodigo + Case "01" + Relacion = "01 - Nota de crédito de los documentos relacionados" + Case "02" + Relacion = "02 - Nota de débito de los documentos relacionados" + Case "03" + Relacion = "03 - Devolución de mercancía sobre facturas o traslados previos" + Case "04" + Relacion = "04 - Sustitución de los CFDI previos" + Case "05" + Relacion = "05 - Traslados de mercancias facturados previamente" + Case "06" + Relacion = "06 - Factura generada por los traslados previos" + Case "07" + Relacion = "07 - CFDI por aplicación de anticipo" + Case "08" + Relacion = "08 - Factura generada por pagos en parcialidades" + Case "09" + Relacion = "09 - Factura generada por pagos diferidos" + End Select + + Dim nodoDocumentosRelacionados As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:CfdiRelacionados", Prefijo), namespaces) + For Each node As XmlNode In nodoDocumentosRelacionados + + Dim nRow As DataRow = DTRelacionados.NewRow + nRow("Relacion") = Relacion + + Try + Dim nodoUUID As XmlNode = node.ChildNodes.Cast(Of XmlNode).FirstOrDefault(Function(x) x.Name = "cfdi:CfdiRelacionado") + nRow("UUID") = ValorXML(nodoUUID, "UUID", "") + Catch ex As Exception + nRow("UUID") = "" + End Try + + DTRelacionados.Rows.Add(nRow) + Next + End If + + Dim nodeTFD As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:TimbreFiscalDigital", "tfd"), namespaces) + If nodeTFD IsNot Nothing Then + FolioFiscal = ValorXML(nodeTFD, "UUID", "") + NoSerieCertificado = ValorXML(nodeTFD, "NoCertificadoSAT", "") + FechaCertificacion = ValorXML(nodeTFD, "FechaTimbrado", "").ToDateTime + SelloCFDi = ValorXML(nodeTFD, "SelloCFD", "") + SelloSAT = ValorXML(nodeTFD, "SelloSAT", "") + NoCertificadoSAT = ValorXML(nodeTFD, "NoCertificadoSAT", "") + + CadenaOriginal = "||1.0|" + FolioFiscal + "|" + FechaCertificacion.ToString("yyyy-MM-dd") + "T" + FechaCertificacion.ToString("HH:mm:ss") + "|" + SelloCFDi + "|" + NoSerieCertificado + "||" + End If + + If Not ImagenCBB.Exists Then + Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar() + CBB.GenerarCBB(UsuarioActual.Empresa.RFC, ClienteRFC, Total, FolioFiscal, RutaCBB) + End If + + + ImagenCBB = New System.IO.FileInfo(RutaCBB) + + If ImagenCBB.Exists Then + ImgCBB = String.Format("file://{0}", ImagenCBB.FullName) + Else + ImgCBB = "" + End If + + + + 'FIXME OICCHECAR DESPUES DE SINCRONIZAR TIMBRADO + 'If Not ImagenCCP.Exists Then + ' Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar() + ' CBB.GenerarCBB(UsuarioActual.Empresa.RFC, ClienteRFC, Total, FolioFiscal, RutaCBB) + 'End If + + + ImagenCCP = New System.IO.FileInfo(RutaCCP) + + If ImagenCCP.Exists Then + ImgCCP = String.Format("file://{0}", ImagenCCP.FullName) + Else + ImgCCP = "" + End If + + End If + + If DtConceptos.Rows.Count > 0 Then + + params.Add(New ReportParameter("LogoPath", RutaImagenLogo)) + 'EMPRESA + params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) + params.Add(New ReportParameter("RegimenFiscal", UsuarioActual.Empresa.Regimen)) + params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) + params.Add(New ReportParameter("FechaImpresion", NowADS().ToDateTime.ToShortDateString)) + params.Add(New ReportParameter("DomicilioFiscal", $"{UsuarioActual.Empresa.Direccion}, {UsuarioActual.Empresa.Colonia}, {UsuarioActual.Empresa.Localidad}, {UsuarioActual.Empresa.Estado}, Tel. {Telefono}")) + params.Add(New ReportParameter("SerieFolio", SerieFolio)) + params.Add(New ReportParameter("RFC", UsuarioActual.Empresa.RFC)) + params.Add(New ReportParameter("DomicilioExpedicion", LugarExpedicion)) + 'CLIENTE + params.Add(New ReportParameter("ClienteNombre", ClienteNombre)) + params.Add(New ReportParameter("ClienteRFC", ClienteRFC)) + params.Add(New ReportParameter("UsoCFDi", ClienteUsoCFDi)) + 'TRANSPORTE + params.Add(New ReportParameter("MedioTransporte", MedioTransporte)) + params.Add(New ReportParameter("TransporteInternacional", TransporteInternacional)) + params.Add(New ReportParameter("PermisoSTCC", PermisoSTCC)) + params.Add(New ReportParameter("NumPermiso", NumPermiso)) + + params.Add(New ReportParameter("Aseguradora", AseguradoraRespCivil)) + params.Add(New ReportParameter("NumPoliza", NumPolizaSeguroRespCivil)) + + params.Add(New ReportParameter("NombreAseguradoraMedioAmbiente", NombreAseguradoraMedioAmbiente)) + params.Add(New ReportParameter("NumPolizaSeguroMedioAmbiente", NumPolizaSeguroMedioAmbiente)) + + params.Add(New ReportParameter("NombreAseguradoraCarga", NombreAseguradoraCarga)) + params.Add(New ReportParameter("NumPolizaSeguroCarga", NumPolizaSeguroCarga)) + + params.Add(New ReportParameter("PlacaVM", PlacaVM)) + params.Add(New ReportParameter("AnioVM", AnioModeloVM)) + params.Add(New ReportParameter("PesoBrutoVehicular", PesoBrutoVehicular)) + + 'TIMBRADO + params.Add(New ReportParameter("FolioFiscal", FolioFiscal)) + params.Add(New ReportParameter("QR", ImgCBB)) + params.Add(New ReportParameter("QRCCP", ImgCCP)) + params.Add(New ReportParameter("SelloCFDI", SelloCFDi)) + params.Add(New ReportParameter("CertificadoContribuyente", NoCertificadoSAT)) + params.Add(New ReportParameter("CadenaOriginal", CadenaOriginal)) + params.Add(New ReportParameter("SerieCertificadoSAT", NoSerieCertificado)) + params.Add(New ReportParameter("FechaCertificacion", FechaCertificacion.ToString("dd/MM/yyyy HH:mm:ss"))) + params.Add(New ReportParameter("SelloSAT", SelloSAT)) + 'TOTALES + params.Add(New ReportParameter("SubTotal", SubTotal.ToString())) + params.Add(New ReportParameter("Descuentos", Descuentos.ToString())) + params.Add(New ReportParameter("Total", Total.ToString())) + + params.Add(New ReportParameter("RemolquePlaca1", RemolquePlaca1)) + params.Add(New ReportParameter("RemolqueSubtimo1", RemolqueSubtimo1)) + + params.Add(New ReportParameter("RemolquePlaca2", RemolquePlaca2)) + params.Add(New ReportParameter("RemolqueSubtimo2", RemolqueSubtimo2)) + + If UsuarioActual.CveEmpresa = 13 Then + params.Add(New ReportParameter("PermisoSCTRemolque1", PermisoSCTR1)) + params.Add(New ReportParameter("PermisoSCTRemolque2", PermisoSCTR2)) + params.Add(New ReportParameter("ConfATR1", ConfATR1)) + params.Add(New ReportParameter("ConfATR2", ConfATR2)) + End If + + + + ' [@CertificadoContribuyente] + '[@CadenaOriginal] + + Dim lrds As New List(Of ReportDataSource) + + Dim rds As New ReportDataSource + rds.Name = "DataSet1" + rds.Value = DtConceptos + lrds.Add(rds) + + Dim rds2 As New ReportDataSource + rds2.Name = "DataSet2" + rds2.Value = DtUbicaciones + lrds.Add(rds2) + + Dim rds3 As New ReportDataSource + rds3.Name = "DataSet3" + rds3.Value = DtMercancias + lrds.Add(rds3) + + Dim rds4 As New ReportDataSource + rds4.Name = "DataSet4" + rds4.Value = DtOperadores + lrds.Add(rds4) + + + Dim rds5 As New ReportDataSource + rds5.Name = "DataSet5" + rds5.Value = DTRelacionados + lrds.Add(rds5) + + If AplicaSubReporte Then + For Each parametro As ReportParameter In params + retorno.Parametros.Add(New ReportParameter($"SRP_{parametro.Name}", parametro.Values.Item(0))) + Next + retorno.Parametros.Add(New ReportParameter($"TieneCartaPorte", "True")) + Else + retorno.Parametros.AddRange(params) + End If + + retorno.DataSources.AddRange(lrds) + End If + + End If + Catch ex As Exception + OnError("Ocurrió un error al generar el pdf de la carta porte", ex) + End Try + Return retorno + End Function + Public Function PdfFactura(ByRef Vta As Modelos.Factura, Optional AplicaPagare As String = "0", Optional Guardar As Boolean = True, Optional SubReportData As Modelos.MSubReportData = Nothing, Optional UsarStimul As Boolean = False, Optional RegenerarQR As Boolean = False) As Byte() Dim retorno As Byte() = Nothing ' Dim ObjVentas As New ClsVentas diff --git a/Ashx/SIGDesc.ashx b/Ashx/SIGDesc.ashx new file mode 100644 index 000000000..43f9264fe --- /dev/null +++ b/Ashx/SIGDesc.ashx @@ -0,0 +1,49 @@ +<%@ WebHandler Language="VB" Class="SIGDesc" %> + +Option Strict Off +Imports System.Data +Imports System.IO +Imports Extensiones +Imports Microsoft.Reporting.WebForms +Imports Newtonsoft.Json + +Public Class SIGDesc : Implements IHttpHandler, IRequiresSessionState + + ReadOnly Property UsuarioActual(ByVal context As HttpContext) As Usuario + Get + UsuarioActual = DirectCast(context.Session("UsuarioSIG"), Usuario) + End Get + End Property + + Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest + If context.Request("metodo") IsNot Nothing AndAlso context.Request("metodo").ToString() = "descargarPDFVenta" Then + Dim CveVenta As Integer = context.Request("CveVenta").ToEntero() + DescargarPDFVenta(context, CveVenta) + End If + + End Sub + + Private Sub DescargarPDFVenta(ByVal context As HttpContext, CveVenta As Integer) + Dim usuario As Usuario = UsuarioActual(context) + If Not IsNothing(usuario) Then + Dim ObjFactura As New Modelos.Factura(usuario, CveVenta, usuario.CveEmpresa, CargaDTDetalle:=False, CargaDatosCliente:=False, CargaDatosRelacionados:=False, VerificaAlmacen:=False) + + Dim ArchivoPDF = String.Format("{0}Empresas\{1}\PDF\{2}\{3}.pdf", ModExtensiones.DirectorioBaseEmpresas, usuario.CveEmpresa, ObjFactura.TipoDocto, ObjFactura.SerieFolio) + Dim FileInfo As FileInfo = New FileInfo(ArchivoPDF) + If FileInfo.Exists Then + context.Response.ContentType = "application/pdf" + context.Response.Flush() + context.Response.WriteFile(FileInfo.FullName) + context.Response.End() + End If + FileInfo = Nothing + End If + End Sub + + Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable + Get + Return False + End Get + End Property + +End Class \ No newline at end of file diff --git a/Compras/PopUpVerFactura.aspx.vb b/Compras/PopUpVerFactura.aspx.vb index 6d8c2930f..a5c3a12c6 100644 --- a/Compras/PopUpVerFactura.aspx.vb +++ b/Compras/PopUpVerFactura.aspx.vb @@ -1338,7 +1338,7 @@ Partial Class PopUpVerFactura Dim RegenerarPDF As Boolean = UrlParametros("REGENERAR") IsNot Nothing AndAlso UrlParametros("REGENERAR").ToString() = "1" Dim STIMUL As Boolean = UrlParametros("STIMULSOFT") IsNot Nothing AndAlso UrlParametros("STIMULSOFT").ToString() = "1" - imprimirFacturaVenta(UrlParametros("CVEVENTA").ToString.ToEntero, AplicaPagare, GuardarPDF:=Guardar, RegenerarPDF:=RegenerarPDF, UsarStimul:=STIMUL) + GenerarPDFVenta(UrlParametros("CVEVENTA").ToString.ToEntero, AplicaPagare, GuardarPDF:=Guardar, RegenerarPDF:=RegenerarPDF, UsarStimul:=STIMUL) End If End If @@ -2116,618 +2116,7 @@ Partial Class PopUpVerFactura End If End Function - Private Sub ImprimeFormatoCartaPorteTimbrado(CveTimbre As Integer) - Dim resp As Modelos.MSubReportData = PreParaImpresionCartaPorte(CveTimbre) - If resp.DataSources.Count > 0 AndAlso resp.Parametros.Count > 0 Then - ImprimirPDF("Empresas/Grales/Formatos/CartaPorteTimbrado.rdlc", resp.DataSources, resp.Parametros, resp.SerieFolio) - End If - End Sub - Private Function PreParaImpresionCartaPorte(CveTimbre As Integer, Optional AplicaSubReporte As Boolean = False) As Modelos.MSubReportData - Dim retorno As New Modelos.MSubReportData - retorno.Nombre = "CartaPorte" - Try - If CveTimbre > 0 Then - Dim params As New List(Of ReportParameter) - '01 Autotransporte Federal - '02 Transporte Marítimo - '03 Transporte Aéreo - '04 Transporte Ferroviario - '05 Ducto - Dim HtTransporte As New Hashtable() - HtTransporte.Add("01", "Autotransporte Federal") - HtTransporte.Add("02", "Transporte Marítimo") - HtTransporte.Add("03", "Transporte Aéreo") - HtTransporte.Add("04", "Transporte Ferroviario") - HtTransporte.Add("05", "Ducto") - - 'EMISOR - Dim LugarExpedicion As String = "" - Dim ImgCBB As String = "" - Dim ImgCCP As String = "" - 'COMPROBANTE - Dim SerieFolio As String = "" - Dim Telefono As String = "" - Dim SubTotal As Decimal = 0 - Dim Descuentos As Decimal = 0 - Dim Total As Decimal = 0 - 'DATOS DEL CLIENTE - Dim ClienteRFC As String = "" - Dim ClienteNombre As String = "" - Dim ClienteUsoCFDi As String = "" - - 'TRANSPORTE - Dim MedioTransporte As String = "" - Dim TransporteInternacional As String = "" - Dim PermisoSTCC As String = "" - Dim NumPermiso As String = "" - Dim AseguradoraRespCivil As String = "" - Dim NumPolizaSeguroRespCivil As String = "" - Dim NombreAseguradoraMedioAmbiente As String = "" - Dim NumPolizaSeguroMedioAmbiente As String = "" - Dim NombreAseguradoraCarga As String = "" - Dim NumPolizaSeguroCarga As String = "" - - Dim RemolquePlaca1 As String = "" - Dim RemolquePlaca2 As String = "" - Dim RemolqueSubtimo1 As String = "" - Dim RemolqueSubtimo2 As String = "" - - Dim PlacaVM As String = "" - Dim AnioModeloVM As String = "" - Dim PesoBrutoVehicular As String = "" - 'TIMBRADO - Dim FolioFiscal As String = "" - Dim NoCertificadoSAT As String = "" - Dim CadenaOriginal As String = "" - Dim NoSerieCertificado As String = "" - Dim FechaCertificacion As DateTime = Nothing - Dim SelloCFDi As String = "" - Dim SelloSAT As String = "" - Dim TipoDocto As String = "" - Dim PermisoSCTR1 As String = "" - Dim PermisoSCTR2 As String = "" - Dim ConfATR1 As String = "" - Dim ConfATR2 As String = "" - - - Dim ObjInv As New ClsGenerales - - If ObjInv.GetGralTimbre(CveTimbre, "-1", MinFecha, MaxFecha, -1, UsuarioActual.CveEmpresa, -1) Then - If ObjInv.DtResultados.Rows.Count > 0 Then - Dim Dr As DataRow = ObjInv.DtResultados.Rows(0) - If Dr IsNot Nothing Then - SerieFolio = Dr("SerieFolio").ToString - Telefono = Dr("FiguraTelefono").ToString - TipoDocto = Dr("TipoDocto").ToString - - If UsuarioActual.CveEmpresa = 13 Then - PermisoSCTR1 = Dr("PermisoSCTR1").ToString - PermisoSCTR2 = Dr("PermisoSCTR2").ToString - ConfATR1 = Dr("ConfATR1").ToString - ConfATR2 = Dr("ConfATR2").ToString - End If - - End If - End If - End If - ObjInv.Dispose() - - retorno.SerieFolio = SerieFolio - - Dim DtConceptos As New DataTable() - DtConceptos.Columns.Add(New DataColumn("Cantidad", GetType(Decimal))) - DtConceptos.Columns.Add(New DataColumn("Unidad", GetType(String))) - DtConceptos.Columns.Add(New DataColumn("Descripcion", GetType(String))) - DtConceptos.Columns.Add(New DataColumn("ValorUnitario", GetType(Decimal))) - DtConceptos.Columns.Add(New DataColumn("Importe", GetType(Decimal))) - - Dim DtUbicaciones As New DataTable() - DtUbicaciones.Columns.Add(New DataColumn("Distancia", GetType(String))) - DtUbicaciones.Columns.Add(New DataColumn("TipoUbicacion", GetType(String))) - DtUbicaciones.Columns.Add(New DataColumn("RFC", GetType(String))) - DtUbicaciones.Columns.Add(New DataColumn("Nombre", GetType(String))) - DtUbicaciones.Columns.Add(New DataColumn("FechaHoraSalida", GetType(DateTime))) - DtUbicaciones.Columns.Add(New DataColumn("Direccion", GetType(String))) - - Dim DtMercancias As New DataTable() - DtMercancias.Columns.Add(New DataColumn("Cantidad", GetType(Decimal))) - DtMercancias.Columns.Add(New DataColumn("UnidadMedida", GetType(String))) - DtMercancias.Columns.Add(New DataColumn("Descripcion", GetType(String))) - DtMercancias.Columns.Add(New DataColumn("PesoEnKg", GetType(String))) - - DtMercancias.Columns.Add(New DataColumn("CveMaterialPeligroso", GetType(String))) - DtMercancias.Columns.Add(New DataColumn("Embalaje", GetType(String))) - - DtMercancias.Columns.Add(New DataColumn("SectorCOFEPRIS", GetType(String))) - DtMercancias.Columns.Add(New DataColumn("NombreIngredienteActivo", GetType(String))) - DtMercancias.Columns.Add(New DataColumn("NomQuimico", GetType(String))) - DtMercancias.Columns.Add(New DataColumn("DenominacionGenerica", GetType(String))) - DtMercancias.Columns.Add(New DataColumn("DenominacionDistintiva", GetType(String))) - DtMercancias.Columns.Add(New DataColumn("Fabricante", GetType(String))) - DtMercancias.Columns.Add(New DataColumn("FormaFarmaceutica", GetType(String))) - DtMercancias.Columns.Add(New DataColumn("CondicionesTransporte", GetType(String))) - DtMercancias.Columns.Add(New DataColumn("RegistroSanitarioAutorizacion", GetType(String))) - DtMercancias.Columns.Add(New DataColumn("PermisoImportacion", GetType(String))) - DtMercancias.Columns.Add(New DataColumn("FolioImportacionVUCEM", GetType(String))) - DtMercancias.Columns.Add(New DataColumn("NumCAS", GetType(String))) - DtMercancias.Columns.Add(New DataColumn("RazonSocialEmpImportacion", GetType(String))) - DtMercancias.Columns.Add(New DataColumn("NumRegistroPlagCOFEPRIS", GetType(String))) - DtMercancias.Columns.Add(New DataColumn("DatosFabricante", GetType(String))) - DtMercancias.Columns.Add(New DataColumn("DatosFormulador", GetType(String))) - DtMercancias.Columns.Add(New DataColumn("DatosMaquilador", GetType(String))) - DtMercancias.Columns.Add(New DataColumn("UsoAutorizado", GetType(String))) - - - Dim DtOperadores As New DataTable() - DtOperadores.Columns.Add(New DataColumn("RFC", GetType(String))) - DtOperadores.Columns.Add(New DataColumn("NumLicencia", GetType(String))) - DtOperadores.Columns.Add(New DataColumn("NombreOperador", GetType(String))) - - Dim DTRelacionados As New DataTable() - DTRelacionados.Columns.Add(New DataColumn("Relacion", GetType(String))) - DTRelacionados.Columns.Add(New DataColumn("UUID", GetType(String))) - - Dim XMLDoc As New XmlDocument - Dim Path As String = String.Format("{0}\{1}\{2}\{3}.{4}", UsuarioActual.Empresa.Ruta, "XML", TipoDocto, String.Format("{0}", SerieFolio), "xml") - Dim Archivo As New System.IO.FileInfo(Path) - - If Archivo.Exists Then - Try - XMLDoc.Load(Path) - Catch ex As Exception - Try - Dim oReader As New StreamReader(Path, Encoding.GetEncoding("ISO-8859-1")) - XMLDoc.Load(oReader) - oReader.Dispose() - Catch ex2 As Exception - GuardaLog("Error al intentar leer el XML del SAT. Error:" & ex2.ToString()) - End Try - End Try - End If - - If XMLDoc IsNot Nothing AndAlso Archivo.Exists Then - - Dim RutaCBB As String = String.Format("{0}\CBB\{1}.jpg", UsuarioActual.Empresa.Ruta, SerieFolio) - Dim ImagenCBB As New System.IO.FileInfo(RutaCBB) - - Dim RutaCCP As String = String.Format("{0}\CBB\{1}_CCP.jpg", UsuarioActual.Empresa.Ruta, SerieFolio) - Dim ImagenCCP As New System.IO.FileInfo(RutaCCP) - - 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) - Dim Version As String = ValorXML(XMLDoc.DocumentElement, "version") - Dim VersionCCP As String = "" - Dim PrefijoCCP As String = "" - - 'Try - - ' 'XDocument doc = XDocument.Parse(Xml); - ' 'String Version = doc.Descendants("cartaporte30:CartaPorte").First().Attribute("version").Value; - - ' Dim NodoVersionCCP As XmlNode = XMLDoc.Descendants("cartaporte30:CartaPorte") - ' If NodoVersionCCP IsNot Nothing Then - ' VersionCCP = ValorXML(NodoVersionCCP, "version") - ' Else - ' VersionCCP = "2.0" - ' End If - 'Catch ex As Exception - - 'End Try - - - If 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 - - params.Add(New ReportParameter("CFDIVersion", Version)) - - 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") - namespaces.AddNamespace("cartaporte", "http://www.sat.gob.mx/CartaPorte") - namespaces.AddNamespace("cartaporte20", "http://www.sat.gob.mx/CartaPorte20") - namespaces.AddNamespace("cartaporte30", "http://www.sat.gob.mx/CartaPorte30") - - Dim Nodos30 = XMLDoc.SelectSingleNode("//cartaporte30:CartaPorte", namespaces) - Dim Nodos20 = XMLDoc.SelectSingleNode("//cartaporte20:CartaPorte", namespaces) - - If Nodos30 IsNot Nothing Then - VersionCCP = "3.0" - PrefijoCCP = "cartaporte30" - End If - - If Nodos20 IsNot Nothing Then - VersionCCP = "2.0" - PrefijoCCP = "cartaporte20" - End If - - params.Add(New ReportParameter("CartaPorteVersion", VersionCCP)) - - Dim nodeComprobante As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Comprobante", Prefijo), namespaces) - If nodeComprobante IsNot Nothing Then - LugarExpedicion = ValorXML(nodeComprobante, "LugarExpedicion") - SubTotal = ValorXML(nodeComprobante, "SubTotal").ToDecimal() - Total = ValorXML(nodeComprobante, "Total").ToDecimal() - End If - - Dim nodeCliente As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Receptor", Prefijo), namespaces) - - If nodeCliente IsNot Nothing Then - ClienteRFC = ValorXML(nodeCliente, "RFC") - ClienteNombre = ValorXML(nodeCliente, "Nombre") - Dim UsoCFDI As String = ValorXML(nodeCliente, "UsoCFDI") - ClienteUsoCFDi = String.Format("{0} - {1}", UsoCFDI, GlobalDTSATUsosCFDI().FiltroPrimeroValor("Descripcion", String.Format("UsoCFDI = '{0}'", UsoCFDI))) - End If - - Dim nodeConceptos As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Conceptos", Prefijo), namespaces) - - If nodeConceptos IsNot Nothing Then - For Each node As XmlNode In nodeConceptos.ChildNodes - Dim Row As DataRow = DtConceptos.NewRow - - Row("Cantidad") = ValorXML(node, "Cantidad", "") - Row("Unidad") = ValorXML(node, "Unidad", "") - Row("Descripcion") = ValorXML(node, "Descripcion", "") - Row("ValorUnitario") = ValorXML(node, "ValorUnitario", "") - Row("Importe") = ValorXML(node, "Importe", "") - DtConceptos.Rows.Add(Row) - Next - End If - Dim nodeComp As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Comprobante/{0}:Complemento", Prefijo), namespaces) - - Dim nodeCartaPorte As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:CartaPorte", PrefijoCCP), namespaces) - If nodeCartaPorte IsNot Nothing Then - TransporteInternacional = ValorXML(nodeCartaPorte, "TranspInternac", "") - End If - - Dim nodeAutotransporteFederal As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:Autotransporte", PrefijoCCP), namespaces) - If nodeAutotransporteFederal IsNot Nothing Then - PermisoSTCC = ValorXML(nodeAutotransporteFederal, "PermSCT", "") - NumPermiso = ValorXML(nodeAutotransporteFederal, "NumPermisoSCT", "") - End If - - Dim nodeIdentificacionVehicular As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:IdentificacionVehicular", PrefijoCCP), namespaces) - If nodeIdentificacionVehicular IsNot Nothing Then - PlacaVM = ValorXML(nodeIdentificacionVehicular, "PlacaVM", "") - AnioModeloVM = ValorXML(nodeIdentificacionVehicular, "AnioModeloVM", "") - PesoBrutoVehicular = ValorXML(nodeIdentificacionVehicular, "PesoBrutoVehicular", "") - End If - - Dim nodeSeguros As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:Seguros", PrefijoCCP), namespaces) - If nodeIdentificacionVehicular IsNot Nothing Then - AseguradoraRespCivil = ValorXML(nodeSeguros, "AseguraRespCivil", "") - NumPolizaSeguroRespCivil = ValorXML(nodeSeguros, "PolizaRespCivil", "") - - 'Por Definir de donde sale - NombreAseguradoraMedioAmbiente = ValorXML(nodeSeguros, "AseguraMedAmbiente", "") - NumPolizaSeguroMedioAmbiente = ValorXML(nodeSeguros, "PolizaMedAmbiente", "") - NombreAseguradoraCarga = ValorXML(nodeSeguros, "AseguraCarga", "") - NumPolizaSeguroCarga = ValorXML(nodeSeguros, "PolizaCarga", "") - End If - - - Dim nodeRemolques As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:Remolques", PrefijoCCP), namespaces) - - If nodeRemolques IsNot Nothing Then - If nodeRemolques.ChildNodes.Count = 1 Then - RemolquePlaca1 = ValorXML(nodeRemolques.ChildNodes(0), "Placa", "") - RemolqueSubtimo1 = ValorXML(nodeRemolques.ChildNodes(0), "SubTipoRem", "") - ElseIf nodeRemolques.ChildNodes.Count > 1 Then - RemolquePlaca1 = ValorXML(nodeRemolques.ChildNodes(0), "Placa", "") - RemolqueSubtimo1 = ValorXML(nodeRemolques.ChildNodes(0), "SubTipoRem", "") - RemolquePlaca2 = ValorXML(nodeRemolques.ChildNodes(1), "Placa", "") - RemolqueSubtimo2 = ValorXML(nodeRemolques.ChildNodes(1), "SubTipoRem", "") - End If - End If - - 'Dim nodeFiguraTransporte As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:FiguraTransporte", "cartaporte20"), namespaces) - 'If nodeFiguraTransporte IsNot Nothing Then - ' Dim CveTransporte As String = ValorXML(nodeFiguraTransporte, "TipoFigura", "") - ' MedioTransporte = String.Format("{0} - {1}", CveTransporte, HtTransporte(CveTransporte).ToString()) - 'End If - - Dim nodeMercancias As XmlNodeList = nodeComp.SelectNodes(String.Format("//{0}:Mercancia", PrefijoCCP), namespaces) - For Each node As XmlNode In nodeMercancias - Dim Row As DataRow = DtMercancias.NewRow - - Row("Cantidad") = ValorXML(node, "Cantidad", "") - Row("UnidadMedida") = ValorXML(node, "Unidad", "") - Row("Descripcion") = ValorXML(node, "Descripcion", "") - Row("PesoEnKg") = ValorXML(node, "PesoEnKg", "") - - Row("CveMaterialPeligroso") = ValorXML(node, "CveMaterialPeligroso", "") - Row("Embalaje") = ValorXML(node, "Embalaje", "") - - Row("SectorCOFEPRIS") = ValorXML(node, "SectorCOFEPRIS", "") - Row("NombreIngredienteActivo") = ValorXML(node, "NombreIngredienteActivo", "") - Row("NomQuimico") = ValorXML(node, "NomQuimico", "") - Row("DenominacionGenerica") = ValorXML(node, "DenominacionGenerica", "") - Row("DenominacionDistintiva") = ValorXML(node, "DenominacionDistintiva", "") - Row("Fabricante") = ValorXML(node, "Fabricante", "") - Row("FormaFarmaceutica") = ValorXML(node, "FormaFarmaceutica", "") - Row("CondicionesTransporte") = ValorXML(node, "CondicionesTransporte", "") - Row("RegistroSanitarioAutorizacion") = ValorXML(node, "RegistroSanitarioAutorizacion", "") - Row("PermisoImportacion") = ValorXML(node, "PermisoImportacion", "") - Row("FolioImportacionVUCEM") = ValorXML(node, "FolioImportacionVUCEM", "") - Row("NumCAS") = ValorXML(node, "NumCAS", "") - Row("RazonSocialEmpImportacion") = ValorXML(node, "RazonSocialEmpImportacion", "") - Row("NumRegistroPlagCOFEPRIS") = ValorXML(node, "NumRegistroPlagCOFEPRIS", "") - Row("DatosFabricante") = ValorXML(node, "DatosFabricante", "") - Row("DatosFormulador") = ValorXML(node, "DatosFormulador", "") - Row("DatosMaquilador") = ValorXML(node, "DatosMaquilador", "") - Row("UsoAutorizado") = ValorXML(node, "UsoAutorizado", "") - - DtMercancias.Rows.Add(Row) - Next - - Dim nodeMercanciaPadre As XmlNodeList = nodeComp.SelectNodes(String.Format("//{0}:Mercancias", PrefijoCCP), namespaces) - If UsuarioActual.CveEmpresa = 13 AndAlso nodeMercanciaPadre IsNot Nothing Then - Dim PesoNetoTotal As String = ValorXML(nodeMercanciaPadre(0), "PesoNetoTotal", "") - Dim UnidadPeso As String = ValorXML(nodeMercanciaPadre(0), "UnidadPeso", "") - Dim NumTotalMercancias As String = ValorXML(nodeMercanciaPadre(0), "NumTotalMercancias", "") - - params.Add(New ReportParameter("PesoNetoTotal", PesoNetoTotal)) - params.Add(New ReportParameter("UnidadPeso", UnidadPeso)) - params.Add(New ReportParameter("NumTotalMercancias", NumTotalMercancias)) - End If - - Dim nodeOperadores As XmlNodeList = nodeComp.SelectNodes(String.Format("//{0}:TiposFigura", PrefijoCCP), namespaces) - For Each node As XmlNode In nodeOperadores - Dim Row As DataRow = DtOperadores.NewRow - - Row("RFC") = ValorXML(node, "RFCFigura", "") - Row("NumLicencia") = ValorXML(node, "NumLicencia", "") - Row("NombreOperador") = ValorXML(node, "NombreFigura", "") - - DtOperadores.Rows.Add(Row) - Next - - Dim DistanciaTotal As Decimal = 0 - Dim nodeUbicaciones As XmlNodeList = nodeComp.SelectNodes(String.Format("//{0}:Ubicacion", PrefijoCCP), namespaces) - For Each node As XmlNode In nodeUbicaciones - Dim Row As DataRow = DtUbicaciones.NewRow - - Row("Distancia") = ValorXML(node, "DistanciaRecorrida", "") - DistanciaTotal += Row("Distancia").ToString().ToDecimal() - Row("TipoUbicacion") = ValorXML(node, "TipoUbicacion", "") - Row("FechaHoraSalida") = ValorXML(node, "FechaHoraSalidaLlegada", "") - Row("RFC") = ValorXML(node, "RFCRemitenteDestinatario", "") - Row("Nombre") = ValorXML(node, "NombreRemitenteDestinatario", "") - - Dim nodeDomicilio As XmlNode = node.ChildNodes.Cast(Of XmlNode).FirstOrDefault(Function(x) x.Name = $"{PrefijoCCP}:Domicilio") 'node.SelectSingleNode(String.Format("//{0}:Domicilio", "cartaporte"), namespaces) - If nodeDomicilio IsNot Nothing Then - - Dim Estado As String = "" - Dim Municipio As String = "" - Dim Colonia As String = "" - Dim calle As String = ValorXML(nodeDomicilio, "Calle", "") - Dim CP As String = ValorXML(nodeDomicilio, "CodigoPostal", "") - - Dim dr As DataRow = GlobalDTGralColonias(ValorXML(nodeDomicilio, "Estado", ""), ValorXML(nodeDomicilio, "Municipio", ""), ValorXML(nodeDomicilio, "Colonia", "")).FiltroPrimero("") - If dr IsNot Nothing Then - Estado = dr("NombreEstado").ToString - Municipio = dr("NombreMunicipio").ToString - Colonia = dr("NombreAsentamiento").ToString - End If - Row("Direccion") = String.Format("{0} Col.{1},{2},{3}. CP {4}", calle, Colonia, Municipio, Estado, CP) - End If - - - DtUbicaciones.Rows.Add(Row) - Next - - If UsuarioActual.CveEmpresa = 13 Then - params.Add(New ReportParameter("DistanciaTotal", DistanciaTotal.ToString())) - End If - - Dim nodeRelacion As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:CfdiRelacionados", Prefijo), namespaces) - - If nodeRelacion IsNot Nothing Then - Dim RelacionCodigo As String = ValorXML(nodeRelacion, "TipoRelacion") - Dim Relacion As String = "" - - Select Case RelacionCodigo - Case "01" - Relacion = "01 - Nota de crédito de los documentos relacionados" - Case "02" - Relacion = "02 - Nota de débito de los documentos relacionados" - Case "03" - Relacion = "03 - Devolución de mercancía sobre facturas o traslados previos" - Case "04" - Relacion = "04 - Sustitución de los CFDI previos" - Case "05" - Relacion = "05 - Traslados de mercancias facturados previamente" - Case "06" - Relacion = "06 - Factura generada por los traslados previos" - Case "07" - Relacion = "07 - CFDI por aplicación de anticipo" - Case "08" - Relacion = "08 - Factura generada por pagos en parcialidades" - Case "09" - Relacion = "09 - Factura generada por pagos diferidos" - End Select - - Dim nodoDocumentosRelacionados As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:CfdiRelacionados", Prefijo), namespaces) - For Each node As XmlNode In nodoDocumentosRelacionados - - Dim nRow As DataRow = DTRelacionados.NewRow - nRow("Relacion") = Relacion - - Try - Dim nodoUUID As XmlNode = node.ChildNodes.Cast(Of XmlNode).FirstOrDefault(Function(x) x.Name = "cfdi:CfdiRelacionado") - nRow("UUID") = ValorXML(nodoUUID, "UUID", "") - Catch ex As Exception - nRow("UUID") = "" - End Try - - DTRelacionados.Rows.Add(nRow) - Next - End If - - Dim nodeTFD As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:TimbreFiscalDigital", "tfd"), namespaces) - If nodeTFD IsNot Nothing Then - FolioFiscal = ValorXML(nodeTFD, "UUID", "") - NoSerieCertificado = ValorXML(nodeTFD, "NoCertificadoSAT", "") - FechaCertificacion = ValorXML(nodeTFD, "FechaTimbrado", "").ToDateTime - SelloCFDi = ValorXML(nodeTFD, "SelloCFD", "") - SelloSAT = ValorXML(nodeTFD, "SelloSAT", "") - NoCertificadoSAT = ValorXML(nodeTFD, "NoCertificadoSAT", "") - - CadenaOriginal = "||1.0|" + FolioFiscal + "|" + FechaCertificacion.ToString("yyyy-MM-dd") + "T" + FechaCertificacion.ToString("HH:mm:ss") + "|" + SelloCFDi + "|" + NoSerieCertificado + "||" - End If - - If Not ImagenCBB.Exists Then - Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar() - CBB.GenerarCBB(UsuarioActual.Empresa.RFC, ClienteRFC, Total, FolioFiscal, RutaCBB) - End If - - - ImagenCBB = New System.IO.FileInfo(RutaCBB) - - If ImagenCBB.Exists Then - ImgCBB = String.Format("file://{0}", ImagenCBB.FullName) - Else - ImgCBB = "" - End If - - - - 'FIXME OICCHECAR DESPUES DE SINCRONIZAR TIMBRADO - 'If Not ImagenCCP.Exists Then - ' Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar() - ' CBB.GenerarCBB(UsuarioActual.Empresa.RFC, ClienteRFC, Total, FolioFiscal, RutaCBB) - 'End If - - - ImagenCCP = New System.IO.FileInfo(RutaCCP) - - If ImagenCCP.Exists Then - ImgCCP = String.Format("file://{0}", ImagenCCP.FullName) - Else - ImgCCP = "" - End If - - End If - - If DtConceptos.Rows.Count > 0 Then - - params.Add(New ReportParameter("LogoPath", RutaImagenLogo)) - 'EMPRESA - params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) - params.Add(New ReportParameter("RegimenFiscal", UsuarioActual.Empresa.Regimen)) - params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) - params.Add(New ReportParameter("FechaImpresion", NowADS().ToDateTime.ToShortDateString)) - params.Add(New ReportParameter("DomicilioFiscal", $"{UsuarioActual.Empresa.Direccion}, {UsuarioActual.Empresa.Colonia}, {UsuarioActual.Empresa.Localidad}, {UsuarioActual.Empresa.Estado}, Tel. {Telefono}")) - params.Add(New ReportParameter("SerieFolio", SerieFolio)) - params.Add(New ReportParameter("RFC", UsuarioActual.Empresa.RFC)) - params.Add(New ReportParameter("DomicilioExpedicion", LugarExpedicion)) - 'CLIENTE - params.Add(New ReportParameter("ClienteNombre", ClienteNombre)) - params.Add(New ReportParameter("ClienteRFC", ClienteRFC)) - params.Add(New ReportParameter("UsoCFDi", ClienteUsoCFDi)) - 'TRANSPORTE - params.Add(New ReportParameter("MedioTransporte", MedioTransporte)) - params.Add(New ReportParameter("TransporteInternacional", TransporteInternacional)) - params.Add(New ReportParameter("PermisoSTCC", PermisoSTCC)) - params.Add(New ReportParameter("NumPermiso", NumPermiso)) - - params.Add(New ReportParameter("Aseguradora", AseguradoraRespCivil)) - params.Add(New ReportParameter("NumPoliza", NumPolizaSeguroRespCivil)) - - params.Add(New ReportParameter("NombreAseguradoraMedioAmbiente", NombreAseguradoraMedioAmbiente)) - params.Add(New ReportParameter("NumPolizaSeguroMedioAmbiente", NumPolizaSeguroMedioAmbiente)) - - params.Add(New ReportParameter("NombreAseguradoraCarga", NombreAseguradoraCarga)) - params.Add(New ReportParameter("NumPolizaSeguroCarga", NumPolizaSeguroCarga)) - - params.Add(New ReportParameter("PlacaVM", PlacaVM)) - params.Add(New ReportParameter("AnioVM", AnioModeloVM)) - params.Add(New ReportParameter("PesoBrutoVehicular", PesoBrutoVehicular)) - - 'TIMBRADO - params.Add(New ReportParameter("FolioFiscal", FolioFiscal)) - params.Add(New ReportParameter("QR", ImgCBB)) - params.Add(New ReportParameter("QRCCP", ImgCCP)) - params.Add(New ReportParameter("SelloCFDI", SelloCFDi)) - params.Add(New ReportParameter("CertificadoContribuyente", NoCertificadoSAT)) - params.Add(New ReportParameter("CadenaOriginal", CadenaOriginal)) - params.Add(New ReportParameter("SerieCertificadoSAT", NoSerieCertificado)) - params.Add(New ReportParameter("FechaCertificacion", FechaCertificacion.ToString("dd/MM/yyyy HH:mm:ss"))) - params.Add(New ReportParameter("SelloSAT", SelloSAT)) - 'TOTALES - params.Add(New ReportParameter("SubTotal", SubTotal.ToString())) - params.Add(New ReportParameter("Descuentos", Descuentos.ToString())) - params.Add(New ReportParameter("Total", Total.ToString())) - - params.Add(New ReportParameter("RemolquePlaca1", RemolquePlaca1)) - params.Add(New ReportParameter("RemolqueSubtimo1", RemolqueSubtimo1)) - - params.Add(New ReportParameter("RemolquePlaca2", RemolquePlaca2)) - params.Add(New ReportParameter("RemolqueSubtimo2", RemolqueSubtimo2)) - - If UsuarioActual.CveEmpresa = 13 Then - params.Add(New ReportParameter("PermisoSCTRemolque1", PermisoSCTR1)) - params.Add(New ReportParameter("PermisoSCTRemolque2", PermisoSCTR2)) - params.Add(New ReportParameter("ConfATR1", ConfATR1)) - params.Add(New ReportParameter("ConfATR2", ConfATR2)) - End If - - - - ' [@CertificadoContribuyente] - '[@CadenaOriginal] - - Dim lrds As New List(Of ReportDataSource) - - Dim rds As New ReportDataSource - rds.Name = "DataSet1" - rds.Value = DtConceptos - lrds.Add(rds) - - Dim rds2 As New ReportDataSource - rds2.Name = "DataSet2" - rds2.Value = DtUbicaciones - lrds.Add(rds2) - - Dim rds3 As New ReportDataSource - rds3.Name = "DataSet3" - rds3.Value = DtMercancias - lrds.Add(rds3) - - Dim rds4 As New ReportDataSource - rds4.Name = "DataSet4" - rds4.Value = DtOperadores - lrds.Add(rds4) - - - Dim rds5 As New ReportDataSource - rds5.Name = "DataSet5" - rds5.Value = DTRelacionados - lrds.Add(rds5) - - If AplicaSubReporte Then - For Each parametro As ReportParameter In params - retorno.Parametros.Add(New ReportParameter($"SRP_{parametro.Name}", parametro.Values.Item(0))) - Next - retorno.Parametros.Add(New ReportParameter($"TieneCartaPorte", "True")) - Else - retorno.Parametros.AddRange(params) - End If - - retorno.DataSources.AddRange(lrds) - End If - - End If - Catch ex As Exception - OnError("Ocurrió un error al generar el pdf de la carta porte", ex) - End Try - Return retorno - End Function #End Region #Region "OP = 'DesXmlTra' - IMPRIME XML TRASLADO" @@ -3022,403 +2411,7 @@ Partial Class PopUpVerFactura Archivo = Nothing End If End Sub - Public Sub imprimirFacturaVenta(CveVenta As Integer, AplicaPagare As String, Optional GuardarPDF As Boolean = False, Optional RegenerarPDF As Boolean = False, Optional UsarStimul As Boolean = False) - Dim ObjVentas As New ClsVentas - Dim Vta As Modelos.Factura = Nothing - Dim PathArchivo As String = "" 'String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio) - - - Dim TmpDTImpuestos As New DataTable - TmpDTImpuestos.Columns.Add("ImpuestoLocal", GetType(String)) - TmpDTImpuestos.Columns.Add("Importe", GetType(Double)) - TmpDTImpuestos.Columns.Add("Orden", GetType(Integer)) - - Dim TmpDTImpuestosIVAIEPS As New DataTable - TmpDTImpuestosIVAIEPS.Columns.Add("Impuesto", GetType(String)) - TmpDTImpuestosIVAIEPS.Columns.Add("tasa", GetType(String)) - TmpDTImpuestosIVAIEPS.Columns.Add("Importe", GetType(Double)) - TmpDTImpuestosIVAIEPS.Columns.Add("Orden", GetType(Integer)) - - If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa, False) AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then - Dim dtVentas As DataTable = ObjVentas.DtResultados - - ' se rellenan los campos de la factura - - Vta = ObjVentas.DtResultados.Rows(0).DataRowToObject(Of Modelos.Factura) - - PathArchivo = String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio) - Dim Archivo As New System.IO.FileInfo(PathArchivo) - - 'SI EL ARCHIVO NO EXISTE O SE VA REGENERA EL PDF, SE DEBEN LLENAR LOS DATOS - If Not Archivo.Exists OrElse RegenerarPDF OrElse UsarStimul Then - Vta.MonedaAbreviatura = dtVentas(0)("Abreviatura").ToString - 'se rellena la sucursal - 'Vta.Subproyecto = ObjVentas.DtResultados.Rows(0).DataRowToObject(Of Modelos.SucursalModel) - Dim CveSubProyecto As Integer = dtVentas(0)("CveSubProyecto").ToString().ToEntero() - - Dim DtSubProyecto As DataTable = GlobalDTSubProyectos(-1, CveSubProyecto:=CveSubProyecto, CveEmpresa:=dtVentas(0)("CveEmpresa").ToString().ToEntero()) - - Vta.SubProyecto = DtSubProyecto.Rows(0).DataRowToObject(Of Modelos.SubProyectoModel) - 'Vta.SubProyecto = ObjVentas.DtResultados.Rows(0).DataRowToObject(Of Modelos.SubProyectoModel) - Vta.Cliente = New Modelos.ClienteModel - Vta.Cliente.Nombre = dtVentas(0)("ClienteNombre").ToString - Vta.Cliente.Telefono = dtVentas(0)("Telefono").ToString - Vta.Cliente.Direccion = dtVentas(0)("ClienteDireccion").ToString - Vta.Cliente.CP = dtVentas(0)("CPCliente").ToString - Vta.Cliente.Ciudad = dtVentas(0)("ClienteCiudad").ToString - Vta.Cliente.Localidad = dtVentas(0)("ClienteLocalidad").ToString - Vta.Cliente.Estado = dtVentas(0)("ClienteEstado").ToString - Vta.Cliente.Pais = dtVentas(0)("ClientePais").ToString - Vta.Cliente.RFC = dtVentas(0)("ClienteRFC").ToString - Vta.Cliente.Colonia = dtVentas(0)("ColoniaCliente").ToString - Vta.AtencionA = dtVentas(0)("AtencionA").ToString - Vta.Cliente.NoExt = dtVentas(0)("ClienteNoExt").ToString - Vta.Cliente.NoInt = dtVentas(0)("ClienteNoInt").ToString - Vta.Cliente.Codigo = dtVentas(0)("ClienteCodigo").ToString - Vta.Cliente.Mail = dtVentas(0)("Mail").ToString - Vta.Cliente.MailCotizacion = dtVentas(0)("SucClienteCorreo").ToString - Vta.Cliente.CodigoRegimenFiscal = dtVentas(0)("CodigoRegimenFiscal").ToString - Vta.Cliente.RegimenFiscal = dtVentas(0)("RegimenFiscal").ToString - Vta.Cliente.UsaProductoAlterno = CBool(dtVentas(0)("UsaProductoAlterno")) - Vta.Cliente.Documentacion = dtVentas(0)("Documentacion").ToString - - Vta.Medico = dtVentas(0)("Medico").ToString - Vta.Procedimiento = dtVentas(0)("Procedimiento").ToString - Vta.Alfa1 = dtVentas(0)("Alfa1").ToString - Vta.FechaEjecucion = dtVentas(0)("FechaEjecucion").ToString.ToDateTime - - Vta.RefDocto = dtVentas(0)("Ref").ToString - Vta.CveVenta = dtVentas(0)("CveVenta").ToString.ToEntero - Vta.NumeroCuenta = dtVentas(0)("NumCtaPago").ToString - Vta.Version = dtVentas(0)("CFDIVersion").ToString - - Vta.NumeroContrato = dtVentas(0)("NumeroContrato").ToString - Vta.DescripcionContrato = dtVentas(0)("DescripcionContrato").ToString - Vta.NumeroDescripcionContrato = If($"{dtVentas(0)("NumeroContrato").ToString} - {dtVentas(0)("NumeroLicitacion").ToString}" = " - ", "", $"{dtVentas(0)("NumeroContrato").ToString} {If(dtVentas(0)("NumeroLicitacion").ToString = "", "", $" - Licitación: {dtVentas(0)("NumeroLicitacion").ToString}")}") - - Vta.PedidoContrato = If(dtVentas(0)("PedidoContrato").ToString = "", Vta.NumeroDescripcionContrato, $"{dtVentas(0)("PedidoContrato").ToString} {If(Vta.NumeroDescripcionContrato = "", "", $" / {Vta.NumeroDescripcionContrato}") }") - Vta.Kilometraje = If(dtVentas(0)("Kilometraje").ToString = "", -1, dtVentas(0)("Kilometraje").ToString.ToDecimal) - 'Vta.PedidoContrato = dtVentas(0)("PedidoContrato").ToString - - Vta.ClienteSucursal = New Modelos.SucursalModel - Vta.ClienteSucursal.Direccion = dtVentas(0)("SucClienteDireccion").ToString - Vta.ClienteSucursal.NoExt = dtVentas(0)("SucClienteNoExt").ToString - Vta.ClienteSucursal.NoInt = dtVentas(0)("SucClienteNoInt").ToString - Vta.ClienteSucursal.Colonia = dtVentas(0)("SucClienteColonia").ToString - Vta.ClienteSucursal.CP = dtVentas(0)("SucClienteCP").ToString - Vta.ClienteSucursal.Municipio = dtVentas(0)("SucClienteCiudad").ToString - Vta.ClienteSucursal.Estado = dtVentas(0)("SucClienteEstado").ToString - Vta.ClienteSucursal.Pais = dtVentas(0)("SucClientePais").ToString - Vta.ClienteSucursal.Localidad = dtVentas(0)("SucClienteLocalidad").ToString - Vta.ClienteSucursal.CorreoSucursal = dtVentas(0)("SucClienteCorreo").ToString - Vta.ClienteSucursal.TelefonoSucursal = dtVentas(0)("SucClienteTelefono").ToString - Vta.ClienteSucursal.Sucursal = dtVentas(0)("SucursalCliente").ToString - Vta.ClienteSucursal.ImprimeNombreSucursal = dtVentas(0)("ImprimeNombreSucursal").ToString - - Vta.EnviarA = New Modelos.EnviarAModel - Vta.EnviarA.CveDireccionEnvio = dtVentas(0)("CveDireccionEnvio").ToString.ToEntero - Vta.EnviarA.EnvioDireccion = dtVentas(0)("EnvioDireccion").ToString - Vta.EnviarA.EnvioColonia = dtVentas(0)("EnvioColonia").ToString - Vta.EnviarA.EnvioCiudad = dtVentas(0)("EnvioCiudad").ToString - Vta.EnviarA.EnvioEstado = dtVentas(0)("EnvioEstado").ToString - Vta.EnviarA.EnvioCP = dtVentas(0)("EnvioCP").ToString - Vta.EnviarA.EnvioTel = dtVentas(0)("EnvioTel").ToString - - Vta.EnviarA.EnvioNoExt = dtVentas(0)("EnvioNoExt").ToString - Vta.EnviarA.EnvioNoInt = dtVentas(0)("EnvioNoInt").ToString - Vta.EnviarA.EnvioContacto = dtVentas(0)("EnvioContacto").ToString - Vta.EnviarA.EnvioDepartamento = dtVentas(0)("EnvioDepartamento").ToString - - 'Vta.EnviarA.EnvioPedidoContrato = dtVentas(0)("EnvioPedidoContrato").ToString - - 'INE COMPLEMENTO - If dtVentas(0)("TipoComite").ToString <> "" Then - Dim INE As New Modelos.ComplementoINE - INE.INETipoComite = dtVentas(0)("TipoComite").ToString - INE.INETipoProceso = dtVentas(0)("TipoProceso").ToString - INE.INEIdContabilidad = dtVentas(0)("IdContabilidad").ToString.ToEntero - Vta.ComplementoINE = INE - End If - - - Dim DR As DataRow = TmpDTImpuestos.NewRow() - If dtVentas(0)("SubTotal").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Subtotal" : DR("Importe") = dtVentas(0)("SubTotal").ToString.ToDouble : DR("Orden") = 10 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - If dtVentas(0)("Descuento").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Descuentos" : DR("Importe") = dtVentas(0)("Descuento").ToString.ToDouble : DR("Orden") = 20 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - If dtVentas(0)("Amortizacion").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Amort.Ant" : DR("Importe") = dtVentas(0)("Amortizacion").ToString.ToDouble : DR("Orden") = 30 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - If dtVentas(0)("SubTotal").ToString.ToDouble <> (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) Then DR("ImpuestoLocal") = "SubTotal2" : DR("Importe") = (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) : DR("Orden") = 40 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - If dtVentas(0)("IVA").ToString.ToDouble >= 0 Then DR("ImpuestoLocal") = "IVA" : DR("Importe") = dtVentas(0)("IVA").ToString.ToDouble : DR("Orden") = 50 : TmpDTImpuestos.Rows.Add(DR) - - 'solo para eclipse, que muesre un subtotal debajo de IVA - If UsuarioActual.CveEmpresa = 15 Then DR = TmpDTImpuestos.NewRow() : DR("ImpuestoLocal") = "Subtotal2" : DR("Importe") = (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) + dtVentas(0)("IVA").ToString.ToDouble : DR("Orden") = 51 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - If dtVentas(0)("RetIVA").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Ret.IVA" : DR("Importe") = dtVentas(0)("RetIVA").ToString.ToDouble : DR("Orden") = 60 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - If dtVentas(0)("RetISR").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Ret.ISR" : DR("Importe") = dtVentas(0)("RetISR").ToString.ToDouble : DR("Orden") = 70 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - - If dtVentas(0)("IEPS").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "IEPS" : DR("Importe") = dtVentas(0)("IEPS").ToString.ToDouble : DR("Orden") = 80 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - - If dtVentas(0)("Total").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Total" : DR("Importe") = dtVentas(0)("Total").ToString.ToDouble : DR("Orden") = 100 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - - If ObjVentas.GetVentaDetalle(CveVenta) Then 'Obtenemos el Detalle de la Oorden de Compra - Vta.DtDetalle = ObjVentas.DtResultados - End If - - If ObjVentas.GetVentaImpuestosLocales(CveVenta) Then - - Dim dtImpuesto As DataTable = ObjVentas.DtResultados - If dtImpuesto.Rows.Count > 0 Then - For Each Row As DataRow In dtImpuesto.Rows - Dim Orden As Integer = 80 - If Row("Importe").ToString.ToDouble <> 0 Then - DR("ImpuestoLocal") = Row("ImpuestoLocal").ToString - DR("Importe") = Row("Importe").ToString.ToDouble - DR("Orden") = Orden - TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - Orden = Orden + 1 - End If - Next - End If - Vta.DtDeduccion = TmpDTImpuestos.FiltraParametros("", Orderby:="Orden ASC") - - End If - - 'TmpDT DESGLOSE DE IMPUESTOS 3.3 - For Each dr1 As DataRow In Vta.DtDetalle.Rows - Dim DrIVA As DataRow = Nothing - Dim DrIEPS As DataRow = Nothing - - Try - DrIVA = TmpDTImpuestosIVAIEPS.Select("Impuesto = 'IVA'")(0) - Catch ex As Exception - DrIVA = Nothing - End Try - - If DrIVA IsNot Nothing Then - DrIVA("Importe") = DrIVA("Importe").ToString.ToDouble + dr1("ImporteIVA").ToString.ToDouble - TmpDTImpuestosIVAIEPS.AcceptChanges() - Else - Dim DR2 As DataRow = TmpDTImpuestosIVAIEPS.NewRow() - If dr1("PorcentajeIVA").ToString.ToDouble > 0 Then - DR2("Impuesto") = "IVA" : DR2("tasa") = String.Format("{0} %", dr1("PorcentajeIVA").ToString.ToDouble() * 100) : DR2("Importe") = dr1("ImporteIVA").ToString.ToDouble : DR2("Orden") = "1" - TmpDTImpuestosIVAIEPS.Rows.Add(DR2) - TmpDTImpuestosIVAIEPS.AcceptChanges() - End If - End If - - Try - DrIEPS = TmpDTImpuestosIVAIEPS.Select($"Impuesto = 'IEPS' AND tasa = '{dr1("PorcentajeIEPS").ToString.ToDouble * 100} %'")(0) - Catch ex As Exception - DrIEPS = Nothing - End Try - - If DrIEPS IsNot Nothing Then - DrIEPS("Importe") = DrIEPS("Importe").ToString.ToDouble + dr1("ImporteIEPS").ToString.ToDouble - TmpDTImpuestosIVAIEPS.AcceptChanges() - Else - Dim DR2 As DataRow = TmpDTImpuestosIVAIEPS.NewRow() - If dr1("PorcentajeIEPS").ToString.ToDouble > 0 Then - DR2("Impuesto") = "IEPS" : DR2("tasa") = String.Format("{0} {1}", dr1("PorcentajeIEPS").ToString.ToDouble * 100, "%") : DR2("Importe") = dr1("ImporteIEPS").ToString.ToDouble : DR2("Orden") = If(dr1("PorcentajeIEPS").ToString.ToDecimal = 0.03, "2", If(dr1("PorcentajeIEPS").ToString.ToDecimal = 0.06, "3", If(dr1("PorcentajeIEPS").ToString.ToDecimal = 0.07, "4", If(dr1("PorcentajeIEPS").ToString.ToDecimal = 0.09, "5", "")))) - TmpDTImpuestosIVAIEPS.Rows.Add(DR2) - TmpDTImpuestosIVAIEPS.AcceptChanges() - End If - End If - - If Vta.Version.ToEntero() = 4 AndAlso dr1("CodigoObjetoImpuesto").ToString() = "02" AndAlso NowADS().Date >= New DateTime(2022, 11, 1) AndAlso dr1("Descuento").ToString().ToDecimal().RoundSQL(2) = dr1("Total").ToString().ToDecimal().RoundSQL(2) Then - dr1("CodigoObjetoImpuesto") = "04" - End If - - Next - - Vta.DtDesgloseImpuestos = TmpDTImpuestosIVAIEPS.FiltraParametros("", Orderby:="Orden ASC") - - If ObjVentas.GetVentasFirmas(CveVenta) Then - Vta.DtFirmas = ObjVentas.DtResultados - End If - - - 'CFDI RELACIONADO - If dtVentas(0)("CveTipoRelacion").ToString.ToEntero > 0 Then - Vta.Timbre.Comprobante.TipoComprobante = If(Vta.TipoDocto.Contiene("Ing", "Ant"), "I", If(Vta.TipoDocto.Contiene("Egs", "Dev"), "E", "")) - If Vta.Timbre.Comprobante.TipoComprobante = "E" Then - If Vta.TipoDocto.Contiene("Egs") Then - Vta.Timbre.CFDIRelacionados.TipoRelacion = "01" - Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Nota de Crédito aplicada a Ingreso" - End If - If Vta.TipoDocto.Contiene("Dev") Then - Vta.Timbre.CFDIRelacionados.TipoRelacion = "03" - Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Devolución aplicada a Ingreso" - End If - Vta.Timbre.CFDIRelacionados.UUID.Add(dtVentas(0)("FolioFiscalPadre").ToString) - End If - ' cuando es refacturacoin es cfdirelacionado, con relacion 04 - If Vta.Timbre.Comprobante.TipoComprobante = "I" Then 'AndAlso (dtVentas(0)("Total").ToString.ToDouble = dtVentas(0)("TotalPadre").ToString.ToDouble) Then - Vta.Timbre.CFDIRelacionados.TipoRelacion = "04" - Vta.Timbre.CFDIRelacionados.UUID.Add(dtVentas(0)("FolioFiscalPadre").ToString) - Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Sustitución de los CFDI Previos" - End If - - If UsuarioActual.Empresa.Funcionalidad(592) = "1" Then - - Dim RowTipoRelacion As DataRow = GlobalDTVtaTiposRelacion().FiltroPrimero($"CveTipoRelacion = {dtVentas(0)("CveTipoRelacion").ToString.ToEntero}") - - Vta.Timbre.CFDIRelacionados.TipoRelacion = RowTipoRelacion("SATClaveTipoRelacion").ToString() - Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = RowTipoRelacion("SATTipoRelacion").ToString() - - If ObjVentas.GetVentasRelacionadas(CveVenta, UsuarioActual.CveEmpresa) Then - Vta.DtDocumentosRelacionados = ObjVentas.DtResultados.FiltraParametros("FolioFiscal IS NOT NULL") - End If - - End If - - End If - - 'If UsuarioActual.CveEmpresa.Contiene(72, 80, 119) Then - If Vta.Timbre.Comprobante.TipoComprobante = "I" Then 'AndAlso (dtVentas(0)("Total").ToString.ToDouble = dtVentas(0)("TotalPadre").ToString.ToDouble) Then - If ObjVentas.GetVentaRefacturacion(dtVentas(0)("CveVentaPadre").ToString.ToEntero) Then - If ObjVentas.DtResultados IsNot Nothing AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then - ObjVentas.DtResultados.Columns.Add("Importe", GetType(Decimal)) - ObjVentas.DtResultados.Rows(0)("Importe") = ObjVentas.DtResultados.Rows(0)("Total") - Vta.DtDocumentosRelacionados = ObjVentas.DtResultados.FiltraParametros("FolioFiscal IS NOT NULL") - If ObjVentas.GetVentasRelacionadas(CveVenta, UsuarioActual.CveEmpresa) Then - Vta.DtNCVinculadas = ObjVentas.DtResultados - Vta.DtDocumentosRelacionados = ObjVentas.DtResultados.FiltraParametros("FolioFiscal IS NOT NULL") - If Vta.DtDocumentosRelacionados.Rows.Count > 0 Then - If Vta.TipoDocto.Contiene("Dev") Then - Vta.Timbre.CFDIRelacionados.TipoRelacion = "03" - Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Devolución aplicada a Ingreso" - End If - End If - End If - End If - End If - Else - - If dtVentas(0)("TipoDocto").ToString.Contiene("Egs", "Dev", "Ant") Then - - If ObjVentas.GetVentasRelacionadas(CveVenta, UsuarioActual.CveEmpresa) Then - Vta.DtNCVinculadas = ObjVentas.DtResultados - Vta.DtDocumentosRelacionados = ObjVentas.DtResultados.FiltraParametros("FolioFiscal IS NOT NULL") - If Vta.DtDocumentosRelacionados.Rows.Count > 0 Then - If Vta.TipoDocto.Contiene("Dev") Then - Vta.Timbre.CFDIRelacionados.TipoRelacion = "03" - Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Devolución aplicada a Ingreso" - End If - End If - End If - End If - End If - - If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso (Vta.DtDocumentosRelacionados Is Nothing OrElse Vta.DtDocumentosRelacionados.Rows.Count = 0) Then - If ObjVentas.GetVentasRelacionadas(CveVenta, UsuarioActual.CveEmpresa) Then - Vta.DtNCVinculadas = ObjVentas.DtResultados - Vta.DtDocumentosRelacionados = ObjVentas.DtResultados '.FiltraParametros("FolioFiscal IS NOT NULL") - If Vta.DtDocumentosRelacionados.Rows.Count > 0 Then - If Vta.TipoDocto.Contiene("Ing") Then - Vta.Timbre.CFDIRelacionados.TipoRelacion = "01" - Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Nota de Crédito aplicada a Ingreso" - End If - - If Vta.TipoDocto.Contiene("Egs") Then - Vta.Timbre.CFDIRelacionados.TipoRelacion = "01" - Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Nota de Crédito aplicada a Ingreso" - End If - - If Vta.TipoDocto.Contiene("Dev") Then - Vta.Timbre.CFDIRelacionados.TipoRelacion = "03" - Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Devolución aplicada a Ingreso" - End If - End If - End If - End If - - 'SI ES TIPO RELACION 07- APLICACION DE ANTICIPOS - If dtVentas(0)("CveTipoRelacion").ToString.ToEntero = 7 Then - Dim RowTipoRelacion As DataRow = GlobalDTVtaTiposRelacion().FiltroPrimero($"CveTipoRelacion = {dtVentas(0)("CveTipoRelacion").ToString.ToEntero}") - - Vta.Timbre.CFDIRelacionados.TipoRelacion = RowTipoRelacion("SATClaveTipoRelacion").ToString() - Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = RowTipoRelacion("SATTipoRelacion").ToString() - - If ObjVentas.GetVentasRelacionadas(CveVenta, UsuarioActual.CveEmpresa) Then - Vta.DtDocumentosRelacionados = ObjVentas.DtResultados.FiltraParametros("FolioFiscal IS NOT NULL") - End If - End If - - End If - - End If - ObjVentas.Dispose() - - If Not IsNothing(Vta) Then - Dim Archivo As New System.IO.FileInfo(PathArchivo) - - Dim Guardar As Boolean = If(GuardarPDF, True, If(AplicaPagare = "1", False, True)) - - Dim CveTimbreCartaPorteVenta As Integer = -1 - Dim CartaPorte As Modelos.MSubReportData = Nothing - 'SI EL ARCHIVO NO EXISTE O SE VA REGENERA EL PDF, SE DEBEN LLENAR LOS DATOS - If Not Archivo.Exists OrElse RegenerarPDF OrElse UsarStimul Then - If UsuarioActual.CveEmpresa = 13 AndAlso Vta.TipoDocto = "Ing" Then - Using ObjGral As New ClsGenerales - If ObjGral.GetGralTimbre(-1, "Ing", MinFecha, MaxFecha, 0, UsuarioActual.CveEmpresa, -1, CveVenta:=CveVenta) AndAlso ObjGral.DtResultados.Rows.Count > 0 Then - Dim RowCP As DataRow = ObjGral.DtResultados.Rows(0) - CveTimbreCartaPorteVenta = RowCP("CveTimbre").ToString().ToEntero() - End If - End Using - - If CveTimbreCartaPorteVenta > 0 Then - CartaPorte = PreParaImpresionCartaPorte(CveTimbreCartaPorteVenta, AplicaSubReporte:=True) - Else - CartaPorte = New Modelos.MSubReportData() - CartaPorte.Parametros.Add(New ReportParameter($"TieneCartaPorte", "False")) - End If - Else - If UsuarioActual.CveEmpresa = 13 AndAlso Vta.TipoDocto.Contiene("Egs", "Ant") Then - CartaPorte = New Modelos.MSubReportData() - CartaPorte.Parametros.Add(New ReportParameter($"TieneCartaPorte", "False")) - End If - End If - Else - If UsuarioActual.CveEmpresa = 13 AndAlso Vta.TipoDocto.Contiene("Egs", "Ant") Then - CartaPorte = New Modelos.MSubReportData() - CartaPorte.Parametros.Add(New ReportParameter($"TieneCartaPorte", "False")) - End If - End If - - If UsarStimul Then - ImprimirbytesPDF(PdfFactura(Vta, AplicaPagare:=AplicaPagare, Guardar:=True, SubReportData:=CartaPorte, UsarStimul:=UsarStimul), Vta.SerieFolio, "PDF") - Else - If Archivo.Exists Then - If RegenerarPDF Then - Archivo.Delete() - ImprimirbytesPDF(PdfFactura(Vta, AplicaPagare:=AplicaPagare, Guardar:=True, SubReportData:=CartaPorte, RegenerarQR:=True), Vta.SerieFolio, "PDF") - Vta = Nothing - Else - HttpContext.Current.Response.Clear() - HttpContext.Current.Response.ClearContent() - HttpContext.Current.Response.ContentType = If(IO.Path.GetExtension(Archivo.Name) = ".txt", "text/plain", "application/pdf") - HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" & Archivo.Name) - HttpContext.Current.Response.AddHeader("Content-Length", Archivo.Length.ToString()) - HttpContext.Current.Response.TransmitFile(PathArchivo) - 'HttpContext.Current.Response.Flush() - HttpContext.Current.Response.End() - Archivo = Nothing - End If - Else - ImprimirbytesPDF(PdfFactura(Vta, AplicaPagare:=AplicaPagare, Guardar:=Guardar, SubReportData:=CartaPorte), Vta.SerieFolio, "PDF") - Vta = Nothing - End If - End If - End If - End Sub #End Region #Region " - OP = 'Alm' - REPORTE ENTRADAS ALMACEN " diff --git a/Scripts/PrintJS/print.min.css b/Scripts/PrintJS/print.min.css new file mode 100644 index 000000000..18fa9d2fb --- /dev/null +++ b/Scripts/PrintJS/print.min.css @@ -0,0 +1 @@ +.printModal{font-family:sans-serif;display:flex;text-align:center;font-weight:300;font-size:30px;left:0;top:0;position:absolute;color:#045fb4;width:100%;height:100%;background-color:hsla(0,0%,100%,.9)}.printClose{position:absolute;right:10px;top:10px}.printClose:before{content:"\00D7";font-family:Helvetica Neue,sans-serif;font-weight:100;line-height:1px;padding-top:.5em;display:block;font-size:2em;text-indent:1px;overflow:hidden;height:1.25em;width:1.25em;text-align:center;cursor:pointer}.printSpinner{margin-top:3px;margin-left:-40px;position:absolute;display:inline-block;width:25px;height:25px;border:2px solid #045fb4;border-radius:50%;animation:spin .75s linear infinite}.printSpinner:after,.printSpinner:before{left:-2px;top:-2px;display:none;position:absolute;content:"";width:inherit;height:inherit;border:inherit;border-radius:inherit}.printSpinner,.printSpinner:after,.printSpinner:before{display:inline-block;border-color:#045fb4 transparent transparent;animation-duration:1.2s}.printSpinner:before{transform:rotate(120deg)}.printSpinner:after{transform:rotate(240deg)}@keyframes spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}} \ No newline at end of file diff --git a/Scripts/PrintJS/print.min.js b/Scripts/PrintJS/print.min.js new file mode 100644 index 000000000..ccbd42dcd --- /dev/null +++ b/Scripts/PrintJS/print.min.js @@ -0,0 +1 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.printJS=t():e.printJS=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){e.exports=n(2)},function(e,t,n){},function(e,t,n){"use strict";n.r(t);n(1);var r={isFirefox:function(){return"undefined"!=typeof InstallTrigger},isIE:function(){return-1!==navigator.userAgent.indexOf("MSIE")||!!document.documentMode},isEdge:function(){return!r.isIE()&&!!window.StyleMedia},isChrome:function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:window;return!!e.chrome},isSafari:function(){return Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor")>0||-1!==navigator.userAgent.toLowerCase().indexOf("safari")},isIOSChrome:function(){return-1!==navigator.userAgent.toLowerCase().indexOf("crios")}},o=r,i={show:function(e){var t=document.createElement("div");t.setAttribute("style","font-family:sans-serif; display:table; text-align:center; font-weight:300; font-size:30px; left:0; top:0;position:fixed; z-index: 9990;color: #0460B5; width: 100%; height: 100%; background-color:rgba(255,255,255,.9);transition: opacity .3s ease;"),t.setAttribute("id","printJS-Modal");var n=document.createElement("div");n.setAttribute("style","display:table-cell; vertical-align:middle; padding-bottom:100px;");var r=document.createElement("div");r.setAttribute("class","printClose"),r.setAttribute("id","printClose"),n.appendChild(r);var o=document.createElement("span");o.setAttribute("class","printSpinner"),n.appendChild(o);var a=document.createTextNode(e.modalMessage);n.appendChild(a),t.appendChild(n),document.getElementsByTagName("body")[0].appendChild(t),document.getElementById("printClose").addEventListener("click",(function(){i.close()}))},close:function(){var e=document.getElementById("printJS-Modal");e&&e.parentNode.removeChild(e)}},a=i;function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function d(e){return e.charAt(0).toUpperCase()+e.slice(1)}function c(e,t){for(var n=0;n]*>(.*?)").test(n))r.innerHTML=t.header;else{var o=document.createElement("h1"),i=document.createTextNode(t.header);o.appendChild(i),o.setAttribute("style",t.headerStyle),r.appendChild(o)}e.insertBefore(r,e.childNodes[0])}function p(e){e.showModal&&a.close(),e.onLoadingEnd&&e.onLoadingEnd(),(e.showModal||e.onLoadingStart)&&window.URL.revokeObjectURL(e.printable);var t="mouseover";(o.isChrome()||o.isFirefox())&&(t="focus");window.addEventListener(t,(function n(){window.removeEventListener(t,n),e.onPrintDialogClose();var r=document.getElementById(e.frameId);r&&r.remove()}))}function u(e,t){try{if(e.focus(),o.isEdge()||o.isIE())try{e.contentWindow.document.execCommand("print",!1,null)}catch(n){e.contentWindow.print()}else e.contentWindow.print()}catch(r){t.onError(r)}finally{o.isFirefox()&&(e.style.visibility="hidden",e.style.left="-1px"),p(t)}}var f={send:function(e,t){document.getElementsByTagName("body")[0].appendChild(t);var n=document.getElementById(e.frameId);n.onload=function(){if("pdf"!==e.type){var t=n.contentWindow||n.contentDocument;if(t.document&&(t=t.document),t.body.appendChild(e.printableElement),"pdf"!==e.type&&e.style){var r=document.createElement("style");r.innerHTML=e.style,t.head.appendChild(r)}var i=t.getElementsByTagName("img");i.length>0?function(e){var t=e.map((function(e){if(e.src&&e.src!==window.location.href)return function(e){return new Promise((function(t){(function n(){e&&"undefined"!=typeof e.naturalWidth&&0!==e.naturalWidth&&e.complete?t():setTimeout(n,500)})()}))}(e)}));return Promise.all(t)}(Array.from(i)).then((function(){return u(n,e)})):u(n,e)}else o.isFirefox()?setTimeout((function(){return u(n,e)}),1e3):u(n,e)}}},m=function(e,t){if(e.base64){var n=Uint8Array.from(atob(e.printable),(function(e){return e.charCodeAt(0)}));b(e,t,n)}else{e.printable=/^(blob|http|\/\/)/i.test(e.printable)?e.printable:window.location.origin+("/"!==e.printable.charAt(0)?"/"+e.printable:e.printable);var r=new window.XMLHttpRequest;r.responseType="arraybuffer",r.addEventListener("error",(function(){p(e),e.onError(r.statusText)})),r.addEventListener("load",(function(){if(-1===[200,201].indexOf(r.status))return p(e),void e.onError(r.statusText);b(e,t,r.response)})),r.open("GET",e.printable,!0),r.send()}};function b(e,t,n){var r=new window.Blob([n],{type:"application/pdf"});r=window.URL.createObjectURL(r),t.setAttribute("src",r),f.send(e,t)}var y=function(e,t){var n=document.getElementById(e.printable);n?(e.printableElement=function r(e,t){for(var n=e.cloneNode(),o=Array.prototype.slice.call(e.childNodes),i=0;i';e.repeatTableHeader&&(r+="");r+="";for(var o=0;o'+d(n[o].displayName)+"";r+="",e.repeatTableHeader&&(r+="");r+="";for(var i=0;i";for(var a=0;a1)for(var s=0;s'+l+""}r+=""}return r+=""}(e),f.send(e,t)};function E(e){return(E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var S=["pdf","html","image","json","raw-html"],x=function(){var e={printable:null,fallbackPrintable:null,type:"pdf",header:null,headerStyle:"font-weight: 300;",maxWidth:800,properties:null,gridHeaderStyle:"font-weight: bold; padding: 5px; border: 1px solid #dddddd;",gridStyle:"border: 1px solid lightgray; margin-bottom: -1px;",showModal:!1,onError:function(e){throw e},onLoadingStart:null,onLoadingEnd:null,onPrintDialogClose:function(){},onIncompatibleBrowser:function(){},modalMessage:"Retrieving Document...",frameId:"printJS",printableElement:null,documentTitle:"Document",targetStyle:["clear","display","width","min-width","height","min-height","max-height"],targetStyles:["border","box","break","text-decoration"],ignoreElements:[],repeatTableHeader:!0,css:null,style:null,scanStyles:!0,base64:!1,onPdfOpen:null,font:"TimesNewRoman",font_size:"12pt",honorMarginPadding:!0,honorColor:!1,imageStyle:"max-width: 100%;"},t=arguments[0];if(t===undefined)throw new Error("printJS expects at least 1 attribute.");switch(E(t)){case"string":e.printable=encodeURI(t),e.fallbackPrintable=e.printable,e.type=arguments[1]||e.type;break;case"object":for(var n in e.printable=t.printable,e.fallbackPrintable="undefined"!=typeof t.fallbackPrintable?t.fallbackPrintable:e.printable,e.fallbackPrintable=e.base64?"data:application/pdf;base64,".concat(e.fallbackPrintable):e.fallbackPrintable,e)"printable"!==n&&"fallbackPrintable"!==n&&(e[n]="undefined"!=typeof t[n]?t[n]:e[n]);break;default:throw new Error('Unexpected argument type! Expected "string" or "object", got '+E(t))}if(!e.printable)throw new Error("Missing printable information.");if(!e.type||"string"!=typeof e.type||-1===S.indexOf(e.type.toLowerCase()))throw new Error("Invalid print type. Available types are: pdf, html, image and json.");e.showModal&&a.show(e),e.onLoadingStart&&e.onLoadingStart();var r=document.getElementById(e.frameId);r&&r.parentNode.removeChild(r);var i=document.createElement("iframe");switch(o.isFirefox()?i.setAttribute("style","width: 1px; height: 100px; position: fixed; left: 0; top: 0; opacity: 0; border-width: 0; margin: 0; padding: 0"):i.setAttribute("style","visibility: hidden; height: 0; width: 0; position: absolute; border: 0"),i.setAttribute("id",e.frameId),"pdf"!==e.type&&(i.srcdoc=""+e.documentTitle+"",e.css&&(Array.isArray(e.css)||(e.css=[e.css]),e.css.forEach((function(e){i.srcdoc+=''}))),i.srcdoc+=""),e.type){case"pdf":if(o.isIE())try{console.info("Print.js doesn't support PDF printing in Internet Explorer.");var l=window.open(e.fallbackPrintable,"_blank");l.focus(),e.onIncompatibleBrowser()}catch(d){e.onError(d)}finally{e.showModal&&a.close(),e.onLoadingEnd&&e.onLoadingEnd()}else m(e,i);break;case"image":g(e,i);break;case"html":y(e,i);break;case"raw-html":h(e,i);break;case"json":v(e,i)}};"undefined"!=typeof window&&(window.printJS=x);t["default"]=x}])["default"]})); \ No newline at end of file diff --git a/Site.master b/Site.master index 834ca815b..58df238ef 100644 --- a/Site.master +++ b/Site.master @@ -25,6 +25,7 @@ + <%-- --%> diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 18d7194e5..e15792de5 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -200,6 +200,9 @@
  • Imprimir PDF
  • +
  • + Impresión directa +
  • Regenerar PDF
  • @@ -449,7 +452,7 @@
    -
    + @@ -592,7 +595,7 @@ Fecha de Cirugia: - + @@ -1979,10 +1982,10 @@ - + - +   @@ -4116,8 +4119,6 @@ --%> - - @@ -4204,7 +4205,8 @@ -
    +
    + @@ -8420,21 +8422,21 @@ <%--Cliente Sucursales --%>
    -
    +
    + AutoPostBack="true" OnSelectedIndexChanged="DdlClienteSucursal_SelectedIndexChanged"> Hospital: -
    +
    -
    + <%--Cliente--%> - <%--
    + <%--
    Hospital: @@ -8456,7 +8458,7 @@
    --%> - + <%--Medico Procedimiento--%>
    @@ -8495,7 +8497,7 @@
    Fecha de Cirugia: - +
    @@ -8539,45 +8541,20 @@ - - +