From 9a27430165bc8c1a6c1251a4f46628b018461b37 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Tue, 6 Feb 2024 17:05:10 -0700 Subject: [PATCH 1/6] --Generar movto de almacen cuando viene desde manifiesto --- Ventas/Ventas.aspx.vb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 6746f54e3..c4d1062b7 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -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 From b1694458fefe327eb9abb8d0d0d4ba12609f3378 Mon Sep 17 00:00:00 2001 From: rakcsle Date: Wed, 7 Feb 2024 08:18:37 -0700 Subject: [PATCH 2/6] SMS - 2024.02.06 OS Observaciones, Rep Cirugias Observaciones personalizar --- App_Code/ClsOS.vb | 3 +- Ashx/CargaEventos.ashx | 4 +-- OS/OrdenesServicios.aspx | 10 ++++++- OS/OrdenesServicios.aspx.vb | 19 ++++++------ OS/RepOSMedicas.aspx | 60 +++++++++++++++++++++++++++++++++---- OS/RepOSMedicas.aspx.vb | 27 +++++++++++++++++ 6 files changed, 104 insertions(+), 19 deletions(-) diff --git a/App_Code/ClsOS.vb b/App_Code/ClsOS.vb index 1bd14b0b8..3e736c02e 100644 --- a/App_Code/ClsOS.vb +++ b/App_Code/ClsOS.vb @@ -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 diff --git a/Ashx/CargaEventos.ashx b/Ashx/CargaEventos.ashx index 4e6bc3267..344297e94 100644 --- a/Ashx/CargaEventos.ashx +++ b/Ashx/CargaEventos.ashx @@ -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 diff --git a/OS/OrdenesServicios.aspx b/OS/OrdenesServicios.aspx index 98bab92bd..bbe58e696 100644 --- a/OS/OrdenesServicios.aspx +++ b/OS/OrdenesServicios.aspx @@ -1312,7 +1312,15 @@ - + +
+
+
+ + +
+
+

