diff --git a/App_Code/ClsContabilidad.vb b/App_Code/ClsContabilidad.vb index e6e877f15..2ed6e8796 100644 --- a/App_Code/ClsContabilidad.vb +++ b/App_Code/ClsContabilidad.vb @@ -3,7 +3,6 @@ Option Strict On Imports System.Data Imports System.Data.SqlClient -Imports System.Web Imports Extensiones Public Class ClsContabilidad @@ -6416,6 +6415,47 @@ Public Class ClsContabilidad Return Retorno End Function + + Public Function ValidacionesPrePoliza(CvePrePoliza As Integer, Opcion As Integer, ByRef UsuarioActual As Usuario, Optional CveVenta As Integer = -1, Optional AutoConta As Boolean = True) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_PrePolizasValidacion") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza + .Add("@Opcion", SqlDbType.Int).Value = Opcion + .Add("@CveEmpresa", SqlDbType.Int).Value = UsuarioActual.CveEmpresa + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@AutoConta", SqlDbType.Int).Value = If(AutoConta, 1, 0) + .Add("@Valor", SqlDbType.Int).Direction = ParameterDirection.Output + .Add("@MsgSalida", SqlDbType.VarChar, 100).Direction = ParameterDirection.Output + .Add("@MsgPrePolizaSalida", SqlDbType.VarChar, 8000).Direction = ParameterDirection.Output + .Add("@Diferencia", SqlDbType.Float).Direction = ParameterDirection.Output + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + ValorPolizaDescuadre = SqlAdapter.SelectCommand.Parameters("@Valor").Value.ToString.ToEntero + MensajePolizaDescuadre = SqlAdapter.SelectCommand.Parameters("@MsgSalida").Value.ToString + ValorDiferencia = SqlAdapter.SelectCommand.Parameters("@Diferencia").Value.ToString + Dim MsgPrePoliza As String = SqlAdapter.SelectCommand.Parameters("@MsgPrePolizaSalida").Value.ToString + If MsgPrePoliza <> "" Then MsgPrePoliza.GuardaLogAD("LogPrePoliza") + + If MensajePolizaDescuadre = "" AndAlso AutoConta Then + If UsuarioActual.Empresa.TipoContabilidad = 2 Then ' eltipocontabilidad deberá activarse en el PA + If Not ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then + MensajePolizaDescuadre = Mensaje.ToString ' regresa el mensaje de contabilización + End If + End If + End If + + Catch ex As Exception + OnError("Ocurrió un error al validar la PrePoliza.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + #End Region #Region "AUXILIAR PREPOLIZAS"