diff --git a/Agropecuaria/RepPreciosVentaManifiesto.aspx b/Agropecuaria/RepPreciosVentaManifiesto.aspx index 7aa2415ec..ef0b88763 100644 --- a/Agropecuaria/RepPreciosVentaManifiesto.aspx +++ b/Agropecuaria/RepPreciosVentaManifiesto.aspx @@ -128,7 +128,7 @@ font-size: 12px;
@@ -139,12 +139,11 @@ font-size: 12px; + - - - - + + diff --git a/Agropecuaria/RepPreciosVentaManifiesto.aspx.vb b/Agropecuaria/RepPreciosVentaManifiesto.aspx.vb index e413df747..f3b8abb5b 100644 --- a/Agropecuaria/RepPreciosVentaManifiesto.aspx.vb +++ b/Agropecuaria/RepPreciosVentaManifiesto.aspx.vb @@ -25,10 +25,10 @@ Partial Class Agrupecuaria_RepPreciosVentaManifiesto If Not IsPostBack Then If UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario.Contiene(77, 21) Then Response.Redirect("/Inicio.aspx") - txtFechaI.Text = $"01/{Now.Month.ToString("0#")}/{Now.Year}" + txtFechaI.Text = Now.AddDays(-1).ToString("dd/MM/yyyy") txtFechaF.Text = Now.ToString("dd/MM/yyyy") - TxtModalFechaInicio.Text = $"01/{Now.Month.ToString("0#")}/{Now.Year}" + TxtModalFechaInicio.Text = Now.AddDays(-1).ToString("dd/MM/yyyy") TxtModalFechaFin.Text = Now.ToString("dd/MM/yyyy") CargaCombos() @@ -120,6 +120,13 @@ Partial Class Agrupecuaria_RepPreciosVentaManifiesto #Region " GV DATOS - ROW DATABOUND " Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + Dim Dif As Decimal = e.Row.DataKey("Diferencia").ToDecimal + If Dif < 0 Then + e.Row.Cells(11).ForeColor = Drawing.Color.Red + e.Row.Cells(12).ForeColor = Drawing.Color.Red + End If + End If End Sub #End Region diff --git a/App_Code/ClsGenerales.vb b/App_Code/ClsGenerales.vb index 4e0ef922e..7b7617049 100644 --- a/App_Code/ClsGenerales.vb +++ b/App_Code/ClsGenerales.vb @@ -384,10 +384,32 @@ Public Class ClsGenerales End Try Return ds - End Function - + End Function + + Public Function GetDashboardData(CveEmpresa As Integer) As DataSet + Dim ds As New DataSet + DataAdapter("PA_Gral_DashboardsGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@Opcion", SqlDbType.Int).Value = 1 + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@FechaInicio", SqlDbType.Date).Value = Date.Now.AddYears(-1) + .Add("@FechaFin", SqlDbType.Date).Value = Date.Now + End With + + Try + SqlAdapter.Fill(ds) + ds.Tables(0).TableName = "Indicadores" + ds.Tables(1).TableName = "DetalleDia" + Return ds + Catch ex As Exception + ' Manejo de errores + Return Nothing + End Try + End Function + + #End Region - + #Region " D I A S I N H A B I L E S " Public Function DiasInhabiles_Add(CveEmpresa As Integer, CveUsuario As Integer, DiaInhabil As String, Descripcion As String, Estatus As Integer, FechaInhabil As Date) As Boolean Dim Retorno As Boolean = False diff --git a/App_Code/ClsMovimientos.vb b/App_Code/ClsMovimientos.vb index 4cad5571a..373a3253f 100644 --- a/App_Code/ClsMovimientos.vb +++ b/App_Code/ClsMovimientos.vb @@ -789,7 +789,6 @@ Public Class ClsMovimientos Public Function GetEgresosSinComprobar(FechaInicio As String, FechaFin As String, CveProveedor As Integer, CvePersonal As Integer, CveClasificacion As Integer, CveUsuarioRegistro As Integer, CveUsuarioResponsable As Integer, CveMoneda As Integer, Saldo As Double, CveEmpresa As Integer, Optional CveTipoTransaccion As Integer = -1, Optional CveUsuarioSolicito As Integer = -1) As Boolean Dim Retorno As Boolean = False - DataAdapter("PA_Banc_EgresosSinComprobar") With SqlAdapter.SelectCommand.Parameters @@ -820,7 +819,6 @@ Public Class ClsMovimientos Public Function GetIngresosAcreedorXSaldar(CveProveedor As Integer, CveMoneda As Integer, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False - DataAdapter("PA_Banc_IngresosAcreedorXSaldar") With SqlAdapter.SelectCommand.Parameters @@ -840,7 +838,6 @@ Public Class ClsMovimientos End Function Public Function GetPrestamosPersonalXSaldar(CvePersonal As Integer, CveMoneda As Integer, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False - DataAdapter("PA_Banc_PrestamosPersonalXSaldar") With SqlAdapter.SelectCommand.Parameters @@ -861,7 +858,6 @@ Public Class ClsMovimientos Public Function GetDeudoresrXSaldar(CveProveedor As Integer, CveMoneda As Integer, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False - DataAdapter("PA_Banc_DuedorXSaldar") With SqlAdapter.SelectCommand.Parameters @@ -883,7 +879,6 @@ Public Class ClsMovimientos Public Function GetIngresosPorComprobar(FechaInicio As String, FechaFin As String, CveCliente As Integer, CveUsuarioRegistro As Integer, CveMoneda As Integer, Saldo As Double, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False - DataAdapter("PA_Banc_IngresosPorComprobar") With SqlAdapter.SelectCommand.Parameters @@ -909,7 +904,6 @@ Public Class ClsMovimientos Public Function GetIngresosAnticiposPorComprobar(FechaInicio As String, FechaFin As String, CveCliente As Integer, CveUsuarioRegistro As Integer, CveMoneda As Integer, Saldo As Double, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False - DataAdapter("PA_Banc_IngresosAnticiposSinComprobar") With SqlAdapter.SelectCommand.Parameters @@ -935,7 +929,6 @@ Public Class ClsMovimientos Public Function GetMovimientosIE(Opcion As Integer, CveFiltro As Integer, CveCuentaBancaria As Integer, FechaInicio As Date, FechaFin As Date, CveMoneda As Integer, Saldo As Double, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False - DataAdapter("PA_Banc_MovimientosIE") With SqlAdapter.SelectCommand.Parameters @@ -962,7 +955,6 @@ Public Class ClsMovimientos Public Function GetEgresosSinComprobarPersonal(CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False - DataAdapter("PA_Banc_EgresosSinComprobarPersonal") With SqlAdapter.SelectCommand.Parameters @@ -982,7 +974,6 @@ Public Class ClsMovimientos Public Function GetChequesFYE(CveEmpresa As Integer, Optional FechaI As DateTime = ModExtensiones.MinFecha, Optional FechaF As DateTime = ModExtensiones.MaxFecha) As Boolean Dim Retorno As Boolean = False - DataAdapter("PA_Banc_ReporteChequesFYEGet") With SqlAdapter.SelectCommand.Parameters @@ -1004,7 +995,6 @@ Public Class ClsMovimientos Public Function GetEgresosSinComprobarPersonalDetalle(CvePersonal As Integer, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False - DataAdapter("PA_Banc_EgresosSinComprobarPersonalDetalle") With SqlAdapter.SelectCommand.Parameters @@ -1025,8 +1015,7 @@ Public Class ClsMovimientos Public Function GetDeudoresSaldos(CveProveedor As Integer, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False - - DataAdapter("PA_Banc_DeudoresSaldos") + DataAdapter("PA_Banc_DeudoresSaldosGet") With SqlAdapter.SelectCommand.Parameters .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor @@ -1045,8 +1034,7 @@ Public Class ClsMovimientos Public Function GetDeudoresComisionesSaldos(CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False - - DataAdapter("PA_Banc_DeudoresComisionesSaldos") + DataAdapter("PA_Banc_DeudoresComisionesSaldosGet") With SqlAdapter.SelectCommand.Parameters .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa @@ -1064,8 +1052,7 @@ Public Class ClsMovimientos Public Function GetDeudoresComisionesSaldosDetalle(CveProveedor As Integer, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False - - DataAdapter("PA_Banc_DeudoresComisionesSaldosDetalle") + DataAdapter("PA_Banc_DeudoresComisionesSaldosDetalleGet") With SqlAdapter.SelectCommand.Parameters .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor @@ -1085,7 +1072,6 @@ Public Class ClsMovimientos Public Function GetDeudoresSaldos2(CveProveedor As Integer, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False - DataAdapter("PA_Banc_DeudoresSaldos2") With SqlAdapter.SelectCommand.Parameters @@ -1106,7 +1092,6 @@ Public Class ClsMovimientos Public Function GetSaldosDeudorAcreedorAnticipos(FechaInicio As Date, FechaFin As Date, Opcion As Integer, CveProveedor As Integer, CvePersonal As Integer, CveClasificacion As Integer, CveUsuarioRegistro As Integer, CveUsuarioResponsable As Integer, CveMoneda As Integer, Saldo As Double, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False - DataAdapter("PA_Banc_SaldosDAP") With SqlAdapter.SelectCommand.Parameters @@ -1136,8 +1121,7 @@ Public Class ClsMovimientos Public Function GetDeudoresSaldosDetalle(CveProveedor As Integer, CveMoneda As Integer, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False - - DataAdapter("PA_Banc_DeudoresSaldosDetalle") + DataAdapter("PA_Banc_DeudoresSaldosDetalleGet") With SqlAdapter.SelectCommand.Parameters .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor @@ -1158,7 +1142,6 @@ Public Class ClsMovimientos Public Function GetIngresosSaldos(CveCliente As Integer, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False - DataAdapter("PA_Banc_IngresosSaldos") With SqlAdapter.SelectCommand.Parameters @@ -1179,7 +1162,6 @@ Public Class ClsMovimientos Public Function GetOtrosIngresos(Opcion As Integer, CveCliente As Integer, CveProveedor As Integer, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False - DataAdapter("PA_Banc_OtrosIngresos") With SqlAdapter.SelectCommand.Parameters @@ -1202,7 +1184,6 @@ Public Class ClsMovimientos Public Function GetIngresosSaldosDetalle(CveCliente As Integer, CveMoneda As Integer, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False - DataAdapter("PA_Banc_IngresosSaldosDetalle") With SqlAdapter.SelectCommand.Parameters @@ -1224,7 +1205,6 @@ Public Class ClsMovimientos Public Function GetDocumentosxPagarDetalle(CveCliente As Integer, CveMoneda As Integer, Opcion As Integer, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False - DataAdapter("PA_Banc_DocumentosxPagarSaldosDetalle") With SqlAdapter.SelectCommand.Parameters @@ -1247,7 +1227,6 @@ Public Class ClsMovimientos Public Function GetCajaChicaDetalle(CveCajaChica As Integer, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False - DataAdapter("PA_Banc_CajaChicaDetalle") With SqlAdapter.SelectCommand.Parameters @@ -1268,7 +1247,6 @@ Public Class ClsMovimientos Public Function UpdateReembolsoComprobante(CveComprobacion As Integer, Comprobante As String) As Boolean Dim Retorno As Boolean = False - DataAdapter("PA_Comp_ReembolosoComprobanteUpdate") With SqlAdapter.SelectCommand.Parameters @@ -1290,7 +1268,6 @@ Public Class ClsMovimientos Public Function GetAcreedoresSaldosDetalles(CveProveedor As Integer, CveMoneda As Integer, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False - DataAdapter("PA_Banc_AcreedoresSaldosDetalles") With SqlAdapter.SelectCommand.Parameters @@ -1312,7 +1289,6 @@ Public Class ClsMovimientos Public Function GetAcreedoresSaldos(CveProveedor As Integer, CveMoneda As Integer, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False - DataAdapter("PA_Banc_AcreedoresSaldos") With SqlAdapter.SelectCommand.Parameters @@ -1414,7 +1390,6 @@ Public Class ClsMovimientos Optional ConComprobacion As Integer = -1, Optional AplicaNC As Integer = -1) As Boolean Dim Retorno As Boolean = False - DataAdapter("PA_Comp_CxPProgramar") With SqlAdapter.SelectCommand.Parameters @@ -1457,7 +1432,8 @@ Public Class ClsMovimientos Return Retorno End Function - Public Function GetCxPPersonalCajaChica(CveEmpresa As Integer, CvePersonal As Integer, CveCajaChica As Integer, NumeroReembolso As String, Optional FechaI As DateTime = ModExtensiones.MinFecha, Optional FechaF As DateTime = ModExtensiones.MaxFecha, Optional OpcionSaldo As Integer = 1) As Boolean + Public Function GetCxPPersonalCajaChica(CveEmpresa As Integer, CvePersonal As Integer, CveCajaChica As Integer, NumeroReembolso As String, Optional FechaI As DateTime = ModExtensiones.MinFecha, Optional FechaF As DateTime = ModExtensiones.MaxFecha, + Optional OpcionSaldo As Integer = 1, Optional CveSubProyecto As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_CxPPersonalCajaChica") With SqlAdapter.SelectCommand.Parameters @@ -1468,6 +1444,7 @@ Public Class ClsMovimientos .Add("@FechaI", SqlDbType.DateTime).Value = FechaI .Add("@FechaF", SqlDbType.DateTime).Value = FechaF .Add("@OpcionSaldo", SqlDbType.Int).Value = OpcionSaldo ' 1. solo con saldo, -1. todos + .Add("@CveSubProyecto", SqlDbType.Int).Value = OpcionSaldo End With Try SqlAdapter.Fill(Data) diff --git a/App_Code/ClsNominas.vb b/App_Code/ClsNominas.vb index 64f4f81e8..3a7756ca7 100644 --- a/App_Code/ClsNominas.vb +++ b/App_Code/ClsNominas.vb @@ -1568,7 +1568,7 @@ Public Class ClsNominas End Function Public Function UpdateConcepto(Codigo As String, Concepto As String, Tipo As String, Formula As String, Sistema As Boolean, Estado As Boolean, CveConceptoPadre As Integer, CveConcepto As Integer, - EsRetencion As Boolean, CveClasificacion As Integer, CveTipoGasto As Integer, TipoCalculo As Boolean, CveConceptoContable As Integer, AplicaFiniquito As Integer, + EsRetencion As Boolean, CveClasificacion As Integer, CveTipoGasto As Integer, TipoCalculo As Boolean, CveConceptoContable As Integer, CveCuenta As Integer, AplicaFiniquito As Integer, AutomaticoGlobal As Integer, Especie As Integer, Imprimir As Integer, CveSATConcepto As Integer, CveEmpresa As Integer, CveUsuario As Integer, ctaImporteNegativoProv As Integer, contabiliza As Integer, CargoOAbono As Integer, cveConceptoContableB As Integer, CveCuentaB As Integer, CveConceptoContablePasivo As Integer, Optional AplicaEfectivale As Integer = 0, Optional EsFormula As Integer = -1) As Boolean @@ -1590,6 +1590,7 @@ Public Class ClsNominas .Add("CveTipoGasto", SqlDbType.Int).Value = CveTipoGasto .Add("TipoCalculo", SqlDbType.Bit).Value = TipoCalculo .Add("CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable + .Add("CveCuenta", SqlDbType.Int).Value = CveCuenta .Add("AplicaFiniquito", SqlDbType.Bit).Value = AplicaFiniquito .Add("AutomaticoGlobal", SqlDbType.Bit).Value = AutomaticoGlobal .Add("Especie", SqlDbType.Bit).Value = Especie diff --git a/App_Code/ClsOP.vb b/App_Code/ClsOP.vb index eb34c60ee..624bb0a8a 100644 --- a/App_Code/ClsOP.vb +++ b/App_Code/ClsOP.vb @@ -481,15 +481,16 @@ Public Class ClsOP Return Retorno End Function - Public Function GetEstatusOP(CveEmpresa As Integer, Optional CveEstatusOP As Integer = -1, Optional TipoEstatus As Integer = -1, Optional Estatus As Integer = -1) As Boolean + Public Function GetEstatusOP(CveEmpresa As Integer, Optional CveEstatusOP As Integer = -1, Optional TipoEstatus As Integer = -1, Optional Estatus As Integer = -1, Optional CveUsuario As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_OP_EstatusOPGet") With SqlAdapter.SelectCommand.Parameters - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - .Add("@CveEstatusOP", SqlDbType.Int).Value = CveEstatusOP - .Add("@TipoEstatus", SqlDbType.Int).Value = TipoEstatus - .Add("@Estatus", SqlDbType.Int).Value = Estatus + .Add("@cveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@cveEstatusOP", SqlDbType.Int).Value = CveEstatusOP + .Add("@tipoEstatus", SqlDbType.Int).Value = TipoEstatus + .Add("@estatus", SqlDbType.Int).Value = Estatus + .Add("@cveUsuario", SqlDbType.Int).Value = CveUsuario End With Try SqlAdapter.Fill(Data) diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 2f9873a89..a89c07bd9 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -78,6 +78,7 @@ Public Class ClsPaginas If Dominio.Contains("VYA".ToUpper()) Then Retorno = "VYA" If Dominio.Contains("GRUPODIAZ".ToUpper()) Then Retorno = "GRUPODIAZ" If Dominio.Contains("FERRETERA".ToUpper()) Then Retorno = "FERRETERA" + If Dominio.Contains("JUMBOLON".ToUpper()) Then Retorno = "JUMBOLON" Return Retorno End Get End Property @@ -6224,6 +6225,8 @@ Public Class ClsPaginas Dim ConfATR2 As String = "" Dim ObjInv As New ClsGenerales Dim TelDestino As String = "" + Dim NombreUsuario As String = "" 'Persona que timbro + Dim LugarOrigen As String = "" If ObjInv.GetGralTimbre(CveTimbre, "-1", MinFecha, MaxFecha, -1, UsuarioActual.CveEmpresa, -1) Then If ObjInv.DtResultados.Rows.Count > 0 Then @@ -6233,6 +6236,8 @@ Public Class ClsPaginas Telefono = Dr("FiguraTelefono").ToString TipoDocto = Dr("TipoDocto").ToString TelDestino = Dr("TelDestino").ToString + NombreUsuario = Dr("NombreUsuario").ToString + LugarOrigen = Dr("LugarOrigen").ToString If UsuarioActual.CveEmpresa = 13 Then PermisoSCTR1 = Dr("PermisoSCTR1").ToString @@ -6629,6 +6634,9 @@ Public Class ClsPaginas params.Add(New ReportParameter("FechaImpresion", NowADS().ToDateTime.ToShortDateString)) params.Add(New ReportParameter("DomicilioFiscal", $"{UsuarioActual.Empresa.Direccion}, {UsuarioActual.Empresa.Colonia}, {UsuarioActual.Empresa.Localidad}, {UsuarioActual.Empresa.Estado}, Tel. {Telefono}")) params.Add(New ReportParameter("SerieFolio", SerieFolio)) + params.Add(New ReportParameter("NombreUsuario", NombreUsuario)) + params.Add(New ReportParameter("LugarOrigen", LugarOrigen)) + params.Add(New ReportParameter("RFC", UsuarioActual.Empresa.RFC)) params.Add(New ReportParameter("DomicilioExpedicion", LugarExpedicion)) 'CLIENTE @@ -10548,6 +10556,7 @@ Public Class ClsPaginas PaginaDict.Add("/General/CatMedidaEquivalencia.aspx".ToUpper(), 773) PaginaDict.Add("/General/RepIndicadorResumen.aspx".ToUpper(), 110) PaginaDict.Add("/General/SaldosMenores.aspx".ToUpper(), -1) + PaginaDict.Add("/General/Dashboard.aspx".ToUpper(), 17) #End Region #Region "GPS" PaginaDict.Add("/GPS/RepTemperatura.aspx".ToUpper(), 681) @@ -11140,7 +11149,7 @@ Public Class ClsPaginas PaginaDict.Add("/Contabilidad/OCDetalleAlmacen.aspx".ToUpper(), -1) PaginaDict.Add("/Contabilidad/RepBalanceGeneralHorizontal.aspx".ToUpper(), -1) PaginaDict.Add("/Agropecuaria/CierreCultivo.aspx".ToUpper(), 1326) - PaginaDict.Add("/Agropecuaria/RepPreciosVentaManifiesto.aspx".ToUpper(), -1) + PaginaDict.Add("/Agropecuaria/RepPreciosVentaManifiesto.aspx".ToUpper(), 1353) PaginaDict.Add("/Inventarios/RepRSCO.aspx".ToUpper(), 1328) PaginaDict.Add("/testApi.aspx".ToUpper(), -1) diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index f5df7ceeb..223f40d59 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -3,9 +3,7 @@ Option Strict On Imports System.Data Imports System.Data.SqlClient -Imports System.Runtime.CompilerServices Imports Extensiones -Imports Profact.TimbraCFDI40 Public Class ClsVentas Implements IDisposable @@ -1643,7 +1641,7 @@ Public Class ClsVentas Return Retorno End Function - Public Function UpdateVentaDetalleRemision(CveVenta As Integer, CvePS As Integer, Cantidad As Decimal, PU As Decimal, IEPS As Decimal, PorcentajeIEPS As Decimal, IVA As Decimal, PorcentajeIVA As Decimal, Descuento As Decimal, Observaciones As String, Optional CveUsuarioModifico As Integer = -1, Optional CvePromocionDetalle As Integer = -1) As Boolean + Public Function UpdateVentaDetalleRemision(CveVenta As Integer, CvePS As Integer, Cantidad As Decimal, PU As Decimal, IEPS As Decimal, PorcentajeIEPS As Decimal, IVA As Decimal, PorcentajeIVA As Decimal, Descuento As Decimal, Observaciones As String, Optional CveUsuarioModifico As Integer = -1, Optional CvePromocionDetalle As Integer = -1, Optional CantidadConversion As Decimal = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_VentasDetalleRemisionUpdate") @@ -1660,6 +1658,7 @@ Public Class ClsVentas .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones .Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico .Add("@CvePromocionDetalle", SqlDbType.Int).Value = CvePromocionDetalle + .Add("@CantidadConversion", SqlDbType.Decimal).Value = CantidadConversion End With Try @@ -7698,7 +7697,7 @@ Public Class ClsVentas End Function - Public Function GetSMSIndicadores(Opcion As Integer, FechaInicio As Date, FechaFin As Date, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Public Function GetSMSIndicadores(Opcion As Integer, FechaInicio As Date, FechaFin As Date, CveUsuario As Integer, CveVendedor As Integer, CveGerenteVendedor As Integer, CveUsuarioTecnico As Integer, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_SMS_IndicadoresGet") With SqlAdapter.SelectCommand.Parameters @@ -7706,6 +7705,9 @@ Public Class ClsVentas .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio .Add("@FechaFin", SqlDbType.Date).Value = FechaFin .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CveGerenteVendedor", SqlDbType.Int).Value = CveGerenteVendedor + .Add("@CveUsuarioTecnico", SqlDbType.Int).Value = CveUsuarioTecnico .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa End With Try @@ -7914,11 +7916,6 @@ Public Class ClsVentas - - - - - #Region "IDisposable Support" diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 53c73fd47..42765c4be 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -1307,6 +1307,7 @@ Namespace Modelos TmpDT.Columns.Add("Descuento", GetType(Decimal)) TmpDT.Columns.Add("TipoDescuento", GetType(Integer)) TmpDT.Columns.Add("TotalImporte", GetType(Decimal)) + TmpDT.Columns.Add("TotalConImpuestos", GetType(Decimal)) TmpDT.Columns.Add("Total", GetType(Decimal)) TmpDT.Columns.Add("RetIVA", GetType(Decimal)) TmpDT.Columns.Add("RetISR", GetType(Decimal)) @@ -1385,8 +1386,14 @@ Namespace Modelos TmpDT.Columns.Add("CveViajePasajero", GetType(Integer)) TmpDT.Columns("CveViajePasajero").DefaultValue = -1 + 'COLUMNAS DE Ventas.aspx TmpDT.Columns.Add("CantidadConversion", GetType(Decimal)) TmpDT.Columns("CantidadConversion").DefaultValue = 0 + TmpDT.Columns.Add("NumeroPedimento", GetType(String)) + TmpDT.Columns.Add("CodigoAlterno", GetType(String)) + TmpDT.Columns.Add("PSAlterno", GetType(String)) + TmpDT.Columns.Add("Costo", GetType(Decimal)) + TmpDT.Columns("Costo").DefaultValue = 0D 'COLUMNAS DE PV.aspx TmpDT.Columns.Add("PUOriginal", GetType(Decimal)) @@ -3604,7 +3611,7 @@ Namespace Modelos Exit Select End If - If ObjFactura.TipoDocto.Contiene("Ing", "Egs", "Ant") AndAlso ValorMultiplicador = -1 Then + If ObjFactura.TipoDocto.Contiene("Ing", "Egs") AndAlso ValorMultiplicador = -1 Then For Each row2 As DataRow In ObjFactura.DtAnticipos.Rows If row2("CveConceptoContable").ToString().ToEntero = 11 Then importeMovimiento = row2("Importe").ToString().ToDecimal * ValorMultiplicador '- ((row2.FCTextBox("TxtAnticipo" & row2.RowIndex).Text.ToDecimal / row2.DataKey("TotalAnticipo").ToDecimal) * row2.DataKey("IVAAnticipo").ToDecimal) @@ -5732,8 +5739,15 @@ Namespace Modelos Return Retorno End If - If ObjFactura.TipoDocto = "Ant" AndAlso ObjFactura.SaldoAmortizado > 0 Then - Retorno.Mensaje = "La factura no se puede cancelar debido a que el anticipo ha sido amortizado." + 'If ObjFactura.TipoDocto = "Ant" AndAlso ObjFactura.SaldoAmortizado > 0 Then + ' Retorno.Mensaje = "La factura no se puede cancelar debido a que el anticipo ha sido amortizado." + ' Retorno.TipoMensaje = TipoMensaje.MsgAdvertencia + + ' Return Retorno + 'End If + + If UsuarioActual.CveEmpresa <> 119 AndAlso ObjFactura.TipoDocto = "Ant" AndAlso ObjFactura.SaldoAnticipo.RoundSQL(2) <> ObjFactura.SubTotal.RoundSQL(2) Then + Retorno.Mensaje = "La factura no se puede cancelar debido a que el anticipo ha sido aplicado." Retorno.TipoMensaje = TipoMensaje.MsgAdvertencia Return Retorno diff --git a/App_Code/Timbrado.vb b/App_Code/Timbrado.vb index 19b3bbb23..a0df85f43 100644 --- a/App_Code/Timbrado.vb +++ b/App_Code/Timbrado.vb @@ -964,9 +964,9 @@ Public Class Timbrado If CvePACEspecial <> -1 Then tCvePAC = CvePACEspecial 'validación especial. - If Ventas.TipoDocto.Contiene("Ing", "Dev") Then + If Ventas.TipoDocto.Contiene("Ing", "Dev") AndAlso UsuarioActual.Empresa.Funcionalidad(153) = "" Then ' funcionalidad para no filtrar por códigos 01010101 - Dim CodigoIncorrecto = (From c In Ventas.Timbre.Conceptos Where (c.ClaveProdServ = "01010101") OrElse (c.ClaveProdServ = "84111506" AndAlso Not UsuarioActual.CveEmpresa.Contiene(2, 70, 144)) + Dim CodigoIncorrecto = (From c In Ventas.Timbre.Conceptos Where (c.ClaveProdServ = "01010101") OrElse (c.ClaveProdServ = "84111506") Select c.ClaveProdServ, c.Descripcion) Dim Str As New StringBuilder Str.Append("Los siguientes productos tienen especificado un código no permitido por el SAT:
") diff --git a/Ashx/E140.ashx b/Ashx/E140.ashx index 1ad9449bc..2445fbc2c 100644 --- a/Ashx/E140.ashx +++ b/Ashx/E140.ashx @@ -132,7 +132,8 @@ Public Class E140 : Implements IHttpHandler, IRequiresSessionState Dim data As New JArray Dim dtt As New DataTable Dim ObjVentas As New ClsVentas - If ObjVentas.GetRepRemisionesSinFacturar(Now.AddYears(-2).ToShortDateString, Now.ToShortDateString, Now.ToShortDateString, CveSubProyecto, -1, -1, "-1", CveEmpresa, CveUsuarioConsulta:=100, PrimerProducto:=True) Then + Dim FechaInicio As String = Now.AddYears(-2).ToShortDateString + If ObjVentas.GetRepRemisionesSinFacturar(FechaInicio, Now.AddDays(1).ToShortDateString, Now.AddDays(1).ToShortDateString, CveSubProyecto, -1, -1, "-1", CveEmpresa, CveUsuarioConsulta:=100, PrimerProducto:=True) Then dtt = ObjVentas.DtResultados.FiltraParametros("CveVenta > 0") End If ObjVentas.Dispose() @@ -296,6 +297,7 @@ Public Class E140 : Implements IHttpHandler, IRequiresSessionState End If Else TieneError = True + MsgError = "Falta información para completar la venta." End If End If If Not TieneError Then diff --git a/Ashx/E158.ashx b/Ashx/E158.ashx index cc6b92bc6..6f4d581b9 100644 --- a/Ashx/E158.ashx +++ b/Ashx/E158.ashx @@ -209,17 +209,6 @@ Public Class E158 : Implements IHttpHandler, IReadOnlySessionState ObjVentas.Dispose() - 'For Each dRow As DataRow In DTresp.Rows - - 'Next - - 'Dim ObjVentas As New ClsVentas - - 'If ObjVentas.AddPreciosVentaManifiesto() Then - - 'End If - - 'ObjVentas.Dispose() 'DTresp.WriteXml("C:\temp\GrowerService\Sales.xml", XmlWriteMode.WriteSchema) diff --git a/Bancos/DepositosCaja.aspx b/Bancos/DepositosCaja.aspx index 0c2d9a41c..8df5dc3b2 100644 --- a/Bancos/DepositosCaja.aspx +++ b/Bancos/DepositosCaja.aspx @@ -224,7 +224,7 @@ -
+
@@ -318,14 +318,14 @@
-
+
-
+
@@ -336,7 +336,7 @@
-
+
@@ -372,7 +372,7 @@
- + diff --git a/Bancos/DepositosCaja.aspx.vb b/Bancos/DepositosCaja.aspx.vb index 5db1c8b8e..c11961c9a 100644 --- a/Bancos/DepositosCaja.aspx.vb +++ b/Bancos/DepositosCaja.aspx.vb @@ -15,11 +15,22 @@ Partial Class Bancos_DepositosCaja Set(value As Integer) ViewState("FacturasCheckadas") = value End Set + End Property + + Private Property IntermediarioPendiente As Boolean + Get + Return ViewState("IntermediarioPendiente").ToString.ToBool + End Get + Set(value As Boolean) + ViewState("IntermediarioPendiente") = value + End Set End Property Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then FacturasCheckadas = 0 + IntermediarioPendiente = False + TxtFecha.Text = NowADS().ToShortDateString txtFechaI.Text = NowADS().AddDays(-1).ToShortDateString txtFechaF.Text = NowADS().ToShortDateString @@ -33,6 +44,17 @@ Partial Class Bancos_DepositosCaja DdlTipoDeposito.Items.Remove("-1") End If + If UsuarioActual.CveEmpresa = 189 Then + If DdlTipoPago.Items.FindByValue("-1") IsNot Nothing Then + DdlTipoPago.Items.Remove(DdlTipoPago.Items.FindByValue("-1")) + End If + + divdescuento2.Visible = False + divdescuento3.Visible = False + DivIntercheck.Visible = False + DivSobrantescheck.Visible = False + End If + CargaCuentas() ChkFaltante.Attributes.Add("onclick", "CheckFaltante(this);") @@ -45,14 +67,11 @@ Partial Class Bancos_DepositosCaja 'Dim StrEncriptPrueba As String = Encripta($"OP=DC&CveIE={2784391}&CuentaCaja={"TestCuantaCaja"}&CuentaDepo={"Test cuenta"}") 'HplImprimirPDF.NavigateUrl = $"/Compras/PopUpVerFactura.aspx?P={StrEncriptPrueba}" - If UsuarioActual.CveEmpresa = 189 Then - If DdlTipoPago.Items.FindByValue("-1") IsNot Nothing Then - DdlTipoPago.Items.Remove(DdlTipoPago.Items.FindByValue("-1")) - End If - - divdescuento2.Visible = False - divdescuento3.Visible = False - DivIntercheck.Visible = False + If UsuarioActual.CveEmpresa = 145 Then + IntermediarioPendiente = True + divInterClasif.Visible = False + divInterSubProyecto.Visible = False + DivIVA.Visible = False End If End If @@ -81,6 +100,7 @@ Partial Class Bancos_DepositosCaja If UsuarioActual.TienePermisoProceso(383) Then DivRowCuenta.Visible = True DivDescuentocheck.Visible = True + DivSobrantescheck.Visible = True Else DivRowCuenta.Visible = False DivDescuentocheck.Visible = False @@ -137,7 +157,6 @@ Partial Class Bancos_DepositosCaja DdlUsuario.DataSource = GlobalDTUsuarios(-1, CveEmpresa:=UsuarioActual.CveEmpresa) DdlUsuario.DataBind() - End Sub Private Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click @@ -305,38 +324,19 @@ Partial Class Bancos_DepositosCaja End If End If - NuevaCvePrePoliza = ObjConta.AddPrePolizas("DepCaja", 13, TotalImportePrePoliza, TotalImportePrePoliza, CveMoneda, Fecha, $"Depósito Bancario - {DdlTipoDeposito.SelectedItem.Text}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=1) + Dim ImporteSobFaltante As Decimal = 0 - Dim IntermediarioFactura As Boolean = False - If UsuarioActual.CveEmpresa = 145 Then IntermediarioFactura = True - If ChkIntermediario.Checked Then - - CveSubProyectoIntermediario = DdlSubProyectoIntermediario.SelectedValue.ToEntero - CveClasificacionIntermediario = DdlClasificacionIntermediario.SelectedValue.ToEntero - CveProveedorIntermediario = DdlProveedorIntermediario.SelectedValue.ToEntero - - If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then ' empresa llantera - If Not ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, False, TotalImporte, TotalImporte, 95, DdlClasificacionIntermediario.SelectedItem.Text, DdlClasificacionIntermediario.SelectedItem.Text, CveClasificacion:=CveClasificacionIntermediario, CveSubProyecto:=CveSubProyectoIntermediario, CveProveedor:=CveProveedorIntermediario, CveCuenta:=57619) Then - OcurrioError = True + If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then + For Each Gvr As GridViewRow In GvFacturas.Rows + If Gvr.FCCheckBox("ChkFactura").Checked Then + ImporteSobFaltante += Gvr.DataKey("SobranteFaltante").ToDecimal() End If - If Not ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, True, TotalImporte, TotalImporte, 95, DdlClasificacionIntermediario.SelectedItem.Text, DdlClasificacionIntermediario.SelectedItem.Text, CveClasificacion:=CveClasificacionIntermediario, CveSubProyecto:=CveSubProyectoIntermediario, CveProveedor:=CveProveedorIntermediario, CveCuenta:=57619) Then - OcurrioError = True - End If - End If - - If Not IntermediarioFactura Then ' si factura no se manda al gasto sino se disminuye solo lo depositado - If Not ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, False, ImporteInter, ImporteInter, 51, DdlClasificacionIntermediario.SelectedItem.Text, DdlClasificacionIntermediario.SelectedItem.Text, CveClasificacion:=CveClasificacionIntermediario, CveSubProyecto:=CveSubProyectoIntermediario) Then - OcurrioError = True - End If - End If - - If IVA <> 0 Then - If Not OcurrioError AndAlso Not ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, False, IVA, IVA, 14, DdlClasificacionIntermediario.SelectedItem.Text, DdlClasificacionIntermediario.SelectedItem.Text, CveClasificacion:=CveClasificacionIntermediario, CveSubProyecto:=CveSubProyectoIntermediario, PorcentajeImpuesto:=0.16D) Then - OcurrioError = True - End If - End If + Next End If + NuevaCvePrePoliza = ObjConta.AddPrePolizas("DepCaja", 13, TotalImportePrePoliza, TotalImportePrePoliza, CveMoneda, Fecha, $"Depósito Bancario - {DdlTipoDeposito.SelectedItem.Text} {If(ImporteSobFaltante <> 0, $"- Sobrante/faltante: ${ImporteSobFaltante:N2}", "")}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=1) + + Dim CveTransaccionBanco As Integer = DdlTipoDeposito.SelectedValue.ToEntero If CveTransaccionBanco = -1 Then @@ -419,6 +419,38 @@ Partial Class Bancos_DepositosCaja OcurrioError = True End If + If Not OcurrioError AndAlso ChkIntermediario.Checked Then + + CveSubProyectoIntermediario = DdlSubProyectoIntermediario.SelectedValue.ToEntero + CveClasificacionIntermediario = DdlClasificacionIntermediario.SelectedValue.ToEntero + CveProveedorIntermediario = DdlProveedorIntermediario.SelectedValue.ToEntero + + If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then ' empresa llantera + If Not ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, False, TotalImporte, TotalImporte, 95, DdlClasificacionIntermediario.SelectedItem.Text, DdlClasificacionIntermediario.SelectedItem.Text, CveClasificacion:=CveClasificacionIntermediario, CveSubProyecto:=CveSubProyectoIntermediario, CveProveedor:=CveProveedorIntermediario, CveCuenta:=57619) Then + OcurrioError = True + End If + If Not ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, True, TotalImporte, TotalImporte, 95, DdlClasificacionIntermediario.SelectedItem.Text, DdlClasificacionIntermediario.SelectedItem.Text, CveClasificacion:=CveClasificacionIntermediario, CveSubProyecto:=CveSubProyectoIntermediario, CveProveedor:=CveProveedorIntermediario, CveCuenta:=57619) Then + OcurrioError = True + End If + End If + + If Not IntermediarioPendiente Then ' si factura no se manda al gasto sino se disminuye solo lo depositado + If Not ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, False, ImporteInter, ImporteInter, 51, DdlClasificacionIntermediario.SelectedItem.Text, DdlClasificacionIntermediario.SelectedItem.Text, CveClasificacion:=CveClasificacionIntermediario, CveSubProyecto:=CveSubProyectoIntermediario) Then + OcurrioError = True + End If + Else 'se manda el saldo como deudor + If Not ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, False, ImporteInter, ImporteInter, 43, "Comisión Intermediario", "Comisión Intermediario", CveClasificacion:=CveClasificacionIntermediario, CveSubProyecto:=CveSubProyectoIntermediario, CveProveedor:=DdlProveedorIntermediario.SelectedValue.ToEntero, CveIE:=CveIEOrigen) Then + OcurrioError = True + End If + End If + + If IVA <> 0 Then + If Not OcurrioError AndAlso Not ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, False, IVA, IVA, 14, DdlClasificacionIntermediario.SelectedItem.Text, DdlClasificacionIntermediario.SelectedItem.Text, CveClasificacion:=CveClasificacionIntermediario, CveSubProyecto:=CveSubProyectoIntermediario, PorcentajeImpuesto:=0.16D) Then + OcurrioError = True + End If + End If + End If + If Not OcurrioError AndAlso ChkCuentaRetorno.Checked Then If Not ObjConta.AddPrePolizasDetalle(NuevaCvePrePoliza, True, CuentaRetorno, CuentaRetorno * TipoCambio, 325, $"Depósito Bancario - CAJA - {tSubProyectoDeposito}", TxtCuentaRetornoObs.Text.Trim, CveSubProyecto:=CveSubProyecto) Then OcurrioError = True @@ -436,11 +468,11 @@ Partial Class Bancos_DepositosCaja Dim Importe As Decimal = Gvr.DataKey("Importe").ToDecimal Dim SerieFolio As String = Gvr.DataKey("SerieFolio").ToString - 'si es el primero, se descuenta la "comisión" - If i = 0 AndAlso IntermediarioFactura Then - Importe = Importe - ImporteInter - i += 1 - End If + ''si es el primero, se descuenta la "comisión" + 'If i = 0 AndAlso IntermediarioPendiente Then + ' Importe = Importe - ImporteInter + ' i += 1 + 'End If 'Datos de las Prepolizas A Cancelar Dim CveIE As Integer = Gvr.DataKey("CveIE").ToEntero diff --git a/Bancos/IE.aspx.vb b/Bancos/IE.aspx.vb index b419b6dd1..12b98c61b 100644 --- a/Bancos/IE.aspx.vb +++ b/Bancos/IE.aspx.vb @@ -2314,7 +2314,7 @@ Partial Class Bancos_IE 'CANCELA NC ImporteAplicar = ImporteAplicar - Impo ImporteAplicarMN = (ImporteAplicar * If(tCveMoneda = 1, 1, TxtTipoCambio.Text.ToDecimal)).RoundSQL() - If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, -(ImporteAplicar), -(ImporteAplicarMN), 12, ReferenciaAplicar, ConceptoAplicar, CveIE:=CveIE, CveVenta:=CveVentaDevDin, CveCliente:=CveCliente, ImporteME:=ImporteAplicarME) Then + If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, (ImporteAplicar), -(ImporteAplicarMN), 91, ReferenciaAplicar, ConceptoAplicar, CveIE:=CveIE, CveVenta:=CveVentaDevDin, CveVentaAmortizacion:=CveVentaDevDin, CveCliente:=CveCliente, ImporteME:=ImporteAplicarME) Then MsgError = "Ocurrió un error al registrar el asiento de pago de devolución" Exit Select End If diff --git a/Compras/Compras.aspx b/Compras/Compras.aspx index 35f1ec5fc..034b3d77b 100644 --- a/Compras/Compras.aspx +++ b/Compras/Compras.aspx @@ -1363,7 +1363,7 @@ <%--4--%> - + <%--5--%> diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index c404ad0b2..6ed284990 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -9373,7 +9373,7 @@ Partial Class Compras_Compras '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - If Not ErrorAC Then + If Retorno AndAlso Not ErrorAC Then Dim Cont As Integer = 0 Dim indiceTR As Integer = 0 For Each Row As DataRow In TmpDT.Rows @@ -9501,6 +9501,11 @@ Partial Class Compras_Compras End If 'Retorno = True 'Alert("La Compra se actualizó correctamente.") + + If Not ActualizarPrePolizaValidacion(ObjContabilidad, ObjCompra) Then + Retorno = False + End If + Else If IdPoliza > 0 Then If Not ObjContabilidad.UpdatePrePolizasDetalleBloquear(CvePrePoliza, True) Then @@ -9513,7 +9518,7 @@ Partial Class Compras_Compras End If End If - If (NumeroReembolsoOriginal.Trim <> TxtRembolsoNumero.Text.Trim) Then + If Retorno AndAlso (NumeroReembolsoOriginal.Trim <> TxtRembolsoNumero.Text.Trim) Then 'NOTA. si hay un cambio en el reembolso, puede tener estas consideraciones. '1. no tenía comprobación y se ocupa relacionar, se deberá validar que no tenga pagos contabilizados '2. se está cambiando de comprobación @@ -9911,6 +9916,7 @@ Partial Class Compras_Compras (row1("TipoAF").ToString.ToEntero <> row2("TipoAF").ToString.ToEntero) Or (row1("CvePS").ToString.ToEntero <> row2("CvePS").ToString.ToEntero) Or (row1("Obs").ToString <> row2("Obs").ToString) Or + (row1("IVAPorcentaje").ToString <> row2("IVAPorcentaje").ToString AndAlso CveCompra > 0 AndAlso CveCompraFactura = 0) Or (DdlTipoCompra.SelectedValue.ToEntero <> TipoCompraOriginal) Then Return False End If @@ -9936,7 +9942,7 @@ Partial Class Compras_Compras End Function - Private Function ActualizarPrePoliza(ObjConta As ClsContabilidad, ObjCompra As ClsCompras) As Boolean + Private Function ActualizarPrePoliza(ByRef ObjConta As ClsContabilidad, ByRef ObjCompra As ClsCompras) As Boolean Dim Retorno As Boolean = True, ErrorPrepoliza As Boolean = False Dim CvePlantillaPrePoliza As Integer @@ -10047,175 +10053,224 @@ Partial Class Compras_Compras If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 228, CveCompra, 1) Then ErrorPrepoliza = True 'PS NO RECIBIDO If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 229, CveCompra, 1) Then ErrorPrepoliza = True 'PS NO RECIBIDO - - 'SI ES GASTO CON ALMACEN REGISTRA EL CONCEPTO 95 - If DdlTipoCompra.SelectedValue = "10" Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMN, importeMN, 95, Referencia, Concepto, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveIE:=CveIE, CvePersonal:=CvePersonal, CveMovimientoAlmacen:=CveMovimientoInventario, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=tipoCambioActual, Contabilizable:=False) Then - ErrorPrepoliza = True - End If + If CveCompra > 0 And CveCompraFactura = 0 Then + If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 14, CveCompra, 1) Then ErrorPrepoliza = True + If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 5, CveCompra, 1) Then ErrorPrepoliza = True + If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 311, CveCompra, 1) Then ErrorPrepoliza = True + If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 305, CveCompra, 1) Then ErrorPrepoliza = True + If Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 306, CveCompra, 1) Then ErrorPrepoliza = True End If + If Not ErrorPrepoliza Then + If DdlTipoCompra.SelectedValue = "10" Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMN, importeMN, 95, Referencia, Concepto, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveIE:=CveIE, CvePersonal:=CvePersonal, CveMovimientoAlmacen:=CveMovimientoInventario, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=tipoCambioActual, Contabilizable:=False) Then + ErrorPrepoliza = True + End If + End If - 'OBTIENE METODO DE CONTABILIZACIÓN AL GUARDAR - Dim CveConceptoContableAlmacen As Integer = 0 - If ObjCompra.GetCompras(CveCompra, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) AndAlso ObjCompra.DtResultados.Rows.Count > 0 Then - CveConceptoContableAlmacen = ObjCompra.DtResultados.FiltroPrimeroValor("CveConceptoContableAlmacen").ToEntero - If CveConceptoContableAlmacen = 0 AndAlso tUsaInventarios Then - If Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then - If (CveImportacion > 0 Or CveFlete > 0) Then - CveConceptoContableAlmacen = CveConceptoContableAlmacen + 'OBTIENE METODO DE CONTABILIZACIÓN AL GUARDAR + Dim CveConceptoContableAlmacen As Integer = 0 + If ObjCompra.GetCompras(CveCompra, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) AndAlso ObjCompra.DtResultados.Rows.Count > 0 Then + CveConceptoContableAlmacen = ObjCompra.DtResultados.FiltroPrimeroValor("CveConceptoContableAlmacen").ToEntero + + If CveConceptoContableAlmacen = 0 AndAlso tUsaInventarios Then + If Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then + If (CveImportacion > 0 Or CveFlete > 0) Then + CveConceptoContableAlmacen = CveConceptoContableAlmacen + Else + CveConceptoContableAlmacen = 205 + End If + If OCVinculada AndAlso DdlOCVinculaInv.Visible AndAlso Not (CveImportacion > 0 Or CveFlete > 0) Then + CveConceptoContableAlmacen = DdlOCVinculaInv.SelectedValue.ToEntero + End If + If UsuarioActual.CveEmpresa.Contiene(72, 80, 140, 141, 152) And Not (CveImportacion > 0 Or CveFlete > 0) Then 'se comento, RMF. 2020.08.19, no le hallo sentido + CveConceptoContableAlmacen = 205 + End If Else - CveConceptoContableAlmacen = 205 + CveConceptoContableAlmacen = 225 End If - If OCVinculada AndAlso DdlOCVinculaInv.Visible AndAlso Not (CveImportacion > 0 Or CveFlete > 0) Then - CveConceptoContableAlmacen = DdlOCVinculaInv.SelectedValue.ToEntero - End If - If UsuarioActual.CveEmpresa.Contiene(72, 80, 140, 141, 152) And Not (CveImportacion > 0 Or CveFlete > 0) Then 'se comento, RMF. 2020.08.19, no le hallo sentido - CveConceptoContableAlmacen = 205 - End If - Else - CveConceptoContableAlmacen = 225 End If End If - End If - 'AF - DT = TmpDT.FiltraParametros("ISNULL(TipoAF,0) = 2") - If DT.Rows.Count > 0 AndAlso DdlTipoComprobante.SelectedValue <> "NC" Then - For Each Row2 As DataRow In DT.Rows - importeMovimiento = Row2("Total").ToString.ToDecimal - importeMN = importeMovimiento * tipoCambioActual * Multiplicador - - If importeMovimiento <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMN, importeMovimiento, 49, Row2("CodAF").ToString, Concepto, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveActivoFijo:=Row2("CveActivoFijo").ToString.ToEntero, CveIE:=CveIE, CvePersonal:=CvePersonal, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento)) Then - ErrorPrepoliza = True - End If - End If - Next - End If - - 'LIMPIA - importeMovimiento = 0 - 'COSTO ALMACEN - Dim DtAlmacenes As DataTable = GlobalDTAlmacen(UsuarioActual.CveEmpresa) - If tUsaInventarios And CveConceptoContableAlmacen = 0 Or DdlTipoCompra.SelectedValue.ToEntero = 10 Then - DT = TmpDT.FiltraParametros("ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) > 0", "", {"CveAlmacen"}) - 'RECORREMOS PARA DETECTAR LA MODALIDAD DEL ALMACEN, EN CASO DE SER SOLO EXISTENCIA LIMPIAMOS CVEALMACEN - - DT.AcceptChanges() - DT = DT.FiltraParametros("ISNULL(CveAlmacen,0) > 0") - If (DT.Rows.Count > 0) AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then + 'AF + DT = TmpDT.FiltraParametros("ISNULL(TipoAF,0) = 2") + If DT.Rows.Count > 0 AndAlso DdlTipoComprobante.SelectedValue <> "NC" Then For Each Row2 As DataRow In DT.Rows - - importeMovimiento = TmpDT.SUM("Total", $"CveAlmacen = {Row2("CveAlmacen")}").ToString.ToDecimal + TmpDT.SUM("CostoIndirectoAlmacen", $"CveAlmacen = {Row2("CveAlmacen")}").ToString.ToDecimal 'Row2("Total").ToString.ToDecimal + Row2("CostoIndirectoAlmacen").ToString.ToDecimal + importeMovimiento = Row2("Total").ToString.ToDecimal importeMN = importeMovimiento * tipoCambioActual * Multiplicador If importeMovimiento <> 0 Then - Dim SeContabiliza As Boolean = True - 'SI ES GASTO DE ALMACEN NO DEBE CONTABILIZAR CONCEPTO 68 - If DdlTipoCompra.SelectedValue = "10" Then - SeContabiliza = False - End If - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, importeMN, 68, Referencia, Concepto, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveIE:=CveIE, CvePersonal:=CvePersonal, CveMovimientoAlmacen:=CveMovimientoInventario, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), Contabilizable:=SeContabiliza) Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMN, importeMovimiento, 49, Row2("CodAF").ToString, Concepto, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveActivoFijo:=Row2("CveActivoFijo").ToString.ToEntero, CveIE:=CveIE, CvePersonal:=CvePersonal, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento)) Then ErrorPrepoliza = True End If End If Next End If - End If - 'LIMPIA - importeMovimiento = 0 + 'LIMPIA + importeMovimiento = 0 + 'COSTO ALMACEN + Dim DtAlmacenes As DataTable = GlobalDTAlmacen(UsuarioActual.CveEmpresa) + If tUsaInventarios And CveConceptoContableAlmacen = 0 Or DdlTipoCompra.SelectedValue.ToEntero = 10 Then + DT = TmpDT.FiltraParametros("ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) > 0", "", {"CveAlmacen"}) + 'RECORREMOS PARA DETECTAR LA MODALIDAD DEL ALMACEN, EN CASO DE SER SOLO EXISTENCIA LIMPIAMOS CVEALMACEN - 'INV [MERCANCIA RECIBIDA POR ADELANTADO (OC) | MERCANCIA PENDIENTE POR RECIBIR (COMPRA) ] - If DdlTipoCompra.SelectedValue.ToEntero <> 10 AndAlso tUsaInventarios And Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") And CveConceptoContableAlmacen.Contiene(176, 205) Then - importeMovimiento = TmpDT.SUM("Total", $"ISNULL(TipoAF,0) <> 2 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND CveTipoPS = 2").ToString.ToDecimal - importeMN = importeMovimiento * tipoCambioActual * Multiplicador + DT.AcceptChanges() + DT = DT.FiltraParametros("ISNULL(CveAlmacen,0) > 0") + If (DT.Rows.Count > 0) AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then + For Each Row2 As DataRow In DT.Rows - If importeMovimiento <> 0 Then - Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, importeMN, CveConceptoContableAlmacen, Referencia, Concepto, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento)) Then - ErrorPrepoliza = True + importeMovimiento = TmpDT.SUM("Total", $"CveAlmacen = {Row2("CveAlmacen")}").ToString.ToDecimal + TmpDT.SUM("CostoIndirectoAlmacen", $"CveAlmacen = {Row2("CveAlmacen")}").ToString.ToDecimal 'Row2("Total").ToString.ToDecimal + Row2("CostoIndirectoAlmacen").ToString.ToDecimal + importeMN = importeMovimiento * tipoCambioActual * Multiplicador + + If importeMovimiento <> 0 Then + Dim SeContabiliza As Boolean = True + 'SI ES GASTO DE ALMACEN NO DEBE CONTABILIZAR CONCEPTO 68 + If DdlTipoCompra.SelectedValue = "10" Then + SeContabiliza = False + End If + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, importeMN, 68, Referencia, Concepto, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveIE:=CveIE, CvePersonal:=CvePersonal, CveMovimientoAlmacen:=CveMovimientoInventario, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If + End If + Next End If End If - End If - 'NC CON PRODUCTOS - CUENTA PUENTE + 'LIMPIA + importeMovimiento = 0 - If tUsaInventarios And Not DdlTipoComprobante.SelectedValue.Contiene("Ant") And CveConceptoContableAlmacen.Contiene(225) Then - importeMovimiento = TmpDT.SUM("Total", $"ISNULL(TipoAF,0) <> 2 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND CveTipoPS = 2").ToString.ToDecimal - importeMN = importeMovimiento * tipoCambioActual * Multiplicador - - If importeMovimiento <> 0 Then - Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, importeMN, CveConceptoContableAlmacen, Referencia, Concepto, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento)) Then - ErrorPrepoliza = True - End If - End If - End If - 'GASTO - DT = TmpDT.Copy - 'RECORREMOS PARA DETECTAR LA MODALIDAD DEL ALMACEN, EN CASO DE SER SOLO EXISTENCIA LIMPIAMOS CVEALMACEN - If DdlTipoCompra.SelectedValue <> "10" Or DdlTipoCompra.SelectedValue = "13" Then - For Each Dr As DataRow In DT.Rows - If DtAlmacenes.FiltroPrimeroValor("Modalidad", $"CveAlmacen = {Dr("CveAlmacen").ToString.ToEntero}").ToString = "Solo Existencia" Then - Dr("CveAlmacen") = 0 - End If - Dr.AcceptChanges() - Next - End If - - DT.AcceptChanges() - DtAlmacenes.Dispose() - - - If DdlTipoCompra.SelectedValue.ToEntero <> 10 Then - 'QUITA 1-[MERCANCIA RECIBIDA POR ADELANTADO (OC) | MERCANCIA PENDIENTE POR RECIBIR (COMPRA)] 2-[NC CON PRODUCTOS] - If tUsaInventarios And CveConceptoContableAlmacen > 0 Then - DT = DT.FiltraParametros("CveTipoPS <> 2") - End If - End If - - Dim DTDistinct As DataTable = DT.Copy - If DdlTipoCompra.SelectedValue.ToEntero = 10 Then - DTDistinct = DTDistinct.FiltraParametros("ISNULL(TipoAF,0) <> 2", "", {"CveClasificacion", "Clasificacion", "SubProyecto", "CveSubProyecto", "CveTipoGasto", "TipoGasto", "CveAlmacen"}) - Else - 'If UsuarioActual.Empresa.Funcionalidad(126) = "1" Then - ' DTDistinct = DTDistinct.FiltraParametros("ISNULL(TipoAF,0) <> 2", "", {"CveClasificacion", "Clasificacion", "SubProyecto", "CveSubProyecto", "CveTipoGasto", "TipoGasto"}) - 'Else - DTDistinct = DTDistinct.FiltraParametros("ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1", "", {"CveClasificacion", "Clasificacion", "SubProyecto", "CveSubProyecto", "CveTipoGasto", "TipoGasto"}) - 'End If - End If - - If DTDistinct.Rows.Count > 0 Then - For Each Row2 As DataRow In DTDistinct.Rows - - 'DETERMINA IMPORTE - 'If UsuarioActual.Empresa.Funcionalidad(126) = "1" Then - ' importeMovimiento = DT.SUM("Total", String.Format("ISNULL(TipoAF,0) <> 2 AND CveClasificacion = {0} AND CveSubProyecto = {1} AND ISNULL(CveTipoGasto,0) = {2}", Row2("CveClasificacion").ToString.ToEntero, Row2("CveSubProyecto").ToString.ToEntero, Row2("CveTipoGasto").ToString.ToEntero)).ToString.ToDecimal - 'Else - importeMovimiento = DT.SUM("Total", String.Format("ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND CveClasificacion = {0} AND CveSubProyecto = {1} AND ISNULL(CveTipoGasto,0) = {2}", Row2("CveClasificacion").ToString.ToEntero, Row2("CveSubProyecto").ToString.ToEntero, Row2("CveTipoGasto").ToString.ToEntero)).ToString.ToDecimal - 'End If - - If DdlTipoCompra.SelectedValue.ToEntero = 10 Then - importeMovimiento = DT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), $"CveAlmacen > 0 ").ToString.ToDecimal + TmpDT.SUM("CostoIndirectoAlmacen", $"CveAlmacen > 0").ToString.ToDecimal - End If + 'INV [MERCANCIA RECIBIDA POR ADELANTADO (OC) | MERCANCIA PENDIENTE POR RECIBIR (COMPRA) ] + If DdlTipoCompra.SelectedValue.ToEntero <> 10 AndAlso tUsaInventarios And Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") And CveConceptoContableAlmacen.Contiene(176, 205) Then + importeMovimiento = TmpDT.SUM("Total", $"ISNULL(TipoAF,0) <> 2 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND CveTipoPS = 2").ToString.ToDecimal importeMN = importeMovimiento * tipoCambioActual * Multiplicador - 'AGREGA MOVIMIENTO - If importeMovimiento <> 0 AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then + If importeMovimiento <> 0 Then Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, importeMN, 6, Referencia, Concepto, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveIE:=CveIE, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=tipoCambioActual, CveTipoGasto:=Row2("CveTipoGasto").ToString.ToEntero) Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, importeMN, CveConceptoContableAlmacen, Referencia, Concepto, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento)) Then ErrorPrepoliza = True End If End If - Next + End If + + 'NC CON PRODUCTOS - CUENTA PUENTE + + If tUsaInventarios And Not DdlTipoComprobante.SelectedValue.Contiene("Ant") And CveConceptoContableAlmacen.Contiene(225) Then + importeMovimiento = TmpDT.SUM("Total", $"ISNULL(TipoAF,0) <> 2 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND CveTipoPS = 2").ToString.ToDecimal + importeMN = importeMovimiento * tipoCambioActual * Multiplicador + + If importeMovimiento <> 0 Then + Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, importeMN, CveConceptoContableAlmacen, Referencia, Concepto, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento)) Then + ErrorPrepoliza = True + End If + End If + End If + 'GASTO + DT = TmpDT.Copy + 'RECORREMOS PARA DETECTAR LA MODALIDAD DEL ALMACEN, EN CASO DE SER SOLO EXISTENCIA LIMPIAMOS CVEALMACEN + If DdlTipoCompra.SelectedValue <> "10" Or DdlTipoCompra.SelectedValue = "13" Then + For Each Dr As DataRow In DT.Rows + If DtAlmacenes.FiltroPrimeroValor("Modalidad", $"CveAlmacen = {Dr("CveAlmacen").ToString.ToEntero}").ToString = "Solo Existencia" Then + Dr("CveAlmacen") = 0 + End If + Dr.AcceptChanges() + Next + End If + + DT.AcceptChanges() + DtAlmacenes.Dispose() + + + If DdlTipoCompra.SelectedValue.ToEntero <> 10 Then + 'QUITA 1-[MERCANCIA RECIBIDA POR ADELANTADO (OC) | MERCANCIA PENDIENTE POR RECIBIR (COMPRA)] 2-[NC CON PRODUCTOS] + If tUsaInventarios And CveConceptoContableAlmacen > 0 Then + DT = DT.FiltraParametros("CveTipoPS <> 2") + End If + End If + + Dim DTDistinct As DataTable = DT.Copy + If DdlTipoCompra.SelectedValue.ToEntero = 10 Then + DTDistinct = DTDistinct.FiltraParametros("ISNULL(TipoAF,0) <> 2", "", {"CveClasificacion", "Clasificacion", "SubProyecto", "CveSubProyecto", "CveTipoGasto", "TipoGasto", "CveAlmacen"}) + Else + 'If UsuarioActual.Empresa.Funcionalidad(126) = "1" Then + ' DTDistinct = DTDistinct.FiltraParametros("ISNULL(TipoAF,0) <> 2", "", {"CveClasificacion", "Clasificacion", "SubProyecto", "CveSubProyecto", "CveTipoGasto", "TipoGasto"}) + 'Else + DTDistinct = DTDistinct.FiltraParametros("ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1", "", {"CveClasificacion", "Clasificacion", "SubProyecto", "CveSubProyecto", "CveTipoGasto", "TipoGasto"}) + 'End If + End If + + If DTDistinct.Rows.Count > 0 Then + For Each Row2 As DataRow In DTDistinct.Rows + + 'DETERMINA IMPORTE + 'If UsuarioActual.Empresa.Funcionalidad(126) = "1" Then + ' importeMovimiento = DT.SUM("Total", String.Format("ISNULL(TipoAF,0) <> 2 AND CveClasificacion = {0} AND CveSubProyecto = {1} AND ISNULL(CveTipoGasto,0) = {2}", Row2("CveClasificacion").ToString.ToEntero, Row2("CveSubProyecto").ToString.ToEntero, Row2("CveTipoGasto").ToString.ToEntero)).ToString.ToDecimal + 'Else + importeMovimiento = DT.SUM("Total", String.Format("ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND CveClasificacion = {0} AND CveSubProyecto = {1} AND ISNULL(CveTipoGasto,0) = {2}", Row2("CveClasificacion").ToString.ToEntero, Row2("CveSubProyecto").ToString.ToEntero, Row2("CveTipoGasto").ToString.ToEntero)).ToString.ToDecimal + 'End If + + If DdlTipoCompra.SelectedValue.ToEntero = 10 Then + importeMovimiento = DT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), $"CveAlmacen > 0 ").ToString.ToDecimal + TmpDT.SUM("CostoIndirectoAlmacen", $"CveAlmacen > 0").ToString.ToDecimal + End If + importeMN = importeMovimiento * tipoCambioActual * Multiplicador + + 'AGREGA MOVIMIENTO + If importeMovimiento <> 0 AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then + Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}" + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, importeMN, 6, Referencia, Concepto, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveIE:=CveIE, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=tipoCambioActual, CveTipoGasto:=Row2("CveTipoGasto").ToString.ToEntero) Then + ErrorPrepoliza = True + End If + End If + Next + + + + End If + + 'LIMPIA + importeMovimiento = 0 + + If CveCompra > 0 And CveCompraFactura = 0 Then + + Dim CveSubProyecto As Integer = TmpDT.MAX("CveSubProyecto").ToEntero + Dim IVAPorcentaje As Decimal = TmpDT.MAX("IVAPorcentaje").ToDecimal + Dim CveTipoSaldo As Integer = 1 + + Select Case DdlTipoComprobante.SelectedValue + Case "Fac" + CveTipoSaldo = 1 + Exit Select + Case "NC" + CveTipoSaldo = 15 + Exit Select + Case "Ant" + CveTipoSaldo = 11 + Exit Select + Case "Dev" + CveTipoSaldo = 15 + Exit Select + End Select + + Dim ConceptoTipoTotal As ConceptosTipoSaldo = ClsPaginas.ObtenerCveConceptoPrePoliza(CveTipoSaldo, DdlMoneda.SelectedValue.ToEntero, False, CveTipoConcepto) + + If Not ErrorPrepoliza AndAlso TxtIVA.Text.ToDecimal > 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TxtIVA.Text.ToDecimal, (TxtIVA.Text.ToDecimal * tipoCambioActual * Multiplicador), 14, Referencia, Concepto, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveSubProyecto:=CveSubProyecto, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=tipoCambioActual, PorcentajeImpuesto:=IVAPorcentaje) Then + ErrorPrepoliza = True + End If + End If + + If Not ErrorPrepoliza AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TxtTotal.Text.ToDecimal, (TxtTotal.Text.ToDecimal * tipoCambioActual * Multiplicador), ConceptoTipoTotal.CveConcepto, Referencia, Concepto, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveSubProyecto:=CveSubProyecto, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=tipoCambioActual) Then + ErrorPrepoliza = True + End If + + End If End If + 'SI ES GASTO CON ALMACEN REGISTRA EL CONCEPTO 95 + - 'LIMPIA - importeMovimiento = 0 Next End If @@ -10225,9 +10280,91 @@ Partial Class Compras_Compras Next End If + ''OIC 2025-04-16 El bloque de validacion se paso a la funcion ActualizarPrePolizaValidacion + 'If DtPrePolizas IsNot Nothing Then + ' For Each RowPrePoliza As DataRow In DtPrePolizas.FiltraParametros("", DistinctColumns:={"CvePrePoliza"}).Rows + ' If ObjConta.ValidacionesPrePoliza(RowPrePoliza("CvePrePoliza").ToString().ToEntero(), UsuarioActual, Opcion:=4, AutoConta:=False) Then + ' If ObjConta.ValorPolizaDescuadre > 0 Then + ' ErrorPrepoliza = True + ' Alert("Error en validacion de prepoliza cuadre", TipoMensaje.MsgAdvertencia) + ' GuardaLogAD($"Compras/Compras-Actualizar | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") + ' Exit For + ' End If + ' End If + ' Next + 'End If + + If Not ErrorPrepoliza Then + Retorno = True + Else + Retorno = False + End If + + Return Retorno + End Function + + + Private Function ActualizarPrePolizaValidacion(ByRef ObjConta As ClsContabilidad, ByRef ObjCompra As ClsCompras) As Boolean + + Dim Retorno As Boolean = True, ErrorPrepoliza As Boolean = False + Dim CvePlantillaPrePoliza As Integer + If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then + CvePlantillaPrePoliza = 60 + Else + CvePlantillaPrePoliza = 1 + End If + + If (ArrAnticipos.Count > 0 And CveCompra > 0) Or (ArrAnticipos.Count > 0 And UsuarioActual.Empresa.UsaAC) Then + CvePlantillaPrePoliza = 52 + End If + + If RBLContado.SelectedValue = "2" AndAlso DdlFuncionarioEmpleado.SelectedValue.ToEntero > 0 Then + + If DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Then + CvePlantillaPrePoliza = 60 + Else + CvePlantillaPrePoliza = 1 + End If + + End If + + Dim DtPrePolizas As DataTable = Nothing + + If ObjConta.GetPlantillaConceptos(UsuarioActual.CveEmpresa, CvePlantillaPrePoliza) Then + For Each Row As DataRow In ObjConta.DtResultados.Rows + + Dim ConceptoContable As Integer = Row("CveConcepto").ToString.ToEntero + + Select Case ConceptoContable + + Case 6 + + Dim CveProveedorConcepto As Integer = 0, CveIE As Integer = 0, CveCreditoDetalle As Integer = 0 + Dim ConceptoPersonal As String = "", Concepto As String = "" + Dim tUsaInventarios As Boolean = UsuarioActual.Empresa.UsaInventarios + If (UsuarioActual.CveEmpresa.Contiene(13, 83, 7, 11, 12, 122, 145)) Then tUsaInventarios = False + + If Not ObjConta.GetPrePolizasDetalleCompra(CveCompra, UsuarioActual.CveEmpresa) Then + ErrorPrepoliza = True + Else + DtPrePolizas = ObjConta.DtResultados.FiltraParametros("CveConceptoContable IN (6,68,49,205,176,5,305,311)") + + If DtPrePolizas.Rows.Count > 0 Then + Dim drr As DataRow = ObjConta.DtResultados.FiltraParametros("CveConceptoContable in(6,68,49,205,176,5,305,311)").FiltroPrimero("") + CveProveedorConcepto = drr("CveProveedor").ToString.ToEntero + CveIE = drr("CveIE").ToString.ToEntero + CveCreditoDetalle = drr("CveCreditoDetalle").ToString.ToEntero + Concepto = drr("Concepto").ToString + End If + End If + + End Select + Next + End If + If DtPrePolizas IsNot Nothing Then For Each RowPrePoliza As DataRow In DtPrePolizas.FiltraParametros("", DistinctColumns:={"CvePrePoliza"}).Rows - If ObjConta.ValidacionesPrePoliza(RowPrePoliza("CvePrePoliza").ToString().ToEntero(), UsuarioActual, Opcion:=4, AutoConta:=False) Then + If Not ObjConta.ValidacionesPrePoliza(RowPrePoliza("CvePrePoliza").ToString().ToEntero(), UsuarioActual, Opcion:=4, AutoConta:=False) Then If ObjConta.ValorPolizaDescuadre > 0 Then ErrorPrepoliza = True Alert("Error en validacion de prepoliza cuadre", TipoMensaje.MsgAdvertencia) @@ -10247,6 +10384,7 @@ Partial Class Compras_Compras Return Retorno End Function + Protected Sub ImgActualizarProyecto_Click(sender As Object, e As EventArgs) Handles ImgActualizarProyecto.Click 'actualizo los proyectos Dim Compra As New ClsCompras @@ -17407,8 +17545,11 @@ Partial Class Compras_Compras End If If TxtDescuento.Text.ToDouble > 0 Then TrDescuento.Visible = True - If ActualizaTotales And UsuarioActual.CveEmpresa = 72 Or Not CveCompraFactura > 0 Then + If ActualizaTotales And (UsuarioActual.CveEmpresa = 72 Or Not CveCompraFactura > 0) Then TxtTotal.Text = Total.ToString.FormatoNumero() + If CveCompra > 0 AndAlso CveCompraFactura = 0 Then + TxtIVA.Text = IVA.ToString.FormatoNumero() + End If End If Else @@ -18023,24 +18164,43 @@ Partial Class Compras_Compras 'HdnIVAPS.Value = If(PS.Rows(0)("IVA").ToString = "-1", ViewState("IVA"), PS.Rows(0)("IVA").ToString).ToString ViewState("IVAPS") = PS("IVA").ToString - If ViewState("IVAPS").ToString.ToEntero() = -1 Then + If ViewState("IVAPS").ToString.ToEntero() = -1 Or (CveCompra > 0 AndAlso CveCompraFactura = 0) Then + + Dim Drr As DataRow = GlobalDTSubProyectos(UsuarioActual.CveEmpresa, CveSubProyecto:=DdlSubProyecto.SelectedValue.ToEntero())(0) ViewState("IVAPS") = Drr("IVA").ToString().ToDouble() - DdlProyecto.SelectedValueExist(Drr("CveProyecto")) + DdlProyecto.SelectedValueExist(Drr("CveProyecto")) DdlIVA.Enabled = True - If Not Modalidad = "U" Then - Select Case ViewState("IVAPS").ToString().ToDouble - Case 0 - DdlIVA.SelectedValue = "1" - Case 0.16 - DdlIVA.SelectedValue = "1.16" - Case 0.08 - DdlIVA.SelectedValue = "1.08" - End Select + If (CveCompra > 0 AndAlso CveCompraFactura = 0) Then + If PS("IVA").ToString.ToEntero = -1 Then + ViewState("IVAPS") = 0.16 + DdlIVA.SelectedValue = "1.16" + Else + Select Case ViewState("IVAPS").ToString().ToDouble + Case 0 + DdlIVA.SelectedValue = "1" + Case 0.16 + DdlIVA.SelectedValue = "1.16" + Case 0.08 + DdlIVA.SelectedValue = "1.08" + End Select + End If + Else + If Not Modalidad = "U" Then + Select Case ViewState("IVAPS").ToString().ToDouble + Case 0 + DdlIVA.SelectedValue = "1" + Case 0.16 + DdlIVA.SelectedValue = "1.16" + Case 0.08 + DdlIVA.SelectedValue = "1.08" + End Select + End If End If + Else 'DdlIVA.SelectedValue = "1" ' DdlIVA.Enabled = False @@ -18684,12 +18844,13 @@ Partial Class Compras_Compras If CveFactura > 0 And TxtIVA.Text.ToDecimal = 0 Then DrPS("IVA") = 0 DrPS("IVAPorcentaje") = 0 + ElseIf CveCompra > 0 And CveCompraFactura = 0 Then + DrPS("IVA") = (IVA * Total).RoundSQL + DrPS("IVAPorcentaje") = IVA Else - If ActualizarIva Then DrPS("IVA") = (IVA * Total).RoundSQL End If - DrPS("IVAPorcentaje") = IVA End If @@ -19813,6 +19974,10 @@ Partial Class Compras_Compras Dim ObjContabilidad As New ClsContabilidad(ObjCompra.IniciaTransacSQL) Dim Estatus As Boolean = ActualizarPrePoliza(ObjContabilidad, ObjCompra) + If Estatus Then + Estatus = ActualizarPrePolizaValidacion(ObjContabilidad, ObjCompra) + End If + If Estatus Then ObjCompra.Commit() diff --git a/Compras/PopUpVerFactura.aspx.vb b/Compras/PopUpVerFactura.aspx.vb index a71ab3f41..3ebde3353 100644 --- a/Compras/PopUpVerFactura.aspx.vb +++ b/Compras/PopUpVerFactura.aspx.vb @@ -1587,19 +1587,18 @@ Partial Class PopUpVerFactura Dim CVEVENTA As Integer = UrlParametros("CVEVENTA").ToString.ToEntero Dim CVECLIENTE As Integer = UrlParametros("CVECLIENTE").ToString.ToEntero Dim MONTO As Decimal = UrlParametros("MONTO").ToString.ToDecimal + Dim TIPO As String = UrlParametros("TIPO").ToString If CVECLIENTE > 0 AndAlso (CVEIE > 0 Or CVEVENTA > 0) Then - ImprimirSaldosAmortizacion(CVEVENTAAMORTIZADA, CVEIE, CVEVENTA, CVECLIENTE, MONTO) + ImprimirSaldosAmortizacion(TIPO, CVEVENTAAMORTIZADA, CVEIE, CVEVENTA, CVECLIENTE, MONTO) End If End If End Sub - Private Sub ImprimirSaldosAmortizacion(CveVentaAmortizada As Integer, CveIE As Integer, CveVenta As Integer, CveCliente As Integer, Monto As Decimal) + Private Sub ImprimirSaldosAmortizacion(Tipo As String, CveVentaAmortizada As Integer, CveIE As Integer, CveVenta As Integer, CveCliente As Integer, Monto As Decimal) - - Dim ObjMovtos As New ClsMovimientos() Dim SaldoAntNCDev As Decimal = 0 Dim DatosSaldoAntNCDev As New DataTable Dim TipoDocto As String = "" @@ -1607,36 +1606,22 @@ Partial Class PopUpVerFactura Dim Saldo As Decimal = 0D Dim DTNCVinculadas As New DataTable - + Dim ObjMovtos As New ClsMovimientos() If ObjMovtos.GetAnticiposNCIxCCliente(CveCliente) Then - DatosSaldoAntNCDev = ObjMovtos.DtResultados + If Tipo.Contiene("NC", "Ant") Then + DatosSaldoAntNCDev = ObjMovtos.DtResultados.FiltraParametros($"Tipo='{Tipo}' AND CveVenta={CveVenta}") + ElseIf Tipo.Contiene("IxC") Then + DatosSaldoAntNCDev = ObjMovtos.DtResultados.FiltraParametros($"Tipo='{Tipo}' AND CveIE={CveIE}") + End If End If ObjMovtos.Dispose() If DatosSaldoAntNCDev IsNot Nothing AndAlso DatosSaldoAntNCDev.Rows.Count > 0 Then - SaldoAntNCDev = If(CveVenta > 0, - DatosSaldoAntNCDev.FiltroPrimeroValor("Saldo", $"CveVenta={CveVenta}").ToDecimal, - DatosSaldoAntNCDev.FiltroPrimeroValor("Saldo", $"CveIE={CveIE}").ToDecimal) - - TipoDocto = If(CveVenta > 0, - DatosSaldoAntNCDev.FiltroPrimeroValor("Tipo", $"CveVenta={CveVenta}"), - DatosSaldoAntNCDev.FiltroPrimeroValor("Tipo", $"CveIE={CveIE}")) - - - - - If CveIE > 0 Then - CveVenta = DatosSaldoAntNCDev.FiltroPrimeroValor("CveVenta", $"CveIE={CveIE}").ToEntero - Folio = DatosSaldoAntNCDev.FiltroPrimeroValor("Folio", $"CveIE={CveIE}") - Saldo = DatosSaldoAntNCDev.FiltroPrimeroValor("Saldo", $"CveIE={CveIE}").ToDecimal - Else - Folio = DatosSaldoAntNCDev.FiltroPrimeroValor("Folio", $"CveVenta={CveVenta}") - Saldo = DatosSaldoAntNCDev.FiltroPrimeroValor("Saldo", $"CveVenta={CveVenta}").ToDecimal - End If - - - + SaldoAntNCDev = DatosSaldoAntNCDev.FiltroPrimeroValor("Saldo").ToDecimal + TipoDocto = DatosSaldoAntNCDev.FiltroPrimeroValor("Tipo") + Folio = DatosSaldoAntNCDev.FiltroPrimeroValor("Folio") + Saldo = DatosSaldoAntNCDev.FiltroPrimeroValor("Saldo").ToDecimal End If @@ -1651,30 +1636,53 @@ Partial Class PopUpVerFactura ObjVentas.Dispose() End If + If TipoDocto.Contiene("IxC") Then + + DTNCVinculadas = New DataTable() + DTNCVinculadas.Columns.Add(New DataColumn("SerieFolioEstatus", GetType(String))) + DTNCVinculadas.Columns.Add(New DataColumn("FechaAplicado", GetType(String))) + DTNCVinculadas.Columns.Add(New DataColumn("Moneda", GetType(String))) + DTNCVinculadas.Columns.Add(New DataColumn("TotalNC", GetType(String))) + Dim DtIxC As DataTable = Nothing + Dim ObjVentas As New ClsVentas + If ObjVentas.GetRepAnticiposNCIXCDetalle(CveCliente, -1, MinFecha, MaxFecha, UsuarioActual.CveEmpresa, -1, 3, -1, MinFecha, MaxFecha, TipoCambio:=1, TCEspecifico:=-1) Then + DtIxC = ObjVentas.DtResultados.FiltraParametros($"CveIE={CveIE} AND TipoColumna ='Aplicación'") + End If + ObjVentas.Dispose() + + If DtIxC IsNot Nothing Then + For Each RowIxC As DataRow In DtIxC.Rows + Dim Row As DataRow = DTNCVinculadas.NewRow + Row("SerieFolioEstatus") = RowIxC("SerieFolioAmortizacion") + Row("FechaAplicado") = RowIxC("FechaAmortizacion") + Row("Moneda") = RowIxC("MonedaAmortizacion") + Row("TotalNC") = RowIxC("ImporteAmortizacion") + DTNCVinculadas.Rows.Add(Row) + Next + End If + End If + If DTNCVinculadas IsNot Nothing Then Dim params As New List(Of ReportParameter) + params.Add(New ReportParameter("Tipo", Tipo)) + Dim ObjVentas As New ClsVentas If ObjVentas.GetVenta(CveVentaAmortizada, UsuarioActual.CveEmpresa) Then Dim DbRowVenta = ObjVentas.DtResultados.Copy().FiltroPrimero("") If DbRowVenta IsNot Nothing Then - params.Add(New ReportParameter("SerieFolio", DbRowVenta("SerieFolio").ToString)) + params.Add(New ReportParameter("SerieFolio", Folio)) params.Add(New ReportParameter("Moneda", DbRowVenta("Moneda").ToString)) params.Add(New ReportParameter("Cliente", DbRowVenta("ClienteNombre").ToString)) - End If End If ObjVentas.Dispose() - - Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png") - - params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) params.Add(New ReportParameter("FechaImpresion", NowADS().ToString)) diff --git a/Compras/RepRembolsoComprobaciones.aspx b/Compras/RepRembolsoComprobaciones.aspx index fb4e387ee..160139739 100644 --- a/Compras/RepRembolsoComprobaciones.aspx +++ b/Compras/RepRembolsoComprobaciones.aspx @@ -26,16 +26,11 @@
  • - - Exportar Excel - + Exportar Excel
  • - - Imprimir Reembolso - + Imprimir Reembolso
  • -
  • Cargar Comprobante
  • @@ -123,6 +118,13 @@
    + +
    + + +
    @@ -188,7 +190,8 @@
    - + Compra diff --git a/Compras/RepRembolsoComprobaciones.aspx.vb b/Compras/RepRembolsoComprobaciones.aspx.vb index edd6c6050..795ce312f 100644 --- a/Compras/RepRembolsoComprobaciones.aspx.vb +++ b/Compras/RepRembolsoComprobaciones.aspx.vb @@ -87,7 +87,9 @@ Partial Class Compras_RepRembolsoComprobaciones DdlPersonal.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa) DdlPersonal.DataBind() - txtFechaI.Text = NowADS.AddYears(-1).ToShortDateString + txtFechaI.Text = NowADS.AddMonths(-3).ToShortDateString + + CargarCentrosDeCosto(Nothing, DdlSubProyecto, Nothing, LblSubProyecto, "Todos") End If End Sub @@ -133,8 +135,17 @@ Partial Class Compras_RepRembolsoComprobaciones Protected Sub GvCxP_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCxP.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then - If e.Row.RowIndex = 0 Then - e.Row.BackColor = Drawing.Color.LightGray + + 'If e.Row.RowIndex = 0 Then + ' e.Row.BackColor = Drawing.Color.LightGray + 'End If + + If e.Row.DataKey("Gpo").Trim.Length = 0 Then + e.Row.CssClass = "Totales" + End If + + If e.Row.DataKey("Gpo").Trim.Length > 0 AndAlso e.Row.DataKey("CveCompra").ToEntero = 0 Then + e.Row.CssClass = "SubTotales" End If e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Right @@ -236,7 +247,8 @@ Partial Class Compras_RepRembolsoComprobaciones If DdlTipoPago.SelectedValue = "2" Then ViewState("CvePersonal") = -2 - ObjMovtos.GetCxPPersonalCajaChica(UsuarioActual.CveEmpresa, CvePersonal, CveCajaChica, If(TxtNumeroReembolso.Text.Trim = "", "-1", TxtNumeroReembolso.Text.Trim), FechaI:=FechaI, FechaF:=FechaF, OpcionSaldo:=-1) + ObjMovtos.GetCxPPersonalCajaChica(UsuarioActual.CveEmpresa, CvePersonal, CveCajaChica, If(TxtNumeroReembolso.Text.Trim = "", "-1", TxtNumeroReembolso.Text.Trim), FechaI:=FechaI, FechaF:=FechaF, OpcionSaldo:=-1, + CveSubProyecto:=DdlSubProyecto.SelectedValue.ToEntero) DtDatos = ObjMovtos.DtResultados GvCxP.DataSource = DtDatos diff --git a/Compras/eFacturas.aspx.vb b/Compras/eFacturas.aspx.vb index 95591bce5..58af0d5ec 100644 --- a/Compras/eFacturas.aspx.vb +++ b/Compras/eFacturas.aspx.vb @@ -1168,7 +1168,7 @@ Partial Class Compras_eFacturas 'End If Dim Funcionalidad123 As Integer = UsuarioActual.Empresa.Funcionalidad(123).ToEntero - If Funcionalidad123 > 0 Then + If Funcionalidad123 > 0 AndAlso Not e.Row.DataKey("CveFactura").ToEntero.Contiene(1223188) Then If NowADS().Day >= Funcionalidad123 Then Dim FechaLimite As Date = New Date(NowADS().Year, NowADS().Month, 1) If e.Row.DBCampo("FechaFactura").ToDate < FechaLimite Then diff --git a/Contabilidad/DiarioPagos.aspx b/Contabilidad/DiarioPagos.aspx index df56da6ec..640fd5901 100644 --- a/Contabilidad/DiarioPagos.aspx +++ b/Contabilidad/DiarioPagos.aspx @@ -1,4 +1,4 @@ -<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="DiarioPagos.aspx.vb" Inherits="Contabilidad_DiarioPagos" %> +<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="DiarioPagos.aspx.vb" Inherits="Contabilidad_DiarioPagos" ValidateRequest="false" %> <%@ Import Namespace="Extensiones" %> diff --git a/Contabilidad/RegPrePolizaS.aspx.vb b/Contabilidad/RegPrePolizaS.aspx.vb index caf9c6f53..3df41ca1e 100644 --- a/Contabilidad/RegPrePolizaS.aspx.vb +++ b/Contabilidad/RegPrePolizaS.aspx.vb @@ -1561,7 +1561,7 @@ Partial Class ContabilidadC_RegPrePolizaS DdlProveedoresE.Items.Insert(0, New ListItem(" - ", "-1")) End Sub Private Sub CargaComprasE(CveProveedor As Integer, Optional tCveCompra As Integer = -1) - If DdlConceptosContablesE.SelectedValue.ToEntero.Contiene(5, 17, 305, 308, 310, 311, 312) Then + If DdlConceptosContablesE.SelectedValue.ToEntero.Contiene(5, 6, 17, 305, 308, 310, 311, 312) Then Dim ObjCompras As New ClsCompras DdlComprasE.ClearSelection() diff --git a/Contabilidad/RepGastosCC.aspx b/Contabilidad/RepGastosCC.aspx index 46c288faa..9f918e6a6 100644 --- a/Contabilidad/RepGastosCC.aspx +++ b/Contabilidad/RepGastosCC.aspx @@ -223,8 +223,6 @@ table.adssigscroll { - - diff --git a/Empresas/153/Formatos/Cotizacion.rdlc b/Empresas/153/Formatos/Cotizacion.rdlc index 6a5cf12c3..47c8076a7 100644 --- a/Empresas/153/Formatos/Cotizacion.rdlc +++ b/Empresas/153/Formatos/Cotizacion.rdlc @@ -1217,8 +1217,8 @@ - CAMELIA No.Ext: 619, Col: Libertad, -CP: 83130, Hermosillo,Sonora, México + SIMON BLEY No.Ext: 355, No.Int: A, Col: Olivares, +CP: 83180, Hermosillo,Sonora, México - - - - - - - - - - - - Textbox28 - - - - LightGrey - - - LightGrey - - - LightGrey - - - - - LightGrey - 1pt - - - - - - - - - - - 3.42604cm - - - 2.43119cm - - - 3.94465cm - - - - - 0.44125cm - - - - - true - true - - - - - =Fields!FechaAplicado.Value - - - - - - - FechaAplicado - - - =IIF(Fields!TotalNC.Value < 0, "#e7505a","White") - 0.5pt - - - - - - - - true - true - - - - - =Fields!Moneda.Value - - - - - - - Moneda - - - =IIF(Fields!TotalNC.Value < 0, "#e7505a","White") - 0.5pt - - - - - - - - true - true - - - - - =Fields!TotalNC.Value - - - - - - - TotalNC - - - =IIF(Fields!TotalNC.Value < 0, "#e7505a","White") - 0.5pt - - - - - - - - - - - - - 0.44125cm - - - true - true - - - - - Fecha - - - - - - - Textbox19 - - - LightGrey - 1pt - - - - - - - - 0.44125cm - - - true - true - - - - - Moneda - - - - - - - Textbox21 - - - LightGrey - 1pt - - - - - - - - 0.44125cm - - - true - true - - - - - Importe - - - - - - - Textbox23 - - - LightGrey - 1pt - - - - - - - - - - - - - 6.69369cm - - - true - true - - - - - =Fields!SerieFolioEstatus.Value - - - - - - - SerieFolioEstatus - - - =IIF(Fields!TotalNC.Value < 0, "#e7505a","White") - 0.5pt - - - - - - - - true - true - DataSet1 - 0.12375cm - 0.25664cm - 0.8825cm - 16.49557cm - - - - - - 0.39616in - - - - - - - Textbox1 - 3.8144cm - 0.6cm - 13.0693cm - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Aplicaciones de facturas - - - - - - - Textbox2 - 0.63528cm - 3.77912cm - 0.52945cm - 13.0693cm - 1 - - - 2pt - 2pt - 2pt - 2pt - - - - External - =Parameters!LogoPath.Value - FitProportional - 0.06614cm - 2.22362cm - 3.00743cm - 2 - - - - - - true - true - - - - - Cliente: - - - - - - - - - true - true - - - - - =Parameters!Cliente.Value - - - - - - true - true - - - - - Factura: - - - - - - - - - true - true - - - - - =Parameters!SerieFolio.Value - - - - - - true - true - - - - - Monto: - - - - - - - - - true - true - - - - - =Parameters!Monto.Value - - - - - - true - true - - - - - Saldo: - - - - - - - - - true - true - - - - - =Parameters!Saldo.Value - - - - - - true - true - - - - - Aplicaciones de facturas: - - - - - - - - - true - true - - - - - Folio: - - - - - - - - - true - true - - - - - =Parameters!Folio.Value - - - - - - true - true - - - - - Fecha: - - - - - - - - - true - true - - - - - =Parameters!FechaImpresion.Value - - - - - - true - true - - - - - Moneda: - - - - - - - - - true - true - - - - - =Parameters!Moneda.Value - - - - - - - - - - - 0.48291cm - true - true - - - true - true - - - - - ="Página " & Globals.PageNumber & " de " & Globals.TotalPages - - - - - - - Textbox3 - 0.08291cm - 18.6093cm - 0.4cm - 2.06587cm - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Usuario: - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - =Parameters!UsuarioImprimio.Value - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Fecha Impresión: - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - =Parameters!FechaImpresion.Value - - - - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - 29.7cm - 21cm - 0.1cm - 0.1cm - 1cm - 0.5cm - 0.13cm - @@ -1538,7 +1538,7 @@ - 1.68927cm + 1.39994cm true @@ -1596,7 +1596,7 @@ 10.58305cm 0.44227cm 1.12062cm - 19.07303cm + 19.13385cm 3 + + + + + + - 22.49898cm + 22.81648cm 1.5cm 0cm 3.90544cm @@ -6374,7 +6405,7 @@ Se ha recibido el número arriba indicado de bultos/contenedores/remolques/autot - 22.49898cm + 22.81648cm 9.94339cm 0cm 3.90544cm @@ -6386,7 +6417,7 @@ Se ha recibido el número arriba indicado de bultos/contenedores/remolques/autot - 22.49898cm + 22.81648cm 14.71743cm 0cm 3.90544cm @@ -6415,7 +6446,7 @@ Se ha recibido el número arriba indicado de bultos/contenedores/remolques/autot Textbox120 - 22.67201cm + 22.98951cm 1.36431cm 0.45969cm 10.17692cm @@ -6508,7 +6539,7 @@ Se ha recibido el número arriba indicado de bultos/contenedores/remolques/autot true 23.161cm 0.03979cm - 23.1317cm + 23.4492cm 19.53633cm 29 @@ -7528,6 +7559,9 @@ Se ha recibido el número arriba indicado de bultos/contenedores/remolques/autot + + =IIF(Fields!MaterialPeligroso.Value = "No",True,False) + @@ -7554,83 +7588,10 @@ Se ha recibido el número arriba indicado de bultos/contenedores/remolques/autot - - true - true - - - - - =Parameters!SerieFolio.Value - - - - - - - SerieFolio - 0.67478cm - 15.20438cm - 0.6cm - 3.97474cm - 12 - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - - - - - =Parameters!FechaCertificacion.Value - - - - - - - SerieFolio - 1.45117cm - 15.20438cm - 0.6cm - 3.97474cm - 13 - - - 2pt - 2pt - 2pt - 2pt - - true - 47.03985cm + 46.78659cm + 0.04317cm 5.54925cm 19.53633cm 31 @@ -8183,6 +8144,18 @@ Se ha recibido el número arriba indicado de bultos/contenedores/remolques/autot true ReportParameter1 + + String + true + true + ReportParameter1 + + + String + true + true + ReportParameter1 + Function PageNumber() As String Return Me.Report.Globals!OverallPageNumber diff --git a/Empresas/Grales/Formatos/RepRembolsosComprobaciones.rdlc b/Empresas/Grales/Formatos/RepRembolsosComprobaciones.rdlc index fe395548e..030db69cb 100644 --- a/Empresas/Grales/Formatos/RepRembolsosComprobaciones.rdlc +++ b/Empresas/Grales/Formatos/RepRembolsosComprobaciones.rdlc @@ -17,6 +17,14 @@ /* Local Query */ + + Gpo + System.String + + + CveCompra + System.Int32 + Proveedor System.String @@ -77,10 +85,10 @@ 1.79565cm - 2.02289cm + 2.90517cm - 2.54059cm + 1.65831cm 2.29435cm @@ -440,6 +448,10 @@ =Fields!SerieFolio.Value @@ -453,7 +465,10 @@ - =IIF(Fields!SerieFolio.Value = "TOTAL", "#67809F", "No color") + =IIF(LEN(Fields!Gpo.Value) = 0 + , "#9cacc1" + , IIF(LEN(Fields!Gpo.Value) > 0 AndAlso Fields!CveCompra.Value = 0, "#cccccc", "No color") + ) 2pt 2pt 2pt @@ -474,6 +489,10 @@ =Fields!Proveedor.Value @@ -487,7 +506,10 @@ - =IIF(Fields!SerieFolio.Value = "TOTAL", "#67809F", "No color") + =IIF(LEN(Fields!Gpo.Value) = 0 + , "#9cacc1" + , IIF(LEN(Fields!Gpo.Value) > 0 AndAlso Fields!CveCompra.Value = 0, "#cccccc", "No color") + ) 2pt 2pt 2pt @@ -509,6 +531,10 @@ @@ -522,7 +548,10 @@ - =IIF(Fields!SerieFolio.Value = "TOTAL", "#67809F", "No color") + =IIF(LEN(Fields!Gpo.Value) = 0 + , "#9cacc1" + , IIF(LEN(Fields!Gpo.Value) > 0 AndAlso Fields!CveCompra.Value = 0, "#cccccc", "No color") + ) 2pt 2pt 2pt @@ -544,6 +573,10 @@ @@ -557,7 +590,10 @@ - =IIF(Fields!SerieFolio.Value = "TOTAL", "#67809F", "No color") + =IIF(LEN(Fields!Gpo.Value) = 0 + , "#9cacc1" + , IIF(LEN(Fields!Gpo.Value) > 0 AndAlso Fields!CveCompra.Value = 0, "#cccccc", "No color") + ) 2pt 2pt 2pt @@ -579,6 +615,10 @@ @@ -592,7 +632,10 @@ - =IIF(Fields!SerieFolio.Value = "TOTAL", "#67809F", "No color") + =IIF(LEN(Fields!Gpo.Value) = 0 + , "#9cacc1" + , IIF(LEN(Fields!Gpo.Value) > 0 AndAlso Fields!CveCompra.Value = 0, "#cccccc", "No color") + ) 2pt 2pt 2pt @@ -614,6 +657,10 @@ @@ -627,7 +674,10 @@ - =IIF(Fields!SerieFolio.Value = "TOTAL", "#67809F", "No color") + =IIF(LEN(Fields!Gpo.Value) = 0 + , "#9cacc1" + , IIF(LEN(Fields!Gpo.Value) > 0 AndAlso Fields!CveCompra.Value = 0, "#cccccc", "No color") + ) 2pt 2pt 2pt @@ -649,6 +699,10 @@ @@ -662,7 +716,10 @@ - =IIF(Fields!SerieFolio.Value = "TOTAL", "#67809F", "No color") + =IIF(LEN(Fields!Gpo.Value) = 0 + , "#9cacc1" + , IIF(LEN(Fields!Gpo.Value) > 0 AndAlso Fields!CveCompra.Value = 0, "#cccccc", "No color") + ) 2pt 2pt 2pt @@ -684,6 +741,10 @@ @@ -697,7 +758,10 @@ - =IIF(Fields!SerieFolio.Value = "TOTAL", "#67809F", "No color") + =IIF(LEN(Fields!Gpo.Value) = 0 + , "#9cacc1" + , IIF(LEN(Fields!Gpo.Value) > 0 AndAlso Fields!CveCompra.Value = 0, "#cccccc", "No color") + ) 2pt 2pt 2pt diff --git a/General/Dashboard.aspx b/General/Dashboard.aspx new file mode 100644 index 000000000..95553bddd --- /dev/null +++ b/General/Dashboard.aspx @@ -0,0 +1,55 @@ +<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="Dashboard.aspx.vb" Inherits="General_Dashboard" %> + + + + + + + + + + + + + + + + + +
    + +
    +
    +
    +
    + + + + diff --git a/General/Dashboard.aspx.vb b/General/Dashboard.aspx.vb new file mode 100644 index 000000000..7384cc14f --- /dev/null +++ b/General/Dashboard.aspx.vb @@ -0,0 +1,101 @@ + +Imports System.Data +Imports Extensiones +Imports System.Web.Services +Imports Newtonsoft.Json +Imports ADSNetLibrary.SIGAPI.Models.CRM.Request +Imports ADSNetLibrary.SIGAPI.Services.CRM + +Partial Class General_Dashboard + Inherits ClsPaginas + + Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load + If Not IsPostBack Then + CargarIndicadores() + End If + End Sub + + Private Sub CargarIndicadores() + Dim Gral As New ClsGenerales + Dim ds As DataSet = Gral.GetDashboardData(UsuarioActual.CveEmpresa) + + If ds IsNot Nothing AndAlso ds.Tables.Count > 0 Then + ProcesarDatosIndicadores(ds.Tables(0)) + End If + End Sub + + Private Sub ProcesarDatosIndicadores(dt As DataTable) + If dt.Rows.Count > 0 Then + Dim dr As DataRow = dt.Rows(0) + + ' Indicador Año + MuestraIndicador(DivIndicadores, "blue", "fa fa-calendar", "Año Actual", dr("AcumAño").ToString.FormatoNumero(0), "#", "Acumulado", + dr("AcumAñoPromedio").ToString.FormatoNumero(0), "#", "Promedio", + dr("AcumAñoContado").ToString.FormatoNumero(0), "#", "Contado", + dr("AcumAñoCredito").ToString.FormatoNumero(0), "#", "Crédito") + + ' Indicador Mes + MuestraIndicador(DivIndicadores, "green", "fa fa-calendar-check-o", "Mes Actual", + dr("AcumMes").ToString.FormatoNumero(0), "#", "Acumulado", + dr("AcumMesPromedio").ToString.FormatoNumero(0), "#", "Promedio", + dr("AcumMesContado").ToString.FormatoNumero(0), "#", "Contado", + dr("AcumMesCredito").ToString.FormatoNumero(0), "#", "Crédito") + + ' Indicador Semana + MuestraIndicador(DivIndicadores, "purple", "fa fa-calendar-minus-o", "Semana Actual", + dr("AcumSemana").ToString.FormatoNumero(0), "#", "Acumulado", + dr("AcumSemanaPromedio").ToString.FormatoNumero(0), "#", "Promedio", + dr("AcumSemanaContado").ToString.FormatoNumero(0), "#", "Contado", + dr("AcumSemanaCredito").ToString.FormatoNumero(0), "#", "Crédito") + + + MuestraIndicador(DivIndicadores, "red", "fa fa-sun-o", "Hoy", + "0".FormatoNumero(0), "#", "Acumulado", + "0".FormatoNumero(0), "#", "Promedio", + "0".FormatoNumero(0), "#", "Contado", + "0".FormatoNumero(0), "#", "Crédito") + End If + End Sub + + Private Sub MuestraIndicador(DIV As HtmlGenericControl, Color As String, Icono As String, Titulo As String, Comentario As String, Link As String, TitleComentario As String) + Dim htmldiv As New StringBuilder + htmldiv.AppendFormat("{0}
    ", DIV.InnerHtml, Color, Icono) + htmldiv.AppendFormat("
    {0}
    Ver Más
    ", Link) + DIV.InnerHtml = htmldiv.ToString + End Sub + Private Sub MuestraIndicador(DIV As HtmlGenericControl, Color As String, Icono As String, Titulo As String, C1 As String, CL1 As String, CT1 As String, C2 As String, CL2 As String, CT2 As String) + Dim htmldiv As New StringBuilder + htmldiv.AppendFormat("{0}
    ", DIV.InnerHtml, Color, Icono) + htmldiv.AppendFormat("
    {0}
    ", Titulo) + htmldiv.AppendFormat("", CT1, C1) + htmldiv.AppendFormat("", CT2, C2) + htmldiv.Append("
    Ver Más ") + htmldiv.AppendFormat("
    ") + DIV.InnerHtml = htmldiv.ToString + End Sub + Private Sub MuestraIndicador(DIV As HtmlGenericControl, Color As String, Icono As String, Titulo As String, C1 As String, CL1 As String, CT1 As String, C2 As String, CL2 As String, CT2 As String, C3 As String, CL3 As String, CT3 As String) + Dim htmldiv As New StringBuilder + htmldiv.AppendFormat("{0}
    ", DIV.InnerHtml, Color, Icono) + htmldiv.AppendFormat("
    {0}
    ", Titulo) + htmldiv.AppendFormat("", CT1, C1) + htmldiv.AppendFormat("", CT2, C2) + htmldiv.AppendFormat("", CT3, C3) + htmldiv.Append("
    Ver Más ") + htmldiv.AppendFormat("
    ") + DIV.InnerHtml = htmldiv.ToString + End Sub + Private Sub MuestraIndicador(DIV As HtmlGenericControl, Color As String, Icono As String, Titulo As String, C1 As String, CL1 As String, CT1 As String, C2 As String, CL2 As String, CT2 As String, C3 As String, CL3 As String, CT3 As String, C4 As String, CL4 As String, CT4 As String) + Dim htmldiv As New StringBuilder + htmldiv.AppendFormat("{0}
    ", DIV.InnerHtml, Color, Icono) + htmldiv.AppendFormat("
    {0}
    ", Titulo, CT1, C1) + htmldiv.AppendFormat("", CT2, C2) + htmldiv.AppendFormat("", CT3, C3) + htmldiv.AppendFormat("", CT4, C4) + htmldiv.AppendFormat("
    Ver Más
    ", CL1) + DIV.InnerHtml = htmldiv.ToString + End Sub + +End Class diff --git a/Inicio.aspx b/Inicio.aspx index 346464f56..9cf4159cd 100644 --- a/Inicio.aspx +++ b/Inicio.aspx @@ -66,10 +66,9 @@ margin-left: 28%; } - .calendariobody label { - font-size: 12px; - } - + .calendariobody label { + font-size: 12px; + } .tareasinicio tr td:nth-child(1) { } @@ -107,11 +106,11 @@ display: block; } - #moopio a:hover { - background-color: rgba(0,0,0,0.5); - transform: scale(1.2); - cursor: default; - } + #moopio a:hover { + background-color: rgba(0,0,0,0.5); + transform: scale(1.2); + cursor: default; + } .MultiLineTextBox { @@ -124,7 +123,29 @@ } - //#region highcharts + + + #divsmsdash { + /* Estilo general compacto */ + --hcg-font-size: 8px !important; + --hcg-padding: 4px; + --hcg-border-radius: 6px; + } + .dashboard-container { + font-size: 16px; /* Tamaño base */ + } + .highcharts-data-table table { + /* Estilo general compacto */ + --hcg-font-size: 8px !important; + --hcg-padding: 4px; + --hcg-border-radius: 6px; + } + + #divsmsdash .hcg-theme-default, .highcharts-datagrid-theme-default { + --hcg-font-size: 10px; + --hcg-padding: 5px; + } + .highcharts-figure, .highcharts-data-table table { min-width: 310px; @@ -176,78 +197,78 @@ margin: 0.3rem 10px; } h1#title { - padding-top: 10px; - margin: 0; - background-color: #3d3d3d; - text-align: center; - color: #fff; -} + padding-top: 10px; + margin: 0; + background-color: #3d3d3d; + text-align: center; + color: #fff; + } -#kpi-vitamin-a .highcharts-dashboards-component-title::before, -#kpi-iron .highcharts-dashboards-component-title::before { - width: 14px; - height: 14px; - border-radius: 28px; - display: inline-block; - padding: 0; - margin-right: 4px; - background-color: var(--highcharts-color-0); - content: " "; -} + #kpi-vitamin-a .highcharts-dashboards-component-title::before, + #kpi-iron .highcharts-dashboards-component-title::before { + width: 14px; + height: 14px; + border-radius: 28px; + display: inline-block; + padding: 0; + margin-right: 4px; + background-color: var(--highcharts-color-0); + content: " "; + } -#kpi-iron .highcharts-dashboards-component-title::before { - background-color: var(--highcharts-color-2); -} + #kpi-iron .highcharts-dashboards-component-title::before { + background-color: var(--highcharts-color-2); + } -#kpi-vitamin-a .highcharts-dashboards-component-kpi-subtitle, -#kpi-iron .highcharts-dashboards-component-kpi-subtitle { - margin-top: 10px; - font-size: 1.2em; - color: var(--highcharts-neutral-color-60); -} + #kpi-vitamin-a .highcharts-dashboards-component-kpi-subtitle, + #kpi-iron .highcharts-dashboards-component-kpi-subtitle { + margin-top: 10px; + font-size: 1.2em; + color: var(--highcharts-neutral-color-60); + } -#kpi-vitamin-a .highcharts-dashboards-component-kpi-value, -#kpi-iron .highcharts-dashboards-component-kpi-value { - font-size: 4em; - line-height: 2.4rem; - margin-top: 10px; - color: var(--highcharts-color-0); -} + #kpi-vitamin-a .highcharts-dashboards-component-kpi-value, + #kpi-iron .highcharts-dashboards-component-kpi-value { + font-size: 4em; + line-height: 2.4rem; + margin-top: 10px; + color: var(--highcharts-color-0); + } -#kpi-iron .highcharts-dashboards-component-kpi-value { - color: var(--highcharts-color-2); -} + #kpi-iron .highcharts-dashboards-component-kpi-value { + color: var(--highcharts-color-2); + } -#dashboard-col-1 .highcharts-color-0 { - fill: var(--highcharts-color-2); - stroke: var(--highcharts-color-2); -} + #dashboard-col-1 .highcharts-color-0 { + fill: var(--highcharts-color-2); + stroke: var(--highcharts-color-2); + } -#kpi-vitamin-a .highcharts-dashboards-component-kpi-value::after, -#kpi-iron .highcharts-dashboards-component-kpi-value::after { - content: ""; - display: block; - font-size: 1rem; -} + #kpi-vitamin-a .highcharts-dashboards-component-kpi-value::after, + #kpi-iron .highcharts-dashboards-component-kpi-value::after { + content: ""; + display: block; + font-size: 1rem; + } -.highcharts-plot-line { - stroke-dasharray: 2px; - stroke: var(--highcharts-color-3); -} + .highcharts-plot-line { + stroke-dasharray: 2px; + stroke: var(--highcharts-color-3); + } -.highcharts-plot-line-label { - fill: var(--highcharts-color-3); -} + .highcharts-plot-line-label { + fill: var(--highcharts-color-3); + } -.highcharts-description { - padding: 0 20px; -} + .highcharts-description { + padding: 0 20px; + } -#kpi-vitamin-a, -#kpi-iron { - flex: 1 1 100%; - height: 205px; -} + #kpi-vitamin-a, + #kpi-iron { + flex: 1 1 100%; + height: 205px; + } /* LARGE */ @media (max-width: 1200px) { @@ -473,7 +494,7 @@ flex: 1 1 50%; } } -//#endregion + @@ -498,7 +519,7 @@
    - +

    @@ -506,10 +527,10 @@
    Indicador - - - - + + + +
    @@ -527,10 +548,33 @@

    -
    -
    -
    -
    +
    + + +
    +
    Opción:
    +
    + + + + + + + +
    +
    + + + + +
    +
    +
    +
    +
    + + +

    diff --git a/Inicio.aspx.vb b/Inicio.aspx.vb index ee937827d..96ba681cf 100644 --- a/Inicio.aspx.vb +++ b/Inicio.aspx.vb @@ -4,73 +4,33 @@ Imports System.Web.Services Imports Newtonsoft.Json Imports ADSNetLibrary.SIGAPI.Models.CRM.Request Imports ADSNetLibrary.SIGAPI.Services.CRM -Imports ADSNetLibrary.SIGAPI.Models.CRM.Response Partial Class Inicio Inherits ClsPaginas Private Dias() As String = {"Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"} - - Public Function GetFacturasCanceladasPendientesWS(objventas As ClsVentas, RFC As String, CveEmpresa As Integer, Optional showalert As Boolean = True) As Boolean - Dim retorno As Boolean = False - Try - - Dim objServicio As New Cancelacion2022.CancelacionSoapClient() - Dim resp As Cancelacion2022.StructCancel = objServicio.ObtienePendientes(RFC, "UserTest", "1234567890") - If resp.Estado = 0 Then - Dim XmlPendientes As String = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(resp.Xml)) - Dim theReader As IO.StringReader = New IO.StringReader(XmlPendientes) - Dim theDataSet As DataSet = New DataSet() - theDataSet.ReadXml(theReader) - - If theDataSet.Tables(0).Rows(0)("Uuid").ToString() <> "null" Then - Dim sb As New StringBuilder() - - For Each item As DataRow In theDataSet.Tables(0).Rows - sb.AppendFormat("{0};", item("Uuid").ToString()) - Next - If objventas.GetFacturasCanceladasPendientes(sb.ToString(), CveEmpresa) Then - retorno = True - End If - gvCancelaPendiente.DataSource = objventas.DtResultados - Else - If showalert Then - Alert("No se encontraron cancelaciones pendientes", ModExtensiones.TipoMensaje.MsgError) - End If - End If - Else - Alert("Los servicios del SAT presentan intermitencia y no se puede obtener la información de cancelaciones pendientes: " & resp.Descripcion, ModExtensiones.TipoMensaje.MsgError) - End If - Catch ex As Exception - retorno = False - Me.OnError("Los servicios del SAT presentan intermitencia y no se puede obtener la información: ", ex, "") - End Try - gvCancelaPendiente.DataBind() - Return retorno - End Function - - Private Sub cargaUnuaUno() - GVPA_OI_UnoAUnoTableroGet.DataSource = New System.Data.DataTable() - - Using ObjPA_O As ClsOIEventos = New ClsOIEventos() - If ObjPA_O.UnoAUnoTableroGet(UsuarioActual.CveEmpresa, NowADS().ToString("yyyy/MM/dd"), UsuarioActual.CveUsuario) Then - - If ObjPA_O.DtResultados.COUNT("CveUnoaUno", "CveUnoaUno = -1") > 0 Then - RegistraScript("$('#DvUnoaUno').modal();") - End If - End If - GVPA_OI_UnoAUnoTableroGet.DataSource = ObjPA_O.DtResultados - End Using - - GVPA_OI_UnoAUnoTableroGet.DataBind() - End Sub Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then 'Using objnoti = New ClsSisNotificaciones() ' objnoti.ContadorCampana("Mi Mensaje", UsuarioActual.CveUsuario.ToString()) 'End Using + Dim clientIp As String = (If(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), + Request.ServerVariables("REMOTE_ADDR"))).Split(","c)(0).Trim() + ' Ruta del archivo con las IP bloqueadas + Dim path As String = Server.MapPath("/Utilerias/IPBloqueadas.txt") + + If System.IO.File.Exists(path) Then + ' Leer el contenido del archivo y separarlo por ";" + Dim contenido As String = System.IO.File.ReadAllText(path) + Dim ipBloqueadas As String() = contenido.Split(";"c) + ' Verificar si la IP está en la lista + If ipBloqueadas.Any(Function(ip) ip.Trim() = clientIp) Then + Response.Redirect("/LogIn.aspx") + End If + End If + If Not IsNothing(Request("logout")) AndAlso Request("logout").ToString() = "1" Then Usuario.CerrarSession() Exit Sub @@ -171,28 +131,49 @@ Partial Class Inicio End If OC.Dispose() End If - - ViewState("FechaSel") = NowADS().ToShortDateString - 'Not UsuarioActual.CveEmpresa.Contiene(66, 74) OrElse - - 'Ventas no timbradas por centro de costo If UsuarioActual.TienePermisoProceso(208) Then MuestraNoTimbradasCentroCosto() - 'Ventas sin correo enviado If UsuarioActual.TienePermisoProceso(319) Then MuestraVentasNoEnviadas() - If UsuarioActual.TienePermisoProceso(271) Then MuestraVentasPUE() If UsuarioActual.TienePermisoProceso(270) Then MuestraComprasPUE() - - If UsuarioActual.TienePermisoProceso(343) Then MuestraPsProximosAVencer() If UsuarioActual.TienePermisoProceso(344) Then MuestraRSCOProximosAVencer() - If UsuarioActual.Empresa.Funcionalidad(578) = "1" AndAlso UsuarioActual.CveRol.Contiene(1577, 1639, 1573) Then - CargaKPICirugias() + If UsuarioActual.Empresa.Funcionalidad(578) = "1" AndAlso (UsuarioActual.CveUsuario = 3964 Or UsuarioActual.CveRol = 1639) Then 'AndAlso UsuarioActual.CveRol.Contiene(1577, 1639, 1573) Then + 'Dim Opcion As Integer = 1 + 'Dim CveVendedor As Integer = -1 + 'Dim CveUsuarioTecnico As Integer = -1 + + 'If UsuarioActual.CveRol = 1577 Then 'vendedor + ' Opcion = 1 + ' CveVendedor = UsuarioActual.CveVendedor + ' CveUsuarioTecnico = UsuarioActual.CveUsuario 'GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveUsuarioTecnico", $"CveVendedor = {CveVendedor}").ToEntero + 'ElseIf UsuarioActual.CveRol.Contiene(1639, 1573) Then ' rol admin. 1573 + ' Opcion = 2 'gerente ventas + 'End If + divsms1.Visible = True + If UsuarioActual.CveUsuario = 3964 Then + DdlSMSOpciones.SelectedValue = "2" + DdlSMSVendedores.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa).FiltraParametros($"CveEstatus=1 ") + DdlSMSVendedores.DataBind() + End If + If UsuarioActual.CveRol.Contiene(1639) Then 'gerente ventas + DdlSMSOpciones.SelectedValue = "2" + DdlSMSOpciones.Items.RemoveAt(4) + DdlSMSOpciones.Items.RemoveAt(3) + DdlSMSOpciones.Items.RemoveAt(2) + Dim CveGerenteVendedor As Integer = -1 + If UsuarioActual.CveUsuario = 4419 Then CveGerenteVendedor = 1386 '; --' daniela + If UsuarioActual.CveUsuario = 4137 Then CveGerenteVendedor = 1172 '; --'jesus alvarez + + DdlSMSVendedores.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa).FiltraParametros($"CveEstatus=1 and CveSuperior = {CveGerenteVendedor} ") + DdlSMSVendedores.DataBind() + End If + CargaSMSKPI() + End If If (UsuarioActual.CveRol = 1062) Or (UsuarioActual.CveUsuario = 100) Then @@ -247,6 +228,59 @@ Partial Class Inicio End Sub + Public Function GetFacturasCanceladasPendientesWS(objventas As ClsVentas, RFC As String, CveEmpresa As Integer, Optional showalert As Boolean = True) As Boolean + Dim retorno As Boolean = False + Try + + Dim objServicio As New Cancelacion2022.CancelacionSoapClient() + Dim resp As Cancelacion2022.StructCancel = objServicio.ObtienePendientes(RFC, "UserTest", "1234567890") + If resp.Estado = 0 Then + Dim XmlPendientes As String = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(resp.Xml)) + Dim theReader As IO.StringReader = New IO.StringReader(XmlPendientes) + Dim theDataSet As DataSet = New DataSet() + theDataSet.ReadXml(theReader) + + If theDataSet.Tables(0).Rows(0)("Uuid").ToString() <> "null" Then + Dim sb As New StringBuilder() + + For Each item As DataRow In theDataSet.Tables(0).Rows + sb.AppendFormat("{0};", item("Uuid").ToString()) + Next + If objventas.GetFacturasCanceladasPendientes(sb.ToString(), CveEmpresa) Then + retorno = True + End If + gvCancelaPendiente.DataSource = objventas.DtResultados + Else + If showalert Then + Alert("No se encontraron cancelaciones pendientes", ModExtensiones.TipoMensaje.MsgError) + End If + End If + Else + Alert("Los servicios del SAT presentan intermitencia y no se puede obtener la información de cancelaciones pendientes: " & resp.Descripcion, ModExtensiones.TipoMensaje.MsgError) + End If + Catch ex As Exception + retorno = False + Me.OnError("Los servicios del SAT presentan intermitencia y no se puede obtener la información: ", ex, "") + End Try + gvCancelaPendiente.DataBind() + Return retorno + End Function + + Private Sub cargaUnuaUno() + GVPA_OI_UnoAUnoTableroGet.DataSource = New System.Data.DataTable() + + Using ObjPA_O As ClsOIEventos = New ClsOIEventos() + If ObjPA_O.UnoAUnoTableroGet(UsuarioActual.CveEmpresa, NowADS().ToString("yyyy/MM/dd"), UsuarioActual.CveUsuario) Then + + If ObjPA_O.DtResultados.COUNT("CveUnoaUno", "CveUnoaUno = -1") > 0 Then + RegistraScript("$('#DvUnoaUno').modal();") + End If + End If + GVPA_OI_UnoAUnoTableroGet.DataSource = ObjPA_O.DtResultados + End Using + + GVPA_OI_UnoAUnoTableroGet.DataBind() + End Sub Private Sub CargaCalendarioGraficas() If (UsuarioActual.CveRol = 1062) Or (UsuarioActual.CveUsuario = 100) Then CargaGraficas() @@ -257,7 +291,7 @@ Partial Class Inicio If UsuarioActual.Empresa.Funcionalidad(560) = "1" Then Dim ObjProveedor As New ClsCompProveedores If ObjProveedor.GetEvaluacionesProveedores(-1, -1, UsuarioActual.CveEmpresa) Then - If ObjProveedor.DtResultados.COUNT("CveEvaluacionProveedor", $"Evaluado = 0 AND CveUsuario={UsuarioActual.CveUsuario}") > 0 Then + If ObjProveedor.DtResultados.COUNT("CveEvaluacionProveedor", $"Evaluado = 0 And CveUsuario={UsuarioActual.CveUsuario}") > 0 Then Dim Mensaje As String = "Hay evaluaciones pendientes de proveedores. ¿Desea realizarlas ahora?" Dim MsgAccionAceptar As String = "window.open(""/Compras/EvaluacionProveedor.aspx?CveProveedor=-1"");" @@ -1436,7 +1470,6 @@ Partial Class Inicio RegistraScript("$('#DvUnoaUno').modal('hide')") End Sub - #Region "DOCUMENTACION" Private Sub CargaDocumentacion() @@ -1493,19 +1526,12 @@ Partial Class Inicio #End Region - - - Protected Sub LnkInconsistencias_Click1(sender As Object, e As EventArgs) MuestraInconsistencias() End Sub - - - Private Sub IniializaDdlsOpcionesAgenda() 'CLIENTES - DdlClientesWS.setEsWebService(True) 'PROVEEDORES @@ -1522,14 +1548,8 @@ Partial Class Inicio DdlPersonal.DataBind() DdlPersonal.Items.Insert(0, New ListItem("Seleccione Uno", "-1")) - CargaDdlEmpresaCRM() - - RBLAgendaOpcion_SelectedIndexChanged(Nothing, Nothing) - - - End Sub Private Sub CargaDdlEmpresaCRM() @@ -1613,26 +1633,18 @@ Partial Class Inicio #Region "S M S - I N D I C A D O R E S" - Private Sub CargaKPICirugias() + Private Sub CargaKPICirugias(Opcion As Integer, Optional CveVendedor As Integer = -1, Optional CveUsuarioTecnico As Integer = -1, Optional CveGerenteVendedor As Integer = -1) DivIndicadores.InnerHtml = "" - Dim Opcion As Integer = 1 Dim dtIndicadores As DataTable = Nothing Dim dtRH As DataTable = Nothing Dim Gral As New ClsVentas Dim ds As DataSet = Nothing - - If UsuarioActual.CveRol = 1577 Then - Opcion = 1 'vendedor - ElseIf UsuarioActual.CveRol.Contiene(1639, 1573) Then ' rol admin. 1573 - Opcion = 2 'gerente ventas - End If - Dim FechaI As Date = Now.FirstDayOfMonth Dim FechaF As Date = Now.LastDayOfMonth - If Gral.GetSMSIndicadores(Opcion, FechaI, FechaF, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + If Gral.GetSMSIndicadores(Opcion, FechaI, FechaF, UsuarioActual.CveUsuario, CveVendedor, CveGerenteVendedor, CveUsuarioTecnico, UsuarioActual.CveEmpresa) Then ds = Gral.DataSetResultados End If '0-ventas totales, 1-comisiones totales, 2-medicos sin consumo, 3-top10medicos, 4-top5marcas, 5-num pacientes @@ -1640,64 +1652,70 @@ Partial Class Inicio Dim StrTexto As New StringBuilder Dim StrSource As New StringBuilder Dim ComisionVendedor, ComisionTecnico, VentasTotales As Decimal - Dim TextoKPIVendedores As String + Dim NumPacientes As Integer = 0 + Dim TextoKPIVendedores As String = "" Dim dtt As DataTable - If Opcion = 1 Then + If ds IsNot Nothing AndAlso ds.Tables.Count > 0 Then + If Opcion = 1 Then #Region "VENDEDORES" - dtt = ds.Tables(0) - If dtt IsNot Nothing Then - VentasTotales = dtt.FiltroPrimeroValor("Importe").ToDecimal - End If - dtt = ds.Tables(1) - If dtt IsNot Nothing Then - ComisionVendedor = dtt.FiltroPrimeroValor("ComisionVendedor").ToDecimal - ComisionTecnico = dtt.FiltroPrimeroValor("ComisionTecnico").ToDecimal - End If + dtt = ds.Tables(0) + If dtt IsNot Nothing Then + VentasTotales = dtt.FiltroPrimeroValor("Importe").ToDecimal + End If + dtt = ds.Tables(1) + If dtt IsNot Nothing Then + ComisionVendedor = dtt.FiltroPrimeroValor("ComisionVendedor").ToDecimal + ComisionTecnico = dtt.FiltroPrimeroValor("ComisionTecnico").ToDecimal + End If - dtt = ds.Tables(2) - 'médicos sin consumo - If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then + dtt = ds.Tables(2) + 'médicos sin consumo + If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then - For Each dr As DataRow In dtt.Rows - StrTexto.AppendFormat("['{0}'],", dr("NombreMedico")) - Next - StrTexto.Length -= 1 - StrSource.Append("{id:'dtmedsinconsumo',type:'JSON',options:{firstRowAsNames:false,columnNames:['Medico'],data:[") - StrSource.Append(StrTexto.ToString) - StrSource.Append("]}}") + For Each dr As DataRow In dtt.Rows + StrTexto.AppendFormat("['{0}'],", dr("NombreMedico")) + Next + StrTexto.Length -= 1 + StrSource.Append("{id:'dtmedsinconsumo',type:'JSON',options:{firstRowAsNames:false,columnNames:['Medico'],data:[") + StrSource.Append(StrTexto.ToString) + StrSource.Append("]}}") - End If - 'top 10 medicos - dtt = ds.Tables(3) - StrTexto.Clear() - If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then - For Each dr As DataRow In dtt.FiltraParametros("Importe > 0").Rows - StrTexto.AppendFormat("['{0}',{1}],", dr("Medico"), dr("Importe")) - Next - StrTexto.Length -= 1 - StrSource.Append(",{id:'dtmedtop10',type:'JSON',options:{firstRowAsNames:false,columnNames:['Medico','Importe'],data:[") - StrSource.Append(StrTexto.ToString) - StrSource.Append("]}}") - End If - 'top 5 marcas - dtt = ds.Tables(4) - StrTexto.Clear() - 'top 5 marcas - If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then - For Each dr As DataRow In dtt.FiltraParametros("Importe > 0").Rows - StrTexto.AppendFormat("['{0}',{1}],", dr("Marca"), dr("Importe")) - Next - StrTexto.Length -= 1 - StrSource.Append(",{id:'dttop5marcas',type:'JSON',options:{firstRowAsNames:false,columnNames:['Marca','Importe'],data:[") - StrSource.Append(StrTexto.ToString) - StrSource.Append("]}}") - End If - 'Dim TextoKPIVendedores As String = "Highcharts.setOptions({chart:{styledMode:true}});Dashboards.board('divsmsdash',{dataPool:{connectors:[{id:'micro-element',type:'JSON',options:{firstRowAsNames:false,columnNames:['Food','Vitamin A','Iron'],data:[['Beef Liver',6421,6.5],['Lamb Liver',2122,6.5],['Cod Liver Oil',1350,0.9],['Mackerel',388,1],['Tuna',214,0.6]]}}]},editMode:{enabled:true,contextMenu:{enabled:true}},components:[{type:'KPI',renderTo:'kpi-vitamin-a',value:900,valueFormat:'{value}',title:'Vitamin A',subtitle:'daily recommended dose'},{type:'KPI',renderTo:'kpi-iron',value:8,title:'Iron',valueFormat:'{value}',subtitle:'daily recommended dose'},{sync:{visibility:true,highlight:true,extremes:true},connector:{id:'micro-element',columnAssignment:[{seriesId:'Vitamin A',data:['Food','Vitamin A']}]},renderTo:'dashboard-col-0',type:'Highcharts',chartOptions:{xAxis:{type:'category',accessibility:{description:'Groceries'}},yAxis:{title:{text:'mcg'},plotLines:[{value:900,zIndex:7,dashStyle:'shortDash',label:{text:'RDA',align:'right',style:{color:'#B73C28'}}}]},credits:{enabled:false},plotOptions:{series:{marker:{radius:6}}},legend:{enabled:true,verticalAlign:'top'},chart:{animation:false,type:'column',spacing:[30,30,30,20]},title:{text:''},tooltip:{valueSuffix:' mcg',stickOnContact:true},lang:{accessibility:{chartContainerLabel:'Vitamin A in food. Highcharts Interactive Chart.'}},accessibility:{description:'The chart is displaying the Vitamin A amount in micrograms for some groceries. There is a plotLine demonstrating the daily Recommended Dietary Allowance (RDA) of 900 micrograms.',point:{valueSuffix:' mcg'}}}},{renderTo:'dashboard-col-1',sync:{visibility:true,highlight:true,extremes:true},connector:{id:'micro-element',columnAssignment:[{seriesId:'Iron',data:['Food','Iron']}]},type:'Highcharts',chartOptions:{xAxis:{type:'category',accessibility:{description:'Groceries'}},yAxis:{title:{text:'mcg'},max:8,plotLines:[{value:8,dashStyle:'shortDash',label:{text:'RDA',align:'right',style:{color:'#B73C28'}}}]},credits:{enabled:false},plotOptions:{series:{marker:{radius:6}}},title:{text:''},legend:{enabled:true,verticalAlign:'top'},chart:{animation:false,type:'column',spacing:[30,30,30,20]},tooltip:{valueSuffix:' mcg',stickOnContact:true},lang:{accessibility:{chartContainerLabel:'Iron in food. Highcharts Interactive Chart.'}},accessibility:{description:'The chart is displaying the Iron amount in micrograms for some groceries. There is a plotLine demonstrating the daily Recommended Dietary Allowance (RDA) of 8 micrograms.',point:{valueSuffix:' mcg'}}}},{renderTo:'dashboard-col-2',connector:{id:'micro-element'},type:'DataGrid',sync:{highlight:true,visibility:true},dataGridOptions:{credits:{enabled:false}}}]},true); - - TextoKPIVendedores = "Highcharts.setOptions({lang: { decimalPoint: '.', thousandsSep: ','},chart:{styledMode:true}});Dashboards.board('divsmsdash',{dataPool:{connectors:[" & StrSource.ToString & "]},editMode: { + End If + 'top 10 medicos + dtt = ds.Tables(3) + StrTexto.Clear() + If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then + For Each dr As DataRow In dtt.FiltraParametros("Importe > 0").Rows + StrTexto.AppendFormat("['{0}',{1}],", dr("Medico"), dr("Importe")) + Next + StrTexto.Length -= 1 + StrSource.Append(",{id:'dtmedtop10',type:'JSON',options:{firstRowAsNames:false,columnNames:['Medico','Importe'],data:[") + StrSource.Append(StrTexto.ToString) + StrSource.Append("]}}") + End If + 'top 5 marcas + dtt = ds.Tables(4) + StrTexto.Clear() + 'top 5 marcas + If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then + For Each dr As DataRow In dtt.FiltraParametros("Importe > 0").Rows + StrTexto.AppendFormat("['{0}',{1}],", dr("Marca"), dr("Importe")) + Next + StrTexto.Length -= 1 + StrSource.Append(",{id:'dttop5marcas',type:'JSON',options:{firstRowAsNames:false,columnNames:['Marca','Importe'],data:[") + StrSource.Append(StrTexto.ToString) + StrSource.Append("]}}") + End If + 'Dim TextoKPIVendedores As String = "Highcharts.setOptions({chart:{styledMode:true}});Dashboards.board('divsmsdash',{dataPool:{connectors:[{id:'micro-element',type:'JSON',options:{firstRowAsNames:false,columnNames:['Food','Vitamin A','Iron'],data:[['Beef Liver',6421,6.5],['Lamb Liver',2122,6.5],['Cod Liver Oil',1350,0.9],['Mackerel',388,1],['Tuna',214,0.6]]}}]},editMode:{enabled:true,contextMenu:{enabled:true}},components:[{type:'KPI',renderTo:'kpi-vitamin-a',value:900,valueFormat:'{value}',title:'Vitamin A',subtitle:'daily recommended dose'},{type:'KPI',renderTo:'kpi-iron',value:8,title:'Iron',valueFormat:'{value}',subtitle:'daily recommended dose'},{sync:{visibility:true,highlight:true,extremes:true},connector:{id:'micro-element',columnAssignment:[{seriesId:'Vitamin A',data:['Food','Vitamin A']}]},renderTo:'dashboard-col-0',type:'Highcharts',chartOptions:{xAxis:{type:'category',accessibility:{description:'Groceries'}},yAxis:{title:{text:'mcg'},plotLines:[{value:900,zIndex:7,dashStyle:'shortDash',label:{text:'RDA',align:'right',style:{color:'#B73C28'}}}]},credits:{enabled:false},plotOptions:{series:{marker:{radius:6}}},legend:{enabled:true,verticalAlign:'top'},chart:{animation:false,type:'column',spacing:[30,30,30,20]},title:{text:''},tooltip:{valueSuffix:' mcg',stickOnContact:true},lang:{accessibility:{chartContainerLabel:'Vitamin A in food. Highcharts Interactive Chart.'}},accessibility:{description:'The chart is displaying the Vitamin A amount in micrograms for some groceries. There is a plotLine demonstrating the daily Recommended Dietary Allowance (RDA) of 900 micrograms.',point:{valueSuffix:' mcg'}}}},{renderTo:'dashboard-col-1',sync:{visibility:true,highlight:true,extremes:true},connector:{id:'micro-element',columnAssignment:[{seriesId:'Iron',data:['Food','Iron']}]},type:'Highcharts',chartOptions:{xAxis:{type:'category',accessibility:{description:'Groceries'}},yAxis:{title:{text:'mcg'},max:8,plotLines:[{value:8,dashStyle:'shortDash',label:{text:'RDA',align:'right',style:{color:'#B73C28'}}}]},credits:{enabled:false},plotOptions:{series:{marker:{radius:6}}},title:{text:''},legend:{enabled:true,verticalAlign:'top'},chart:{animation:false,type:'column',spacing:[30,30,30,20]},tooltip:{valueSuffix:' mcg',stickOnContact:true},lang:{accessibility:{chartContainerLabel:'Iron in food. Highcharts Interactive Chart.'}},accessibility:{description:'The chart is displaying the Iron amount in micrograms for some groceries. There is a plotLine demonstrating the daily Recommended Dietary Allowance (RDA) of 8 micrograms.',point:{valueSuffix:' mcg'}}}},{renderTo:'dashboard-col-2',connector:{id:'micro-element'},type:'DataGrid',sync:{highlight:true,visibility:true},dataGridOptions:{credits:{enabled:false}}}]},true); + dtt = ds.Tables(5) + StrTexto.Clear() + If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then + NumPacientes = dtt.FiltroPrimeroValor("NumeroPacientes").ToEntero + End If + TextoKPIVendedores = "Highcharts.setOptions({lang: { decimalPoint: '.', thousandsSep: ','},chart:{styledMode:true}});Dashboards.board('divsmsdash',{dataPool:{connectors:[" & StrSource.ToString & "]},editMode: { enabled: false, contextMenu: { enabled: true } }, @@ -1757,8 +1775,8 @@ Partial Class Inicio },{ type: 'KPI', renderTo: 'kpi-iron3', - value: 18, - title: 'Personas', + value: " & NumPacientes & ", + title: 'Pacientes', valueFormat: '{value}', subtitle: '-' },{ @@ -1844,96 +1862,100 @@ Partial Class Inicio }, dataGridOptions: { caption: { - text: 'Médicos sin consumo en +30d', - rowHeight: 20, // ⬅️ Altura de cada fila en píxeles - style: { - fontSize: '8px', - fontWeight: 'bold' - } + text: 'Médicos sin consumo en +30d' },style: { maxHeight: '350px', - overflowY: 'auto' + overflowY: 'auto', + fontSize: '7pt', + fontWeight: 'normal' }, credits: { enabled: false } + , cellStyle: { + fontWeight: 'normal', + fontSize: '8px' + } } }] }, true); " #End Region - - Else + ElseIf Opcion = 2 Then #Region "GERENTE" - dtt = ds.Tables(0) - If dtt IsNot Nothing Then - VentasTotales = dtt.FiltroPrimeroValor("Importe").ToDecimal - End If - dtt = ds.Tables(1) - StrTexto.Clear() - 'ventas por mes - If dtt IsNot Nothing Then - For Each dr As DataRow In dtt.FiltraParametros("AnioAnterior > 0 or AnioActual > 0", "MesNum").Rows - StrTexto.AppendFormat("['{0}',{1}, {2}],", dr("Mes"), dr("AnioAnterior"), dr("AnioActual")) - Next - StrTexto.Length -= 1 - StrSource.Append("{id:'dtmesxmes',type:'JSON',options:{firstRowAsNames:false,columnNames:['Mes','Anterior','Actual'],data:[") - StrSource.Append(StrTexto.ToString) - StrSource.Append("]}}") - End If + dtt = ds.Tables(0) + If dtt IsNot Nothing Then + VentasTotales = dtt.FiltroPrimeroValor("Importe").ToDecimal + End If + dtt = ds.Tables(1) + StrTexto.Clear() + 'ventas por mes + If dtt IsNot Nothing Then + For Each dr As DataRow In dtt.FiltraParametros("AnioAnterior > 0 or AnioActual > 0", "MesNum").Rows + StrTexto.AppendFormat("['{0}',{1}, {2}],", dr("Mes"), dr("AnioAnterior"), dr("AnioActual")) + Next + StrTexto.Length -= 1 + StrSource.Append("{id:'dtmesxmes',type:'JSON',options:{firstRowAsNames:false,columnNames:['Mes','Anterior','Actual'],data:[") + StrSource.Append(StrTexto.ToString) + StrSource.Append("]}}") + End If - dtt = ds.Tables(2) - StrTexto.Clear() - 'médicos sin consumo - If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then + dtt = ds.Tables(2) + StrTexto.Clear() + 'médicos sin consumo + If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then - For Each dr As DataRow In dtt.Rows - StrTexto.AppendFormat("['{0}','{1}'],", dr("NombreMedico"), dr("Vendedor")) - Next - StrTexto.Length -= 1 - StrSource.Append(",{id:'dtmedsinconsumo',type:'JSON',options:{firstRowAsNames:false,columnNames:['Medico','Vendedor'],data:[") - StrSource.Append(StrTexto.ToString) - StrSource.Append("]}}") - End If - 'vendedores - dtt = ds.Tables(3) - StrTexto.Clear() - If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then - For Each dr As DataRow In dtt.FiltraParametros("Importe > 0").Rows - StrTexto.AppendFormat("['{0}',{1}],", dr("Vendedor"), dr("Importe")) - Next - StrTexto.Length -= 1 - StrSource.Append(",{id:'dtvendedores',type:'JSON',options:{firstRowAsNames:false,columnNames:['Vendedor','Importe'],data:[") - StrSource.Append(StrTexto.ToString) - StrSource.Append("]}}") - End If - 'top 10 medicos - dtt = ds.Tables(4) - StrTexto.Clear() - If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then - For Each dr As DataRow In dtt.FiltraParametros("Importe > 0").Rows - StrTexto.AppendFormat("['{0}',{1}],", dr("Medico"), dr("Importe")) - Next - StrTexto.Length -= 1 - StrSource.Append(",{id:'dtmedtop10',type:'JSON',options:{firstRowAsNames:false,columnNames:['Medico','Importe'],data:[") - StrSource.Append(StrTexto.ToString) - StrSource.Append("]}}") - End If - 'top 5 marcas - dtt = ds.Tables(5) - StrTexto.Clear() - 'top 5 marcas - If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then - For Each dr As DataRow In dtt.FiltraParametros("Importe > 0").Rows - StrTexto.AppendFormat("['{0}',{1}],", dr("Marca"), dr("Importe")) - Next - StrTexto.Length -= 1 - StrSource.Append(",{id:'dttop5marcas',type:'JSON',options:{firstRowAsNames:false,columnNames:['Marca','Importe'],data:[") - StrSource.Append(StrTexto.ToString) - StrSource.Append("]}}") + For Each dr As DataRow In dtt.Rows + StrTexto.AppendFormat("['{0}','{1}'],", dr("NombreMedico"), dr("Vendedor")) + Next + StrTexto.Length -= 1 + StrSource.Append(",{id:'dtmedsinconsumo',type:'JSON',options:{firstRowAsNames:false,columnNames:['Medico','Vendedor'],data:[") + StrSource.Append(StrTexto.ToString) + StrSource.Append("]}}") + End If + 'vendedores + dtt = ds.Tables(3) + StrTexto.Clear() + If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then + For Each dr As DataRow In dtt.FiltraParametros("Importe > 0").Rows + StrTexto.AppendFormat("['{0}',{1},'/a/a.aspx?CveI=1'],", If(dr("Vendedor").ToString.Length > 10, dr("Vendedor").ToString.Substring(0, 10), dr("Vendedor")), dr("Importe")) + Next + StrTexto.Length -= 1 + StrSource.Append(",{id:'dtvendedores',type:'JSON',options:{firstRowAsNames:false,columnNames:['Vendedor','Importe','Url'],data:[") + StrSource.Append(StrTexto.ToString) + StrSource.Append("]}}") + End If + 'top 10 medicos + dtt = ds.Tables(4) + StrTexto.Clear() + If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then + For Each dr As DataRow In dtt.FiltraParametros("Importe > 0").Rows + StrTexto.AppendFormat("['{0}',{1}],", dr("Medico"), dr("Importe")) + Next + StrTexto.Length -= 1 + StrSource.Append(",{id:'dtmedtop10',type:'JSON',options:{firstRowAsNames:false,columnNames:['Medico','Importe'],data:[") + StrSource.Append(StrTexto.ToString) + StrSource.Append("]}}") + End If + 'top 5 marcas + dtt = ds.Tables(5) + StrTexto.Clear() + If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then + For Each dr As DataRow In dtt.FiltraParametros("Importe > 0").Rows + StrTexto.AppendFormat("['{0}',{1},'https://www.google.com'],", dr("Marca"), dr("Importe")) + Next + StrTexto.Length -= 1 + StrSource.Append(",{id:'dttop5marcas',type:'JSON',options:{firstRowAsNames:false,columnNames:['Marca','Importe','Url'],data:[") + StrSource.Append(StrTexto.ToString) + StrSource.Append("]}}") - End If - 'Dim TextoKPIVendedores As String = "Highcharts.setOptions({chart:{styledMode:true}});Dashboards.board('divsmsdash',{dataPool:{connectors:[{id:'micro-element',type:'JSON',options:{firstRowAsNames:false,columnNames:['Food','Vitamin A','Iron'],data:[['Beef Liver',6421,6.5],['Lamb Liver',2122,6.5],['Cod Liver Oil',1350,0.9],['Mackerel',388,1],['Tuna',214,0.6]]}}]},editMode:{enabled:true,contextMenu:{enabled:true}},components:[{type:'KPI',renderTo:'kpi-vitamin-a',value:900,valueFormat:'{value}',title:'Vitamin A',subtitle:'daily recommended dose'},{type:'KPI',renderTo:'kpi-iron',value:8,title:'Iron',valueFormat:'{value}',subtitle:'daily recommended dose'},{sync:{visibility:true,highlight:true,extremes:true},connector:{id:'micro-element',columnAssignment:[{seriesId:'Vitamin A',data:['Food','Vitamin A']}]},renderTo:'dashboard-col-0',type:'Highcharts',chartOptions:{xAxis:{type:'category',accessibility:{description:'Groceries'}},yAxis:{title:{text:'mcg'},plotLines:[{value:900,zIndex:7,dashStyle:'shortDash',label:{text:'RDA',align:'right',style:{color:'#B73C28'}}}]},credits:{enabled:false},plotOptions:{series:{marker:{radius:6}}},legend:{enabled:true,verticalAlign:'top'},chart:{animation:false,type:'column',spacing:[30,30,30,20]},title:{text:''},tooltip:{valueSuffix:' mcg',stickOnContact:true},lang:{accessibility:{chartContainerLabel:'Vitamin A in food. Highcharts Interactive Chart.'}},accessibility:{description:'The chart is displaying the Vitamin A amount in micrograms for some groceries. There is a plotLine demonstrating the daily Recommended Dietary Allowance (RDA) of 900 micrograms.',point:{valueSuffix:' mcg'}}}},{renderTo:'dashboard-col-1',sync:{visibility:true,highlight:true,extremes:true},connector:{id:'micro-element',columnAssignment:[{seriesId:'Iron',data:['Food','Iron']}]},type:'Highcharts',chartOptions:{xAxis:{type:'category',accessibility:{description:'Groceries'}},yAxis:{title:{text:'mcg'},max:8,plotLines:[{value:8,dashStyle:'shortDash',label:{text:'RDA',align:'right',style:{color:'#B73C28'}}}]},credits:{enabled:false},plotOptions:{series:{marker:{radius:6}}},title:{text:''},legend:{enabled:true,verticalAlign:'top'},chart:{animation:false,type:'column',spacing:[30,30,30,20]},tooltip:{valueSuffix:' mcg',stickOnContact:true},lang:{accessibility:{chartContainerLabel:'Iron in food. Highcharts Interactive Chart.'}},accessibility:{description:'The chart is displaying the Iron amount in micrograms for some groceries. There is a plotLine demonstrating the daily Recommended Dietary Allowance (RDA) of 8 micrograms.',point:{valueSuffix:' mcg'}}}},{renderTo:'dashboard-col-2',connector:{id:'micro-element'},type:'DataGrid',sync:{highlight:true,visibility:true},dataGridOptions:{credits:{enabled:false}}}]},true); + End If + dtt = ds.Tables(6) + StrTexto.Clear() + If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then + NumPacientes = dtt.FiltroPrimeroValor("NumeroPacientes").ToEntero + End If + 'Dim TextoKPIVendedores As String = "Highcharts.setOptions({chart:{styledMode:true}});Dashboards.board('divsmsdash',{dataPool:{connectors:[{id:'micro-element',type:'JSON',options:{firstRowAsNames:false,columnNames:['Food','Vitamin A','Iron'],data:[['Beef Liver',6421,6.5],['Lamb Liver',2122,6.5],['Cod Liver Oil',1350,0.9],['Mackerel',388,1],['Tuna',214,0.6]]}}]},editMode:{enabled:true,contextMenu:{enabled:true}},components:[{type:'KPI',renderTo:'kpi-vitamin-a',value:900,valueFormat:'{value}',title:'Vitamin A',subtitle:'daily recommended dose'},{type:'KPI',renderTo:'kpi-iron',value:8,title:'Iron',valueFormat:'{value}',subtitle:'daily recommended dose'},{sync:{visibility:true,highlight:true,extremes:true},connector:{id:'micro-element',columnAssignment:[{seriesId:'Vitamin A',data:['Food','Vitamin A']}]},renderTo:'dashboard-col-0',type:'Highcharts',chartOptions:{xAxis:{type:'category',accessibility:{description:'Groceries'}},yAxis:{title:{text:'mcg'},plotLines:[{value:900,zIndex:7,dashStyle:'shortDash',label:{text:'RDA',align:'right',style:{color:'#B73C28'}}}]},credits:{enabled:false},plotOptions:{series:{marker:{radius:6}}},legend:{enabled:true,verticalAlign:'top'},chart:{animation:false,type:'column',spacing:[30,30,30,20]},title:{text:''},tooltip:{valueSuffix:' mcg',stickOnContact:true},lang:{accessibility:{chartContainerLabel:'Vitamin A in food. Highcharts Interactive Chart.'}},accessibility:{description:'The chart is displaying the Vitamin A amount in micrograms for some groceries. There is a plotLine demonstrating the daily Recommended Dietary Allowance (RDA) of 900 micrograms.',point:{valueSuffix:' mcg'}}}},{renderTo:'dashboard-col-1',sync:{visibility:true,highlight:true,extremes:true},connector:{id:'micro-element',columnAssignment:[{seriesId:'Iron',data:['Food','Iron']}]},type:'Highcharts',chartOptions:{xAxis:{type:'category',accessibility:{description:'Groceries'}},yAxis:{title:{text:'mcg'},max:8,plotLines:[{value:8,dashStyle:'shortDash',label:{text:'RDA',align:'right',style:{color:'#B73C28'}}}]},credits:{enabled:false},plotOptions:{series:{marker:{radius:6}}},title:{text:''},legend:{enabled:true,verticalAlign:'top'},chart:{animation:false,type:'column',spacing:[30,30,30,20]},tooltip:{valueSuffix:' mcg',stickOnContact:true},lang:{accessibility:{chartContainerLabel:'Iron in food. Highcharts Interactive Chart.'}},accessibility:{description:'The chart is displaying the Iron amount in micrograms for some groceries. There is a plotLine demonstrating the daily Recommended Dietary Allowance (RDA) of 8 micrograms.',point:{valueSuffix:' mcg'}}}},{renderTo:'dashboard-col-2',connector:{id:'micro-element'},type:'DataGrid',sync:{highlight:true,visibility:true},dataGridOptions:{credits:{enabled:false}}}]},true); - TextoKPIVendedores = "Highcharts.setOptions({lang: { decimalPoint: '.', thousandsSep: ','},chart:{styledMode:true}});Dashboards.board('divsmsdash',{dataPool:{connectors:[" & StrSource.ToString & "]},editMode: { + TextoKPIVendedores = "Highcharts.setOptions({lang: { decimalPoint: '.', thousandsSep: ','},chart:{styledMode:true}});Dashboards.board('divsmsdash',{dataPool:{connectors:[" & StrSource.ToString & "]},editMode: { enabled: false, contextMenu: { enabled: true } }, @@ -1979,8 +2001,8 @@ Partial Class Inicio },{ type: 'KPI', renderTo: 'kpi-iron3', - value: 18, - title: 'Personas', + value: " & NumPacientes & ", + title: 'Pacientes', valueFormat: '{value}', subtitle: '-' },{ @@ -2021,40 +2043,54 @@ Partial Class Inicio lang: { accessibility: { chartContainerLabel: '' } } } }, { - renderTo: 'dashboard-col-1', - sync: { - visibility: true, - highlight: true, - extremes: true - }, - connector: { - id: 'dttop5marcas', - columnAssignment: [{ - seriesId: 'Top 5 Marcas', - data: ['Marca', 'Importe'] - }] - }, - type: 'Highcharts', - chartOptions: { - xAxis: { - type: 'category', - accessibility: { description: 'Groceries' } + renderTo: 'dashboard-col-1', + connector: { + id: 'dttop5marcas', + columnAssignment: [{ + seriesId: 'Top 5 Marcas', + data: ['Marca', 'Importe','Url'] + }] }, - yAxis: { title: { text: '' } }, - credits: { enabled: false }, - title: { text: '' }, - legend: { enabled: true, verticalAlign: 'top' }, - chart: { - animation: false, type: 'bar', - spacing: [30, 30, 30, 20] - }, - tooltip: { valueSuffix: ' ', stickOnContact: true }, - lang: { accessibility: { - chartContainerLabel: 'Iron in food. Highcharts ' + 'Interactive Chart.' + type: 'Highcharts', + chartOptions: { + chart: { + type: 'bar', + animation: false, + spacing: [30, 30, 30, 20] + }, + title: { text: '' }, + credits: { enabled: false }, + legend: { enabled: true, verticalAlign: 'top' }, + xAxis: { + type: 'category', + accessibility: { description: 'Groceries' } + }, + yAxis: { title: { text: '' } }, + tooltip: { + valueSuffix: ' ', + stickOnContact: true + }, + plotOptions: { + series: { + cursor: 'pointer', + point: { + events: { + click: function () { + const url = this.options?.Url; + + console.log('URL del punto:', url); + if (url) { + window.open(url, '_blank'); + } else { + alert('No se encontró la URL del punto.'); + } + } + } + } + } } } - } - }, { + }, { renderTo: 'dashboard-col-3', sync: { visibility: true, @@ -2065,24 +2101,67 @@ Partial Class Inicio id: 'dtvendedores', columnAssignment: [{ seriesId: 'Vendedores', - data: ['Vendedor', 'Importe'] + data: ['Vendedor', 'Importe','Url'] }] }, type: 'Highcharts', chartOptions: { xAxis: { type: 'category', - accessibility: { description: 'Groceries' } + accessibility: { description: '' } }, yAxis: { title: { text: '' } }, credits: { enabled: false }, - title: { text: '' }, + plotOptions: { + pie: { + allowPointSelect: true, + cursor: 'pointer', + dataLabels: [{ + enabled: true, + distance: 20 + }, { + enabled: true, + distance: -40, + format: '{point.percentage:.1f}%', + style: { + fontSize: '1.2em', + textOutline: 'none', + opacity: 0.7 + }, + filter: { + operator: '>', + property: 'percentage', + value: 10 + } + }] + } + }, + title: { text: 'Vendedores' }, legend: { enabled: true, verticalAlign: 'top' }, chart: { - animation: false, type: 'bar', - spacing: [30, 30, 30, 20] + animation: false, type: 'pie' }, - tooltip: { valueSuffix: ' ', stickOnContact: true }, + tooltip: { + pointFormat: '{series.name}: {point.percentage:.1f}%
    Valor: {point.y}' + }, + plotOptions: { + pie: { + allowPointSelect: true, + cursor: 'pointer', + dataLabels: { + enabled: true, + format: '{point.name}: {point.percentage:.1f} %' + }, + point: { + events: { + click: function () { + const url = this.options?.Url; + if (url) window.open(url, '_blank'); + } + } + } + } + }, lang: { accessibility: { chartContainerLabel: 'Iron in food. Highcharts ' + 'Interactive Chart.' } @@ -2140,25 +2219,311 @@ Partial Class Inicio highlight: true, visibility: true }, - dataGridOptions: { + dataGridOptions: { caption: { - text: 'Médicos sin consumo en +30d', - rowHeight: 20, // Altura de cada fila en píxeles - style: { - fontSize: '8pt', - fontWeight: 'bold' - } + text: 'Médicos sin consumo en +30d' },style: { maxHeight: '350px', - overflowY: 'auto' + overflowY: 'auto', + fontSize: '7pt', + fontWeight: 'normal' }, credits: { enabled: false } + , cellStyle: { + fontWeight: 'normal', + fontSize: '8px' + } } }] }, true); " #End Region + + ElseIf Opcion = 3 Then +#Region "ALMACEN" + Dim TotalEntregas, TotalRecoleciones, ProductosConExistencia, Ingresadas, NoUsadas As Integer + Dim EntregasDiarias As Decimal = 0 + dtt = ds.Tables(0) + If dtt IsNot Nothing Then + TotalEntregas = dtt.FiltroPrimeroValor("TotalEntregas").ToEntero + TotalRecoleciones = dtt.FiltroPrimeroValor("TotalRecoleccion").ToEntero + ProductosConExistencia = dtt.FiltroPrimeroValor("ProductosExistencias").ToEntero + Ingresadas = dtt.FiltroPrimeroValor("Ingresadas").ToEntero + NoUsadas = dtt.FiltroPrimeroValor("NoUsadas").ToEntero + EntregasDiarias = dtt.FiltroPrimeroValor("EntregasDiarias").ToDecimal + End If + + TextoKPIVendedores = "Highcharts.setOptions({lang: { decimalPoint: '.', thousandsSep: ','},chart:{styledMode:true}});Dashboards.board('divsmsdash',{dataPool:{connectors:[" & StrSource.ToString & "]},editMode: { + enabled: false, + contextMenu: { enabled: true } + }, + gui: { + layouts: [{ + rows: [{ + cells: [{ + id: 'kpi-wrapper', + layout: { + rows: [{ + cells: [{ + id: 'kpi-iron0' + }, { + id: 'kpi-iron1' + }, { + id: 'kpi-iron2' + }] + },{ + cells: [{ + id: 'kpi-iron3' + }, { + id: 'kpi-iron4' + }, { + id: 'kpi-iron5' + }] + }] + } + }] + }] + }] + }, + components: [{ + type: 'KPI', + renderTo: 'kpi-iron0', + value: " & TotalEntregas & ", + valueFormat: '{value}', + title: 'Total Entrega', + subtitle: '-' + }, { + type: 'KPI', + renderTo: 'kpi-iron1', + value: " & TotalRecoleciones & ", + title: 'Total Recolecciones', + valueFormat: '{value}', + valueStyle: { color: '#198754'}, + subtitle: '' + }, { + type: 'KPI', + renderTo: 'kpi-iron2', + value: " & ProductosConExistencia & ", + title: 'Productos con Existencia', + valueFormat: '{value}', + subtitle: '-' + },{ + type: 'KPI', + renderTo: 'kpi-iron3', + value: " & Ingresadas & ", + title: 'Ingresadas', + valueFormat: '{value}', + subtitle: '-' + },{ + type: 'KPI', + renderTo: 'kpi-iron4', + value: " & NoUsadas & ", + title: 'No usadas', + valueFormat: '{value}', + subtitle: '-' + },{ + type: 'KPI', + renderTo: 'kpi-iron5', + value: " & EntregasDiarias & ", + title: 'Prom Entrega diaria', + valueFormat: '{value:,.2f}', + subtitle: '-' + } ] + }, true); " +#End Region + ElseIf Opcion = 4 Then +#Region "TECNICO" + Dim CirugiasDiaSiguiente, Comision, NumCirugias As Integer + Dim MontoCirugias As Decimal = 0 + dtt = ds.Tables(0) + If dtt IsNot Nothing Then + CirugiasDiaSiguiente = dtt.FiltroPrimeroValor("CirugiasDiaSiguiente").ToEntero + Comision = dtt.FiltroPrimeroValor("Comision").ToEntero + NumCirugias = dtt.FiltroPrimeroValor("NumCirugias").ToEntero + MontoCirugias = dtt.FiltroPrimeroValor("MontoCirugias").ToDecimal + End If + + TextoKPIVendedores = "Highcharts.setOptions({lang: { decimalPoint: '.', thousandsSep: ','},chart:{styledMode:true}});Dashboards.board('divsmsdash',{dataPool:{connectors:[" & StrSource.ToString & "]},editMode: { + enabled: false, + contextMenu: { enabled: true } + }, + gui: { + layouts: [{ + rows: [{ + cells: [{ + id: 'kpi-wrapper', + layout: { + rows: [{ + cells: [{ + id: 'kpi-iron0' + }, { + id: 'kpi-iron1' + }] + },{ + cells: [{ + id: 'kpi-iron2' + },{ + id: 'kpi-iron3' + } ] + }] + } + }] + }] + }] + }, + components: [{ + type: 'KPI', + renderTo: 'kpi-iron0', + value: " & CirugiasDiaSiguiente & ", + valueFormat: '{value}', + title: 'Cirugías Dia Sig', + subtitle: '-' + }, { + type: 'KPI', + renderTo: 'kpi-iron1', + value: " & Comision & ", + title: '$ Comisión', + valueFormat: '{value:,.2f}', + valueStyle: { color: '#198754'}, + subtitle: '' + }, { + type: 'KPI', + renderTo: 'kpi-iron2', + value: " & NumCirugias & ", + title: '# Cirugías', + valueFormat: '{value}', + subtitle: '-' + },{ + type: 'KPI', + renderTo: 'kpi-iron3', + value: " & MontoCirugias & ", + title: '$ Cirugías', + valueFormat: '{value:,.2f}', + subtitle: '-' + } ] + }, true); " +#End Region + ElseIf Opcion = 5 Then +#Region "GERENTE TECNICO" + Dim CirugiasAsistidas As Integer + Dim MontoCirugias, TicketPromedio As Decimal + dtt = ds.Tables(0) + If dtt IsNot Nothing Then + CirugiasAsistidas = dtt.FiltroPrimeroValor("CirugiasAsistidas").ToEntero + TicketPromedio = dtt.FiltroPrimeroValor("TicketPromedio").ToDecimal + End If + 'top cirugias técnicos + dtt = ds.Tables(1) + StrTexto.Clear() + If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then + For Each dr As DataRow In dtt.FiltraParametros("Cantidad > 0").Rows + StrTexto.AppendFormat("['{0}',{1}],", dr("NombreTecnico"), dr("Cantidad")) + Next + StrTexto.Length -= 1 + StrSource.Append("{id:'dttecnicos',type:'JSON',options:{firstRowAsNames:false,columnNames:['NombreTecnico','Cantidad'],data:[") + StrSource.Append(StrTexto.ToString) + StrSource.Append("]}}") + End If + + TextoKPIVendedores = "Highcharts.setOptions({lang: { decimalPoint: '.', thousandsSep: ','},chart:{styledMode:true}});Dashboards.board('divsmsdash',{dataPool:{connectors:[" & StrSource.ToString & "]},editMode: { + enabled: false, + contextMenu: { enabled: true } + }, + gui: { + layouts: [{ + rows: [{ + cells: [{ + id: 'kpi-wrapper', + layout: { + rows: [{ + cells: [{ + id: 'kpi-vitamin-a' + },{ + id: 'kpi-iron3' + }] + }] + } + }] + }, { + cells: [{ + id: 'dashboard-col-3' + }] + }] + }] + }, + components: [{ + type: 'KPI', + renderTo: 'kpi-vitamin-a', + value: " & CirugiasAsistidas & ", + valueFormat: '{value}', + title: 'Cirugías Asistidas', + subtitle: '-' + },{ + type: 'KPI', + renderTo: 'kpi-iron', + value: " & TicketPromedio & ", + title: 'Ticket Promedio', + valueFormat: '{value}', + subtitle: '-' + }, { + renderTo: 'dashboard-col-3', + sync: { + visibility: true, + highlight: true, + extremes: true + }, + connector: { + id: 'dttecnicos', + columnAssignment: [{ + seriesId: 'Técnicos', + data: ['NombreTecnico', 'Cantidad'] + }] + }, + type: 'Highcharts', + chartOptions: { + xAxis: { + type: 'category', + accessibility: { description: '' } + }, + yAxis: { title: { text: '' } }, + credits: { enabled: false }, + + title: { text: 'Técnicos' }, + legend: { enabled: true, verticalAlign: 'top' }, + chart: { + animation: false, type: 'pie' + }, + tooltip: { + pointFormat: '{series.name}: {point.percentage:.1f}%
    Valor: {point.y}' + }, + plotOptions: { + pie: { + allowPointSelect: true, + cursor: 'pointer', + dataLabels: { + enabled: true, + format: '{point.name}: {point.percentage:.1f} %' + }, + point: { + events: { + click: function () { + const url = this.options?.Url; + if (url) window.open(url, '_blank'); + } + } + } + } + }, + lang: { accessibility: { + chartContainerLabel: 'Iron in food. Highcharts ' + 'Interactive Chart.' + } + } + } + }] + }, true); " +#End Region + End If + RegistraScript(TextoKPIVendedores, "top10") End If - RegistraScript(TextoKPIVendedores, "top10") dtIndicadores = Nothing dtRH = Nothing @@ -2166,4 +2531,49 @@ Partial Class Inicio End Sub #End Region + + Private Sub CargaSMSKPI(Optional CveGerente As Integer = -1) + If DdlSMSOpciones.SelectedValue = "1" Then + DdlSMSVendedores.Visible = True + DdlSMSTecnico.Visible = False + Dim CveUsuarioTecnico As Integer = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveUsuario", $"CveVendedor = {DdlSMSVendedores.SelectedValue}").ToEntero + CargaKPICirugias(DdlSMSOpciones.SelectedValue.ToEntero, DdlSMSVendedores.SelectedValue.ToEntero, CveUsuarioTecnico) + + ElseIf DdlSMSOpciones.SelectedValue = "2" Then ' ROL DE GERENTE DE VENTAS + Dim CveGerenteVendedor As Integer = -1 + If UsuarioActual.CveRol = 1639 Then + If UsuarioActual.CveUsuario = 4419 Then CveGerenteVendedor = 1386 ' daniela + If UsuarioActual.CveUsuario = 4137 Then CveGerenteVendedor = 1172 'jesus alvarez + End If + DdlSMSVendedores.Visible = False + CargaKPICirugias(DdlSMSOpciones.SelectedValue.ToEntero, CveGerenteVendedor:=CveGerenteVendedor) + + ElseIf DdlSMSOpciones.SelectedValue = "4" Then + DdlSMSTecnico.DataSource = GlobalDTUsuarios(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("CveRol = 1582") + DdlSMSTecnico.DataBind() + DdlSMSTecnico.Items.Insert(0, New ListItem("Todos", "-1")) + DdlSMSTecnico.Visible = True + DdlSMSVendedores.Visible = False + CargaKPICirugias(DdlSMSOpciones.SelectedValue.ToEntero, -1, DdlSMSTecnico.SelectedValue.ToEntero) + Else + DdlSMSVendedores.Visible = False + DdlSMSTecnico.Visible = False + CargaKPICirugias(DdlSMSOpciones.SelectedValue.ToEntero) + End If + End Sub + + Protected Sub DdlSMSOpciones_SelectedIndexChanged(sender As Object, e As EventArgs) + CargaSMSKPI() + End Sub + + + + Protected Sub DdlSMSVendedores_SelectedIndexChanged(sender As Object, e As EventArgs) + Dim CveUsuarioTecnico As Integer = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveUsuario", $"CveVendedor = {DdlSMSVendedores.SelectedValue}").ToEntero + CargaKPICirugias(DdlSMSOpciones.SelectedValue.ToEntero, DdlSMSVendedores.SelectedValue.ToEntero, CveUsuarioTecnico) + End Sub + + Protected Sub DdlSMSTecnico_SelectedIndexChanged(sender As Object, e As EventArgs) + CargaKPICirugias(DdlSMSOpciones.SelectedValue.ToEntero, -1, DdlSMSTecnico.SelectedValue.ToEntero) + End Sub End Class diff --git a/Inventarios/CatAlmacenes.aspx.vb b/Inventarios/CatAlmacenes.aspx.vb index 7ce506e4f..b6ef7f467 100644 --- a/Inventarios/CatAlmacenes.aspx.vb +++ b/Inventarios/CatAlmacenes.aspx.vb @@ -98,16 +98,18 @@ Partial Class Inventarios_CatAlmacenes Private Sub CargaUsuarios() - Dim DT As DataTable = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa).FiltraParametros(" Estatus = 1 ").Copy + Dim DT As DataTable = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa) - DT.DefaultView.Sort = "Nombre ASC" - DT = DT.DefaultView.ToTable + If DT IsNot Nothing Then + DT = DT.FiltraParametros(" Estatus = 1 ").Copy + DT.DefaultView.Sort = "Nombre ASC" + DT = DT.DefaultView.ToTable - DdlUsuariosAutoriza.DataSource = DT - DdlUsuariosAutoriza.DataBind() - - DdlUsuariosAutoriza.Items.Insert(0, New ListItem("Seleccione uno", "-1")) + DdlUsuariosAutoriza.DataSource = DT + DdlUsuariosAutoriza.DataBind() + DdlUsuariosAutoriza.Items.Insert(0, New ListItem("Seleccione uno", "-1")) + End If End Sub Private Sub CargaCuentasContables() diff --git a/Inventarios/EntradasSalidas.aspx b/Inventarios/EntradasSalidas.aspx index be49d534e..42612ffdd 100644 --- a/Inventarios/EntradasSalidas.aspx +++ b/Inventarios/EntradasSalidas.aspx @@ -432,6 +432,14 @@
    +
    + +
    + +
    +
    diff --git a/Inventarios/EntradasSalidas.aspx.vb b/Inventarios/EntradasSalidas.aspx.vb index f71e68d1d..e8976f18d 100644 --- a/Inventarios/EntradasSalidas.aspx.vb +++ b/Inventarios/EntradasSalidas.aspx.vb @@ -921,6 +921,11 @@ Partial Class Inventarios_EntradasSalidas HplOS.NavigateUrl = $"/OS/OrdenesServicios.aspx?CveOS={DtMov.Rows(0)("CveOS")}" End If + If DtMov.Rows(0)("CveOP").ToString.ToEntero() > 0 Then + divOP.Visible = True + HplOP.Text = "1" 'DtMov.Rows(0)("OSFolio").ToString + HplOP.NavigateUrl = $"/OP/OP.aspx?CveOP={DtMov.Rows(0)("CveOP")}" + End If If (DdlAlmacen.Items.FindByValue(Mov.CveAlmacen.ToString()) Is Nothing) Then Dim dr As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveEstatus:=-1).FiltroPrimero(String.Format("CveAlmacen = {0}", Mov.CveAlmacen)) @@ -2137,7 +2142,7 @@ Partial Class Inventarios_EntradasSalidas CveConceptoContable = 78 EsContabilizable = True Case 28, 31 - CveConceptoContable = 51 + CveConceptoContable = 290 If DdlConcepto.SelectedValue.ToEntero = 28 Then ''cuando es 28, es otros ingresos.78 CveConceptoContable = 78 @@ -2149,7 +2154,7 @@ Partial Class Inventarios_EntradasSalidas If DdlSubProyecto.Visible = True AndAlso DdlSubProyecto.SelectedValue.ToEntero > 0 Then tCveSubProyecto = DdlSubProyecto.SelectedValue.ToEntero Case 34 - CveConceptoContable = 51 + CveConceptoContable = 290 EsContabilizable = True Case 13, 29 CveConceptoContable = 69 @@ -2160,7 +2165,7 @@ Partial Class Inventarios_EntradasSalidas CveClasificacion = drr("CveClasificacion").ToString.ToEntero End If Case 3 - CveConceptoContable = 51 + CveConceptoContable = 290 EsContabilizable = True Case Else CveConceptoContable = 95 @@ -2174,7 +2179,7 @@ Partial Class Inventarios_EntradasSalidas Else 'Dim Total As Decimal = 0 - If CveConceptoContable.Contiene(181, 78, 51, 69) Then + If CveConceptoContable.Contiene(181, 78, 290, 69) Then Dim Dt As DataTable = ObjInventario.DtResultados.FiltraParametros("", "", {"CveClasificacion"}).Copy For Each Dr As DataRow In Dt.Rows @@ -4069,49 +4074,56 @@ Partial Class Inventarios_EntradasSalidas ErrorMovInv = True End If Else - If ObjInventario.Modulo.Contiene("TA/G1", "Recons", "API-PT/C1") Then - Contabilizable = False + If ObjInventario.Modulo.Contiene("API-Traspaso-PT-Pallet") Then + Contabilizable = True If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, DtCostos.SUMD("Total").RoundSQL, DtCostos.SUMD("Total").RoundSQL, 68, Concepto, Concepto, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimientoRelacionado, Contabilizable:=Contabilizable) Then ErrorMovInv = True End If Else - If ObjInventario.Modulo.Contiene("Consig") Then + If ObjInventario.Modulo.Contiene("TA/G1", "Recons", "API-PT/C1", "API-Traspaso-PT-Pallet") Then Contabilizable = False - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, DtCostos.SUMD("Total").RoundSQL, DtCostos.SUMD("Total").RoundSQL, 95, Concepto, Concepto, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimientoRelacionado, Contabilizable:=Contabilizable) Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, DtCostos.SUMD("Total").RoundSQL, DtCostos.SUMD("Total").RoundSQL, 68, Concepto, Concepto, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimientoRelacionado, Contabilizable:=Contabilizable) Then ErrorMovInv = True End If Else - If ObjInventario.Modulo.Contiene("ASA/G1", "Vta/E4", "ARMPAQ1", "RE/GSC3") Then + If ObjInventario.Modulo.Contiene("Consig") Then Contabilizable = False - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, DtCostos.SUMD("Total").RoundSQL, DtCostos.SUMD("Total").RoundSQL, 68, Concepto, Concepto, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimientoRelacionado, Contabilizable:=Contabilizable) Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, DtCostos.SUMD("Total").RoundSQL, DtCostos.SUMD("Total").RoundSQL, 95, Concepto, Concepto, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimientoRelacionado, Contabilizable:=Contabilizable) Then ErrorMovInv = True End If Else - If DdlConcepto.SelectedValue.Contiene("1", "6", "22", "23", "7", "16", "21", "24", "32") Then - 'genero las prepolizas manuales - Dim tCveConcepto As Integer = 95 - Dim CveCuenta As Integer - If UsuarioActual.CveEmpresa = 119 Then CveCuenta = 55519 - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, DtCostos.SUMD("Total"), DtCostos.SUMD("Total"), tCveConcepto, Concepto, Concepto, CveVenta:=CveVenta, CveClasificacion:=-1, CveMovimientoAlmacen:=CveMovimiento, CveSubProyecto:=-1, Contabilizable:=Contabilizable) Then + If ObjInventario.Modulo.Contiene("ASA/G1", "Vta/E4", "ARMPAQ1", "RE/GSC3") Then + Contabilizable = False + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, DtCostos.SUMD("Total").RoundSQL, DtCostos.SUMD("Total").RoundSQL, 68, Concepto, Concepto, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimientoRelacionado, Contabilizable:=Contabilizable) Then ErrorMovInv = True End If Else - - Dim tCveSubProyecto As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen={DdlAlmacen.SelectedValue.ToEntero}").ToEntero - Dim tCveConcepto As Integer = 69 - If ObjInventario.CveConcepto = 37 Then - tCveConcepto = 181 - End If - - For Each RowInv As DataRow In tmpCostos.Rows - ValorInventario = DtCostos.SUM("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").ToString.ToDecimal.RoundSQL - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, ValorInventario, ValorInventario, tCveConcepto, Concepto, Concepto, CveVenta:=CveVenta, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimiento, CveSubProyecto:=tCveSubProyecto, Contabilizable:=Contabilizable) Then + If DdlConcepto.SelectedValue.Contiene("1", "6", "22", "23", "7", "16", "21", "24", "32") Then + 'genero las prepolizas manuales + Dim tCveConcepto As Integer = 95 + Dim CveCuenta As Integer + If UsuarioActual.CveEmpresa = 119 Then CveCuenta = 55519 + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, DtCostos.SUMD("Total"), DtCostos.SUMD("Total"), tCveConcepto, Concepto, Concepto, CveVenta:=CveVenta, CveClasificacion:=-1, CveMovimientoAlmacen:=CveMovimiento, CveSubProyecto:=-1, Contabilizable:=Contabilizable) Then ErrorMovInv = True - Exit For + End If + Else + + Dim tCveSubProyecto As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen={DdlAlmacen.SelectedValue.ToEntero}").ToEntero + Dim tCveConcepto As Integer = 69 + If ObjInventario.CveConcepto = 37 Then + tCveConcepto = 181 End If - Next + For Each RowInv As DataRow In tmpCostos.Rows + ValorInventario = DtCostos.SUM("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").ToString.ToDecimal.RoundSQL + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, ValorInventario, ValorInventario, tCveConcepto, Concepto, Concepto, CveVenta:=CveVenta, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimiento, CveSubProyecto:=tCveSubProyecto, Contabilizable:=Contabilizable) Then + ErrorMovInv = True + Exit For + End If + + Next + End If End If End If End If diff --git a/Inventarios/PaquetesArmadoDesarmado.aspx.vb b/Inventarios/PaquetesArmadoDesarmado.aspx.vb index 30f4d5d8d..ea9f75b27 100644 --- a/Inventarios/PaquetesArmadoDesarmado.aspx.vb +++ b/Inventarios/PaquetesArmadoDesarmado.aspx.vb @@ -200,7 +200,6 @@ Partial Class Inventarios_PaquetesArmadoDesarmado Private Sub InicializaValores() CreaDtSeriesDesarmado() - 'CARGA PS PAQUETES DdlPaqueteArmado.DataSource = GlobalDTPS(UsuarioActual.CveEmpresa).FiltraParametros("CvePSPaquete > 0") DdlPaqueteArmado.DataBind() @@ -278,9 +277,9 @@ Partial Class Inventarios_PaquetesArmadoDesarmado Dim ObjProductosServicios As New ClsProductosServicios DtDatosArmado = New DataTable - Dim drP As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPaqueteArmado.SelectedValue.ToEntero).FiltroPrimero("") + Dim drP As DataRow = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=DdlPaqueteArmado.SelectedValue.ToEntero).FiltroPrimero("") - Dim CveUMTemp As Integer = drP("CveUM").ToString.ToEntero + Dim CveUMTemp As Integer = drP("CveUnidadMedida").ToString.ToEntero If ObjProductosServicios.GetPaqueteDetalle(DdlPaqueteArmado.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, CveUMTemp, TxtCantidadArmado.Text.ToDouble, DdlAlmacenArmado.SelectedValue.ToEntero, TxtFechaArmado.Text.ToDate, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente)) Then DtDatosArmado = ObjProductosServicios.DtResultados.FiltraParametros("CveTipoPS = 2").Copy Else @@ -296,7 +295,6 @@ Partial Class Inventarios_PaquetesArmadoDesarmado CveVendedor = If(RowApartadosArmado.Visible, DdlVendedorArmado.SelectedValue.ToEntero, -1) CveCliente = If(RowClienteArmado.Visible, DdlClienteArmado.SelectedValue.ToEntero, -1) - If DtDatosArmado.Rows.Count > 0 Then For Each Dr As DataRow In DtDatosArmado.Rows Dr("Cantidad") = Dr("Cantidad").ToString.ToDecimal * TxtCantidadArmado.Text.ToDecimal @@ -323,8 +321,6 @@ Partial Class Inventarios_PaquetesArmadoDesarmado End If - - If AplicaSeriePaquete Or AplicaLotePaquete Or AplicaCaducidadPaquete Then DivSeriesPaqueteArmado.Visible = True Dim Dt As New DataTable @@ -403,10 +399,9 @@ Partial Class Inventarios_PaquetesArmadoDesarmado GvSeriesPaqueteDesarmado.DataBind() BtnAgregarSerieDesarmado.Enabled = True + Dim drP As DataRow = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=DdlPaqueteDesarmado.SelectedValue.ToEntero).FiltroPrimero("") - Dim drP As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPaqueteDesarmado.SelectedValue.ToEntero).FiltroPrimero("") - - Dim CveUMTemp As Integer = drP("CveUM").ToString.ToEntero + Dim CveUMTemp As Integer = drP("CveUnidadMedida").ToString.ToEntero CveVendedor = If(RowApartadosDesarmado.Visible, DdlVendedorDesarmado.SelectedValue.ToEntero, -1) CveCliente = If(RowClienteDesarmado.Visible, DdlClienteDesarmado.SelectedValue.ToEntero, -1) Dim FechaFin As String = TxtFechaDesarmado.Text.ToDateTime.ToString("yyyy/MM/dd 23:59") @@ -506,7 +501,6 @@ Partial Class Inventarios_PaquetesArmadoDesarmado Alert("No hay ningun registro para generar el movimiento. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) Exit Sub End If - Guardar(1) End Sub @@ -568,7 +562,6 @@ Partial Class Inventarios_PaquetesArmadoDesarmado Alert("Es necesario ingresas todos las fechas de caducidad de los componentes.", TipoMensaje.MsgAdvertencia) Exit Sub End If - End If Else @@ -580,23 +573,17 @@ Partial Class Inventarios_PaquetesArmadoDesarmado End If If gvr.DataKey("AplicaCaducidad") = "True" Then - If gvr.FCTextBox("TxtCaducidad").Text.ToDate <= MinFecha Then Alert("Es necesario ingresas todos las fechas de caducidad de los componentes.", TipoMensaje.MsgAdvertencia) Exit Sub End If - End If End If - - - Next Case 2 ' DESARMADO For Each gvr As GridViewRow In GvDatosDesarmado.Rows If gvr.DataKey("AplicaSerie") = "True" Then - 'If gvr.DataKey("AplicaSerie") = "True" Then ' 'If gvr.DataKey("Cantidad").ToEntero <> DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", gvr.DataKey("Consec"))).Rows.Count Then ' ' Alert("Es necesario ingresas todas las series de los componentes.", TipoMensaje.MsgAdvertencia) @@ -619,15 +606,11 @@ Partial Class Inventarios_PaquetesArmadoDesarmado End If If gvr.DataKey("AplicaCaducidad") = "True" Then - If gvr.FCTextBox("TxtCaducidad").Text.ToDate <= MinFecha Then Alert("Es necesario ingresas todos las fechas de caducidad de los componentes.", TipoMensaje.MsgAdvertencia) Exit Sub End If - End If - - Next End Select @@ -683,26 +666,20 @@ Partial Class Inventarios_PaquetesArmadoDesarmado For Each GvRow As GridViewRow In GvDatosArmado.Rows - FechaCaducidad = If(CBool(GvRow.DataKey("AplicaCaducidad")) AndAlso GvRow.FCTextBox("TxtCaducidad").ToString().ToDate > MinFecha, GvRow.FCTextBox("TxtCaducidad").Text.ToDate, MinFecha) + FechaCaducidad = If(CBool(GvRow.DataKey("AplicaCaducidad")) AndAlso GvRow.FCTextBox("TxtCaducidad").Text.ToDate > MinFecha, GvRow.FCTextBox("TxtCaducidad").Text.ToDate, MinFecha) Lote = If(CBool(GvRow.DataKey("AplicaLote")), GvRow.FCTextBox("TxtLote").Text.Trim, "-1") - If UsuarioActual.Empresa.Funcionalidad(578).ToEntero = 1 Then - - Dim DdlCaducidadProducto As DropDownList = GvRow.FCDropDownList("DdlCaducidadProducto") - Dim ArrayCaducidad As String() = DdlCaducidadProducto.SelectedValue.Split("|"c) + If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then + Dim ArrayCaducidad As String() = GvRow.FCDropDownList("DdlCaducidadProducto").SelectedValue.Split("|"c) Lote = ArrayCaducidad(0) FechaCaducidad = ArrayCaducidad(1).ToDate - End If Dim Existencia As Decimal = ObjInventarioVal.GetExistenciasPS(GvRow.DataKey("CvePS").ToEntero, GvRow.DataKey("CveUM").ToEntero, UsuarioActual.CveEmpresa, CveAlmacen:=DdlAlmacenArmado.SelectedValue.ToEntero(), FechaMovto:=TxtFechaArmado.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Serie:="-1", Lote:=Lote, FechaCaducidad:=FechaCaducidad) - If GvRow.DataKey("Cantidad").ToDecimal > Existencia Then TieneErrorExistencia = True - TextoError.AppendFormat(" - {0} Existencia: {1:#,##0.##}
    ", GvRow.DataKey("CodigoPS"), Existencia) - End If ''If Dr("CantidadGV").ToString().ToDecimal > 0 Then @@ -758,16 +735,10 @@ Partial Class Inventarios_PaquetesArmadoDesarmado RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") Exit Sub End If - End If - - - - Dim ObjInventario As New ClsInventarios Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) - Dim TieneError As Boolean = False Dim MensajeError As String = "" @@ -801,13 +772,10 @@ Partial Class Inventarios_PaquetesArmadoDesarmado Dim Lote As String = If(Gvr.FCTextBox("TxtLote").Text = "", "-1", Gvr.FCTextBox("TxtLote").Text) Dim FechaCaducidad As String = If(Gvr.FCTextBox("TxtCaducidad").Text = "", "-1", Gvr.FCTextBox("TxtCaducidad").Text) - If UsuarioActual.Empresa.Funcionalidad(578).ToEntero = 1 Then - - Dim DdlCaducidadProducto As DropDownList = Gvr.FCDropDownList("DdlCaducidadProducto") - Dim ArrayCaducidad As String() = DdlCaducidadProducto.SelectedValue.Split("|"c) + If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then + Dim ArrayCaducidad As String() = Gvr.FCDropDownList("DdlCaducidadProducto").SelectedValue.Split("|"c) Lote = ArrayCaducidad(0) FechaCaducidad = ArrayCaducidad(1) - End If Dim CveSeccionAlmacen As Integer = Gvr.FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero() @@ -826,11 +794,7 @@ Partial Class Inventarios_PaquetesArmadoDesarmado Exit For End If Next - - If TieneError Then - Exit For - End If - + If TieneError Then Exit For Else If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Gvr.DataKey("Cantidad").ToString.ToDecimal, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, 0, -1, CveSeccionAlmacen:=CveSeccionAlmacen, Lote:=Lote, @@ -860,16 +824,15 @@ Partial Class Inventarios_PaquetesArmadoDesarmado PUTemp = PUTemp / TxtCantidadArmado.Text.ToDecimal Dim CvePSTemp = CvePaqueteArmado Dim CveSeccionAlmacen As Integer = -1 - Dim Drp As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePaqueteArmado).FiltroPrimero("") + Dim Drp As DataRow = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=CvePaqueteArmado).FiltroPrimero("") - Dim CveUMTemp As Integer = Drp("CveUM").ToString.ToEntero + Dim CveUMTemp As Integer = Drp("CveUnidadMedida").ToString.ToEntero Dim AplicaSeccion As Boolean = CBool(Drp("AplicaSeccion")) If AplicaSeccion Then CveSeccionAlmacen = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, CveAlmacenArmado, CvePaqueteArmado).FiltroPrimeroValor("CveSeccionAlmacen").ToEntero End If - - If AplicaSeriePaquete Then + If AplicaSeriePaquete Or AplicaLotePaquete Or AplicaCaducidadPaquete Then Dim ContadorPaquete = 1 Dim DtSeriesComponentes As New DataTable For Each Gvr As GridViewRow In GvSeriesPaqueteArmado.Rows @@ -900,7 +863,6 @@ Partial Class Inventarios_PaquetesArmadoDesarmado Next End If Next - ContadorPaquete = ContadorPaquete + 1 Next Else @@ -934,7 +896,7 @@ Partial Class Inventarios_PaquetesArmadoDesarmado Dim CvePSTemp As Integer = CvePaqueteDesarmado Dim CveSeccionAlmacen As Integer = -1 - Dim Drp As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePaqueteDesarmado).FiltroPrimero("") + Dim Drp As DataRow = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=CvePaqueteDesarmado).FiltroPrimero("") Dim CveUMTemp As Integer = Drp("CveUM").ToString.ToEntero 'Dim AplicaSeccion As Boolean = CBool(Drp("AplicaSeccion")) @@ -1070,9 +1032,9 @@ Partial Class Inventarios_PaquetesArmadoDesarmado If Not TieneError Then Dim Msg As New StringBuilder - Msg.AppendFormat("
    El Movimiento de salida se registro con el Folio: {1}", CveMovimientoSalida, FolioSalida) + Msg.AppendFormat("
    El Movimiento de salida se registro con el Folio: {1}", CveMovimientoSalida, FolioSalida) Msg.AppendFormat("
    Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoSalida))) - Msg.AppendFormat("


    El Movimiento de entrada se registro con el Folio: {1}", CveMovimientoEntrada, FolioEntrada) + Msg.AppendFormat("

    El Movimiento de entrada se registro con el Folio: {1}", CveMovimientoEntrada, FolioEntrada) Msg.AppendFormat("
    Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoEntrada))) Alert(Msg.ToString, TipoMensaje.MsgInformacion) ObjInventario.Commit() @@ -1659,8 +1621,8 @@ Partial Class Inventarios_PaquetesArmadoDesarmado End If Dim AplicaCaducidad = False - If GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).FiltraParametros("").Rows(0) IsNot Nothing Then - AplicaCaducidad = If(GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).FiltraParametros("").Rows(0)("AplicaCaducidad").ToString = "True", True, False) + If GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).FiltraParametros("").Rows(0) IsNot Nothing Then + AplicaCaducidad = If(GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).FiltraParametros("").Rows(0)("AplicaCaducidad").ToString = "True", True, False) End If Row("ConsecId") = CveConsecSerieLote @@ -1754,7 +1716,7 @@ Partial Class Inventarios_PaquetesArmadoDesarmado 'VERIFICA EXISTENCIAS Dim ObjInventarios As New ClsInventarios - Dim CveUMTemp = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePaqueteDesarmado).FiltroPrimeroValor("CveUM").ToEntero + Dim CveUMTemp = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=CvePaqueteDesarmado).FiltroPrimeroValor("CveUM").ToEntero Dim Existencia = ObjInventarios.GetExistenciasPS(CvePaqueteDesarmado, CveUMTemp, UsuarioActual.CveEmpresa, CveAlmacenDesarmado, FechaMovto:=TxtFechaDesarmado.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Serie:=Serie, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), Lote:=Lote, FechaCaducidad:=FechaCaducidad) diff --git a/Inventarios/RecepcionAlmacen.aspx.vb b/Inventarios/RecepcionAlmacen.aspx.vb index ef8415673..067f4e1d6 100644 --- a/Inventarios/RecepcionAlmacen.aspx.vb +++ b/Inventarios/RecepcionAlmacen.aspx.vb @@ -3790,7 +3790,7 @@ Partial Class Inventarios_RecepcionAlmacen End If If CveTipoFechaVencimiento = 2 Then - If Not objCompras.UpdateFechaVencimientoCompra(CveCompra, TxtFecha.Text.ToDate, UsuarioActual.CveEmpresa) Then + If Not objCompras.UpdateFechaVencimientoCompra(CveCompra, TxtFecha.Text.ToDate, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then ErrorProceso = True End If End If diff --git a/LogIn.aspx.vb b/LogIn.aspx.vb index 104e4dd54..373b95ad4 100644 --- a/LogIn.aspx.vb +++ b/LogIn.aspx.vb @@ -29,16 +29,14 @@ Partial Class LogIn #End Region Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load - '"187.158.96.163" es la de mi casa - 'If (Context.Session("UsuarioSIG") IsNot Nothing) OrElse Not User.Identity.IsAuthenticated Then - 'Request.Headers.Add("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJOb21icmUiOiJhZG1pbiIsIkN2ZVVzdWFyaW8iOiIyMDA5IiwiQ3ZlRW1wcmVzYSI6IjIiLCJDdmVQZXJmaWwiOiIyIiwiTWFpbCI6ImFkbWluQGFkbWluLmNvbSIsImV4cCI6MTU5NDY3MzQ2NCwiaXNzIjoiVGVzdC5jb20iLCJhdWQiOiJUZXN0LmNvbSJ9.vmPRxGfxzR10Rf-4Luk2Ej0SVs7w2XGDGJBCyx5VSQI") - 'Response.AddHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJOb21icmUiOiJhZG1pbiIsIkN2ZVVzdWFyaW8iOiIyMDA5IiwiQ3ZlRW1wcmVzYSI6IjIiLCJDdmVQZXJmaWwiOiIyIiwiTWFpbCI6ImFkbWluQGFkbWluLmNvbSIsImV4cCI6MTU5NDY3MzQ2NCwiaXNzIjoiVGVzdC5jb20iLCJhdWQiOiJUZXN0LmNvbSJ9.vmPRxGfxzR10Rf-4Luk2Ej0SVs7w2XGDGJBCyx5VSQI") - 'Response.End() - 'End If + Dim iplist As String() = New String() {"", ""} If HttpContext.Current.Request.ServerVariables("REMOTE_ADDR").ToString().Contiene(iplist) Then Response.Redirect("http://www.adsistemas.mx/login.aspx") 'si alguien lo ve es correcto la pagina vieja de adsistemas End If + + + 'leer un txt para validar una ip Dim token As String = GetTokenAngular() If (token.Length > 0) Then If Not IsNothing(Request("port")) Then @@ -92,7 +90,22 @@ Partial Class LogIn PnlLoginB.CssClass = "logincint login-form " PnlContraB.CssClass = "logincint login-form " lnkFavicon.Href = "/Imagenes/favicongps.ico" - Else + End If + + Dim clientIp As String = (If(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), + Request.ServerVariables("REMOTE_ADDR"))).Split(","c)(0).Trim() + ' Ruta del archivo con las IP bloqueadas + Dim path As String = Server.MapPath("/Utilerias/IPBloqueadas.txt") + + If System.IO.File.Exists(path) Then + ' Leer el contenido del archivo y separarlo por ";" + Dim contenido As String = System.IO.File.ReadAllText(path) + Dim ipBloqueadas As String() = contenido.Split(";"c) + ' Verificar si la IP está en la lista + If ipBloqueadas.Any(Function(ip) ip.Trim() = clientIp) Then + Alert(" this site can't be reached

    refused to connect.

    ERR_CONNECTION_REFUSED

    ", TipoMensaje.MsgError) + BtnLogIn.Visible = False + End If End If HdfImagenes.Value = strimg.ToString() diff --git a/Nomina/ConceptoNomina.aspx.cs b/Nomina/ConceptoNomina.aspx.cs index 1361b2a74..dd21edd51 100644 --- a/Nomina/ConceptoNomina.aspx.cs +++ b/Nomina/ConceptoNomina.aspx.cs @@ -342,6 +342,7 @@ public partial class Nomina_CatConcepto : ClsPaginas int CveConceptoPadre = DdlConceptoPadre.SelectedValue.ToEntero(); int CveConceptoContable = DdlConceptoContable.SelectedValue.ToEntero(); + int CveCuenta = (DdlCtaContable.DataValueField == "Id" ? 0 : DdlCtaContable.SelectedValue.ToEntero()); bool estado; if (ChkEstado.Checked) estado = true; @@ -378,8 +379,8 @@ public partial class Nomina_CatConcepto : ClsPaginas if (EsEditar) { TieneError = !ObjNomina.UpdateConcepto(codigo, concepto, tipo, formula, sistema, estado, CveConceptoPadre, CveConcepto, retencion, CveClasificacion, CveTipoGasto, - tipoCalculo, CveConceptoContable, AplicaFiniquito, AutomaticoGlobal, Especie, Imprimir, CveSATConcepto, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, - ctaImporteNegativoProv, contabiliza, CargoOAbono, cveConceptoContableB , CveCuentaB, CveConceptoContablePasivo, AplicaEfectivale, EsFormula); + tipoCalculo, CveConceptoContable, CveCuenta, AplicaFiniquito, AutomaticoGlobal, Especie, Imprimir, CveSATConcepto, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, + ctaImporteNegativoProv, contabiliza, CargoOAbono, cveConceptoContableB, CveCuentaB, CveConceptoContablePasivo, AplicaEfectivale, EsFormula); if (!TieneError) { diff --git a/Nomina/Nomina.aspx.cs b/Nomina/Nomina.aspx.cs index f98996b1b..4d27e3f08 100644 --- a/Nomina/Nomina.aspx.cs +++ b/Nomina/Nomina.aspx.cs @@ -9872,7 +9872,7 @@ public partial class Nomina_Nomina2 : ClsPaginas { if (objnom.DTSetResultados.Tables.Count > 1) { - ContaConceptossource = get_GlobalDTContaConceptosContables(-1).FiltraParametros("AplicaPersonal = 1"); + ContaConceptossource = get_GlobalDTContaConceptosContables(-1).FiltraParametros("AplicaNomina = 1 OR AplicaPersonal = 1"); //using (ClsContabilidad ObjContaz = new ClsContabilidad()) //{ // if (ObjContaz.GetConta_ConceptosContables()) @@ -9883,7 +9883,6 @@ public partial class Nomina_Nomina2 : ClsPaginas if (UsuarioActual.Empresa.TipoContabilidad == 1) { - using (ClsContabilidad ObjConta = new ClsContabilidad()) { if (ObjConta.GetCuentas(-1, "-1", 1, UsuarioActual.CveEmpresa)) @@ -9912,7 +9911,7 @@ public partial class Nomina_Nomina2 : ClsPaginas GVProvision.DataSource = objnom.DTSetResultados.Tables[1]; GVProvision.DataBind(); RegistraScript("$('#ModalRegistraProvision').modal();"); - Alert("no se pudo registrar la provisión, existen cuentas sin vincular", TipoMensaje.MsgAdvertencia); + Alert("La Provisión no se pudo registrar porque existen conceptos sin vincular a su cuenta.", TipoMensaje.MsgAdvertencia); UpRegistroProvision.Update(); } diff --git a/OP/OP.aspx b/OP/OP.aspx index 7ca37ef2a..82f0c1184 100644 --- a/OP/OP.aspx +++ b/OP/OP.aspx @@ -279,6 +279,36 @@ padding: 5px; margin-top: 10px; } + + .quantity-control { + position: relative; + display: flex; + align-items: center; + width: 120px; + } + + .quantity-input { + width: 70px !important; + padding-right: 30px; + } + + .quantity-buttons { + position: absolute; + right: 0; + display: flex; + flex-direction: column; + gap: 2px; + } + + .btn-quantity { + padding: 0; + width: 22px; + height: 18px; + line-height: 1; + border: 1px solid #ddd; + background: #f8f9fa; + cursor: pointer; + } @@ -466,7 +496,8 @@
    Productos
    + CssClass="table table-striped table-hover" GridLines="None" Width="100%" + OnRowDataBound="GvProductos_RowDataBound"> @@ -474,7 +505,7 @@ @@ -560,7 +591,7 @@ CssClass="table table-striped table-hover" GridLines="None" Width="100%"> - +
    @@ -745,6 +776,16 @@
    +
    +
    + +
    +
    + + + + + + + + + + diff --git a/OP/OP.aspx.vb b/OP/OP.aspx.vb index 3053d6962..da0815cfa 100644 --- a/OP/OP.aspx.vb +++ b/OP/OP.aspx.vb @@ -57,11 +57,20 @@ Partial Class OP_OP End Set End Property + Private Property TipoEstatus As Integer + Get + Return ViewState("TipoEstatus").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("TipoEstatus") = value + End Set + End Property + Private Property DtMPAgregados As DataTable Get If ViewState("DtMPAgregados") Is Nothing Then DtMPAgregados = New DataTable() - DtMPAgregados.Columns.Add("Clave", GetType(Integer)) + DtMPAgregados.Columns.Add("CvePS", GetType(Integer)) DtMPAgregados.Columns.Add("PSCodigo", GetType(String)) DtMPAgregados.Columns.Add("CveUM", GetType(Integer)) DtMPAgregados.Columns.Add("UnidadMedida", GetType(String)) @@ -74,21 +83,38 @@ Partial Class OP_OP End Set End Property + Private Property DtDevoluciones As DataTable + Get + If ViewState("DtDevoluciones") Is Nothing Then + DtDevoluciones = New DataTable() + DtDevoluciones.Columns.Add("CvePS", GetType(Integer)) + DtDevoluciones.Columns.Add("Devolucion", GetType(Decimal)) + DtDevoluciones.Columns.Add("CveAlmacenDevolucion", GetType(Integer)) + End If + Return CType(ViewState("DtDevoluciones"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtDevoluciones") = value + End Set + End Property #End Region Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then CveOP = If(Request("CveOP") <> "", Request("CveOP").ToString.ToEntero, "-1".ToEntero) + TipoEstatus = -1 CreaPS() SetValues() End If + + BtnCancelarOP.Visible = (CveOP > 0 AndAlso TipoEstatus <> 3 AndAlso TipoEstatus <> 4) End Sub Private Sub CreaPS() DtPS = New DataTable() DtPS.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI - DtPS.Columns.Add("Clave", GetType(Integer)) + DtPS.Columns.Add("CvePS", GetType(Integer)) DtPS.Columns.Add("PSCodigo", GetType(String)) DtPS.Columns.Add("UnidadMedida", GetType(String)) DtPS.Columns.Add("Cantidad", GetType(Decimal)) @@ -98,7 +124,7 @@ Partial Class OP_OP DtMP = New DataTable() DtMP.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI - DtMP.Columns.Add("Clave", GetType(Integer)) + DtMP.Columns.Add("CvePS", GetType(Integer)) DtMP.Columns.Add("CvePSMateriaPrima", GetType(Integer)) DtMP.Columns.Add("CveUM", GetType(Integer)) DtMP.Columns.Add("CveUMMateriaPrima", GetType(Integer)) @@ -106,24 +132,29 @@ Partial Class OP_OP DtMP.Columns.Add("UnidadMedida", GetType(String)) DtMP.Columns.Add("Cantidad", GetType(Decimal)) DtMP.Columns.Add("Surtido", GetType(Decimal)) + 'DtMP.Columns.Add("CvePSProducto", GetType(Integer)) 'DtMP.Columns.Add("CveAlmacenDestino", GetType(Integer)) DtMO = New DataTable() DtMO.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI - DtMO.Columns.Add("Clave", GetType(Integer)) + DtMO.Columns.Add("CvePS", GetType(Integer)) DtMO.Columns.Add("CveUM", GetType(Integer)) DtMO.Columns.Add("CvePuesto", GetType(Integer)) DtMO.Columns.Add("Puesto", GetType(String)) DtMO.Columns.Add("Cantidad", GetType(Decimal)) + DtMO.Columns.Add("CostoHora", GetType(Decimal)) + DtMO.Columns.Add("Total", GetType(Decimal)) + DtCI = New DataTable() DtCI.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI - DtCI.Columns.Add("Clave", GetType(Integer)) - 'DtCI.Columns.Add("CveUM", GetType(Integer)) - 'DtCI.Columns.Add("CvePSMateriaPrima", GetType(Integer)) - 'DtCI.Columns.Add("CveUMMateriaPrima", GetType(Integer)) + DtCI.Columns.Add("CvePS", GetType(Integer)) DtCI.Columns.Add("productoMateriaPrima", GetType(String)) + DtCI.Columns.Add("CvePSProducto", GetType(Integer)) DtCI.Columns.Add("Cantidad", GetType(Decimal)) + 'DtCI.Columns.Add("Costo", GetType(Decimal)) + DtCI.Columns.Add("ImporteCostoIndirecto", GetType(Decimal)) + DtCI.Columns.Add("Total", GetType(Decimal)) End Sub @@ -133,24 +164,65 @@ Partial Class OP_OP CargarClientes() CargarCentrosDeCosto(DdlProyecto, DdlSubProyecto, LblProyecto, LblSubProyecto, divProyecto:=DivProyecto, VisualizacionReporte:=1) CargarProductos() + CargaDatos() - If CveOP = -1 Then - - DdlClientes.Enabled = True - DdlProyecto.Enabled = True - DdlSubProyecto.Enabled = True - DdlPS.Enabled = True - LnkSolicitarMP.Visible = False - BtnSimularMP.Visible = True - BtnFinalizarOP.Visible = False + If TipoEstatus = 3 Then + DeshabilitarControles() ' Deshabilita todos los controles relevantes Else - DdlClientes.Enabled = False - DdlPS.Enabled = False - LnkSolicitarMP.Visible = False - BtnSimularMP.Visible = False - BtnFinalizarOP.Visible = True - CargaDatos() + If CveOP = -1 Then ' Nueva OP + DdlClientes.Enabled = True + DdlProyecto.Enabled = True + DdlSubProyecto.Enabled = True + DdlPS.Enabled = True + TxtEstatus.Enabled = True ' Estatus no editable + LnkSolicitarMP.Visible = False + BtnSimularMP.Visible = True + BtnFinalizarOP.Visible = False + Else ' OP existente no finalizada + If TipoEstatus <> 3 Then + DdlClientes.Enabled = True + DdlProyecto.Enabled = True + DdlSubProyecto.Enabled = True + DdlPS.Enabled = True + TxtDescripcion.Enabled = True + Txtfecha.Enabled = True + TxtEstatus.Enabled = True ' Estatus no editable + BtnAgregarProducto.Enabled = True + BtnSimularMP.Visible = False + BtnGuardarOP.Enabled = True + BtnFinalizarOP.Visible = True + imgCalendarioF.Enabled = True + LnkSolicitarMP.Visible = True + End If + End If End If + + UpOP.Update() + UpGvDatosOP.Update() + End Sub + + Private Sub DeshabilitarControles() + ' Deshabilitar DropDownLists + DdlClientes.Enabled = False + DdlProyecto.Enabled = False + DdlSubProyecto.Enabled = False + DdlPS.Enabled = False + + ' Deshabilitar TextBox y Date + TxtDescripcion.Enabled = False + Txtfecha.Enabled = False + imgCalendarioF.Enabled = False + TxtEstatus.Enabled = False + + ' Ocultar Botones + BtnAgregarProducto.Visible = False + BtnSimularMP.Visible = False + BtnGuardarOP.Visible = False + BtnFinalizarOP.Visible = False + LnkSolicitarMP.Visible = False + + UpOP.Update() + UpGvDatosOP.Update() End Sub Private Sub CargaDatos() @@ -169,6 +241,7 @@ Partial Class OP_OP DdlPS.txtValue.Value = dr("CvePS").ToString Txtfecha.Text = dr("Fecha").ToString TxtDescripcion.Text = dr("Descripcion").ToString + TipoEstatus = dr("TipoEstatus").ToString.ToEntero If ObjOP.GetProductosOP(CveOP, UsuarioActual.CveEmpresa) Then @@ -176,7 +249,7 @@ Partial Class OP_OP For Each rowProducto As DataRow In ObjOP.DtResultados.Rows Dim newRow As DataRow = DtPS.NewRow() newRow("Tipo") = "Producto" - newRow("Clave") = rowProducto("CvePS").ToString.ToEntero + newRow("CvePS") = rowProducto("CvePS").ToString.ToEntero newRow("PSCodigo") = rowProducto("Producto").ToString newRow("UnidadMedida") = rowProducto("UnidadMedida").ToString @@ -191,9 +264,9 @@ Partial Class OP_OP For Each rowMP As DataRow In ObjOP.DtResultados.Rows Dim newRow As DataRow = DtMP.NewRow() newRow("Tipo") = "MP" - newRow("Clave") = rowMP("CvePS").ToString.ToEntero + newRow("CvePS") = rowMP("CvePS").ToString.ToEntero newRow("PSCodigo") = rowMP("Producto").ToString - newRow("CvePSMateriaPrima") = rowMP("CvePS").ToString.ToEntero + newRow("CvePSMateriaPrima") = rowMP("CvePSMateriaPrima").ToString.ToEntero newRow("CveUMMateriaPrima") = rowMP("CveUM").ToString.ToEntero newRow("UnidadMedida") = rowMP("UnidadMedida").ToString newRow("Cantidad") = rowMP("Cantidad").ToString.ToDecimal @@ -208,8 +281,11 @@ Partial Class OP_OP For Each rowMO As DataRow In ObjOP.DtResultados.Rows Dim newRow As DataRow = DtMO.NewRow() newRow("Tipo") = "MO" + newRow("CvePS") = rowMO("CvePS").ToString().ToEntero() newRow("Puesto") = rowMO("Puesto").ToString newRow("Cantidad") = rowMO("Cantidad").ToString.ToDecimal + newRow("CostoHora") = rowMO("precioHora").ToString.ToDecimal() + newRow("Total") = rowMO("Cantidad").ToString().ToDecimal() * rowMO("precioHora").ToString().ToDecimal() DtMO.Rows.Add(newRow) Next End If @@ -220,8 +296,12 @@ Partial Class OP_OP For Each rowCI As DataRow In ObjOP.DtResultados.Rows Dim newRow As DataRow = DtCI.NewRow() newRow("Tipo") = "CI" + newRow("CvePS") = rowCI("CvePS").ToString().ToEntero() + newRow("CvePSProducto") = rowCI("CvePSProducto").ToString().ToEntero() + 'newRow("CvePSMateriaPrima") = rowCI("CvePSMateriaPrima").ToString().ToEntero() newRow("productoMateriaPrima") = rowCI("producto").ToString - newRow("Cantidad") = rowCI("Cantidad").ToString.ToDecimal + newRow("ImporteCostoIndirecto") = rowCI("ImporteCostoIndirecto").ToString.ToDecimal() + newRow("Total") = rowCI("ImporteCostoIndirecto") DtCI.Rows.Add(newRow) Next @@ -267,7 +347,7 @@ Partial Class OP_OP Dim DrPS As DataRow = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") newRow("Tipo") = "Producto" - newRow("Clave") = CvePS + newRow("CvePS") = CvePS newRow("PSCodigo") = DrPS("PSCodigo") newRow("UnidadMedida") = DrPS("UnidadMedida") newRow("Cantidad") = 1 @@ -285,13 +365,14 @@ Partial Class OP_OP For Each drMP As DataRow In ObjMP.DtResultados.Rows Dim rowMP As DataRow = DtMP.NewRow() rowMP("Tipo") = "MP" - rowMP("Clave") = CvePS - rowMP("CvePSMateriaPrima") = CvePS + rowMP("CvePS") = CvePS + rowMP("CvePSMateriaPrima") = drMP("CvePSMateriaPrima").ToString().ToEntero() rowMP("CveUM") = CveUM - rowMP("CveUMMateriaPrima") = CveUM 'drMP("CveUMMateriaPrima").ToString().ToEntero() + rowMP("CveUMMateriaPrima") = drMP("CveUMMateriaPrima").ToString().ToEntero() rowMP("PSCodigo") = drMP("productoMateriaPrima").ToString() rowMP("UnidadMedida") = drMP("UnidadMedidaMateriaPrima").ToString() rowMP("Cantidad") = drMP("Cantidad").ToString().ToDecimal() + rowMP("Surtido") = 0 DtMP.Rows.Add(rowMP) Next @@ -303,9 +384,11 @@ Partial Class OP_OP For Each drMO As DataRow In ObjMO.DtResultados.Rows Dim rowMO As DataRow = DtMO.NewRow() rowMO("Tipo") = "MO" - rowMO("Clave") = CvePS + rowMO("CvePS") = CvePS rowMO("Puesto") = drMO("Puesto").ToString() rowMO("Cantidad") = drMO("Cantidad").ToString().ToDecimal() + rowMO("CostoHora") = drMO("precioHora").ToString.ToDecimal() + rowMO("Total") = drMO("Cantidad").ToString().ToDecimal() * drMO("precioHora").ToString().ToDecimal() DtMO.Rows.Add(rowMO) Next End If @@ -317,10 +400,12 @@ Partial Class OP_OP For Each drCI As DataRow In ObjCI.DtResultados.Rows Dim rowCI As DataRow = DtCI.NewRow() rowCI("Tipo") = "CI" - rowCI("Clave") = CvePS + rowCI("CvePS") = CvePS + rowCI("CvePSProducto") = drCI("CvePSProducto").ToString() 'rowCI("CvePSMateriaPrima") = drCI("CvePSMateriaPrima").ToString().ToEntero() rowCI("productoMateriaPrima") = drCI("productoMateriaPrima").ToString() - rowCI("Cantidad") = drCI("Cantidad").ToString().ToDecimal() + rowCI("ImporteCostoIndirecto") = drCI("ImporteCostoIndirecto").ToString().ToDecimal() + rowCI("Total") = rowCI("ImporteCostoIndirecto") DtCI.Rows.Add(rowCI) Next End If @@ -329,10 +414,16 @@ Partial Class OP_OP End Sub Protected Sub BtnEliminarProducto_Click(sender As Object, e As EventArgs) + + ' Verificar si la OP está finalizada + If TxtEstatus.Text = "Finalizada" Then + Alert("No se pueden eliminar productos de una OP finalizada.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If Dim btnEliminar As LinkButton = DirectCast(sender, LinkButton) Dim CveProducto As Integer = btnEliminar.CommandArgument.ToEntero() - Dim filasProducto As DataRow() = DtPS.Select($"Clave = {CveProducto}") + Dim filasProducto As DataRow() = DtPS.Select($"CvePS = {CveProducto}") If filasProducto.Length > 0 Then DtPS.Rows.Remove(filasProducto(0)) EliminarDatosRelacionados(CveProducto) @@ -343,24 +434,31 @@ Partial Class OP_OP Private Sub EliminarDatosRelacionados(CveProducto As Integer) ' Materia Prima - Dim filasMP As DataRow() = DtMP.Select($"Clave = {CveProducto}") + Dim filasMP As DataRow() = DtMP.Select($"CvePS = {CveProducto}") For Each fila As DataRow In filasMP DtMP.Rows.Remove(fila) Next ' Mano de Obra - Dim filasMO As DataRow() = DtMO.Select($"Clave = {CveProducto}") + Dim filasMO As DataRow() = DtMO.Select($"CvePS = {CveProducto}") For Each fila As DataRow In filasMO DtMO.Rows.Remove(fila) Next ' Costos Indirectos - Dim filasCI As DataRow() = DtCI.Select($"Clave = {CveProducto}") + Dim filasCI As DataRow() = DtCI.Select($"CvePS = {CveProducto}") For Each fila As DataRow In filasCI DtCI.Rows.Remove(fila) Next End Sub + Protected Sub GvProductos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvProductos.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + Dim btnEliminar As LinkButton = DirectCast(e.Row.FindControl("BtnEliminar"), LinkButton) + btnEliminar.Visible = (TipoEstatus <> 3) + End If + End Sub + Protected Sub LnkSolicitarMP_Click(sender As Object, e As EventArgs) ' Cargar almacenes DdlAlmacenOrigenMP.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 1") @@ -560,22 +658,17 @@ Partial Class OP_OP Dim MensajeExistencia As New StringBuilder MensajeExistencia.Append("No hay la existencia suficiente de los siguientes productos:
    ") - '✅ 1. Validar existencias de MP + For Each row As GridViewRow In GvMPAgregados.Rows - '✅ Obtener claves CORRECTAS de la materia prima + Dim CveMP As Integer = GvMPAgregados.DataKeys(row.RowIndex)("CvePSMateriaPrima").ToString().ToEntero() Dim CveUMMP As Integer = GvMPAgregados.DataKeys(row.RowIndex)("CveUMMateriaPrima").ToString().ToEntero() Dim CantidadSolicitada As Decimal = DtMP.Rows(row.RowIndex)("Cantidad").ToString().ToDecimal() - - 'DtMP.Rows(row.RowIndex)("CveAlmacenDestino") = DdlAlmacenDestinoMP.SelectedValue.ToEntero() - - '✅ Verificar existencias Dim Existencia As Decimal = ObjInventario.GetExistenciasPS( CvePS:=CveMP, CveUnidadMedida:=CveUMMP, CveEmpresa:=UsuarioActual.CveEmpresa, - CveAlmacen:=DdlAlmacenOrigenMP.SelectedValue.ToEntero() - ) + CveAlmacen:=DdlAlmacenOrigenMP.SelectedValue.ToEntero()) If Existencia < CantidadSolicitada Then Dim NombreProducto As String = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveMP).FiltroPrimeroValor("Producto", "") @@ -596,21 +689,21 @@ Partial Class OP_OP Exit Sub End If - '✅ 2. Crear traspaso si todo está correcto + ObjInventario.IniciaTransacSQL() Dim TieneError As Boolean = False Dim FolioSolicitud As Integer = ObjInventario.AddTrasladoSolicitud( - TxtObservacionesMP.Text.Trim(), - DdlAlmacenOrigenMP.SelectedValue.ToEntero(), - DdlAlmacenDestinoMP.SelectedValue.ToEntero(), - Estatus, - -1, - NowADS, - CveUsuario:=UsuarioActual.CveUsuario, - CveEmpresa:=UsuarioActual.CveEmpresa, - EstatusAlmacen:=EstatusAlmacen - ) + TxtObservacionesMP.Text.Trim(), + DdlAlmacenOrigenMP.SelectedValue.ToEntero(), + DdlAlmacenDestinoMP.SelectedValue.ToEntero(), + Estatus, + -1, + NowADS, + CveUsuario:=UsuarioActual.CveUsuario, + CveEmpresa:=UsuarioActual.CveEmpresa, + EstatusAlmacen:=EstatusAlmacen + ) If FolioSolicitud > 0 Then CveTraspasoSolicitud = ObjInventario.CveTraspasoSolicitud @@ -618,10 +711,10 @@ Partial Class OP_OP TieneError = True End If - '✅ 3. Agregar detalles del traspaso + If Not TieneError Then For Each row As GridViewRow In GvMPAgregados.Rows - '✅ Usar claves de MATERIA PRIMA (CvePSMateriaPrima y CveUMMateriaPrima) + Dim CveMP As Integer = GvMPAgregados.DataKeys(row.RowIndex)("CvePSMateriaPrima").ToString().ToEntero() Dim CveUMMP As Integer = GvMPAgregados.DataKeys(row.RowIndex)("CveUMMateriaPrima").ToString().ToEntero() Dim Cantidad As Decimal = DtMP.Rows(row.RowIndex)("Cantidad").ToString().ToDecimal() @@ -629,8 +722,8 @@ Partial Class OP_OP If Not ObjInventario.AddTrasladoSolicitudDetalle( CveTraspasoSolicitud, Cantidad, - CveUMMP, '✅ Unidad de medida de la MP - CveMP, '✅ Clave de la MP + CveUMMP, + CveMP, 0, "", -1, "-1", "-1", MinFecha ) Then TieneError = True @@ -639,7 +732,6 @@ Partial Class OP_OP Next End If - '✅ 4. Confirmar o cancelar transacción If Not TieneError Then ObjInventario.Commit() Alert($"Solicitud de Traspaso guardada. Folio: {FolioSolicitud}", TipoMensaje.MsgInformacion) @@ -671,8 +763,6 @@ Partial Class OP_OP Try - - If Me.CveOP = -1 Then ' Modo CREACIÓN Dim xmlProductos As String = DataTableToXML(DtPS) @@ -695,7 +785,7 @@ Partial Class OP_OP Alert("Orden creada con Folio: " & FolioGenerado, TipoMensaje.MsgInformacion) End If Else ' Modo EDICIÓN - Dim CvePS As Integer = DtPS.Rows(0)("Clave").ToString.ToEntero() + Dim CvePS As Integer = DtPS.Rows(0)("CvePS").ToString.ToEntero() Dim Cantidad As Integer = DtPS.Rows(0)("Cantidad").ToString.ToEntero() BtnFinalizarOP.Visible = True If Not clsOP.UpdateOP( @@ -736,7 +826,7 @@ Partial Class OP_OP For Each row As DataRow In dt.Rows Dim producto As XmlElement = xmlDoc.CreateElement("Producto") - producto.InnerXml = $"{row("Clave")}{row("Cantidad")}{row("CveUM")}" + producto.InnerXml = $"{row("CvePS")}{row("Cantidad")}{row("CveUM")}" xmlDoc.DocumentElement.AppendChild(producto) Next @@ -786,31 +876,176 @@ Partial Class OP_OP End Sub Protected Sub DdlAlmacenOrigenMP_SelectedIndexChanged(sender As Object, e As EventArgs) - ' ✅ Mantener siempre el almacén de producción (tipo 28) en destino + DdlAlmacenDestinoMP.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 28") DdlAlmacenDestinoMP.DataBind() - ' ✅ Opcional: Seleccionar el primer almacén de producción por defecto + If DdlAlmacenDestinoMP.Items.Count > 0 Then DdlAlmacenDestinoMP.SelectedIndex = 0 End If End Sub -#Region "Eventos de Botones" + Protected Sub GvProductoTerminado_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + Dim originalQty As Decimal = Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Cantidad")) + Dim txtCantidad As TextBox = DirectCast(e.Row.FindControl("TxtCantidadPT"), TextBox) + txtCantidad.Attributes("data-original") = originalQty.ToString("0") + End If + End Sub + Protected Sub GvMPUtilizada_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + Dim originalQty As Decimal = Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Cantidad")) + Dim txtDevolucion As TextBox = DirectCast(e.Row.FindControl("TxtDevolucionMP"), TextBox) + txtDevolucion.Attributes("data-original") = originalQty.ToString("0") + End If + End Sub + +#Region "Cancelar" + Protected Sub BtnCancelarOP_Click(sender As Object, e As EventArgs) + ' Cargar almacenes + DdlAlmacenSalidaMP.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 1") + DdlAlmacenSalidaMP.DataBind() + DdlAlmacenDevolucionCancel.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 1") + DdlAlmacenDevolucionCancel.DataBind() + DdlAlmacenMermas.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 1") + DdlAlmacenMermas.DataBind() + + ' Cargar MP + GvMPCancelacion.DataSource = DtMP.FiltraParametros("Tipo = 'MP'") + GvMPCancelacion.DataBind() + + RegistraScript("$('#DVModalCancelarOP').modal('show');") + UpModalCancelar.Update() + End Sub + + Protected Sub BtnAceptarCancelacion_Click(sender As Object, e As EventArgs) + Dim ObjInventario As New ClsInventarios() + Dim TieneError As Boolean = False + Dim MensajeError As String = "" + ObjInventario.IniciaTransacSQL() + Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) + Dim ObjOP As New ClsOP(ObjInventario.IniciaTransacSQL()) + + Try + + + ' Validaciones + If DdlAlmacenSalidaMP.SelectedValue = "-1" OrElse + DdlAlmacenDevolucionCancel.SelectedValue = "-1" Then + Throw New Exception("Seleccione todos los almacenes requeridos") + End If + + ' 1. Movimiento de Salida MP + Dim CveMovSalida As Integer = ObjInventario.AddMovimiento( + DdlAlmacenSalidaMP.SelectedValue.ToEntero(), 26, 1, NowADS, -1, + UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, + Observaciones:="Cancelación OP #" & LblFolio.Text) + + ' 2. Movimiento de Entrada Devoluciones + Dim CveMovEntradaDev As Integer = ObjInventario.AddMovimiento( + DdlAlmacenDevolucionCancel.SelectedValue.ToEntero(), 27, 1, NowADS, -1, + UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + + ' 3. Procesar cada material + For Each row As GridViewRow In GvMPCancelacion.Rows + Dim Cantidad As Decimal = CDec(row.Cells(2).Text) + Dim Merma As Decimal = row.FCTextBox("TxtMerma").Text.ToDecimal() + Dim Devolucion As Decimal = row.FCTextBox("TxtDevolucionCancel").Text.ToDecimal() + + If (Merma + Devolucion) > Cantidad Then + Throw New Exception("La suma de merma y devolución no puede exceder la cantidad") + End If + + Dim CvePS As Integer = GvMPCancelacion.DataKeys(row.RowIndex).Values(0) + Dim CveUM As Integer = GvMPCancelacion.DataKeys(row.RowIndex).Values(1) + + ' Registrar salida + ObjInventario.AddMovimientoDetalle(CveMovSalida, Cantidad, CveUM, CvePS, 0) + + ' Registrar devolución + If Devolucion > 0 Then + ObjInventario.AddMovimientoDetalle(CveMovEntradaDev, Devolucion, CveUM, CvePS, 0) + End If + Next + + ' 4. Registrar mermas si existen + Dim TotalMermas As Decimal = 0 + If DdlAlmacenMermas.SelectedValue <> "-1" Then + Dim CveMovMerma As Integer = ObjInventario.AddMovimiento( + DdlAlmacenMermas.SelectedValue.ToEntero(), 26, 1, NowADS, -1, + UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + + For Each row As GridViewRow In GvMPCancelacion.Rows + Dim Merma As Decimal = row.FCTextBox("TxtMerma").Text.ToDecimal() + If Merma > 0 Then + Dim CvePS As Integer = GvMPCancelacion.DataKeys(row.RowIndex).Values(0) + Dim CveUM As Integer = GvMPCancelacion.DataKeys(row.RowIndex).Values(1) + ObjInventario.AddMovimientoDetalle(CveMovMerma, Merma, CveUM, CvePS, 0) + TotalMermas += Merma + End If + Next + End If + + ' 5. Generar pólizas contables + Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("OP/Cancelacion", 53, 0, 0, 1, NowADS, + "Cancelación OP #" & LblFolio.Text, + UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + + ' Salida MP (Abono 68) + ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TotalMP, TotalMP, 68, "Salida MP Cancelación") + + ' Entrada Devoluciones (Cargo 68) + ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TotalDevoluciones, TotalDevoluciones, 68, "Devoluciones Cancelación") + + If TotalMermas > 0 Then + ' Salida Mermas (Abono 68) + ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TotalMermas, TotalMermas, 68, "Mermas Cancelación") + ' Cargo Mermas (95) + ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TotalMermas, TotalMermas, 95, "Ajuste por Mermas") + End If + + ' 6. Actualizar estatus OP + + If ObjOP.UpdateEstatusOP(CveOP, 4, UsuarioActual.CveEmpresa) Then + ObjInventario.Commit() + TxtEstatus.Text = "Cancelado" + BtnCancelarOP.Visible = False + UpOP.Update() + RegistraScript("$('#DVModalCancelarOP').modal('hide');") + Alert("OP cancelada correctamente", TipoMensaje.MsgInformacion) + Else + Throw New Exception("Error al actualizar el estatus de la OP") + End If + + Catch ex As Exception + ObjInventario.RollBack() + Alert($"Error: {ex.Message}", TipoMensaje.MsgError) + Finally + ObjInventario.Dispose() + ObjConta.Dispose() + End Try + End Sub +#End Region + + + +#Region "Finalizar" Protected Sub BtnFinalizarOP_Click(sender As Object, e As EventArgs) If CveOP = -1 Then Exit Sub ' 1. Cargar almacén de salida (Tipo 28) DdlAlmacenOrigenSalidaMP.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 28") DdlAlmacenOrigenSalidaMP.DataBind() - - ' 2. Cargar almacén de producto terminado DdlAlmacenTerminado.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 1") DdlAlmacenTerminado.DataBind() DdlAlmacenTerminado.Items.Insert(0, New ListItem("Seleccionar almacén", "-1")) - + ' Almacén de Devoluciones (Tipo 1) + DdlAlmacenDevolucion.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 1") + DdlAlmacenDevolucion.DataBind() + DdlAlmacenDevolucion.Items.Insert(0, New ListItem("Seleccionar almacén", "-1")) ' 3. Cargar GridViews GvProductoTerminado.DataSource = DtPS.FiltraParametros("Tipo = 'Producto'") GvProductoTerminado.DataBind() @@ -823,15 +1058,42 @@ Partial Class OP_OP End Sub Protected Sub BtnGuardarFinalizarOP_Click(sender As Object, e As EventArgs) + Dim EstatusFinalizar As String = GlobalDTOPEstatus(UsuarioActual.CveEmpresa).FiltroPrimeroValor("EstatusOP", "TipoEstatus=3") + Dim CveEstatusFinalizar As Integer = GlobalDTOPEstatus(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveEstatusOP", "TipoEstatus=3").ToEntero() + If Not CveEstatusFinalizar > 0 Then + Alert("No se encontró el estatus de finalización de la OP.", TipoMensaje.MsgError) + Exit Sub + End If + If DdlAlmacenOrigenSalidaMP.SelectedValue = "-1" OrElse DdlAlmacenTerminado.SelectedValue = "-1" Then Alert("Selecciona ambos almacenes.", TipoMensaje.MsgAdvertencia) Exit Sub End If - ' Dim TotalCantidad As Decimal = DtMovimientos.SUMD("Cantidad") - 'Inicia la transacción + For Each row As GridViewRow In GvProductoTerminado.Rows + Dim txtCantidad As TextBox = DirectCast(row.FindControl("TxtCantidadPT"), TextBox) + Dim cantidadIngresada As Decimal = txtCantidad.Text.ToDecimal() + Dim cantidadOriginal As Decimal = txtCantidad.Attributes("data-original").ToDecimal() - Dim CveMovimientoSalida As Integer = 0 + If cantidadIngresada > cantidadOriginal Then + Alert("La cantidad del producto terminado no puede superar lo solicitado.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + Next + + + For Each row As GridViewRow In GvMPUtilizada.Rows + Dim txtDevolucion As TextBox = DirectCast(row.FindControl("TxtDevolucionMP"), TextBox) + Dim devolucionIngresada As Decimal = txtDevolucion.Text.ToDecimal() + Dim cantidadOriginal As Decimal = txtDevolucion.Attributes("data-original").ToDecimal() + + If devolucionIngresada > cantidadOriginal Then + Alert("La devolución no puede superar la cantidad de materia prima solicitada.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + Next + + Dim CveMovimientoSalida As Integer = 1 Dim CveMovimientoEntrada As Integer = 0 Dim IDPoliza As Integer = 0 Dim FolioSalida As Integer = 0 @@ -844,39 +1106,143 @@ Partial Class OP_OP Dim ErrorMovInv As Boolean = False Dim TextoError As String = "" Dim TipoMovimientoSalida As Integer = 8 + Dim TipoMovimientoDev As Integer = 33 Dim CveConceptoEntrada As Integer = 9 Dim TotalCostoMP As Decimal = 0 + 'Dim TotalDevoluciones As Decimal = 0 + Dim CveMovimientoDev As Integer = 0 + Dim CostoDevoluciones As Decimal = 0 + Dim ObjInventario As New ClsInventarios() ObjInventario.IniciaTransacSQL() Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) Dim ObjOP As New ClsOP(ObjInventario.IniciaTransacSQL()) + Dim TotalMPProducto As Decimal = 0 + Dim TotalMOProducto As Decimal = 0 + Dim TotalCIProducto As Decimal = 0 + Try - - CveMovimientoSalida = ObjInventario.AddMovimiento(DdlAlmacenOrigenSalidaMP.SelectedValue.ToEntero(), TipoMovimientoSalida, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:="Finalización OP #" & LblFolio.Text, Modulo:="OP/FinalizarOPSalida") - + 'Salida de MP + CveMovimientoSalida = ObjInventario.AddMovimiento(DdlAlmacenOrigenSalidaMP.SelectedValue.ToEntero(), TipoMovimientoSalida, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:="Finalización OP #" & LblFolio.Text, Modulo:="OP/FinalizarOPSalida", CveOP:=CveOP) + FolioEntrada = ObjInventario.Folio + Dim DtMPAlmacen As DataTable = Nothing If CveMovimientoSalida > 0 Then - For Each rowMP As DataRow In DtMP.Select("Tipo = 'MP'") - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, rowMP("Cantidad").ToString.ToDecimal(), rowMP("CveUMMateriaPrima").ToString.ToEntero(), rowMP("CvePSMateriaPrima").ToString.ToEntero(), 1) Then - ErrorMovInv = True : TextoError = "x" : Exit For + For Each rowMP As DataRow In DtMP.Select("Tipo = 'MP'") + Dim CvePS As Integer = rowMP("CvePSMateriaPrima").ToString.ToEntero + Dim CveUM As Integer = rowMP("CveUMMateriaPrima").ToString.ToEntero + Dim Cantidad As Decimal = rowMP("Cantidad").ToString.ToDecimal + + + ' Registrar detalle + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Cantidad, CveUM, CvePS, 0) Then + ErrorMovInv = True + Exit For End If Next - If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then - TotalCostoMP = ObjInventario.DtResultados.SUMD("Total") + + If Not ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then + Throw New Exception("Error al cargar detalles del inventario") + End If + DtMPAlmacen = ObjInventario.DtResultados.Copy() + + ' 5. Calcular TotalCostoMP + TotalCostoMP = ObjInventario.DtResultados.SUMD("Total") + + ' 1. Recorrer cada Producto Terminado en la OP + For Each rowProducto As DataRow In DtPS.Select("Tipo = 'Producto'") + Dim CvePSProducto As Integer = rowProducto("CvePS").ToString.ToEntero() + Dim CantidadProducto As Decimal = rowProducto("Cantidad").ToString.ToDecimal() + Dim MPProducto As Decimal = 0 + Dim MOProducto As Decimal = 0 + Dim CIProducto As Decimal = 0 + + ' 2. Calcular Costo de Materias Primas por Producto + For Each rowMP As DataRow In DtMP.FiltraParametros($"CvePS = {CvePSProducto}").Rows + Dim CvePSMP As Integer = rowMP("CvePSMateriaPrima").ToString.ToEntero() + Dim CveUMMP As Integer = rowMP("CveUMMateriaPrima").ToString.ToEntero() + Dim PU As Decimal = DtMPAlmacen.FiltroPrimeroValor("PU", $"CvePS = {CvePSMP}").ToDecimal() + MPProducto += rowMP("Cantidad").ToString().ToDecimal() * PU + Next + + ' 3. Calcular Mano de Obra por Producto + For Each rowMO As DataRow In DtMO.FiltraParametros($"CvePS = {CvePSProducto}").Rows + MOProducto += rowMO("Total").ToString.ToDecimal() + Next + + ' 4. Calcular Costos Indirectos por Producto + For Each rowCI As DataRow In DtCI.FiltraParametros($"CvePSProducto = {CvePSProducto}").Rows + CIProducto += rowCI("Total").ToString.ToDecimal() + Next + ' 5. Determinar las devoluciones del Producto + Dim TotalDevPT As Decimal = GvMPUtilizada.Rows.Cast(Of GridViewRow)().Where(Function(row) GvMPUtilizada.DataKeys(row.RowIndex).Values(0).ToString().ToEntero() = CvePSProducto).Sum(Function(row) DirectCast(row.FindControl("TxtDevolucionMP"), TextBox).Text.ToDecimal()) + + ' 6. Sumar Total por Producto (MP + MO + CI) + Dim TotalProducto As Decimal = MPProducto + MOProducto + CIProducto - TotalDevPT + + rowProducto("Costo") = TotalProducto + + TotalMPProducto += MPProducto + TotalMOProducto += MOProducto + TotalCIProducto += CIProducto + Next + + DtPS.AcceptChanges() + + ' 2. PROCESAR DEVOLUCIONES SI EXISTEN + If Not ErrorMovInv Then + Dim TotalDevoluciones As Decimal = GvMPUtilizada.Rows.Cast(Of GridViewRow)().Sum(Function(row) DirectCast(row.FindControl("TxtDevolucionMP"), TextBox).Text.ToDecimal()) + + If TotalDevoluciones > 0 Then + If DdlAlmacenDevolucion.SelectedValue = "-1" Then + Alert("Seleccione almacén para devoluciones", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + CveMovimientoDev = ObjInventario.AddMovimiento(DdlAlmacenDevolucion.SelectedValue.ToEntero(), TipoMovimientoDev, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=$"Devolución OP #{LblFolio.Text}", Modulo:="OP/Devoluciones", CveMovimientoRelacionado:=CveMovimientoSalida, CveOP:=CveOP) + + If CveMovimientoDev > 0 Then + For Each row As GridViewRow In GvMPUtilizada.Rows + Dim Devolucion As Decimal = row.FCTextBox("TxtDevolucionMP").Text.ToDecimal() + If Devolucion > 0 Then + Dim CvePS As Integer = row.DataKey("CvePSMateriaPrima").ToEntero 'GvMPUtilizada.DataKeys(row.RowIndex)("CvePSMateriaPrima").ToString.ToEntero() + Dim CveUM As Integer = row.DataKey("CveUMMateriaPrima").ToEntero 'GvMPUtilizada.DataKeys(row.RowIndex)("CveUMMateriaPrima").ToString.ToEntero() + + + Dim PU As Decimal = DtMPAlmacen.FiltroPrimeroValor("PU", $"CvePS = {CvePS} AND CveUM = {CveUM}").ToDecimal() + + If Not ObjInventario.AddMovimientoDetalle( + CveMovimientoDev, + Devolucion, + CveUM, + CvePS, + PU + ) Then + ErrorMovInv = True + End If + + CostoDevoluciones += Devolucion * PU + End If + Next + End If + End If End If + 'ENTRADA DE PRODUCTO TERMINADO If Not ErrorMovInv Then - CveMovimientoEntrada = ObjInventario.AddMovimiento(DdlAlmacenTerminado.SelectedValue.ToEntero(), CveConceptoEntrada, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:="Finalización OP #" & LblFolio.Text, Modulo:="OP/FinalizarOPEntrada", CveMovimientoRelacionado:=CveMovimientoSalida) + CveMovimientoEntrada = ObjInventario.AddMovimiento(DdlAlmacenTerminado.SelectedValue.ToEntero(), CveConceptoEntrada, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:="Finalización OP #" & LblFolio.Text, Modulo:="OP/FinalizarOPEntrada", CveMovimientoRelacionado:=CveMovimientoSalida, CveOP:=CveOP) End If If CveMovimientoEntrada > 0 AndAlso Not ErrorMovInv Then - Dim CantidadPT As Decimal = DtPS.AsEnumerable().Sum(Function(row) Convert.ToDecimal(row("Cantidad"))) - Dim PU_PT As Decimal = If(CantidadPT > 0, TotalCostoMP / CantidadPT, 1) + Dim CostoTotalProduccion As Decimal = TotalMPProducto + TotalMOProducto + TotalCIProducto + Dim CostoPTAjustado As Decimal = CostoTotalProduccion - CostoDevoluciones + 'Dim CantidadPT As Decimal = DtPS.AsEnumerable().Sum(Function(r) r.Field(Of Decimal)("Cantidad")) + 'Dim PU_PT As Decimal = If(CantidadPT > 0, CostoPTAjustado / CantidadPT, 0) For Each rowPT As DataRow In DtPS.Select("Tipo = 'Producto'") - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, rowPT("Cantidad").ToString.ToDecimal(), rowPT("CveUM").ToString.ToEntero(), rowPT("Clave").ToString.ToEntero(), PU_PT) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, rowPT("Cantidad").ToString.ToDecimal(), rowPT("CveUM").ToString.ToEntero(), rowPT("CvePS").ToString.ToEntero(), rowPT("Costo").ToString.ToDecimal()) Then ErrorMovInv = True : TextoError = "x" : Exit For End If Next @@ -885,28 +1251,35 @@ Partial Class OP_OP Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/OPFinalizada", 53, 0, 0, 1, Fecha, "Producción OP #" & LblFolio.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - If CvePrePoliza > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TotalCostoMP, TotalCostoMP, 68, "Consumo MP OP #" & LblFolio.Text, "Consumo MP OP #" & LblFolio.Text, CveMovimientoAlmacen:=CveMovimientoSalida) Then - ErrorMovInv = True - End If - - If Not ErrorMovInv AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TotalCostoMP, TotalCostoMP, 68, "Producción PT OP #" & LblFolio.Text, "Producción PT OP #" & LblFolio.Text, CveMovimientoAlmacen:=CveMovimientoEntrada) Then - ErrorMovInv = True - End If - - If Not ErrorMovInv Then - - If Not ObjOP.UpdateEstatusOP(CveOP, 3, UsuarioActual.CveEmpresa) Then - ErrorMovInv = True : TextoError = "Error al actualizar estatus de la OP" + If CvePrePoliza > 0 Then + 'salida MP + If CvePrePoliza > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TotalCostoMP, TotalCostoMP, 68, "Consumo MP OP #" & LblFolio.Text, "Consumo MP OP #" & LblFolio.Text, CveMovimientoAlmacen:=CveMovimientoSalida) Then + ErrorMovInv = True + End If + ' entrada PT + If Not ErrorMovInv AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, CostoPTAjustado, CostoPTAjustado, 68, "Producción PT OP #" & LblFolio.Text, "Producción PT OP #" & LblFolio.Text, CveMovimientoAlmacen:=CveMovimientoEntrada) Then + ErrorMovInv = True + End If + 'dev MP + If Not ErrorMovInv AndAlso CostoDevoluciones <> 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, CostoDevoluciones, CostoDevoluciones, 68, "Devoluciones PT OP #" & LblFolio.Text, "Devoluciones PT OP #" & LblFolio.Text, CveMovimientoAlmacen:=CveMovimientoDev) Then + ErrorMovInv = True + End If + 'costo indirecto + If Not ErrorMovInv AndAlso TotalCIProducto <> 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TotalCIProducto, TotalCIProducto, 95, "Costo Indirecto PT OP #" & LblFolio.Text, "Costo Indirecto PT OP #" & LblFolio.Text) Then + ErrorMovInv = True + End If + 'mano de obra + If Not ErrorMovInv AndAlso TotalCIProducto <> 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TotalMOProducto, TotalMOProducto, 95, "Mano de Obra PT OP #" & LblFolio.Text, "Mano de Obra PT OP #" & LblFolio.Text) Then + ErrorMovInv = True End If End If - 'If Not ErrorMovInv Then - ' If Not ObjConta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual) Then - ' ErrorMovInv = True : TextoError = "Error en validación de póliza" - ' ElseIf ObjConta.ValorPolizaDescuadre > 0 Then - ' ErrorMovInv = True : TextoError = "Descuadre en póliza contable" - ' End If + 'If Not ObjConta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual) Then + 'ErrorMovInv = True : TextoError = "Error en validación de póliza" + 'ElseIf ObjConta.ValorPolizaDescuadre > 0 Then + ' ErrorMovInv = True : TextoError = "Descuadre en póliza contable" + 'End If 'End If End If End If @@ -914,16 +1287,32 @@ Partial Class OP_OP If Not ErrorMovInv Then - ObjInventario.Commit() - Alert($"Orden de producción finalizada. -
    {ObjInventario.Folio} ", TipoMensaje.MsgInformacion) + If ObjOP.UpdateEstatusOP(CveOP, CveEstatusFinalizar, UsuarioActual.CveEmpresa) Then + ObjInventario.Commit() + TxtEstatus.Text = EstatusFinalizar + DeshabilitarControles() + UpOP.Update() + UpGvDatosOP.Update() + Alert("Orden de producción finalizada.
    " & "" & FolioEntrada & "", + TipoMensaje.MsgInformacion) + + + + RegistraScript("$('#DVModalFinalizarOP').modal('hide');") + + + Else + ObjInventario.RollBack() + Alert("Error al actualizar el estatus.", TipoMensaje.MsgError) + End If + Else ObjInventario.RollBack() Alert($"Error contable: {TextoError}", TipoMensaje.MsgError) End If - RegistraScript("$('#DVModalFinalizarOP').modal('hide');") - CargaDatos() + + Catch ex As Exception ObjInventario.RollBack() @@ -933,7 +1322,6 @@ Partial Class OP_OP ObjConta.Dispose() End Try - End Sub #End Region End Class diff --git a/Sistemas/UsuarioDetalle.aspx.vb b/Sistemas/UsuarioDetalle.aspx.vb index 46a4906b3..3113d2ecc 100644 --- a/Sistemas/UsuarioDetalle.aspx.vb +++ b/Sistemas/UsuarioDetalle.aspx.vb @@ -1382,13 +1382,14 @@ Partial Class Sistemas_UsuarioDetalle ' End If 'RECARGA GLOBAL ESTATUS - GlobalDTOCEstatusUsuarios(tCveEmpresa) = Nothing - - 'If ObjOC.GetEstatusUsuarios(-1, -1, -1, -1, -1) Then Application("GlobalDTOCEstatusUsuarios") = ObjOC.DtResultados Else Application("GlobalDTOCEstatusUsuarios") = Nothing - - - 'RECARGA GLOBAL ALMACEN - 'If ObjUsuarios.GetAlmacen(-1, UsuarioActual.CveEmpresa) Then Application("GlobalDTAlmacenUsuarios") = ObjUsuarios.DtResultados Else Application("GlobalDTAlmacenUsuarios") = Nothing + GlobalDTOCEstatus(tCveEmpresa) = Nothing + GlobalDTOCEstatusUsuarios(tCveEmpresa) = Nothing + + 'If ObjOC.GetEstatusUsuarios(-1, -1, -1, -1, -1) Then Application("GlobalDTOCEstatusUsuarios") = ObjOC.DtResultados Else Application("GlobalDTOCEstatusUsuarios") = Nothing + + + 'RECARGA GLOBAL ALMACEN + 'If ObjUsuarios.GetAlmacen(-1, UsuarioActual.CveEmpresa) Then Application("GlobalDTAlmacenUsuarios") = ObjUsuarios.DtResultados Else Application("GlobalDTAlmacenUsuarios") = Nothing GlobalDTAlmacenUsuarios(-1, tCveEmpresa) = Nothing 'RECARGA GLOBAL EMPRESAS USUARIOS diff --git a/Ventas/ActualizarPrecios.aspx.vb b/Ventas/ActualizarPrecios.aspx.vb index a09d59cb4..3aaa0ed3a 100644 --- a/Ventas/ActualizarPrecios.aspx.vb +++ b/Ventas/ActualizarPrecios.aspx.vb @@ -315,6 +315,14 @@ Partial Class Ventas_ActualizarPrecios GvMultiple.DataBind() End If + 'sms, ocultar las últimos 2 columnas, solo mostrar la columna de precio + If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then + If Not UsuarioActual.TienePermisoProceso(201) Then 'puede ver importes de inventario + GvMultiple.Columns(GvMultiple.Columns.Count - 1).Visible = False + GvMultiple.Columns(GvMultiple.Columns.Count - 2).Visible = False + End If + End If + UpDescargar.Update() UpDatos.Update() UPPrecioLista.Update() @@ -998,7 +1006,6 @@ Partial Class Ventas_ActualizarPrecios Dim TxtId As String = "TxtPrecio_" + (colIndex - 1).ToString() If indiceColumna <= DtPreciosMultiple.Columns.Count - 1 Then - Dim CvePrecioLista As Integer = GvMultiple.HeaderRow.FCLabel(LtlId).Attributes().Item("cvepreciolista").ToEntero() Dim Precio As Decimal = GvRow.FCTextBox(TxtId).Text.ToDecimal() TieneError = Not ObjPS.UpdatePSPreciosLista(Precio, CvePrecioLista, 0, CvePS, UsuarioActual.CveUsuario, NowADS(), True) @@ -1009,30 +1016,23 @@ Partial Class Ventas_ActualizarPrecios Dim splitValues As String() = text.Split("|"c) If splitValues.Length > 1 Then - Dim PrecioLista As String = splitValues(1) - Dim DrPS = DtPS.FiltroPrimero($"CvePS = {CvePS}") If DrPS IsNot Nothing Then TieneError = ActualizarPreciosFranquicia(ObjPS, DrPS("Codigo").ToString(), Precio, 0, PrecioLista, UpdatePrecioMinimo:=False) Else TieneError = True End If - End If - Else Exit For End If - If TieneError Then Exit For End If End If - Next End If - Next Catch ex As Exception OnError("Ocurrió un error al actualizar precios", ex) diff --git a/Ventas/Clientes.aspx b/Ventas/Clientes.aspx index 320c35caf..97a0b5725 100644 --- a/Ventas/Clientes.aspx +++ b/Ventas/Clientes.aspx @@ -1901,9 +1901,9 @@
    - - - + + +
    diff --git a/Ventas/Clientes.aspx.vb b/Ventas/Clientes.aspx.vb index 3a92c0b96..92714d0e2 100644 --- a/Ventas/Clientes.aspx.vb +++ b/Ventas/Clientes.aspx.vb @@ -1765,8 +1765,6 @@ Partial Class Clientes If array(4) = "1" Then ChkRevViernes.Checked = True If array(5) = "1" Then ChkRevSabado.Checked = True End If - - ChkInformacionCompleta.Checked = Boolean.Parse(ObjClientes.DtResultados(0)("InformacionCompleta").ToString()) 'Horario @@ -2578,39 +2576,38 @@ Partial Class Clientes Alert("El uso del cfdi debe ser 'S01 - Sin efectos fiscales' cuando se utiliza el RFC genérico.", TipoMensaje.MsgAdvertencia) Exit Sub - End If Dim InformacionCompleta As Boolean = True 'validación de información completa If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then - + Dim tPagare As Integer = 0 If TxtRFC.Text.Trim() = "" Then InformacionCompleta = False If ChkPermiteCredito.Checked Then If TxtLimiteCredito.Text.ToDecimal = 0 OrElse TxtCobranzaContacto.Text.Trim = "" OrElse TxtCobranzaTelefono.Text.Trim = "" OrElse TxtDiasEspecifico.Text.Trim = "" OrElse TxtCobranzaCorreo.Text.Trim = "" Then InformacionCompleta = False End If + 'si es el concepto de pagaré + tPagare = 0 + For Each dRow As GridViewRow In GvDocumentosCliente.Rows + Dim CveDocumentacion As Integer = dRow.DataKey("CveDocumentacion").ToEntero() + If CveDocumentacion = 265 Then + If dRow.FCTextBox("TxtFechaVigencia").Text.ToDate > Now Then tPagare = 1 + End If + Next + If tPagare = 0 Then InformacionCompleta = False + If GvClentesPersonalEntrega.Rows.Count = 0 Then InformacionCompleta = False + End If - If TxtContacto.Text.Trim() = "" Then InformacionCompleta = False If TxtTelefono.Text.Trim() = "" Then InformacionCompleta = False If TxtEmail.Text.Trim() = "" Then InformacionCompleta = False - If TxtRepresentanteLegal.Text.Trim() = "" Then InformacionCompleta = False - 'si es el concepto de pagaré - Dim tPagare As Integer = 0 - For Each dRow As GridViewRow In GvDocumentosCliente.Rows - Dim CveDocumentacion As Integer = dRow.DataKey("CveDocumentacion").ToEntero() - If CveDocumentacion = 265 Then tPagare = 1 - Next - If tPagare = 0 Then InformacionCompleta = False - tPagare = 0 'valida que cuando menos tenga una cuenta - For Each dRow As GridViewRow In GvBancosCuentas.Rows - tPagare = 1 - Next - If tPagare = 0 Then InformacionCompleta = False - 'If DivInfoCompleta.Visible Then - ' InformacionCompleta = ChkInformacionCompleta.Checked - 'End If + 'SOLO VALIDA EN CLIENTES FRECUENTE + If DdlTipoCliente.SelectedValue = "1" Then + If TxtContacto.Text.Trim() = "" Then InformacionCompleta = False + If TxtRepresentanteLegal.Text.Trim() = "" Then InformacionCompleta = False + + End If End If 'CargaSucursal() diff --git a/Ventas/ClientesAbonar.aspx.vb b/Ventas/ClientesAbonar.aspx.vb index 32fa60b0e..184fd643b 100644 --- a/Ventas/ClientesAbonar.aspx.vb +++ b/Ventas/ClientesAbonar.aspx.vb @@ -4,7 +4,6 @@ Imports System.Data Imports ADSTimbrado Imports Extensiones -Imports Org.BouncyCastle.Ocsp Partial Class Ventas_ClientesAbonar Inherits ClsPaginas @@ -743,6 +742,36 @@ Partial Class Ventas_ClientesAbonar Exit Sub End If + If UsuarioActual.Empresa.Funcionalidad(382) = "1" AndAlso RblTipoPago.SelectedValue = "3" Then + Dim DtSaldo As DataTable = Nothing + Dim ObjMovto As New ClsMovimientos + If ObjMovto.GetIngresosSaldosDetalle(CveCliente, -1, UsuarioActual.CveEmpresa) Then + DtSaldo = ObjMovto.DtResultados.FiltraParametros($"CveIE={DdlIngreso.SelectedValue.ToEntero()}") + End If + ObjMovto.Dispose() + + If DtSaldo IsNot Nothing AndAlso DtSaldo.Rows.Count = 1 Then + Dim ImporteRef As Decimal = DtSaldo.SUM("Saldo", $"CveIE={DdlIngreso.SelectedValue.ToEntero()}") + Dim ImporteAbonar As Decimal = 0 + + For Each gvr As GridViewRow In GvCxC.Rows + If gvr.FCCheckBox("Chk").Checked Then + ImporteAbonar += gvr.FCTextBox("TxtAbonar").Text.ToDecimal() + End If + Next + ImporteAbonar += TxtAnticipo.Text.ToDecimal() + + If ImporteRef.RoundSQL(2) <> ImporteAbonar.RoundSQL(2) Then + Alert("El importe abonado es diferente al saldo del ingreso", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + Else + Alert("No se pudieron validar los saldos", TipoMensaje.MsgError) + Exit Sub + End If + + End If + Dim Cuenta As String = "" Dim CuentaDeposito As String = "" diff --git a/Ventas/PVCobranza.aspx b/Ventas/PVCobranza.aspx index 1178e920e..6e138db07 100644 --- a/Ventas/PVCobranza.aspx +++ b/Ventas/PVCobranza.aspx @@ -342,7 +342,7 @@
    -
    +
    @@ -371,16 +371,16 @@ DataKeyNames="CveVenta,CveCliente,TipoDocto,Saldo,AtencionA,CveFormaPago33,SerieFolio,CondicionesPago,PlazoCobranza"> <%----%> - +
    - - - - + + + +
    -
    +
    @@ -685,13 +685,13 @@
    $ - +
    -
    +
    $ @@ -700,13 +700,13 @@
    -
    +
     
    $ - +
    @@ -1239,8 +1239,7 @@ " style="display: inline-block; margin-right: -20px; width: 150px;" /> " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info">
    -
    -
    +
    Total: @@ -1250,7 +1249,7 @@ + DataKeyNames="ISTotal,Saldo,CveIE,Folio,Tipo,CveVenta,CveConceptoContable,CveConceptoContableAmor, TotalAnticipo, SubTotalAnticipo, IVAAnticipo,IEPS, ImpuestosLocalesAnticipo, SubTotalAmortizacion, SubTotal, Original, IVA, RetIVA, RetISR, FolioFiscal, CveClasificacionNC, TipoCambio,TipoCambioPago,TipoCambioHoy, CveMoneda,Fecha,SaldoSubTotal,SaldoConImpuestos,RegresarImpuesto,DevolucionImportePagado,CveCliente,Descuentos,CveFormaPago"> @@ -1539,8 +1538,6 @@ } $("#LblTotalAnticipos").text(FormatoNumero(FnSumaValoresAnt(), 2)); - - // $get('HdnVentaSaldo').value = Total - FnSumaValoresAnt(); } function FnSumaValoresAnt() { @@ -1583,15 +1580,24 @@ HdnSobranteFaltante.value = "0"; //HdnCambioFaltante.value = "1"; let cambio = total - totalVenta; - if (cambio > 1) { + if (cambio > 1 || totalEfectivo > 0) { $get("TxtFaltante").value = ""; $get("ChkSobFaltante").checked = false; $get("TxtCambio").value = FormatoNumero(cambio); } else { - $get("TxtFaltante").value = FormatoNumero(cambio); - $get("ChkSobFaltante").checked = true; - $get("TxtCambio").value = FormatoNumero(cambio); + //SOLO ACTIVAR SI NO HAY EFECTIVO + if (totalEfectivo == 0) { + if (cambio == 'NaN') { + $get("TxtFaltante").value = "0.00"; + } else { + $get("TxtFaltante").value = FormatoNumero(cambio); + } + + $get("ChkSobFaltante").checked = true; + $get("TxtCambio").value = ""; + } + } } else { @@ -1617,15 +1623,71 @@ $('#C_LblDiferenciaCajaBloqueo').val(FormatoNumero(total)); } + function ValidaSobranteFaltante() { + + let sobFaltantePermitido = 1; + + if (<%= If(UsuarioActual.Empresa.CveEmpresa = 189, 1, 0)%> == 1) { + sobFaltantePermitido = 10; + } + + let totalEfectivo = $get("TxtImporteEfectivo") ? ToDouble($get("TxtImporteEfectivo").value) : 0; + + if (totalEfectivo > 0) { + sobFaltantePermitido = 0; + } + + if (sobFaltantePermitido > 0) { + if (ToDouble($get("TxtFaltante").value) > sobFaltantePermitido) { + alert("El sobrante/faltante no debe ser mayor a " + sobFaltantePermitido); + $get("TxtFaltante").value = ""; + $get("ChkSobFaltante").checked = false; + } else { + $get("ChkSobFaltante").checked = true; + } + } else { + alert("El sobrante/faltante no esta permitido"); + $get("TxtFaltante").value = ""; + $get("ChkSobFaltante").checked = false; + } + + + } + function CargaSobranteFaltante() { $('#ChkSobFaltante').change(function () { if (this.checked == true) { - if (ToDouble($get("TxtCambio").value) > 1) { - alert("El sobrante/faltante no debe ser mayor a 1") - } else { - $get("TxtFaltante").value = $get("TxtCambio").value; + let sobFaltantePermitido = 1; + + if (<%= If(UsuarioActual.Empresa.CveEmpresa = 189, 1, 0)%> == 1) { + sobFaltantePermitido = 10; } - + + let totalEfectivo = $get("TxtImporteEfectivo") ? ToDouble($get("TxtImporteEfectivo").value) : 0; + + if (totalEfectivo > 0) { + sobFaltantePermitido = 0; + } + + if (sobFaltantePermitido > 0) { + if (ToDouble($get("TxtCambio").value) > sobFaltantePermitido) { + alert("El sobrante/faltante no debe ser mayor a " + sobFaltantePermitido) + $get("ChkSobFaltante").checked = false; + } else { + if ($get("TxtCambio").value == 'NaN') { + $get("TxtFaltante").value = "0.00"; + } else { + $get("TxtFaltante").value = $get("TxtCambio").value; + } + } + } else { + alert("El sobrante/faltante no esta permitido"); + $get("TxtFaltante").value = ""; + $get("ChkSobFaltante").checked = false; + } + + + } else { $get("TxtFaltante").value = ""; diff --git a/Ventas/PVCobranza.aspx.vb b/Ventas/PVCobranza.aspx.vb index efa42fdd2..cc878b939 100644 --- a/Ventas/PVCobranza.aspx.vb +++ b/Ventas/PVCobranza.aspx.vb @@ -520,7 +520,7 @@ Partial Class Ventas_PVCobranza HdnVentaCondicionesPago.Value = GvRow.DataKey("CondicionesPago") HdnPlazoCobranza.Value = GvRow.DataKey("PlazoCobranza") - If UsuarioActual.CveEmpresa.Contiene(189, 193, 195, 196, 197) AndAlso GvRow.DataKey("TipoDocto") = "Rem" Then + If UsuarioActual.CveEmpresa.Contiene(189, 193, 195, 196, 197) AndAlso GvRow.DataKey("TipoDocto").Contiene("Rem", "Ant") Then DivAnticipo.Visible = True ImgAntiPend.Visible = True End If @@ -593,13 +593,19 @@ Partial Class Ventas_PVCobranza Faltante = Math.Abs(TxtFaltante.Text.ToDecimal()) End If - If Faltante > 1 Then - Alert("El faltante no puede ser mayor a 1.00", TipoMensaje.MsgAdvertencia) + Dim sobFaltantePermitido = 1 + + If UsuarioActual.CveEmpresa = 189 Then + sobFaltantePermitido = 10 + End If + + If Faltante > sobFaltantePermitido Then + Alert($"El faltante no puede ser mayor a {sobFaltantePermitido}", TipoMensaje.MsgAdvertencia) Exit Sub End If - If Sobrante > 1 Then - Alert("El sobrante no puede ser mayor a 1.00", TipoMensaje.MsgAdvertencia) + If Sobrante > sobFaltantePermitido Then + Alert($"El sobrante no puede ser mayor a {sobFaltantePermitido}", TipoMensaje.MsgAdvertencia) Exit Sub End If @@ -607,6 +613,11 @@ Partial Class Ventas_PVCobranza Alert("No hay importe para sobrante/faltante", TipoMensaje.MsgAdvertencia) Exit Sub End If + Else + If TxtFaltante.Text.ToDecimal() <> 0 Then + Alert("No debe especificar sobrante/faltante", TipoMensaje.MsgAdvertencia) + Exit Sub + End If End If 'validaciones @@ -662,7 +673,15 @@ Partial Class Ventas_PVCobranza End If End If - Dim tCveCorte As Integer = CveCorte + Dim DebeTenerCorteCaja As Boolean = UsuarioActual.TienePermisoProceso(371) ' Usa Cortes de Caja - en Cajas + + Dim tCveCorte As Integer = If(DebeTenerCorteCaja, Me.CveCorte, -1) + + If DebeTenerCorteCaja AndAlso tCveCorte <= 0 Then + Alert("No se puede realizar el pago. Debe tener un corte activo", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + Dim CveVenta As Integer = HdnCveVenta.Value.ToEntero Dim CveVentaRemision As Integer = -1 @@ -701,7 +720,7 @@ Partial Class Ventas_PVCobranza Dim PedidoContrato = DbRowVenta("PedidoContrato").ToString() Dim OrdenCompra = DbRowVenta("OrdenCompra").ToString() - If tCveCorte <= 0 AndAlso DbRowVenta("CveCorte").ToString.ToEntero > 0 Then tCveCorte = DbRowVenta("CveCorte").ToString.ToEntero + 'If tCveCorte <= 0 AndAlso DbRowVenta("CveCorte").ToString.ToEntero > 0 Then tCveCorte = DbRowVenta("CveCorte").ToString.ToEntero Dim CvePrePoliza As Integer = -1 Dim Fecha As Date = DbRowVenta("Fecha").ToString.ToDate 'NowADS() @@ -730,7 +749,7 @@ Partial Class Ventas_PVCobranza CveVentaRemision = HdnCveVenta.Value.ToEntero - respFactura = GenerarFactura(CveVendedor, VentaActual, ObjVentas2, ObjClientes, ObservacionesAlmacen, VentaContado, PlazoCobranza, Observaciones, PedidoContrato, OrdenCompra) + respFactura = GenerarFactura(tCveCorte, CveVendedor, VentaActual, ObjVentas2, ObjClientes, ObservacionesAlmacen, VentaContado, PlazoCobranza, Observaciones, PedidoContrato, OrdenCompra) If respFactura Is Nothing Then MsgError = "Ocurrió un error al generar la factura" @@ -880,7 +899,7 @@ Partial Class Ventas_PVCobranza MsgError = "Tiene saldo pendiente por aplicar" End If - If UsuarioActual.CveRol <> 1 Then + If DebeTenerCorteCaja Then If MsgError = "" AndAlso Not ObjVentas2.UpdateVentaCorte(CveVenta, UsuarioActual.CveEmpresa, tCveCorte) Then MsgError = "Error al aplicar el corte" End If @@ -951,7 +970,7 @@ Partial Class Ventas_PVCobranza GuardaLog(ex.ToString()) End Try - If MsgError = "" AndAlso Not ChkSobFaltante.Checked Then + If MsgError = "" Then If ObjConta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual, Opcion:=5, CveVenta:=CveVenta) Then If ObjConta.ValorPolizaDescuadre > 0 Then GuardaLogAD($"Ventas/Ventas-NCGeneradas | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") @@ -1024,12 +1043,12 @@ Partial Class Ventas_PVCobranza If respFactura IsNot Nothing AndAlso respFactura.Factura IsNot Nothing AndAlso respFactura.Factura.DtAnticiposAplicados IsNot Nothing Then For Each dr As DataRow In respFactura.Factura.DtAnticiposAplicados.Rows - msBuild.AppendLine($"
    Imprimir Saldo Aplicado {dr("Folio").ToString}
    ") + respFactura.Factura.Total, dr("Tipo")))}"">Imprimir Saldo Aplicado {dr("Folio").ToString}
    ") Next End If @@ -1064,12 +1083,12 @@ Partial Class Ventas_PVCobranza If respNC IsNot Nothing AndAlso respNC.Factura IsNot Nothing AndAlso respNC.Factura.DtAnticiposAplicados IsNot Nothing Then For Each dr As DataRow In respNC.Factura.DtAnticiposAplicados.Rows - msBuild.AppendLine($"
    Imprimir Saldo Aplicado {dr("Folio").ToString}
    ") + respNC.Factura.Total, dr("Tipo")))}"">Imprimir Saldo Aplicado {dr("Folio").ToString}
    ") Next End If @@ -1264,7 +1283,7 @@ Partial Class Ventas_PVCobranza UpL.Update() End Sub - Private Function GenerarFactura(CveVendedor As Integer, ByRef VentaRemision As Venta, ByRef ObjVentas As ClsVentas, ByRef ObjClientes As ClsClientes, ObservacionesAlmacen As String, VentaConta As Boolean, PlazoCobranza As Integer, Observaciones As String, PedidoContrato As String, OrdenCompra As String) As Modelos.Factura.MMensajeFactura + Private Function GenerarFactura(CveCorte As Integer, CveVendedor As Integer, ByRef VentaRemision As Venta, ByRef ObjVentas As ClsVentas, ByRef ObjClientes As ClsClientes, ObservacionesAlmacen As String, VentaConta As Boolean, PlazoCobranza As Integer, Observaciones As String, PedidoContrato As String, OrdenCompra As String) As Modelos.Factura.MMensajeFactura Dim Retorno As Modelos.Factura.MMensajeFactura = Nothing Dim SbAlert As New StringBuilder() Dim SBAmortizaciones As New StringBuilder @@ -1305,6 +1324,7 @@ Partial Class Ventas_PVCobranza Dim DtPagos As DataTable = New DataTable("DtPagosFactura") DtPagos.Columns.Add(New DataColumn("CveFormaPago", GetType(Integer))) DtPagos.Columns.Add(New DataColumn("Importe", GetType(Decimal))) + Dim PagadoSinEfectivo As Decimal = 0 If VentaConta Then If TxtImporteCredito.Text.ToDecimal > 0 Then DtPagos.Rows.Add({4, TxtImporteCredito.Text.ToDecimal}) : PagadoSinEfectivo += TxtImporteCredito.Text.ToDecimal @@ -1315,7 +1335,19 @@ Partial Class Ventas_PVCobranza If TxtImporteTransferencia.Text.ToDecimal > 0 Then DtPagos.Rows.Add({3, TxtImporteTransferencia.Text.ToDecimal}) : PagadoSinEfectivo += TxtImporteTransferencia.Text.ToDecimal - If TxtNCDev.Text.ToDecimal > 0 Then DtPagos.Rows.Add({21, TxtNCDev.Text.ToDecimal}) : PagadoSinEfectivo += TxtNCDev.Text.ToDecimal + 'If TxtNCDev.Text.ToDecimal > 0 Then DtPagos.Rows.Add({21, TxtNCDev.Text.ToDecimal}) : PagadoSinEfectivo += TxtNCDev.Text.ToDecimal + + If TxtNCDev.Text.ToDecimal > 0 Then + For Each GvRow As GridViewRow In GVAnticipos.Rows + If GvRow.DataKey("Tipo").Contiene("NC", "IxC", "Ant") AndAlso GvRow.FCCheckBox("Chk" & GvRow.RowIndex) IsNot Nothing AndAlso GvRow.FCCheckBox("Chk" & GvRow.RowIndex).Checked Then + + Dim CveFormaPagoAnt = GvRow.DataKey("CveFormaPago").ToEntero() + Dim Importe = GvRow.FCTextBox(String.Format("TxtAnticipo{0}", GvRow.RowIndex)).Text.ToDecimal() + + DtPagos.Rows.Add({CveFormaPagoAnt, Importe}) + End If + Next + End If If TxtImporteOtrosContado.Text.ToDecimal() > 0 Then PagadoSinEfectivo += TxtImporteOtrosContado.Text.ToDecimal @@ -1436,6 +1468,8 @@ Partial Class Ventas_PVCobranza End If End If + ObjFactura.CveCorte = CveCorte + Retorno = ObjFactura.EmitirFactura(False, Transac:=ObjVentas.IniciaTransacSQL(), Modulo:="Cobranza/GuardarVenta", MostrarURL:=True) Retorno.Factura = ObjFactura @@ -1444,22 +1478,6 @@ Partial Class Ventas_PVCobranza For Each msg In Retorno.Mensajes SbAlert.AppendFormat("{0}
    ", msg) Next - - SbAlert.AppendFormat("
    ", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1", Retorno.CveVenta))) - - For Each dr As DataRow In DtAnticipos.Rows - SBAmortizaciones.AppendLine($"
    Imprimir historial {dr("Folio").ToString}
    ") - Next - - - SbAlert.Append(SBAmortizaciones.ToString) - Else SbAlert.Append("Ocurrió un error al generar la factura") End If @@ -1601,7 +1619,6 @@ Partial Class Ventas_PVCobranza Dim Importe = GvRowAnticipo.FCTextBox(String.Format("TxtAnticipo{0}", GvRowAnticipo.RowIndex)).Text.ToDecimal() Dim CveConceptoContable = GvRowAnticipo.DataKey("CveConceptoContable").ToEntero() - Dim FolioFiscal = GvRowAnticipo.DataKey("FolioFiscal") Dim Descuentos As Decimal = GvRowAnticipo.DataKey("Descuentos").ToDecimal() Dim TotalAnticipo As Decimal = GvRowAnticipo.DataKey("TotalAnticipo").ToDecimal() @@ -1612,8 +1629,10 @@ Partial Class Ventas_PVCobranza Dim Folio = GvRowAnticipo.DataKey("Folio") Dim Tipo = GvRowAnticipo.DataKey("Tipo") - DtAnticipos.Rows.Add(CveVenta, Importe, CveConceptoContable, CveIE, FolioFiscal, Descuentos, TotalAnticipo, SubTotalAnticipo, CveMoneda, Fecha, TipoCambioPago, Folio, Tipo) + + ObjNC.Observaciones = $"Folio: {GvRowAnticipo.DataKey("Folio")}" + End If ObjNC.EsNCAmortizacion = True @@ -1687,12 +1706,9 @@ Partial Class Ventas_PVCobranza If ChkSobFaltante.Checked AndAlso SobranteFaltante <> 0 Then 'SOBRANTE If SobranteFaltante > 0 Then - 'SI ES EL SOBRANTE EN EFECTIVO SUMAR EL SOBRANTE/FALTANTE + 'EL SOBRANTE/FALTANTE NO PUEDE SER EN EFECTIVO If Metodo = 13 Then - ImporteIE += SobranteFaltante - Pago.OtroGastoIngreso = SobranteFaltante.ToString().ToDecimal() - 'LIMPIAR SOBRANTE/FALTANTE - SobranteFaltante = 0 + Retorno = "Error en aplicación de sobrante/faltante" Else 'AJUSTAR DONDE EL IMPORTE A BANCOS SEA MAYOR EN EL DE LA VENTA If ImporteBancos.RoundSQL(2) >= ImporteAbonoVenta.RoundSQL(2) Then @@ -1705,50 +1721,60 @@ Partial Class Ventas_PVCobranza 'FALTANTE If SobranteFaltante < 0 Then - 'METER LO QUE FALTA COMO GASTO - If (ImporteBancos.RoundSQL(2) + Math.Abs(SobranteFaltante)) = ImporteAbonoVenta.RoundSQL(2) Then - Pago.OtroGastoIngreso = SobranteFaltante.ToString().ToDecimal() - 'LIMPIAR SOBRANTE/FALTANTE - SobranteFaltante = 0 - 'SUMAR AL PAGO - If ImporteBancos < ImporteAbonoVenta Then - ImporteBancos += Math.Abs(SobranteFaltante) + 'EL SOBRANTE/FALTANTE NO PUEDE SER EN EFECTIVO + If Metodo = 13 Then + Retorno = "Error en aplicación de sobrante/faltante" + Else 'METER LO QUE FALTA COMO GASTO + If (ImporteBancos.RoundSQL(2) + Math.Abs(SobranteFaltante)) = ImporteAbonoVenta.RoundSQL(2) Then + Pago.OtroGastoIngreso = SobranteFaltante.ToString().ToDecimal() + + 'SUMAR AL PAGO + If ImporteBancos < ImporteAbonoVenta Then + ImporteBancos += Math.Abs(SobranteFaltante) + End If + + 'LIMPIAR SOBRANTE/FALTANTE + SobranteFaltante = 0 End If End If + End If End If - CveIEPago = ObjIE.AddBancos_IE(CveBancoCuenta, Metodo, Fecha, "-1", VentaActual.ClienteNombre, ImporteIE, 1, 1, Obs, "", False, True, 0, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCorte:=tCveCorte, CveAutorizacion:=CveAutorizacion, CveSubProyecto:=CveSubProyecto) - If CveIEPago > 0 Then - Dim tImportePago As Decimal = If(ImporteBancos > ImporteAbonoVenta, ImporteAbonoVenta, ImporteBancos) 'toma el importe menor para la factura + If String.IsNullOrEmpty(Retorno) Then + CveIEPago = ObjIE.AddBancos_IE(CveBancoCuenta, Metodo, Fecha, "-1", VentaActual.ClienteNombre, ImporteIE, 1, 1, Obs, "", False, True, 0, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCorte:=tCveCorte, CveAutorizacion:=CveAutorizacion, CveSubProyecto:=CveSubProyecto) + If CveIEPago > 0 Then + Dim tImportePago As Decimal = If(ImporteBancos > ImporteAbonoVenta, ImporteAbonoVenta, ImporteBancos) 'toma el importe menor para la factura - If ImporteIE > 0 Then + If ImporteIE > 0 Then - Pago.ImportePagoVenta = tImportePago - Pago.ImportePago = ImporteIE - Pago.CveIE = CveIEPago - Pago.CveMonedaPago = VentaActual.CveMoneda - Pago.Fecha = NowADS() - Pago.Referencia = VentaActual.SerieFolio - If Pago.CveMonedaPago > 1 Then Pago.TCPago = GlobalTipoCambio(Now).ToDecimal + Pago.ImportePagoVenta = tImportePago + Pago.ImportePago = ImporteIE + Pago.CveIE = CveIEPago + Pago.CveMonedaPago = VentaActual.CveMoneda + Pago.Fecha = NowADS() + Pago.Referencia = VentaActual.SerieFolio + If Pago.CveMonedaPago > 1 Then Pago.TCPago = GlobalTipoCambio(Now).ToDecimal - ErrorConta = AplicaPrePolizaPagoVenta(VentaActual, Pago, CvePrePoliza, ObjConta) - End If + ErrorConta = AplicaPrePolizaPagoVenta(VentaActual, Pago, CvePrePoliza, ObjConta) + End If - If ErrorConta Then - Retorno = "Error en aplicación de pago" - End If - Dim MetodoPago As Integer = If(Metodo = 13, 1, If(Metodo = 12, 4, If(Metodo = 11, 5, If(Metodo = 3, 2, 3)))) - If Not ErrorConta AndAlso Not ObjVentas.AddVta_VentaPago(VentaActual.CveVenta, MetodoPago, ImporteBancos) Then - Retorno = "Error en aplicación de pago.." + If ErrorConta Then + Retorno = "Error en aplicación de pago" + End If + Dim MetodoPago As Integer = If(Metodo = 13, 1, If(Metodo = 12, 4, If(Metodo = 11, 5, If(Metodo = 3, 2, 3)))) + If Not ErrorConta AndAlso Not ObjVentas.AddVta_VentaPago(VentaActual.CveVenta, MetodoPago, ImporteBancos) Then + Retorno = "Error en aplicación de pago.." + ErrorConta = True + End If + HdnCveIE.Value = CveIEPago.ToString + Else + Retorno = "Pago en Bancos no registrado" ErrorConta = True End If - HdnCveIE.Value = CveIEPago.ToString - Else - Retorno = "Pago en Bancos no registrado" - ErrorConta = True End If + Else Retorno = "No se ha especificado la cuenta" End If @@ -2230,43 +2256,32 @@ Partial Class Ventas_PVCobranza Protected Sub ImgAntiPend_Click(sender As Object, e As EventArgs) - Dim CveVenta As Integer = HdnCveVenta.Value.ToEntero() - - 'If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then - ' If DdlTipoAmortizacionAnticipo.Items.FindByValue("4") Is Nothing Then - ' DdlTipoAmortizacionAnticipo.Items.Insert(1, New ListItem("Pago con devolución", "4")) - ' End If - ' DdlTipoAmortizacionAnticipo.SelectedValueExist("4") - - ' DdlTipoRelacionAnticipo.SelectedValueExist("-1") - - ' divAmortizacionTipoRelacion.Visible = False - - ' DdlTipoAmortizacionAnticipo_SelectedIndexChanged(DdlTipoAmortizacionAnticipo, EventArgs.Empty) - 'End If + VerificaCargaAnticipo() + UpAnticipos.Update() + RegistraScript("$('#DivAnticipos').modal();", "AE") + End Sub + Private Sub VerificaCargaAnticipo() + Dim CveVenta As Integer = HdnCveVenta.Value.ToEntero() Dim DbRowVenta As DataRow = Nothing Dim ObjVentas As New ClsVentas If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa, VerificaAlmacen:=False) Then DbRowVenta = ObjVentas.DtResultados.Copy().FiltroPrimero("") End If ObjVentas.Dispose() - + Dim tTipoDocto As String If DbRowVenta IsNot Nothing Then CveCliente = DbRowVenta("CveCliente").ToString().ToEntero() CveVendedor = DbRowVenta("CveVendedor").ToString().ToEntero() + tTipoDocto = DbRowVenta("TipoDocto").ToString() End If If CveCliente > 0 Then - CargaAnticipos(CveCliente) + CargaAnticipos(CveCliente, tTipoDocto) End If - - UpAnticipos.Update() - - RegistraScript("$('#DivAnticipos').modal();", "AE") End Sub - Private Sub CargaAnticipos(CveCliente As Integer) + Private Sub CargaAnticipos(CveCliente As Integer, TipoDocto As String) If CveCliente > 0 Then Dim ObjMovtos As New ClsMovimientos() If ObjMovtos.GetAnticiposNCIxCCliente(CveCliente) Then @@ -2274,8 +2289,11 @@ Partial Class Ventas_PVCobranza End If ObjMovtos.Dispose() + Dim TipoAnticipo As String = "'NC','IxC','Ant'" + If TipoDocto = "Ant" Then TipoAnticipo = " 'IxC' " + If Me.TmpDTAnticiposNCIxCCliente IsNot Nothing Then - GVAnticipos.DataSource = Me.TmpDTAnticiposNCIxCCliente.FiltraParametros($"ISTotal = 0 AND Saldo > 0 AND Tipo IN('NC','IxC','Ant') ") + GVAnticipos.DataSource = Me.TmpDTAnticiposNCIxCCliente.FiltraParametros($"ISTotal = 0 AND Saldo > 0 AND Tipo IN ({TipoAnticipo}) ") Else GVAnticipos.DataSource = Nothing End If @@ -2298,24 +2316,7 @@ Partial Class Ventas_PVCobranza End Sub Protected Sub LnkRecargaAnticipos_Click(sender As Object, e As EventArgs) - Dim CveVenta As Integer = HdnCveVenta.Value.ToEntero() - - If CveCliente <= 0 Then - Dim DbRowVenta As DataRow = Nothing - Dim ObjVentas As New ClsVentas - If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then - DbRowVenta = ObjVentas.DtResultados.Copy().FiltroPrimero("") - End If - ObjVentas.Dispose() - - If DbRowVenta IsNot Nothing Then - CveCliente = DbRowVenta("CveCliente").ToString().ToEntero() - End If - End If - - If CveCliente > 0 Then - CargaAnticipos(CveCliente) - End If + VerificaCargaAnticipo() End Sub Protected Sub LnkSolicitarActivarAnticipo_Click(sender As Object, e As EventArgs) @@ -2469,9 +2470,9 @@ Partial Class Ventas_PVCobranza Dim AnticipoAutorizado = CBool(e.Row.DBCampo("AnticipoAutorizado")) - 'If Not EsProduccion AndAlso UsuarioActual.CveRol = 1 Then - ' AnticipoAutorizado = True - 'End If + If Not EsProduccion AndAlso UsuarioActual.CveRol = 1 Then + AnticipoAutorizado = True + End If If UsuarioActual.Empresa.Funcionalidad(185) = "1" Then If e.Row.DBCampo("Tipo").ToString().Contiene("NC", "Ant", "IxC") AndAlso Not AnticipoAutorizado Then @@ -3109,7 +3110,10 @@ Partial Class Ventas_PVCobranza Dim objPuntoVenta As New ClsPuntoVenta Dim FechaInicio As Date = New Date(txtFechaI.Text.ToDate.Year, 1, 1) Dim FechaFin As Date = New Date(FechaInicio.Year, 12, 31) - Dim CveCuenta As Integer = 197107 + Dim CveCuenta As Integer = -2 + + If UsuarioActual.CveEmpresa = 189 Then CveCuenta = 197107 'gdiaz + If UsuarioActual.CveEmpresa = 197 Then CveCuenta = 187752 'ayven If objPuntoVenta.GetVta_EstadoCajas(CveCuenta, UsuarioActual.CveEmpresa, FechaInicio, FechaFin) Then GvEstadoCajas.DataSource = objPuntoVenta.DtResultados diff --git a/Ventas/RepComisionesSMS.aspx b/Ventas/RepComisionesSMS.aspx index 0126ce39a..9ba4d2fa2 100644 --- a/Ventas/RepComisionesSMS.aspx +++ b/Ventas/RepComisionesSMS.aspx @@ -154,7 +154,7 @@
    @@ -175,7 +175,7 @@ - + diff --git a/Ventas/RepComisionesSMS.aspx.vb b/Ventas/RepComisionesSMS.aspx.vb index c06b9b639..23d0bf991 100644 --- a/Ventas/RepComisionesSMS.aspx.vb +++ b/Ventas/RepComisionesSMS.aspx.vb @@ -73,10 +73,10 @@ Partial Class Ventas_RepComisionesSMS LnkExportar.Visible = False Dim FechaIPago As Date = If(TxtFechaIPago.Text.ToDate < MinFecha, MinFecha, TxtFechaIPago.Text.ToDate) Dim FechaFPago As Date = If(TxtFechaFPago.Text.ToDate < MinFecha, MaxFecha, TxtFechaFPago.Text.ToDate) - + Dim CveMarca As Integer = -1 Dim ObjVentas As New ClsVentas - If ObjVentas.GetComisionesMedicasRep(txtFechaI.Text.ToDate, txtFechaF.Text.ToDate, UsuarioActual.CveEmpresa, -1, -1, DdlMedico.SelectedValue.ToEntero, DdlVendedor.SelectedValue.ToEntero, DdlUsuarioAtendio.SelectedValue.ToEntero, UsuarioActual.CveUsuario, -1, FechaIPago, FechaFPago) Then + If ObjVentas.GetComisionesMedicasRep(txtFechaI.Text.ToDate, txtFechaF.Text.ToDate, UsuarioActual.CveEmpresa, -1, -1, DdlMedico.SelectedValue.ToEntero, DdlVendedor.SelectedValue.ToEntero, DdlUsuarioAtendio.SelectedValue.ToEntero, UsuarioActual.CveUsuario, -1, CveMarca, FechaIPago, FechaFPago) Then GvDatos.DataSource = ObjVentas.DtResultados If ObjVentas.DtResultados IsNot Nothing AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then diff --git a/Ventas/RepVentasResumen.aspx.vb b/Ventas/RepVentasResumen.aspx.vb index 70a217f03..292b771a5 100644 --- a/Ventas/RepVentasResumen.aspx.vb +++ b/Ventas/RepVentasResumen.aspx.vb @@ -103,7 +103,7 @@ Partial Class Ventas_RepVentasResumen VxC = Nothing End If - If ObjMovtos.GetRepRecuperacion(TxtFechaI.Text.ToDate, TxtFechaF.Text.ToDate, -1, DdlSubProyecto.SelectedValue.ToEntero, -1, -1, -1, "-1", UsuarioActual.CveEmpresa, 5, -1, "-1", CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then + If ObjMovtos.GetRepRecuperacion(TxtFechaI.Text.ToDate, TxtFechaF.Text.ToDate, MinFecha, MaxFecha, -1, DdlSubProyecto.SelectedValue.ToEntero, "-1", -1, "-1", "-1", UsuarioActual.CveEmpresa, 5, CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then Datos = ObjVentas.DtResultados GvPxC.DataSource = Datos Else diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index b76727f61..b060a909e 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -1127,6 +1127,8 @@ Predial + Ed. Med + IVA IEPS @@ -1260,6 +1262,8 @@ + + @@ -1472,6 +1476,15 @@ <%--13--%> + + + + + + + + + <%--14--%>
    @@ -1479,7 +1492,7 @@
    <%----%> - <%--14--%> + <%--15--%>
    @@ -1487,17 +1500,17 @@
    <%----%> - <%--15--%> - <%--16--%> - + <%--17--%> + + <%--18--%> - <%--18--%> + <%--19--%>
    @@ -1511,14 +1524,14 @@ CssClass="btn btn-circle btn-sm green" Text="" /> - <%--19--%> + <%--20--%> - <%--20--%> + <%--21--%> - <%--21--%> + <%--22--%> @@ -1538,13 +1551,13 @@ - <%--22--%> + <%--23--%> - <%--23--%> + <%--24--%> diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index c7fcb1d25..e8e0dc05c 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -21,15 +21,16 @@ Partial Class Ventas #Region "Propiedades" Private Const NumeroDecimales As Integer = 2 + Dim ColumnaSubProyecto As Integer = 8 Dim ColumnaDescuento As Integer = 11 Dim ColumnaPredial As Integer = 12 - Dim ColumnaSubProyecto As Integer = 8 - Dim ColumnaIVA As Integer = 13 - Dim ColumnaIEPS As Integer = 14 - Dim ColumnaRetIVA As Integer = 15 - Dim ColumnaRetISR As Integer = 16 - Dim ColumnaEditar As Integer = 18 - Dim ColumnaEliminar As Integer = 19 + Dim ColumnaCantConversion As Integer = 13 + Dim ColumnaIVA As Integer = 14 + Dim ColumnaIEPS As Integer = 15 + Dim ColumnaRetIVA As Integer = 16 + Dim ColumnaRetISR As Integer = 17 + Dim ColumnaEditar As Integer = 19 + Dim ColumnaEliminar As Integer = 20 'Factura de ventas Dim DTConceptos As DataTable @@ -2744,7 +2745,7 @@ Partial Class Ventas End If AC.Dispose() 'columna de Fuente de recaudacion - GvPS.Columns(22).Visible = True + GvPS.Columns(23).Visible = True nomostrar.Visible = True nomostrar2.Visible = True 'GvPS.Width = 1250 @@ -5037,11 +5038,7 @@ Partial Class Ventas CargaNCDT(Dr("CveVenta").ToString().ToEntero(), DbRowVenta("TipoDocto").ToString(), Dr("Importe").ToString().ToDecimal, Dr("FolioFiscal").ToString(), TC:=Dr("TipoCambio").ToString().ToDecimal) End If Next - - If GvNC.Rows.Count > 0 Then - ImgAntiPend.Visible = False - End If - + If GvNC.Rows.Count > 0 Then ImgAntiPend.Visible = False End If End If End If @@ -5066,7 +5063,6 @@ Partial Class Ventas ChkDevAlm.Enabled = False 'LiDevolucionAlmacen.Visible = False End If - End If 'SI ES COTIZACION PUEDE GENERAR UNA OC PARA MODIFICAR LOS IMPORTES @@ -5093,6 +5089,11 @@ Partial Class Ventas If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then TxtAlfa1.Text = DbRowVenta("Alfa1").ToString + If DbRowVenta("CveTipoVenta").ToString = "2" Then 'pago directo + GvPS.Columns(ColumnaCantConversion).Visible = True + thCantConversion1.Visible = True + thCantConversion2.Visible = True + End If End If 'CARGAR PS @@ -5254,7 +5255,7 @@ Partial Class Ventas If TienePermiso <> "" Then ' si tiene acceso en el subproyecto 'LkNotaCredito.Visible = UsuarioActual.TienePermisoProceso(175) If UsuarioActual.TienePermisoProceso(264) Then - InicializaAplicaDevolucion(TmpDT) + InicializaAplicaDevolucion(TmpDT, DbRowVenta("Fecha").ToString().ToDateTime()) End If End If @@ -5895,8 +5896,8 @@ Partial Class Ventas End If 'Ocultamos los botones Clonar y Ordenar - GvPS.Columns(20).Visible = False GvPS.Columns(21).Visible = False + GvPS.Columns(22).Visible = False thOrden.Visible = False GvFirmas.DataSource = DTmpF @@ -6360,7 +6361,7 @@ Partial Class Ventas Dim HabilitarExistencias As Boolean = False If UsuarioActual.Empresa.Funcionalidad(382) = "1" AndAlso DbRowVenta("TipoDocto").ToString().Contiene("Rem", "Cot") Then HabilitarExistencias = True - GvPS.Columns(20).Visible = True + GvPS.Columns(21).Visible = True End If If HabilitarExistencias Then @@ -8793,9 +8794,6 @@ Partial Class Ventas Protected Sub GvPS_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvPS.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then e.Row.Attributes("id") = e.Row.RowIndex.ToString() - If e.Row.RowIndex = 0 Then - End If - If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then 'MODO EDICION @@ -8838,9 +8836,7 @@ Partial Class Ventas e.Row.FCDropDownList("DdlSubProyecto").DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, dr("CveProyecto").ToString().ToEntero(), UsuarioActual.CveEmpresa, -1, 1) e.Row.FCDropDownList("DdlSubProyecto").DataBind() e.Row.FCDropDownList("DdlSubProyecto").SelectedValueExist(e.Row.DBCampo("CveSubProyecto")) - End If - End If If UsuarioActual.TienePermisoProceso(68) OrElse UsuarioActual.Empresa.Funcionalidad(109) = "1" Then @@ -8848,7 +8844,6 @@ Partial Class Ventas e.Row.FCTextBox("TxtDescuento").Enabled = False End If - If Not EsCreaApartirDe Then 'Si es una devolucion If NuevaFactura = 0 Then @@ -8906,7 +8901,6 @@ Partial Class Ventas e.Row.FCDropDownList("DdlPrecioListaEdit").DataBind() e.Row.FCDropDownList("DdlPrecioListaEdit").SelectedValueExist(e.Row.DBCampo("CvePrecioLista")) End If - End If 'Si es facturacion de OC o Contrato @@ -8950,7 +8944,6 @@ Partial Class Ventas e.Row.FCTextBox("TxtPrecio").Enabled = False End If - 'PERMISO EDITAR REM If e.Row.DBCampo("TipoDocto") = "Rem" And ModalidadEdicion Then 'LO PERMITIDO MODIFICAR @@ -8983,9 +8976,8 @@ Partial Class Ventas e.Row.FCLabel("LblTurnoEditar").Visible = True e.Row.FCTextBox("TxtNumTurnosEditar").Visible = True End If - 'LA COLUMNA DE ELIMINACION NO DEBE ESTAR VISIBLE EN EL MODO EDICION - If GvPS.Columns(19).Visible Then + If GvPS.Columns(20).Visible Then e.Row.FCLinkButton("imgD").Visible = False End If @@ -9115,7 +9107,6 @@ Partial Class Ventas End If End If - If DdlTipoComprobante.SelectedValue.Contiene("Cot") Then e.Row.FCHyperLink("HLPS").Visible = True e.Row.FCLabel("LblPS").Visible = False @@ -9124,7 +9115,6 @@ Partial Class Ventas e.Row.FCHyperLink("HLPS").Visible = False e.Row.FCLabel("LblPS").Visible = True End If - End If If CveVenta <= 0 Then @@ -9240,7 +9230,7 @@ Partial Class Ventas OrdenarPS() - If GvPS.Columns(21).Visible Then + If GvPS.Columns(22).Visible Then For Each GvRow As GridViewRow In GvPS.Rows If GvRow.RowType = DataControlRowType.Header Then @@ -9266,6 +9256,7 @@ Partial Class Ventas Dim Cantidad, PU As Decimal Dim ObjDescuento As New Modelos.VentaDescuentos Dim CuentaPredial As String + Dim CantidadConversion As Decimal = GvPS.Rows(e.RowIndex).FCTextBox("TxtCantidadConversion").Text.Trim.ToDecimal Cantidad = GvPS.Rows(e.RowIndex).FCTextBox("TxtCantidad").Text.ToDecimal PU = (GvPS.Rows(e.RowIndex).FCTextBox("TxtPrecio").Text.ToDecimal).RoundSQL(6) @@ -9332,11 +9323,9 @@ Partial Class Ventas If ObjPrecioSugerido IsNot Nothing AndAlso ObjPrecioSugerido.PrecioSugerido > 0 Then PU = ObjPrecioSugerido.PrecioSugerido End If - End If End If - If RecalcularPromociones Then ObjDescuento = CalcularDescuentos(CvePSNuevo, Cantidad, PU) @@ -9410,13 +9399,11 @@ Partial Class Ventas If GvPS.Rows(e.RowIndex).FCDropDownList("DdlPrecioListaEdit").SelectedItem IsNot Nothing Then PrecioLista = GvPS.Rows(e.RowIndex).FCDropDownList("DdlPrecioListaEdit").SelectedItem.Text End If - End If End If Dim SubProyecto As String = "" Dim CveSubProyecto As Integer = -1 - Dim Proyecto As String = "" Dim CveProyecto As Integer = -1 @@ -9445,7 +9432,7 @@ Partial Class Ventas CveProyecto, Proyecto, CveSubProyecto, SubProyecto, CuentaPredial:=CuentaPredial, CveVentaDetalle:=GvPS.Rows(e.RowIndex).DataKey("CveVentaDetalle").ToString().ToEntero(), SeActualiza:=True, CvePromocionDetalle:=ObjDescuento.CvePromocionDetalle, - ObjDescuento:=ObjDescuento, NumTurnos:=NumTurnos, CvePrecioLista:=CvePrecioLista, PrecioLista:=PrecioLista, ConsecutivoManual:=ConsecutivoActual, OrdenManual:=OrdenOriginal) + ObjDescuento:=ObjDescuento, NumTurnos:=NumTurnos, CvePrecioLista:=CvePrecioLista, PrecioLista:=PrecioLista, CantidadConversion:=CantidadConversion, ConsecutivoManual:=ConsecutivoActual, OrdenManual:=OrdenOriginal) ' TmpDT.Rows(e.RowIndex)("CveUM") = Ddl.SelectedValue ' TmpDT.Rows(e.RowIndex)("UM") = Ddl.SelectedItem.Text @@ -9509,6 +9496,7 @@ Partial Class Ventas TmpDT.Rows(e.RowIndex)("PorcentajeRetIVA") = ClienteRetIVA TmpDT.Rows(e.RowIndex)("PorcentajeRetISR") = ClienteRetISR TmpDT.Rows(e.RowIndex)("CuentaPredial") = CuentaPredial + TmpDT.Rows(e.RowIndex)("CantidadConversion") = CantidadConversion TmpDT.Rows(e.RowIndex)("TotalConImpuestos") = (TmpDT.Rows(e.RowIndex)("Total").ToString().ToDecimal() - TmpDT.Rows(e.RowIndex)("Descuento").ToString().ToDecimal() + TmpDT.Rows(e.RowIndex)("ImporteIVA").ToString().ToDecimal()).RoundSQL(2) @@ -9558,7 +9546,6 @@ Partial Class Ventas TmpDT.Rows(e.RowIndex)("CveSubProyecto") = DdlSubProyectoDatos.SelectedValue.ToEntero() End If - 'RELACIONAL PS CON EL DESCUENTO If ObjDescuento IsNot Nothing Then ObjDescuento.Consec = TmpDT.Rows(e.RowIndex)("Consec").ToString().ToEntero() @@ -9566,12 +9553,12 @@ Partial Class Ventas 'RECALCULA LA CANTIDAD DE CONVERSION If CantidadOriginal <> Cantidad Then - Dim CantidadConversion As Decimal = TmpDT.Rows(e.RowIndex)("CantidadConversion").ToString().ToDecimal() + If AplicaComercioExterior Then 'SI NO VIENE DE MANIFIESTO UTILIZA EL PESO DEL PRODUCTO If Request("CveManifiesto") Is Nothing Then If DrPS("PesoKg").ToString().ToDecimal() > 0 Then - CantidadConversion = Cantidad * DrPS("PesoKg").ToString().ToDecimal() + CantidadConversion = Cantidad * DrPS("PesoKg").ToString.ToDecimal() Else CantidadConversion = Cantidad End If @@ -9616,7 +9603,7 @@ Partial Class Ventas 'JJMQ 20160506: Se agrego para la validacion de pago de contado. 'CVImporteContado.ValueToCompare = TxtTotal.Text.Replace(",", "") - If GvPS.Columns(21).Visible Then + If GvPS.Columns(22).Visible Then For Each GvRow As GridViewRow In GvPS.Rows If GvRow.RowType = DataControlRowType.Header Then GvRow.FCLinkButton("LnkOrdenarGvPS").Visible = True @@ -14885,7 +14872,7 @@ Partial Class Ventas CveContratoDetalle:=Row("CveContratoDetalle").ToString().ToEntero(), CvePromocionDetalle:=Row("CvePromocionDetalle").ToString().ToEntero(), IEPS:=Row("ImporteIEPS").ToString().ToDecimal, CveMovimientoDetallePedido:=Row("CveMovimientoDetallePedido").ToString().ToEntero(), ImporteRetIVA:=Row("ImporteRetIVA").ToString().ToDecimal, ImporteRetISR:=Row("ImporteRetISR").ToString().ToDecimal, PorcentajeIVA:=Row("PorcentajeIVA").ToString().ToDecimal, PorcentajeIEPS:=Row("PorcentajeIEPS").ToString().ToDecimal, PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString().ToDecimal, PorcentajeRetISR:=Row("PorcentajeRetISR").ToString().ToDecimal, CuentaPredial:=Row("CuentaPredial").ToString(), CvePrecioLista:=Row("CvePrecioLista").ToString().ToEntero(), - CveActivoFijo:=Row("CveActivoFijo").ToString().ToEntero(), NumTurnos:=Row("NumTurnos").ToString().ToDecimal(), EstatusAlmacen:=EsatusAlmacen, CantidadConversion:=Row("CantidadConversion").ToString().ToDecimal()) Then + CveActivoFijo:=Row("CveActivoFijo").ToString().ToEntero(), NumTurnos:=Row("NumTurnos").ToString().ToDecimal(), EstatusAlmacen:=EsatusAlmacen, CantidadConversion:=Row("CantidadConversion").ToString.ToDecimal()) Then ErrorList.Add("Ocurrió un error al agregar un Producto o Servicio a la Factura.
    Revise su factura y cualquier detalle comuníquese a Soporte Técnico") Exit For Else @@ -21255,7 +21242,7 @@ Partial Class Ventas Row("TieneProntoPago") = "Si" 'SOLO DEBE MOSTRASE SI EL PAGO ES DE CONTADO If RBLPago.SelectedValue = "2" Then - GvPS.Columns(23).Visible = True + GvPS.Columns(24).Visible = True thProntoPago.Visible = True thProntoPago2.Visible = True End If @@ -24551,7 +24538,7 @@ Partial Class Ventas TxtAtencionA.Enabled = True - GvPS.Columns(21).Visible = True + GvPS.Columns(22).Visible = True thOrden.Visible = True Dim HabilitarExistencias As Boolean = False @@ -24716,7 +24703,8 @@ Partial Class Ventas For Each Row As DataRow In TmpDT.Rows Dim CveVentaDetalle As Integer = Row("CveVentaDetalle").ToString().ToEntero() If CveVentaDetalle > 0 Then - If Not ObjVentas.UpdateVentaDetalleRemision(Row("CveVentaDetalle").ToString().ToEntero(), Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().ToDecimal, Row("PU").ToString().ToDecimal(), Row("ImporteIEPS").ToString().ToDecimal(), Row("PorcentajeIEPS").ToString().ToDecimal(), Row("ImporteIVA").ToString().ToDecimal(), Row("PorcentajeIVA").ToString().ToDecimal(), Row("Descuento").ToString().ToDecimal(), Row("Obs").ToString(), UsuarioActual.CveUsuario, CvePromocionDetalle:=Row("CvePromocionDetalle").ToString().ToEntero()) Then + If Not ObjVentas.UpdateVentaDetalleRemision(Row("CveVentaDetalle").ToString().ToEntero(), Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().ToDecimal, Row("PU").ToString().ToDecimal(), Row("ImporteIEPS").ToString().ToDecimal(), Row("PorcentajeIEPS").ToString().ToDecimal(), Row("ImporteIVA").ToString().ToDecimal(), Row("PorcentajeIVA").ToString().ToDecimal(), Row("Descuento").ToString().ToDecimal(), Row("Obs").ToString(), UsuarioActual.CveUsuario, + CvePromocionDetalle:=Row("CvePromocionDetalle").ToString().ToEntero(), CantidadConversion:=Row("CantidadConversion").ToString.ToDecimal()) Then OcurrioError = True Exit For End If @@ -25217,11 +25205,11 @@ Partial Class Ventas If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then If RBLPago.SelectedValue = "2" Then - GvPS.Columns(23).Visible = True + GvPS.Columns(24).Visible = True thProntoPago.Visible = True thProntoPago2.Visible = True Else - GvPS.Columns(23).Visible = False + GvPS.Columns(24).Visible = False thProntoPago.Visible = False thProntoPago2.Visible = False End If @@ -28579,9 +28567,9 @@ Partial Class Ventas 'Ocultamos los botones Editar, Clonar y Ordenar - GvPS.Columns(18).Visible = False - GvPS.Columns(20).Visible = False + GvPS.Columns(19).Visible = False GvPS.Columns(21).Visible = False + GvPS.Columns(22).Visible = False thOrden.Visible = False DdlVendedor.SelectedValue = DbRowVenta("CveVendedor").ToString() @@ -32875,7 +32863,7 @@ Partial Class Ventas #End Region #Region " APLICA DEVOLUCION " - Private Sub InicializaAplicaDevolucion(DtDetalle As DataTable) + Private Sub InicializaAplicaDevolucion(DtDetalle As DataTable, FechaVenta As DateTime) 'If Not UsuarioActual.CveUsuario = 100 Then ' If Not UsuarioActual.CveEmpresa.Contiene(72, 80, 119, 140, 141, 146) Then ' Exit Sub @@ -32887,7 +32875,17 @@ Partial Class Ventas Exit Sub End If - LBAplicaDevolucion.Visible = True + If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then + If FechaVenta.ToShortDateString.ToDate < Now.ToShortDateString.ToDate Then + LBAplicaDevolucion.Visible = True + Else + LBAplicaDevolucion.Visible = False + End If + Else + LBAplicaDevolucion.Visible = True + End If + + 'SOLO APLICA DEVOLUCION SI TIENE MOVIMIENTOS DE ALMACEN 'If VentaSaldoAlmacen < 0 Then @@ -33152,10 +33150,10 @@ Partial Class Ventas 'REINICIALIZA GENERALES PS LbAgregar.Visible = False - GvPS.Columns(18).Visible = False GvPS.Columns(19).Visible = False GvPS.Columns(20).Visible = False GvPS.Columns(21).Visible = False + GvPS.Columns(22).Visible = False thOrden.Visible = False DivRemisionesFacturadas.Visible = False @@ -33848,7 +33846,7 @@ Partial Class Ventas End If If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then - GvPS.Columns(20).Visible = True + GvPS.Columns(21).Visible = True End If 'ECONO, SOLO EL CLIENTE SIGI, PUEDE MODIFICAR EL IVA A 16% @@ -33870,14 +33868,14 @@ Partial Class Ventas imgCalendario.Visible = False End If - GvPS.Columns(21).Visible = True + GvPS.Columns(22).Visible = True thOrden.Visible = True Dim HabilitarExistencias As Boolean = False If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then HabilitarExistencias = True - GvPS.Columns(20).Visible = True + GvPS.Columns(21).Visible = True End If For Each GvRow As GridViewRow In GvPS.Rows @@ -35715,8 +35713,8 @@ Partial Class Ventas DdlLineaAdicional_SelectedIndexChanged(DdlLineaAdicional, EventArgs.Empty) 'HABILITA EDITAR Y ELIMINAR DEL GV - GvPS.Columns(18).Visible = True GvPS.Columns(19).Visible = True + GvPS.Columns(20).Visible = True SetPermisos() @@ -37398,7 +37396,7 @@ Partial Class Ventas End If AC.Dispose() 'columna de Fuente de recaudacion - GvPS.Columns(22).Visible = True + GvPS.Columns(23).Visible = True nomostrar.Visible = True nomostrar2.Visible = True 'GvPS.Width = 1250 @@ -37863,7 +37861,7 @@ Partial Class Ventas ObjFacturaProntoPago.UsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("Descripcion", String.Format("CveUsoCFDI = {0}", ObjCliente.CveUsoCFDI)) ObjFacturaProntoPago.ClaveUsoCFDISAT = GlobalDTSATUsosCFDI.FiltroPrimeroValor("UsoCFDI", String.Format("CveUsoCFDI = {0}", ObjCliente.CveUsoCFDI)) - ObjFacturaProntoPago.DtDetalle = CreaDTDetalleNCProntoPago() + ObjFacturaProntoPago.DtDetalle = Modelos.Factura.CreaDTFactura() 'CreaDTDetalleNCProntoPago() CargaImpuestosProntoPago(ObjFacturaProntoPago, ObjFactura, ObjCliente.DesglosaIEPS, ObjCliente.RetIVA.ToDecimal, ObjCliente.RetISR.ToDecimal) @@ -38158,100 +38156,6 @@ Partial Class Ventas Return query.QueryToDataTable(False) End Function - Protected Function CreaDTDetalleNCProntoPago() As DataTable - Dim TmpDT As New DataTable - TmpDT.Columns.Add("CveVenta", GetType(Integer)) - TmpDT.Columns.Add("Consec", GetType(Integer)) - TmpDT.Columns.Add("Cantidad", GetType(Decimal)) - TmpDT.Columns.Add("Codigo", GetType(String)) - TmpDT.Columns.Add("CveUM", GetType(Integer)) - TmpDT.Columns.Add("UM", GetType(String)) - TmpDT.Columns.Add("SATClaveUM", GetType(String)) - TmpDT.Columns.Add("CveClasificacion", GetType(Integer)) - TmpDT.Columns.Add("Clasificacion", GetType(String)) - TmpDT.Columns.Add("CvePS", GetType(Integer)) - TmpDT.Columns.Add("PS", GetType(String)) - TmpDT.Columns.Add("CodigoPS", GetType(String)) - TmpDT.Columns.Add("SATClaveProdServ", GetType(String)) - TmpDT.Columns.Add("NoIdentificacion", GetType(String)) - TmpDT.Columns.Add("CveTipoPS", GetType(Integer)) - TmpDT.Columns.Add("CveTipoInvPS", GetType(Integer)) - TmpDT.Columns.Add("Serie", GetType(String)) - TmpDT.Columns.Add("CuentaPredial", GetType(String)) - TmpDT.Columns.Add("Obs", GetType(String)) - TmpDT.Columns.Add("TiempoEntrega", GetType(String)) - TmpDT.Columns.Add("PU", GetType(Decimal)) - TmpDT.Columns.Add("IVA", GetType(Decimal)) - TmpDT.Columns.Add("ImporteIVA", GetType(Decimal)) - TmpDT.Columns.Add("PorcentajeIVA", GetType(Decimal)) - TmpDT.Columns.Add("ImporteRetIVA", GetType(Decimal)) - TmpDT.Columns.Add("ImporteRetISR", GetType(Decimal)) - TmpDT.Columns.Add("PorcentajeRetIVA", GetType(Decimal)) - TmpDT.Columns.Add("PorcentajeRetISR", GetType(Decimal)) - TmpDT.Columns.Add("ImporteIEPS", GetType(Decimal)) - TmpDT.Columns.Add("IEPS", GetType(Decimal)) - TmpDT.Columns.Add("PorcentajeIEPS", GetType(Decimal)) - TmpDT.Columns.Add("Descuento", GetType(Decimal)) - TmpDT.Columns.Add("TipoDescuento", GetType(Integer)) - TmpDT.Columns.Add("TotalImporte", GetType(Decimal)) - TmpDT.Columns.Add("Total", GetType(Decimal)) - 'Para uso del módulo contable - TmpDT.Columns.Add("CveProyecto", GetType(Integer)) - TmpDT.Columns.Add("Proyecto", GetType(String)) - TmpDT.Columns.Add("CveSubProyecto", GetType(Integer)) - TmpDT.Columns.Add("SubProyecto", GetType(String)) - TmpDT.Columns.Add("CveVentaDetallePadre", GetType(Integer)) - 'TipoDescuento: 1 = Descuento * PU; 2 = Descuento por Total del concepto - TmpDT.Columns.Add("CvePresupuestoIngreso", GetType(Integer)) - TmpDT.Columns.Add("CveFuenteRecaudacion", GetType(Integer)) - 'Contratos - TmpDT.Columns.Add("CveContratoDetalle", GetType(Integer)) - 'Remisiones a Facturas - TmpDT.Columns.Add("CveVentaDetalle", GetType(Integer)) - TmpDT.Columns.Add("CveVentaDetalleRemision", GetType(Integer)) - TmpDT.Columns.Add("CveVentaDetalleCotizacion", GetType(Integer)) - 'Pedido2 a Facturas - TmpDT.Columns.Add("CveVentaDetallePedido2", GetType(Integer)) - TmpDT.Columns.Add("Origen", GetType(Integer)) - 'Ordenes Servicio - TmpDT.Columns.Add("CveOS", GetType(Integer)) - TmpDT.Columns.Add("CveOSDetalle", GetType(Integer)) - TmpDT.Columns.Add("SeFacturara", GetType(Integer)) - TmpDT.Columns.Add("Folio", GetType(Integer)) - TmpDT.Columns.Add("Estatus", GetType(String)) - 'Ordenamiento - TmpDT.Columns.Add("Orden", GetType(Integer)) - TmpDT.Columns.Add("TipoDocto", GetType(String)) - 'OC - TmpDT.Columns.Add("CveOrdenCompraDetalle", GetType(Integer)) - TmpDT.Columns.Add("EntregaDirecta", GetType(Integer)) - TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer)) - TmpDT.Columns.Add("CantidadFacturadaRem", GetType(Decimal)) - TmpDT.Columns.Add("CantidadFacturadaCot", GetType(Decimal)) - TmpDT.Columns.Add("CantidadFacturadaPed2", GetType(Decimal)) - TmpDT.Columns.Add("CantidadInventario", GetType(Decimal)) - TmpDT.Columns.Add("ClaveSATFraccionArancelaria", GetType(String)) - TmpDT.Columns.Add("ClaveSATUnidadAduana", GetType(String)) - TmpDT.Columns.Add("ClaveSATFraccionArancelariaDescripcion", GetType(String)) - TmpDT.Columns.Add("ClaveSATUnidadAduanaDescripcion", GetType(String)) - TmpDT.Columns.Add("CodigoObjetoImpuesto", GetType(String)) - TmpDT.Columns.Add("CveTamaño", GetType(Integer)) - TmpDT.Columns.Add("EsCargo", GetType(Boolean)) - TmpDT.Columns.Add("CveMarca", GetType(Integer)) - TmpDT.Columns.Add("CvePrecioLista", GetType(Integer)) - TmpDT.Columns.Add("PrecioLista", GetType(String)) - TmpDT.Columns.Add("CveActivoFijo", GetType(Integer)) - TmpDT.Columns.Add("AFDepreciacion", GetType(Decimal)) - TmpDT.Columns.Add("AFValorInicial", GetType(Decimal)) - TmpDT.Columns.Add("NumTurnos", GetType(Decimal)) - TmpDT.Columns("NumTurnos").DefaultValue = 0D - TmpDT.Columns.Add("NumeroPedimento", GetType(String)) - TmpDT.Columns.Add("TotalConImpuestos", GetType(Decimal)) - TmpDT.Columns.Add("Costo", GetType(Decimal)) - TmpDT.Columns("Costo").DefaultValue = 0D - - Return TmpDT - End Function Private Function InicializaDTVentasNCProntoPago() As DataTable Dim DtVentasNC As New DataTable DtVentasNC.Columns.Add("CveVenta", GetType(Integer)) @@ -40256,6 +40160,13 @@ Partial Class Ventas Alert("Debe de seleccionar un hospital.", TipoMensaje.MsgAdvertencia) Exit Sub End If + 'activa la columna para especificar el precio + + GvPS.Columns(ColumnaCantConversion).Visible = True + thCantConversion1.Visible = True + thCantConversion2.Visible = True + thCantConversion1.InnerText = "Ed. Med" + Else If DdlClienteSucursalCliente() > 0 Then ViewState("CveCliente") = DdlClienteSucursalCliente() @@ -40366,12 +40277,13 @@ Partial Class Ventas Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero Dim EdMedica As Decimal = 0 If RBLTipoVenta.SelectedValue = "2" Then EdMedica = GvRow.FCTextBox("TxtEdMedica").Text.ToDecimal + 'tomamos la columna de predial, para el uso de ed médica If Cantidad > 0 Then If AgregarProductoServicio(Cantidad, CveUnidadMedida, Abreviatura, CveClasificacion, Clasificacion, CvePS, "", TxtObsPS.Text.TrimEnd, PU, 0, DdlProyecto.SelectedValue.ToEntero(), DdlProyecto.SelectedItem.Text, DdlSubProyecto.SelectedValue.ToEntero(), DdlSubProyecto.SelectedItem.Text, - Serie:=If(DIVCod.Visible, TxtCodigoSerie.Text.Trim, ""), TiempoEntrega:=TxtTiempoEntrega.Text, CuentaPredial:=TxtCuentaPredial.Text.Trim, RegeneraIEPS:=ClienteDesglosaIEPS, CvePromocionDetalle:=-1, + Serie:=If(DIVCod.Visible, TxtCodigoSerie.Text.Trim, ""), TiempoEntrega:=TxtTiempoEntrega.Text, CuentaPredial:="", RegeneraIEPS:=ClienteDesglosaIEPS, CvePromocionDetalle:=-1, ImporteProntoPago:=0, ObjDescuento:=Nothing, CvePrecioLista:=-1, PrecioLista:="", NumTurnos:=0, CantidadConversion:=EdMedica) Then CountPsAgregados = CountPsAgregados + 1 Else diff --git a/asmx/WSSIGApp.asmx b/asmx/WSSIGApp.asmx index c357054be..8976da08c 100644 --- a/asmx/WSSIGApp.asmx +++ b/asmx/WSSIGApp.asmx @@ -1745,7 +1745,7 @@ Public Class WSSIGApp Public Function GetRepRecuperacion(CveEmpresa As Integer, FechaI As String, FechaF As String, Gpo As Integer, CveUsuarioConsulta As Integer, CveSubProyecto As Integer, CveCliente As Integer) As String Dim retorno = "[]" Using ObjVentas As New ClsMovimientos - If ObjVentas.GetRepRecuperacion(FechaI.ToDateTime(), FechaF.ToDateTime(), CveCliente, CveSubProyecto, -1, -1, -1, "-1", CveEmpresa, Gpo, -1, CveUsuarioConsulta:=CveUsuarioConsulta) Then + If ObjVentas.GetRepRecuperacion(FechaI.ToDateTime(), FechaF.ToDateTime(), MinFecha, MaxFecha, CveCliente, CveSubProyecto, -1, -1, -1, "-1", CveEmpresa, Gpo, -1, CveUsuarioConsulta:=CveUsuarioConsulta) Then retorno = ObjVentas.DtResultados.ToJson() End If End Using