Files
SanchoToro/bdGrupoSanchoToro/extensiones/asientos.cs
2026-01-30 13:44:23 +01:00

133 lines
3.8 KiB
C#

using FluentFTP.Helpers;
using Microsoft.VisualBasic;
using System;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data;
using System.Linq;
namespace bdGrupoSanchoToro.db
{
public partial class asientos
{
public enum TipoAsiento : int
{
NORMAL = 0,
APERTURA = 1,
REGULARIZACION = 2
}
[NotMapped]
public string Cuentas
{
get
{
if (this.apuntes.Count > 10)
return "** MÁS DE 10 **";
else
{
string sCuentas = "";
foreach (var ap in this.apuntes)
sCuentas += ap.idCuentaNavigation.NumeroCuenta + " ";
return sCuentas.Trim();
}
}
}
[NotMapped]
public string Documentos
{
get
{
string sDocumentos = "";
foreach (var ap in this.apuntes.ToList().Where(x => x.NumeroDocumento != null && x.NumeroDocumento != "").GroupBy(x => x.NumeroDocumento))
sDocumentos += ap.First().NumeroDocumento + " ";
return sDocumentos.Trim();
}
}
[NotMapped]
public string Conceptos
{
get
{
string sDocumentos = "";
foreach (var ap in this.apuntes.ToList().GroupBy(x => x.Concepto))
sDocumentos += ap.First().Concepto + " ";
return sDocumentos.Trim();
}
}
[NotMapped]
public int? idAsiento_Nulable
{
get
{
if (this.idAsiento == 0)
return null;
else
return this.idAsiento;
}
}
public void RellenaCuentaTmp()
{
foreach (var ap in this.apuntes)
{
ap.NumeroCuentaTmp = ap.idCuentaNavigation.NumeroCuenta;
ap.DescripcionCuentaTmp = ap.idCuentaNavigation.Denominacion;
}
}
public void RefrescaExtensiones()
{
OnPropertyChanged("EjercicioTmp");
OnPropertyChanged("idAsiento_Nulable");
}
public static cuentas ObtieneCuenta(tscGrupoSanchoToro bd, string cta, int idEjercicio)
{
var cuenta = bd.cuentas.FirstOrDefault(x => x.NumeroCuenta == cta & x.idEjercicio == idEjercicio);
if (cuenta == null)
{
var ctaant = bd.cuentas.Where(x => x.NumeroCuenta == cta).OrderByDescending(x => x.idEjercicioNavigation.FechaInicio).FirstOrDefault();
if (ctaant != null)
cuenta = bdGrupoSanchoToro.db.cuentas.CreaCuenta(bd, idEjercicio, cta, ctaant.Denominacion, ctaant.Observaciones);
}
return cuenta;
}
[NotMapped]
public bool Punteado
{
get
{
return FechaPunteo.HasValue;
}
set
{
if (value)
{
FechaPunteo = DateTime.Now;
}
else
{
FechaPunteo=null;
}
OnPropertyChanged("Punteado");
}
}
[NotMapped]
private string _Ejercicio;
[NotMapped]
public string EjercicioTmp
{
get
{
if (_Ejercicio == "" && idEjercicioNavigation != null)
_Ejercicio = idEjercicioNavigation.Descripcion;
return _Ejercicio;
}
set
{
_Ejercicio = value;
OnPropertyChanged("EjercicioTmp");
}
}
}
}