diff --git a/OS/OrdenesServicios.aspx.vb b/OS/OrdenesServicios.aspx.vb index 6bfe489ec..31d94fb18 100644 --- a/OS/OrdenesServicios.aspx.vb +++ b/OS/OrdenesServicios.aspx.vb @@ -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 diff --git a/OS/RepOSMedicas.aspx b/OS/RepOSMedicas.aspx index 8da020fa3..621e7e27c 100644 --- a/OS/RepOSMedicas.aspx +++ b/OS/RepOSMedicas.aspx @@ -21,6 +21,10 @@
  • Excel
  • +
  • + + Personalizar Columnas +
  • @@ -174,21 +178,26 @@ <%--3--%> - <%--4--%> - + <%--5--%> - + <%--6--%> - + <%--7--%> - + <%--8--%> - + <%--9--%> + + <%--10--%> + <%--11--%> + <%--12--%> + <%--13--%> + @@ -196,6 +205,45 @@ + + + + + + diff --git a/OS/RepOSMedicas.aspx.vb b/OS/RepOSMedicas.aspx.vb index a68acdb0b..a231dbf39 100644 --- a/OS/RepOSMedicas.aspx.vb +++ b/OS/RepOSMedicas.aspx.vb @@ -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 From 13178dfbcb5572a105e2f4cc45dd20547074a859 Mon Sep 17 00:00:00 2001 From: rrene Date: Wed, 7 Feb 2024 08:30:14 -0700 Subject: [PATCH 3/6] -- cambios en estatus inicial --- Transportes/RepContratos.aspx.vb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Transportes/RepContratos.aspx.vb b/Transportes/RepContratos.aspx.vb index 2ee2ee576..9b7187055 100644 --- a/Transportes/RepContratos.aspx.vb +++ b/Transportes/RepContratos.aspx.vb @@ -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.") From ee0279a9a67674f14b4568667a6964b1da24cce4 Mon Sep 17 00:00:00 2001 From: rakcsle Date: Wed, 7 Feb 2024 09:16:41 -0700 Subject: [PATCH 4/6] SMS - 2024.02.06 precios en modal, cuando es tipo de venta: venta directa --- Ventas/Ventas.aspx | 8 +++++++- Ventas/Ventas.aspx.vb | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index e8ba1c28f..592764f8e 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -8517,7 +8517,13 @@ - + + + + + + + <%----%> diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 6746f54e3..e1f2aec54 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -36417,12 +36417,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 +36502,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 +36566,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 From b2cbe4a71d46e2b7e77862af1191fb472b9ba6b0 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 7 Feb 2024 10:16:32 -0700 Subject: [PATCH 5/6] --pantalla de facturacion global --- App_Code/ClsClientes.vb | 2 +- App_Code/ClsGenerales.vb | 27 ++ App_Code/ClsPaginas.vb | 59 ++++- App_Code/ClsVentas.vb | 8 +- App_Code/Modelos.vb | 437 +++++++++++++++++++++---------- Ventas/FacturacionGlobal.aspx | 287 ++++++++++++++++++++ Ventas/FacturacionGlobal.aspx.vb | 227 ++++++++++++++++ 7 files changed, 896 insertions(+), 151 deletions(-) create mode 100644 Ventas/FacturacionGlobal.aspx create mode 100644 Ventas/FacturacionGlobal.aspx.vb diff --git a/App_Code/ClsClientes.vb b/App_Code/ClsClientes.vb index fe124ff28..a7804beb0 100644 --- a/App_Code/ClsClientes.vb +++ b/App_Code/ClsClientes.vb @@ -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 diff --git a/App_Code/ClsGenerales.vb b/App_Code/ClsGenerales.vb index 7f52bb552..9f2ba1de5 100644 --- a/App_Code/ClsGenerales.vb +++ b/App_Code/ClsGenerales.vb @@ -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 diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 81a751e4c..c90d114eb 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -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" @@ -5342,7 +5373,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 @@ -5714,7 +5745,7 @@ Public Class ClsPaginas End If If UsarStimul Then - Dim bytesPDF = 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 @@ -5723,7 +5754,7 @@ Public Class ClsPaginas If Archivo.Exists Then If RegenerarPDF Then Archivo.Delete() - Dim bytesPDF = 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 @@ -5744,7 +5775,7 @@ Public Class ClsPaginas Archivo = Nothing End If Else - Dim bytesPDF = 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 @@ -6366,7 +6397,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 @@ -6907,6 +6938,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 @@ -10643,7 +10690,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) diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index ab9e9da34..6f7c546d5 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -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 diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index cb05523bc..3f30dd49c 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -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.
    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 diff --git a/Ventas/FacturacionGlobal.aspx b/Ventas/FacturacionGlobal.aspx new file mode 100644 index 000000000..03f285bb6 --- /dev/null +++ b/Ventas/FacturacionGlobal.aspx @@ -0,0 +1,287 @@ +<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="FacturacionGlobal.aspx.vb" Inherits="Ventas_FacturacionGlobal" %> + + + + + + + + Facturación global + + + + + + + + + + +
    +
    +
    + + "> + +
    +
    +
    + +
    + +
    + +
    +
    + + + + + + + + + + +
    +
    + +
    +
    + + + + + + + + + + +
    +
    + +
    + PUBLICO GENERAL +
    +
    +
    +
    +
    +
    +
    + + +
    +
    +
    +
    +
    + Remisiones por facturar +
    +
    +
    +
    +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    +
    +
    +
    + + +
    +
    + + Facturación +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    + +
    + + + +
    +
    +
    +
    + +
    + + + +
    +
    +
    +
    + +
    + + + + +
    +
    +
    +
    +
    + + + + +
    + + + + + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + + + diff --git a/Ventas/FacturacionGlobal.aspx.vb b/Ventas/FacturacionGlobal.aspx.vb new file mode 100644 index 000000000..b766d3436 --- /dev/null +++ b/Ventas/FacturacionGlobal.aspx.vb @@ -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}
    ", Retorno.Mensajes(Retorno.Mensajes.Count - 1)) + SbAlert.AppendFormat("
    ", 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 From eaf6f2b872f476581dae05e1df2c2e760f8547a2 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 7 Feb 2024 15:43:54 -0700 Subject: [PATCH 6/6] =?UTF-8?q?--Correci=C3=B3n=20de=20tipo=20de=20relacio?= =?UTF-8?q?n=20manual?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ventas/Ventas.aspx.vb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 9f0633599..a17c40d89 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -12075,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 @@ -12625,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() @@ -13402,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