2026-01-30-v2
This commit is contained in:
@@ -0,0 +1,214 @@
|
||||
|
||||
|
||||
Imports System.Data.Entity
|
||||
Imports DevExpress.Xpf.Core.ServerMode
|
||||
Imports bdGrupoSanchoToro
|
||||
Imports DevExpress.Xpf.Grid
|
||||
Imports DevExpress.Xpf.Core
|
||||
Imports System.Linq.Dynamic
|
||||
Imports DevExpress.Xpf.Bars
|
||||
Imports tsl5.Datos
|
||||
Imports tsWPF
|
||||
Imports DevExpress.Data
|
||||
Imports tsWPF.Comun
|
||||
Imports tsWPFCore.Comun
|
||||
Imports tsWPFCore
|
||||
Imports tsUtilidades
|
||||
|
||||
Imports bdGrupoSanchoToro.db
|
||||
Imports bdGrupoSanchoToro.db.Utilidades
|
||||
|
||||
Public Class ucBalanceExplotacion
|
||||
|
||||
Private TotalGastos As Double
|
||||
Private TotalIngresos As Double
|
||||
Dim bd As tscGrupoSanchoToro
|
||||
' Private _Ejercicios As List(Of Integer)
|
||||
' Private _NivelCuentas As Integer
|
||||
|
||||
|
||||
|
||||
Public Overrides ReadOnly Property idRegistroAplicacionActual As String
|
||||
Get
|
||||
Return "BalanceExplotacion"
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Overrides ReadOnly Property DescripcionRegistro As String
|
||||
Get
|
||||
Return "Cuentas"
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Overrides ReadOnly Property NombreTablaBase As String
|
||||
Get
|
||||
Return "Cuentas"
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Overrides Sub EstableceDataContextSecundarios(Optional Background As Boolean = False)
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub EstableceTitulo()
|
||||
Me.docpanel.Caption = "Balance de Explotación"
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub Cargado()
|
||||
Dim Ejercicios = bd.ejercicioscontables.OrderByDescending(Function(x) x.FechaInicio).ToList
|
||||
Dim ejab = Ejercicios.Where(Function(x) x.FechaCierre Is Nothing)
|
||||
deFechaInicio.EditValue = ejab.OrderBy(Function(x) x.FechaInicio).First.FechaInicio
|
||||
deFechaFin.EditValue = ejab.OrderByDescending(Function(x) x.FechaFin).First.FechaFin
|
||||
End Sub
|
||||
|
||||
|
||||
Public Overrides Function EstableceDCPrincipal(Optional Background As Boolean = False, Optional FuerzaNuevo As Boolean = False, Optional Refrescar As Boolean = False) As EstadosAplicacion
|
||||
Return EstadosAplicacion.AplicacionSinIndice
|
||||
End Function
|
||||
|
||||
Public Overrides Function ObtieneBD() As tsUtilidades.ItsContexto
|
||||
bd = tscGrupoSanchoToro.NuevoContexto()
|
||||
Return bd
|
||||
End Function
|
||||
|
||||
'Public Overrides Function ObtieneConexionBD() As BBDD
|
||||
' Return bdCOASVD.GestionAsegasaEntities.bdga
|
||||
'End Function
|
||||
|
||||
Public Overrides Function ObtienePermisos() As tsUtilidades.Permisos
|
||||
Return Comun.ObtienePermisos(Me.bd, "AP.CONTABILIDAD", idUsuario)
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
Public Sub New()
|
||||
|
||||
' Esta llamada es exigida por el diseñador.
|
||||
InitializeComponent()
|
||||
'Me.lgFiltrosBusquedaRapida.Visibility = Visibility.Collapsed
|
||||
'Me.lgFiltrosBusquedaAvanzada.Visibility = Visibility.Visible
|
||||
' Agregue cualquier inicialización después de la llamada a InitializeComponent().
|
||||
|
||||
End Sub
|
||||
|
||||
Public Function ObtieneApuntes(ByRef DataContext As Object, BackGround As Boolean, FechaInicio As DateOnly, FechaFin As DateOnly) As List(Of CuentaBalanceExplotacion)
|
||||
Dim parametros(0) As Object
|
||||
Dim iNumExc As Integer = 0
|
||||
Dim lcbe As New List(Of CuentaBalanceExplotacion)
|
||||
Do
|
||||
Try
|
||||
Dim tiporeg As Integer = bdGrupoSanchoToro.db.asientos.TipoAsiento.REGULARIZACION
|
||||
Dim rsa = bd.apuntes.Include(Function(x) x.idCuentaNavigation.idCuenta).Where(Function(x) x.idAsientoNavigation.Tipo <> tiporeg And x.idAsientoNavigation.Fecha >= FechaInicio And x.idAsientoNavigation.Fecha <= FechaFin And (x.idCuentaNavigation.NumeroCuenta.StartsWith("6") Or x.idCuentaNavigation.NumeroCuenta.StartsWith("7"))).GroupBy(Function(x) x.idCuentaNavigation.NumeroCuenta).ToList()
|
||||
Dim orden As Integer
|
||||
For Each g In rsa
|
||||
Dim cbe As New CuentaBalanceExplotacion
|
||||
orden += 1
|
||||
With cbe
|
||||
.Cuenta = g.First.idCuentaNavigation.NumeroCuenta
|
||||
.Denominacion = g.First.idCuentaNavigation.Denominacion
|
||||
.Importe = (g.Sum(Function(x) x.Debe) - g.Sum(Function(x) x.Haber)) * If(.Cuenta.StartsWith("6"), 1, -1)
|
||||
.Grupo = If(.Cuenta.StartsWith("6"), "GASTOS", "INGRESOS")
|
||||
End With
|
||||
lcbe.Add(cbe)
|
||||
Next
|
||||
' rs = bd.asientos.Where(Function(x) x.Fecha >= FechaInicio And x.Fecha <= FechaFin).ToList
|
||||
Exit Do
|
||||
Catch ex As Exception
|
||||
iNumExc += 1
|
||||
If iNumExc > 3 Then
|
||||
lcbe = Nothing
|
||||
Exit Do
|
||||
End If
|
||||
End Try
|
||||
Loop
|
||||
Return lcbe
|
||||
End Function
|
||||
|
||||
Public Async Sub ObtieneApuntesAsync(bd As tscGrupoSanchoToro, Background As Boolean)
|
||||
Try
|
||||
|
||||
Dim rs As New List(Of CuentaBalanceExplotacion)
|
||||
Dim fi, ff As DateOnly?
|
||||
|
||||
fi = deFechaInicio.EditValue
|
||||
ff = deFechaFin.EditValue
|
||||
If Background Then
|
||||
Me.ContenedorAplicacion.IsEnabled = False
|
||||
Await Task.Run(Sub()
|
||||
rs = ObtieneApuntes(bd, Background, fi, ff)
|
||||
End Sub)
|
||||
Else
|
||||
If DXSplashScreen.IsActive = False Then DXSplashScreen.Show(Of tsWPFCore.SplashScreenTecnosis)()
|
||||
DXSplashScreen.SetState("Buscando Apuntes ...")
|
||||
rs = ObtieneApuntes(bd, Background, fi, ff)
|
||||
End If
|
||||
|
||||
gc.ItemsSource = rs
|
||||
DataContext = rs
|
||||
gc.RefreshData()
|
||||
gc.ExpandAllGroups()
|
||||
Catch ex As Exception
|
||||
If DXSplashScreen.IsActive Then DXSplashScreen.Close()
|
||||
DXMessageBox.Show(ex.Message, "Error")
|
||||
Finally
|
||||
Me.ContenedorAplicacion.IsEnabled = True
|
||||
If DXSplashScreen.IsActive Then DXSplashScreen.Close()
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub Nuevo() Handles Me.BotonNuevoPulsado
|
||||
FuncionesDinamicas.AbrirAP(New ucCuenta, OtrosParametros)
|
||||
End Sub
|
||||
|
||||
Private Sub ApLineas_Enlazar(Celda As EditGridCellData, Defecto As Boolean) Handles Me.Enlazar
|
||||
Dim id As Integer = DirectCast(Me.gc.CurrentItem, cuentas).idCuenta
|
||||
Dim uc As New ucCuenta(id)
|
||||
FuncionesDinamicas.AbrirAP(New ucCuenta(id), OtrosParametros)
|
||||
End Sub
|
||||
|
||||
Private Sub BtBuscar_Click(sender As Object, e As RoutedEventArgs)
|
||||
ObtieneApuntesAsync(bd, False)
|
||||
End Sub
|
||||
|
||||
Private Sub Gc_CustomSummary(sender As Object, e As DevExpress.Data.CustomSummaryEventArgs)
|
||||
Dim Campo As String = (CType(e.Item, GridSummaryItem)).FieldName
|
||||
Dim cta As CuentaBalanceExplotacion = Nothing
|
||||
If e.SummaryProcess = CustomSummaryProcess.Calculate Then
|
||||
cta = DirectCast(e.Row, CuentaBalanceExplotacion)
|
||||
End If
|
||||
Select Case Campo
|
||||
Case "Importe" 'INGRESOS
|
||||
If e.SummaryProcess = CustomSummaryProcess.Start Then
|
||||
TotalIngresos = 0
|
||||
TotalGastos = 0
|
||||
End If
|
||||
If e.SummaryProcess = CustomSummaryProcess.Calculate Then
|
||||
If cta.Cuenta.StartsWith("6") Then
|
||||
TotalGastos += cta.Importe
|
||||
Else
|
||||
TotalIngresos += cta.Importe
|
||||
End If
|
||||
End If
|
||||
If e.SummaryProcess = CustomSummaryProcess.Finalize Then
|
||||
e.TotalValue = TotalIngresos
|
||||
End If
|
||||
Case "TotalGastos"
|
||||
If e.SummaryProcess = CustomSummaryProcess.Finalize Then
|
||||
e.TotalValue = TotalGastos
|
||||
End If
|
||||
Case "Perdidas"
|
||||
If e.SummaryProcess = CustomSummaryProcess.Finalize Then
|
||||
e.TotalValue = If(TotalGastos > TotalIngresos, TotalGastos - TotalIngresos, 0)
|
||||
End If
|
||||
Case "Ganancias"
|
||||
If e.SummaryProcess = CustomSummaryProcess.Finalize Then
|
||||
e.TotalValue = If(TotalIngresos > TotalGastos, TotalIngresos - TotalGastos, 0)
|
||||
End If
|
||||
End Select
|
||||
End Sub
|
||||
End Class
|
||||
Public Class CuentaBalanceExplotacion
|
||||
Property Grupo As String
|
||||
Property Cuenta As String
|
||||
Property Denominacion As String
|
||||
Property Importe As Double
|
||||
End Class
|
||||
Reference in New Issue
Block a user