143 lines
4.3 KiB
C#
143 lines
4.3 KiB
C#
using Microsoft.VisualBasic.CompilerServices;
|
|
using System;
|
|
using System.ComponentModel;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
namespace bdGrupoSanchoToro.db
|
|
{
|
|
public partial class apuntes
|
|
{
|
|
[NotMapped]
|
|
private string _NumeroCuentaTmp;
|
|
[NotMapped]
|
|
public string NumeroCuentaTmp
|
|
{
|
|
get
|
|
{
|
|
return _NumeroCuentaTmp;
|
|
}
|
|
set
|
|
{
|
|
_NumeroCuentaTmp = value;
|
|
OnPropertyChanged("NumeroCuentaTmp");
|
|
}
|
|
}
|
|
[NotMapped]
|
|
public double SaldoCuentaTmp { get; set; }
|
|
[NotMapped]
|
|
public string DescripcionCuentaTmp { get; set; }
|
|
public static void EstableceSaldoTmp(List<apuntes> lap)
|
|
{
|
|
double SaldoAnterior = 0;
|
|
foreach (var ap in lap)
|
|
{
|
|
SaldoAnterior = SaldoAnterior + ap.Debe - ap.Haber;
|
|
ap.SaldoCuentaTmp = SaldoAnterior;
|
|
}
|
|
}
|
|
public static List<Tipo> ListaTiposDocumentos()
|
|
{
|
|
var lEstados = new List<Tipo>();
|
|
foreach (TiposDocumentos Enumeracion in Enum.GetValues(typeof(TiposDocumentos)))
|
|
lEstados.Add(new Tipo() { id = (int)Enumeracion, Descripcion = Enumeracion.ToString().Replace("_", " ") });
|
|
return lEstados;
|
|
}
|
|
|
|
|
|
public double DebeAnterior(tscGrupoSanchoToro bd, DateOnly Fecha)
|
|
{
|
|
try
|
|
{
|
|
var aps = bd.apuntes.Where(X => X.idCuentaNavigation.idCuenta == this.idCuenta & X.idAsientoNavigation.Fecha < Fecha).ToList();
|
|
return aps.Sum(x => x.Debe);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message, ex);
|
|
}
|
|
}
|
|
public double HaberAnterior(tscGrupoSanchoToro bd, DateOnly Fecha)
|
|
{
|
|
try
|
|
{
|
|
var aps = bd.apuntes.Where(X => X.idCuenta == this.idCuenta & X.idAsientoNavigation.Fecha < Fecha).ToList();
|
|
return aps.Sum(x => x.Haber);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message, ex);
|
|
}
|
|
}
|
|
[NotMapped]
|
|
private bool? _Conciliado;
|
|
[NotMapped]
|
|
public bool Conciliado
|
|
{
|
|
get
|
|
{
|
|
if (_Conciliado.HasValue)
|
|
return (bool)_Conciliado;
|
|
else if (ConciliacionActual_TMP != null)
|
|
{
|
|
if (ConciliacionActual_TMP.idConciliacion != this.idConciliacion)
|
|
return false;
|
|
else
|
|
return this.idConciliacion.HasValue;
|
|
}
|
|
else
|
|
return this.idConciliacion.HasValue;
|
|
}
|
|
set
|
|
{
|
|
_Conciliado = value;
|
|
if (value)
|
|
this.idConciliacionNavigation = this.ConciliacionActual_TMP;
|
|
else
|
|
this.idConciliacion = null;
|
|
}
|
|
}
|
|
public string ConciliadoEn
|
|
{
|
|
get
|
|
{
|
|
if (ConciliacionActual_TMP != null && this.idConciliacion.HasValue && this.idConciliacion != ConciliacionActual_TMP.idConciliacion)
|
|
return "Nº Conc.: " + this.idConciliacion + " (" + this.idConciliacionNavigation.Anno.ToString + "-" + this.idConciliacionNavigation.Mes.ToString + ")";
|
|
else
|
|
return "";
|
|
}
|
|
}
|
|
[NotMapped]
|
|
public conciliacionesbancarias ConciliacionActual_TMP { get; set; }
|
|
[NotMapped]
|
|
public double Saldo
|
|
{
|
|
get
|
|
{
|
|
return Math.Round(Debe - Haber, 2);
|
|
}
|
|
}
|
|
[NotMapped]
|
|
public double Diferencia
|
|
{
|
|
get
|
|
{
|
|
return Debe - Haber;
|
|
}
|
|
}
|
|
|
|
|
|
public class Tipo
|
|
{
|
|
public int id { get; set; }
|
|
public string Descripcion { get; set; }
|
|
}
|
|
|
|
public enum TiposDocumentos
|
|
{
|
|
RECIBO = 1,
|
|
FACTURA = 2,
|
|
OTRO = 99
|
|
}
|
|
}
|
|
} |