diff --git a/App_Code/ClsContratos.vb b/App_Code/ClsContratos.vb index b5237427d..b97b600fe 100644 --- a/App_Code/ClsContratos.vb +++ b/App_Code/ClsContratos.vb @@ -302,7 +302,8 @@ Public Class ClsContratos Geom As String, CveContratoPadre As Integer, CveUsuario As Integer, CveEmpresa As Integer, EsPresupuestal As Boolean, Minimo As Double, Maximo As Double, Importe As Double, CveMoneda As Integer, ModalidadDetalle As Integer, Optional CveContratosEstatus As Integer = -1, Optional CveContratoTipo As Integer = -1, Optional TipoCambio As Double = 1, Optional CveSucursalCliente As Integer = -1, Optional CveAlmacenOrigen As Integer = -1, Optional CveAlmacenDestino As Integer = -1, Optional PorcentajeComision As Integer = -1, Optional TipoGarantia As Integer = -1, Optional Folio As Integer = -1, Optional FechaVenc As Date = Nothing, Optional EstatusFianza As Integer = -1, Optional CvePeriodo As Integer = -1, Optional CveContratoPlantilla As Integer = -1, Optional CveCuentaEquipo As Integer = -1, - Optional CveVendedor As Integer = -1, Optional Observaciones As String = "", Optional CveDireccionEnvio As Integer = -1, Optional AplicaImpuestosLocales As Boolean = False, Optional CorreoNotificacionPedDev As String = "") As Integer + Optional CveVendedor As Integer = -1, Optional Observaciones As String = "", Optional CveDireccionEnvio As Integer = -1, Optional AplicaImpuestosLocales As Boolean = False, Optional CorreoNotificacionPedDev As String = "", + Optional FacturacionCicilica As Boolean = False, Optional FacturacionCiclicaAutomatico As Boolean = False, Optional DiaMesFacturacion As Integer = 1) As Integer Dim Retorno As Integer = -1 DataAdapter("PA_Con_ContratosAdd") @@ -353,7 +354,10 @@ Public Class ClsContratos .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones .Add("@CveDireccionEnvio", SqlDbType.Int).Value = CveDireccionEnvio .Add("@AplicaImpuestosLocales", SqlDbType.Bit).Value = If(AplicaImpuestosLocales, 1, 0) - .Add("@CorreoNotificacionPedDev", SqlDbType.VarChar).Value = CorreoNotificacionPedDev + .Add("@CorreoNotificacionPedDev", SqlDbType.VarChar).Value = CorreoNotificacionPedDev + .Add("@FacturacionCicilica", SqlDbType.Bit).Value = FacturacionCicilica + .Add("@FacturacionCiclicaAutomatico", SqlDbType.Bit).Value = FacturacionCiclicaAutomatico + .Add("@DiaMesFacturacion", SqlDbType.TinyInt).Value = DiaMesFacturacion End With @@ -378,7 +382,8 @@ Public Class ClsContratos CveContratoPadre As Integer, CveUsuario As Integer, CveEmpresa As Integer, EsPresupuestal As Boolean, Minimo As Double, Maximo As Double, Importe As Double, CveMoneda As Integer, ModalidadDetalle As Integer, Optional CveContratosEstatus As Integer = -1, Optional CveContratoTipo As Integer = -1, Optional TipoCambio As Double = 1.0, Optional CveSucursalCliente As Integer = -1, Optional CveAlmacenOrigen As Integer = -1, Optional CveAlmacenDestino As Integer = -1, Optional PorcentajeComision As Integer = -1, Optional TipoGarantia As Integer = -1, Optional Folio As Integer = -1, Optional FechaVenc As Date = Nothing, Optional EstatusFianza As Integer = -1, Optional CveContratoPlantilla As Integer = -1, Optional CveCuentaEquipo As Integer = -1, - Optional CveVendedor As Integer = -1, Optional Observaciones As String = "", Optional CveDireccionEnvio As Integer = -1, Optional AplicaImpuestosLocales As Boolean = False, Optional CorreoNotificacionPedDev As String = "") As Boolean + Optional CveVendedor As Integer = -1, Optional Observaciones As String = "", Optional CveDireccionEnvio As Integer = -1, Optional AplicaImpuestosLocales As Boolean = False, Optional CorreoNotificacionPedDev As String = "", Optional FacturacionCicilica As Boolean = False, Optional FacturacionCiclicaAutomatico As Boolean = False, + Optional DiaMesFacturacion As Integer = 1, Optional CvePeriodo As Integer = -1) As Boolean Dim Retorno = False DataAdapter("PA_Con_ContratosUpdate") @@ -428,8 +433,11 @@ Public Class ClsContratos .Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones .Add("@CveDireccionEnvio", SqlDbType.Int).Value = CveDireccionEnvio .Add("@AplicaImpuestosLocales", SqlDbType.Bit).Value = If(AplicaImpuestosLocales, 1, 0) - .Add("@CorreoNotificacionPedDev", SqlDbType.VarChar).Value = CorreoNotificacionPedDev - + .Add("@CorreoNotificacionPedDev", SqlDbType.VarChar).Value = CorreoNotificacionPedDev + .Add("@FacturacionCicilica", SqlDbType.Bit).Value = FacturacionCicilica + .Add("@FacturacionCiclicaAutomatico", SqlDbType.Bit).Value = FacturacionCiclicaAutomatico + .Add("@DiaMesFacturacion", SqlDbType.TinyInt).Value = DiaMesFacturacion + .Add("@CvePeriodo", SqlDbType.Int).Value = CvePeriodo End With Try @@ -721,7 +729,7 @@ Public Class ClsContratos Return Retorno End Function - Public Function CicloComercialUpdate(CveCicloComercial As Integer, FueFacturado As Boolean, CveEmpresa As Integer) As Boolean + Public Function CicloComercialUpdate(CveCicloComercial As Integer, FueFacturado As Boolean, CveEmpresa As Integer, Optional CveVenta As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Con_CicloComercialUpdate") @@ -729,6 +737,7 @@ Public Class ClsContratos .Add("@FueFacturado", SqlDbType.Bit).Value = FueFacturado .Add("@CveCicloComercial", SqlDbType.Int).Value = CveCicloComercial .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta End With Try diff --git a/App_Code/ClsNominas.vb b/App_Code/ClsNominas.vb index 513bb17b4..53b11a3e3 100644 --- a/App_Code/ClsNominas.vb +++ b/App_Code/ClsNominas.vb @@ -1913,7 +1913,7 @@ Public Class ClsNominas End Try Return Retorno End Function - Public Function AddUPNom_NominasDetalles(CveNomina As Integer, CvePeriodo As Integer, CvePersonal As Integer, CveConcepto As Integer, Importe As Decimal, ImporteGravado As Decimal, ImporteExento As Decimal, CveUsuario As Integer, Optional IsEdited As Boolean = False) As Boolean + Public Function AddUPNom_NominasDetalles(CveNomina As Integer, CvePeriodo As Integer, CvePersonal As Integer, CveConcepto As Integer, Importe As Decimal, ImporteGravado As Decimal, ImporteExento As Decimal, ImporteValor As Decimal, CveUsuario As Integer, Optional IsEdited As Boolean = False) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Nom_NominasDetallesAddUP") @@ -1926,6 +1926,7 @@ Public Class ClsNominas .Add("Importe", SqlDbType.Float).Value = Importe .Add("ImporteGravado", SqlDbType.Float).Value = ImporteGravado .Add("ImporteExento", SqlDbType.Float).Value = ImporteExento + .Add("ImporteValor", SqlDbType.Float).Value = ImporteValor .Add("CveUsuario", SqlDbType.Int).Value = CveUsuario .Add("IsEdited", SqlDbType.Bit).Value = IsEdited End With @@ -1984,7 +1985,7 @@ Public Class ClsNominas End Try Return retorno End Function - Public Function GetNominaEmpleado(CveProyecto As Integer, CveSubProyecto As Integer, CveTurno As Integer, CvePeriodo As Integer, CveEmpresa As Integer, Agrupador As Integer) As Boolean + Public Function GetNominaEmpleado(CveProyecto As Integer, CveSubProyecto As Integer, CveTurno As Integer, CvePeriodo As Integer, CveEmpresa As Integer, Agrupador As Integer, Optional RegimenContratacion As Integer = 1) As Boolean Dim retorno As Boolean = False Try DTSet = New DataSet() @@ -1996,6 +1997,7 @@ Public Class ClsNominas .Add("@CvePeriodo", SqlDbType.Int).Value = CvePeriodo .Add("@Agrupador", SqlDbType.VarChar).Value = Agrupador .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@RegimenContratacion", SqlDbType.Int).Value = RegimenContratacion End With @@ -2033,6 +2035,121 @@ Public Class ClsNominas Return retorno End Function +#Region "CRUD_Nom_PersonalIncapacidad" + Public Function PersonalIncapacidadGet(cvePersonalIncapacidad As Int32, cvePersonal As Int32, CveEmpresa As Int32) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_Nom_PersonalIncapacidadGet", CommandType.StoredProcedure) + Try + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePersonalIncapacidad", SqlDbType.Int).Value = cvePersonalIncapacidad + .Add("@CvePersonal", SqlDbType.Int).Value = cvePersonal + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + SqlAdapter.Fill(Data) + retorno = True + Catch sqEx As SqlException + retorno = False + OnError("Ocurrió un error al obtener las tablas de nomina.", sqEx, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + retorno = False + OnError("Ocurrió un error al obtener las tablas de nomina.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return retorno + End Function + Public Function PersonalIncapacidadAdd(CveUsuarioCapturo As Integer, cvePersonal As Int32, folio As String, fechaInicio As DateTime, diasAutorizados As Int32, cveTipodeIncidencia As Int32, cveRamoSeguro As Int32, cveTipoRiesgo As Int32, porcentajedeIncapacidad As Int32, cveSecuelaConsecuencia As Int32, cveControlIncapacidad As Int32, descripcion As String) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_Nom_PersonalIncapacidadAdd", CommandType.StoredProcedure) + Try + With SqlAdapter.SelectCommand.Parameters + .Add("@CveUsuarioCapturo", SqlDbType.Int).Value = CveUsuarioCapturo + .Add("@CvePersonal", SqlDbType.Int).Value = cvePersonal + .Add("@Folio", SqlDbType.VarChar).Value = folio + .Add("@FechaInicio", SqlDbType.DateTime).Value = fechaInicio + .Add("@DiasAutorizados", SqlDbType.Int).Value = diasAutorizados + .Add("@CveTipodeIncidencia", SqlDbType.Int).Value = cveTipodeIncidencia + .Add("@CveRamoSeguro", SqlDbType.Int).Value = cveRamoSeguro + .Add("@CveTipoRiesgo", SqlDbType.Int).Value = cveTipoRiesgo + .Add("@PorcentajedeIncapacidad", SqlDbType.Int).Value = porcentajedeIncapacidad + .Add("@CveSecuelaConsecuencia", SqlDbType.Int).Value = cveSecuelaConsecuencia + .Add("@CveControlIncapacidad", SqlDbType.Int).Value = cveControlIncapacidad + .Add("@Descripcion", SqlDbType.VarChar).Value = descripcion + End With + SqlAdapter.Fill(Data) + retorno = True + Catch sqEx As SqlException + retorno = False + OnError("Ocurrió un error al agregar las tablas de nomina.", sqEx, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + retorno = False + OnError("Ocurrió un error al agregar las tablas de nomina.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return retorno + End Function + Public Function PersonalIncapacidadUp(CveUsuarioCapturo As Integer, cvePersonalIncapacidad As Int32, folio As String, fechaInicio As DateTime, diasAutorizados As Int32, cveTipodeIncidencia As Int32, cveRamoSeguro As Int32, cveTipoRiesgo As Int32, porcentajedeIncapacidad As Int32, cveSecuelaConsecuencia As Int32, cveControlIncapacidad As Int32, descripcion As String) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_Nom_PersonalIncapacidadUp", CommandType.StoredProcedure) + Try + With SqlAdapter.SelectCommand.Parameters + .Add("@CveUsuarioCapturo", SqlDbType.Int).Value = CveUsuarioCapturo + .Add("@CvePersonalIncapacidad", SqlDbType.Int).Value = cvePersonalIncapacidad + .Add("@Folio", SqlDbType.VarChar).Value = folio + .Add("@FechaInicio", SqlDbType.DateTime).Value = fechaInicio + .Add("@DiasAutorizados", SqlDbType.Int).Value = diasAutorizados + .Add("@CveTipodeIncidencia", SqlDbType.Int).Value = cveTipodeIncidencia + .Add("@CveRamoSeguro", SqlDbType.Int).Value = cveRamoSeguro + .Add("@CveTipoRiesgo", SqlDbType.Int).Value = cveTipoRiesgo + .Add("@PorcentajedeIncapacidad", SqlDbType.Int).Value = porcentajedeIncapacidad + .Add("@CveSecuelaConsecuencia", SqlDbType.Int).Value = cveSecuelaConsecuencia + .Add("@CveControlIncapacidad", SqlDbType.Int).Value = cveControlIncapacidad + .Add("@Descripcion", SqlDbType.VarChar).Value = descripcion + End With + SqlAdapter.Fill(Data) + retorno = True + Catch sqEx As SqlException + retorno = False + OnError("Ocurrió un error al actualizar las tablas de nomina.", sqEx, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + retorno = False + OnError("Ocurrió un error al actualizar las tablas de nomina.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return retorno + End Function + Public Function PersonalIncapacidadRemove(CveUsuarioCapturo As Integer, cvePersonalIncapacidad As Int32) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_Nom_PersonalIncapacidadRemove", CommandType.StoredProcedure) + Try + With SqlAdapter.SelectCommand.Parameters + .Add("@CveUsuarioCapturo", SqlDbType.Int).Value = CveUsuarioCapturo + .Add("@CvePersonalIncapacidad", SqlDbType.Int).Value = cvePersonalIncapacidad + End With + SqlAdapter.Fill(Data) + retorno = True + Catch sqEx As SqlException + retorno = False + OnError("Ocurrió un error al eliminar las tablas de nomina.", sqEx, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + retorno = False + OnError("Ocurrió un error al eliminar las tablas de nomina.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return retorno + End Function + + Public Function PersonalIncapacidadCatalogos() As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_Nom_PersonalIncapacidadCatalogos", CommandType.StoredProcedure) + Try + SqlAdapter.Fill(Data) + retorno = True + Catch sqEx As SqlException + retorno = False + OnError("Ocurrió un error al obtener las tablas de incapacidad.", sqEx, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + retorno = False + OnError("Ocurrió un error al obtener las tablas de incapacidad.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return retorno + End Function +#End Region #Region "CRUD_Acumulados" Public Function GetAcumuladosTipos() As Boolean Dim retorno As Boolean = False diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 2f896980b..8fe10c062 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -1490,7 +1490,7 @@ Public Class ClsPaginas ' Application("GlobalDTBancosCuentas") = value ' End Set 'End Property - Property GlobalDTBancosCuentas(CveUsuario As Integer, Optional CveCuenta As Integer = -1, Optional Estatus As Integer = 1, Optional CveEmpresa As Integer = -1) As DataTable + Property GlobalDTBancosCuentas(CveUsuario As Integer, Optional CveCuenta As Integer = -1, Optional Estatus As Integer = 1, Optional CveEmpresa As Integer = -1, Optional CveTipoCuenta As Integer = -1) As DataTable Get Dim AppNombre As String = String.Format("GlobalDTBancosCuentas-{0}", CveEmpresa) 'sino existe, recarga los datos @@ -1506,6 +1506,7 @@ Public Class ClsPaginas Dim Str As String = String.Format("CveEmpresa = {0} ", UsuarioActual.CveEmpresa) If CveUsuario > -1 Then Str = String.Format("{0} AND CveUsuario = {1}", Str, CveUsuario) + If CveTipoCuenta > -1 Then Str = String.Format("{0} AND CveTipoCuenta = {1}", Str, CveTipoCuenta) If CveCuenta > -1 Then Str = String.Format("{0} AND CveCuenta = {1}", Str, CveCuenta) If Estatus > -1 Then Str = String.Format("{0} AND Estatus = '{1}'", Str, If(Estatus = 1, "Activo", "Inactivo")) diff --git a/App_Code/ClsProductosServicios.vb b/App_Code/ClsProductosServicios.vb index 9d400ef08..159317562 100644 --- a/App_Code/ClsProductosServicios.vb +++ b/App_Code/ClsProductosServicios.vb @@ -404,7 +404,7 @@ Public Class ClsProductosServicios Optional CveFraccionArancelaria As Integer = -1, Optional CveClasificacionDetalle As Integer = -1, Optional CveTamaño As Integer = -1, Optional CveModelo As Integer = -1, Optional CveMedida As Integer = -1, Optional CveRinTamaño As Integer = -1, Optional ClaveImpuestoEmpaque As String = "", Optional ClaveImpuestoUM As String = "", Optional ClaveCategoriaToxicidad As String = "", Optional ClaveImpuestoTipoProducto As String = "", Optional Litraje As Double = -1, Optional EsOutSourcing As Boolean = False, Optional AplicaSerie As Boolean = False, Optional AplicaLote As Boolean = False, - Optional AplicaCaducidad As Boolean = False, Optional AplicaSeccion As Boolean = False) As Integer + Optional AplicaCaducidad As Boolean = False, Optional AplicaSeccion As Boolean = False, Optional TiempoCaducidad As Integer = -1) As Integer Dim Retorno As Integer = -1 DataAdapter("PA_ProductosServiciosAdd") @@ -483,6 +483,7 @@ Public Class ClsProductosServicios .Add("@AplicaLote", SqlDbType.Bit).Value = AplicaLote .Add("@AplicaCaducidad", SqlDbType.Bit).Value = AplicaCaducidad .Add("@AplicaSeccion", SqlDbType.Bit).Value = AplicaSeccion + .Add("@TiempoCaducidad", SqlDbType.SmallInt).Value = TiempoCaducidad End With Try @@ -629,7 +630,7 @@ Public Class ClsProductosServicios Optional CveFraccionArancelaria As Integer = -1, Optional CveUsuarioModifico As Integer = -1, Optional CveClasificacionDetalle As Integer = -1, Optional CveTamaño As Integer = -1, Optional CveModelo As Integer = -1, Optional CveMedida As Integer = -1, Optional CveRinTamaño As Integer = -1, Optional ClaveImpuestoEmpaque As String = "", Optional ClaveImpuestoUM As String = "", Optional ClaveCategoriaToxicidad As String = "", Optional ClaveImpuestoTipoProducto As String = "", Optional Litraje As Double = -1, Optional EsOutSourcing As Boolean = False, - Optional AplicaSerie As Boolean = False, Optional AplicaLote As Boolean = False, Optional AplicaCaducidad As Boolean = False, Optional AplicaSeccion As Boolean = False) As Boolean + Optional AplicaSerie As Boolean = False, Optional AplicaLote As Boolean = False, Optional AplicaCaducidad As Boolean = False, Optional AplicaSeccion As Boolean = False, Optional TiempoCaducidad As Integer = -1) As Boolean Dim Retorno As Boolean = False @@ -710,6 +711,7 @@ Public Class ClsProductosServicios .Add("@AplicaLote", SqlDbType.Bit).Value = AplicaLote .Add("@AplicaCaducidad", SqlDbType.Bit).Value = AplicaCaducidad .Add("@AplicaSeccion", SqlDbType.Bit).Value = AplicaSeccion + .Add("@TiempoCaducidad", SqlDbType.SmallInt).Value = TiempoCaducidad End With Try diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index 474a9d366..df81cf748 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -107,40 +107,40 @@ Public Class ClsVentas Data = New DataTable End Sub -#Region "Conexiones" +#Region "Conexiones" - Private Sub ConexionAdd() - If Not EsTransaccionCompartida AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + Private Sub ConexionAdd() + If Not EsTransaccionCompartida AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then Try DataAdapter("PA_Sis_RegistrarConexion") With SqlAdapter.SelectCommand.Parameters .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name .Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}?{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString) .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output - End With - SqlAdapter.Fill(Data) - CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero - Catch ex As Exception - OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - End If - End Sub - - Private Sub ConexionClose() - If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then - - DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) - - Try - SqlAdapter.Fill(Data) - - Catch ex As Exception - OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - CveConexion = 0 - End If - + End With + SqlAdapter.Fill(Data) + CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + End Sub + + Private Sub ConexionClose() + If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) + + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + CveConexion = 0 + End If + End Sub #End Region @@ -4591,6 +4591,75 @@ Public Class ClsVentas End Try Return retorno End Function + + Public Function GetClientesPersonalEntrega(CvePersonalEntrega As Integer, CveCliente As Integer, CveEmpresa As Integer, Estatus As Integer) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_Vta_ClientesPersonalEntregaGet", CommandType.StoredProcedure) + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePersonalEntrega", SqlDbType.Int).Value = CvePersonalEntrega + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Estatus", SqlDbType.Int).Value = Estatus + End With + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los clientes personal entrega", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return retorno + End Function + + Public Function AddClientesPersonalEntrega(PersonalEntrega As String, CveCliente As Integer, CveUsuario As Integer, Estatus As Boolean) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_Vta_ClientesPersonalEntregaAdd", CommandType.StoredProcedure) + With SqlAdapter.SelectCommand.Parameters + .Add("@PersonalEntrega", SqlDbType.NVarChar).Value = PersonalEntrega + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + End With + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar el personal entrega", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return retorno + End Function + + Public Function UpdateClientesPersonalEntrega(CvePersonalEntrega As Integer, PersonalEntrega As String, CveUsuario As Integer, Estatus As Boolean) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_Vta_ClientesPersonalEntregaUpdate", CommandType.StoredProcedure) + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePersonalEntrega", SqlDbType.Int).Value = CvePersonalEntrega + .Add("@PersonalEntrega", SqlDbType.NVarChar).Value = PersonalEntrega + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@Estatus", SqlDbType.Bit).Value = Estatus + End With + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el personal entrega", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return retorno + End Function + + Public Function RemoveClientesPersonalEntrega(CvePersonalEntrega As Integer) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_Vta_ClientesPersonalEntregaDelete", CommandType.StoredProcedure) + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePersonalEntrega", SqlDbType.Int).Value = CvePersonalEntrega + End With + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar el personal entrega", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return retorno + End Function #Region "Conciliación emitidas SAT" Public Function ConciliacionemitidasSATGet(cveEmpresa As Int32) As Boolean diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 2f8750b96..0ed55e76e 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -855,7 +855,7 @@ Namespace Modelos End If If CveCicloComercial > 0 AndAlso ErrorList.Count = 0 Then - If Not ObjContr.CicloComercialUpdate(Me.CveCicloComercial, True, UsuarioActual.CveEmpresa) Then + If Not ObjContr.CicloComercialUpdate(Me.CveCicloComercial, True, UsuarioActual.CveEmpresa, CveVenta:=CveVenta) Then ErrorList.Add("No se pudo actualizar ") End If End If diff --git a/Ashx/SIGFacturacionCiclica.ashx b/Ashx/SIGFacturacionCiclica.ashx new file mode 100644 index 000000000..ca832ce20 --- /dev/null +++ b/Ashx/SIGFacturacionCiclica.ashx @@ -0,0 +1,709 @@ +<%@ WebHandler Language="VB" Class="SIGFacturacionCiclica" %> +'Option Explicit On +'Option Strict On + +Imports System +Imports System.Web +Imports System.Data +Imports Newtonsoft.Json.Linq +Imports Extensiones +Imports System.IO +Imports Microsoft.AspNet.SignalR + +Public Class SIGFacturacionCiclica : Implements IHttpHandler, IRequiresSessionState + Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest + context.Response.ContentType = "text/plain" + Dim retorno = False + Try + If context.Request("Metodo") IsNot Nothing Then + Select Case context.Request("Metodo") + Case "EjecutaServicio" + ModExtensiones.GuardaLogAD("Servicio Ejecutado...........", "LogFacturacionCiclica") + retorno = IniciaFacturacionMasiva() + End Select + + End If + + Catch ex As Exception + ex.GuardaLog(ex.Message) + End Try + + If retorno Then + context.Response.Write("True") + Else + context.Response.Write("False") + End If + End Sub + + Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable + Get + Return False + End Get + End Property + + Private Function Parametros(Cadena As String) As Hashtable + Dim P1() As String = Cadena.Split("&"c) + Dim Tmp As String + Dim P2() As String + + Dim URLParametros As New Hashtable + + For Each Tmp In P1 + P2 = Tmp.Replace("%26%", "&").Split("="c) + URLParametros.Add(P2(0).ToString.ToUpper, P2(1)) + Next + Return URLParametros + End Function + +#Region "V A L I D A - D A T O S" + Private Function ValidaUsuarioSistema(CveEmpresa As Integer) As Usuario + Dim UsuarioActual As Usuario = Nothing + Dim ObjUsuarios As New ClsSisUsuarios + If ObjUsuarios.GetUsuarios(100) Then + If ObjUsuarios.DtResultados.Rows.Count > 0 Then + Dim Usuario = ObjUsuarios.DtResultados.Rows(0)("Usuario").ToString() + Dim Contrasenia = ObjUsuarios.DtResultados.Rows(0)("Contraseña").ToString() + UsuarioActual = ObjUsuarios.ValidaUsuario(Usuario, Contrasenia, IMEI, CveEmpresa) + UsuarioActual.CveEmpresa = CveEmpresa + CreaObjetoEmpresa(UsuarioActual) + End If + End If + ObjUsuarios.Dispose() + Return UsuarioActual + End Function + Private Sub CreaObjetoEmpresa(ByRef UsuarioActual As Usuario) + + Dim ObjEmpresa As New ClsSisEmpresas() + If ObjEmpresa.GetEmpresas(UsuarioActual.CveEmpresa, "-1", "-1", "-1", "-1") Then + If ObjEmpresa.GetEmpresasFuncionalidades(UsuarioActual.CveEmpresa) Then + Dim dttmp As Data.DataTable = ObjEmpresa.DtResultados + + Dim EmpresasFuncionalidades As New HybridDictionary + For Each Row As Data.DataRow In dttmp.Rows + EmpresasFuncionalidades.Add(Convert.ToInt32(Row("CveFuncionalidad")), Row("Valor").ToString) + Next + ObjEmpresa.Empresa.SetFuncionalidades(EmpresasFuncionalidades) + End If + + UsuarioActual.Empresa = ObjEmpresa.Empresa + End If + ObjEmpresa.Dispose() + End Sub + +#End Region + + Private Function IniciaFacturacionMasiva() As Boolean + Dim Retorno As Boolean = True + Dim FechaRef As DateTime = DateTime.Now + Dim DTCicloComercial As DataTable = Nothing + + Using ObjContratos As New ClsContratos + If ObjContratos.CicloComercialGet(-1, -1, -1, -1, FechaRef, FechaRef, -1) Then + DTCicloComercial = ObjContratos.DtResultados.FiltraParametros("FueFacturado = 0 AND FacturacionCiclicaAutomatico = 1") + End If + End Using + + If DTCicloComercial IsNot Nothing Then + For Each RowEmpresa As DataRow In DTCicloComercial.FiltraParametros("", DistinctColumns:={"CveEmpresa"}).Rows + Dim CveEmpresa As Integer = RowEmpresa("CveEmpresa").ToString().ToEntero() + Dim UsuarioActual = ValidaUsuarioSistema(CveEmpresa) + If UsuarioActual IsNot Nothing Then + Retorno = EjecutarFacturacionMasiva(UsuarioActual, DTCicloComercial.FiltraParametros($"CveEmpresa = {CveEmpresa}")) + End If + Next + End If + + Return Retorno + End Function + + Private Function EjecutarFacturacionMasiva(UsuarioActual As Usuario, DTCicloComercial As DataTable) As Boolean + Dim Retorno As Boolean = False + + If DTCicloComercial IsNot Nothing Then + For Each Row As DataRow In DTCicloComercial.Rows + + If Row("Observaciones").ToString().Contains("{DIA}") Then + Row("Observaciones") = Row("Observaciones").ToString().Replace("{DIA}", DateTime.Now.Day.ToString()) + End If + + If Row("Observaciones").ToString().Contains("{MES}") Then + Dim fecha As DateTime = DateTime.Now + Dim formatoFecha = Globalization.CultureInfo.CurrentCulture.DateTimeFormat + Dim nombreMes = formatoFecha.GetMonthName(fecha.Month).ToUpper() + + Row("Observaciones") = Row("Observaciones").ToString().Replace("{MES}", nombreMes) + End If + + If Row("Observaciones").ToString().Contains("{AÑO}") Then + Row("Observaciones") = Row("Observaciones").ToString().Replace("{AÑO}", DateTime.Now.Year.ToString()) + End If + + If Row("Observaciones").ToString().Contains("{TC}") Then + Row("Observaciones") = Row("Observaciones").ToString().Replace("{TC}", GlobalTipoCambio(Now).FormatoNumero) + End If + + Dim Resp = EmitirImprimir(UsuarioActual, Row) + + If Resp.CveVenta > 0 Then + Retorno = True + End If + + Next + + End If + + Return Retorno + End Function + + Private Function EmitirImprimir(UsuarioActual As Usuario, RowCiclo As DataRow) As Modelos.Factura.MMensajeFactura + Dim Resp As New Modelos.Factura.MMensajeFactura + + Dim ObjFactura = CreaObjetosVenta(UsuarioActual, RowCiclo) + + If ObjFactura Is Nothing Then + Resp.Mensajes.Add("Ocurrió un error al procesar los datos de la Venta ") + ObjFactura = Nothing + Return Resp + End If + + If ObjFactura.CveCliente > 0 Then + If ObjFactura.DtDetalle.Rows.Count > 0 Then + Resp = ObjFactura.EmitirFactura() + Else + Resp.Mensajes.Add("No se pudo completar facturación por que no se encontraron partidas ") + End If + Else + Resp.Mensajes.Add("No se pudo completar facturación por que no se encontraro el cliente ") + End If + + Return Resp + End Function + +#Region "P R E P A R A - V E N T A" + Private Function CreaDTVentas() As DataTable + Dim TmpDT = 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("AsientoContableVentas", GetType(Integer)) + TmpDT.Columns.Add("IdCtaContVentas", GetType(Integer)) + TmpDT.Columns.Add("AplicaParaConcepto", GetType(Boolean)) + 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("CveTamaño", GetType(Integer)) + TmpDT.Columns.Add("EsCargo", GetType(Boolean)) + + Return TmpDT + End Function + Private Function CreaObjetosVenta(UsuarioActual As Usuario, DR As DataRow) As Modelos.Factura + Dim ObjFactura = New Modelos.Factura(UsuarioActual) + Try + ObjFactura.DirectorioServidor = HttpContext.Current.Server.MapPath("/") + + Dim CveProyecto As String = "" + Dim CveSubProyecto As String = "" + Dim Proyecto As String = "" + Dim SubProyecto As String = "" + Dim CveCicloComercial = DR("CveCicloComercial").ToString().ToEntero() + + ObjFactura.CveCicloComercial = CveCicloComercial + + Dim TmpDT As DataTable = CreaDTVentas() + + ObjFactura.Version = "3.3" + ObjFactura.CveUsuario = UsuarioActual.CveUsuario + ObjFactura.CveEmpresa = UsuarioActual.CveEmpresa + ObjFactura.ConvertirPesos = False + ObjFactura.CveMoneda = DR("CveMoneda").ToString.ToEntero + ObjFactura.Moneda = GlobalDTMonedas.FiltroPrimeroValor("Moneda", $"CveMoneda = {ObjFactura.CveMoneda} ") + ObjFactura.MonedaSAT = GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", $"CveMoneda = {DR("CveMoneda").ToString.ToEntero}") + ObjFactura.TipoCambio = If(ObjFactura.CveMoneda = 1, 1, GlobalTipoCambio(Now)) + ObjFactura.TipoDocto = "Ing" + ObjFactura.RefDocto = "" + ObjFactura.Folio = -1 + ObjFactura.Serie = "-1" + ObjFactura.CveMesa = -1 + ObjFactura.Fecha = DR("FechaVenc").ToString.ToDate + ObjFactura.CvePrePoliza = -1 + ObjFactura.CveMetodoPago = 1 + ObjFactura.MetodoPago = "Efectivo" + ObjFactura.FechaPago = DateTime.Today + ObjFactura.MotivoDescuento = "" + ObjFactura.Observaciones = DR("Observaciones").ToString + ObjFactura.FechaEjecucion = DateTime.Today + 'ObjFactura.ClaveMetodoPagoSAT = GlobalDTMetodosPago.FiltroPrimeroValor("ClaveSAT", $"CveMetodoPago = {1}") + ObjFactura.UsuarioCreo = UsuarioActual.Usuario + ObjFactura.CveCondicionEntrega = -1 + ObjFactura.CondicionEntrega = "" + ObjFactura.NumeroCuenta = "" + 'ObjFactura.CveSucursal = GlobalDTSucursales.FiltroPrimeroValor("CveSucursal", $"CveEmpresa = {UsuarioActual.CveEmpresa}").ToEntero + 'ObjFactura.Cliente.NumCtaPago = TxtNumCtaPago.Text.Trim + ObjFactura.CondicionesPago = 0 + ObjFactura.FormaPago = 0 + 'ObjFactura.SerieFolio = String.Format("{0}-{1}", LblSerie.Text, TxtFolio.Text) + ObjFactura.PedidoContrato = "" + ObjFactura.NumeroContrato = DR("NumeroContrato").ToString + ObjFactura.DescripcionContrato = DR("DescripcionContrato").ToString + ObjFactura.CveCorte = -1 + ObjFactura.TipoDocumento = "Factura" + ObjFactura.Alfa1 = "" + ObjFactura.Alfa2 = "" + ObjFactura.Alfa3 = "" + 'Totales, Y se llena TmpDTImpuestos + ObjFactura.Descuento = 0 + ObjFactura.Amortizacion = 0 + ObjFactura.CveContrato = DR("CveContrato").ToString.ToEntero + CveProyecto = DR("CveProyecto").ToString + Proyecto = DR("ProyectoContrato").ToString + CveSubProyecto = DR("CveSubProyecto").ToString + ObjFactura.CveSubProyecto = CveSubProyecto.ToEntero + ObjFactura.CveSubProyectoCobranza = CveSubProyecto.ToEntero + ObjFactura.CveSubProyectoEjecucion = CveSubProyecto.ToEntero + + ObjFactura.SubProyecto = New Modelos.SubProyectoModel(GlobalDTSubProyectos(-1).FiltroPrimero(String.Format("CveSubProyecto = {0}", ObjFactura.CveSubProyecto))) + ObjFactura.SubProyectoMatriz = New Modelos.SubProyectoModel(GlobalDTSubProyectos(-1, CveSubProyecto:=-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("TipoSucursal=1")) + + + SubProyecto = DR("SubProyectoContrato").ToString + + Dim DtDetalle As DataTable = Nothing + Dim objContratos As New ClsContratos + If objContratos.GetContratosDetalle(DR("CveContrato").ToString.ToEntero) Then + DtDetalle = objContratos.DtResultados + Else + DtDetalle = Nothing + End If + objContratos.Dispose() + + Dim DtR As DataRow + ObjFactura.SubTotal = SUM(DtDetalle, "Total").ToDecimal + ObjFactura.IVA = SUM(DtDetalle, "ImporteIVA").ToDecimal + ObjFactura.RetIVA = SUM(DtDetalle, "ImporteRetIVA").ToDecimal + ObjFactura.RetISR = SUM(DtDetalle, "ImporteRetISR").ToDecimal + ObjFactura.IEPS = SUM(DtDetalle, "ImporteIEPS").ToDecimal + ObjFactura.Total = ObjFactura.SubTotal + ObjFactura.IVA + ObjFactura.IEPS - (ObjFactura.RetIVA + ObjFactura.RetISR) + + For Each row As DataRow In DtDetalle.Rows + Dim drPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=row("CvePS").ToString().ToEntero()).FiltroPrimero("") + + DtR = TmpDT.NewRow + DtR("CveVenta") = -1 + DtR("Codigo") = row("Codigo") + DtR("Consec") = TmpDT.Rows.Count + 1 + DtR("Cantidad") = row("CantidadContratada") + DtR("CveUM") = row("CveUM") + DtR("UM") = row("UM") + DtR("SATClaveUM") = row("SATClaveUM") + DtR("CveClasificacion") = row("CveClasificacion") + DtR("Clasificacion") = row("Clasificacion") + DtR("CvePS") = row("CvePS") + DtR("PS") = row("PS") + DtR("CodigoPS") = row("CodigoPS") + DtR("SATClaveProdServ") = row("SATClaveProdServ") + DtR("NoIdentificacion") = row("NoIdentificacion") + DtR("CveTipoPS") = drPS("CveTipoPS") + DtR("CveTipoInvPS") = drPS("Inv_CveMetodoInventario") + DtR("Obs") = row("Observacion").ToString + DtR("PU") = row("PU") + DtR("IVA") = row("PorcentajeIVA") + DtR("PorcentajeIVA") = row("PorcentajeIVA") + DtR("ImporteIVA") = row("ImporteIVA") + DtR("PorcentajeIEPS") = row("PorcentajeIEPS") + DtR("ImporteIEPS") = row("ImporteIEPS") + DtR("PorcentajeRetIVA") = row("PorcentajeRetIVA") + DtR("ImporteRetIVA") = row("ImporteRetIVA") + DtR("PorcentajeRetISR") = row("PorcentajeRetISR") + DtR("ImporteRetISR") = row("ImporteRetISR") + DtR("Descuento") = 0 + DtR("TipoDescuento") = 0 + DtR("CveProyecto") = CveProyecto + DtR("Proyecto") = Proyecto + DtR("CveSubProyecto") = CveSubProyecto + DtR("SubProyecto") = SubProyecto + DtR("CveVentaDetalle") = 0 + DtR("CveContratoDetalle") = row("CveContratoDetalle") + DtR("CuentaPredial") = row("CuentaPredial") + DtR("TotalImporte") = row("Total") + + TmpDT.Rows.Add(DtR) + Next + + 'DETALLES + ObjFactura.DtDetalle = TmpDT + + 'CLIENTE + ObjFactura.CveCliente = DR("CveCliente").ToString.ToEntero + ObjFactura.SetCliente() + + Dim ObjCliente As New ClsClientes + If ObjCliente.GetClientes(ObjFactura.CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, -1, TipoCliente:=-1) Then + If ObjCliente.DtResultados.Rows.Count > 0 Then + ObjFactura.CveFormaPago33 = ObjCliente.CveFormaPago33 + ObjFactura.FormaPago33 = GlobalDTVtaFormaPago.FiltroPrimeroValor("FormaPago", String.Format("CveFormaPago = {0}", ObjCliente.CveFormaPago33)) + ObjFactura.FormaPagoSAT33 = GlobalDTVtaFormaPago.FiltroPrimeroValor("ClaveFormaPagoSAT", String.Format("CveFormaPago = {0}", ObjCliente.CveFormaPago33)) + + ObjFactura.CveMetodoPago33 = ObjCliente.CveMetodoPago33 + ObjFactura.MetodoPago33 = GlobalDTVtaMetodoPago.FiltroPrimeroValor("MetodoPago", String.Format("CveMetodoPago = {0}", ObjCliente.CveMetodoPago33)) + ObjFactura.ClaveMetodoPagoSAT = GlobalDTVtaMetodoPago.FiltroPrimeroValor("ClaveMetodoPagoSAT", String.Format("CveMetodoPago = {0}", ObjCliente.CveMetodoPago33)) + + ObjFactura.CveUsoCFDI = ObjCliente.CveUsoCFDI + ObjFactura.UsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("Descripcion", String.Format("CveUsoCFDI = {0}", ObjCliente.CveUsoCFDI)) + ObjFactura.ClaveUsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("UsoCFDI", String.Format("CveUsoCFDI = {0}", ObjCliente.CveUsoCFDI)) + + ObjFactura.CveMetodoPago = ObjCliente.CveMetodoPago + + If GlobalDTMetodosPago.FiltraParametros(String.Format("CveMetodoPago = {0}", ObjCliente.CveMetodoPago)).Rows.Count > 0 Then + ObjFactura.MetodoPago = GlobalDTMetodosPago.FiltraParametros(String.Format("CveMetodoPago = {0}", ObjCliente.CveMetodoPago)).Rows(0)("MetodoPago").ToString + Else + ObjFactura.CveMetodoPago = 1 + ObjFactura.MetodoPago = "Efectivo" + End If + End If + End If + + If ObjCliente.GetSucursales(ObjFactura.CveCliente) Then + If ObjCliente.DtResultados.Rows.Count > 0 Then + ObjFactura.CveClienteSucursal = If(String.IsNullOrEmpty(ObjCliente.DtResultados.FiltroPrimeroValor("CveClienteSucursal", "Estatus = 'Activo'")), -1, ObjCliente.DtResultados.FiltroPrimeroValor("CveClienteSucursal", "Estatus = 'Activo'").ToEntero()) + Else + ObjFactura.CveClienteSucursal = -1 + End If + End If + ObjCliente.Dispose() + + 'SUBPROYECTO + 'ObjFactura.SetSubProyectoMatriz(Me) + 'ObjFactura.SetSubProyecto(Me) + + ObjFactura.Timbre = PreParaTimbre(ObjFactura, UsuarioActual) + Catch ex As Exception + ObjFactura = Nothing + OnError("Ocurrió un error al generar la factura", ex) + End Try + + + Return ObjFactura + + End Function + + Private Function PreParaTimbre(Obj As Modelos.Factura, UsuarioActual As Usuario) As CFDITimbre + Dim Timbre As New CFDITimbre + Timbre.Comprobante.TipoComprobante = If(Obj.TipoDocto.Contiene("Ing", "Ant"), "I", If(Obj.TipoDocto.Contiene("Egs", "Dev"), "E", "")) + Timbre.Comprobante.Folio = Obj.Folio.ToString + Timbre.Comprobante.Serie = Obj.Serie + Timbre.Comprobante.Fecha = Obj.FechaCP + Timbre.Comprobante.FormadePago = Obj.FormaPagoSAT33 + Timbre.Comprobante.CondicionesdePago = Obj.FormaPago33 + Timbre.Comprobante.MetodoPago = Obj.ClaveMetodoPagoSAT + Timbre.Comprobante.Subtotal = Obj.SubTotal + Timbre.Comprobante.Descuentos = Obj.Descuento + Timbre.Comprobante.Moneda = Obj.MonedaSAT + Timbre.Comprobante.TipoCambio = If(Obj.CveMoneda = 1, "1", Obj.TipoCambio.ToString) + Timbre.Comprobante.Total = Obj.Total + + Timbre.Comprobante.LugarExpedicion = Obj.SubProyecto.CP + Timbre.Comprobante.Confirmacion = "" + + Timbre.Receptor.RFC = Obj.Cliente.RFC + Timbre.Receptor.Nombre = Obj.Cliente.Nombre + Timbre.Receptor.ResidenciaFiscal = "" + Timbre.Receptor.NumeroRegistroTributario = "" + Timbre.Receptor.UsoCFDI = Obj.ClaveUsoCFDI + + + If Obj.CveTipoRelacion > 0 Then + Select Case Obj.CveTipoRelacion + Case 1 + Timbre.CFDIRelacionados.TipoRelacion = "01" + Timbre.CFDIRelacionados.TipoRelacionTexto = "01-Nota de Crédito aplicada a Ingreso" + Case 2 + Timbre.CFDIRelacionados.TipoRelacion = "02" + Timbre.CFDIRelacionados.TipoRelacionTexto = "02-Nota de débito de los documentos relacionados" + Case 3 + Timbre.CFDIRelacionados.TipoRelacion = "03" + Timbre.CFDIRelacionados.TipoRelacionTexto = "03-Devolución aplicada a Ingreso" + Case 4 + Timbre.CFDIRelacionados.TipoRelacion = "04" + Timbre.CFDIRelacionados.TipoRelacionTexto = "04-Refacturación de Ingreso" + Case 7 + Timbre.CFDIRelacionados.TipoRelacion = "07" + Timbre.CFDIRelacionados.TipoRelacionTexto = "07-CFDI por aplicación de anticipo" + Case 8 + Timbre.CFDIRelacionados.TipoRelacion = "08" + Timbre.CFDIRelacionados.TipoRelacionTexto = "08-Factura generada por pagos en parcialidades " + Case 9 + Timbre.CFDIRelacionados.TipoRelacion = "09" + Timbre.CFDIRelacionados.TipoRelacionTexto = "09-Factura generada por pagos diferidos" + + End Select + + 'If DtVentasNC IsNot Nothing AndAlso DtVentasNC.Rows.Count > 0 Then + ' For Each Dr As DataRow In DtVentasNC.Rows + ' Timbre.CFDIRelacionados.UUID.Add(Dr("FolioFiscal").ToString) + ' Next + 'Else + ' Timbre.CFDIRelacionados.UUID.Add(HdnFolioFiscalNC.Value) + 'End If + + End If + + + Dim totSubTotal As Decimal = Obj.SubTotal + Dim totIVA As Decimal = Obj.IVA + Dim totRetIVA As Decimal = Obj.RetIVA + Dim totRetISR As Decimal = Obj.RetISR + Dim i As Integer = 1 + + 'detalles + Dim tPS As String = "" + + For Each drr As DataRow In Obj.DtDetalle.Rows + If drr("PS").ToString.Length = 1 Then + tPS = drr("Obs").ToString + Else + If drr("PS").ToString.Length = 0 Then + tPS = "" + Else + tPS = String.Format("{0} {1}", drr("PS"), drr("Obs")) + End If + End If + 'condicionante, especial + If UsuarioActual.CveEmpresa = 15 Then drr("UM") = "" ' les comentan que no debe de ir la etiqueta de "unidad" en el producto + + Dim concepto As New CFDIConceptos With {.Cantidad = drr("Cantidad").ToString.ToDecimal, + .Descripcion = tPS, + .ValorUnitario = drr("PU").ToString.ToDecimal, + .Importe = drr("TotalImporte").ToString.ToDecimal, + .Descuento = drr("Descuento").ToString.ToDecimal, + .Unidad = drr("UM").ToString, + .ClaveUnidad = drr("SATClaveUM").ToString, + .ClaveProdServ = drr("SATClaveProdServ").ToString, + .Noidentificacion = drr("Noidentificacion").ToString, + .CuentaPredial = drr("CuentaPredial").ToString} + 'verifica suma subtotales + If i = Obj.DtDetalle.Rows.Count AndAlso totSubTotal <> concepto.Importe Then 'proceso de ajusta de decimales + concepto.Importe = totSubTotal + End If + totSubTotal = totSubTotal - concepto.Importe + + 'siempre estaremos agregando el iva, auqnue sea en importe cero o tasa cero, para que se emita la factura + ' If drr("ImporteIVA").ToString.ToDouble > 0 Then + concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeIVA").ToString.ToDecimal, .Impuesto = "002", .Importe = drr("ImporteIVA").ToString.ToDecimal}) + ' End If + + If drr("ImporteIEPS").ToString.ToDouble > 0 Then + concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeIEPS").ToString.ToDecimal, .Impuesto = "003", .Importe = drr("ImporteIEPS").ToString.ToDecimal}) + End If + + If drr("ImporteRetIVA").ToString.ToDouble > 0 Then 'si hay retenciones + concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "R", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeRetIVA").ToString.ToDecimal, .Impuesto = "002", .Importe = drr("ImporteRetIVA").ToString.ToDecimal}) + End If + + If drr("ImporteRetISR").ToString.ToDouble > 0 Then 'retención de ISR + concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "R", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeRetISR").ToString.ToDecimal, .Impuesto = "001", .Importe = drr("ImporteRetISR").ToString.ToDecimal}) + End If + + Timbre.Conceptos.Add(concepto) + i += 1 + Next + Return Timbre + End Function +#End Region + + +#Region "G L O B A L - D T" + Public Property GlobalTipoCambio(Optional Fecha As Date = MinFecha) As Double + Get + If GlobalTipoCambio <= 0 Then + 'sino tiene dato lo recargo por si ya esta insertado + If Fecha = MinFecha Then Fecha = Now + + Dim ObjGral As New ClsGenerales + If ObjGral.GetTipoCambio(-1, Fecha) AndAlso ObjGral.DtResultados.Rows.Count > 0 Then + + HttpContext.Current.Application("GlobalTipoCambio") = ObjGral.DtResultados.Rows(0)("TipoCambio").ToString.ToDouble + Else + HttpContext.Current.Application("GlobalTipoCambio") = 0 + End If + ObjGral.Dispose() + + End If + + Return HttpContext.Current.Application("GlobalTipoCambio").ToString.ToDouble + End Get + Set(value As Double) + HttpContext.Current.Application("GlobalTipoCambio") = value + End Set + + End Property + Property GlobalDTMonedas() As DataTable + Get + GlobalDTMonedas = DirectCast(HttpContext.Current.Application("GlobalDTMonedas"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTMonedas") = value + End Set + End Property + ReadOnly Property GlobalDTPS(CveEmpresa As Integer, Optional CvePS As Integer = -1, Optional SATClavePS As String = "-1", Optional AplicaParaVenta As Integer = -1, Optional Estatus As Integer = -1, Optional Codigo As String = "-1") As DataTable + Get + Dim ObjPS As New ClsProductosServicios + + If ObjPS.GetPS(CvePS, -1, CveEmpresa, Codigo:=Codigo, SATClavePS:=SATClavePS, pAplicaParaVenta:=AplicaParaVenta, pEstado:=Estatus) Then + GlobalDTPS = ObjPS.DtResultados + Else + GlobalDTPS = Nothing + End If + + ObjPS.Dispose() + End Get + End Property + Public Property GlobalDTVtaFormaPago() As DataTable + Get + GlobalDTVtaFormaPago = DirectCast(HttpContext.Current.Application("GlobalDTVtaFormaPago"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTVtaFormaPago") = value + End Set + End Property + Property GlobalDTVtaMetodoPago() As DataTable + Get + GlobalDTVtaMetodoPago = DirectCast(HttpContext.Current.Application("GlobalDTVtaMetodoPago"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTVtaMetodoPago") = value + End Set + End Property + Property GlobalDTSATUsosCFDI(Optional EsPersonaFisica As Integer = -1) As DataTable + Get + If EsPersonaFisica <> -1 Then + Dim Tipo As String = "" + If EsPersonaFisica = 1 Then Tipo = "AplicaPersonaFisica = 1" Else Tipo = "AplicaPersonaMoral = 1" + + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTSATUsosCFDI"), DataTable), Tipo, " UsoCFDIDescripcion", DataViewRowState.CurrentRows) + GlobalDTSATUsosCFDI = Dv.ToTable + Dv.Dispose() + Else + GlobalDTSATUsosCFDI = DirectCast(HttpContext.Current.Application("GlobalDTSATUsosCFDI"), DataTable) + End If + + End Get + Set(ByVal value As DataTable) + HttpContext.Current.Application("GlobalDTSATUsosCFDI") = value + End Set + End Property + + Property GlobalDTMetodosPago() As DataTable + Get + GlobalDTMetodosPago = DirectCast(HttpContext.Current.Application("GlobalDTMetodosPago"), DataTable) + End Get + Set(value As DataTable) + HttpContext.Current.Application("GlobalDTMetodosPago") = value + End Set + End Property + Public Property GlobalDTSubProyectos(CveProyecto As Integer, Optional CveSubProyecto As Integer = -1, Optional CveEmpresa As Integer = -1, Optional Estatus As Integer = 1) As DataTable + Get + Dim AppNombre As String = String.Format("GlobalDTSubProyectos-{0}", CveEmpresa) + 'sino existe, recarga los datos + If DirectCast(HttpContext.Current.Application(AppNombre), DataTable) Is Nothing Or (DirectCast(HttpContext.Current.Application(AppNombre), DataTable) IsNot Nothing AndAlso DirectCast(HttpContext.Current.Application(AppNombre), DataTable).Rows.Count = 0) Then + Dim P As New ClsSubProyectos + If P.GetSubProyectos(CveEmpresa:=CveEmpresa) Then HttpContext.Current.Application(AppNombre) = P.DtResultados + P.Dispose() + End If + + If CveProyecto <> -1 OrElse CveSubProyecto <> -1 OrElse CveEmpresa <> -1 OrElse Estatus <> -1 Then + Dim StrSQL As New StringBuilder + If CveProyecto <> -1 Then StrSQL.AppendFormat(" AND CveProyecto = {0}", CveProyecto) + If CveSubProyecto <> -1 Then StrSQL.AppendFormat(" AND CveSubProyecto = {0}", CveSubProyecto) + If Estatus <> -1 Then StrSQL.AppendFormat(" AND CveEstatus = {0}", Estatus) + If CveEmpresa <> -1 Then StrSQL.AppendFormat(" AND CveEmpresa = {0}", CveEmpresa) + + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application(AppNombre), DataTable), StrSQL.ToString.Trim.TrimStart("A"c, "N"c, "D"c), "", DataViewRowState.CurrentRows) + GlobalDTSubProyectos = Dv.ToTable + Dv.Dispose() + + Else + GlobalDTSubProyectos = DirectCast(HttpContext.Current.Application(AppNombre), DataTable) + End If + + End Get + Set(ByVal value As DataTable) + Dim AppNombre As String = String.Format("GlobalDTSubProyectos-{0}", CveEmpresa) + HttpContext.Current.Application(AppNombre) = value + End Set + End Property +#End Region +End Class \ No newline at end of file diff --git a/Contratos/Contrato.aspx b/Contratos/Contrato.aspx index 4b9616588..3624dace8 100644 --- a/Contratos/Contrato.aspx +++ b/Contratos/Contrato.aspx @@ -487,14 +487,14 @@ -
+ <%--
-
+
--%>
@@ -575,14 +575,6 @@
- - -
- -
- -
-
@@ -816,12 +808,6 @@ - - - - - - @@ -408,7 +453,7 @@
- +
@@ -437,10 +482,10 @@ - + <%--GV DATOS--%> + DataKeyNames="Consec,CvePS,Codigo,CodigoBarras,AplicaSerieLote,CveUM,CantidadC,CantidadF,UM,PS,CveClasificacion,CveVentaDetalle,CveTamaño,AplicaSeccion, AplicaSerie,AplicaLote,AplicaCaducidad" HeaderStyle-CssClass="Titulos" CssClass="table table-striped table-hover Widthall ScrollAD gvInventario mysmallbtn" data-heighterror="450" data-freezerows="1" GridLines="None"> @@ -452,11 +497,11 @@ - + - + - + @@ -721,6 +766,7 @@
Cantidad +
@@ -763,6 +809,8 @@ Cant.: + +
@@ -885,7 +933,7 @@ # Cajas: - + diff --git a/Inventarios/EntregaAlmacen.aspx.vb b/Inventarios/EntregaAlmacen.aspx.vb index ec68fe2b0..ae40df21d 100644 --- a/Inventarios/EntregaAlmacen.aspx.vb +++ b/Inventarios/EntregaAlmacen.aspx.vb @@ -575,6 +575,7 @@ Partial Class Inventarios_EntregaAlmacen CveContrato = DtDatos.Rows(0)("CveContrato").ToString.ToEntero CveVendedor = DtDatos.Rows(0)("CveVendedor").ToString.ToEntero CveCliente = DtDatos.Rows(0)("CveCliente").ToString.ToEntero + ClienteEntregaPersonal(CveCliente) CveSubProyecto = DtDatos.Rows(0)("CveSubProyecto").ToString.ToEntero EsInterno = CBool(DtDatos.Rows(0)("EsInterno").ToString) @@ -3774,8 +3775,25 @@ Partial Class Inventarios_EntregaAlmacen ElseIf RbEntregaInterna.Checked Then 'RegistraScript("$('#ModalPaqueteriaInterna').modal('show')") End If - End Sub + End Sub #End Region - - + +#Region "Cliente entrega personal" + Private Sub ClienteEntregaPersonal(CveCliente As Integer) + Dim ObjVentas As New ClsVentas() + If ObjVentas.GetClientesPersonalEntrega(-1, CveCliente, UsuarioActual.CveEmpresa, 1) Then + If ObjVentas.DtResultados.Rows.Count > 0 Then + GvClentesPersonalEntrega.DataSource = ObjVentas.DtResultados + GvClentesPersonalEntrega.DataBind() + DivPersonalEntrega.Visible = True + Else + DivPersonalEntrega.Visible = False + End If + End If + ObjVentas.Dispose() + UpClentesPersonalEntrega.Update() + End Sub +#End Region + + End Class diff --git a/Inventarios/Kardex.aspx b/Inventarios/Kardex.aspx index 4df28a4d8..d3d08e46b 100644 --- a/Inventarios/Kardex.aspx +++ b/Inventarios/Kardex.aspx @@ -139,7 +139,7 @@
-
+
"> @@ -156,7 +156,7 @@
<%----%> -
diff --git a/Inventarios/KardexAlmacenHorizontal.aspx b/Inventarios/KardexAlmacenHorizontal.aspx index 6e64d0cb0..3ccaa1725 100644 --- a/Inventarios/KardexAlmacenHorizontal.aspx +++ b/Inventarios/KardexAlmacenHorizontal.aspx @@ -93,7 +93,7 @@ Generar Excel
  • - +
  • @@ -200,8 +200,8 @@
    - - + +
    diff --git a/Inventarios/KardexAlmacenHorizontal.aspx.vb b/Inventarios/KardexAlmacenHorizontal.aspx.vb index 105d2bca4..9179c58de 100644 --- a/Inventarios/KardexAlmacenHorizontal.aspx.vb +++ b/Inventarios/KardexAlmacenHorizontal.aspx.vb @@ -344,7 +344,7 @@ Partial Class Inventarios_KardexAlmacen End Sub - Protected Sub LnkProyectos_Click(sender As Object, e As EventArgs) + Protected Sub LnkProyectado_Click(sender As Object, e As EventArgs) RegistraScript(String.Format("$('#{0}').modal();", "DivProyeccion")) End Sub diff --git a/Inventarios/RepApartados.aspx b/Inventarios/RepApartados.aspx index c9cbef7a0..36216384a 100644 --- a/Inventarios/RepApartados.aspx +++ b/Inventarios/RepApartados.aspx @@ -106,7 +106,7 @@
    - + @@ -175,5 +175,29 @@
    + diff --git a/Inventarios/RepApartados.aspx.vb b/Inventarios/RepApartados.aspx.vb index cb2b86a4d..d2d984085 100644 --- a/Inventarios/RepApartados.aspx.vb +++ b/Inventarios/RepApartados.aspx.vb @@ -200,9 +200,10 @@ Partial Class Inventarios_RepApartados End If If e.Row.DBCampo("IDGPO").ToString.ToEntero = 3 Then - If e.Row.DBCampo("CveVendedor").ToEntero() = UsuarioActual.CveVendedor Then + If DdlSubProyectos.SelectedValue.ToEntero() > 0 AndAlso e.Row.DBCampo("CveVendedor").ToEntero() = UsuarioActual.CveVendedor Then e.Row.FCTextBox("TxtCantidad").Visible = True e.Row.FCRangeValidator("RVCantidad").Visible = True + e.Row.FCTextBox("TxtCantidad").Attributes.Add("onkeyup", $"LimitaCantidad({e.Row.FCTextBox("TxtCantidad").ClientID},{e.Row.DBCampo("Cantidad").ToEntero});") End If End If @@ -271,7 +272,7 @@ Partial Class Inventarios_RepApartados End If If Not GvDatos.Rows.Cast(Of GridViewRow).Any(Function(gvr) gvr.FCTextBox("TxtCantidad").Text.ToEntero() > 0) Then - Alert("No se ha seleccionado ningun cliente", TipoMensaje.MsgAdvertencia) + Alert("No se ha seleccionado ningun producto para realizar el traspaso", TipoMensaje.MsgAdvertencia) Exit Sub End If @@ -298,6 +299,10 @@ Partial Class Inventarios_RepApartados 'CUADRA LOS LOS PRODUCTOS CON LO QUE SE PUEDE DESAPARTAR Dim DtDetalleTraspasar As DataTable = CuadrarMovimientosApartado(CveAlmacenApartado, Row("CveCliente").ToString().ToEntero(), Row("CveVendedor").ToString().ToEntero(), DtPSTraspasar, ObjInventario) + If DtDetalleTraspasar.Rows.Count = 0 Then + ErrorMovInv = True + Mensaje.Append("No se encontraron productos para realizar el traspaso.") + End If DtPSTraspasar.Dispose() Dim MovSalida = GenerarMovimientoAlmacen(CveAlmacenApartado, 8, Row("CveVendedor").ToString().ToEntero(), Row("CveCliente").ToString().ToEntero(), -1, TxtObs.Text.Trim(), DtDetalleTraspasar, ObjInventario, "RepApar/1") @@ -316,8 +321,12 @@ Partial Class Inventarios_RepApartados If Not ErrorMovInv Then EntradasAlmacen.Add(MovEntrada) + Else + Mensaje.Append("No se pudo generar el movimiento de apartado.") End If - + Else + Mensaje.Append("No se pudo generar el movimiento de desapartado.") + Exit For End If Next @@ -367,19 +376,24 @@ Partial Class Inventarios_RepApartados End If If DtRetorno IsNot Nothing Then - For Each RowCantidad As DataRow In DtPSTraspasar.Rows + For Each RowTraspasar As DataRow In DtPSTraspasar.Rows Dim Filtro As New StringBuilder - Filtro.AppendFormat("CvePS={0}", RowCantidad("CvePS")) + Filtro.AppendFormat("CvePS={0}", RowTraspasar("CvePS")) 'SI TIENE SERIE LA AGREGA AL FILTRO - If Not String.IsNullOrEmpty(RowCantidad("Serie").ToString()) Then - Filtro.AppendFormat("AND Serie='{0}'", RowCantidad("Serie")) + If Not String.IsNullOrEmpty(RowTraspasar("Serie").ToString()) Then + Filtro.AppendFormat(" AND Serie='{0}'", RowTraspasar("Serie")) Else - Filtro.AppendFormat("AND ISNULL(Serie,'') = ''") + Filtro.AppendFormat(" AND ISNULL(Serie,'') = ''") + End If + + 'FILTRA EL MOVIMIENTO DE APARTADO ORIGINAL + If Not String.IsNullOrEmpty(RowTraspasar("CveMovimientoDetalleEntrada").ToString()) Then + Filtro.AppendFormat(" AND CveMovimientoDetalle={0}", RowTraspasar("CveMovimientoDetalleEntrada")) End If Dim RowDesapartado As DataRow = DtDesapartado.Select(Filtro.ToString()).FirstOrDefault() - RowDesapartado("Cantidad") = RowCantidad("Cantidad") + RowDesapartado("Cantidad") = RowTraspasar("Cantidad") DtRetorno.Rows.Add(RowDesapartado.ItemArray) Next @@ -396,6 +410,7 @@ Partial Class Inventarios_RepApartados Dt.Columns.Add(New DataColumn("Serie", GetType(String))) Dt.Columns.Add(New DataColumn("CveCliente", GetType(Integer))) Dt.Columns.Add(New DataColumn("CveVendedor", GetType(Integer))) + Dt.Columns.Add(New DataColumn("CveMovimientoDetalleEntrada", GetType(Integer))) For Each GvRow As GridViewRow In GvDatos.Rows.Cast(Of GridViewRow).Where(Function(gvr) gvr.FCTextBox("TxtCantidad").Text.ToEntero() > 0) Dim Row As DataRow = Dt.NewRow @@ -405,6 +420,7 @@ Partial Class Inventarios_RepApartados Row("Serie") = GvRow.DataKey("Serie") Row("CveCliente") = GvRow.DataKey("CveCliente").ToEntero() Row("CveVendedor") = GvRow.DataKey("CveVendedor").ToEntero() + Row("CveMovimientoDetalleEntrada") = GvRow.DataKey("CveMovimientoDetalleEntrada").ToEntero() Dt.Rows.Add(Row) Next diff --git a/Nomina/Aguinaldo.aspx.cs b/Nomina/Aguinaldo.aspx.cs index 51805038c..c0d0f5939 100644 --- a/Nomina/Aguinaldo.aspx.cs +++ b/Nomina/Aguinaldo.aspx.cs @@ -111,6 +111,7 @@ public partial class Nomina_Aguinaldo : ClsPaginas int CvePeriodo; decimal ImporteGravado = 0; decimal ImporteExento = 0; + decimal ImporteValor = 0; //string NombrePersonal = ""; int CveMetodoPago = 0; int CveNomina = 0; @@ -167,6 +168,8 @@ public partial class Nomina_Aguinaldo : ClsPaginas Importe = row["Aguinaldo"].ToString().ToDecimal(); ImporteGravado = row["AguinaldoGravado"].ToString().ToDecimal(); ImporteExento = Importe - ImporteGravado; + ImporteValor = row["DiasLaborados"].ToString().ToDecimal(); + if (CvePersonal > 0 && Importe>0 && row["CveNomina"].ToString().ToEntero()==0) { @@ -196,7 +199,7 @@ public partial class Nomina_Aguinaldo : ClsPaginas if (CveNomina > 0) { - if (!objNomina.AddUPNom_NominasDetalles(objNomina.CveNomina, CvePeriodoSeleccionado, CvePersonal, CveConcepto, Importe, ImporteGravado, ImporteExento, UsuarioActual.CveUsuario)) + if (!objNomina.AddUPNom_NominasDetalles(objNomina.CveNomina, CvePeriodoSeleccionado, CvePersonal, CveConcepto, Importe, ImporteGravado, ImporteExento, ImporteValor, UsuarioActual.CveUsuario)) { continuar = false; } diff --git a/Nomina/Nomina2.aspx b/Nomina/Nomina2.aspx index abf7b0787..7f3f7d249 100644 --- a/Nomina/Nomina2.aspx +++ b/Nomina/Nomina2.aspx @@ -4,6 +4,10 @@