This commit is contained in:
AbrahamCastilloV
2024-02-07 18:04:33 -07:00
16 changed files with 1060 additions and 180 deletions

View File

@@ -1216,7 +1216,7 @@ Public Class ClsClientes
Try
SqlAdapter.Fill(Data)
Retorno = True
Catch ex As Exception
OnError("Ocurrió un error al tratar de agregar datos a la base de datos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
End Try

View File

@@ -2945,6 +2945,33 @@ Public Class ClsGenerales
OnError("Ocurrió un error al obtener los paises del SAT", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
End Try
Return Retorno
End Function
Public Function GetSATPeriodicidad() As Boolean
Dim Retorno As Boolean = False
DataAdapter("PA_Gral_SAT_PeriodicidadGet")
With SqlAdapter.SelectCommand.Parameters
End With
Try
SqlAdapter.Fill(Data)
Retorno = True
Catch ex As Exception
OnError("Ocurrió un error al obtener la Periodicidad del SAT", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
End Try
Return Retorno
End Function
Public Function GetSATMeses() As Boolean
Dim Retorno As Boolean = False
DataAdapter("PA_Gral_SAT_MesesGet")
With SqlAdapter.SelectCommand.Parameters
End With
Try
SqlAdapter.Fill(Data)
Retorno = True
Catch ex As Exception
OnError("Ocurrió un error al obtener los meses del SAT", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
End Try
Return Retorno
End Function
Public Function GetSATEstado(ClaveSATPais As String) As Boolean

View File

@@ -794,7 +794,7 @@ Public Class ClsOS
End Function
Public Function UpdateOrdenesServiciosFinaliza(CveOS As Integer, CveOSDetalle As Integer, CvePS As Integer, CveEmpresa As Integer, Optional Opcion As Integer = 1) As Boolean
Public Function UpdateOrdenesServiciosFinaliza(CveOS As Integer, CveOSDetalle As Integer, CvePS As Integer, CveEmpresa As Integer, Optional Opcion As Integer = 1, Optional Observaciones As String = "-1") As Boolean
Dim Retorno As Boolean = False
DataAdapter("PA_OS_OrdenesServiciosFinalizaUpdate")
@@ -805,6 +805,7 @@ Public Class ClsOS
.Add("@CvePS", SqlDbType.Int).Value = CvePS
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
.Add("@Opcion", SqlDbType.Int).Value = Opcion
.Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones
End With

View File

@@ -418,6 +418,37 @@ Public Class ClsPaginas
Application(AppNombre) = value
End Set
End Property
Public Shared Property GlobalDTGralSATMeses() As DataTable
Get
Dim AppNombre As String = "GlobalDTGralSATMeses"
If HttpContext.Current.Application(AppNombre) Is Nothing Then
Dim ObjGrales As New ClsGenerales
If ObjGrales.GetSATMeses() Then HttpContext.Current.Application(AppNombre) = ObjGrales.DtResultados
ObjGrales.Dispose()
End If
GlobalDTGralSATMeses = DirectCast(HttpContext.Current.Application(AppNombre), DataTable)
End Get
Set(value As DataTable)
Dim AppNombre As String = "GlobalDTGralSATMeses"
HttpContext.Current.Application(AppNombre) = value
End Set
End Property
Public Shared Property GlobalDTGralSATPeriodicidad() As DataTable
Get
Dim AppNombre As String = "GlobalDTGralSATPeriodicidad"
If HttpContext.Current.Application(AppNombre) Is Nothing Then
Dim ObjGrales As New ClsGenerales
If ObjGrales.GetSATPeriodicidad() Then HttpContext.Current.Application(AppNombre) = ObjGrales.DtResultados
ObjGrales.Dispose()
End If
GlobalDTGralSATPeriodicidad = DirectCast(HttpContext.Current.Application(AppNombre), DataTable)
End Get
Set(value As DataTable)
Dim AppNombre As String = "GlobalDTGralSATPeriodicidad"
HttpContext.Current.Application(AppNombre) = value
End Set
End Property
Property GlobalDTGralPaises() As DataTable
Get
Dim AppNombre As String = "GlobalDTGralPaises"
@@ -1627,7 +1658,7 @@ Public Class ClsPaginas
End If
End If
GlobalDTCRMTipoProceso = DirectCast(HttpContext.Current.Application(AppNombre), DataTable)
GlobalDTCRMTipoProceso = DirectCast(HttpContext.Current.Application(AppNombre), DataTable)
End Get
Set(value As DataTable)
Dim AppNombre As String = $"GlobalDTCRMTipoProceso-{CveEmpresa}"
@@ -5391,7 +5422,7 @@ 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)
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, Optional EsTicket As Boolean = False)
Dim ObjVentas As New ClsVentas
Dim Vta As Modelos.Factura = Nothing
@@ -5763,7 +5794,7 @@ Public Class ClsPaginas
End If
If UsarStimul Then
Dim bytesPDF As Byte() = PdfFactura(Vta, AplicaPagare:=AplicaPagare, Guardar:=True, SubReportData:=CartaPorte, UsarStimul:=UsarStimul)
Dim bytesPDF = PdfFactura(Vta, AplicaPagare:=AplicaPagare, Guardar:=True, SubReportData:=CartaPorte, UsarStimul:=UsarStimul, EsTicket:=EsTicket)
If DescargarArchivo Then
ImprimirbytesPDF(bytesPDF, Vta.SerieFolio, "PDF")
End If
@@ -5772,7 +5803,7 @@ Public Class ClsPaginas
If Archivo.Exists Then
If RegenerarPDF Then
Archivo.Delete()
Dim bytesPDF As Byte() = PdfFactura(Vta, AplicaPagare:=AplicaPagare, Guardar:=True, SubReportData:=CartaPorte, RegenerarQR:=True)
Dim bytesPDF = PdfFactura(Vta, AplicaPagare:=AplicaPagare, Guardar:=True, SubReportData:=CartaPorte, RegenerarQR:=True, EsTicket:=EsTicket)
If DescargarArchivo Then
ImprimirbytesPDF(bytesPDF, Vta.SerieFolio, "PDF")
End If
@@ -5793,7 +5824,7 @@ Public Class ClsPaginas
Archivo = Nothing
End If
Else
Dim bytesPDF As Byte() = PdfFactura(Vta, AplicaPagare:=AplicaPagare, Guardar:=Guardar, SubReportData:=CartaPorte)
Dim bytesPDF = PdfFactura(Vta, AplicaPagare:=AplicaPagare, Guardar:=Guardar, SubReportData:=CartaPorte, EsTicket:=EsTicket)
If DescargarArchivo Then
ImprimirbytesPDF(bytesPDF, Vta.SerieFolio, "PDF")
End If
@@ -6415,7 +6446,7 @@ Public Class ClsPaginas
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()
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, Optional EsTicket As Boolean = False) As Byte()
Dim retorno As Byte() = Nothing
' Dim ObjVentas As New ClsVentas
'DATOS GENERALES
@@ -6956,6 +6987,22 @@ Public Class ClsPaginas
NombreArchivoDescarga = "FacturaUSA"
End If
If UsuarioActual.Empresa.Funcionalidad(718) = "1" Then
If EsTicket Then
NombreArchivo = "FacturaTicket"
NombreArchivoDescarga = "FacturaTicket"
End If
If UsuarioActual.Empresa.Funcionalidad(707) = "1" Then
Dim SATMes As String = ClsPaginas.GlobalDTGralSATMeses().FiltroPrimeroValor("Mes", $"CveSATMes = {Vta.CveSATMes}")
Dim SATPerioricidad = ClsPaginas.GlobalDTGralSATPeriodicidad().FiltroPrimeroValor("Periodicidad", $"CveSATPeriodicidad = {Vta.CveSATPeriodicidad}")
params.Add(New ReportParameter("SATPerioricidad", SATPerioricidad))
params.Add(New ReportParameter("SATMes", SATMes))
params.Add(New ReportParameter("SATAnio", Vta.SATAnio.ToString()))
End If
End If
If UsuarioActual.CveEmpresa.Contiene(137) Then
params.Add(New ReportParameter("CveVenta", Vta.CveVenta.ToString))
End If
@@ -10693,7 +10740,7 @@ Public Class ClsPaginas
PaginaDict.Add("/Ventas/CatProcedimientos.aspx".ToUpper(), 1344)
PaginaDict.Add("/Ventas/CatProcedimientoDetalle.aspx".ToUpper(), 1344)
PaginaDict.Add("/Ventas/CatEspecialidadesSubEspecialidades.aspx".ToUpper(), 1346)
PaginaDict.Add("/Ventas/FacturacionGlobal.aspx".ToUpper(), 546)

View File

@@ -439,7 +439,7 @@ Public Class ClsVentas
Optional CorreoNotificacion As String = "", Optional FormaPaqueteria As Integer = 1, Optional FacturarSucursal As Boolean = False, Optional VentaDesglosaIEPS As Boolean = False, Optional ServicioDomicilio As Boolean = False, Optional RFCReceptor As String = "", Optional Adjunto As String = "-1",
Optional DevolucionImportePagado As Decimal = 0, Optional EsGarantia As Boolean = False, Optional CveLineaAdicional As Integer = -1, Optional DescripcionVenta As String = "",
Optional CveMedico As Integer = -1, Optional CveProcedimiento As Integer = -1, Optional CveTipoVenta As Integer = -1, Optional RequiereOS As Boolean = False,
Optional FechaParaSurtir As DateTime = MinFecha, Optional Paciente As String = "-1", Optional Episodio As String = "-1") As Boolean
Optional FechaParaSurtir As DateTime = MinFecha, Optional Paciente As String = "-1", Optional Episodio As String = "-1", Optional EsFacturaGlobal As Boolean = False, Optional CveSATPeriodicidad As Integer = -1, Optional CveSATMes As Integer = -1, Optional SATAnio As Integer = -1) As Boolean
Dim Retorno As Boolean = False
DataAdapter("PA_VentasAdd")
@@ -548,8 +548,10 @@ Public Class ClsVentas
.Add("@Paciente", SqlDbType.VarChar).Value = Paciente
.Add("@Episodio", SqlDbType.VarChar).Value = Episodio
.Add("@EsFacturaGlobal", SqlDbType.Bit).Value = EsFacturaGlobal
.Add("@CveSATPeriodicidad", SqlDbType.Int).Value = CveSATPeriodicidad
.Add("@CveSATMes", SqlDbType.Int).Value = CveSATMes
.Add("@SATAnio", SqlDbType.Int).Value = SATAnio
.Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue
End With
'SqlTypes.SqlDateTime.Null

View File

