2026-01-30 03

This commit is contained in:
2026-01-30 12:07:23 +01:00
parent 6034845e65
commit 79ae74ee26
28 changed files with 319 additions and 89 deletions

View File

@@ -211,7 +211,7 @@ namespace bdGrupoSanchoToro
// las.Add("System.Data.Entity.dll");
// las.Add("dll");
// las.Add("tsWPF.dll");
// las.Add("tsl5.dll");
// las.Add("tsUtilidades.dll");
// var lp = new List<string>();
// lp.Add("bd As tscGrupoSanchoToro");
// // For Each p In parametros

View File

@@ -1078,14 +1078,14 @@ public partial class GrupoSanchoToroContext : DbContext
entity.HasIndex(e => e.Descripcion, "Descripcion_UNIQUE").IsUnique();
entity.HasIndex(e => e.idEmpresa, "ejercicioscontables_empresascontables_idx");
entity.HasIndex(e => e.idEmpresa, "ejercicioscontables_empresas_idx");
entity.Property(e => e.Descripcion).HasMaxLength(40);
entity.Property(e => e.NivelesCuentas).HasMaxLength(20);
entity.HasOne(d => d.idEmpresaNavigation).WithMany(p => p.ejercicioscontables)
.HasForeignKey(d => d.idEmpresa)
.HasConstraintName("ejercicioscontables_empresascontables");
.HasConstraintName("ejercicioscontables_empresas");
});
modelBuilder.Entity<empresas>(entity =>

View File

@@ -1,7 +1,8 @@
using System;
using Microsoft.VisualBasic.CompilerServices;
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.CompilerServices;
using Microsoft.VisualBasic.CompilerServices;
namespace bdGrupoSanchoToro.db
{
@@ -100,6 +101,7 @@ namespace bdGrupoSanchoToro.db
return "";
}
}
[NotMapped]
public conciliacionesbancarias ConciliacionActual_TMP { get; set; }
public double Saldo
{

View File

@@ -87,6 +87,26 @@ namespace bdGrupoSanchoToro.db
}
return cuenta;
}
public bool Punteado
{
get
{
return FechaPunteo.HasValue;
}
set
{
if (value)
{
FechaPunteo = DateTime.Now;
}
else
{
FechaPunteo=null;
}
OnPropertyChanged("Punteado");
}
}
private string _Ejercicio;
public string EjercicioTmp
{

View File

@@ -1,7 +1,8 @@
using System;
using Microsoft.VisualBasic.CompilerServices;
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.CompilerServices;
using Microsoft.VisualBasic.CompilerServices;
using tsUtilidades.Extensiones;
namespace bdGrupoSanchoToro.db
@@ -17,6 +18,7 @@ namespace bdGrupoSanchoToro.db
}
public const string CUENTA_PERDIDAS_Y_GANANCIAS = "12900000";
[NotMapped]
public List<apuntes> ApuntesTemporales { get; set; }
public string Descripcion
{

View File

@@ -0,0 +1,167 @@
using bdGrupoSanchoToro;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using tsUtilidades.Extensiones;
namespace bdGrupoSanchoToro.db
{
public partial class ejercicioscontables
{
public static int ObtieneidEjercicioAbierto(DateOnly Fecha)
{
var bd = tscGrupoSanchoToro.NuevoContexto();
var ej = bd.ejercicioscontables.FirstOrDefault(x => x.FechaInicio <= Fecha & x.FechaFin >= Fecha & x.FechaCierre.HasValue == false);
if (ej is null)
{
ej = bd.ejercicioscontables.FirstOrDefault(x => x.FechaInicio <= Fecha & x.FechaFin >= Fecha & x.FechaCierre.HasValue);
if (ej is null)
{
if (DateOnly.FromDateTime(DateTime.Today).DayNumber - Fecha.DayNumber > 365d || Fecha.DayNumber - DateOnly.FromDateTime(DateTime.Today).DayNumber > 60d)
{
throw new Exception("La fecha del ejercicio " + Fecha.ToShortDateString() + " parece incorrecta");
}
else
{
ej = ejercicioscontables.AbreEjercicio(bd, Fecha);
return ej.idEjercicio;
}
}
else
{
throw new Exception("El ejercicio está cerrado");
}
}
else
{
return ej.idEjercicio;
}
}
public string DescripcionExtendida
{
get
{
if (this.FechaInicio.Month == 1 & this.FechaInicio.Day == 1 & this.FechaFin.Month == 12 & this.FechaFin.Day == 31)
{
return this.idEmpresaNavigation.RazonSocial + " " + this.FechaInicio.Year.ToString();
}
else
{
return this.idEmpresaNavigation.RazonSocial + " " + this.FechaInicio.ToString() + " " + this.FechaFin.ToString();
}
}
}
public bdGrupoSanchoToro.db.asientos AsientoApertura
{
get
{
return this.asientos.FirstOrDefault(x => x.Tipo == (int)bdGrupoSanchoToro.db.asientos.TipoAsiento.APERTURA);
}
}
public bdGrupoSanchoToro.db.asientos AsientoRegularizacion
{
get
{
return this.asientos.FirstOrDefault(x => x.Tipo == (int)bdGrupoSanchoToro.db.asientos.TipoAsiento.REGULARIZACION);
}
}
// Private _CuentasPlanContable As List(Of cuentasplancontable)
// Public ReadOnly Property CuentasPlanContable As List(Of cuentasplancontable)
// Get
// If _CuentasPlanContable Is Nothing Then
// _CuentasPlanContable = Me.plancontable.gruposplancontable.SelectMany(Function(x) x.cuentasplancontable).ToList
// End If
// Return _CuentasPlanContable
// End Get
// End Property
public void CopiaCuentas()
{
try
{
tscGrupoSanchoToro bd = tscGrupoSanchoToro.NuevoContexto();
var ea = bd.ejercicioscontables.OrderByDescending(x => x.FechaInicio).FirstOrDefault(x => x.FechaInicio < this.FechaInicio);
if (ea is not null)
{
var ctas1 = ea.cuentas.Where(x => x.NumeroCuenta.Length == 1).ToList();
var ctas2 = ea.cuentas.Where(x => x.NumeroCuenta.Length == 2).ToList();
var ctas3 = ea.cuentas.Where(x => x.NumeroCuenta.Length == 3).ToList();
var ctas4 = ea.cuentas.Where(x => x.NumeroCuenta.Length == 4).ToList();
var ctas8 = ea.cuentas.Where(x => x.NumeroCuenta.Length == 8).ToList();
int Nc = 0;
foreach (var cta in ctas1)
Nc += this.CopiaCuenta(bd, this, cta);
foreach (var cta in ctas2)
Nc += this.CopiaCuenta(bd, this, cta);
foreach (var cta in ctas3)
Nc += this.CopiaCuenta(bd, this, cta);
foreach (var cta in ctas4)
Nc += this.CopiaCuenta(bd, this, cta);
foreach (var cta in ctas8)
Nc += this.CopiaCuenta(bd, this, cta);
bd.SaveChanges();
}
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
}
private int CopiaCuenta(tscGrupoSanchoToro bd, ejercicioscontables Ejercicio, bdGrupoSanchoToro.db.cuentas CtaAnterior)
{
if (!Ejercicio.cuentas.Any(X => (X.NumeroCuenta ?? "") == (CtaAnterior.NumeroCuenta ?? "")))
{
var nc = new bdGrupoSanchoToro.db.cuentas();
nc.Denominacion = CtaAnterior.Denominacion;
nc.EsCuentaFinal = CtaAnterior.EsCuentaFinal;
nc.Mote = CtaAnterior.Mote;
nc.Observaciones = CtaAnterior.Observaciones;
nc.NumeroCuenta = CtaAnterior.NumeroCuenta;
nc.idEjercicio = Ejercicio.idEjercicio;
nc.idEmpresaAmortizacion = CtaAnterior.idEmpresaAmortizacion;
nc.PresupuestoEnero = CtaAnterior.PresupuestoEnero;
nc.PresupuestoFebrero = CtaAnterior.PresupuestoFebrero;
nc.PresupuestoMarzo = CtaAnterior.PresupuestoMarzo;
nc.PresupuestoAbril = CtaAnterior.PresupuestoAbril;
nc.PresupuestoMayo = CtaAnterior.PresupuestoMayo;
nc.PresupuestoJunio = CtaAnterior.PresupuestoJunio;
nc.PresupuestoJulio = CtaAnterior.PresupuestoJulio;
nc.PresupuestoAgosto = CtaAnterior.PresupuestoAgosto;
nc.PresupuestoSeptiembre = CtaAnterior.PresupuestoSeptiembre;
nc.PresupuestoOctubre = CtaAnterior.PresupuestoOctubre;
nc.PresupuestoNoviembre = CtaAnterior.PresupuestoNoviembre;
nc.PresupuestoDiciembre = CtaAnterior.PresupuestoDiciembre;
bd.cuentas.Add(nc);
return 1;
}
else
{
return 0;
}
}
public static ejercicioscontables AbreEjercicio(tscGrupoSanchoToro bd, DateOnly Fecha)
{
var ej = new ejercicioscontables();
ej.FechaApertura = DateOnly.FromDateTime(DateTime.Now);
ej.FechaInicio = DateOnly.FromDateTime(new DateTime(Fecha.Year, 1, 1));
ej.FechaFin = DateOnly.FromDateTime( new DateTime(Fecha.Year, 12, 31));
ej.Descripcion = Fecha.Year.ToString();
bd.ejercicioscontables.Add(ej);
bd.SaveChanges();
ej.CopiaCuentas();
return ej;
}
public static bool CompruebaEjereciciosAbiertos(tscGrupoSanchoToro bd, List<DateOnly> Fechas)
{
var ejeabiertos = bd.ejercicioscontables.Where(x => x.FechaCierre.HasValue == false).ToList();
return Fechas.All(x => ejeabiertos.Any(y => y.FechaInicio <= x & y.FechaFin >= x));
}
}
}