Agregar archivos de proyecto.
This commit is contained in:
492
bdGrupoSanchoToro/extensiones/movimientoscaja.cs
Normal file
492
bdGrupoSanchoToro/extensiones/movimientoscaja.cs
Normal file
@@ -0,0 +1,492 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Microsoft.VisualBasic.CompilerServices;
|
||||
using tsUtilidades.Extensiones;
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
|
||||
public partial class movimientoscaja:INotifyPropertyChanged
|
||||
{
|
||||
|
||||
public string FacturaYFecha
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idFacturaNavigation is not null)
|
||||
{
|
||||
return this.idFacturaNavigation.NumeroFactura + " (" + this.idFacturaNavigation.FechaFactura.ToString("dd-MM-yyyy") + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
public DateTime? FechaCierre
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idMovimientoCierreNavigation is not null)
|
||||
{
|
||||
return this.idMovimientoCierreNavigation.Fecha;
|
||||
}
|
||||
else
|
||||
{
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Impresion
|
||||
{
|
||||
get
|
||||
{
|
||||
switch ((TipoMovimientoEnum)this.Tipo)
|
||||
{
|
||||
case TipoMovimientoEnum.RECIBO_CLIENTE:
|
||||
{
|
||||
return "Imprimir Recibo";
|
||||
}
|
||||
case TipoMovimientoEnum.CIERRE_CAJA:
|
||||
{
|
||||
return "Imprimir Cierre";
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Clase
|
||||
{
|
||||
get
|
||||
{
|
||||
switch ((TipoMovimientoEnum)this.Tipo)
|
||||
{
|
||||
case TipoMovimientoEnum.RECIBO_CLIENTE:
|
||||
{
|
||||
if (this.idFacturaNavigation is null)
|
||||
{
|
||||
return "*DESCONOCIDO*";
|
||||
}
|
||||
else if (this.idFacturaNavigation.TotalIVA != 0d)
|
||||
{
|
||||
return "A";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "B";
|
||||
}
|
||||
}
|
||||
case TipoMovimientoEnum.FIANZA:
|
||||
{
|
||||
return "A";
|
||||
}
|
||||
case TipoMovimientoEnum.RECIBO_PROVEEDOR:
|
||||
{
|
||||
return "A";
|
||||
}
|
||||
case TipoMovimientoEnum.OTROS_GASTOS_O_INGRESOS:
|
||||
{
|
||||
return "B";
|
||||
}
|
||||
case TipoMovimientoEnum.CIERRE_CAJA:
|
||||
{
|
||||
return "CIERRE CAJA";
|
||||
}
|
||||
case TipoMovimientoEnum.REGULARIZACION_CAJA:
|
||||
{
|
||||
return "REGULARIZACION_CAJA"; // TipoMovimientoEnum.TRASPASO_DE_OTRA_CAJA
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
return "TRASPASOS";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public virtual double ImporteNegativo
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Importe * (double)-1;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.Importe = value * -1;
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public string RazonSocial
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idFactura.HasValue)
|
||||
{
|
||||
return this.idFacturaNavigation.idClienteNavigation.RazonSocial;
|
||||
}
|
||||
else if (this.idFacturaRecibida.HasValue)
|
||||
{
|
||||
return this.idFacturaRecibidaNavigation.idProveedorNavigation.RazonSocial;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual int? idEntidad
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
if (this.idFactura.HasValue)
|
||||
{
|
||||
return this.idFacturaNavigation.idCliente;
|
||||
}
|
||||
else if (this.idFacturaRecibida.HasValue)
|
||||
{
|
||||
return this.idFacturaRecibidaNavigation.idProveedor;
|
||||
}
|
||||
else
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual string ReferenciaDocumento
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
if (this.idFactura.HasValue)
|
||||
{
|
||||
return !string.IsNullOrEmpty(this.idFacturaNavigation.NumeroFactura.NothingAVacio()) ? this.idFacturaNavigation.NumeroFactura : this.idFacturaNavigation.idFactura.ToString();
|
||||
}
|
||||
else if (this.idFacturaRecibida.HasValue)
|
||||
{
|
||||
return this.idFacturaRecibidaNavigation.NumeroFactura;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual DateOnly? FechaDocumento
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
if (this.idFactura.HasValue)
|
||||
{
|
||||
return this.idFacturaNavigation.FechaFactura;
|
||||
}
|
||||
else if (this.idFacturaRecibida.HasValue)
|
||||
{
|
||||
return this.idFacturaRecibidaNavigation.FechaFactura;
|
||||
}
|
||||
else
|
||||
{
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public virtual string DescripcionTipoMovimiento
|
||||
{
|
||||
get
|
||||
{
|
||||
TipoMovimientoEnum tip = (TipoMovimientoEnum)this.Tipo;
|
||||
return tip.ToString().Replace("_", " ");
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual int? idCaja_Nulable
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idCaja == 0)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.idCaja;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value.HasValue)
|
||||
{
|
||||
this.idCaja = value.Value;
|
||||
}
|
||||
this.OnPropertyChanged("idCaja_Nulable");
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual ICollection<movimientoscaja> MovimientosDelCierre
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.InverseidMovimientoCierreNavigation;
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public virtual string ClienteOProveedor
|
||||
{
|
||||
get
|
||||
{
|
||||
switch ((TipoMovimientoEnum)this.Tipo)
|
||||
{
|
||||
case TipoMovimientoEnum.RECIBO_CLIENTE:
|
||||
{
|
||||
return this.idFacturaNavigation.idClienteNavigation.RazonSocial;
|
||||
}
|
||||
|
||||
case TipoMovimientoEnum.RECIBO_PROVEEDOR:
|
||||
{
|
||||
return this.idFacturaRecibidaNavigation.idProveedorNavigation.RazonSocial;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual string Descripcion
|
||||
{
|
||||
get
|
||||
{
|
||||
switch ((TipoMovimientoEnum)this.Tipo)
|
||||
{
|
||||
case TipoMovimientoEnum.RECIBO_CLIENTE:
|
||||
{
|
||||
return "Recibo a " + this.idFacturaNavigation.idClienteNavigation.RazonSocial + " Nº " + this.NumeroRecibo;
|
||||
}
|
||||
|
||||
case TipoMovimientoEnum.RECIBO_PROVEEDOR:
|
||||
{
|
||||
return "Pago a " + this.idFacturaRecibidaNavigation.idProveedorNavigation.RazonSocial + " Fra: " + this.idFacturaRecibidaNavigation.NumeroFactura;
|
||||
}
|
||||
case TipoMovimientoEnum.OTROS_GASTOS_O_INGRESOS:
|
||||
{
|
||||
if (this.Importe > 0d)
|
||||
{
|
||||
return "Ingreso: " + this.Observaciones;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Gasto: " + this.Observaciones;
|
||||
}
|
||||
}
|
||||
case TipoMovimientoEnum.REGULARIZACION_CAJA:
|
||||
{
|
||||
return "Regularización de Caja"; // TipoMovimientoEnum.TRASPASO_DE_OTRA_CAJA
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
return this.Observaciones;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual double ImporteCerrado
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.InverseidMovimientoCierreNavigation.Sum(x => x.Importe);
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual double SaldoDespuesCierre
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.SaldoAntesCierre + ImporteCerrado;
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual double ImporteEntradasMovimientosCerrados
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.InverseidMovimientoCierreNavigation.Where(x => x.Importe > 0d).Sum(x => x.Importe);
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual double ImporteSalidasMovimientosCerrados
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.InverseidMovimientoCierreNavigation.Where(x => x.Importe < 0d).Sum(x => x.Importe) * -1;
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual string NumeroReciboTMP
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idMovimiento == 0)
|
||||
{
|
||||
return "« AUTOMÁTICO »";
|
||||
}
|
||||
else if (string.IsNullOrEmpty(this.NumeroRecibo.NothingAVacio()))
|
||||
{
|
||||
return this.idMovimiento.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.NumeroRecibo;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void EstableceNumeroRecibo()
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.NumeroRecibo.NothingAVacio()))
|
||||
{
|
||||
var ur = this.idFacturaNavigation.movimientoscaja.ToList().Where(x => x.NumeroRecibo.NothingAVacio().Contains(".")).OrderByDescending(x => x.NumeroRecibo).FirstOrDefault();
|
||||
int NuevoRec = 1;
|
||||
if (ur is not null)
|
||||
NuevoRec = Conversions.ToInteger(ur.NumeroRecibo.Split('.')[1]) + 1;
|
||||
this.NumeroRecibo = this.idFacturaNavigation.NumeroFactura + "." + NuevoRec.ToString().PadLeft(3, '0');
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public virtual DateTime? FechaConciliacion
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idConciliacionNavigation is not null)
|
||||
{
|
||||
return this.Fecha;
|
||||
}
|
||||
else
|
||||
{
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool? _Conciliado;
|
||||
[ NotMapped]public virtual bool Conciliado
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Conciliado.HasValue)
|
||||
{
|
||||
return (bool)_Conciliado;
|
||||
}
|
||||
else if (ConciliacionActual_TMP is not null)
|
||||
{
|
||||
if (ConciliacionActual_TMP.idConciliacion is var arg1 && this.idConciliacion is { } arg2 && arg1 != arg2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.idConciliacion.HasValue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.idConciliacion.HasValue;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
_Conciliado = value;
|
||||
if (value)
|
||||
{
|
||||
this.idConciliacionNavigation = ConciliacionActual_TMP;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.idConciliacion = default(int?);
|
||||
}
|
||||
}
|
||||
}
|
||||
[NotMapped] public virtual conciliacionesbancarias ConciliacionActual_TMP { get; set; }
|
||||
// Public ReadOnly Property ConciliadoEn As String
|
||||
// Get
|
||||
// If ConciliacionActual_TMP IsNot Nothing AndAlso Me.idConciliacion.HasValue AndAlso Me.idConciliacion <> ConciliacionActual_TMP.idConciliacion Then
|
||||
// Return "Nº Conc.: " & Me.idConciliacion & " (" & Me.conciliacionesbancarias.Año.ToString & "-" & Me.conciliacionesbancarias.Mes.ToString & ")"
|
||||
// Else
|
||||
// Return ""
|
||||
// End If
|
||||
// End Get
|
||||
// End Property
|
||||
private string _FicheroAdjuntoTMP;
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
[NotMapped] public virtual string FicheroAdjuntoTMP
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idFicheroNavigation is not null)
|
||||
{
|
||||
_FicheroAdjuntoTMP = this.idFicheroNavigation.NombreFichero;
|
||||
return _FicheroAdjuntoTMP;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
if (this.idFicheroNavigation is not null)
|
||||
{
|
||||
this.idFicheroNavigation = null;
|
||||
}
|
||||
}
|
||||
_FicheroAdjuntoTMP = value;
|
||||
this.OnPropertyChanged("FicheroAdjuntoTMP");
|
||||
}
|
||||
}
|
||||
protected void OnPropertyChanged([CallerMemberName] string name = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
||||
}
|
||||
}
|
||||
|
||||
public enum TipoMovimientoEnum
|
||||
{
|
||||
RECIBO_CLIENTE = 0,
|
||||
FIANZA = 1,
|
||||
RECIBO_PROVEEDOR = 2,
|
||||
TRASPASO_CAJA = 3,
|
||||
OTROS_GASTOS_O_INGRESOS = 4,
|
||||
REGULARIZACION_CAJA = 8,
|
||||
CIERRE_CAJA = 9
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user