diff --git a/App_Code/ClsContPAQi.vb b/App_Code/ClsContPAQi.vb index cfcc0c792..ccbbfd441 100644 --- a/App_Code/ClsContPAQi.vb +++ b/App_Code/ClsContPAQi.vb @@ -470,20 +470,6 @@ Public Class ClsContPAQi StrSQL.Append(" 0, @Serie, @Folio, @Referencia, 0, 0, @SubTotal + @IVA, @RetIVA, @RetISR, @SubTotal + @IVA - @RetIVA - @RetISR,") StrSQL.Append(" YEAR(@FechaMov), MONTH(@FechaMov),@SubTotal, 0,0,1,@UUID);") - StrSQL.Append(" EXEC PA_UpdateId 'Id_DevolucionIVA';") - - StrSQL.Append(" SET @IdDevIVA = dbo.FNC_GetCounter ('Id_MovimientoImpuesto');") - StrSQL.Append(" INSERT INTO MovimientosImpuestos ") - StrSQL.Append(" (Id,RowVersion, IdPoliza, NumMovto, IdPersona, SistOrig, EjercicioAsignado,PeriodoAsignado, IdCuenta,,Captado,AplicaImpuesto,Modificado, ") - StrSQL.Append(" Serie, Folio, Referencia, UUID, Origen, OrigenMovto, Computable, TipoMovimiento, TipoFactor, Impuesto, ObjetoImpuesto, NombreImpuestoLocal, TasaOCuota, ImpBase, ") - StrSQL.Append(" ImpImpuesto, ImpTotal, Desglosado, IVANoAcred, AcumulaIETU, IdConceptoIETU, IETUDeducible, IETUModificado, IETUAcreditable, GuidMov, GuidMovPadre, Migrado,") - StrSQL.Append(" ConceptoIVA,SubconceptoIVA,ClasificadorIVA,ProporcionDIOT,DeducibleDIOT)") - StrSQL.Append(" VALUES (@IdDevIVA, @RowVersion, @IdPoliza, ISNULL ((SELECT MAX (NumMovto) FROM MovimientosImpuestos WHERE IdPoliza = @IdPoliza), 0) + 1, @IdPersona, 1,YEAR(@FechaMov), MONTH(@FechaMov), @IdCuenta, 0,1,0,") - StrSQL.Append(" @Serie, @Folio, @Referencia, @UUID,2, 0,0,0,1,2,0,'',0.16, @SubTotal, @IVA,@SubTotal + @IVA,0, @IVANoAcred,0,0,0,0,'','',0,1,1,1,1,0,0);") - StrSQL.Append(" ") - - StrSQL.Append(" EXEC PA_UpdateId 'Id_MovimientoImpuesto';") - StrSQL.Append(" END TRY") StrSQL.Append(" BEGIN CATCH") @@ -526,6 +512,130 @@ Public Class ClsContPAQi Return Retorno End Function + Public Function AddMovimientoImpuesto(IdPoliza As Integer, IdCuenta As Integer, IdProveedor As Integer, TasaOCuotaIVA As Double, TasaOCuota As Double, SubTotal As Double, ImpImpuesto As Double, FechaMovto As Date, Referencia As String, Serie As String, Folio As Integer, UUID As String, + NoDeducible As Boolean, IVANoAcred As Double, GuidMov As String, GuidMovPadre As String, TipoMovimiento As Integer, Impuesto As Integer) As Boolean + + + Dim Retorno As Boolean = False + Dim ConceptoIVA As Integer = 0 + Dim SubconceptoIVA As Integer = 0 + Dim ProporcionDIOT As Integer = 100 + Dim DeducibleDIOT As Integer = 1 + + If IdPoliza <= 0 Or IdCuenta <= 0 Then + Return False + End If + + Select Case TasaOCuotaIVA + Case 16 + ConceptoIVA = 1 + SubconceptoIVA = If(SubTotal > 0, 2, 3) + Exit Select + Case 8 + ConceptoIVA = 4 + SubconceptoIVA = If(SubTotal > 0, 5, 6) + Exit Select + Case 0 + ConceptoIVA = 14 + SubconceptoIVA = If(SubTotal > 0, 15, 16) + Exit Select + Case Else + Return False + End Select + + + If NoDeducible Then + ProporcionDIOT = 0 + DeducibleDIOT = 2 + End If + + ' GuidMov, ConceptoIVA SubconceptoIVA ProporcionDIOT DeducibleDIOT + + StrSQL.Clear() + StrSQL.Append(" BEGIN") + + StrSQL.AppendLine(" DECLARE ") + StrSQL.AppendLine(" @Error NVARCHAR(300),") + StrSQL.AppendLine(" @IdMovDev INT;") + StrSQL.AppendLine(" SET NOCOUNT ON;") + + StrSQL.AppendLine(" BEGIN TRY") + + StrSQL.AppendLine(" DECLARE @IdPersona INT = (SELECT TOP 1 PER.Id FROM Proveedores PRO + INNER JOIN Personas PER ON PER.Codigo = PRO.CodigoPersona AND PER.EsProveedor = 1 + WHERE PRO.Id = @IdProveedor); + + IF @IdPersona IS NULL OR @IdPersona <= 0 + BEGIN + DECLARE @ErrorPersona NVARCHAR(300) = Concat('No se encontro el IdPersona del proveedor con id ',@IdProveedor ) + RAISERROR (@ErrorPersona, 16, 1); + END + ") + + StrSQL.AppendLine(" + SET @IdMovDev = dbo.FNC_GetCounter ('Id_MovimientoImpuesto'); + INSERT INTO MovimientosImpuestos + (Id,RowVersion, IdPoliza, NumMovto, IdPersona, SistOrig, EjercicioAsignado,PeriodoAsignado, IdCuenta,Captado,AplicaImpuesto,Modificado, + Serie, Folio, Referencia, UUID, Origen, OrigenMovto, Computable, TipoMovimiento, TipoFactor, Impuesto, ObjetoImpuesto, NombreImpLocal, TasaOCuota, ImpBase, + ImpImpuesto, ImpTotal, Desglosado, IVANoAcred, AcumulaIETU, IdConceptoIETU, IETUDeducible, IETUModificado, IETUAcreditable, GuidMov, GuidMovPadre, Migrado, + ConceptoIVA,SubconceptoIVA,ClasificadorIVA,ProporcionDIOT,DeducibleDIOT) + + VALUES (@IdMovDev, @RowVersion, @IdPoliza, ISNULL ((SELECT MAX (NumMovto) FROM MovimientosImpuestos WHERE IdPoliza = @IdPoliza), 0) + 1, @IdPersona, 0,YEAR(@FechaMov), MONTH(@FechaMov), @IdCuenta, 0, 1, 0, + @Serie, @Folio, @Referencia, @UUID, 2, 0, 1, @TipoMovimiento, 1, @Impuesto, 2,'', @TasaOCuota, @SubTotal, + @ImpImpuesto, @ImpImpuesto,0, @IVANoAcred, 0, 0, 0, 0, 0, @GuidMov, @GuidMovPadre, 0, + @ConceptoIVA, @SubconceptoIVA, 0, @ProporcionDIOT, @DeducibleDIOT); + + EXEC PA_UpdateId 'Id_MovimientoImpuesto'; + ") + + + StrSQL.AppendLine(" END TRY") + + StrSQL.AppendLine(" BEGIN CATCH") + StrSQL.AppendLine(" SET @Error = CONCAT('Número: ', ERROR_NUMBER(), '; Procedimiento: ', ERROR_PROCEDURE(), '; Linea: ', ERROR_LINE(), '; Detalle: ', ERROR_MESSAGE());") + StrSQL.AppendLine(" RAISERROR(@Error, 16, 1);") + StrSQL.AppendLine(" END CATCH") + + StrSQL.Append(" END; ") + + SqlDataAdapter(StrSQL.ToString, CommandType.Text) + 'SqlDataAdapter("PA_AddDevolucionIVA") + + With SqlAdapter.SelectCommand.Parameters + .Add("@RowVersion", SqlDbType.Int).Value = GlobalRowVersion + .Add("@IdPoliza", SqlDbType.Int).Value = IdPoliza + .Add("@IdCuenta", SqlDbType.Int).Value = IdCuenta + .Add("@IdProveedor", SqlDbType.Int).Value = IdProveedor + .Add("@TasaOCuota", SqlDbType.Float).Value = Math.Round(TasaOCuota, 2) + .Add("@SubTotal", SqlDbType.Float).Value = Math.Round(SubTotal, 2) + .Add("@ImpImpuesto", SqlDbType.Float).Value = Math.Round(ImpImpuesto, 2) + .Add("@IVANoAcred", SqlDbType.Float).Value = Math.Round(IVANoAcred, 2) + .Add("@FechaMov", SqlDbType.DateTime).Value = FechaMovto + .Add("@Referencia", SqlDbType.VarChar).Value = If(Referencia.Length > 30, Referencia.Substring(1, 30), Referencia) + .Add("@Serie", SqlDbType.VarChar).Value = If(Serie.Length > 15, Serie.Substring(1, 15), Serie) + .Add("@Folio", SqlDbType.Int).Value = If(Len(Folio.ToString) <= 8, Folio, Right(Folio.ToString, 8).ToEntero) ' se limita a 8 digitos, sino le cortan y se toman los ultimos 8, para que guarde e contpaqi + .Add("@UUID", SqlDbType.VarChar).Value = UUID + .Add("@ConceptoIVA", SqlDbType.Int).Value = ConceptoIVA + .Add("@SubconceptoIVA", SqlDbType.Int).Value = SubconceptoIVA + .Add("@ProporcionDIOT", SqlDbType.Int).Value = ProporcionDIOT + .Add("@DeducibleDIOT", SqlDbType.Int).Value = DeducibleDIOT + .Add("@GuidMov", SqlDbType.VarChar).Value = GuidMov + .Add("@GuidMovPadre", SqlDbType.VarChar).Value = GuidMovPadre + .Add("@TipoMovimiento", SqlDbType.Int).Value = TipoMovimiento + .Add("@Impuesto", SqlDbType.Int).Value = Impuesto + End With + + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un Error al agregar el movimiento de impuesto de egresos en la póliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function UpdateDevolucionesIVA(Id As Integer, IdPoliza As Integer, IdCuenta As Integer, IdProveedor As Integer, PorIVA As Double, SubTotal As Double, IVA As Double, RetIVA As Double, RetISR As Double, FechaMovto As Date, Referencia As String, Serie As String, Folio As Integer) As Boolean Dim Retorno As Boolean = False @@ -2278,6 +2388,7 @@ Public Class ClsContPAQi StrSQL.AppendLine(" @NumMovto INT,") StrSQL.AppendLine(" @IdDiario INT,") StrSQL.AppendLine(" @SegNegMovtos INT,") + StrSQL.AppendLine(" @IdMoneda INT,") StrSQL.AppendLine(" @Fecha DATETIME,") StrSQL.AppendLine(" @IDEjercicio INT,") StrSQL.AppendLine(" @TimeStamp NVARCHAR (200);") @@ -2288,10 +2399,11 @@ Public Class ClsContPAQi StrSQL.AppendLine(" SET @Fecha = @FechaMov;") StrSQL.AppendLine(" SET @IdDiario = 0;") StrSQL.AppendLine(" SELECT @Ejercicio = P.Ejercicio, @Periodo = P.Periodo, @TipoPol = TipoPol, @Folio = P.Folio FROM Polizas P WHERE Id = @IdPoliza;") - StrSQL.AppendLine(" SELECT @SegNegMovtos = SegNegMovtos FROM Cuentas C WHERE Id = @IdCuenta;") + StrSQL.AppendLine(" SELECT @SegNegMovtos = SegNegMovtos, @IdMoneda = IdMoneda FROM Cuentas C WHERE Id = @IdCuenta;") StrSQL.AppendLine("") StrSQL.AppendLine(" BEGIN TRY") StrSQL.AppendLine(" ") + StrSQL.AppendLine(" IF (@IdMoneda = 1) SET @ImporteME = 0; ") ''DESCOMENTAR PARA CIERRE PERIODO 'StrSQL.AppendLine("DECLARE") diff --git a/App_Code/ClsGenerales.vb b/App_Code/ClsGenerales.vb index 7b7617049..791d4eb80 100644 --- a/App_Code/ClsGenerales.vb +++ b/App_Code/ClsGenerales.vb @@ -1649,7 +1649,7 @@ Public Class ClsGenerales Public Function AddCuentasDepositos(BancoNombre As String, Plaza As String, Sucursal As String, Cuenta As String, CLABE As String, CIE As String, SWIFT As String, Referencia As String, RefCrediProveedor As String, CveUsuario As Integer, CveMoneda As Integer, CveEmpresa As Integer, Optional CveProveedor As Integer = -1, Optional CveCliente As Integer = -1, Optional CvePersonal As Integer = -1, Optional CveColectiva As Integer = -1, Optional CveUsuarioModifico As Integer = -1, Optional Correo As String = "", Optional BBVAAlias As String = "-1", Optional EstatusPagoElectronico As Boolean = False, Optional EstatusPagoElectronicoGrupos As Boolean = False, Optional CveSATBanco As Integer = -1, - Optional ConceptoCIE As String = "-1") As Boolean + Optional ConceptoCIE As String = "-1", Optional Estatus As Boolean = True) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Gral_CuentasDepositosAdd") @@ -1678,6 +1678,7 @@ Public Class ClsGenerales .Add("@EstatusPagoElectronicoGrupos", SqlDbType.Bit).Value = EstatusPagoElectronicoGrupos .Add("@CveSATBanco", SqlDbType.Int).Value = CveSATBanco .Add("@ConceptoCIE", SqlDbType.VarChar).Value = ConceptoCIE + .Add("@Estatus", SqlDbType.VarChar).Value = Estatus End With diff --git a/Ashx/SIGFacturacion.ashx b/Ashx/SIGFacturacion.ashx index 034a71d08..ec403c3e2 100644 --- a/Ashx/SIGFacturacion.ashx +++ b/Ashx/SIGFacturacion.ashx @@ -233,6 +233,7 @@ Public Class SIGFacturacion : Implements IHttpHandler, IRequiresSessionState Dim Usuario = ObjUsuarios.DtResultados.Rows(0)("Usuario").ToString() Dim Contrasenia = ObjUsuarios.DtResultados.Rows(0)("Contraseña").ToString() UsuarioActual = ObjUsuarios.ValidaUsuario(Usuario, Contrasenia, CveEmpresa:=CveEmpresa) + HttpContext.Current.Session("UsuarioSIG") = UsuarioActual End If ObjUsuarios.Dispose() Return UsuarioActual diff --git a/Ashx/TareasProgramadas.ashx b/Ashx/TareasProgramadas.ashx index fb461e57e..8e79bea06 100644 --- a/Ashx/TareasProgramadas.ashx +++ b/Ashx/TareasProgramadas.ashx @@ -108,7 +108,9 @@ Public Class TareasProgramadas : Implements IHttpHandler, IReadOnlySessionState context.Response.Write(retorno) Case "EstadosCuenta" 'CargaEstadosCuenta(context, 119, 227774) - CargaEstadosCuenta(context, 119, -1, FechaEnvio, FechaActual) + 'CargaEstadosCuenta(context, 119, -1, FechaEnvio, FechaActual) + Dim tCveEmpresa As Integer = context.Request("CveEmpresa").ToString.ToEntero + CargaEstadosCuenta(context, tCveEmpresa, -1, FechaEnvio, FechaActual) Case "ScoreCard" CargaScoreCard(context, 140, FechaEnvio) @@ -354,6 +356,9 @@ Public Class TareasProgramadas : Implements IHttpHandler, IReadOnlySessionState #Region "E S T A D O S D E C U E N T A" Private Sub CargaEstadosCuenta(ByVal context As HttpContext, pCveEmpresa As Integer, pCveCliente As Integer, FechaEnvio As DateTime, FechaActual As DateTime) + + Dim Usuario As Usuario = ValidaUsuarioSistema(100, pCveEmpresa) + Dim Retorno As New JArray() Dim DtEmpresas As DataTable = Nothing Using ObjEmpresas As New ClsSisEmpresas() @@ -364,7 +369,7 @@ Public Class TareasProgramadas : Implements IHttpHandler, IReadOnlySessionState If DtEmpresas IsNot Nothing Then For Each Row As DataRow In DtEmpresas.Rows - Dim Usuario As Usuario = ValidaUsuarioSistema(100, Row("CveEmpresa").ToString().ToEntero()) + 'Dim Usuario As Usuario = ValidaUsuarioSistema(100, Row("CveEmpresa").ToString().ToEntero()) Dim obj As JObject = EjecutarEnvioEstadoCuenta(Usuario, FechaEnvio, FechaActual, pCveCliente:=pCveCliente) Retorno.Add(obj) @@ -499,7 +504,9 @@ Public Class TareasProgramadas : Implements IHttpHandler, IReadOnlySessionState Dim Envio As Boolean = False If Not String.IsNullOrEmpty(Correo) Then + 'Correo = "oscar.irigoyen@adssistemas.mx" Envio = EnviarEstadoCuenta(UsuarioActual, Correo, Cliente) + GuardaLog($"Log envio Estados Cuenta correo {If(Envio, "Enviado", "Error")} CveCliente {CveCliente} ") End If If Envio Then @@ -522,6 +529,7 @@ Public Class TareasProgramadas : Implements IHttpHandler, IReadOnlySessionState New JProperty("Cliente", Cliente.Nombre) )) End If + End If Next End If @@ -857,7 +865,10 @@ Public Class TareasProgramadas : Implements IHttpHandler, IReadOnlySessionState If sw.Elapsed.TotalSeconds > 10 Then GuardaLog($"Reporte:{RutaReporte} | Tiempo Renderizado Milisegundos: {sw.ElapsedMilliseconds},Total Segundos: {sw.Elapsed.TotalSeconds} ") End If - If MR IsNot Nothing Then MR.Dispose() + If MR IsNot Nothing Then + 'MR.Close() + MR.Dispose() + End If Return Bytes End Function diff --git a/Compras/Compras.aspx b/Compras/Compras.aspx index 034b3d77b..889e34b70 100644 --- a/Compras/Compras.aspx +++ b/Compras/Compras.aspx @@ -716,6 +716,8 @@