diff --git a/App_Code/CFDITimbre.vb b/App_Code/CFDITimbre.vb index 749257ef8..22febac8e 100644 --- a/App_Code/CFDITimbre.vb +++ b/App_Code/CFDITimbre.vb @@ -479,14 +479,14 @@ Public Class CFDIComplementoPagos20 Public ReadOnly Property MontoTotalPagos As Decimal Get - Return (From c In ComplementoPagos Select c.Monto * c.TipoCambioP).Sum() + Return (From c In ComplementoPagos Select c.Monto * c.TipoCambioP).Sum().RoundSQL() End Get End Property Public ReadOnly Property TotalTrasladosBaseIVA0 As Decimal Get Dim Ret As Decimal = 0 For Each cfd As CFDIComplementoPago In ComplementoPagos - Ret = Ret + ((From c In cfd.Traslados Where c.Impuesto = "002" And c.TasaOCuota = 0.0 Select c.BaseMN).Sum() * cfd.TipoCambioP.RoundSQL(4)) 'temporal redondeo a 4, 2023.07.07 + Ret = Ret + ((From c In cfd.Traslados Where c.Impuesto = "002" And c.TasaOCuota = 0.0 Select c.BaseMN).Sum() * cfd.TipoCambioP) Next Return Ret.RoundSQL() End Get 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/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 78964e5b4..66c8e9396 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -5342,6 +5342,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/App_Code/ClsTransportes.vb b/App_Code/ClsTransportes.vb index 13189b553..979375c2e 100644 --- a/App_Code/ClsTransportes.vb +++ b/App_Code/ClsTransportes.vb @@ -184,6 +184,7 @@ Public Class ClsTransportes CveMasivo = Data.Rows(0)("CveMasivo").ToString.ToEntero Fecha = Data.Rows(0)("Fecha").ToString.ToDate Ruta = Data.Rows(0)("Ruta").ToString + Me.CveViaje = Data.Rows(0)("CveViaje").ToString.ToEntero End If Retorno = True Catch ex As Exception @@ -273,20 +274,15 @@ Public Class ClsTransportes Return Retorno End Function - Public Function GetViajesPasajeros(CveViaje As Integer, Optional CveViajePasajero As Integer = 0, Optional Estatus As Boolean = False) As Boolean + Public Function GetViajesPasajeros(CveViaje As Integer, Optional CveViajePasajero As Integer = -1, Optional Estatus As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Trans_ViajesPasajerosGet") - If Estatus = True Then - With SqlAdapter.SelectCommand.Parameters - .Add("@CveViaje", SqlDbType.Int).Value = CveViaje - .Add("@Estatus", SqlDbType.Bit).Value = Estatus - End With - Else - With SqlAdapter.SelectCommand.Parameters - .Add("@CveViaje", SqlDbType.Int).Value = CveViaje - End With - End If + With SqlAdapter.SelectCommand.Parameters + .Add("@CveViaje", SqlDbType.Int).Value = CveViaje + .Add("@CveViajePasajero", SqlDbType.Int).Value = CveViajePasajero + .Add("@Estatus", SqlDbType.Int).Value = Estatus + End With Try SqlAdapter.Fill(Data) diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 2feb5e7e7..df92c7193 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -1449,8 +1449,10 @@ Namespace Modelos End Function Public Function AgregarPS(CvePS As Integer, Cantidad As Decimal, PU As Decimal, Descuento As Decimal, Obs As String, - Optional CveUM As Integer = -1, Optional CveProyecto As Integer = -1, Optional Proyecto As String = "", Optional CveSubProyecto As Integer = -1, - Optional SubProyecto As String = "", Optional PorcentajeIVA As Decimal = -1, Optional CuentaPredial As String = "") As Boolean + Optional CveUM As Integer = -1, Optional CveProyecto As Integer = -1, Optional Proyecto As String = "", + Optional CveSubProyecto As Integer = -1, + Optional SubProyecto As String = "", Optional PorcentajeIVA As Decimal = -1, + Optional CuentaPredial As String = "", Optional CveVentaDetallePadre As Integer = -1) As Boolean If Not CvePS > 0 Then Alert("Ocurrió un error al cargar la información del producto a agregar. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgError) @@ -1626,7 +1628,7 @@ Namespace Modelos Row("EntregaDirecta") = 0 'Contratos Row("CveContratoDetalle") = -1 - Row("CveVentaDetalle") = -1 + Row("CveVentaDetalle") = CveVentaDetallePadre Row("CveMovimientoDetallePedido") = -1 Row("CveOrdenCompraDetalle") = -1 Row("CveVentaDetalleRemision") = -1 @@ -2154,7 +2156,7 @@ Namespace Modelos CveMetodoPago33:=factura.CveMetodoPago33, CveUsoCFDI:=factura.CveUsoCFDI, OrdenCompra:=factura.OrdenCompra, CveCuentaTerminal:=factura.CveCuentaTerminal, CveTipoRelacion:=factura.CveTipoRelacion, ImpuestoLocal:=TotalImpuestoLocal, CveVentaRelacion:=(If(factura.CveVentaRelacion.ToEntero > 0, factura.CveVentaRelacion, -1)), ImporteRelacion:=(If(factura.ImporteRelacion <> Nothing, factura.ImporteRelacion, -1)), CveTipoAmortizacionAnticipo:=factura.CveTipoAmortizacionAnticipo, CveEmpresaCRM:=CveEmpresaCRM, EsInterno:=EsInterno, ServicioDomicilio:=factura.ServicioDomicilio, RFCReceptor:=RFCReceptor, EsGarantia:=factura.EsGarantia, DescripcionVenta:=factura.DescripcionVenta, - CveMedico:=factura.CveMedico, CveProcedimiento:=factura.CveProcedimiento, CveTipoVenta:=factura.CveTipoVenta) Then + CveMedico:=factura.CveMedico, CveProcedimiento:=factura.CveProcedimiento, CveTipoVenta:=factura.CveTipoVenta, FechaParaSurtir:=factura.FechaParaSurtir) Then ErrorList.Add("Ocurrió un error al Generar la Venta.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico") 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/Bancos/ConciliacionesBancarias.aspx.vb b/Bancos/ConciliacionesBancarias.aspx.vb index 0d92fcc16..3b372de36 100644 --- a/Bancos/ConciliacionesBancarias.aspx.vb +++ b/Bancos/ConciliacionesBancarias.aspx.vb @@ -223,6 +223,7 @@ Partial Class Bancos_ConciliacionesBancariasaspx Protected Sub LnkConciliarManual_Click(sender As Object, e As EventArgs) ModalidadConciliacion = "M" + If DdlCriterio.Items.FindByValue("2") Is Nothing Then DdlCriterio.Items.Add(New ListItem("Importe - Tipo Movimiento", "2")) DdlCriterio.SelectedIndex = 0 DivCriterio.Visible = True TxtFechaAplicado.Text = txtFechaI.Text @@ -323,7 +324,7 @@ Partial Class Bancos_ConciliacionesBancariasaspx End Sub Protected Sub LnlConciliarAutomaticamente_Click(sender As Object, e As EventArgs) ModalidadConciliacion = "A" - DdlCriterio.SelectedIndex = 0 + DdlCriterio.Items.Remove(DdlCriterio.Items.FindByValue("2")) DivCriterio.Visible = True TxtFechaAplicado.Text = txtFechaI.Text UpModalCriterio.Update() 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/Content/AjaxControlToolkit/Styles/Tabs.css b/Content/AjaxControlToolkit/Styles/Tabs.css index 5908a0886..628e0cd98 100644 --- a/Content/AjaxControlToolkit/Styles/Tabs.css +++ b/Content/AjaxControlToolkit/Styles/Tabs.css @@ -86,7 +86,6 @@ border: 1px solid #999999; border-top: 0; font-family: verdana,tahoma,helvetica; - font-size: 12px; padding: 8px; } diff --git a/Inventarios/EntregaAlmacen.aspx.vb b/Inventarios/EntregaAlmacen.aspx.vb index d6d20549f..d907fcd2b 100644 --- a/Inventarios/EntregaAlmacen.aspx.vb +++ b/Inventarios/EntregaAlmacen.aspx.vb @@ -4,8 +4,7 @@ Option Explicit On Imports System.Data Imports System.Data.SqlClient Imports System.IO -Imports Extensiones -Imports Microsoft.Owin.Security.Provider +Imports Extensiones Imports Microsoft.Reporting.WebForms Partial Class Inventarios_EntregaAlmacen @@ -342,7 +341,7 @@ Partial Class Inventarios_EntregaAlmacen InicializaValores() CargaParametrosAD() - If UsuarioActual.CveEmpresa.Contiene(1, 72, 80, 146, 119) Then DdlAlmacen.AutoPostBack = True + If UsuarioActual.CveEmpresa.Contiene(1, 72, 80, 146, 119, 186) Then DdlAlmacen.AutoPostBack = True If UsuarioActual.Empresa.Funcionalidad(281).ToEntero() = 1 Then @@ -521,9 +520,7 @@ Partial Class Inventarios_EntregaAlmacen If DtPendientes IsNot Nothing Then GVPendientes.DataSource = DtPendientes - End If - LtActualizado.Text = String.Format("Actualizado: {0}", NowADS().ToString("H:mm")) GVPendientes.DataBind() @@ -613,8 +610,6 @@ Partial Class Inventarios_EntregaAlmacen TipoEntrega = 1 BtnGuardar.Visible = True - - Dim StrAlmacenes As String = "CveTipoAlmacen IN (1,2,26)" If UsuarioActual.CveSubProyecto = 8804 Then diff --git a/Inventarios/RepNotasSinAlmacen.aspx b/Inventarios/RepNotasSinAlmacen.aspx index eeb3a3dbc..4c77704d6 100644 --- a/Inventarios/RepNotasSinAlmacen.aspx +++ b/Inventarios/RepNotasSinAlmacen.aspx @@ -165,14 +165,23 @@ - + - - - + + + - + + + + + + + + + + diff --git a/Inventarios/RepNotasSinAlmacen.aspx.vb b/Inventarios/RepNotasSinAlmacen.aspx.vb index fb5cdbac1..df5bfc5e2 100644 --- a/Inventarios/RepNotasSinAlmacen.aspx.vb +++ b/Inventarios/RepNotasSinAlmacen.aspx.vb @@ -74,7 +74,18 @@ Partial Class RepNotasSinAlmacen Dim TienePermisoDesmarcar As Boolean = UsuarioActual.TienePermisoProceso(278) GvVentas.Columns(5).Visible = TienePermisoImportes GvCompras.Columns(4).Visible = TienePermisoImportes - GvCompras.Columns(5).Visible = TienePermisoDesmarcar + GvCompras.Columns(5).Visible = TienePermisoDesmarcar + + If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then ' es empresa hospitalaria + GvVentas.Columns(2).HeaderText = "Fecha Cirugía" + GvVentas.Columns(3).HeaderText = "Hospital" + GvVentas.Columns(6).Visible = True + GvVentas.Columns(7).Visible = True + TxtFechaF.Text = NowADS.AddDays(3).ToShortDateString + CType(GvVentas.Columns(2), BoundField).DataFormatString = "{0:dd/MM/yyyy HH:mm}" + CType(GvVentas.Columns(2), BoundField).ItemStyle.Width = Unit.Pixel(120) + End If + End Sub Private Sub CargaCombos() TxtFechaF.Text = NowADS().ToShortDateString @@ -88,18 +99,10 @@ Partial Class RepNotasSinAlmacen DdlProveedor.setEsWebService(True) DdlProveedor.Attributes.Add("data-metodo", "getproveedores") DdlProveedor.SelectedText = "Todos" - DdlProveedor.SelectedValue = "-1" - - 'DdlSucursal.DataSource = GlobalDTSucursales(UsuarioActual.CveEmpresa) - 'DdlSucursal.DataBind() - - CargarCentrosDeCosto(Nothing, DdlSubProyecto, Nothing, LblSubProyecto) - 'DdlSubProyecto.Items.Clear() - 'DdlSubProyecto.SelectedValue = Nothing - 'DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa, Estatus:=1) - 'DdlSubProyecto.DataBind() - - 'DdlSubProyecto.Items.Insert(0, New ListItem("Sin SubProyecto Asignado", "-1")) + DdlProveedor.SelectedValue = "-1" + + CargarCentrosDeCosto(Nothing, DdlSubProyecto, Nothing, LblSubProyecto) + End Sub Protected Sub btConsultar_Click(sender As Object, e As EventArgs) Handles btConsultar.Click @@ -131,13 +134,8 @@ Partial Class RepNotasSinAlmacen GvVentas.DataSource = Nothing End If - GvVentas.DataBind() - - 'If (GvVentas.Rows.Count > 0) Then - ' GvVentas.UseAccessibleHeader = True - ' GvVentas.HeaderRow.TableSection = TableRowSection.TableHeader - ' RegistraScript("OrdenarGvVentas();") - 'End If + GvVentas.DataBind() + Else 'Compras If Not DdlProveedor.SelectedValue.ToEntero > 0 Then diff --git a/OS/OrdenesServicios.aspx.vb b/OS/OrdenesServicios.aspx.vb index 36b7a9574..d23b2813d 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 @@ -372,8 +374,7 @@ Partial Class OS_OrdenesServicios 'CargaEstatusOS() CargaDatos() 'PermisosSegunEstatus() - CargaDetalles() - CargaMateriales() + DivSeFactura.Visible = True BtnGuardar.Text = "Guardar Cambios" @@ -670,7 +671,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 @@ -704,7 +705,8 @@ Partial Class OS_OrdenesServicios CargaEventoBitacora() CargaHistorial() - + CargaDetalles() + CargaMateriales() If TipoEstatus.Contiene(1, 2, 3) Then LnkAccionesMaterialUtilizado.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,228 @@ 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 = DtVentaDetalle.FiltroPrimeroValor("CveVentaDetalle", $"CveVentaDetallePadre = {GvRow.DataKey("CveVentaDetalle")}").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.") + ObjV.Commit() + 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() @@ -3194,6 +3262,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 @@ -3204,7 +3275,7 @@ Partial Class OS_OrdenesServicios Dim Obs As String = GvRow.DataKey("Observaciones") If CantidadRegistro > 0 Then - If Not ObjFactura.AgregarPS(CvePS, CantidadRegistro, PU, Descuento, Obs, CveSubProyecto:=CveSubProyectoPedido) Then + If Not ObjFactura.AgregarPS(CvePS, CantidadRegistro, PU, Descuento, Obs, CveSubProyecto:=CveSubProyectoPedido, CveVentaDetallePadre:=GvRow.DataKey("CveVentaDetalle").ToEntero) Then Alert("Error al agregar producto", TipoMensaje.MsgAdvertencia) ProcesoOK = False Exit For diff --git a/OS/RepOSMedicas.aspx.vb b/OS/RepOSMedicas.aspx.vb index a561100f0..f1fd8baca 100644 --- a/OS/RepOSMedicas.aspx.vb +++ b/OS/RepOSMedicas.aspx.vb @@ -72,7 +72,7 @@ Partial Class OS_RepOSMedicas End If txtFechaI.Text = NowADS().FirstDayOfMonth.ToShortDateString - txtFechaF.Text = NowADS().ToShortDateString + txtFechaF.Text = NowADS().AddDays(2).ToShortDateString DdlMedico.DataSource = GlobalDTMedicos(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' ") DdlMedico.DataBind() diff --git a/RH/CatDocumentos.aspx b/RH/CatDocumentos.aspx index 8b286199b..048d8d9e0 100644 --- a/RH/CatDocumentos.aspx +++ b/RH/CatDocumentos.aspx @@ -51,7 +51,7 @@ + EmptyDataText="No se encontraron registros de documentos" CssClass="table table-hover table-advance Widthall mysmallbtn" GridLines="None" > diff --git a/RH/CatDocumentos.aspx.vb b/RH/CatDocumentos.aspx.vb index 55bf7dd7f..cd2cf8e7f 100644 --- a/RH/CatDocumentos.aspx.vb +++ b/RH/CatDocumentos.aspx.vb @@ -233,24 +233,19 @@ Partial Class RH_CatDocumentos TxtOrden.Text = Orden.ToString TxtDiasLimite.Text = GvRow.DataKey("DiasLimite") - ChkAplicaDiasLimite.Checked = Boolean.Parse(GvRow.DataKey("AplicaDiasLimite")) - ChkAplicaFechaVencimiento.Checked = Boolean.Parse(GvRow.DataKey("AplicaFechaVencimiento")) - + ChkAplicaDiasLimite.Checked = CBool(GvRow.DataKey("AplicaDiasLimite")) + ChkAplicaFechaVencimiento.Checked = CBool(GvRow.DataKey("AplicaFechaVencimiento")) DdlDocumentacionTipo.SelectedValueExist(CveDocumentacionTipo) chkEstatus.Checked = Estatus chkRequerido.Checked = Requerido - LtlTituloModalDocumentacion.Text = "Actualizar Documento: " & Documentacion BtnAgregarDocumentoModal.Text = "Actualizar" UpModalDocumentacion.Update() ActualizarDocumentacion = True - - - CargaDatosParametro() RegistraScript("$('#divAgregarDocumentacion').modal({ backdrop: 'static', keyboard: false});") 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/Transportes/Boletos.aspx b/Transportes/Boletos.aspx index a7201422a..e8c33e9fc 100644 --- a/Transportes/Boletos.aspx +++ b/Transportes/Boletos.aspx @@ -1,5 +1,5 @@ <%@ Page Language="VB" Title="Transportes V&A - Comprar Boleto" AutoEventWireup="false" MasterPageFile="~/Site.master" CodeFile="Boletos.aspx.vb" - Inherits="Boletos" EnableEventValidation="true" %> + Inherits="Boletos" %> Comprar Boleto @@ -67,155 +67,146 @@ -<%-- - -
  • - Viajes -
  • -
    -
    --%> + + + - -
    -
    -
    -
    - - Datos del Cliente + + +
    +
    +
    +
    +
    + + Datos del Cliente +
    +
    +
    +
    +
    -
    -
    +
    + +
    + + + + +
    + +
    +
    +
    + + +
    +
    + +
    +
    +
    +
    + + + + + + +
    +
    +
    +
    + + + +
    +
    +
    + +
    + + + +
    + +
    +
    + +
    +
    +
    + + Datos del Viaje +
    +
    +
    + +
    +
    +
    + + +
    +
    +
    +
    + + + + + +
    +
    +
    +
    +
    +
    + + +
    +
    +
    + +
    + + + + +
    +
    + +
    + +
    + +
    +
    + +
    +
    + + +
    -
    -
    - - - - -
    - -
    -
    -
    - - -
    -
    - -
    -
    -
    -
    - - - - - - -
    -
    -
    -
    - - - -
    -
    -
    - -
    - - - -
    - -
    -
    - -
    -
    -
    - - Datos del Viaje -
    -
    - -
    - - -
    -
    -
    - - -
    -
    -
    -
    - - - - - -
    -
    -
    -
    -
    -
    - - -
    -
    -
    - -
    - - - - -
    -
    - -
    - - -
    - -
    -
    - -
    -
    - -
    -
    - -
    -
    - -
    - -
    +
    @@ -226,6 +217,7 @@ + @@ -474,6 +466,9 @@
    +
    + + diff --git a/Transportes/Boletos.aspx.vb b/Transportes/Boletos.aspx.vb index 8958a0446..8af8af748 100644 --- a/Transportes/Boletos.aspx.vb +++ b/Transportes/Boletos.aspx.vb @@ -59,13 +59,16 @@ Partial Class Boletos 'Datos Viaje Dim ObjViaje As New ClsTransportes Dim retornoViaje As Boolean = ObjViaje.GetViajes(CveViaje, UsuarioActual.CveEmpresa) - ViewState("CveRuta") = ObjViaje.CveRuta - If retornoViaje Then + + If retornoViaje AndAlso ObjViaje.CveViaje > 0 Then + CveRuta = ObjViaje.CveRuta TxtRuta.Text = ObjViaje.Ruta TxtFecha.Text = ObjViaje.Fecha.ToShortDateString + CargaDestinos() 'Boletos Vendidos Dim dt As DataTable - If ObjViaje.GetViajesPasajeros(CveViaje, Estatus:=True) Then 'Poner párametro para estatus y cancelado de viajes + If ObjViaje.GetViajesPasajeros(CveViaje, Estatus:=1) Then 'Poner párametro para estatus y cancelado de viajes + dt = ObjViaje.DtResultados dt = ObjViaje.DtResultados Dim cph As ContentPlaceHolder = CType(Me.Master.FindControl("C"), ContentPlaceHolder) For Each dr As DataRow In dt.Rows @@ -75,7 +78,6 @@ Partial Class Boletos lnk.CssClass = "nodisponible" lnk.ToolTip = dr("Nombre").ToString End If - Next End If End If @@ -85,6 +87,10 @@ Partial Class Boletos Protected Sub InicializaCombos() 'Lista Destinos''carga específicos + + End Sub + + Private Sub CargaDestinos() Dim ObjDestinos As New ClsTransportes() If ObjDestinos.GetDestinos(CveRuta:=CveRuta) Then @@ -102,20 +108,18 @@ Partial Class Boletos End If ObjDestinos.Dispose() End Sub - - Protected Sub CotizarTarifa(sender As Object, e As EventArgs) + Private Sub CotizarTarifa() If DdlDestino.SelectedValue <> "" And DdlPartida.SelectedValue <> "" Then Dim ObjDestinos As New ClsTransportes() Dim retorno As Boolean = ObjDestinos.GetDestinosTarifas(DdlPartida.SelectedValue.ToEntero, DdlDestino.SelectedValue.ToEntero) - Dim ImporteR As Decimal = ObjDestinos.DtResultados.FiltroPrimeroValor("Importe").ToDecimal + Dim ImporteR As Decimal = ObjDestinos.DtResultados.FiltroPrimeroValor("Importe").ToDecimal.RoundSQL ObjDestinos.Dispose() If retorno Then If ImporteR > 0 Then - Dim redondeado As String = CStr(Math.Round(ImporteR, 2)) - ViewState("Importe") = redondeado - TxtCosto.Text = $"El precio de su boleto es ${Importe}" + ViewState("Importe") = ImporteR + TxtCosto.Text = $"El precio de su boleto es ${ImporteR.FormatoNumero}" BtnGuardar.Visible = True upPanel.Visible = True Else @@ -157,16 +161,30 @@ Partial Class Boletos Dim retorno As Integer = ObjTransporte.AddViajesPasajeros(CveViaje, DdlPartida.SelectedValue.ToEntero, DdlDestino.SelectedValue.ToEntero, Importe, AsientoSeleccionado.ToEntero, TxtNombre.Text, TxtVisa.Text, TxtCelular.Text, CBool(RblSexo.SelectedValue), TxtObservaciones.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) If retorno > 1 Then + Alert("Boleto generado correctamente") ObjTransporte.Commit() + DdlPartida.SelectedValue = "" + DdlDestino.SelectedValue = "" + TxtNombre.Text = "" + TxtVisa.Text = "" + TxtCelular.Text = "" + TxtObservaciones.Text = "" End If Catch ex As Exception ObjTransporte.RollBack() Alert($"No se pudo generar el boleto {ex}", TipoMensaje.MsgError) Finally ObjTransporte.Dispose() - Response.Redirect($"/Transportes/Boletos.aspx?CveViaje={CveViaje}") End Try End Sub + + Protected Sub DdlPartida_SelectedIndexChanged(sender As Object, e As EventArgs) + CotizarTarifa() + End Sub + + Protected Sub DdlDestino_SelectedIndexChanged(sender As Object, e As EventArgs) + CotizarTarifa() + End Sub End Class diff --git a/Transportes/RepBoletos.aspx b/Transportes/RepBoletos.aspx index 5255ff9a3..b0c7b381e 100644 --- a/Transportes/RepBoletos.aspx +++ b/Transportes/RepBoletos.aspx @@ -14,9 +14,9 @@ -<%-- + ---%> +
    @@ -27,11 +27,13 @@
    + + -
    +
    + data-sort="true" DataKeyNames="CveViajePasajero,Asiento,Nombre, Visa,Celular,Sexo,Estatus,Partida,Destino, Importe,FechaIng, Agencia, TelefonoAgencia"> @@ -93,10 +95,10 @@ - + data-btn-ok-label="si" OnClick="BtnCancelar_Click" /> @@ -107,6 +109,8 @@
    + + diff --git a/Transportes/RepBoletos.aspx.vb b/Transportes/RepBoletos.aspx.vb index c658b7b15..f85fe63e8 100644 --- a/Transportes/RepBoletos.aspx.vb +++ b/Transportes/RepBoletos.aspx.vb @@ -31,7 +31,7 @@ Partial Class ListadoBoletos Response.Redirect("/Transportes/RepViajes.aspx") End If CveViaje = Request.QueryString("CveViaje").ToEntero - Ruta = Request.QueryString("Ruta") + Ruta = IfNull(Request("Ruta"), "").ToString Prueba.Text = Ruta @@ -46,62 +46,33 @@ Partial Class ListadoBoletos Private Sub CargaDatos() Dim ObjTransportes As New ClsTransportes - If ObjTransportes.GetViajesPasajeros(CveViaje) Then - GvBoletos.DataSource = ObjTransportes.DtResultados - ObjTransportes.Dispose() - GvBoletos.DataBind() End If - End Sub - - Protected Sub ToggleViajesPasajeros(sender As Object, e As EventArgs) - Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) - Dim CveViajePasajero As String = GvRow.DataKey("CveViajePasajero") - Dim Estatus As String = GvRow.DataKey("Estatus") - Dim cambiarEstatus As Boolean = Not Estatus.ToBool - Dim ObjTransportes As New ClsTransportes - - Try - ObjTransportes.IniciaTransacSQL() - If ObjTransportes.UpdateViajesPasajeros(CveViajePasajero.ToEntero, Activar:=True, Estatus:=cambiarEstatus) Then - - If cambiarEstatus Then - Alert($"El boleto ha sido cancelado correctamente.") - Else - Alert($"El boleto ha sido reactivado correctamente.") - - End If - End If - ObjTransportes.Commit() - - Catch ex As Exception - ObjTransportes.RollBack() - Alert($"No se pudo cambiar el estatus del boleto {ex}", TipoMensaje.MsgError) - Finally - ObjTransportes.Dispose() - CargaDatos() - End Try - + ObjTransportes.Dispose() + GvBoletos.DataBind() End Sub Protected Sub ImprimirBoleto(sender As Object, e As EventArgs) Dim dtResult As New DataTable() Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim Fecha As Date = GvRow.DataKey("FechaIng").ToDate + Dim Importe As Decimal = GvRow.DataKey("Importe").ToDecimal Dim params As New List(Of ReportParameter) From { New ReportParameter("Ruta", Ruta), New ReportParameter("Origen", GvRow.DataKey("Partida")), New ReportParameter("Destino", GvRow.DataKey("Destino")), - New ReportParameter("FechaSalida", "2024-01-03"), - New ReportParameter("HoraSalida", "17:00"), + New ReportParameter("FechaSalida", Fecha.ToShortDateString()), + New ReportParameter("HoraSalida", Fecha.ToString("HH:mm")), New ReportParameter("Nombre", GvRow.DataKey("Nombre")), New ReportParameter("Visa", GvRow.DataKey("Visa")), New ReportParameter("Celular", GvRow.DataKey("Celular")), - New ReportParameter("Importe", GvRow.DataKey("Importe")), + New ReportParameter("Importe", Math.Round(Importe, 1).ToString), New ReportParameter("TipoBoleto", "Tipo Boleto"), - New ReportParameter("Agencia", "Agencia"), - New ReportParameter("TelefonoAgencia", "Telefono Agencia") + New ReportParameter("Agencia", GvRow.DataKey("Agencia")), + New ReportParameter("TelefonoAgencia", GvRow.DataKey("TelefonoAgencia")), + New ReportParameter("Asiento", GvRow.DataKey("Asiento")) } ImprimirPDFStimul($"{UsuarioActual.Empresa.Ruta}Formatos\Boleto.mrt", dtResult, params, NombreArchivo:="Boleto") @@ -110,4 +81,29 @@ Partial Class ListadoBoletos End Sub + + Protected Sub BtnCancelar_Click(sender As Object, e As EventArgs) + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim CveViajePasajero As String = GvRow.DataKey("CveViajePasajero") + Dim Estatus As String = GvRow.DataKey("Estatus") + Dim cambiarEstatus As Boolean = Not Estatus.ToBool + Dim ObjTransportes As New ClsTransportes + ObjTransportes.IniciaTransacSQL() + Try + If ObjTransportes.UpdateViajesPasajeros(CveViajePasajero.ToEntero, Activar:=cambiarEstatus, Estatus:=cambiarEstatus) Then + If Not cambiarEstatus Then + Alert($"El boleto ha sido cancelado correctamente.") + Else + Alert($"El boleto ha sido reactivado correctamente.") + End If + End If + ObjTransportes.Commit() + Catch ex As Exception + ObjTransportes.RollBack() + Alert($"No se pudo cambiar el estatus del boleto {ex}", TipoMensaje.MsgError) + Finally + ObjTransportes.Dispose() + CargaDatos() + End Try + End Sub End Class \ No newline at end of file diff --git a/Transportes/RepContratos.aspx b/Transportes/RepContratos.aspx index 869056f5f..a6e58d5a8 100644 --- a/Transportes/RepContratos.aspx +++ b/Transportes/RepContratos.aspx @@ -64,7 +64,7 @@ + data-sort="true" DataKeyNames="CveContrato, DescripcionContrato, Ubicacion, FechaInicial, FechaFinal, CveCliente, CveTipoAF, Importe, ImporteMin, ImporteMax "> @@ -261,7 +261,7 @@
    - +
    diff --git a/Transportes/RepContratos.aspx.vb b/Transportes/RepContratos.aspx.vb index 3877a3cdb..a39ff2de3 100644 --- a/Transportes/RepContratos.aspx.vb +++ b/Transportes/RepContratos.aspx.vb @@ -47,6 +47,10 @@ Partial Class ListadoContratos TxtObservaciones.Text = "" TxtUbicacion.Text = "" DdlTransporte.SelectedValue = "" + DdlClientes.SelectedText = "" + TxtDolares.Text = "" + TxtPesos.Text = "" + TxtAnticipo.Text = "" BtnGuardar.Text = "Guardar" myModalLabel.InnerHtml = "Agregar Contrato" @@ -77,7 +81,7 @@ Partial Class ListadoContratos End If 'Agregar contrato If BtnGuardar.Text = "Guardar" Then - CveContratoHijo = ObjContratos.AddContratos("", TxtDescripcion.Text, "", UsuarioActual.CveProveedor, DdlClientes.SelectedValue.ToEntero, -1, TxtFechaSalida.Text.ToDate, TxtFechaRegreso.Text.ToDate, TxtUbicacion.Text, "", 10, -1, -1, -1, -1, "", "", -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, False, -1, -1, -1, -1, 0, CveContratoTipo:=2, CveContratosEstatus:=1, CveTipoAF:=DdlTransporte.SelectedValue.ToEntero) + CveContratoHijo = ObjContratos.AddContratos("", TxtDescripcion.Text, "", UsuarioActual.CveProveedor, DdlClientes.SelectedValue.ToEntero, -1, TxtFechaSalida.Text.ToDate, TxtFechaRegreso.Text.ToDate, TxtUbicacion.Text, "", 10, -1, -1, -1, -1, "", "", -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, False, TxtAnticipo.Text.ToDecimal, TxtPesos.Text.ToDecimal, TxtDolares.Text.ToDecimal, -1, 0, CveContratoTipo:=2, CveContratosEstatus:=1, CveTipoAF:=DdlTransporte.SelectedValue.ToEntero) End If If CveContratoHijo > 0 Then @@ -87,7 +91,7 @@ Partial Class ListadoContratos 'Actualizar contrato If BtnGuardar.Text = "Editar" Then - retorno = ObjContratos.UpdateContratos(CveContrato, "", TxtDescripcion.Text, "", -1, DdlClientes.SelectedValue.ToEntero, -1, TxtFechaSalida.Text.ToDate, TxtFechaRegreso.Text.ToDate, TxtUbicacion.Text, "", 10, -1, -1, -1, -1, "", "", -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, False, -1, -1, -1, -1, 0, CveContratoTipo:=2, CveContratosEstatus:=1) + retorno = ObjContratos.UpdateContratos(CveContrato, "", TxtDescripcion.Text, "", -1, DdlClientes.SelectedValue.ToEntero, -1, TxtFechaSalida.Text.ToDate, TxtFechaRegreso.Text.ToDate, TxtUbicacion.Text, "", 10, -1, -1, -1, -1, "", "", -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, False, TxtAnticipo.Text.ToDecimal, TxtPesos.Text.ToDecimal, TxtDolares.Text.ToDecimal, -1, 0, CveContratoTipo:=2, CveContratosEstatus:=1) End If If retorno Then @@ -100,8 +104,11 @@ Partial Class ListadoContratos TxtFechaRegreso.Text = "" TxtObservaciones.Text = "" TxtUbicacion.Text = "" - DdlClientes.SelectedValue = "" + DdlClientes.SelectedText = "" DdlTransporte.SelectedValue = "" + TxtDolares.Text = "" + TxtPesos.Text = "" + TxtAnticipo.Text = "" BtnGuardar.Text = "Guardar" Catch ex As Exception Alert($"Ocurrió un error {ex}", TipoMensaje.MsgError) @@ -129,6 +136,10 @@ Partial Class ListadoContratos TxtObservaciones.Text = GvRow.DataKey("DescripcionContrato") TxtUbicacion.Text = GvRow.DataKey("Ubicacion") DdlTransporte.SelectedValue = GvRow.DataKey("CveTipoAF") + TxtDolares.Text = GvRow.DataKey("Importe") + TxtPesos.Text = GvRow.DataKey("ImporteMax") + TxtAnticipo.Text = GvRow.DataKey("ImporteMin") + If DateTime.TryParse(GvRow.DataKey("FechaInicial").ToString, fechaInicial) And DateTime.TryParse(GvRow.DataKey("FechaFinal").ToString, fechaFinal) Then TxtFechaSalida.Text = fechaInicial.ToString("yyyy-MM-dd HH:mm:ss").Replace(" ", "T") TxtFechaRegreso.Text = fechaFinal.ToString("yyyy-MM-dd HH:mm:ss").Replace(" ", "T") 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 @@
    - + diff --git a/Ventas/Clientes.aspx.vb b/Ventas/Clientes.aspx.vb index 60219d322..4b8cb4d48 100644 --- a/Ventas/Clientes.aspx.vb +++ b/Ventas/Clientes.aspx.vb @@ -2137,7 +2137,17 @@ Partial Class Clientes Protected Sub BtnSendMail_Click(sender As Object, e As System.EventArgs) Handles BtnSendMail.Click Try - If HdnCveVenta.Value <> "-1" AndAlso HdnFolioVenta.Value <> "-1" Then + If HdnCveVenta.Value <> "-1" AndAlso HdnFolioVenta.Value <> "-1" Then + + Dim ArchivoPDF As String = String.Format("{0}/PDF/{1}/{2}.pdf", UsuarioActual.Empresa.Ruta, HdnTipoDocto.Value, HdnFolioVenta.Value) + 'REGENERAR EL PDF + If Not File.Exists(ArchivoPDF) Then + Try + GenerarPDFVenta(HdnCveVenta.Value.ToEntero(), AplicaPagare:="1", GuardarPDF:=True, RegenerarPDF:=True, DescargarArchivo:=False) + Catch ex As Exception + OnError("Ocurrió un error al regenerar el PDF", ex) + End Try + End If Dim ObjMail As New ClsSisMail() Dim Ruta As String = UsuarioActual.Empresa.Ruta 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 diff --git a/Ventas/Promociones.aspx.vb b/Ventas/Promociones.aspx.vb index 91d82696c..21fce0286 100644 --- a/Ventas/Promociones.aspx.vb +++ b/Ventas/Promociones.aspx.vb @@ -164,11 +164,12 @@ Partial Class Ventas_Promociones If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then GvDatos.Columns(8).Visible = True DivRin.Visible = True - Dim ObjGral As New ClsGenerales - If ObjGral.GetRimTamanios(UsuarioActual.CveEmpresa) Then - DdlRin.DataSource = ObjGral.DtResultados - End If - ObjGral.Dispose() + 'Dim ObjGral As New ClsGenerales + 'If ObjGral.GetRinTamanios(UsuarioActual.CveEmpresa) Then + ' DdlRin.DataSource = ObjGral.DtResultados + 'End If + 'ObjGral.Dispose() + DdlRin.DataSource = GlobalDTPSRinTamaños(UsuarioActual.CveEmpresa) DdlRin.DataBind() DdlRin.Items.Insert(0, New ListItem("Todos", "-1")) End If @@ -1073,12 +1074,12 @@ Partial Class Ventas_Promociones ObjPS.Dispose() - Dim ObjGral As New ClsGenerales - If ObjGral.GetRimTamanios(UsuarioActual.CveEmpresa) Then - DTRines = ObjGral.DtResultados - End If - ObjGral.Dispose() - + 'Dim ObjGral As New ClsGenerales + 'If ObjGral.GetRinTamanios(UsuarioActual.CveEmpresa) Then + ' DTRines = ObjGral.DtResultados + 'End If + 'ObjGral.Dispose() + DTRines = GlobalDTPSRinTamaños(UsuarioActual.CveEmpresa) Dim RegistroActual As Integer = 1 For Each dRow As DataRow In DTPlantilla.Rows diff --git a/Ventas/RepRemisiones.aspx b/Ventas/RepRemisiones.aspx index e97d8a298..2ad99df24 100644 --- a/Ventas/RepRemisiones.aspx +++ b/Ventas/RepRemisiones.aspx @@ -220,81 +220,21 @@ + data-sort="true" GridLines="None"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <%-- - - - - - - - --%> - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + @@ -304,15 +244,8 @@ <%----%> - - - - - - - <%----%> - - + + diff --git a/Ventas/RepRemisiones.aspx.vb b/Ventas/RepRemisiones.aspx.vb index 41da0b713..5f7c92f82 100644 --- a/Ventas/RepRemisiones.aspx.vb +++ b/Ventas/RepRemisiones.aspx.vb @@ -97,10 +97,10 @@ Partial Class RepRemisiones End If If DtVentas IsNot Nothing Then - GvDatos.Columns(7).Visible = DtVentas.SUMD("Descuento") > 0 + GvDatos.Columns(10).Visible = DtVentas.SUMD("Descuento") > 0 End If - GvDatos.Columns(10).Visible = chkInv.Checked 'solo se visualiza si está selccionada + GvDatos.Columns(13).Visible = chkInv.Checked 'solo se visualiza si está selccionada ObjVentas.Dispose() GvDatos.DataBind() @@ -118,16 +118,12 @@ Partial Class RepRemisiones e.Row.CssClass = "SubTotales2" e.Row.Font.Bold = True e.Row.Attributes.Add("style", "background:#CCCCCC !important") - Else - e.Row.FCLiteral("LtlFolio").Text = "" & e.Row.FCLiteral("LtlFolio").Text & "" - e.Row.FCLiteral("LtlFecha").Text = "" & e.Row.FCLiteral("LtlFecha").Text & "" - + Else If e.Row.DBCampo("FechaVencimiento").ToDate < NowADS() Then ' e.Row.Cells(2).CssClass = "danger" e.Row.Cells(2).ForeColor = Drawing.Color.Red - End If - - e.Row.Cells(5).Text = e.Row.Cells(5).Text + "%" + End If + End If e.Row.FCLiteral("LtlTotal").Text = " 0, e.Row.DBCampo("CveCliente").ToString(), DdlClientes.SelectedValue) & "&CveContrato=" & CveContrato & "&CveSubProyecto=" & Sucursales & "&CveMoneda=" & e.Row.DBCampo("CveMoneda") & """>" & e.Row.FCLiteral("LtlTotal").Text & "" @@ -137,28 +133,28 @@ Partial Class RepRemisiones #Region "CARGA COMBOS FILTRO" Private Sub CargaCliente() - 'CargaClientes - 'Dim EsWS = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False) - 'If EsWS Then + DdlClientes.setEsWebService(True) - ' Else - 'DdlClientes.setEsWebService(False) - 'DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1) - 'DdlClientes.DataBind() - 'DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1")) - 'End If - If UsuarioActual.TienePermisoProceso(201) Then divVerInv.Visible = True + End If + + If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then ' es empresa hospitalaria + GvDatos.Columns(3).HeaderText = "Hospital" + GvDatos.Columns(5).Visible = True + GvDatos.Columns(6).Visible = True + 'columna de fecha + GvDatos.Columns(1).HeaderText = "Fecha Cirugía" + CType(GvDatos.Columns(1), HyperLinkField).DataTextFormatString = "{0:dd/MM/yyyy HH:mm}" + CType(GvDatos.Columns(1), HyperLinkField).ItemStyle.Width = Unit.Pixel(120) End If - End Sub Private Sub CargaSucursales() DdlSubProyectos.DataSource() = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) - DdlSubProyectos.DataBind() - 'DdlSubProyectos.Items.Insert(0, New ListItem("Todos", "-1")) + DdlSubProyectos.DataBind() + End Sub Private Sub CargaContrato() diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 18d7194e5..f8293738d 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -200,6 +200,9 @@
  • Imprimir PDF
  • +
  • + Impresión directa +
  • Regenerar PDF
  • @@ -449,7 +452,7 @@
    -
    +
    @@ -586,13 +589,13 @@ Requiere Técnico: - + Fecha de Cirugia: - + @@ -1979,10 +1982,10 @@
    - + - +   @@ -4116,8 +4119,6 @@ --%> - -
    @@ -4204,7 +4205,8 @@ -
    +
    + @@ -5366,7 +5368,7 @@ + DataKeyNames="CveVenta, CveVentaDetalle, PU, Total, Cantidad, CveContrato,Surtido,Medico,Procedimiento" AllowPaging="False"> @@ -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 @@
    - - +