@@ -1452,7 +1452,7 @@ Namespace Modelos
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
Optional CuentaPredial As String = "", Optional CveVentaDetallePadre As Integer = -1, Optional CveVentaDetalleRemision 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)
@@ -1631,7 +1631,7 @@ Namespace Modelos
Row("CveVentaDetalle") = CveVentaDetallePadre
Row("CveMovimientoDetallePedido") = -1
Row("CveOrdenCompraDetalle") = -1
Row("CveVentaDetalleRemision") = -1
Row("CveVentaDetalleRemision") = CveVentaDetalleRemision
Row("CveVentaDetalleCotizacion") = -1
Row("CveVentaDetallePedido2") = -1
Row("CuentaPredial") = CuentaPredial
@@ -1790,6 +1790,18 @@ Namespace Modelos
Timbre.Complementos.ComercioExterior.AplicaComercioExteriorSubProyecto = False
If Me.EsFacturaGlobal Then
Dim SATMes As String = ClsPaginas.GlobalDTGralSATMeses().FiltroPrimeroValor("Mes", $"CveSATMes = {Me.CveSATMes}")
Dim SATPerioricidad = ClsPaginas.GlobalDTGralSATPeriodicidad().FiltroPrimeroValor("Periodicidad", $"CveSATPeriodicidad = {Me.CveSATPeriodicidad}")
Timbre.InformacionGlobal = New CFDIInformacionGlobal() With {
.Año = Me.SATAnio.ToString(),
.Meses = SATMes,
.Perioricidad = SATPerioricidad
}
End If
Me.FemsaFactura = New Modelos.FemsaFactura
Me.Timbre = Timbre
End Sub
@@ -2156,7 +2168,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, CveVentaTerminal:=factura.CveVentaTerminal,
CveMedico:=factura.CveMedico, CveProcedimiento:=factura.CveProcedimiento, CveTipoVenta:=factura.CveTipoVenta, FechaParaSurtir:=factura.FechaParaSurtir, Paciente:=factura.Paciente, Episodio:=factura.Episodio) Then
CveMedico:=factura.CveMedico, CveProcedimiento:=factura.CveProcedimiento, CveTipoVenta:=factura.CveTipoVenta, FechaParaSurtir:=factura.FechaParaSurtir, Paciente:=factura.Paciente, Episodio:=factura.Episodio, EsFacturaGlobal:=factura.EsFacturaGlobal, CveSATPeriodicidad:=factura.CveSATPeriodicidad, CveSATMes:=factura.CveSATMes, SATAnio:=factura.SATAnio) Then
ErrorList.Add("Ocurrió un error al Generar la Venta.<br />Revise su factura y cualquier detalle comuníquese a Soporte Técnico")
@@ -2206,10 +2218,6 @@ Namespace Modelos
Row("CveVentaDetalle") = ObjVentas.CveVentaDetalle
If DtInventario IsNot Nothing Then
'If DtInventario.Select($"CvePS={Row("CvePS").ToString.ToEntero}").Length > 0 Then
' Dim rowInv As DataRow = DtInventario.Select($"CvePS={Row("CvePS").ToString.ToEntero}")(0)
' rowInv("CveVentaDetalle") = ObjVentas.CveVentaDetalle
'End If
Try
Dim InvDr As DataRow = DtInventario.Select($"Consec = {Row("Consec").ToString()}")(0)
@@ -2448,7 +2456,9 @@ Namespace Modelos
GuardarVentaPrePolizas(factura, ObjConta, TmpDTDetalle, CveNCaVincular, ObjBancos, ObjVentas, ObjEventos:=ObjEventos, ObjInventario:=ObjInventario)
If ErrorList.Count = 0 Then
'inventarios
GuardarVentaInventarios(Resp, factura, ObjInventario, ObjConta, ObjVentas, ObjAcum)
If GuardarVentaInventarios(Resp, factura, ObjInventario, ObjConta, ObjVentas, ObjAcum) Then
ErrorList.Add("Ocurrio un error al guardar el inventario")
End If
'GuardaRecepcionUsados(factura, ObjInventario, ObjConta)
@@ -4211,10 +4221,10 @@ Namespace Modelos
End If
End If
If factura.CveAlmacen > 0 AndAlso factura.TipoDocto.Contiene("Ing", "Egs", "Rem") AndAlso RemisionesLista.Count > 0 Then
If RemisionesLista IsNot Nothing AndAlso factura.TipoDocto = "Ing" AndAlso RemisionesLista.Count > 0 Then
For Each CveRemision As Integer In RemisionesLista
'El almacen general es el Primer Almacen de Material en la Sucursal
If Not TraspasoAlmacen(ObjInventario, CveRemision, ObjConta, True, 9) Then
If Not TraspasoAlmacen(ObjInventario, ObjVentas, CveRemision, ObjConta, True, 9, factura.EsFacturaGlobal) Then
OcurrioError = True
Exit For
End If
@@ -4337,40 +4347,68 @@ Namespace Modelos
Return Not OcurrioError
End Function
Private Function CuadrarFacturaMovimientos(MovDetalle As DataTable) As DataTable
Private Function CuadrarFacturaMovimientos(ByRef ObjVentas As ClsVentas, CveRemision As Integer, MovDetalle As DataTable) As DataTable
Dim MovDTCuadrados As New DataTable
MovDTCuadrados = MovDetalle.Clone
MovDTCuadrados.Clear()
'Llenamos el DT solo si es primera llamada
If DtRemConceptosSurtidos Is Nothing Then
DtRemConceptosSurtidos = New DataTable
DtRemConceptosSurtidos.Columns.Add("CveVentaDetalle", GetType(Integer))
DtRemConceptosSurtidos.Columns.Add("Cantidad", GetType(Decimal))
DtRemConceptosSurtidos.Columns.Add("Surtido", GetType(Decimal))
Dim DtDetalleRemision As DataTable = Nothing
Dim StrCveVentasDetalle As New StringBuilder()
For Each dr As DataRow In DtRemisiones.Rows
Dim dtr As DataRow = DtRemConceptosSurtidos.NewRow
dtr("CveVentaDetalle") = dr("CveVentaDetalle")
dtr("Cantidad") = dr("Cantidad")
dtr("Surtido") = 0
DtRemConceptosSurtidos.Rows.Add(dtr)
If ObjVentas.GetVentaDetalle(CveRemision) Then
DtDetalleRemision = ObjVentas.DtResultados.FiltraParametros("", DistinctColumns:={"CveVenta", "CveVentaDetalle"})
End If
For Each RowDetalle As DataRow In DtDetalleRemision.Rows
StrCveVentasDetalle.AppendFormat("{0},", RowDetalle("CveVentaDetalle"))
Next
If StrCveVentasDetalle.Length > 0 Then
StrCveVentasDetalle.Remove(StrCveVentasDetalle.Length - 1, 1)
End If
If DtDetalleRemision IsNot Nothing Then
DtRemConceptosSurtidos = New DataTable
DtRemConceptosSurtidos.Columns.Add("CveRemision", GetType(Integer))
DtRemConceptosSurtidos.Columns.Add("CveVentaDetalle", GetType(Integer))
DtRemConceptosSurtidos.Columns.Add("Cantidad", GetType(Decimal))
DtRemConceptosSurtidos.Columns.Add("Surtido", GetType(Decimal))
'VERIFICA SOLO LOS QUE SON TIPO PRODUCTOS
For Each dr As DataRow In (Me.DtDetalle.Copy()).FiltraParametros($"CveTipoPS = 2 AND CveVentaDetalle IN ({StrCveVentasDetalle.ToString()})").Rows
Dim dtr As DataRow = DtRemConceptosSurtidos.NewRow
dtr("CveRemision") = CveRemision
dtr("CveVentaDetalle") = dr("CveVentaDetalle")
dtr("Cantidad") = dr("Cantidad")
dtr("Surtido") = 0
DtRemConceptosSurtidos.Rows.Add(dtr)
Next
End If
End If
For Each dr As DataRow In MovDetalle.Rows
Dim rowSurtidos As DataRow = DtRemConceptosSurtidos.FiltroPrimero($"CveVentaDetalle={dr("CveVentaDetalle")}")
Dim rowSurtidosP As DataRow = DtRemConceptosSurtidos.Select($"CveVentaDetalle={dr("CveVentaDetalle")}").FirstOrDefault()
Dim rowSurtidosP As DataRow = DtRemConceptosSurtidos.Select($"CveVentaDetalle={dr("CveVentaDetalle")}").FirstOrDefault
Dim Indice As Integer = DtRemConceptosSurtidos.Rows.IndexOf(rowSurtidosP)
'Si no se ha terminado de surtir agregamos el movimiento
If Indice >= 0 Then
' rowSurtidos("Surtido").ToString.ToDouble < rowSurtidos("Cantidad").ToString.ToDouble AndAlso (dr("CantidadDisponible").ToString.ToDouble - rowSurtidos("Surtido").ToString.ToDouble > 0 Or dr("Serie").ToString <> "")
If rowSurtidos("Surtido").ToString.ToDecimal < rowSurtidos("Cantidad").ToString.ToDecimal Then
Dim CantidadSurtida As Double = If(dr("CantidadDisponible").ToString.ToDecimal < rowSurtidos("Cantidad").ToString.ToDouble, dr("CantidadDisponible").ToString.ToDecimal, rowSurtidos("Cantidad").ToString.ToDecimal)
' rowSurtidos("Surtido").ToString().ToDouble < rowSurtidos("Cantidad").ToString().ToDouble AndAlso (dr("CantidadDisponible").ToString().ToDouble - rowSurtidos("Surtido").ToString().ToDouble > 0 Or dr("Serie").ToString() <> "")
If rowSurtidos("Surtido").ToString().ToDecimal < rowSurtidos("Cantidad").ToString().ToDecimal Then
Dim CantidadSurtida As Decimal = If(dr("CantidadDisponible").ToString().ToDecimal < rowSurtidos("Cantidad").ToString().ToDouble, dr("CantidadDisponible").ToString().ToDecimal, rowSurtidos("Cantidad").ToString().ToDecimal)
'SI LA CANTIDAD SURTIDA SUPERA LO REQUERIDO, TOMA SOLO LO NECESARIO PARA COMPLETAR
If (rowSurtidos("Surtido").ToString().ToDecimal + CantidadSurtida) > rowSurtidos("Cantidad").ToString().ToDecimal Then
CantidadSurtida = (rowSurtidos("Cantidad").ToString().ToDecimal - rowSurtidos("Surtido").ToString().ToDecimal)
End If
MovDTCuadrados.ImportRow(dr)
MovDTCuadrados(MovDTCuadrados.Rows.Count - 1)("Cantidad") = CantidadSurtida
DtRemConceptosSurtidos(Indice)("Surtido") = rowSurtidos("Surtido").ToString.ToDecimal + CantidadSurtida
DtRemConceptosSurtidos(Indice)("Surtido") = rowSurtidos("Surtido").ToString().ToDecimal + CantidadSurtida
End If
Else
ErrorList.Add("Ocurrió un error al traspasar el inventario de la remisión")
@@ -4380,115 +4418,177 @@ Namespace Modelos
Return MovDTCuadrados
End Function
Private Function TraspasoAlmacen(ByRef ObjInventario As ClsInventarios, CveRemision As Integer, ByRef ObjConta As ClsContabilidad, ConSalida As Boolean, ConceptoMovimiento As Integer) As Boolean
Private Function TraspasoAlmacen(ByRef ObjInventario As ClsInventarios, ByRef ObjVentas As ClsVentas, CveRemision As Integer, ByRef ObjConta As ClsContabilidad, ConSalida As Boolean, ConceptoMovimiento As Integer, EsFacturaGlobal As Boolean) As Boolean
Dim OcurrioError As Boolean = False
Dim DtMovimientos As DataTable
Dim DtMovimientosDetalles As DataTable
DtRemConceptosSurtidos = Nothing
Try
Dim DtRemisionesTmpDT As DataTable = Me.DtDetalle.Copy()
Dim DtMovimientos As DataTable
Dim DtMovimientosDetalles As DataTable
DtRemConceptosSurtidos = Nothing
'Obtenemos los movimientos detalle
If ObjInventario.GetInv_Mov(CveRemision, UsuarioActual.CveEmpresa) Then
Dim TieneMovimientosServicioDomicilio As Boolean = False
Dim TieneMovimientosSinCosto As Boolean = False
Dim TieneMovimientosContrato As Boolean = False
If ObjInventario.DtResultados.Rows.Count > 0 Then
'Obtenemos los movimientos detalle
If ObjInventario.GetInv_Mov(CveRemision, UsuarioActual.CveEmpresa) Then
DtMovimientos = ObjInventario.DtResultados.FiltraParametros("", DistinctColumns:={"CveMovimiento"})
If ObjInventario.DtResultados.Rows.Count > 0 Then
'Si estamos facturando remisiones ajustamos por ventadetalle
If RemisionesLista.Count > 0 Then
Dim resultados = From DtRemisiones In DtRemisiones
Join DtMovDet In ObjInventario.DtResultados.FiltraParametros("CvePS > 0") On DtRemisiones("CveVentaDetalleRemision").ToString.ToEntero Equals DtMovDet("CveVentaDetalle").ToString.ToEntero
Select DtMovDet
Try
DtMovimientosDetalles = resultados.CopyToDataTable
Catch ex As Exception
GuardaLog($"LOG IPP: Ventas LN: 10033. - DtRemisionesTmpDT.Rows.Count: {DtRemisiones.Rows.Count} - ObjInventario.DtResultados.FiltraParametros('CvePS > 0').Rows.Count: {ObjInventario.DtResultados.FiltraParametros("CvePS > 0").Rows.Count}")
DtMovimientosDetalles = New DataTable
End Try
Else
DtMovimientosDetalles = ObjInventario.DtResultados.FiltraParametros("CvePS > 0")
End If
DtMovimientos = ObjInventario.DtResultados.FiltraParametros("", DistinctColumns:={"CveMovimiento"})
For Each dr As DataRow In DtMovimientos.Rows
'Obtenemos los Movimientos de salida
If ObjInventario.GetMovimientos(dr("CveMovimiento").ToString.ToEntero, ConceptoMovimiento, -1, UsuarioActual.CveEmpresa) Then
If ObjInventario.DtResultados.Rows.Count > 0 AndAlso DtMovimientosDetalles.Rows.Count > 0 Then
Dim CveAlmacenSalida As Integer = ObjInventario.DtResultados(0)("CveAlmacen").ToString.ToEntero
Dim CveAlmacenEntrada As Integer = ObjInventario.DtResultados(0)("CveAlmacenRelacionado").ToString.ToEntero
Dim CveMoneda As Integer = ObjInventario.DtResultados(0)("CveMoneda").ToString.ToEntero
Dim CveTipoAlmacen As Integer = ObjInventario.DtResultados(0)("CveTipoAlmacen").ToString.ToEntero
If (CveAlmacenEntrada > 0 AndAlso CveTipoAlmacen <> 1) Or RemisionesLista.Count = 0 Then 'Con remisiones parciales ignoramos las surtidas ya realizadas
Dim MovDetalle As New DataTable
If RemisionesLista.Count > 0 Then
MovDetalle = CuadrarFacturaMovimientos(DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")} AND TieneSalidaxFactura IS NULL"))
Else
MovDetalle = DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")}")
End If
If ErrorList.Count = 0 Then
If MovDetalle.Rows.Count > 0 Then
Dim CveMovimientoSalidaPorTraspaso As Integer = -1
'Le damos salida de apartado por traspaso
CveMovimientoSalidaPorTraspaso = GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenSalida, 8, CveMoneda, CveRemision)
If Not CveMovimientoSalidaPorTraspaso > 0 Then
OcurrioError = True
Exit For
End If
'Le damos entrada al general por traspaso
If Not OcurrioError Then
If Not GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenEntrada, 9, CveMoneda, CveRemision, CveMovimientoRelacionado:=CveMovimientoSalidaPorTraspaso) > 0 Then
OcurrioError = True
Exit For
End If
End If
If Not OcurrioError Then
If ConSalida Then
'Le damos salida normal
If Not GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenEntrada, 3, CveMoneda, Me.CveVenta, MovimientoPrePoliza:=True, ObjConta:=ObjConta) > 0 Then
OcurrioError = True
Exit For
End If
End If
End If
End If
Else
OcurrioError = True
End If
MovDetalle.Dispose()
'Si estamos facturando remisiones ajustamos por ventadetalle
If RemisionesLista.Count > 0 AndAlso DtRemisionesTmpDT IsNot Nothing AndAlso DtRemisionesTmpDT.Rows.Count > 0 AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then
Dim resultados = From DtRemisiones In DtRemisionesTmpDT
Join DtMovDet In ObjInventario.DtResultados.FiltraParametros("CvePS > 0") On DtRemisiones("CveVentaDetalleRemision").ToString().ToEntero() Equals DtMovDet("CveVentaDetalle").ToString().ToEntero()
Select DtMovDet
Try
If resultados.Count > 0 Then
DtMovimientosDetalles = resultados.CopyToDataTable
Else
DtMovimientosDetalles = New DataTable
End If
Catch ex As Exception
GuardaLog($"LOG IPP: Ventas LN: 10033. - DtRemisionesTmpDT.Rows.Count: {DtRemisionesTmpDT.Rows.Count} - ObjInventario.DtResultados.FiltraParametros('CvePS > 0').Rows.Count: {ObjInventario.DtResultados.FiltraParametros("CvePS > 0").Rows.Count} Ex:{ex.Message}")
DtMovimientosDetalles = New DataTable
End Try
'SE FILTRAN LOS MOVIMIENTOS DE LA PARTE QUE SE FACTURA DE LA REMISION
DtMovimientos = DtMovimientosDetalles.FiltraParametros("", DistinctColumns:={"CveMovimiento"})
Else
DtMovimientosDetalles = ObjInventario.DtResultados.FiltraParametros("CvePS > 0")
End If
'VALIDAR SI TIENE PRODUCTOS POR TRASPASAR
If DtMovimientos.Rows.Count > 0 Then
Dim GeneroMovimientoAlmacen As Boolean = False
TieneMovimientosServicioDomicilio = DtMovimientosDetalles.COUNT("CveTipoAlmacen", "CveTipoAlmacen IN (29,4)") > 0
TieneMovimientosSinCosto = DtMovimientosDetalles.COUNT("CveTipoAlmacen", "CveTipoAlmacen=26") > 0
TieneMovimientosContrato = DtMovimientosDetalles.COUNT("CveTipoAlmacen", "CveTipoAlmacen IN (11)") > 0
For Each dr As DataRow In DtMovimientos.Rows
'VERIFICA SI YA SE GENERARON LAS SALIDAS DE ALMACEN NECESARIAS
If DtRemConceptosSurtidos IsNot Nothing Then
If DtRemConceptosSurtidos.SUMD("Surtido") = DtRemConceptosSurtidos.SUMD("Cantidad") Then
Exit For
End If
End If
'Obtenemos los Movimientos de salida
If ObjInventario.GetMovimientos(dr("CveMovimiento").ToString().ToEntero(), ConceptoMovimiento, -1, UsuarioActual.CveEmpresa) Then
If ObjInventario.DtResultados.Rows.Count > 0 AndAlso DtMovimientosDetalles.Rows.Count > 0 Then
Dim RowMovimiento As DataRow = ObjInventario.DtResultados(0)
Dim CveAlmacenSalida As Integer = RowMovimiento("CveAlmacen").ToString().ToEntero()
Dim CveAlmacenEntrada As Integer = RowMovimiento("CveAlmacenRelacionado").ToString().ToEntero()
Dim CveMoneda As Integer = RowMovimiento("CveMoneda").ToString().ToEntero()
Dim CveTipoAlmacen As Integer = RowMovimiento("CveTipoAlmacen").ToString().ToEntero()
If (CveAlmacenEntrada > 0 AndAlso CveTipoAlmacen <> 1) Or RemisionesLista.Count = 0 Then 'Con remisiones parciales ignoramos las surtidas ya realizadas
Dim MovDetalle As New DataTable
Dim AplicaMovimientoDetalleEntrada As Boolean = True
If RemisionesLista.Count > 0 Then
AplicaMovimientoDetalleEntrada = True
If TieneMovimientosSinCosto OrElse TieneMovimientosServicioDomicilio OrElse EsFacturaGlobal Then
MovDetalle = DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")}")
Else
If TieneMovimientosContrato Then
MovDetalle = CuadrarFacturaMovimientos(ObjVentas, CveRemision, DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")}"))
Else
MovDetalle = CuadrarFacturaMovimientos(ObjVentas, CveRemision, DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")} AND (SaldoAlmacen > 0 AND CantidadDisponible > 0)"))
End If
End If
Else
MovDetalle = DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")}")
End If
If ErrorList.Count = 0 AndAlso MovDetalle.Rows.Count > 0 Then
Dim CveMovimientoSalidaPorTraspaso As Integer = -1
Dim CveConceptoSalidaAlmacen As Integer = 40 'SALIDA DEFINITIVA DEL SISTEMA
Dim CveAlmacenParaSalida As Integer = CveAlmacenSalida
'Le damos salida normal
If ConSalida AndAlso Not OcurrioError Then
If Not OcurrioError Then
Dim CveMovimientoSalidaAlmacen As Integer = GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenParaSalida, CveConceptoSalidaAlmacen, CveMoneda, Me.CveVenta, AplicaMovimientoDetalleEntrada:=AplicaMovimientoDetalleEntrada, MovimientoPrePoliza:=True, ObjConta:=ObjConta)
GeneroMovimientoAlmacen = CveMovimientoSalidaAlmacen > 0
If Not GeneroMovimientoAlmacen Then
OcurrioError = True
Exit For
End If
'If Not OcurrioError AndAlso UsuarioActual.Empresa.Funcionalidad(573) = "1" Then
' OcurrioError = Not GenerarMovimientoAlmacenVirtual(TmpDTDetalle, CveMovimientoSalidaAlmacen, CveAlmacenParaSalida, ObjInventario, ObjConta:=ObjConta)
'End If
End If
End If
End If
MovDetalle.Dispose()
If OcurrioError Then
Exit For
End If
End If
End If
End If
If OcurrioError Then
Exit For
End If
Next
'VERIFICA QUE SE HAYA GENERADO MOVIMIENTO DE ALMACEN
If Not OcurrioError Then
OcurrioError = Not GeneroMovimientoAlmacen
End If
ElseIf ObjInventario.GetMovimientos(dr("CveMovimiento").ToString.ToEntero, 3, -1, UsuarioActual.CveEmpresa) Then
'Esquema viejo, evitamos que aparezca por surtir
If Not ObjInventario.ActualizarEsDevolucionVenta(Me.CveVenta, 2) Then
OcurrioError = True
Exit For
'VERIFICA SI YA SE GENERARON LAS SALIDAS DE ALMACEN NECESARIAS
If Not OcurrioError AndAlso RemisionesLista.Count > 0 AndAlso DtRemConceptosSurtidos IsNot Nothing Then
If DtRemConceptosSurtidos.SUMD("Surtido") <> DtRemConceptosSurtidos.SUMD("Cantidad") Then
OcurrioError = True
Alert("Lo facturado no coincide con lo surtido en inventario", TipoMensaje.MsgAdvertencia)
End If
End If
End If
Next
End If
Else
OcurrioError = True
End If
End If
'LIMPIAR EL DT DE CONCEPTOS SURTIDOS
If DtRemConceptosSurtidos IsNot Nothing Then
DtRemConceptosSurtidos.Clear()
DtRemConceptosSurtidos = Nothing
End If
Catch ex As Exception
OcurrioError = True
OnError("Ocurrió un error al realizar el traspaso", ex)
End Try
Return Not OcurrioError
End Function
Private Function GenerarMovimientoAlmacen(ByRef ObjInventario As ClsInventarios, DtMovDetalle As DataTable, CveAlmacen As Integer, ConceptoEntrada As Integer, CveMoneda As Integer, CveVenta As Integer, Optional MovimientoPrePoliza As Boolean = False, Optional ByRef ObjConta As ClsContabilidad = Nothing, Optional CveMovimientoRelacionado As Integer = -1) As Integer
Private Function GenerarMovimientoAlmacen(ByRef ObjInventario As ClsInventarios, DtMovDetalle As DataTable, CveAlmacen As Integer, ConceptoEntrada As Integer, CveMoneda As Integer, CveVenta As Integer, Optional MovimientoPrePoliza As Boolean = True,
Optional ByRef ObjConta As ClsContabilidad = Nothing, Optional CveMovimientoRelacionado As Integer = -1, Optional AplicaMovimientoDetalleEntrada As Boolean = False,
Optional CveAlmacenDestino As Integer = -1) As Integer
Dim OcurrioError As Boolean = False
Dim DtRemisionesTmpDT As DataTable = Me.DtDetalle.Copy()
Dim ContadorMovtosDetalles As Integer = 0
'Creamos el movimiento
Dim CveMovimientoInventario As Integer = ObjInventario.AddMovimiento(CveAlmacen, ConceptoEntrada, CveMoneda, ClsPaginas.NowADS(), -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, -1, -1, CveMovimientoRelacionado:=CveMovimientoRelacionado, Modulo:="Mod/M2")
Dim CveMovimientoInventario As Integer = ObjInventario.AddMovimiento(CveAlmacen, ConceptoEntrada, CveMoneda, ClsPaginas.NowADS(), -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, -1, -1,
CveMovimientoRelacionado:=CveMovimientoRelacionado, CveAlmacenDestino:=CveAlmacenDestino, Modulo:="Vta/E4")
If CveMovimientoInventario > 0 Then
@@ -4496,8 +4596,8 @@ Namespace Modelos
For Each MovDet As DataRow In DtMovDetalle.Rows
Dim Cantidad As Decimal = 0
Dim CantidadRemision As Decimal = DtRemisiones.FiltroPrimeroValor("Cantidad", $"CveVentaDetalleRemision={MovDet("CveVentaDetalle").ToString}").ToDecimal
Dim CantidadInventario As Decimal = MovDet("Cantidad").ToString.ToDecimal
Dim CantidadRemision As Decimal = DtRemisionesTmpDT.FiltroPrimeroValor("Cantidad", $"CveVentaDetalleRemision={MovDet("CveVentaDetalle").ToString()}").ToDecimal
Dim CantidadInventario As Decimal = MovDet("Cantidad").ToString().ToDecimal
If RemisionesLista.Count > 0 AndAlso CantidadInventario >= CantidadRemision Then
Cantidad = CantidadRemision
@@ -4505,34 +4605,44 @@ Namespace Modelos
Cantidad = CantidadInventario
End If
Dim CveUnidad As Integer = MovDet("CveUM").ToString.ToEntero
Dim PU As Decimal = MovDet("PU").ToString.ToDecimal
Dim CveProducto As Integer = MovDet("CvePS").ToString.ToEntero
Dim Serie As String = MovDet("Serie").ToString
Dim Consec As Integer = DtRemisiones.FiltroPrimeroValor("Consec", $"CveVentaDetalle = {MovDet("CveVentaDetalle").ToString}").ToEntero
Dim CveUnidad As Integer = MovDet("CveUM").ToString().ToEntero()
Dim PU As Decimal = MovDet("PU").ToString().ToDecimal
Dim CveProducto As Integer = MovDet("CvePS").ToString().ToEntero()
Dim Serie As String = MovDet("Serie").ToString()
Dim Lote As String = MovDet("Lote").ToString()
Dim FechaCaducidad As Date = MovDet("FechaCaducidad").ToString.ToDate
Dim CveSeccionAlmacen As Integer = -3 'SE DEBE CALCULAR LA SECCION EL EN TRIGGER DE INVENTARIOS
Dim Consec As Integer = DtRemisionesTmpDT.FiltroPrimeroValor("Consec", $"CveVentaDetalleRemision = {MovDet("CveVentaDetalle").ToString()}").ToEntero()
'COMIENZA: VENTADETALLE
'CUANDO SEA SALIDA VA POR LA VENTA DETALLE DE LA FACTURA DE LA REMISION - OJO!! SOLO FUNCIONA HASTA ORITA QUE SE HACE SALIDA SOLO CUANDO SE FACTURA LA REMISION
Dim CveVentaDetalle As Integer = If(ConceptoEntrada.Contiene(3, 40), DtDetalle.FiltroPrimeroValor("CveVentaDetalle", $"Consec={Consec}").ToEntero, MovDet("CveVentaDetalle").ToString.ToEntero)
Dim CveVentaDetalle As Integer = If(ConceptoEntrada.Contiene(3, 40), Me.DtDetalle.FiltroPrimeroValor("CveVentaDetalle", $"Consec={Consec}").ToEntero(), MovDet("CveVentaDetalle").ToString().ToEntero())
Dim CveVentaDetalleRemision As Integer = -1
If ConceptoEntrada = 40 AndAlso MovDet("CveVentaDetalle").ToString().ToEntero() > 0 Then
CveVentaDetalleRemision = MovDet("CveVentaDetalle").ToString().ToEntero()
End If
'CUANDO LA VENTADETALLE NO TENGA VALOR DEBE MARCAR ERROR, NUEVA RESTRICCION DE ALMACEN
If CveVentaDetalle < 0 Then
If CveVentaDetalle <= 0 Then
Alert("no se encontro la venta detalle. Por favor comuniquese con atención SIG.", TipoMensaje.ToastError)
OcurrioError = True
Exit For
End If
'TERMINA: VENTADETALLE
If Cantidad < 0 Then
ErrorList.Add("Ocurrió un Error al generar los movimientos de almacén. Por favor comuniquese con atención SIG.")
Alert("Ocurrió un Error al generar los movimientos de almacén. Por favor comuniquese con atención SIG.", TipoMensaje.MsgError)
OcurrioError = True
Exit For
End If
If ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, Cantidad, CveUnidad, CveProducto, PU, -1, Serie:=Serie, CveVentaDetalle:=CveVentaDetalle, CveVentaDetalleRemision:=CveVentaDetalleRemision) Then
'CUANDO SEA REMISION FACTURADA DEBE RELACIONAR LOS NUEVOS MOVIMIENTOS POR EL DETALLE
Dim CveMovimientoDetalleEntrada As Integer = -1
If AplicaMovimientoDetalleEntrada Then
CveMovimientoDetalleEntrada = MovDet("CveMovimientoDetalle").ToString().ToEntero()
End If
If ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, Cantidad, CveUnidad, CveProducto, PU, -1, CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad, CveVentaDetalle:=CveVentaDetalle, CveMovimientoDetalleEntrada:=CveMovimientoDetalleEntrada, CveVentaDetalleRemision:=CveVentaDetalleRemision) Then
ContadorMovtosDetalles += 1
Else
OcurrioError = True
@@ -4543,35 +4653,77 @@ Namespace Modelos
'Agregamos las PrePolizas
If Not OcurrioError Then
If MovimientoPrePoliza AndAlso CveMovimientoInventario > 0 Then
'OcurrioError = Not GeneraPrePolizaMovimientoAlmacen(ObjInventario, ObjConta, ObjContPaq, ObjFactura, ObjFactura.CvePrePoliza, CveMovimientoInventario, CveAlmacen)
Dim CveSubProyectoPrePoliza As Integer = Me.CveSubProyecto
If CveAlmacen > 0 Then
Dim CveSubProyectoAlmacen As Integer = ClsPaginas.GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=CveAlmacen).FiltroPrimeroValor("CveSubProyecto").ToString().ToEntero()
If CveSubProyectoAlmacen > 0 Then
CveSubProyectoPrePoliza = CveSubProyectoAlmacen
End If
End If
If ObjInventario.GetMovimientosDetalle(CveMovimientoInventario, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then
Dim DtCostos As DataTable = ObjInventario.DtResultados.Copy
Dim tCveSubProyecto As Integer = Me.CveSubProyecto
Dim DtCostosDistinct As DataTable = ObjInventario.DtResultados.FiltraParametros("", "", {"CveClasificacion"})
Dim ValorInventario As Decimal
Dim GroupBycostos As String() = {"CveClasificacion", "CveSubProyecto", "SubProyecto"}
Dim tmpCostos As DataTable = DtCostos.GroupByDT("", "", {GroupBycostos}, SumColumns:={"Total"}).FiltraParametros("GroupADSType = 1")
Dim TotalCostoAcumulado As Decimal = 0D
Dim Cont As Integer = 1
Dim TotalCosto As Decimal = DtCostos.SUMD("Total").RoundSQL
Dim TipoMovto69 As Boolean = False
'SI ES MOVIMIENTO DE ENTRADA CAMBIAR LA NATURALEZA DEL MOVIMIENTO
If ConceptoEntrada.Contiene(9) Then
TipoMovto69 = True
End If
For Each RowInv As DataRow In DtCostosDistinct.Rows
ValorInventario = DtCostos.SUMD("Total", String.Format("CveClasificacion = {0}", RowInv("CveClasificacion"))).RoundSQL
TotalCostoAcumulado += ValorInventario
'cuando es el último movimiento y hay diferencias en los importes
If Cont = DtCostosDistinct.Rows.Count AndAlso TotalCosto <> TotalCostoAcumulado Then
ValorInventario = ValorInventario + (TotalCosto - TotalCostoAcumulado)
End If
For Each RowInv As DataRow In tmpCostos.Rows
'ValorInventario = DtCostos.SUMD("Total", String.Format("CveClasificacion = {0}", RowInv("CveClasificacion")))
ValorInventario = RowInv("Total").ToString.ToDecimal
If UsuarioActual.CveEmpresa <> 119 Then tCveSubProyecto = RowInv("CveSubProyecto").ToString.ToEntero()
Try
If ValorInventario <> 0 Then
If Not ObjConta.AddPrePolizasDetalle(Me.CvePrePoliza, False, ValorInventario, ValorInventario, 69, Me.SerieFolio, Me.SerieFolio, CveVenta:=CveVenta, CveCliente:=Me.CveCliente, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimientoInventario, CveSubProyecto:=tCveSubProyecto) Then
OcurrioError = True
Exit For
End If
Dim CveSubProyecto69 As Integer = CveSubProyectoPrePoliza
If UsuarioActual.CveEmpresa = 119 Then
CveSubProyecto69 = Me.CveSubProyecto
End If
'If ValorInventario <> 0 Then
If Not ObjConta.AddPrePolizasDetalle(Me.CvePrePoliza, TipoMovto69, ValorInventario, ValorInventario, 69, Me.SerieFolio, Me.SerieFolio, CveVenta:=CveVenta, CveCliente:=Me.CveCliente, CveClasificacion:=RowInv("CveClasificacion").ToString().ToEntero(), CveMovimientoAlmacen:=CveMovimientoInventario, CveSubProyecto:=CveSubProyecto69) Then
OcurrioError = True
Exit For
End If
'End If
Catch ex As Exception
OcurrioError = True
ModExtensiones.GuardaLog("Error inesperado (15147)." + ex.ToString())
Alert("Error inesperado (15147). Por favor comuniquese con atención SIG.", TipoMensaje.ToastError)
End Try
Cont += 1
Next
If Not OcurrioError Then
ValorInventario = (DtCostos.SUM("Total", "")).RoundSQL
If Not ObjConta.AddPrePolizasDetalle(Me.CvePrePoliza, True, ValorInventario, ValorInventario, 68, Me.SerieFolio, Me.SerieFolio, CveVenta:=CveVenta, CveCliente:=Me.CveCliente, CveMovimientoAlmacen:=CveMovimientoInventario, CveSubProyecto:=Me.CveSubProyecto) Then
If Not ObjConta.AddPrePolizasDetalle(Me.CvePrePoliza, Not TipoMovto69, TotalCosto, TotalCosto, 68, Me.SerieFolio, Me.SerieFolio, CveVenta:=CveVenta, CveCliente:=Me.CveCliente, CveMovimientoAlmacen:=CveMovimientoInventario, CveSubProyecto:=CveSubProyectoPrePoliza) Then
OcurrioError = True
End If
End If
If Not OcurrioError AndAlso UsuarioActual.CveEmpresa = 119 Then
If ObjInventario.GetVentasPedimento(CveVenta, UsuarioActual.CveEmpresa) Then
Dim dttped As DataTable = ObjInventario.DtResultados
For Each drt As DataRow In dttped.FiltraParametros("Pedimento <> ''").Rows
ObjInventario.UpdateVentasDetalleNumeroPedimento(CveVenta, drt("CveVentaDetalle").ToString.ToEntero, drt("Pedimento").ToString)
Dim dtr As DataRow() = Me.DtDetalle.Select($"CveVentaDetalle ={drt("CveVentaDetalle")}")
If dtr IsNot Nothing Then 'actualizamos los datos temporales para timbrar
dtr(0)("NumeroPedimento") = drt("Pedimento").ToString
End If
Next
End If
End If
Else
OcurrioError = True
End If
@@ -4582,7 +4734,6 @@ Namespace Modelos
If ContadorMovtosDetalles = 0 Then
OcurrioError = True
End If
Else
OcurrioError = True
End If
@@ -7455,6 +7606,10 @@ Namespace Modelos
Public Property FemsaFactura As Modelos.FemsaFactura
Public Property DevolucionImportePagado As Decimal = 0
Public Property DescripcionVenta As String = ""
Public Property EsFacturaGlobal As Boolean = False
Public Property CveSATPeriodicidad As Integer = -1
Public Property CveSATMes As Integer = -1
Public Property SATAnio As Integer = -1
Public Sub SetSubProyecto()
If CveSubProyecto > 0 AndAlso UsuarioActual IsNot Nothing Then

View File

@@ -85,7 +85,7 @@ Public Class CargaEventos : Implements IHttpHandler, IRequiresSessionState
FI = context.Request("start").ToDate
FF = context.Request("end").ToDate
If Not GetEventos(CveUsuario, CveEmpresa, FI, FF) Then
If Not GetEventos(CveUsuario, CveEmpresa, FI, FF, context:=context) Then
'Convierte el objeto de Eventos en JSON
'Dim oSerializer As System.Web.Script.Serialization.JavaScriptSerializer = New System.Web.Script.Serialization.JavaScriptSerializer
Dim sJSON As String = Newtonsoft.Json.JsonConvert.SerializeObject(events)
@@ -280,7 +280,7 @@ Public Class CargaEventos : Implements IHttpHandler, IRequiresSessionState
'AGREGAMOS CUANDO NO ES RECURRENTE
Dim tFecha As DateTime = DateAdd(DateInterval.Month, -6, ClsPaginas.NowADS())
'SI LA FECHA DEL EVENTO ES MENOR DE 6 MESES DE LA FECHA ACTUAL NO LO AGREGA
If dr("FechaFinal").ToString.ToDateTime > tFecha Or dr("FechaInicio").ToString.ToDateTime > tFecha Then
If dr("FechaFin").ToString.ToDateTime > tFecha Or dr("FechaInicio").ToString.ToDateTime > tFecha Then
events.Add(cevent)
End If
Else

View File

@@ -1312,7 +1312,15 @@
<label for="<%= TxtFolioRemisionModal.ClientID.ToString()%>">Folio:</label>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group form-md-line-input input-iconright" runat="server" >
<asp:TextBox ID="TxtObservacionModal" runat="server" CssClass="form-control" CausesValidation="true" MaxLength="250"></asp:TextBox>
<label for="<%= TxtFolioRemisionModal.ClientID.ToString()%>">Observaciones:</label>
</div>
</div>
</div>
<br />
<div class="row">
<div class="col-md-12">

View File

@@ -3298,11 +3298,7 @@ Partial Class OS_OrdenesServicios
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"
@@ -3328,11 +3324,16 @@ Partial Class OS_OrdenesServicios
ProcesoOK = False
End If
End If
End If
If ProcesoOK Then
If Not ObjOS.UpdateOrdenesServiciosFinaliza(CveOS, -1, -1, UsuarioActual.CveEmpresa, Observaciones:=TxtObservacionModal.Text.Trim) Then
ProcesoOK = False
End If
End If
End If

View File

@@ -21,6 +21,10 @@
<li>
<asp:LinkButton ID="LnkExportar" runat="server" Visible="false"><i class="fa fa-file-excel-o"></i> Excel</asp:LinkButton>
</li>
<li>
<asp:LinkButton ID="LnkPersonalizar" OnClick="LnkPersonalizar_Click" runat="server" Visible="false"><i class="fa fa-pencil"></i>Personalizar Columnas</asp:LinkButton>
</li>
</ContentTemplate>
<Triggers>
@@ -174,21 +178,26 @@
<asp:BoundField HeaderText="Hospital" DataField="Nombre" />
<%--3--%>
<asp:BoundField HeaderText="Tipo" DataField="TipoVenta" />
<asp:BoundField HeaderText="Médico" DataField="Medico" />
<%--4--%>
<asp:BoundField HeaderText="Procedimiento" DataField="Procedimiento" />
<asp:BoundField HeaderText="Médico" DataField="Medico" />
<%--5--%>
<asp:BoundField HeaderText="Vendedor" DataField="Vendedor" />
<asp:BoundField HeaderText="Procedimiento" DataField="Procedimiento" />
<%--6--%>
<asp:BoundField HeaderText="Estatus" DataField="EstatusOrdenServicio" />
<asp:BoundField HeaderText="Vendedor" DataField="Vendedor" />
<%--7--%>
<asp:BoundField HeaderText="Técnico" DataField="NombreUsuario" />
<asp:BoundField HeaderText="Estatus" DataField="EstatusOrdenServicio" />
<%--8--%>
<asp:BoundField HeaderText="Paciente" DataField="Paciente" />
<asp:BoundField HeaderText="Técnico" DataField="NombreUsuario" />
<%--9--%>
<asp:BoundField HeaderText="Paciente" DataField="Paciente" />
<%--10--%>
<asp:BoundField HeaderText="Episodio" DataField="IdentificadorCliente" />
<%--11--%>
<asp:HyperLinkField HeaderText="Pedido" DataTextField="SerieFolioPedido" ControlStyle-CssClass="Texto" DataNavigateUrlFormatString="/Ventas/Ventas.aspx?CveVenta={0}" DataNavigateUrlFields="CveVentaPedido" Target="_blank" />
<%--12--%>
<asp:HyperLinkField HeaderText="Remisión" DataTextField="SerieFolioRemision" ControlStyle-CssClass="Texto" DataNavigateUrlFormatString="/Ventas/Ventas.aspx?CveVenta={0}" DataNavigateUrlFields="CveVentaRemision" Target="_blank" />
<%--13--%>
<asp:BoundField HeaderText="Observaciones" DataField="Observaciones" visible="false" />
</Columns>
</asp:GridView>
@@ -196,6 +205,45 @@
</asp:UpdatePanel>
<asp:UpdatePanel runat="server" ID="UPPersonalizar" UpdateMode="Conditional">
<ContentTemplate>
<div id="DivPersonalizar" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content SucursalCobranza-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">
<asp:Label ID="Label1" runat="server" ClientIDMode="Static" Text="Personalizar Columnas"></asp:Label></h4>
</div>
<div class="modal-body">
<table class="table table-striped nobordertop table-advance table-hover">
<tbody>
<tr>
<td style="text-align: left;"><asp:CheckBox ID="ChkObservaciones" runat="server" Text="&nbsp;Observaciones" Checked="false" /></td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<div class="row">
<div class="col-md-12">
<%--<button type="button" class="btn btn-success" data-dismiss="modal" onclick="$('#BtnPersonalizar').click();">Personalizar</button>--%>
<asp:Button ID="BtnPersonalizar" ClientIDMode="Static" runat="server" Text="Personalizar" class="btn btn-success" OnClick="BtnPersonalizar_Click" />
<button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
</div>
</div>
</div>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="JS" runat="Server">

View File

@@ -98,10 +98,14 @@ Partial Class OS_RepOSMedicas
Dim FechaI As Date = If(txtFechaI.Text.Trim = "", MinFecha, txtFechaI.Text.ToDate)
Dim FechaF As Date = If(txtFechaF.Text.Trim = "", MaxFecha, txtFechaF.Text.ToDate)
Dim Cvecliente As Integer = If(DdlClientes.SelectedValue.ToEntero > 0, DdlClientes.SelectedValue.ToEntero, -1)
LnkPersonalizar.Visible = False
If ObjOS.GetRepOrdenesServicioMedicasRep(FechaI, FechaF, Cvecliente, DdlVendedor.SelectedValue.ToEntero, DdlEstatusOS.SelectedValue.ToEntero, DdlTecnico.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, UsuarioActual.CveEmpresa,
CveMedico:=DdlMedico.SelectedValue.ToEntero, CveProcedimiento:=DdlProcedimiento.SelectedValue.ToEntero) Then
GvDatos.DataSource = ObjOS.DtResultados
If ObjOS.DtResultados IsNot Nothing AndAlso ObjOS.DtResultados.Rows.Count > 0 Then
LnkPersonalizar.Visible = True
End If
Else
GvDatos.DataSource = Nothing
End If
@@ -163,4 +167,27 @@ Partial Class OS_RepOSMedicas
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
End Sub
Protected Sub LnkPersonalizar_Click(sender As Object, e As EventArgs)
' ChkGuardarPersonalizacion.Checked = False
RegistraScript("$('#DivPersonalizar').modal('show')")
End Sub
Protected Sub BtnPersonalizar_Click(sender As Object, e As System.EventArgs) Handles BtnPersonalizar.Click
Personaliza()
End Sub
Private Sub Personaliza()
GvDatos.Columns(13).Visible = ChkObservaciones.Checked
CargaDatos()
End Sub
End Class

View File

@@ -90,12 +90,10 @@ Partial Class ListadoContratos
Dim CveContratoTipo As Integer = 2
Dim retorno As Boolean = False
If ObjContratos.GetContratosEstatus(UsuarioActual.CveEmpresa) Then
CveEstatusInicial = ObjContratos.DtResultados.FiltroPrimeroValor("CveContratoEstatus", "TipoEstatus=1").ToEntero
End If
CveEstatusInicial = GlobalDTContratosEstatus(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveContratoEstatus", "TipoEstatus=1").ToEntero
'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, TxtAnticipo.Text.ToDecimal, TxtPesos.Text.ToDecimal, TxtDolares.Text.ToDecimal, -1, 0, CveContratoTipo:=2, CveContratosEstatus:=1, CveTipoAF:=DdlTipoAF.SelectedValue.ToEntero, CveChofer:=DdlChofer.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:=CveEstatusInicial, CveTipoAF:=DdlTipoAF.SelectedValue.ToEntero, CveChofer:=DdlChofer.SelectedValue.ToEntero)
If CveContratoHijo > 0 Then
ObjContratos.Commit()
Alert("Agregado Correctamente.")

View File

@@ -0,0 +1,287 @@
<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="FacturacionGlobal.aspx.vb" Inherits="Ventas_FacturacionGlobal" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Css" runat="Server">
<style>
.v-center {
display: flex;
align-items: center;
}
.Widthall {
width: 100% !important;
}
.dataTables_scrollHeadInner {
width: 100% !important;
background-color: #dddddd;
padding-left: 0px !important;
}
.dataTables_scrollFoot {
display: none;
position: static;
}
.table-scrollable {
margin: 0px !important;
}
.dataTables_scroll {
margin-bottom: 0px;
}
.table.dataTable {
margin-top: 0px !important;
}
.dataTables_scrollBody table th {
padding: 0px !important;
padding-right: 4px !important;
padding-left: 4px !important;
}
.sinlink td a {
pointer-events: none;
cursor: default;
color: black;
font-size: small;
}
.white a {
color: white !important;
}
.select2 .select2-selection__rendered {
line-height: 1;
color: #111;
}
.select2 .select2-selection--multiple {
box-sizing: border-box;
cursor: pointer;
display: block;
min-height: 20px;
user-select: none;
-webkit-user-select: none;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice {
margin-top: 10px;
}
.select2-selection__rendered {
margin-top: 0px;
height: 25px;
}
.select2-selection {
margin-top: 0px;
height: 31px;
}
.select2-container--default.select2-container--focus .select2-selection--multiple {
border: none;
outline: 0;
}
</style>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="E" runat="Server">
Facturación global
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="HB" runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="H" runat="Server">
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="HA" runat="Server">
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="C" runat="Server">
<asp:UpdatePanel ID="UPFiltros" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div class="portlet solid grey-cascade portlet-filter" style="">
<div class="portlet-title portlet-filterT smalltitle" style="min-height: 49px; position: relative;">
<div class="tools">
<asp:Button ID="BtnConsultar" runat="server" Text="Consultar" class="btn btn-primary" OnClick="BtnConsultar_Click" ValidationGroup="Valida" />
<a href="javascript:;" data-idchekbox="<%= chkexpand.ClientID%>" class=" <%= IIf(chkexpand.Checked = True, "collapse", "expand")%>"></a>
<asp:CheckBox ID="chkexpand" CssClass="hidden" runat="server" />
</div>
<div class="titlefiltros caption">
<div class="row v-center">
<label class="col-md-1">Sucursal: </label>
<div class="col-md-2">
<asp:DropDownList ID="DdlSubProyecto" DataTextField="SubProyecto" DataValueField="CveSubProyecto" CssClass="ddlFiltros input-sm select2me Widthall" Style="width: 100%;" runat="server"></asp:DropDownList>
</div>
<label class="col-md-1 truncate">Fecha Inicial:</label>
<div class="col-md-1">
<div class="input-group input-sm input-small date date-picker" data-date-format="dd/mm/yyyy" style="width: 140px !important; padding: 0px;">
<asp:TextBox ID="txtFechaI" runat="server" CssClass="form-control" CausesValidation="true" MaxLength="10" Width="100px"></asp:TextBox>
<span class="input-group-btn ">
<asp:LinkButton ID="imgCalendario" class="btn default " Text="<i class='fa fa-calendar'></i>" runat="server"></asp:LinkButton>
</span>
<ajax:MaskedEditExtender ID="MEEFechaI" runat="server" TargetControlID="txtFechaI" Mask="99/99/9999" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left"></ajax:MaskedEditExtender>
<ajax:CalendarExtender runat="server" ID="Calendario" TargetControlID="txtFechaI" PopupButtonID="ImgCalendario" PopupPosition="BottomRight" Enabled="True"></ajax:CalendarExtender>
<asp:RequiredFieldValidator ID="rfvFechaI" runat="server" ControlToValidate="txtFechaI" Display="None" ErrorMessage="El campo <b>''Fecha Inicial''</b> es requerido por la aplicación, por favor ingrese una fecha." ValidationGroup="Valida"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="cvFechaI" runat="server" ControlToValidate="txtFechaI" Display="None" ErrorMessage="El campo <b>''Fecha Inicial''</b> no tienes el formato correcto, por favor intente de nuevo con el siguiente formato: (dd/mm/yyyy)." Operator="DataTypeCheck" Type="Date" ValidationGroup="Valida"></asp:CompareValidator>
<ajax:ValidatorCalloutExtender ID="vcoFfvFI" runat="server" HighlightCssClass="vco" TargetControlID="rfvFechaI" Width="350px"></ajax:ValidatorCalloutExtender>
<ajax:ValidatorCalloutExtender ID="vcoCvFI" runat="server" HighlightCssClass="vco" TargetControlID="cvFechaI" Width="350px"></ajax:ValidatorCalloutExtender>
</div>
</div>
<label class="col-md-1 truncate">Fecha Final:</label>
<div class="col-md-1">
<div class="input-group input-sm input-small date date-picker " data-date-format="dd/mm/yyyy" style="width: 140px !important; padding: 0px;">
<asp:TextBox ID="txtFechaF" runat="server" CssClass="form-control" CausesValidation="true" MaxLength="10" Width="100px"></asp:TextBox>
<span class="input-group-btn ">
<asp:LinkButton ID="imgCalendarioF" class="btn default " Text="<i class='fa fa-calendar'></i>" runat="server"></asp:LinkButton>
</span>
<ajax:MaskedEditExtender ID="MEEFechaF" runat="server" TargetControlID="txtFechaF" Mask="99/99/9999" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left"></ajax:MaskedEditExtender>
<ajax:CalendarExtender runat="server" ID="Calendario2" TargetControlID="txtFechaF" PopupButtonID="imgCalendarioF" PopupPosition="BottomRight" Enabled="True"></ajax:CalendarExtender>
<asp:RequiredFieldValidator ID="rfvFechaF" runat="server" ControlToValidate="txtFechaF" Display="None" ErrorMessage="El campo <b>''Fecha Final''</b> es requerido por la aplicación, por favor ingrese una fecha." ValidationGroup="Valida"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="cvFechaF" runat="server" ControlToValidate="txtFechaF" Display="None" ErrorMessage="El campo <b>''Fecha Final''</b> no tienes el formato correcto, por favor intente de nuevo con el siguiente formato: (dd/mm/yyyy)." Operator="DataTypeCheck" Type="Date" ValidationGroup="Valida"></asp:CompareValidator>
<ajax:ValidatorCalloutExtender ID="vcoRfvFF" runat="server" HighlightCssClass="vco" TargetControlID="rfvFechaF" Width="350px"></ajax:ValidatorCalloutExtender>
<ajax:ValidatorCalloutExtender ID="vcoCvFF" runat="server" HighlightCssClass="vco" TargetControlID="cvFechaF" Width="350px"></ajax:ValidatorCalloutExtender>
</div>
</div>
<label class="col-md-1 truncate">Cliente:</label>
<div class="col-md-2">
PUBLICO GENERAL
</div>
</div>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UPDatos" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div class="row">
<div class="col-md-10">
<div class="portlet light xspadding traspasorow bordered">
<div class="portlet-title">
<div class="caption font-green">
<span class="caption-subject bold uppercase" style="line-height: 1;">Remisiones por facturar</span>
</div>
<div class="actions">
<div class="btn-group">
<div class="row" style="margin-left: 0px; text-align: right" align="left">
<div style="margin-right: 15px">
<input type="text" id="TxtBusqueda" class="form-control input-sm" onkeyup="<%= String.Format("FiltrarTabla('TxtBusqueda','{0}')", GvDatos.ClientID) %>" style="display: inline-block; margin-right: -20px; width: 150px;" />
<a href="javascript:;" onclick="<%= String.Format("FiltrarTabla('TxtBusqueda','{0}')", GvDatos.ClientID) %>" style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"><i class="icon-magnifier"></i></a>
</div>
</div>
</div>
</div>
</div>
<div class="portlet-body rowpadding">
<div class="row">
<div class="col-md-12">
<asp:GridView ID="GvDatos" runat="server" AutoGenerateColumns="False" EmptyDataText="No se encontró ninguna remisión pendiente por facturar" DataKeyNames="CveVenta"
ToolTip="Remisiones sin Facturar"
CssClass="table table-striped table-advance table-hover Widthall ScrollAD"
data-sort="true" GridLines="None">
<Columns>
<asp:TemplateField ItemStyle-HorizontalAlign="center" HeaderText="" ItemStyle-Width="10%">
<HeaderTemplate>
<asp:CheckBox runat="server" ID="chkSelectAll" CssClass="ChkAllClick" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox runat="server" ID="chkDis" Visible="false" CssClass="ChkAllEvt" />
</ItemTemplate>
</asp:TemplateField>
<asp:HyperLinkField HeaderText="Folio" ItemStyle-Width="100px" DataTextField="Folio" DataNavigateUrlFormatString="/Ventas/Ventas.aspx?CveVenta={0}" DataNavigateUrlFields="CveVenta" Target="_blank" />
<asp:HyperLinkField HeaderText="Fecha" ItemStyle-Width="100px" DataTextField="Fecha" DataTextFormatString="{0:d}" DataNavigateUrlFormatString="/Ventas/Ventas.aspx?CveVenta={0}" DataNavigateUrlFields="CveVenta" />
<asp:BoundField DataField="SubTotal" HeaderText="SubTotal" DataFormatString="{0:N2}" ItemStyle-HorizontalAlign="Right" />
<asp:BoundField DataField="Descuento" HeaderText="Descuento" DataFormatString="{0:N2}" ItemStyle-HorizontalAlign="Right" />
<asp:BoundField DataField="IVA" HeaderText="IVA" DataFormatString="{0:N2}" ItemStyle-HorizontalAlign="Right" />
<asp:TemplateField ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="10%">
<HeaderTemplate>
<asp:Label Text="Total" runat="server" CausesValidation="false"> </asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="LtlTotal" runat="server" Text='<%# Eval("Total", "{0:N2}") & " " & Eval("Abreviatura").ToString %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle CssClass="Titulos" />
<RowStyle CssClass="Texto" />
<AlternatingRowStyle CssClass="TextoAlterno" />
</asp:GridView>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-2" style="padding-bottom: 15px; display: flex; align-items: flex-end; justify-content: flex-end;">
<asp:UpdatePanel ID="UpFacturar" runat="server" class="portlet light xspadding bordered " style="min-width: 100%;" UpdateMode="Conditional">
<ContentTemplate>
<div class="portlet-title">
<div class="caption font-green">
<i class="icon-pin font-green"></i>
<span class="caption-subject bold uppercase">Facturación </span>
</div>
<div class="actions">
<div class="btn-group">
</div>
</div>
<div class="tools">
<a href="javascript:;" class="collapse"></a>
</div>
</div>
<div class="portlet-body formnombottom">
<div class="row v-center">
<label class="col-md-3">Periodo: </label>
<div class="col-md-9">
<asp:DropDownList ID="DdlPeriodo" DataTextField="Descripcion" DataValueField="CveSATPeriodicidad" CssClass="ddlFiltros input-sm select2me Widthall" Style="width: 100%;" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DdlPeriodo_SelectedIndexChanged"></asp:DropDownList>
<asp:RequiredFieldValidator ID="RFVPeriodo" runat="server" InitialValue="-1" ControlToValidate="DdlPeriodo" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Periodo''</b> es necesario, por favor ingréselo." ValidationGroup="GrpEmitir"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VCEPerido" runat="server" HighlightCssClass="vco" TargetControlID="RFVPeriodo" Width="350px"></ajax:ValidatorCalloutExtender>
</div>
</div>
<br />
<div class="row v-center">
<label class="col-md-3">Mes: </label>
<div class="col-md-9">
<asp:DropDownList ID="DdlMes" DataTextField="Descripcion" DataValueField="CveSATMes" CssClass="ddlFiltros input-sm select2me Widthall" Style="width: 100%;" runat="server"></asp:DropDownList>
<asp:RequiredFieldValidator ID="RFVMes" runat="server" InitialValue="-1" ControlToValidate="DdlMes" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Mes''</b> es necesario, por favor ingréselo." ValidationGroup="GrpEmitir"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VCEMes" runat="server" HighlightCssClass="vco" TargetControlID="RFVMes" Width="350px"></ajax:ValidatorCalloutExtender>
</div>
</div>
<br />
<div class="row v-center">
<label class="col-md-3 ">Año:</label>
<div class="col-md-9">
<asp:DropDownList ID="DdlAnio" CssClass="ddlFiltros input-sm select2me Widthall" Style="width: 100%;" runat="server">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RFVAnio" runat="server" InitialValue="-1" ControlToValidate="DdlAnio" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Mes''</b> es necesario, por favor ingréselo." ValidationGroup="GrpEmitir"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VCEAnio" runat="server" HighlightCssClass="vco" TargetControlID="RFVAnio" Width="350px"></ajax:ValidatorCalloutExtender>
</div>
</div>
<br />
<div class="row">
<div class="col-md-12">
<table border="0" class="Widthall" style="padding-top: 20px;">
<tr>
<td align="center">
<asp:UpdatePanel ID="UpGuardar" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="BtnGuardar" runat="server" CssClass="btn btn-primary" Text="Emitir e Imprimir" ValidationGroup="GrpEmitir" OnClick="BtnGuardar_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</table>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
<asp:Content ID="Content8" ContentPlaceHolderID="JS" runat="Server">
<script>
$('body').on('click', '.ChkAllClick input', function () { $(".ChkAllEvt input").not(this).prop('checked', $('.ChkAllClick input').is(':checked')); });
</script>
</asp:Content>

View File

@@ -0,0 +1,227 @@
Option Explicit On
Option Strict On
Imports System.Data
Imports Extensiones
Partial Class Ventas_FacturacionGlobal
Inherits ClsPaginas
Private Property CveSubProyecto As Integer
Get
Return If(IsNothing(ViewState("CveSubProyecto")), -1, ViewState("CveSubProyecto").ToString().ToEntero())
End Get
Set(value As Integer)
ViewState("CveSubProyecto") = value
End Set
End Property
Private Property DtRemisiones As DataTable
Get
Return If(IsNothing(ViewState("DtRemisiones")), Nothing, CType(ViewState("DtRemisiones"), DataTable))
End Get
Set(value As DataTable)
ViewState("DtRemisiones") = value
End Set
End Property
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
CargaCombos()
End If
End Sub
#Region " C A R G A - D A T O S "
Public Sub CargaCombos()
DdlSubProyecto.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa)
DdlSubProyecto.DataBind()
DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlPeriodo.DataSource = GlobalDTGralSATPeriodicidad()
DdlPeriodo.DataBind()
DdlPeriodo.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlMes.DataSource = GlobalDTGralSATMeses().FiltraParametros("ISNULL(CveSATPeriodicidad,0) <> 5")
DdlMes.DataBind()
DdlMes.Items.Insert(0, New ListItem("Seleccione", "-1"))
Dim Anio As Integer = Now.Year
Dim AnioAnterior As Integer = Now.Year - 1
DdlAnio.Items.Add(New ListItem(Anio.ToString(), Anio.ToString()))
DdlAnio.Items.Add(New ListItem(AnioAnterior.ToString(), AnioAnterior.ToString()))
End Sub
Protected Sub DdlPeriodo_SelectedIndexChanged(sender As Object, e As EventArgs)
If DdlPeriodo.SelectedValue = "5" Then
DdlMes.DataSource = GlobalDTGralSATMeses().FiltraParametros("ISNULL(CveSATPeriodicidad,0) = 5")
Else
DdlMes.DataSource = GlobalDTGralSATMeses().FiltraParametros("ISNULL(CveSATPeriodicidad,0) <> 5")
End If
DdlMes.DataBind()
UPFiltros.Update()
End Sub
'Private Function CalculaFechas() As MFiltroPeriodicidad
' Dim Retorno As New MFiltroPeriodicidad()
' Dim Mes As String = GlobalDTGralSATMeses().FiltroPrimeroValor("Mes", $"CveSATMes = {DdlMes.SelectedValue}")
' Select Case DdlPeriodo.SelectedValue
' Case "1"
' Retorno.FechaI = DateTime.Now.AddDays(-1).Day.ToString() + "/" + Mes + "/" + DdlAnio.SelectedValue
' Retorno.FechaF = Retorno.FechaI.ToDate().AddDays(1).ToString("dd/MM/yyyy")
' Case "2"
' Retorno.FechaI = DateTime.Now.AddDays(-7).Day.ToString() + "/" + Mes + "/" + DdlAnio.SelectedValue
' Retorno.FechaF = Retorno.FechaI.ToDate().AddDays(7).ToString("dd/MM/yyyy")
' Case "3"
' If DateTime.Now.Day < 16 Then
' Retorno.FechaI = "01/" + Mes + "/" + DdlAnio.SelectedValue
' Retorno.FechaF = "15/" + Mes + "/" + DdlAnio.SelectedValue
' Else
' Dim LastDayOfMonth = DateTime.DaysInMonth(DdlAnio.SelectedValue.ToEntero(), DdlMes.SelectedValue.ToEntero())
' Retorno.FechaI = "16/" + Mes + "/" + DdlAnio.SelectedValue
' Retorno.FechaF = LastDayOfMonth.ToString() + "/" + Mes + "/" + DdlAnio.SelectedValue
' End If
' Case "4"
' Dim LastDayOfMonth = DateTime.DaysInMonth(DdlAnio.SelectedValue.ToEntero(), DdlMes.SelectedValue.ToEntero())
' Retorno.FechaI = "01/" + Mes + "/" + DdlAnio.SelectedValue
' Retorno.FechaF = LastDayOfMonth.ToString() + "/" + Mes + "/" + DdlAnio.SelectedValue
' Case "5"
' Dim LastDayOfMonth = DateTime.DaysInMonth(DdlAnio.SelectedValue.ToEntero(), DdlMes.SelectedValue.ToEntero())
' Dim PrimerMes = GlobalDTGralSATMeses().FiltroPrimeroValor("PrimerMes", $"CveSATMes = {DdlMes.SelectedValue}")
' Dim SegundoMes = GlobalDTGralSATMeses().FiltroPrimeroValor("SegundoMes", $"CveSATMes = {DdlMes.SelectedValue}")
' Retorno.FechaI = "01/" + PrimerMes + "/" + DdlAnio.SelectedValue
' Retorno.FechaF = LastDayOfMonth.ToString() + "/" + SegundoMes + "/" + DdlAnio.SelectedValue
' End Select
' Return Retorno
'End Function
Public Sub CargaDatos()
Me.CveSubProyecto = -1
Dim CveCliente As Integer = UsuarioActual.Empresa.Funcionalidad(714).ToEntero()
Dim FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.Trim(), "-1")
Dim FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim(), "-1")
Dim ObjVentas As New ClsVentas
If ObjVentas.GetRepRemisionesSinFacturar(FechaI, FechaF, "-1", DdlSubProyecto.SelectedValue, CveCliente, -1, "-1", UsuarioActual.CveEmpresa, CveUsuarioConsulta:=UsuarioActual.CveUsuario, ConsultaInventario:=False) Then
DtRemisiones = ObjVentas.DtResultados.FiltraParametros("CveVenta > 0 OR Folio IN ('Total Pesos')")
Me.CveSubProyecto = DdlSubProyecto.SelectedValue.ToEntero()
Else
DtRemisiones = Nothing
End If
ObjVentas.Dispose()
GvDatos.DataSource = DtRemisiones
GvDatos.DataBind()
UPDatos.Update()
End Sub
#End Region
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
CargaDatos()
End Sub
Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DBCampo("CveVenta").ToEntero() > 0 Then
e.Row.FCCheckBox("chkDis").Visible = True
Else
e.Row.CssClass = "Totales"
End If
End If
End Sub
Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs)
Dim CveCliente As Integer = UsuarioActual.Empresa.Funcionalidad(714).ToEntero()
Dim CveMoneda As Integer = -1
Dim SbRemisiones As New StringBuilder()
Dim RemisionesLista As New List(Of Integer)
For Each RowRem As GridViewRow In GvDatos.Rows
If RowRem.RowType = DataControlRowType.DataRow Then
If RowRem.FCCheckBox("chkDis").Checked Then
SbRemisiones.AppendFormat("{0},", RowRem.DataKey("CveVenta"))
RemisionesLista.Add(RowRem.DataKey("CveVenta").ToEntero())
End If
End If
Next
If RemisionesLista.Count = 0 Then
Alert("Debe seleccionar al menos una remisión", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
SbRemisiones.Remove(SbRemisiones.Length - 1, 1)
Dim DtRemisionesPS As New DataTable()
Dim ObjClientes As New ClsClientes
If ObjClientes.GetVentasRemisionesTotales(CveCliente, SbRemisiones.ToString(), 1) Then
DtRemisionesPS = ObjClientes.DtResultados.Copy()
End If
ObjClientes.Dispose()
Dim ObjFactura = Modelos.Factura.CrearVentaNueva(UsuarioActual, Me.CveSubProyecto, CveCliente, CveMoneda, "Ing")
ObjFactura.EsFacturaGlobal = True
ObjFactura.CveSATPeriodicidad = DdlPeriodo.SelectedValue.ToEntero()
ObjFactura.CveSATMes = DdlMes.SelectedValue.ToEntero()
ObjFactura.SATAnio = DdlAnio.SelectedValue.ToEntero()
ObjFactura.RemisionesLista = RemisionesLista
ObjFactura.DtRemisionesPS = DtRemisionesPS
ObjFactura.DtRemisiones = DtRemisiones.FiltraParametros($"CveVenta IN ({SbRemisiones.ToString()})")
For Each Dr As DataRow In DtRemisionesPS.Rows
ObjFactura.AgregarPS(Dr("CvePS").ToString().ToEntero(), Dr("Cantidad").ToString().ToDecimal(), Dr("PU").ToString().ToDecimal(), Dr("Descuento").ToString().ToDecimal, Dr("Obs").ToString(), CveUM:=Dr("CveUM").ToString().ToEntero(),
CveProyecto:=Dr("CveProyecto").ToString().ToEntero(), CveSubProyecto:=Dr("CveSubProyecto").ToString().ToEntero(), CveVentaDetallePadre:=Dr("CveVentaDetalle").ToString().ToEntero(), CveVentaDetalleRemision:=Dr("CveVentaDetalle").ToString().ToEntero())
Next
ObjFactura.CalculaTotales()
ObjFactura.PreparaTimbre()
'ObjFactura.DtInventario = ObjFactura.DtDetalle.FiltraParametros("CveTipoPs = 2")
Dim SbAlert As New StringBuilder()
Dim urlFactura As String = ""
Dim Retorno As Modelos.Factura.MMensajeFactura = Nothing
Try
Retorno = ObjFactura.EmitirFactura(True)
If Retorno IsNot Nothing AndAlso Retorno.CveVenta > 0 Then
SbAlert.AppendFormat("{0}<br>", Retorno.Mensajes(Retorno.Mensajes.Count - 1))
SbAlert.AppendFormat("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar PDF Factura</a></li></ul><br/>", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1", Retorno.CveVenta)))
urlFactura = $"/Compras/PopUpVerFactura.aspx?P={Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1", Retorno.CveVenta))}"
Else
SbAlert.Append("Ocurrió un error al generar la factura")
End If
Catch ex As Exception
SbAlert.Append("Ocurrió un error al generar el documento")
GuardaLog(ex.ToString())
End Try
If Retorno IsNot Nothing AndAlso Retorno.Mensajes.Count > 0 Then
Retorno.Mensajes(Retorno.Mensajes.Count - 1) = SbAlert.ToString()
End If
If Retorno IsNot Nothing AndAlso Retorno.Mensajes IsNot Nothing AndAlso Retorno.Mensajes.Count > 0 Then
For Each Mensaje As String In Retorno.Mensajes
Alert(Mensaje, If(Retorno.TieneError, TipoMensaje.MsgError, TipoMensaje.MsgInformacion), If(Retorno.TieneError, "", "document.location.href=""/Ventas/FacturacionGlobal.aspx"";"), ShowCloseButton:=False)
Next
Else
If SbAlert.Length = 0 Then
SbAlert.Append("Ocurrió un error al generar la factura")
End If
Alert(SbAlert.ToString(), TipoMensaje.MsgError, ShowCloseButton:=False)
End If
If ObjFactura IsNot Nothing Then
ObjFactura.Dispose()
End If
End Sub
End Class

