From 75522a4593b2a23954b1a47bcb62737d7ac74d43 Mon Sep 17 00:00:00 2001 From: Oscar Irigoyen Date: Thu, 29 Sep 2022 06:28:46 -0700 Subject: [PATCH] Saldos iniciales carga clasificiaones y Cvemoneda y tipo cambio en otras cargas --- App_Code/ClsClasificaciones.vb | 11 ++- General/SaldosIniciales.aspx | 5 +- General/SaldosIniciales.aspx.vb | 165 +++++++++++++++++++++++++++++--- 3 files changed, 165 insertions(+), 16 deletions(-) diff --git a/App_Code/ClsClasificaciones.vb b/App_Code/ClsClasificaciones.vb index 42d03da4b..6d25100b9 100644 --- a/App_Code/ClsClasificaciones.vb +++ b/App_Code/ClsClasificaciones.vb @@ -32,6 +32,8 @@ Public Class ClsClasificaciones End Get End Property + Public Property CveClasificacion As Integer = -1 + #End Region Sub New(Optional TransaccionCompartida As SqlTransaction = Nothing) @@ -272,7 +274,8 @@ Public Class ClsClasificaciones Public Function AddClasificaciones(Clasificacion As String, Codigo As String, IdCuentaGasto As Integer, CuentaGasto As String, IdCuentaCostos As Integer, CuentaCostos As String, IdCuentaIngreso As Integer, CuentaIngreso As String, CveCategoria As Integer, CveUsuario As Integer, CveEmpresa As Integer, Optional RequiereSerieLote As Integer = 0, Optional UsoClasificacion As Integer = -1, Optional CveSATPS As Integer = -1, Optional RequiereAFCompra As Boolean = False, Optional RequiereAFInsumo As Boolean = False, Optional RequierePersonal As Boolean = False, Optional EsAcumulador As Boolean = False, Optional TopVentas As Boolean = False, Optional TopCompras As Boolean = False, Optional PrecioBaseCosto As Decimal = -1) As Boolean - Dim Retorno As Boolean = False + Dim Retorno As Boolean = False + Me.CveClasificacion = -1 DataAdapter("PA_ClasificacionesAdd") @@ -306,13 +309,15 @@ Public Class ClsClasificaciones .Add("@EsAcumulador", SqlDbType.Bit).Value = EsAcumulador .Add("@TopCompras", SqlDbType.Bit).Value = TopCompras .Add("@TopVentas", SqlDbType.Bit).Value = TopVentas - .Add("@PrecioBaseCosto", SqlDbType.Money).Value = PrecioBaseCosto - + .Add("@PrecioBaseCosto", SqlDbType.Money).Value = PrecioBaseCosto + + .Add("@CveClasificacion", SqlDbType.Int).Direction = ParameterDirection.Output End With Try SqlAdapter.Fill(Data) + Me.CveClasificacion = SqlAdapter.SelectCommand.Parameters("@CveClasificacion").Value.ToString.ToEntero Retorno = True Catch Ex1 As SqlException If Ex1.Message.Contains("Número: 2627;") Then diff --git a/General/SaldosIniciales.aspx b/General/SaldosIniciales.aspx index 031168917..55ac5080c 100644 --- a/General/SaldosIniciales.aspx +++ b/General/SaldosIniciales.aspx @@ -29,7 +29,7 @@
-
+
@@ -44,6 +44,7 @@ + <%----%> @@ -53,7 +54,7 @@ - +
diff --git a/General/SaldosIniciales.aspx.vb b/General/SaldosIniciales.aspx.vb index 6a39c6780..71ad7a0f1 100644 --- a/General/SaldosIniciales.aspx.vb +++ b/General/SaldosIniciales.aspx.vb @@ -628,6 +628,36 @@ Partial Class General_SaldosIniciales Exit Sub End If + ElseIf RblFormato.SelectedValue = "16" Then 'CLASIFICACIONES + + If Not dt.Columns(0).ColumnName = "Clasificacion" Then + Alert("El nombre de la primera columna debe ser 'Clasificacion'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + + If Not dt.Columns(1).ColumnName = "Categoria" Then + Alert("El nombre de la segunda columna debe ser 'Categoria'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + + If Not dt.Columns(2).ColumnName = "UsoClasificacion" Then + Alert("El nombre de la segunda columna debe ser 'UsoClasificacion'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + + If Not dt.Columns(3).ColumnName = "CuentaContableIngreso" Then + Alert("El nombre de la segunda columna debe ser 'CuentaContableIngreso'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + + If Not dt.Columns(4).ColumnName = "CuentaContableGasto" Then + Alert("El nombre de la cuarta columna debe ser 'CuentaContableGasto'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + + + + End If @@ -2214,14 +2244,130 @@ Partial Class General_SaldosIniciales ProcesaAnticipoCliente(dt, DTCuentasContables) ElseIf RblFormato.SelectedValue = "15" Then ProcesaBancos(dt, DTCuentasContables) + ElseIf RblFormato.SelectedValue = "16" Then + ProcesaClasificaciones(dt, DTCuentasContables) End If End If End Sub + Private Sub ProcesaClasificaciones(dt As DataTable, dTCuentasContables As DataTable) + Dim ObjClasificaciones As New ClsClasificaciones + Dim ObjConta As New ClsContabilidad(ObjClasificaciones.IniciaTransacSQL) + Dim ErrorProceso As Boolean = False + Dim Contador As Integer = 0 + + + For Each dRow As DataRow In dt.Rows + + + Dim Clasificacion As String = dRow("Clasificacion").ToString.Trim + Dim Categoria As String = dRow("Categoria").ToString.Trim + Dim UsoClasificacion As String = dRow("UsoClasificacion").ToString.Trim.ToUpper + Dim CuentaContableIngreso As String = dRow("CuentaContableIngreso").ToString.Trim + Dim CuentaContableGasto As String = dRow("CuentaContableGasto").ToString.Trim + + Dim CveClasificacion As Integer = -1 + Dim CveUsoClasificacion As Integer = -1 + Dim CveCategoria As Integer = -1 + + + CveCategoria = GlobalDTGralCategorias(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveCategoria", $" Categoria = '{Categoria}' ").ToEntero + + If Not CveCategoria > 0 Then + CveCategoria = GlobalDTGralCategorias(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveCategoria", "").ToEntero + If Not CveCategoria > 0 Then + Alert($"Clasificación {Clasificacion} la categoria {Categoria} no es valida.", TipoMensaje.MsgAdvertencia) + ErrorProceso = True + Exit For + End If + + End If + + + If UsoClasificacion = "INGRESOS" Then + CveUsoClasificacion = 1 + ElseIf UsoClasificacion = "GASTO" Then + CveUsoClasificacion = 2 + ElseIf UsoClasificacion = "INGRESOS/GASTO" Then + CveUsoClasificacion = 3 + End If + + If Not CveUsoClasificacion > 0 Then + Alert($"Clasificación {Clasificacion} el uso {UsoClasificacion} no es valido.", TipoMensaje.MsgAdvertencia) + ErrorProceso = True + Exit For + End If + + Dim CveCuentaContableIngreso As Integer = dTCuentasContables.FiltroPrimeroValor("CveCuenta", $"Codigo ='{CuentaContableIngreso}'").ToEntero + Dim CveCuentaContableGasto As Integer = dTCuentasContables.FiltroPrimeroValor("CveCuenta", $"Codigo ='{CuentaContableGasto}'").ToEntero + + If CuentaContableIngreso.Trim.Length > 0 AndAlso CveCuentaContableIngreso <= 0 Then + Alert($"Clasificación {Clasificacion} no se encontro la cuenta de ingreso {CuentaContableIngreso}.", TipoMensaje.MsgAdvertencia) + ErrorProceso = True + End If + + If CuentaContableGasto.Trim.Length > 0 AndAlso CveCuentaContableGasto <= 0 Then + Alert($"Clasificación {Clasificacion} no se encontro la cuenta de gasto {CuentaContableGasto}.", TipoMensaje.MsgAdvertencia) + ErrorProceso = True + End If + + + + If ObjClasificaciones.AddClasificaciones(Clasificacion, "", -1, "-1", -1, "-1", -1, "-1", CveCategoria, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, RequiereSerieLote:=0, UsoClasificacion:=CveUsoClasificacion, + CveSATPS:=-1, RequiereAFCompra:=False, RequiereAFInsumo:=False, RequierePersonal:=False, EsAcumulador:=False, TopVentas:=False, TopCompras:=False, PrecioBaseCosto:=-1) Then + + CveClasificacion = ObjClasificaciones.CveClasificacion + + If Not CveClasificacion > 0 Then + ErrorProceso = True + End If + Else + ErrorProceso = True + End If + + + + If Not ErrorProceso Then + + If CveCuentaContableIngreso > 0 Then + If Not AsignacionCuenta(ObjConta, 4, CveCuentaContableIngreso, -1, -1, -1, -1, UsuarioActual.CveEmpresa, CveClasificacion) Then + ErrorProceso = True + Alert("Se presento un error al guardar en asignaciones", TipoMensaje.MsgAdvertencia) + Exit For + End If + End If + + If CveCuentaContableGasto > 0 Then + If Not AsignacionCuenta(ObjConta, 6, CveCuentaContableGasto, -1, -1, -1, -1, UsuarioActual.CveEmpresa, CveClasificacion) Then + ErrorProceso = True + Alert("Se presento un error al guardar en asignaciones", TipoMensaje.MsgAdvertencia) + Exit For + End If + End If + + End If + + + Contador = Contador + 1 + Next + + + If Not ErrorProceso Then + ObjClasificaciones.Commit() + Alert($"Se agregaron {Contador} Clasificaciones.") + Else + ObjClasificaciones.RollBack() + End If + + + ObjClasificaciones.Dispose() + + End Sub + Private Sub ProcesaBancos(DTBancos As DataTable, DTCuentasContables As DataTable) Dim ErrorProceso As Boolean = False @@ -2312,7 +2458,7 @@ Partial Class General_SaldosIniciales End If - If Not AsignacionCuenta(ObjConta, 30, CveCuentaContable, CveCuentaBancaria, -1, -1, -1, UsuarioActual.CveEmpresa) Then + If Not AsignacionCuenta(ObjConta, 30, CveCuentaContable, CveCuentaBancaria, -1, -1, -1, UsuarioActual.CveEmpresa, -1) Then ErrorProceso = True Alert("Se presento un error al guardar en asignaciones", TipoMensaje.MsgAdvertencia) Exit For @@ -2445,7 +2591,7 @@ Partial Class General_SaldosIniciales End If - If Not AsignacionCuenta(ObjConta, 10, CveCuentaContable, -1, CveProveedor, -1, -1, UsuarioActual.CveEmpresa) Then + If Not AsignacionCuenta(ObjConta, 10, CveCuentaContable, -1, CveProveedor, -1, -1, UsuarioActual.CveEmpresa, -1) Then ErrorProceso = True Alert("Se presento un error al guardar en asignaciones", TipoMensaje.MsgAdvertencia) Exit For @@ -2576,7 +2722,7 @@ Partial Class General_SaldosIniciales End If - If Not AsignacionCuenta(ObjConta, 66, CveCuentaContable, -1, -1, CveCliente, -1, UsuarioActual.CveEmpresa) Then + If Not AsignacionCuenta(ObjConta, 66, CveCuentaContable, -1, -1, CveCliente, -1, UsuarioActual.CveEmpresa, -1) Then ErrorProceso = True Alert("Se presento un error al guardar en asignaciones", TipoMensaje.MsgAdvertencia) Exit For @@ -2619,19 +2765,14 @@ Partial Class General_SaldosIniciales Private Function AsignacionCuenta(ObjContabilidad As ClsContabilidad, CveConceptoContable As Integer, CveCuentaContable As Integer, CveBancoCuenta As Integer, CveProveedor As Integer, CveCliente As Integer, - CvePersonal As Integer, CveEmpresa As Integer) As Boolean + CvePersonal As Integer, CveEmpresa As Integer, CveClasificacion As Integer) As Boolean Dim Respuesta As Boolean = False - 'If Not ObjConta.AddCuentasAsignaciones(28, UsuarioActual.CveEmpresa, CveCuentaContable, -1, - ' -1, -1, ObjRH.CvePersonal, -1, -1, 0, CveBancoCuenta:=-1, CveConceptoNomina:=-1, CveSubProyecto:=-1, CveActivoFijo:=-1, - ' CveTipoGasto:=-1, RegeneraCuenta:=False) Then - ' ErrorRH = True - ' Exit For - 'End If + If ObjContabilidad.AddCuentasAsignaciones(CveConceptoContable, CveEmpresa, CveCuentaContable, -1, - CveProveedor, CveCliente, CvePersonal, -1, -1, 0, CveBancoCuenta:=CveBancoCuenta, CveConceptoNomina:=-1, CveSubProyecto:=-1, CveActivoFijo:=-1, + CveProveedor, CveCliente, CvePersonal, CveClasificacion, -1, 0, CveBancoCuenta:=CveBancoCuenta, CveConceptoNomina:=-1, CveSubProyecto:=-1, CveActivoFijo:=-1, CveTipoGasto:=-1, RegeneraCuenta:=False) Then Respuesta = True End If @@ -2673,6 +2814,8 @@ Partial Class General_SaldosIniciales Directorio = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\SaldosIniciales\FormatoAnticipoCliente.xlsx" ElseIf RblFormato.SelectedValue = "15" Then Directorio = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\SaldosIniciales\FormatoBancos.xlsx" + ElseIf RblFormato.SelectedValue = "16" Then + Directorio = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\SaldosIniciales\FormatoClasificaciones.xlsx" End If If Not (Directorio = "") Then