-- mejora

This commit is contained in:
2023-08-18 19:06:42 -07:00
parent 3d032c7dfe
commit cd9d8346f2
18 changed files with 263 additions and 356 deletions

View File

@@ -2538,11 +2538,11 @@ Partial Class Clientes
Dim NombreCuentaCuentaAltaCompaq As String = ""
Dim IdCuentaAltaCompaq As Integer = -1
'Si tiene contabilizacion automatica y la funcionalidad de carga cuenta automatica o UsaAC le agregamos automaticamente una cuenta al cliente
If UsuarioActual.Empresa.Funcionalidad(211).ToEntero() > 0 AndAlso (UsuarioActual.Empresa.Funcionalidad(200).ToEntero() > 0 Or UsuarioActual.Empresa.UsaAC) AndAlso DdlCtaContableClientes.SelectedValue.ToEntero() < 1 Then
If Not AgregarCuentaContable(BtnActivaRegistroClientes, DdlCtaContableClientes, CodigoCuentaAltaCompaq, NombreCuentaCuentaAltaCompaq, IdCuentaAltaCompaq) Then
ErrorProceso = True
End If
End If
'If UsuarioActual.Empresa.Funcionalidad(211).ToEntero() > 0 AndAlso (UsuarioActual.Empresa.Funcionalidad(200).ToEntero() > 0 Or UsuarioActual.Empresa.UsaAC) AndAlso DdlCtaContableClientes.SelectedValue.ToEntero() < 1 Then
' If Not AgregarCuentaContable(BtnActivaRegistroClientes, DdlCtaContableClientes, CodigoCuentaAltaCompaq, NombreCuentaCuentaAltaCompaq, IdCuentaAltaCompaq) Then
' ErrorProceso = True
' End If
'End If
'Dim MetodoPago = DdlMetodoPago.SelectedValue.Toentero()
'If UsuarioActual.Empresa.CvePlataforma = 3 Then
@@ -2612,12 +2612,11 @@ Partial Class Clientes
End If
End If
If IdCuentaAltaCompaq > 0 Then
If Not AltaCuentaContabilidadSIG(CodigoCuentaAltaCompaq, NombreCuentaCuentaAltaCompaq, IdCuentaAltaCompaq, 1, ObjClientes.IniciaTransacSQL) Then
ErrorProceso = True
End If
End If
'If IdCuentaAltaCompaq > 0 Then
' If Not AltaCuentaContabilidadSIG(CodigoCuentaAltaCompaq, NombreCuentaCuentaAltaCompaq, IdCuentaAltaCompaq, 1, ObjClientes.IniciaTransacSQL) Then
' ErrorProceso = True
' End If
'End If
If ErrorProceso Then
ObjClientes.RollBack()
@@ -2638,7 +2637,6 @@ Partial Class Clientes
End If
End If
Else
Dim NombreCliente As String = ""
If TxtRFC.Text.Length = 13 AndAlso TxtApellidoPaterno.Text <> "" AndAlso TxtApellidoMaterno.Text <> "" AndAlso TxtNombres.Text <> "" Then
@@ -2672,7 +2670,6 @@ Partial Class Clientes
ObjClientes.AddClienteImpuestosLocales(CveCliente, GVR.DataKey("CveImpuestoLocal").ToEntero())
End If
Next
GuardarDocumentosClientes()
'For Each gvr As GridViewRow In GvDocsVentas.Rows
@@ -2753,18 +2750,13 @@ Partial Class Clientes
#Region "G L O B L A L"
Private Sub RecargaGlobal()
'Dim Hilo As New System.Threading.Thread(AddressOf GeneraGlobalDT)
'Hilo.Start()
Private Sub RecargaGlobal()
GeneraGlobalDT()
End Sub
Private Sub GeneraGlobalDT()
GlobalDTCliente(UsuarioActual.CveEmpresa) = Nothing
'Dim Objclientes As New ClsClientes
'If Objclientes.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, -1, Estatus:=-1) Then
' Application("GlobalDTCliente") = Objclientes.DtResultados
'End If
'Objclientes.Dispose()
GlobalDTCliente(UsuarioActual.CveEmpresa) = Nothing
End Sub
#End Region
@@ -3701,147 +3693,147 @@ Partial Class Clientes
End Sub
Public Sub BtnAgregaCuentaContable(sender As Object, e As EventArgs) Handles BtnActivaRegistroClientes.Click, BtnActivaRegistroAnticipos.Click, BtnActivaRegistroIVA.Click, BtnActivaRegistroISR.Click
Dim CuentaContable = DirectCast(sender, Button).CommandArgument.ToString()
Dim Button = DirectCast(sender, Button)
'Dim CuentaContable = DirectCast(sender, Button).CommandArgument.ToString()
'Dim Button = DirectCast(sender, Button)
Dim CodigoCuentaAltaCompaq As String = ""
Dim NombreCuentaCuentaAltaCompaq As String = ""
Dim IdCuentaAltaCompaq As Integer = -1
'Dim CodigoCuentaAltaCompaq As String = ""
'Dim NombreCuentaCuentaAltaCompaq As String = ""
'Dim IdCuentaAltaCompaq As Integer = -1
Select Case CuentaContable
Case "Clientes"
AgregarCuentaContable(Button, DdlCtaContableClientes, "", "", -1)
Case "Anticipos"
'Select Case CuentaContable
' Case "Clientes"
' AgregarCuentaContable(Button, DdlCtaContableClientes, "", "", -1)
' Case "Anticipos"
AgregarCuentaContable(Button, DdlCtaContableAnticipos, CodigoCuentaAltaCompaq, NombreCuentaCuentaAltaCompaq, IdCuentaAltaCompaq)
AltaCuentaContabilidadSIG(CodigoCuentaAltaCompaq, NombreCuentaCuentaAltaCompaq, IdCuentaAltaCompaq, 3)
' AgregarCuentaContable(Button, DdlCtaContableAnticipos, CodigoCuentaAltaCompaq, NombreCuentaCuentaAltaCompaq, IdCuentaAltaCompaq)
' AltaCuentaContabilidadSIG(CodigoCuentaAltaCompaq, NombreCuentaCuentaAltaCompaq, IdCuentaAltaCompaq, 3)
Case "RetIVA"
' Case "RetIVA"
AgregarCuentaContable(Button, DdlCtaContableRetIVA, "", "", -1)
Case "RetISR"
AgregarCuentaContable(Button, DdlCtaContableRetISR, "", "", -1)
End Select
' AgregarCuentaContable(Button, DdlCtaContableRetIVA, "", "", -1)
' Case "RetISR"
' AgregarCuentaContable(Button, DdlCtaContableRetISR, "", "", -1)
'End Select
End Sub
Private Function AgregarCuentaContable(btn As Button, ddl As DropDownList, ByRef CodigoCuentaAltaCompaq As String, ByRef NombreCuentaCuentaAltaCompaq As String, ByRef IdCuentaAltaCompaq As Integer) As Boolean
Dim IdCuentaContable As Integer = -1
Dim CtaCodigo As String = ""
Dim TieneError = False
Dim ProcesoCorrecto As Boolean
Dim ObjContaAC As New ClsContPAQi(UsuarioActual.Empresa)
ObjContaAC.IniciaTransacSQL()
Dim CuentaPadre = -1
Select Case btn.CommandArgument.ToString()
Case "Clientes"
CuentaPadre = UsuarioActual.Empresa.Funcionalidad(211).ToEntero()
Case "Anticipos"
CuentaPadre = UsuarioActual.Empresa.Funcionalidad(212).ToEntero()
Case "RetIVA"
CuentaPadre = UsuarioActual.Empresa.Funcionalidad(213).ToEntero()
Case "RetISR"
CuentaPadre = UsuarioActual.Empresa.Funcionalidad(214).ToEntero()
End Select
'SI EL NOMBRE DEL PROVEEDOR ES MAYOR DE 50 LO CORTAMOS
Dim NombreCuenta = If(TxtNombreComercial.Text.Trim.Length > 50, TxtNombreComercial.Text.Trim.Substring(0, 50), TxtNombreComercial.Text.Trim)
IdCuentaContable = ObjContaAC.AddSiguienteCuentaHijo(CuentaPadre, NombreCuenta, Tipo:="A", CuentaMayor:=2)
NombreCuentaCuentaAltaCompaq = NombreCuenta
IdCuentaAltaCompaq = IdCuentaContable
If IdCuentaContable > 0 Then
ObjContaAC.GetCuentas(IdCuentaContable, "-1", -1)
Dim dt = ObjContaAC.DtResultados
If dt.Rows.Count = 1 Then
Dim row As DataRow = dt.Rows(0)
CtaCodigo = CStr(row("CtaCodigo"))
CodigoCuentaAltaCompaq = CStr(row("Codigo"))
Else
TieneError = True
End If
Else
TieneError = True
End If
If Not TieneError Then
ObjContaAC.Commit()
'Alert(String.Format("Se registo la Cuenta Contable: {0}", CtaCodigo, TipoMensaje.MsgInformacion))
ddl.Items.Add(New ListItem(CtaCodigo, IdCuentaContable.ToString())) : ddl.SelectedValueExist(IdCuentaContable.ToString())
btn.Visible = False
ddl.Width = 206
ProcesoCorrecto = True
Else
ObjContaAC.RollBack()
Alert("error", TipoMensaje.MsgError)
ProcesoCorrecto = False
End If
ObjContaAC.Dispose()
UpFiscalContable.Update()
Return ProcesoCorrecto
End Function
Private Function AltaCuentaContabilidadSIG(CodigoCuentaAltaCompaq As String, NombreCuentaCuentaAltaCompaq As String, IdCuentaAltaCompaq As Integer, CveConceptoContable As Integer, Optional Transaccion As SqlTransaction = Nothing) As Boolean
Dim Respuesta As Boolean = False
Dim DisposeClases As Boolean = False
Dim ObjContabilidad As ClsContabilidad
If Transaccion Is Nothing Then
ObjContabilidad = New ClsContabilidad
DisposeClases = True
Else
ObjContabilidad = New ClsContabilidad(Transaccion)
DisposeClases = False
End If
If UsuarioActual.CveEmpresa.Contiene(7, 11, 145, 122) Then
Dim CvePadre As Integer = GlobalDTContaCuentasContables(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveCuenta", $"IdCompaq = {UsuarioActual.Empresa.Funcionalidad(211).ToEntero()}").ToEntero
'If ObjContabilidad.GetCuentasGlobales(UsuarioActual.CveEmpresa, 1) Then
' Dim CvePadre As Integer = ObjContabilidad.DtResultados.FiltroPrimeroValor("CveCuenta").ToEntero
If CvePadre > 0 Then
Dim CvecuentaNueva As Integer = ObjContabilidad.AddCuenta(CvePadre, CodigoCuentaAltaCompaq, NombreCuentaCuentaAltaCompaq, "A", 2, 1, CveCliente:=CveCliente, IdCompaq:=IdCuentaAltaCompaq)
If CvecuentaNueva > 0 Then
If ObjContabilidad.AddCuentasAsignaciones(CveConceptoContable, UsuarioActual.CveEmpresa, CvecuentaNueva, CveCliente:=CveCliente, PorcentajeIVA:=0) Then
Respuesta = True
End If
End If
End If
'End If
Else
Respuesta = True
End If
If DisposeClases Then
ObjContabilidad.Dispose()
If Not Respuesta Then
Alert("Se presento un error al agregar y asignar la cuenta (Conta SIG).", TipoMensaje.MsgAdvertencia)
End If
End If
Return Respuesta
End Function
End Sub
'Private Function AgregarCuentaContable(btn As Button, ddl As DropDownList, ByRef CodigoCuentaAltaCompaq As String, ByRef NombreCuentaCuentaAltaCompaq As String, ByRef IdCuentaAltaCompaq As Integer) As Boolean
' Dim IdCuentaContable As Integer = -1
' Dim CtaCodigo As String = ""
' Dim TieneError = False
' Dim ProcesoCorrecto As Boolean
' Dim ObjContaAC As New ClsContPAQi(UsuarioActual.Empresa)
' ObjContaAC.IniciaTransacSQL()
' Dim CuentaPadre = -1
' Select Case btn.CommandArgument.ToString()
' Case "Clientes"
' CuentaPadre = UsuarioActual.Empresa.Funcionalidad(211).ToEntero()
' Case "Anticipos"
' CuentaPadre = UsuarioActual.Empresa.Funcionalidad(212).ToEntero()
' Case "RetIVA"
' CuentaPadre = UsuarioActual.Empresa.Funcionalidad(213).ToEntero()
' Case "RetISR"
' CuentaPadre = UsuarioActual.Empresa.Funcionalidad(214).ToEntero()
' End Select
' 'SI EL NOMBRE DEL PROVEEDOR ES MAYOR DE 50 LO CORTAMOS
' Dim NombreCuenta = If(TxtNombreComercial.Text.Trim.Length > 50, TxtNombreComercial.Text.Trim.Substring(0, 50), TxtNombreComercial.Text.Trim)
' IdCuentaContable = ObjContaAC.AddSiguienteCuentaHijo(CuentaPadre, NombreCuenta, Tipo:="A", CuentaMayor:=2)
' NombreCuentaCuentaAltaCompaq = NombreCuenta
' IdCuentaAltaCompaq = IdCuentaContable
' If IdCuentaContable > 0 Then
' ObjContaAC.GetCuentas(IdCuentaContable, "-1", -1)
' Dim dt = ObjContaAC.DtResultados
' If dt.Rows.Count = 1 Then
' Dim row As DataRow = dt.Rows(0)
' CtaCodigo = CStr(row("CtaCodigo"))
' CodigoCuentaAltaCompaq = CStr(row("Codigo"))
' Else
' TieneError = True
' End If
' Else
' TieneError = True
' End If
' If Not TieneError Then
' ObjContaAC.Commit()
' 'Alert(String.Format("Se registo la Cuenta Contable: {0}", CtaCodigo, TipoMensaje.MsgInformacion))
' ddl.Items.Add(New ListItem(CtaCodigo, IdCuentaContable.ToString())) : ddl.SelectedValueExist(IdCuentaContable.ToString())
' btn.Visible = False
' ddl.Width = 206
' ProcesoCorrecto = True
' Else
' ObjContaAC.RollBack()
' Alert("error", TipoMensaje.MsgError)
' ProcesoCorrecto = False
' End If
' ObjContaAC.Dispose()
' UpFiscalContable.Update()
' Return ProcesoCorrecto
'End Function
'Private Function AltaCuentaContabilidadSIG(CodigoCuentaAltaCompaq As String, NombreCuentaCuentaAltaCompaq As String, IdCuentaAltaCompaq As Integer, CveConceptoContable As Integer, Optional Transaccion As SqlTransaction = Nothing) As Boolean
' Dim Respuesta As Boolean = False
' Dim DisposeClases As Boolean = False
' Dim ObjContabilidad As ClsContabilidad
' If Transaccion Is Nothing Then
' ObjContabilidad = New ClsContabilidad
' DisposeClases = True
' Else
' ObjContabilidad = New ClsContabilidad(Transaccion)
' DisposeClases = False
' End If
' If UsuarioActual.CveEmpresa.Contiene(7, 11, 145, 122) Then
' Dim CvePadre As Integer = GlobalDTContaCuentasContables(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveCuenta", $"IdCompaq = {UsuarioActual.Empresa.Funcionalidad(211).ToEntero()}").ToEntero
' 'If ObjContabilidad.GetCuentasGlobales(UsuarioActual.CveEmpresa, 1) Then
' ' Dim CvePadre As Integer = ObjContabilidad.DtResultados.FiltroPrimeroValor("CveCuenta").ToEntero
' If CvePadre > 0 Then
' Dim CvecuentaNueva As Integer = ObjContabilidad.AddCuenta(CvePadre, CodigoCuentaAltaCompaq, NombreCuentaCuentaAltaCompaq, "A", 2, 1, CveCliente:=CveCliente, IdCompaq:=IdCuentaAltaCompaq)
' If CvecuentaNueva > 0 Then
' If ObjContabilidad.AddCuentasAsignaciones(CveConceptoContable, UsuarioActual.CveEmpresa, CvecuentaNueva, CveCliente:=CveCliente, PorcentajeIVA:=0) Then
' Respuesta = True
' End If
' End If
' End If
' 'End If
' Else
' Respuesta = True
' End If
' If DisposeClases Then
' ObjContabilidad.Dispose()
' If Not Respuesta Then
' Alert("Se presento un error al agregar y asignar la cuenta (Conta SIG).", TipoMensaje.MsgAdvertencia)
' End If
' End If
' Return Respuesta
'End Function
#End Region