View File

@@ -8517,7 +8517,13 @@
<asp:BoundField DataField="Abreviatura" HeaderText="UM">
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="Precio" HeaderText="Precio" DataFormatString="{0:#,##0.###}" HtmlEncode="False" />
<asp:TemplateField ItemStyle-HorizontalAlign="Right" HeaderText="Precio" ItemStyle-Width="30px">
<ItemTemplate>
<asp:TextBox ID="TxtPrecio" runat="server" Text='<%# Eval("Precio", "{0:N4}") %>' Style="text-align: right!important" Width="80px" Enabled="false"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<%--<asp:BoundField DataField="Precio" HeaderText="Precio" DataFormatString="{0:#,##0.###}" HtmlEncode="False" />--%>
</Columns>
<HeaderStyle CssClass="Titulos" Height="15px"></HeaderStyle>
</asp:GridView>

View File

@@ -2732,6 +2732,14 @@ Partial Class Ventas
End Using
If TmpDT IsNot Nothing Then
DtInv = TmpDT.Copy.FiltraParametros("CveTipoPS = 2")
TabAlmacen.Visible = True
DivAlmacen.Visible = True
CargaGVInv(DtInv)
End If
If AplicaComercioExterior Then
CargaGvComercioExterior()
End If
@@ -12067,6 +12075,12 @@ Partial Class Ventas
'Amortizacion
ObjFactura.CveTipoRelacion = DdlTipoRelacionAnticipo.SelectedValue.ToEntero()
If Me.AplicaRelacionManual Then
If DdlTipoRelacionARelacionar.SelectedValue.ToEntero() > 0 AndAlso Me.TmpDTFacturasRelacionadas IsNot Nothing AndAlso Me.TmpDTFacturasRelacionadas.Rows.Count > 0 Then
ObjFactura.CveTipoRelacion = DdlTipoRelacionARelacionar.SelectedValue.ToEntero()
End If
End If
'If ObjFactura.CveTipoRelacion > 0 Then
' Select Case ObjFactura.CveTipoRelacion
' Case 7
@@ -12617,7 +12631,7 @@ Partial Class Ventas
End If
'SI LAS FACTURAS SE RELACIONARAN MANUALMENTE SE AGREGAN
If UsuarioActual.TienePermisoProceso(321) AndAlso Me.AplicaRelacionManual AndAlso DdlTipoRelacionARelacionar.SelectedValue.ToEntero() > 0 Then
If Me.AplicaRelacionManual AndAlso DdlTipoRelacionARelacionar.SelectedValue.ToEntero() > 0 Then
Dim CveTipoRelacion As Integer = DdlTipoRelacionARelacionar.SelectedValue.ToEntero()
@@ -13394,7 +13408,7 @@ Partial Class Ventas
End If
End If
If UsuarioActual.TienePermisoProceso(321) AndAlso Me.AplicaRelacionManual Then
If Me.AplicaRelacionManual Then
For Each GvRow As GridViewRow In GvFacturasRelacionadas.Rows
If GvRow.RowType = DataControlRowType.DataRow Then
If GvRow.DataKey("CveVenta").ToEntero() > 0 Then
@@ -36417,12 +36431,13 @@ Partial Class Ventas
Dim Cantidad As Decimal = GvRow.FCTextBox("TxtCantidad").Text.ToDecimal
Dim CveUnidadMedida As Integer = GvRow.DataKey("CveUnidadMedida").ToEntero
Dim Abreviatura As String = GvRow.DataKey("Abreviatura").ToString
Dim PU As Decimal = GvRow.DataKey("Precio").ToDecimal
Dim CveClasificacion As Integer = GvRow.DataKey("CveClasificacion").ToEntero
Dim Clasificacion As String = GvRow.DataKey("Clasificacion").ToString
Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero
Dim CodigoPS As String = GvRow.DataKey("CodigoPS")
Dim PU As Decimal = GvRow.FCTextBox("TxtPrecio").Text.ToDecimal
If Cantidad > 0 Then
If Not ValidaAgregarPS(CvePS, CveUnidadMedida, PU, 2, Cantidad, CodigoPS) Then
Alert("No hay existencia.", TipoMensaje.MsgAdvertencia)
@@ -36501,7 +36516,7 @@ Partial Class Ventas
Dim Cantidad As Decimal = GvRow.FCTextBox("TxtCantidad").Text.ToDecimal
Dim CveUnidadMedida As Integer = GvRow.DataKey("CveUnidadMedida").ToEntero
Dim Abreviatura As String = GvRow.DataKey("Abreviatura").ToString
Dim PU As Decimal = GvRow.DataKey("Precio").ToDecimal
Dim PU As Decimal = GvRow.FCTextBox("TxtPrecio").Text.ToDecimal
Dim CveClasificacion As Integer = GvRow.DataKey("CveClasificacion").ToEntero
Dim Clasificacion As String = GvRow.DataKey("Clasificacion").ToString
Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero
@@ -36565,6 +36580,37 @@ Partial Class Ventas
GvProductosProcedimiento.DataBind()
DVGvProductosProcedimiento.Visible = True
For Each GvRow As GridViewRow In GvProductosProcedimiento.Rows
If RBLTipoVenta.SelectedValue = "2" Then
Dim Cantidad As Decimal = GvRow.FCTextBox("TxtCantidad").Text.ToDecimal
Dim CveUnidadMedida As Integer = GvRow.DataKey("CveUnidadMedida").ToEntero
Dim Abreviatura As String = GvRow.DataKey("Abreviatura").ToString
Dim PU As Decimal = GvRow.DataKey("Precio").ToDecimal
Dim CveClasificacion As Integer = GvRow.DataKey("CveClasificacion").ToEntero
Dim Clasificacion As String = GvRow.DataKey("Clasificacion").ToString
Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero
'SUGIERE PRECIO
Dim PrecioSugerido As Decimal = 0
Dim tPrecioSugerido As Decimal = 0
tPrecioSugerido = PU
Dim ObjPrecioSugerido As Modelos.MPrecioSugerido = CalculaPrecioSugerido(CvePS, CveClasificacion)
PrecioSugerido = ObjPrecioSugerido.PrecioSugerido
If ObjPrecioSugerido.CvePrecioLista > 0 AndAlso DivPrecioLista.Visible Then
DdlPrecioLista.SelectedValueExist(ObjPrecioSugerido.CvePrecioLista)
End If
If PrecioSugerido <= 0 Then PrecioSugerido = tPrecioSugerido
GvRow.FCTextBox("TxtPrecio").Text = PrecioSugerido.ToString("#,###.####")
End If
Next
UpDvModalTipoVenta.Update()
End Sub