agregado procesos y bd clases
This commit is contained in:
107
bdAsegasa/Extensiones/DatosRecibosExportacion.cs
Normal file
107
bdAsegasa/Extensiones/DatosRecibosExportacion.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
[Serializable]
|
||||
public class DatosRecibosExportacion
|
||||
{
|
||||
public DatosRecibosExportacion()
|
||||
{
|
||||
}
|
||||
|
||||
public DatosRecibosExportacion(vf_recibosextendidos Recibo)
|
||||
{
|
||||
CodigoRecibo = Recibo.CodigoRecibo;
|
||||
NumeroPoliza = Recibo.NumeroPoliza;
|
||||
Tomador = Recibo.Tomador;
|
||||
Matricula = Recibo.Matricula;
|
||||
FechaEfecto = Recibo.FechaEfecto;
|
||||
FechaVencimiento = Recibo.FechaVencimiento;
|
||||
Compania = Recibo.Compania;
|
||||
Agente = Recibo.Agente;
|
||||
SubAgente = Recibo.SubAgente;
|
||||
Ramo = Recibo.Ramo;
|
||||
FechaExpedicion = Recibo.FechaExpedicion;
|
||||
BienesAsegurados = Recibo.BienesAsegurados;
|
||||
FechaBaja = Recibo.FechaBaja;
|
||||
CausaBaja = Recibo.CausaBaja;
|
||||
TipoRecibo = Recibo.TipoRecibo;
|
||||
TipoPago = Recibo.TipoPago;
|
||||
Oficina = Recibo.Oficina;
|
||||
PrimaNeta = Recibo.PrimaNeta;
|
||||
BonificacionORecargo = Recibo.BonificacionORecargo;
|
||||
Consorcio = Recibo.Consorcio;
|
||||
Impuesto = Recibo.Impuesto;
|
||||
RecargoExterno = Recibo.RecargoExterno;
|
||||
TotalRecibo = Recibo.TotalRecibo;
|
||||
ComisionReciboPrimaNeta = Recibo.ComisionReciboPrimaNeta;
|
||||
PorcentajeReciboPrimaNeta = Recibo.PorcentajeReciboPrimaNeta;
|
||||
TotalComision = Recibo.TotalComision;
|
||||
PorcentajeComisionAgente = Recibo.PorcentajeComisionAgente;
|
||||
ComisionAgente = Recibo.ComisionAgente;
|
||||
}
|
||||
|
||||
public DatosRecibosExportacion(ve_recibos Recibo)
|
||||
{
|
||||
CodigoRecibo = Recibo.CodigoRecibo;
|
||||
NumeroPoliza = Recibo.NumeroPoliza;
|
||||
Tomador = Recibo.Tomador;
|
||||
Matricula = Recibo.Matricula;
|
||||
FechaEfecto = Recibo.FechaEfecto;
|
||||
FechaRecepcionCia = Recibo.FechaRecepcionCia;
|
||||
FechaVencimiento = Recibo.FechaVencimiento;
|
||||
Compania = Recibo.Compania;
|
||||
Agente = Recibo.Agente;
|
||||
SubAgente = Recibo.SubAgente;
|
||||
Ramo = Recibo.Ramo;
|
||||
FechaExpedicion = Recibo.FechaExpedicion;
|
||||
BienesAsegurados = Recibo.BienesAsegurados;
|
||||
FechaBaja = Recibo.FechaBaja;
|
||||
CausaBaja = Recibo.CausaBaja;
|
||||
TipoRecibo = Recibo.TipoRecibo;
|
||||
TipoPago = Recibo.TipoPago;
|
||||
Oficina = Recibo.Oficina;
|
||||
PrimaNeta = Recibo.PrimaNeta;
|
||||
BonificacionORecargo = Recibo.BonificacionORecargo;
|
||||
Consorcio = Recibo.Consorcio;
|
||||
Impuesto = Recibo.Impuesto;
|
||||
RecargoExterno = Recibo.RecargoExterno;
|
||||
TotalRecibo = Recibo.TotalRecibo;
|
||||
ComisionReciboPrimaNeta = Recibo.ComisionReciboPrimaNeta;
|
||||
PorcentajeReciboPrimaNeta = Recibo.PorcentajeReciboPrimaNeta;
|
||||
TotalComision = Recibo.TotalComision;
|
||||
PorcentajeComisionAgente = Recibo.PorcentajeComisionAgente;
|
||||
ComisionAgente = Recibo.ComisionAgente;
|
||||
}
|
||||
|
||||
public string CodigoRecibo { get; set; }
|
||||
public string NumeroPoliza { get; set; }
|
||||
public string Tomador { get; set; }
|
||||
public string Matricula { get; set; }
|
||||
public DateOnly FechaEfecto { get; set; }
|
||||
public DateOnly? FechaRecepcionCia { get; set; }
|
||||
public DateOnly FechaVencimiento { get; set; }
|
||||
public string Compania { get; set; }
|
||||
public string Agente { get; set; }
|
||||
public string SubAgente { get; set; }
|
||||
public string Ramo { get; set; }
|
||||
public DateOnly? FechaExpedicion { get; set; }
|
||||
public string BienesAsegurados { get; set; }
|
||||
public DateOnly? FechaBaja { get; set; }
|
||||
public string CausaBaja { get; set; }
|
||||
public string TipoRecibo { get; set; }
|
||||
public string TipoPago { get; set; }
|
||||
public string Oficina { get; set; }
|
||||
public double? PrimaNeta { get; set; }
|
||||
public double? BonificacionORecargo { get; set; }
|
||||
public double? Consorcio { get; set; }
|
||||
public double? Impuesto { get; set; }
|
||||
public double? RecargoExterno { get; set; }
|
||||
public double? TotalRecibo { get; set; }
|
||||
public double? ComisionReciboPrimaNeta { get; set; }
|
||||
public double? PorcentajeReciboPrimaNeta { get; set; }
|
||||
public double? TotalComision { get; set; }
|
||||
public double? PorcentajeComisionAgente { get; set; }
|
||||
public double? ComisionAgente { get; set; }
|
||||
}
|
||||
}
|
||||
11
bdAsegasa/Extensiones/Etiquetas.cs
Normal file
11
bdAsegasa/Extensiones/Etiquetas.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public class Etiquetas
|
||||
{
|
||||
public string? Campo1 { get; set; }
|
||||
public string? Campo2 { get; set; }
|
||||
public string? Campo3 { get; set; }
|
||||
public string? Campo4 { get; set; }
|
||||
public string? Campo5 { get; set; }
|
||||
}
|
||||
}
|
||||
14
bdAsegasa/Extensiones/GrupoLiquidacionCias.cs
Normal file
14
bdAsegasa/Extensiones/GrupoLiquidacionCias.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public class GrupoLiquidacionCias
|
||||
{
|
||||
public double NumeroGeneracion { get; set; }
|
||||
public DateTime FechaGeneracion { get; set; }
|
||||
public List<pagosliquidacionescias> Pagos { get; set; } = new List<pagosliquidacionescias>();
|
||||
public double TotalLiquidacion => Math.Round(Pagos.Sum(x => x.ImportePago), 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
14
bdAsegasa/Extensiones/PagoExtorno.cs
Normal file
14
bdAsegasa/Extensiones/PagoExtorno.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public class PagoExtorno
|
||||
{
|
||||
public double NumeroGeneracion { get; set; }
|
||||
public DateTime FechaGeneracion { get; set; }
|
||||
public List<ve_recibos> Pagos { get; set; } = new List<ve_recibos>();
|
||||
public double TotalLiquidacion => Math.Round(Pagos.Sum(x => (x.TotalRecibo ?? 0) * -1), 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
55
bdAsegasa/Extensiones/accionessiniestros_eiac.cs
Normal file
55
bdAsegasa/Extensiones/accionessiniestros_eiac.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class accionessiniestros_eiac
|
||||
{
|
||||
public enum ClavesAccionSiniestroEnum : int
|
||||
{
|
||||
DOCUMENTACIÓN_O_INFORMACIÓN = 1,
|
||||
JUDICIAL = 2,
|
||||
PERITACIÓN = 3,
|
||||
REPARACIÓN = 4,
|
||||
INDEMNIZACIÓN = 5,
|
||||
DESCONOCIDA = 99
|
||||
}
|
||||
|
||||
public string DescripcionAccionSiniestro
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.AccionSiniestro.HasValue)
|
||||
{
|
||||
return ((ClavesAccionSiniestroEnum)this.AccionSiniestro.Value).ToString().Replace("_", " ");
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum ClavesSituacionAccionEnum : int
|
||||
{
|
||||
PENDIENTE_DE_INICIO = 1,
|
||||
EN_CURSO_DE_EJECUCIÓN_INICIADA = 2,
|
||||
FINALIZADA = 3,
|
||||
DESCONOCIDA = 99
|
||||
}
|
||||
|
||||
public string DescripcionSituacionAccionSiniestro
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.SituacionAccion.HasValue)
|
||||
{
|
||||
return ((ClavesSituacionAccionEnum)this.SituacionAccion.Value).ToString().Replace("_", " ");
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
312
bdAsegasa/Extensiones/agentes.cs
Normal file
312
bdAsegasa/Extensiones/agentes.cs
Normal file
@@ -0,0 +1,312 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using tsUtilidades.Extensiones;
|
||||
using tsUtilidades.Enumeraciones;
|
||||
using System.ComponentModel.DataAnnotations.Schema; // Assuming enums might be here
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class agentes
|
||||
{
|
||||
public string NombreYCodigo
|
||||
{
|
||||
get
|
||||
{
|
||||
return Nombre + " - " + Codigo;
|
||||
}
|
||||
}
|
||||
|
||||
public string CodigoYNombre
|
||||
{
|
||||
get
|
||||
{
|
||||
return Codigo + " - " + Nombre;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual direcciones Direccion
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idDireccion.HasValue && this.idDireccion.Value > 0)
|
||||
{
|
||||
return this.idDireccionNavigation;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _CodigoPostalTmpEsNulo = true;
|
||||
private string _CodigoPostalTmp;
|
||||
public string CodigoPostalTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_CodigoPostalTmpEsNulo)
|
||||
{
|
||||
if (Direccion == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
_CodigoPostalTmp = Direccion.CodigoPostal;
|
||||
_CodigoPostalTmpEsNulo = false;
|
||||
return Direccion.CodigoPostal;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return _CodigoPostalTmp;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
_CodigoPostalTmp = value;
|
||||
_CodigoPostalTmpEsNulo = false;
|
||||
if (Direccion != null)
|
||||
{
|
||||
Direccion.CodigoPostal = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _DomicilioTmpEsNulo = true;
|
||||
private string _DomicilioTmp;
|
||||
public string DomicilioTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_DomicilioTmpEsNulo)
|
||||
{
|
||||
if (Direccion == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
_DomicilioTmp = Direccion.Direccion;
|
||||
_DomicilioTmpEsNulo = false;
|
||||
return Direccion.Direccion;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return _DomicilioTmp;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
_DomicilioTmp = value;
|
||||
_DomicilioTmpEsNulo = false;
|
||||
if (Direccion != null)
|
||||
{
|
||||
Direccion.Direccion = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _CodigoPoblacionTmpEsNulo = true;
|
||||
private string _CodigoPoblacionTmp;
|
||||
public string CodigoPoblacionTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_CodigoPoblacionTmpEsNulo)
|
||||
{
|
||||
if (Direccion == null || Direccion.CodigoMunicipio == null) // In VB it was Direccion.municipios Is Nothing, which usually checks the foreign key or nav property. We use the key or check the DB.
|
||||
{
|
||||
if (Direccion != null && Direccion.CodigoMunicipioNavigation == null) // Try to get navigation property
|
||||
{
|
||||
if ((Direccion.CodigoPostal ?? "") != "")
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
var pob = bd.codigospostales.FirstOrDefault(x => x.CodigoPostal == Direccion.CodigoPostal);
|
||||
if (pob == null)
|
||||
{
|
||||
return "CP.ERRONEO";
|
||||
}
|
||||
else
|
||||
{
|
||||
Direccion.CodigoMunicipio = pob.CodigoMunicipio;
|
||||
_CodigoPoblacionTmp = pob.CodigoMunicipio;
|
||||
_CodigoPoblacionTmpEsNulo = false;
|
||||
return _CodigoPoblacionTmp;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_CodigoPoblacionTmp = Direccion.CodigoMunicipio;
|
||||
_CodigoPoblacionTmpEsNulo = false;
|
||||
return Direccion.CodigoMunicipio;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return _CodigoPoblacionTmp;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
_CodigoPoblacionTmp = value;
|
||||
_CodigoPoblacionTmpEsNulo = false;
|
||||
if (Direccion != null)
|
||||
{
|
||||
Direccion.CodigoMunicipio = value;
|
||||
}
|
||||
ProvinciaTmp = municipios.ObtieneProvincia(_CodigoPoblacionTmp);
|
||||
PoblacionTmp = municipios.ObtienePoblacion(_CodigoPoblacionTmp);
|
||||
}
|
||||
}
|
||||
|
||||
private string _PoblacionTmp;
|
||||
private bool _PoblacionTmpEsNulo = true;
|
||||
public string PoblacionTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_PoblacionTmpEsNulo) _PoblacionTmp = municipios.ObtienePoblacion(CodigoPoblacionTmp);
|
||||
return _PoblacionTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_PoblacionTmp = value;
|
||||
_PoblacionTmpEsNulo = false;
|
||||
}
|
||||
}
|
||||
|
||||
private string _ProvinciaTmp;
|
||||
private bool _ProvinciaTmpEsNulo = true;
|
||||
public string ProvinciaTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_ProvinciaTmpEsNulo) _ProvinciaTmp = municipios.ObtieneProvincia(CodigoPoblacionTmp);
|
||||
return _ProvinciaTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_ProvinciaTmp = value;
|
||||
_ProvinciaTmpEsNulo = false;
|
||||
}
|
||||
}
|
||||
|
||||
public string OficinaAgente
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.Codigo != "000029013008" && (this.Codigo.StartsWith("2") || this.Codigo.StartsWith("000004") || this.Codigo.StartsWith("000018") || this.Codigo.StartsWith("000023") || this.Codigo.StartsWith("000029") || this.Codigo.StartsWith("100029")))
|
||||
{
|
||||
return "Antequera";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Sevilla";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public virtual List<polizassg> PolizasConDocumentosPendientes
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.polizassg.Where(x =>
|
||||
(x.NumeroPoliza != null || x.FechaAceptacionPresupuesto.HasValue) &&
|
||||
(x.FechaDocumentosSuplementoRevisado != null || x.NumeroSuplemento == 0 || x.idAgenteNavigation.Codigo == "1" || x.idAgenteNavigation.Codigo == "2") &&
|
||||
x.documentospolizassg.Any(y => y.Obligatorio && y.FechaComprobacion == null && y.idFichero == null)
|
||||
).ToList();
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual List<polizassg> PolizasConDocumentosPendientes7Dias
|
||||
{
|
||||
get
|
||||
{
|
||||
DateTime FechaInicio = DateTime.Today.AddDays(-7);
|
||||
return this.polizassg.Where(x =>
|
||||
x.FechaBaja.HasValue == false &&
|
||||
(x.NumeroPoliza != null || x.FechaAceptacionPresupuesto != null) &&
|
||||
(x.FechaAlta >= new DateTime(FechaInicio.Year, FechaInicio.Month, FechaInicio.Day) &&
|
||||
(x.FechaDocumentosSuplementoRevisado != null || x.NumeroSuplemento == 0 || x.idAgenteNavigation.Codigo == "1" || x.idAgenteNavigation.Codigo == "2") &&
|
||||
x.documentospolizassg.Any(y => y.FechaComprobacion == null && y.idFichero == null && y.Obligatorio && (y.idDocumentoASolicitarNavigation == null || y.idDocumentoASolicitarNavigation.SolicitarAAgente)))
|
||||
).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CambiaCarteraAgente(string AgenteAnterior, string AgenteNuevo)
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
var idnueage = bd.agentes.First(x => x.Codigo == AgenteNuevo).idAgente;
|
||||
|
||||
var recs = bd.recibos.Where(x => x.liquidacionesagenterecibos.Any() == false && x.idAgenteNavigation.Codigo == AgenteAnterior).ToList();
|
||||
|
||||
int tge = (int)TipoGestionEnum.CAMBIO_CARTERA_AGENTE;
|
||||
|
||||
foreach (var r in recs)
|
||||
{
|
||||
r.idAgente = idnueage;
|
||||
var tg = new gestionesrecibos
|
||||
{
|
||||
idRecibo = r.idRecibo,
|
||||
FormaComunicacion = (int)FormaComunicacionEnum.POR_EMAIL, // Used to be just 4
|
||||
Tipo = tge,
|
||||
GestionesRealizadas = TipoGestionEnum.CAMBIO_CARTERA_AGENTE.ToString().Replace("_", " "),
|
||||
Fecha = DateTime.Now,
|
||||
idCorreo = null,
|
||||
Observaciones = "Cambio Cartera Agente del " + AgenteAnterior + " al " + AgenteNuevo
|
||||
};
|
||||
bd.gestionesrecibos.Add(tg);
|
||||
}
|
||||
bd.SaveChanges();
|
||||
|
||||
var tgp = bd.enumeraciones.First(x => x.Codigo == "TGP.CAMCARAG");
|
||||
var idtgp = tgp.idEnumeracion;
|
||||
|
||||
var pols = bd.polizassg.Where(x => x.idAgenteNavigation.Codigo == AgenteAnterior && x.FechaBaja.HasValue == false);
|
||||
foreach (var p in pols)
|
||||
{
|
||||
p.idAgente = idnueage;
|
||||
var tg = new gestionespolizassg
|
||||
{
|
||||
idPoliza = p.idPoliza,
|
||||
idTipo = idtgp,
|
||||
GestionesRealizadas = tgp.Descripcion,
|
||||
Fecha = DateTime.Now,
|
||||
Observaciones = "Cambio Cartera Agente del " + AgenteAnterior + " al " + AgenteNuevo
|
||||
};
|
||||
bd.gestionespolizassg.Add(tg);
|
||||
}
|
||||
bd.SaveChanges();
|
||||
|
||||
var ageant = bd.agentes.First(x => x.Codigo == AgenteAnterior);
|
||||
bool bbaja;
|
||||
if (ageant.FechaBaja.HasValue == false)
|
||||
{
|
||||
ageant.FechaBaja = new DateOnly(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
|
||||
bbaja = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bbaja = false;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
return bbaja;
|
||||
}
|
||||
}
|
||||
}
|
||||
74
bdAsegasa/Extensiones/amortizacionrecibos.cs
Normal file
74
bdAsegasa/Extensiones/amortizacionrecibos.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class amortizacionrecibos
|
||||
{
|
||||
public string Tomador
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idReciboNavigation != null && this.idReciboNavigation.idPolizaNavigation != null)
|
||||
{
|
||||
return this.idReciboNavigation.idPolizaNavigation.RazonSocialTomadorTmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
public string Compania
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idReciboNavigation != null && this.idReciboNavigation.idPolizaNavigation != null && this.idReciboNavigation.idPolizaNavigation.idCompaniaNavigation != null)
|
||||
{
|
||||
return this.idReciboNavigation.idPolizaNavigation.idCompaniaNavigation.Nombre;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
public string Ramo
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idReciboNavigation != null && this.idReciboNavigation.idPolizaNavigation != null && this.idReciboNavigation.idPolizaNavigation.idRamoNavigation != null)
|
||||
{
|
||||
return this.idReciboNavigation.idPolizaNavigation.idRamoNavigation.Descripcion;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ve_amortizacionrecibos
|
||||
{
|
||||
public int idAmortizacion { get; set; }
|
||||
public int? idRecibo { get; set; }
|
||||
public DateOnly FechaInicioAmortizacion { get; set; }
|
||||
public DateOnly FechaFinAmortizacion { get; set; }
|
||||
public double? PorcentajeAnual { get; set; }
|
||||
public DateOnly? FechaBaja { get; set; }
|
||||
public int? idMotivoBaja { get; set; }
|
||||
public int idEmpresa { get; set; }
|
||||
public string NumeroCuenta { get; set; }
|
||||
public string Observaciones { get; set; }
|
||||
public DateOnly? FechaAlta { get; set; }
|
||||
public string CodigoRecibo { get; set; }
|
||||
public double TotalRecibo { get; set; }
|
||||
public string Ramo { get; set; }
|
||||
public string Compañía { get; set; }
|
||||
public string Tomador { get; set; }
|
||||
public string CIFTomador { get; set; }
|
||||
public string CausaBaja { get; set; }
|
||||
public string Empresa { get; set; }
|
||||
}
|
||||
}
|
||||
136
bdAsegasa/Extensiones/apuntes.cs
Normal file
136
bdAsegasa/Extensiones/apuntes.cs
Normal file
@@ -0,0 +1,136 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using bdAsegasa.dbcontext;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class apuntes
|
||||
{
|
||||
public string NumeroCuentaTmp { get; set; }
|
||||
public double SaldoCuentaTmp { get; set; }
|
||||
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 enum TiposDocumentos
|
||||
{
|
||||
RECIBO = 1,
|
||||
FACTURA = 2,
|
||||
OTRO = 99
|
||||
}
|
||||
|
||||
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(tscgestionasegasa bd, DateOnly Fecha)
|
||||
{
|
||||
try
|
||||
{
|
||||
var aps = bd.apuntes.Where(X => X.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(tscgestionasegasa 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);
|
||||
}
|
||||
}
|
||||
|
||||
public double Saldo => Math.Round(Debe - Haber, 2);
|
||||
|
||||
private bool? _Conciliado;
|
||||
public bool Conciliado
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Conciliado.HasValue)
|
||||
{
|
||||
return _Conciliado.Value;
|
||||
}
|
||||
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 virtual conciliacionesbancarias ConciliacionActual_TMP { get; set; }
|
||||
|
||||
public string ConciliadoEn
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ConciliacionActual_TMP != null && this.idConciliacion.HasValue && this.idConciliacion != ConciliacionActual_TMP.idconciliacion)
|
||||
{
|
||||
return "Nº Conc.: " + this.idConciliacion + " (" + this.idConciliacionNavigation.Año.ToString() + "-" + this.idConciliacionNavigation.Mes.ToString() + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double Diferencia => Debe - Haber;
|
||||
}
|
||||
|
||||
public class Tipo
|
||||
{
|
||||
public int id { get; set; }
|
||||
public string Descripcion { get; set; }
|
||||
}
|
||||
}
|
||||
549
bdAsegasa/Extensiones/asientos.cs
Normal file
549
bdAsegasa/Extensiones/asientos.cs
Normal file
@@ -0,0 +1,549 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using tsUtilidades.Extensiones;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class asientos
|
||||
{
|
||||
public enum TipoAsiento : int
|
||||
{
|
||||
NORMAL = 0,
|
||||
APERTURA = 1,
|
||||
REGULARIZACION = 2
|
||||
}
|
||||
|
||||
public string Cuentas
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.apuntes.Count > 10)
|
||||
{
|
||||
return "** MÁS DE 10 **";
|
||||
}
|
||||
else
|
||||
{
|
||||
string sCuentas = "";
|
||||
foreach (var ap in this.apuntes)
|
||||
{
|
||||
if (ap.idCuentaNavigation != null)
|
||||
{
|
||||
sCuentas += ap.idCuentaNavigation.NumeroCuenta + " ";
|
||||
}
|
||||
}
|
||||
return sCuentas.Trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Documentos
|
||||
{
|
||||
get
|
||||
{
|
||||
string sDocumentos = "";
|
||||
var docs = this.apuntes.ToList()
|
||||
.Where(x => !string.IsNullOrEmpty(x.NumeroDocumento))
|
||||
.GroupBy(x => x.NumeroDocumento);
|
||||
|
||||
foreach (var ap in docs)
|
||||
{
|
||||
sDocumentos += ap.First().NumeroDocumento + " ";
|
||||
}
|
||||
return sDocumentos.Trim();
|
||||
}
|
||||
}
|
||||
|
||||
public string Conceptos
|
||||
{
|
||||
get
|
||||
{
|
||||
string sConceptos = "";
|
||||
var groups = this.apuntes.ToList().GroupBy(x => x.Concepto);
|
||||
foreach (var ap in groups)
|
||||
{
|
||||
sConceptos += ap.First().Concepto + " ";
|
||||
}
|
||||
return sConceptos.Trim();
|
||||
}
|
||||
}
|
||||
|
||||
public int? idAsiento_Nulable
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idAsiento == 0) return null;
|
||||
return this.idAsiento;
|
||||
}
|
||||
}
|
||||
|
||||
public void RellenaCuentaTmp()
|
||||
{
|
||||
foreach (var ap in this.apuntes)
|
||||
{
|
||||
if (ap.idCuentaNavigation != null)
|
||||
{
|
||||
ap.NumeroCuentaTmp = ap.idCuentaNavigation.NumeroCuenta;
|
||||
ap.DescripcionCuentaTmp = ap.idCuentaNavigation.Denominacion;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void GeneraAsientoRecibosContado(tscgestionasegasa bd, List<vf_recibosextendidos> Recibos, Action<string, Exception> DelegadoError)
|
||||
{
|
||||
var hoy = DateOnly.FromDateTime(DateTime.Now);
|
||||
|
||||
var ej = bd.ejercicioscontables.FirstOrDefault(x => x.FechaInicio <= hoy && x.FechaFin >= hoy && !x.FechaCierre.HasValue);
|
||||
|
||||
if (ej == null) ej = bdAsegasa.db.ejercicioscontables.AbreEjercicio(bd, new DateTime(hoy.Year, hoy.Month, hoy.Day));
|
||||
|
||||
var idTiporem = bd.enumeraciones.First(x => x.Codigo == "TIPREM.CO").idEnumeracion;
|
||||
var tipospagos = bd.enumeraciones.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "TIPP").ToList();
|
||||
var idSituacion = bd.enumeraciones.First(x => x.Codigo == "SITR.PA").idEnumeracion;
|
||||
var Cont = bd.enumeraciones.First(x => x.Codigo == "CONT.NUMGEN");
|
||||
var Conceps = bd.conceptosapuntes.ToList();
|
||||
|
||||
if (Cont.ValorNumerico1.HasValue)
|
||||
Cont.ValorNumerico1++;
|
||||
else
|
||||
Cont.ValorNumerico1 = 1;
|
||||
|
||||
var remesa = new remesas();
|
||||
remesa.IBAN = "";
|
||||
remesa.FechaCreacion = DateTime.Now;
|
||||
remesa.Fecha = hoy;
|
||||
remesa.idTipo = idTiporem;
|
||||
|
||||
bd.remesas.Add(remesa);
|
||||
bd.SaveChanges();
|
||||
|
||||
int numgenerados = 0;
|
||||
int numerrores = 0;
|
||||
string sRecibosConErrores = "";
|
||||
List<vf_recibosextendidos> lrg = new List<vf_recibosextendidos>();
|
||||
|
||||
foreach (var recibo in Recibos)
|
||||
{
|
||||
var r = bd.recibos.First(x => x.idRecibo == recibo.idRecibo);
|
||||
try
|
||||
{
|
||||
GeneraAsientoReciboContado(bd, r, tipospagos, Conceps, idSituacion, remesa, (int)Cont.ValorNumerico1.Value);
|
||||
lrg.Add(recibo);
|
||||
numgenerados++;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
sRecibosConErrores += recibo.CodigoRecibo + Environment.NewLine;
|
||||
numerrores++;
|
||||
DelegadoError?.Invoke("GeneraAsientoRecibosContado", ex);
|
||||
}
|
||||
}
|
||||
|
||||
string sDestinatarios = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCONTA").ValorAlfabeticoLargo;
|
||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
byte[] f = null;
|
||||
|
||||
if (lrg.Count > 0)
|
||||
{
|
||||
var lr = lrg.Select(x => new
|
||||
{
|
||||
x.CodigoRecibo,
|
||||
x.NumeroPoliza,
|
||||
x.NumeroSuplemento,
|
||||
x.Tomador,
|
||||
x.BienesAsegurados,
|
||||
x.Ramo,
|
||||
x.Compania
|
||||
}).ToList();
|
||||
// f = tsWPF.Utilidades.Varias.IEnumerableAExcel(lr);
|
||||
// TODO: Implement Excel generation for .NET 8 if needed
|
||||
}
|
||||
|
||||
string sCuerpo = "";
|
||||
if (numgenerados > 0) sCuerpo = "Adjunto le remitimos listado de recibos marcados como remesados (Contado)";
|
||||
if (numerrores > 0)
|
||||
{
|
||||
sCuerpo += Environment.NewLine + "Los siguientes recibos no pudieron ser marcados como remesados correctamente: " + Environment.NewLine + sRecibosConErrores;
|
||||
}
|
||||
|
||||
if (numgenerados > 0)
|
||||
{
|
||||
bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(null, "Se han marcado " + numgenerados.ToString() + " Recibos como remesados (Contado)", sCuerpo, cta, f, "Pagos-" + DateTime.Now.ToString("yyyy-MM-dd") + ".xlsx", "Listado Recibos de con fecha de pago " + DateTime.Now.ToString("yyyy-MM-dd"), sDestinatarios, "", "sevilla@tecnosis.net");
|
||||
}
|
||||
else
|
||||
{
|
||||
bdAsegasa.db.correos.GeneraRegistroCorreo(null, "Los siguientes recibos no pudieron ser marcados como remesados (Contado)", sCuerpo, cta, sDestinatarios, "", "sevilla@tecnosis.net");
|
||||
}
|
||||
}
|
||||
|
||||
public static void GeneraAsientoReciboContado(tscgestionasegasa bd, recibos Recibo, List<enumeraciones> TiposPago, List<conceptosapuntes> Conceptos, int idSituacion, remesas Remesa, int NumeroGeneracion, bool Inverso = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
string Tipp = TiposPago.First(x => x.idEnumeracion == Recibo.idTipoPago).Codigo.Split('.')[1];
|
||||
var ent = Recibo.idPolizaNavigation.EntidadPolizaTomador.idEntidadNavigation;
|
||||
|
||||
var na = new asientos();
|
||||
bd.asientos.Add(na);
|
||||
|
||||
na.Fecha = Inverso ? DateOnly.FromDateTime(DateTime.Now) : Recibo.FechaPago.Value;
|
||||
na.idEjercicio = ejercicioscontables.ObtieneidEjercicioAbierto(new DateTime(na.Fecha.Year, na.Fecha.Month, na.Fecha.Day));
|
||||
na.Tipo = (int)asientos.TipoAsiento.NORMAL;
|
||||
na.FechaIntroduccion = DateTime.Now;
|
||||
if (bdAsegasa.db.Utilidades.dsc.idUsuario > 0) na.idUsuario = bdAsegasa.db.Utilidades.dsc.idUsuario;
|
||||
|
||||
var nap1 = new apuntes();
|
||||
nap1.idAsientoNavigation = na;
|
||||
nap1.Concepto = ent.RazonSocial;
|
||||
nap1.NumeroDocumento = Recibo.idRecibo.ToString();
|
||||
|
||||
string Cta = "";
|
||||
switch (Tipp)
|
||||
{
|
||||
case "PE":
|
||||
if (string.IsNullOrEmpty(ent.CuentaContable)) throw new Exception("La entidad " + ent.RazonSocial + " no tiene asignada una cuenta contable");
|
||||
Cta = ent.CuentaContable;
|
||||
nap1.idConcepto = Conceptos.First(x => x.Codigo == "029").idConcepto;
|
||||
break;
|
||||
case "CO":
|
||||
Cta = Recibo.OficinaAgente.ToUpper() == "SEVILLA" ? "57000000" : "57000002";
|
||||
if (Recibo.TotalRecibo > 0)
|
||||
nap1.idConcepto = Conceptos.First(x => x.Codigo == "015").idConcepto;
|
||||
else
|
||||
nap1.idConcepto = Conceptos.First(x => x.Codigo == "029").idConcepto;
|
||||
break;
|
||||
case "CTA":
|
||||
if (Recibo.TotalRecibo > 0)
|
||||
{
|
||||
Cta = "57000001";
|
||||
nap1.idConcepto = Conceptos.First(x => x.Codigo == "016").idConcepto;
|
||||
}
|
||||
else
|
||||
{
|
||||
Cta = "57200004";
|
||||
nap1.idConcepto = Conceptos.First(x => x.Codigo == "029").idConcepto;
|
||||
}
|
||||
nap1.Concepto = "TRF. " + ent.RazonSocial;
|
||||
break;
|
||||
case "CTR":
|
||||
Cta = "57200004";
|
||||
nap1.idConcepto = Conceptos.First(x => x.Codigo == "015").idConcepto;
|
||||
nap1.Concepto = "TRANS. " + ent.RazonSocial;
|
||||
break;
|
||||
case "CIN":
|
||||
Cta = "57200004";
|
||||
nap1.idConcepto = Conceptos.First(x => x.Codigo == "015").idConcepto;
|
||||
nap1.Concepto = "TPV. " + ent.RazonSocial;
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Tipo de pago " + Tipp + " no soportado");
|
||||
}
|
||||
|
||||
var cuenta = bd.cuentas.FirstOrDefault(x => x.NumeroCuenta == Cta && x.idEjercicio == na.idEjercicio);
|
||||
if (cuenta == null)
|
||||
{
|
||||
var ctaant = bd.cuentas.Where(x => x.NumeroCuenta == Cta).OrderByDescending(x => x.idEjercicioNavigation.FechaInicio).FirstOrDefault();
|
||||
if (ctaant != null) cuenta = bdAsegasa.db.cuentas.CreaCuenta(bd, na.idEjercicio, Cta, ctaant.Denominacion, ctaant.Observaciones);
|
||||
}
|
||||
|
||||
if (cuenta == null) throw new Exception("No existe la cuenta " + Cta + " para el recibo " + Recibo.CodigoRecibo);
|
||||
nap1.idCuentaNavigation = cuenta;
|
||||
|
||||
if (Inverso)
|
||||
{
|
||||
nap1.Haber = (double)Recibo.TotalRecibo.Value;
|
||||
nap1.Debe = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nap1.Haber = 0;
|
||||
nap1.Debe = (double)Recibo.TotalRecibo.Value;
|
||||
}
|
||||
na.apuntes.Add(nap1);
|
||||
|
||||
var nap2 = new apuntes();
|
||||
nap2.idAsientoNavigation = na;
|
||||
string Cta2 = "4400" + Recibo.idPolizaNavigation.idCompaniaNavigation.Codigo;
|
||||
nap2.idCuenta = bd.cuentas.First(x => x.NumeroCuenta == Cta2 && x.idEjercicio == na.idEjercicio).idCuenta;
|
||||
|
||||
if (Inverso)
|
||||
{
|
||||
nap2.Haber = 0;
|
||||
nap2.Debe = Math.Round((double)Recibo.TotalRecibo.Value, 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
else
|
||||
{
|
||||
nap2.Debe = 0;
|
||||
nap2.Haber = Math.Round((double)Recibo.TotalRecibo.Value, 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
nap2.Concepto = ent.RazonSocial;
|
||||
nap2.idConcepto = Conceptos.First(x => x.Codigo == "005").idConcepto;
|
||||
nap2.NumeroDocumento = Recibo.idRecibo.ToString();
|
||||
na.apuntes.Add(nap2);
|
||||
|
||||
na.Importe = na.apuntes.Sum(x => x.Debe);
|
||||
Recibo.idRemesa = Remesa.idRemesa;
|
||||
Recibo.idSituacion = idSituacion;
|
||||
bd.SaveChanges();
|
||||
|
||||
// Logic for amortization
|
||||
if (Tipp == "PE" && nap1.idCuentaNavigation.idEmpresaAmortizacion.HasValue)
|
||||
{
|
||||
if (!Inverso)
|
||||
{
|
||||
var Amr = new amortizacionrecibos();
|
||||
int iUltimoMes = 0;
|
||||
var ud = bd.detallesamortizacionrecibos.Where(x => x.FechaAplicacion.HasValue).OrderByDescending(x => x.FechaAplicacion).FirstOrDefault();
|
||||
if (ud != null) iUltimoMes = ud.Mes;
|
||||
|
||||
int iMesPago = Recibo.FechaPago.Value.Year * 100 + Recibo.FechaPago.Value.Month;
|
||||
if (iUltimoMes >= iMesPago)
|
||||
{
|
||||
Amr.FechaInicioAmortizacion = new DateOnly(iUltimoMes / 100, iUltimoMes % 100, 1).AddMonths(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Amr.FechaInicioAmortizacion = Recibo.FechaPago.Value;
|
||||
}
|
||||
|
||||
Amr.idRecibo = Recibo.idRecibo;
|
||||
Amr.PorcentajeAnual = 100;
|
||||
Amr.idEmpresa = nap1.idCuentaNavigation.idEmpresaAmortizacion.Value;
|
||||
Amr.FechaFinAmortizacion = (new DateOnly(Amr.FechaInicioAmortizacion.Year, Amr.FechaInicioAmortizacion.Month, 1)).AddMonths(12);
|
||||
Amr.NumeroCuenta = nap1.idCuentaNavigation.NumeroCuenta;
|
||||
Amr.FechaAlta = DateOnly.FromDateTime(DateTime.Now);
|
||||
|
||||
DateTime FechaInicial = new DateTime(Amr.FechaInicioAmortizacion.Year, Amr.FechaInicioAmortizacion.Month, 1);
|
||||
for (int i = 0; i <= 11; i++)
|
||||
{
|
||||
var amrd = new detallesamortizacionrecibos();
|
||||
amrd.Mes = FechaInicial.AddMonths(i).Year * 100 + FechaInicial.AddMonths(i).Month;
|
||||
if (i < 11)
|
||||
{
|
||||
amrd.ValorAmortizado = Math.Round(Recibo.TotalRecibo.Value / 12, 2, MidpointRounding.AwayFromZero);
|
||||
amrd.ValorAcumulado = Math.Round(Recibo.TotalRecibo.Value / 12 * (i + 1), 2, MidpointRounding.AwayFromZero);
|
||||
amrd.ValorResidual = Math.Round(Recibo.TotalRecibo.Value - amrd.ValorAcumulado, 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
else
|
||||
{
|
||||
amrd.ValorAmortizado = Math.Round(Recibo.TotalRecibo.Value - Amr.detallesamortizacionrecibos.Sum(x => x.ValorAmortizado), 2, MidpointRounding.AwayFromZero);
|
||||
amrd.ValorAcumulado = Recibo.TotalRecibo.Value;
|
||||
amrd.ValorResidual = 0;
|
||||
}
|
||||
Amr.detallesamortizacionrecibos.Add(amrd);
|
||||
}
|
||||
bd.amortizacionrecibos.Add(Amr);
|
||||
}
|
||||
bd.SaveChanges();
|
||||
|
||||
var apas = new aplicacionesasientos();
|
||||
apas.idAplicacion = Recibo.idRecibo;
|
||||
apas.Tipo = Inverso ? (int)Enums.TipoAplicacionAsientoEnum.RECIBO_BAJA_TIPO_PAGO_PE : (int)Enums.TipoAplicacionAsientoEnum.RECIBO_CONTABILIZACION_PAGO_CONTADO;
|
||||
apas.idAsiento = na.idAsiento;
|
||||
bd.aplicacionesasientos.Add(apas);
|
||||
bd.SaveChanges();
|
||||
}
|
||||
|
||||
// Execute raw SQL if necessary for triggers or legacy compatibility
|
||||
// bd.Database.ExecuteSqlRaw("UPDATE registrosactualizados SET FechaCreacion=Now() where FechaCreacion Is null and NumeroGeneracion={0};", NumeroGeneracion);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static asientos GeneraAsientoReciboPagadoEnCiaYaFacturado(tscgestionasegasa bd, recibos Recibo, int idEjercicio)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ent = Recibo.idPolizaNavigation.EntidadPolizaTomador.idEntidadNavigation;
|
||||
var na = new asientos();
|
||||
bd.asientos.Add(na);
|
||||
|
||||
na.Fecha = DateOnly.FromDateTime(DateTime.Now);
|
||||
na.idEjercicio = idEjercicio;
|
||||
na.Tipo = (int)asientos.TipoAsiento.NORMAL;
|
||||
na.FechaIntroduccion = DateTime.Now;
|
||||
if (bdAsegasa.db.Utilidades.dsc.idUsuario > 0) na.idUsuario = bdAsegasa.db.Utilidades.dsc.idUsuario;
|
||||
|
||||
// Apunte 1: Desfacturacion Client (Haber)
|
||||
var nap1 = new apuntes();
|
||||
nap1.idAsientoNavigation = na;
|
||||
nap1.Concepto = "RECIBO PAGADO EN CIA (DESFACTURACION) " + ent.RazonSocial;
|
||||
nap1.NumeroDocumento = Recibo.idRecibo.ToString();
|
||||
string Cta1 = "4400" + Recibo.idPolizaNavigation.idCompaniaNavigation.Codigo;
|
||||
nap1.idCuentaNavigation = ObtieneCuenta(bd, Cta1, idEjercicio);
|
||||
nap1.Haber = Math.Round((double)Recibo.TotalRecibo.Value, 2, MidpointRounding.AwayFromZero);
|
||||
nap1.Debe = 0;
|
||||
na.apuntes.Add(nap1);
|
||||
|
||||
// Apunte 2: Desfacturacion Company (Debe - NET)
|
||||
var nap2 = new apuntes();
|
||||
nap2.idAsientoNavigation = na;
|
||||
string Cta2 = "4190" + Recibo.idPolizaNavigation.idCompaniaNavigation.Codigo;
|
||||
nap2.idCuentaNavigation = ObtieneCuenta(bd, Cta2, idEjercicio);
|
||||
nap2.Debe = Math.Round((double)(Recibo.TotalRecibo.Value - Recibo.TotalComision.Value), 2, MidpointRounding.AwayFromZero);
|
||||
nap2.Haber = 0;
|
||||
nap2.Concepto = "RECIBO PAGADO EN CIA (DESFACTURACION)" + ent.RazonSocial;
|
||||
nap2.NumeroDocumento = Recibo.idRecibo.ToString();
|
||||
na.apuntes.Add(nap2);
|
||||
|
||||
// Apunte 3: Desfacturacion Commission (Debe)
|
||||
var nap3 = new apuntes();
|
||||
nap3.idAsientoNavigation = na;
|
||||
string Cta3 = "7050" + Recibo.idPolizaNavigation.idCompaniaNavigation.Codigo;
|
||||
nap3.idCuentaNavigation = ObtieneCuenta(bd, Cta3, idEjercicio);
|
||||
nap3.Debe = Math.Round((double)Recibo.TotalComision.Value, 2, MidpointRounding.AwayFromZero);
|
||||
nap3.Haber = 0;
|
||||
nap3.Concepto = "RECIBO PAGADO EN CIA (DESFACTURACION)" + ent.RazonSocial;
|
||||
nap3.NumeroDocumento = Recibo.idRecibo.ToString();
|
||||
na.apuntes.Add(nap3);
|
||||
|
||||
// Apunte 4: Pago en CIA (Debe - COM)
|
||||
var nap4 = new apuntes();
|
||||
nap4.idAsientoNavigation = na;
|
||||
nap4.Concepto = "RECIBO PAGADO EN CIA " + ent.RazonSocial;
|
||||
nap4.NumeroDocumento = Recibo.idRecibo.ToString();
|
||||
nap4.idCuentaNavigation = ObtieneCuenta(bd, Cta2, idEjercicio);
|
||||
nap4.Haber = 0;
|
||||
nap4.Debe = Math.Round((double)Recibo.TotalComision.Value, 2, MidpointRounding.AwayFromZero);
|
||||
na.apuntes.Add(nap4);
|
||||
|
||||
// Apunte 5: Pago en CIA (Haber - COM)
|
||||
var nap5 = new apuntes();
|
||||
nap5.idAsientoNavigation = na;
|
||||
nap5.idCuentaNavigation = ObtieneCuenta(bd, Cta3, idEjercicio);
|
||||
nap5.Debe = 0;
|
||||
nap5.Haber = Math.Round((double)Recibo.TotalComision.Value, 2, MidpointRounding.AwayFromZero);
|
||||
nap5.Concepto = "RECIBO PAGADO EN CIA " + ent.RazonSocial;
|
||||
nap5.NumeroDocumento = Recibo.idRecibo.ToString();
|
||||
na.apuntes.Add(nap5);
|
||||
|
||||
na.Importe = na.apuntes.Sum(x => x.Debe);
|
||||
bd.SaveChanges();
|
||||
|
||||
var apas = new aplicacionesasientos();
|
||||
apas.idAplicacion = Recibo.idRecibo;
|
||||
apas.Tipo = (int)Enums.TipoAplicacionAsientoEnum.RECIBO_PAGADO_EN_CIA;
|
||||
apas.idAsiento = na.idAsiento;
|
||||
bd.aplicacionesasientos.Add(apas);
|
||||
bd.SaveChanges();
|
||||
|
||||
return na;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static asientos GeneraAsientoReciboPagadoEnCia(tscgestionasegasa bd, recibos Recibo)
|
||||
{
|
||||
try
|
||||
{
|
||||
var today = DateOnly.FromDateTime(DateTime.Now);
|
||||
|
||||
var ej = bd.ejercicioscontables.FirstOrDefault(x => x.FechaInicio <= today && x.FechaFin >= today && !x.FechaCierre.HasValue);
|
||||
if (ej == null) ej = bdAsegasa.db.ejercicioscontables.AbreEjercicio(bd, DateTime.Today);
|
||||
|
||||
var ent = Recibo.idPolizaNavigation.EntidadPolizaTomador.idEntidadNavigation;
|
||||
var na = new asientos();
|
||||
bd.asientos.Add(na);
|
||||
|
||||
na.Fecha = today;
|
||||
na.idEjercicio = ej.idEjercicio;
|
||||
na.Tipo = (int)asientos.TipoAsiento.NORMAL;
|
||||
na.FechaIntroduccion = DateTime.Now;
|
||||
if (bdAsegasa.db.Utilidades.dsc.idUsuario > 0) na.idUsuario = bdAsegasa.db.Utilidades.dsc.idUsuario;
|
||||
|
||||
var nap1 = new apuntes();
|
||||
nap1.idAsientoNavigation = na;
|
||||
nap1.Concepto = "RECIBO PAGADO EN CIA " + ent.RazonSocial;
|
||||
nap1.NumeroDocumento = Recibo.idRecibo.ToString();
|
||||
string Cta1 = "4190" + Recibo.idPolizaNavigation.idCompaniaNavigation.Codigo;
|
||||
nap1.idCuentaNavigation = ObtieneCuenta(bd, Cta1, ej.idEjercicio);
|
||||
nap1.Haber = 0;
|
||||
nap1.Debe = Math.Round((double)Recibo.TotalComision.Value, 2, MidpointRounding.AwayFromZero);
|
||||
na.apuntes.Add(nap1);
|
||||
|
||||
var nap2 = new apuntes();
|
||||
nap2.idAsientoNavigation = na;
|
||||
string Cta2 = "7050" + Recibo.idPolizaNavigation.idCompaniaNavigation.Codigo;
|
||||
nap2.idCuentaNavigation = ObtieneCuenta(bd, Cta2, ej.idEjercicio);
|
||||
nap2.Debe = 0;
|
||||
nap2.Haber = Math.Round((double)Recibo.TotalComision.Value, 2, MidpointRounding.AwayFromZero);
|
||||
nap2.Concepto = "RECIBO PAGADO EN CIA " + ent.RazonSocial;
|
||||
nap2.NumeroDocumento = Recibo.idRecibo.ToString();
|
||||
na.apuntes.Add(nap2);
|
||||
|
||||
na.Importe = Math.Round(na.apuntes.Sum(x => x.Debe), 2, MidpointRounding.AwayFromZero);
|
||||
bd.SaveChanges();
|
||||
|
||||
var apas = new aplicacionesasientos();
|
||||
apas.idAplicacion = Recibo.idRecibo;
|
||||
apas.Tipo = (int)Enums.TipoAplicacionAsientoEnum.RECIBO_PAGADO_EN_CIA;
|
||||
apas.idAsiento = na.idAsiento;
|
||||
bd.aplicacionesasientos.Add(apas);
|
||||
bd.SaveChanges();
|
||||
|
||||
return na;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void RefrescaExtensiones()
|
||||
{
|
||||
OnPropertyChanged("EjercicioTmp");
|
||||
OnPropertyChanged("idAsiento_Nulable");
|
||||
}
|
||||
|
||||
public static cuentas ObtieneCuenta(tscgestionasegasa 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 = bdAsegasa.db.cuentas.CreaCuenta(bd, idEjercicio, cta, ctaant.Denominacion, ctaant.Observaciones);
|
||||
}
|
||||
return cuenta;
|
||||
}
|
||||
|
||||
public bool Punteado
|
||||
{
|
||||
get => FechaPunteo.HasValue;
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
FechaPunteo = DateTime.Now;
|
||||
else
|
||||
FechaPunteo = null;
|
||||
}
|
||||
}
|
||||
|
||||
private string _Ejercicio;
|
||||
public string EjercicioTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(_Ejercicio) && this.idEjercicioNavigation!= null)
|
||||
{
|
||||
_Ejercicio = this.idEjercicioNavigation.Descripcion;
|
||||
}
|
||||
return _Ejercicio;
|
||||
}
|
||||
set
|
||||
{
|
||||
_Ejercicio = value;
|
||||
OnPropertyChanged("EjercicioTmp");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
bdAsegasa/Extensiones/cajas.cs
Normal file
11
bdAsegasa/Extensiones/cajas.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class cajas
|
||||
{
|
||||
public enum TipoCaja
|
||||
{
|
||||
METALICO = 0,
|
||||
BANCO = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
7
bdAsegasa/Extensiones/codigospostales.cs
Normal file
7
bdAsegasa/Extensiones/codigospostales.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class codigospostales
|
||||
{
|
||||
public string NombreMunicipio => !string.IsNullOrEmpty(DescripcionAdicional) ? $"{DescripcionAdicional} ({CodigoMunicipioNavigation?.Nombre})" : (CodigoMunicipioNavigation?.Nombre ?? "");
|
||||
}
|
||||
}
|
||||
7
bdAsegasa/Extensiones/comisionesagentes.cs
Normal file
7
bdAsegasa/Extensiones/comisionesagentes.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class comisionesagentes
|
||||
{
|
||||
public bool AEliminar { get; set; }
|
||||
}
|
||||
}
|
||||
119
bdAsegasa/Extensiones/companias.cs
Normal file
119
bdAsegasa/Extensiones/companias.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using bdAsegasa.dbcontext;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class companias
|
||||
{
|
||||
public direcciones Direccion => (this.idDireccion.HasValue && this.idDireccion.Value > 0) ? this.idDireccionNavigation : null;
|
||||
|
||||
private string _codigoPostalTmp;
|
||||
private bool _codigoPostalTmpEsNulo = true;
|
||||
public string CodigoPostalTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_codigoPostalTmpEsNulo)
|
||||
{
|
||||
_codigoPostalTmp = Direccion?.CodigoPostal ?? "";
|
||||
_codigoPostalTmpEsNulo = false;
|
||||
}
|
||||
return _codigoPostalTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_codigoPostalTmp = value;
|
||||
_codigoPostalTmpEsNulo = false;
|
||||
if (Direccion != null) Direccion.CodigoPostal = value;
|
||||
}
|
||||
}
|
||||
|
||||
private string _domicilioTmp;
|
||||
private bool _domicilioTmpEsNulo = true;
|
||||
public string DomicilioTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_domicilioTmpEsNulo)
|
||||
{
|
||||
_domicilioTmp = Direccion?.Direccion ?? "";
|
||||
_domicilioTmpEsNulo = false;
|
||||
}
|
||||
return _domicilioTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_domicilioTmp = value;
|
||||
_domicilioTmpEsNulo = false;
|
||||
if (Direccion != null) Direccion.Direccion = value;
|
||||
}
|
||||
}
|
||||
|
||||
private string _codigoPoblacionTmp;
|
||||
private bool _codigoPoblacionTmpEsNulo = true;
|
||||
public string CodigoPoblacionTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_codigoPoblacionTmpEsNulo)
|
||||
{
|
||||
if (Direccion == null || Direccion.CodigoMunicipioNavigation == null)
|
||||
{
|
||||
if (Direccion != null && !string.IsNullOrEmpty(Direccion.CodigoPostal))
|
||||
{
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var cp = bd.codigospostales.FirstOrDefault(x => x.CodigoPostal == Direccion.CodigoPostal);
|
||||
if (cp != null)
|
||||
{
|
||||
_codigoPoblacionTmp = cp.CodigoMunicipio;
|
||||
_codigoPoblacionTmpEsNulo = false;
|
||||
return _codigoPoblacionTmp;
|
||||
}
|
||||
return "CP.ERRONEO";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
_codigoPoblacionTmp = Direccion.CodigoMunicipio;
|
||||
_codigoPoblacionTmpEsNulo = false;
|
||||
}
|
||||
}
|
||||
return _codigoPoblacionTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_codigoPoblacionTmp = value;
|
||||
_codigoPoblacionTmpEsNulo = false;
|
||||
if (Direccion != null) Direccion.CodigoMunicipio = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string DescripcionFormaLiquidacion => ((FormaLiquidacionEnum)(this.FormaLiquidacion)).ToString();
|
||||
public string CodigoNombre => $"{this.Codigo} {this.Nombre}";
|
||||
|
||||
public enum FormaLiquidacionEnum
|
||||
{
|
||||
TRANSFERENCIA = 0,
|
||||
RECIBO = 1
|
||||
}
|
||||
|
||||
public static List<FormaLiquidacion> ListadoFormaLiquidacion()
|
||||
{
|
||||
return Enum.GetValues(typeof(FormaLiquidacionEnum))
|
||||
.Cast<FormaLiquidacionEnum>()
|
||||
.Select(e => new FormaLiquidacion { id = (int)e, Descripcion = e.ToString() })
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public class FormaLiquidacion
|
||||
{
|
||||
public int id { get; set; }
|
||||
public string Descripcion { get; set; }
|
||||
}
|
||||
}
|
||||
76
bdAsegasa/Extensiones/conciliacionesbancarias.cs
Normal file
76
bdAsegasa/Extensiones/conciliacionesbancarias.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class conciliacionesbancarias
|
||||
{
|
||||
public double ImporteExtractosConciliados => this.movimientosbancarios.Sum(x => (double)x.Importe);
|
||||
public double ImporteApuntesConciliados => this.apuntes.Sum(x => x.Debe - x.Haber);
|
||||
|
||||
private int? _Año;
|
||||
public int? Año
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Año.HasValue)
|
||||
{
|
||||
return _Año;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.FechaInicio == DateOnly.MinValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.FechaInicio.Year;
|
||||
}
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
_Año = value;
|
||||
if (value.HasValue && Mes.HasValue)
|
||||
{
|
||||
this.FechaInicio = new DateOnly(value.Value, Mes.Value, 1);
|
||||
this.FechaFin = new DateOnly(value.Value, Mes.Value, DateTime.DaysInMonth(value.Value, Mes.Value));
|
||||
}
|
||||
// OnPropertyChanged is handled by Fody/PropertyChanged in the partial class.
|
||||
}
|
||||
}
|
||||
|
||||
private int? _Mes;
|
||||
public int? Mes
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Mes.HasValue)
|
||||
{
|
||||
return _Mes;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.FechaInicio == DateOnly.MinValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.FechaInicio.Month;
|
||||
}
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
_Mes = value;
|
||||
if (value.HasValue && Año.HasValue)
|
||||
{
|
||||
this.FechaInicio = new DateOnly(Año.Value, value.Value, 1);
|
||||
this.FechaFin = new DateOnly(Año.Value, value.Value, DateTime.DaysInMonth(Año.Value, value.Value));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.VisualBasic;
|
||||
using Microsoft.VisualBasic;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
@@ -31,40 +31,57 @@ namespace bdAsegasa.db
|
||||
}
|
||||
}
|
||||
|
||||
public static void GeneraRegistroCorreon(tscgestionasegasa bd, string Asunto, string Cuerpo, bdAsegasa.db.cuentascorreo cuenta, string Destinatario, string ConCopia, string ConCopiaOculta, byte[] FicheroAdjunto = null, string NombreFicheroAdjunto = "", int? idAplicacion = default, string CodigoAplicacion = "", int? idEntidad = default)
|
||||
public static int GeneraRegistroCorreoConAdjunto(tscgestionasegasa bd, string Asunto, string Cuerpo, cuentascorreo cuenta, byte[] Fichero, string NombreFichero, string DescripcionFichero, string Destinatario, string Copia = "", string CopiaOculta = "", bool MarcarComoAnulado = false, string Remitente = "", int? idAplicacion = null, string CodigoAplicacion = "")
|
||||
{
|
||||
int resultado = 0;
|
||||
try
|
||||
{
|
||||
string sRutaAdjunto = "";
|
||||
var correo = new correos()
|
||||
if (bd == null) bd = tscgestionasegasa.NuevoContexto();
|
||||
int idTipoAdjunto = bd.enumeraciones.First(x => x.Codigo == "TIPFIC.ADJCOR").idEnumeracion;
|
||||
|
||||
var f = new ficheros
|
||||
{
|
||||
idTipo = idTipoAdjunto,
|
||||
Descripcion = DescripcionFichero,
|
||||
Fichero = Fichero,
|
||||
NombreFichero = NombreFichero,
|
||||
Fecha = DateTime.Now
|
||||
};
|
||||
bd.ficheros.Add(f);
|
||||
bd.SaveChanges();
|
||||
|
||||
var correo = new correos
|
||||
{
|
||||
Asunto = Asunto,
|
||||
Cuerpo = Cuerpo,
|
||||
Destinatario = Destinatario,
|
||||
Copia = ConCopia,
|
||||
CopiaOculta = ConCopiaOculta,
|
||||
DireccionRespuesta = cuenta.Remitente,
|
||||
Copia = Copia,
|
||||
CopiaOculta = CopiaOculta,
|
||||
DireccionRespuesta = cuenta.ResponderA,
|
||||
FechaCreacion = bd.AhoraMySql(),
|
||||
idcuenta = cuenta.idCuenta,
|
||||
Remitente = cuenta.Remitente,
|
||||
idFicheroAdjunto = f.idFichero,
|
||||
idAplicacion = idAplicacion,
|
||||
CodigoAplicacion = CodigoAplicacion,
|
||||
// idEntidad = idEntidad
|
||||
CodigoAplicacion = CodigoAplicacion
|
||||
};
|
||||
//if (bdAsegasa.db.Utilidades.idUsuario > 0)
|
||||
// correo.idUsuario = bdAsegasa.db.Utilidades.idUsuario;
|
||||
bd.correos.Add(correo);
|
||||
if (FicheroAdjunto is not null)
|
||||
|
||||
if (string.IsNullOrEmpty(Remitente))
|
||||
{
|
||||
var fi = new bdAsegasa.db.ficheros();
|
||||
fi.Descripcion = "Fichero Adjunto Correo";
|
||||
fi.NombreFichero = NombreFicheroAdjunto;
|
||||
fi.Fichero = FicheroAdjunto;
|
||||
fi.Fecha = DateTime.Now;
|
||||
fi.idTipo = bd.enumeraciones.First(x => x.Codigo == "TIPFIC.ADJCOR").idEnumeracion;
|
||||
correo.idFicheroAdjuntoNavigation = fi;
|
||||
correo.Remitente = cuenta.Remitente;
|
||||
}
|
||||
else
|
||||
{
|
||||
correo.Remitente = Remitente;
|
||||
}
|
||||
|
||||
if (MarcarComoAnulado)
|
||||
{
|
||||
correo.FechaAnulacion = DateTime.Now;
|
||||
}
|
||||
|
||||
bd.correos.Add(correo);
|
||||
bd.GuardarCambios();
|
||||
return correo.idcorreo;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -73,5 +90,96 @@ namespace bdAsegasa.db
|
||||
}
|
||||
}
|
||||
|
||||
public static int GeneraRegistroCorreo(tscgestionasegasa bd, string Asunto, string Cuerpo, bdAsegasa.db.cuentascorreo cuenta, string Destinatario, string Copia = "", string CopiaOculta = "", int? idfichero = null, bool MarcarComoAnulado = false, string Remitente = "", string ResponderA = "")
|
||||
{
|
||||
try
|
||||
{
|
||||
if (bd == null) bd = tscgestionasegasa.NuevoContexto();
|
||||
var correo = new correos
|
||||
{
|
||||
Asunto = Asunto,
|
||||
Cuerpo = Cuerpo,
|
||||
Destinatario = Destinatario,
|
||||
Copia = Copia,
|
||||
CopiaOculta = CopiaOculta,
|
||||
FechaCreacion = bd.AhoraMySql(),
|
||||
idcuenta = cuenta.idCuenta,
|
||||
idFicheroAdjunto = idfichero
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(ResponderA))
|
||||
{
|
||||
correo.DireccionRespuesta = ResponderA;
|
||||
}
|
||||
else
|
||||
{
|
||||
correo.DireccionRespuesta = cuenta.ResponderA;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(Remitente))
|
||||
{
|
||||
correo.Remitente = Remitente;
|
||||
}
|
||||
else
|
||||
{
|
||||
correo.Remitente = cuenta.Remitente;
|
||||
}
|
||||
if (MarcarComoAnulado) correo.FechaAnulacion = DateTime.Now;
|
||||
bd.correos.Add(correo);
|
||||
bd.GuardarCambios();
|
||||
return correo.idcorreo;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.Write(ex.Message);
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static int GeneraRegistroCorreoVariosFicheros(tscgestionasegasa bd, string Asunto, string Cuerpo, cuentascorreo cuenta, string Destinatario, System.Collections.Generic.List<int> idficheros = null, DateTime? FechaAnulacion = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var correo = new correos
|
||||
{
|
||||
Asunto = Asunto,
|
||||
Cuerpo = Cuerpo,
|
||||
Destinatario = Destinatario,
|
||||
DireccionRespuesta = cuenta.Remitente,
|
||||
FechaCreacion = bd.AhoraMySql(),
|
||||
idcuenta = cuenta.idCuenta,
|
||||
Remitente = cuenta.Remitente,
|
||||
FechaAnulacion = FechaAnulacion
|
||||
};
|
||||
if (idficheros != null)
|
||||
{
|
||||
foreach (var f in idficheros)
|
||||
{
|
||||
var nf = new ficherosadjuntos { idFichero = f };
|
||||
correo.ficherosadjuntos.Add(nf);
|
||||
}
|
||||
}
|
||||
bd.correos.Add(correo);
|
||||
bd.GuardarCambios();
|
||||
return correo.idcorreo;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Error en GeneraRegistroCorreoVariosFicheros. Asunto:" + Asunto + " " + ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public class CorreoReducido
|
||||
{
|
||||
public int idCorreo { get; set; }
|
||||
public string Destinatario { get; set; }
|
||||
public string Asunto { get; set; }
|
||||
public DateTime FechaCreacion { get; set; }
|
||||
public DateTime? FechaAnulacion { get; set; }
|
||||
public string MensajeError { get; set; }
|
||||
public string Aplicacion { get; set; }
|
||||
public string CodigoAplicacion { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
420
bdAsegasa/Extensiones/cuentas.cs
Normal file
420
bdAsegasa/Extensiones/cuentas.cs
Normal file
@@ -0,0 +1,420 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using tsUtilidades.Extensiones;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class cuentas
|
||||
{
|
||||
public static int LongitudCuentaFinal = 8;
|
||||
public const string CUENTA_PERDIDAS_Y_GANANCIAS = "12900000";
|
||||
|
||||
public virtual List<apuntes> ApuntesTemporales { get; set; }
|
||||
|
||||
public string Descripcion
|
||||
{
|
||||
get { return this.NumeroCuenta + " " + this.Denominacion; }
|
||||
}
|
||||
|
||||
public void RellenaApuntesTemporales(bool IncluirAsientoCierre)
|
||||
{
|
||||
if (this.Nivel == LongitudCuentaFinal)
|
||||
{
|
||||
var apap = this.apuntes.Where(x => x.idAsientoNavigation.Tipo == (int)asientos.TipoAsiento.APERTURA).ToList();
|
||||
if (apap.Count == 0)
|
||||
{
|
||||
this.SaldoInicialTmp = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.SaldoInicialTmp = Math.Round(apap.Sum(x => x.Debe - x.Haber), 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
|
||||
if (IncluirAsientoCierre)
|
||||
{
|
||||
ApuntesTemporales = this.apuntes.Where(x => x.idAsientoNavigation.Tipo != (int)asientos.TipoAsiento.APERTURA).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
ApuntesTemporales = this.apuntes.Where(x => x.idAsientoNavigation.Tipo != (int)asientos.TipoAsiento.APERTURA && x.idAsientoNavigation.Tipo != (int)asientos.TipoAsiento.REGULARIZACION).ToList();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
var apap = bd.apuntes.Where(x => x.idCuentaNavigation.NumeroCuenta.StartsWith(this.NumeroCuenta) && x.idAsientoNavigation.Tipo == (int)asientos.TipoAsiento.APERTURA).ToList();
|
||||
if (apap.Count == 0)
|
||||
{
|
||||
this.SaldoInicialTmp = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.SaldoInicialTmp = Math.Round(apap.Sum(x => x.Debe - x.Haber), 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
|
||||
if (IncluirAsientoCierre)
|
||||
{
|
||||
ApuntesTemporales = bd.apuntes.Where(x => x.idAsientoNavigation.idEjercicio == this.idEjercicio && x.idCuentaNavigation.NumeroCuenta.StartsWith(this.NumeroCuenta) && x.idAsientoNavigation.Tipo != (int)asientos.TipoAsiento.APERTURA).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
ApuntesTemporales = bd.apuntes.Where(x => x.idAsientoNavigation.idEjercicio == this.idEjercicio && x.idCuentaNavigation.NumeroCuenta.StartsWith(this.NumeroCuenta) && x.idAsientoNavigation.Tipo != (int)asientos.TipoAsiento.REGULARIZACION && x.idAsientoNavigation.Tipo != (int)asientos.TipoAsiento.APERTURA).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
if (ApuntesTemporales.Count == 0)
|
||||
{
|
||||
this.SaldoDebeTmp = 0;
|
||||
this.SaldoHaberTmp = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.SaldoDebeTmp = Math.Round(ApuntesTemporales.Sum(x => x.Debe), 2, MidpointRounding.AwayFromZero);
|
||||
this.SaldoHaberTmp = Math.Round(ApuntesTemporales.Sum(x => x.Haber), 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
this.SaldoFinalTmp = this.SaldoInicialTmp + this.SaldoDebeTmp - this.SaldoHaberTmp;
|
||||
}
|
||||
|
||||
public double SaldoInicialTmp { get; set; }
|
||||
public double SaldoDebeTmp { get; set; }
|
||||
public double SaldoHaberTmp { get; set; }
|
||||
public double SaldoFinalTmp { get; set; }
|
||||
|
||||
public static cuentas CreaCuenta(tscgestionasegasa bd, int idEjercicio, string NumeroCuenta, string Descripcion, string Observaciones = "")
|
||||
{
|
||||
var cta = bd.cuentas.FirstOrDefault(x => x.NumeroCuenta == NumeroCuenta && x.idEjercicio == idEjercicio);
|
||||
if (cta == null)
|
||||
{
|
||||
cta = new cuentas();
|
||||
cta.NumeroCuenta = NumeroCuenta;
|
||||
cta.idEjercicio = idEjercicio;
|
||||
cta.Denominacion = Descripcion.Acortar(150);
|
||||
cta.EsCuentaFinal = true;
|
||||
cta.Observaciones = Observaciones;
|
||||
bd.cuentas.Add(cta);
|
||||
bd.SaveChanges();
|
||||
}
|
||||
return cta;
|
||||
}
|
||||
|
||||
public static cuentas CreaCuenta(gestionasegasaEntities bd, DateOnly Fecha, string NumeroCuenta, string Descripcion, string Observaciones = "")
|
||||
{
|
||||
var ej = bd.ejercicioscontables.FirstOrDefault(x => x.FechaInicio <= Fecha && x.FechaFin >= Fecha);
|
||||
if (ej == null) throw new Exception("No existe ningún ejercicio abierto para la fecha " + Fecha.ToString());
|
||||
return CreaCuenta(bd, ej.idEjercicio, NumeroCuenta, Descripcion, Observaciones);
|
||||
}
|
||||
|
||||
public double TotalSaldoAntesCierre
|
||||
{
|
||||
get
|
||||
{
|
||||
var ac = this.idEjercicioNavigation.asientos.FirstOrDefault(x => x.Tipo == (int)asientos.TipoAsiento.REGULARIZACION);
|
||||
if (ac == null)
|
||||
{
|
||||
return TotalSaldo;
|
||||
}
|
||||
else
|
||||
{
|
||||
var tdac = ac.apuntes.Where(x => x.idCuentaNavigation.NumeroCuenta.StartsWith(this.NumeroCuenta)).Sum(x => x.Debe);
|
||||
var thac = ac.apuntes.Where(x => x.idCuentaNavigation.NumeroCuenta.StartsWith(this.NumeroCuenta)).Sum(x => x.Haber);
|
||||
return TotalSaldo - tdac + thac;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Grupo1
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.NumeroCuenta.Length > 1)
|
||||
{
|
||||
string nc = this.NumeroCuenta.Substring(0, 1);
|
||||
return nc + " - " + this.idEjercicioNavigation.cuentas.First(x => x.NumeroCuenta == nc).Denominacion;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public string Grupo2
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.NumeroCuenta.Length > 2)
|
||||
{
|
||||
string nc = this.NumeroCuenta.Substring(0, 2);
|
||||
return nc + " - " + this.idEjercicioNavigation.cuentas.First(x => x.NumeroCuenta == nc).Denominacion;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public string Grupo3
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.NumeroCuenta.Length > 3)
|
||||
{
|
||||
string nc = this.NumeroCuenta.Substring(0, 3);
|
||||
return nc + " - " + this.idEjercicioNavigation.cuentas.First(x => x.NumeroCuenta == nc).Denominacion;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public string Grupo4
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.NumeroCuenta.Length > 4)
|
||||
{
|
||||
string nc = this.NumeroCuenta.Substring(0, 4);
|
||||
return nc + " - " + this.idEjercicioNavigation.cuentas.First(x => x.NumeroCuenta == nc).Denominacion;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private gestionasegasaEntities _bd;
|
||||
public gestionasegasaEntities bd
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_bd == null) _bd = (gestionasegasaEntities?)tscgestionasegasa.NuevoContexto();
|
||||
return _bd;
|
||||
}
|
||||
}
|
||||
|
||||
public cuentas CuentaSuperior1
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.NumeroCuenta.Length == 1) return null;
|
||||
string superior = this.NumeroCuenta.Substring(0, 1);
|
||||
return bd.cuentas.First(x => x.NumeroCuenta == superior && x.idEjercicio == this.idEjercicio);
|
||||
}
|
||||
}
|
||||
|
||||
public cuentas CuentaSuperior2
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.NumeroCuenta.Length < 3) return null;
|
||||
string superior = this.NumeroCuenta.Substring(0, 2);
|
||||
return bd.cuentas.First(x => x.NumeroCuenta == superior && x.idEjercicio == this.idEjercicio);
|
||||
}
|
||||
}
|
||||
|
||||
public cuentas CuentaSuperior3
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.NumeroCuenta.Length < 4) return null;
|
||||
string superior = this.NumeroCuenta.Substring(0, 3);
|
||||
return bd.cuentas.First(x => x.NumeroCuenta == superior && x.idEjercicio == this.idEjercicio);
|
||||
}
|
||||
}
|
||||
|
||||
public cuentas CuentaSuperior4
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.NumeroCuenta.Length < 5) return null;
|
||||
string superior = this.NumeroCuenta.Substring(0, 4);
|
||||
return bd.cuentas.First(x => x.NumeroCuenta == superior && x.idEjercicio == this.idEjercicio);
|
||||
}
|
||||
}
|
||||
|
||||
public int Nivel
|
||||
{
|
||||
get { return this.NumeroCuenta.NothingAVacio().Length; }
|
||||
}
|
||||
|
||||
private vf_cuentas _ValoresExtendidos;
|
||||
public vf_cuentas ValoresExtendidos
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_ValoresExtendidos == null) _ValoresExtendidos = Obtiene_vf_cuenta();
|
||||
return _ValoresExtendidos;
|
||||
}
|
||||
}
|
||||
|
||||
public vf_cuentas Obtiene_vf_cuenta()
|
||||
{
|
||||
try
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
vf_cuentas ct;
|
||||
if (this.Nivel == 8)
|
||||
{
|
||||
ct = bd.vf_cuentas.First(x => x.idCuenta == this.idCuenta);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Nivel == 0)
|
||||
{
|
||||
ct = new vf_cuentas();
|
||||
// Initialize all zero
|
||||
}
|
||||
else
|
||||
{
|
||||
var sumatorio = bd.vf_cuentas.Where(x => x.NumeroCuenta.StartsWith(this.NumeroCuenta) && x.idEjercicio == this.idEjercicio).ToList();
|
||||
ct = new vf_cuentas();
|
||||
ct.idCuenta = this.idCuenta;
|
||||
ct.idEjercicio = this.idEjercicio;
|
||||
ct.Mote = this.Mote;
|
||||
ct.Denominacion = this.Denominacion;
|
||||
ct.idEmpresaAmortizacion = this.idEmpresaAmortizacion;
|
||||
ct.NumeroCuenta = this.NumeroCuenta;
|
||||
ct.Observaciones = this.Observaciones;
|
||||
|
||||
ct.PresupuestoEnero = Math.Round(sumatorio.Sum(x => x.PresupuestoEnero), 2, MidpointRounding.AwayFromZero);
|
||||
ct.PresupuestoFebrero = Math.Round(sumatorio.Sum(x => x.PresupuestoFebrero), 2, MidpointRounding.AwayFromZero);
|
||||
ct.PresupuestoMarzo = Math.Round(sumatorio.Sum(x => x.PresupuestoMarzo), 2, MidpointRounding.AwayFromZero);
|
||||
ct.PresupuestoAbril = Math.Round(sumatorio.Sum(x => x.PresupuestoAbril), 2, MidpointRounding.AwayFromZero);
|
||||
ct.PresupuestoMayo = Math.Round(sumatorio.Sum(x => x.PresupuestoMayo), 2, MidpointRounding.AwayFromZero);
|
||||
ct.PresupuestoJunio = Math.Round(sumatorio.Sum(x => x.PresupuestoJunio), 2, MidpointRounding.AwayFromZero);
|
||||
ct.PresupuestoJulio = Math.Round(sumatorio.Sum(x => x.PresupuestoJulio), 2, MidpointRounding.AwayFromZero);
|
||||
ct.PresupuestoAgosto = Math.Round(sumatorio.Sum(x => x.PresupuestoAgosto), 2, MidpointRounding.AwayFromZero);
|
||||
ct.PresupuestoSeptiembre = Math.Round(sumatorio.Sum(x => x.PresupuestoSeptiembre), 2, MidpointRounding.AwayFromZero);
|
||||
ct.PresupuestoOctubre = Math.Round(sumatorio.Sum(x => x.PresupuestoOctubre), 2, MidpointRounding.AwayFromZero);
|
||||
ct.PresupuestoNoviembre = Math.Round(sumatorio.Sum(x => x.PresupuestoNoviembre), 2, MidpointRounding.AwayFromZero);
|
||||
ct.PresupuestoDiciembre = Math.Round(sumatorio.Sum(x => x.PresupuestoDiciembre), 2, MidpointRounding.AwayFromZero);
|
||||
|
||||
ct.DebeEnero = Math.Round(sumatorio.Sum(x => x.DebeEnero.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.DebeFebrero = Math.Round(sumatorio.Sum(x => x.DebeFebrero.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.DebeMarzo = Math.Round(sumatorio.Sum(x => x.DebeMarzo.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.DebeAbril = Math.Round(sumatorio.Sum(x => x.DebeAbril.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.DebeMayo = Math.Round(sumatorio.Sum(x => x.DebeMayo.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.DebeJunio = Math.Round(sumatorio.Sum(x => x.DebeJunio.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.DebeJulio = Math.Round(sumatorio.Sum(x => x.DebeJulio.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.DebeAgosto = Math.Round(sumatorio.Sum(x => x.DebeAgosto.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.DebeSeptiembre = Math.Round(sumatorio.Sum(x => x.DebeSeptiembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.DebeOctubre = Math.Round(sumatorio.Sum(x => x.DebeOctubre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.DebeNoviembre = Math.Round(sumatorio.Sum(x => x.DebeNoviembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.DebeDiciembre = Math.Round(sumatorio.Sum(x => x.DebeDiciembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
|
||||
ct.HaberEnero = Math.Round(sumatorio.Sum(x => x.HaberEnero.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.HaberFebrero = Math.Round(sumatorio.Sum(x => x.HaberFebrero.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.HaberMarzo = Math.Round(sumatorio.Sum(x => x.HaberMarzo.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.HaberAbril = Math.Round(sumatorio.Sum(x => x.HaberAbril.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.HaberMayo = Math.Round(sumatorio.Sum(x => x.HaberMayo.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.HaberJunio = Math.Round(sumatorio.Sum(x => x.HaberJunio.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.HaberJulio = Math.Round(sumatorio.Sum(x => x.HaberJulio.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.HaberAgosto = Math.Round(sumatorio.Sum(x => x.HaberAgosto.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.HaberSeptiembre = Math.Round(sumatorio.Sum(x => x.HaberSeptiembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.HaberOctubre = Math.Round(sumatorio.Sum(x => x.HaberOctubre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.HaberNoviembre = Math.Round(sumatorio.Sum(x => x.HaberNoviembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.HaberDiciembre = Math.Round(sumatorio.Sum(x => x.HaberDiciembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
|
||||
ct.TotalDebe = Math.Round(sumatorio.Sum(x => x.TotalDebe), 2, MidpointRounding.AwayFromZero);
|
||||
ct.TotalHaber = Math.Round(sumatorio.Sum(x => x.TotalHaber), 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
|
||||
if (Nivel > 0)
|
||||
{
|
||||
var cta1 = bd.cuentas.First(x => x.NumeroCuenta == ct.NumeroCuenta.Substring(0, 1) && x.idEjercicio == this.idEjercicio);
|
||||
ct.Grupo1 = cta1.NumeroCuenta + " " + cta1.Denominacion;
|
||||
if (ct.Nivel > 1)
|
||||
{
|
||||
var cta2 = bd.cuentas.First(x => x.NumeroCuenta == ct.NumeroCuenta.Substring(0, 2) && x.idEjercicio == this.idEjercicio);
|
||||
ct.Grupo2 = cta2.NumeroCuenta + " " + cta2.Denominacion;
|
||||
if (ct.Nivel > 2)
|
||||
{
|
||||
var cta3 = bd.cuentas.First(x => x.NumeroCuenta == ct.NumeroCuenta.Substring(0, 3) && x.idEjercicio == this.idEjercicio);
|
||||
ct.Grupo3 = cta3.NumeroCuenta + " " + cta3.Denominacion;
|
||||
if (ct.Nivel > 3)
|
||||
{
|
||||
var cta4 = bd.cuentas.First(x => x.NumeroCuenta == ct.NumeroCuenta.Substring(0, 4) && x.idEjercicio == this.idEjercicio);
|
||||
ct.Grupo4 = cta4.NumeroCuenta + " " + cta4.Denominacion;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ct;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
#region Saldos
|
||||
public double SaldoEnero => ValoresExtendidos.SaldoEnero;
|
||||
public double SaldoFebrero => ValoresExtendidos.SaldoFebrero;
|
||||
public double SaldoMarzo => ValoresExtendidos.SaldoMarzo;
|
||||
public double SaldoAbril => ValoresExtendidos.SaldoAbril;
|
||||
public double SaldoMayo => ValoresExtendidos.SaldoMayo;
|
||||
public double SaldoJunio => ValoresExtendidos.SaldoJunio;
|
||||
public double SaldoJulio => ValoresExtendidos.SaldoJulio;
|
||||
public double SaldoAgosto => ValoresExtendidos.SaldoAgosto;
|
||||
public double SaldoSeptiembre => ValoresExtendidos.SaldoSeptiembre;
|
||||
public double SaldoOctubre => ValoresExtendidos.SaldoOctubre;
|
||||
public double SaldoNoviembre => ValoresExtendidos.SaldoNoviembre;
|
||||
public double SaldoDiciembre => ValoresExtendidos.SaldoDiciembre;
|
||||
public double TotalSaldo => ValoresExtendidos.TotalSaldo;
|
||||
#endregion
|
||||
|
||||
#region Presupuestos
|
||||
public double TotalPresupuestado
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Round(PresupuestoEnero + PresupuestoFebrero + PresupuestoMarzo + PresupuestoAbril + PresupuestoMayo + PresupuestoJunio + PresupuestoJulio + PresupuestoAgosto + PresupuestoSeptiembre + PresupuestoOctubre + PresupuestoNoviembre + PresupuestoDiciembre, 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
public void ActualizaTotalPresupuestado() => OnPropertyChanged("TotalPresupuestado");
|
||||
|
||||
public double DesvioPresupuestoEnero => ValoresExtendidos.DesvioPresupuestoEnero;
|
||||
public double DesvioPresupuestoFebrero => ValoresExtendidos.DesvioPresupuestoFebrero;
|
||||
public double DesvioPresupuestoMarzo => ValoresExtendidos.DesvioPresupuestoMarzo;
|
||||
public double DesvioPresupuestoAbril => ValoresExtendidos.DesvioPresupuestoAbril;
|
||||
public double DesvioPresupuestoMayo => ValoresExtendidos.DesvioPresupuestoMayo;
|
||||
public double DesvioPresupuestoJunio => ValoresExtendidos.DesvioPresupuestoJunio;
|
||||
public double DesvioPresupuestoJulio => ValoresExtendidos.DesvioPresupuestoJulio;
|
||||
public double DesvioPresupuestoAgosto => ValoresExtendidos.DesvioPresupuestoAgosto;
|
||||
public double DesvioPresupuestoSeptiembre => ValoresExtendidos.DesvioPresupuestoSeptiembre;
|
||||
public double DesvioPresupuestoOctubre => ValoresExtendidos.DesvioPresupuestoOctubre;
|
||||
public double DesvioPresupuestoNoviembre => ValoresExtendidos.DesvioPresupuestoNoviembre;
|
||||
public double DesvioPresupuestoDiciembre => ValoresExtendidos.DesvioPresupuestoDiciembre;
|
||||
public double DesvioPresupuestoTotal => ValoresExtendidos.DesvioPresupuestoTotal;
|
||||
|
||||
public double PorcentajeDesvioPresupuestoEnero => ValoresExtendidos.PorcentajeDesvioPresupuestoEnero;
|
||||
public double PorcentajeDesvioPresupuestoFebrero => ValoresExtendidos.PorcentajeDesvioPresupuestoFebrero;
|
||||
public double PorcentajeDesvioPresupuestoMarzo => ValoresExtendidos.PorcentajeDesvioPresupuestoMarzo;
|
||||
public double PorcentajeDesvioPresupuestoAbril => ValoresExtendidos.PorcentajeDesvioPresupuestoAbril;
|
||||
public double PorcentajeDesvioPresupuestoMayo => ValoresExtendidos.PorcentajeDesvioPresupuestoMayo;
|
||||
public double PorcentajeDesvioPresupuestoJunio => ValoresExtendidos.PorcentajeDesvioPresupuestoJunio;
|
||||
public double PorcentajeDesvioPresupuestoJulio => ValoresExtendidos.PorcentajeDesvioPresupuestoJulio;
|
||||
public double PorcentajeDesvioPresupuestoAgosto => ValoresExtendidos.PorcentajeDesvioPresupuestoAgosto;
|
||||
public double PorcentajeDesvioPresupuestoSeptiembre => ValoresExtendidos.PorcentajeDesvioPresupuestoSeptiembre;
|
||||
public double PorcentajeDesvioPresupuestoOctubre => ValoresExtendidos.PorcentajeDesvioPresupuestoOctubre;
|
||||
public double PorcentajeDesvioPresupuestoNoviembre => ValoresExtendidos.PorcentajeDesvioPresupuestoNoviembre;
|
||||
public double PorcentajeDesvioPresupuestoDiciembre => ValoresExtendidos.PorcentajeDesvioPresupuestoDiciembre;
|
||||
public double PorcentajeDesvioPresupuestoTotal => ValoresExtendidos.PorcentajeDesvioPresupuestoTotal;
|
||||
#endregion
|
||||
|
||||
public static List<GrupoCuenta> ListadoGruposCuentas()
|
||||
{
|
||||
return new List<GrupoCuenta>
|
||||
{
|
||||
new GrupoCuenta { Nivel = 1, Descripcion = "GRUPO INICIAL 1 DÍGITO" },
|
||||
new GrupoCuenta { Nivel = 2, Descripcion = "GRUPO INTERMEDIO 2 DÍGITOS" },
|
||||
new GrupoCuenta { Nivel = 3, Descripcion = "GRUPO INTERMEDIO 3 DÍGITOS" },
|
||||
new GrupoCuenta { Nivel = 4, Descripcion = "GRUPO INTERMEDIO 4 DÍGITOS" },
|
||||
new GrupoCuenta { Nivel = 8, Descripcion = "GRUPO FINAL 8 DÍGITOS" }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class GrupoCuenta
|
||||
{
|
||||
public int Nivel { get; set; }
|
||||
public string Descripcion { get; set; }
|
||||
}
|
||||
}
|
||||
54
bdAsegasa/Extensiones/detallesamortizacionrecibos.cs
Normal file
54
bdAsegasa/Extensiones/detallesamortizacionrecibos.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class detallesamortizacionrecibos
|
||||
{
|
||||
public string MesFecha
|
||||
{
|
||||
get
|
||||
{
|
||||
string mesStr = this.Mes.ToString();
|
||||
return mesStr.Substring(0, 4) + "/" + mesStr.Substring(4, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ve_detallesamortizacionrecibos
|
||||
{
|
||||
public int idDetalle { get; set; }
|
||||
public int idAmortizacion { get; set; }
|
||||
public int? idRecibo { get; set; }
|
||||
public DateOnly FechaInicioAmortizacion { get; set; }
|
||||
public DateOnly FechaFinAmortizacion { get; set; }
|
||||
public double PorcentajeAnual { get; set; }
|
||||
public DateOnly? FechaBaja { get; set; }
|
||||
public int? idMotivoBaja { get; set; }
|
||||
public int idEmpresa { get; set; }
|
||||
public string NumeroCuenta { get; set; }
|
||||
public string Observaciones { get; set; }
|
||||
public DateOnly? FechaAlta { get; set; }
|
||||
public string CodigoRecibo { get; set; }
|
||||
public DateOnly FechaEfecto { get; set; }
|
||||
public double TotalRecibo { get; set; }
|
||||
public string Ramo { get; set; }
|
||||
public string Compañía { get; set; }
|
||||
public string Tomador { get; set; }
|
||||
public string CIFTomador { get; set; }
|
||||
public string CausaBaja { get; set; }
|
||||
public string Empresa { get; set; }
|
||||
public double ValorAmortizado { get; set; }
|
||||
public double ValorAcumulado { get; set; }
|
||||
public double ValorResidual { get; set; }
|
||||
public int Mes { get; set; }
|
||||
public DateTime? FechaAplicacion { get; set; }
|
||||
public string MesFecha
|
||||
{
|
||||
get
|
||||
{
|
||||
string mesStr = this.Mes.ToString();
|
||||
return mesStr.Substring(0, 4) + "/" + mesStr.Substring(4, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
10
bdAsegasa/Extensiones/direcciones.cs
Normal file
10
bdAsegasa/Extensiones/direcciones.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class direcciones
|
||||
{
|
||||
// Note: municipios.ObtienePoblacion and ObtieneProvincia should be implemented in municipios extension.
|
||||
// For now, assuming they are available or using the navigation.
|
||||
public string PoblacionTmp => CodigoMunicipioNavigation?.Nombre ?? "";
|
||||
public string ProvinciaTmp => CodigoMunicipioNavigation?.CodigoProvinciaNavigation?.Nombre ?? "";
|
||||
}
|
||||
}
|
||||
7
bdAsegasa/Extensiones/documentosasolicitar.cs
Normal file
7
bdAsegasa/Extensiones/documentosasolicitar.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class documentosasolicitar
|
||||
{
|
||||
public bool ElementoComprobado { get; set; }
|
||||
}
|
||||
}
|
||||
71
bdAsegasa/Extensiones/documentospolizassg.cs
Normal file
71
bdAsegasa/Extensiones/documentospolizassg.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using bdAsegasa.dbcontext;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class documentospolizassg
|
||||
{
|
||||
public bool DocumentoComprobado
|
||||
{
|
||||
get => this.FechaComprobacion.HasValue;
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
this.FechaComprobacion = DateTime.Now;
|
||||
this.idUsuarioComprueba = Utilidades.dsc.idUsuario;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.FechaComprobacion = null;
|
||||
this.idUsuarioComprueba = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void GeneraDocumentosASolicitar(tscgestionasegasa bd, polizassg poliza, List<int> idDocsASolicitar = null)
|
||||
{
|
||||
List<documentosasolicitar> das;
|
||||
if (idDocsASolicitar != null)
|
||||
{
|
||||
das = bd.documentosasolicitar.Where(x => idDocsASolicitar.Contains(x.idDocumento)).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
das = bd.documentosasolicitar.Where(x => x.idRamo == poliza.idRamo).ToList();
|
||||
}
|
||||
|
||||
var enumDomiciliacion = bd.enumeraciones.FirstOrDefault(x => x.Codigo == "TIPP.BA");
|
||||
int idDomiciliacion = enumDomiciliacion?.idEnumeracion ?? -1;
|
||||
|
||||
foreach (var d in das)
|
||||
{
|
||||
var dp = new documentospolizassg();
|
||||
poliza.documentospolizassg.Add(dp);
|
||||
dp.Descripcion = d.idRamoNavigation?.Descripcion;
|
||||
dp.idDocumentoASolicitar = d.idDocumento;
|
||||
dp.Obligatorio = d.Obligatorio;
|
||||
dp.Fecha = DateTime.Now;
|
||||
|
||||
if (d.idRamoNavigation?.Codigo == "DOCRAM.MDTO" && poliza.idTipoPago != idDomiciliacion)
|
||||
{
|
||||
dp.Obligatorio = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string DescripcionTipo => ((TipoDocumentoEnum)(this.Tipo)).ToString().Replace("_", " ");
|
||||
|
||||
public enum TipoDocumentoEnum : int
|
||||
{
|
||||
DESCONOCIDO = 0,
|
||||
PÓLIZA = 1,
|
||||
CARTA_SUPLEMENTO = 2,
|
||||
CERTIFICADO_SEGURO = 3,
|
||||
RECIBO = 10,
|
||||
OTROS = 100
|
||||
}
|
||||
}
|
||||
}
|
||||
115
bdAsegasa/Extensiones/ejercicioscontables.cs
Normal file
115
bdAsegasa/Extensiones/ejercicioscontables.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using bdAsegasa.dbcontext;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class ejercicioscontables
|
||||
{
|
||||
public static int ObtieneidEjercicioAbierto(DateTime fecha)
|
||||
{
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var ej = bd.ejercicioscontables.FirstOrDefault(x => x.FechaInicio <= DateOnly.FromDateTime(fecha) && x.FechaFin >= DateOnly.FromDateTime(fecha) && x.FechaCierre == null);
|
||||
if (ej == null)
|
||||
{
|
||||
ej = bd.ejercicioscontables.FirstOrDefault(x => x.FechaInicio <= DateOnly.FromDateTime(fecha) && x.FechaFin >= DateOnly.FromDateTime(fecha) && x.FechaCierre != null);
|
||||
if (ej == null)
|
||||
{
|
||||
if (Math.Abs((DateTime.Today - fecha).TotalDays) > 365)
|
||||
{
|
||||
throw new Exception("La fecha del ejercicio " + fecha.ToShortDateString() + " parece incorrecta");
|
||||
}
|
||||
else
|
||||
{
|
||||
return AbreEjercicio(bd, fecha).idEjercicio;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("El ejercicio está cerrado");
|
||||
}
|
||||
}
|
||||
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}";
|
||||
}
|
||||
return $"{this.idEmpresaNavigation?.RazonSocial} {this.FechaInicio} {this.FechaFin}";
|
||||
}
|
||||
}
|
||||
|
||||
public void CopiaCuentas(tscgestionasegasa bd)
|
||||
{
|
||||
var ea = bd.ejercicioscontables
|
||||
.Where(x => x.FechaInicio < this.FechaInicio)
|
||||
.OrderByDescending(x => x.FechaInicio)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (ea != null)
|
||||
{
|
||||
var ctas = bd.cuentas.Where(x => x.idEjercicio == ea.idEjercicio).ToList();
|
||||
foreach (var cta in ctas.OrderBy(x => x.NumeroCuenta.Length))
|
||||
{
|
||||
if (!bd.cuentas.Any(x => x.idEjercicio == this.idEjercicio && x.NumeroCuenta == cta.NumeroCuenta))
|
||||
{
|
||||
var nc = new cuentas
|
||||
{
|
||||
Denominacion = cta.Denominacion,
|
||||
EsCuentaFinal = cta.EsCuentaFinal,
|
||||
Mote = cta.Mote,
|
||||
Observaciones = cta.Observaciones,
|
||||
NumeroCuenta = cta.NumeroCuenta,
|
||||
idEjercicio = this.idEjercicio,
|
||||
idEmpresaAmortizacion = cta.idEmpresaAmortizacion,
|
||||
PresupuestoEnero = cta.PresupuestoEnero,
|
||||
PresupuestoFebrero = cta.PresupuestoFebrero,
|
||||
PresupuestoMarzo = cta.PresupuestoMarzo,
|
||||
PresupuestoAbril = cta.PresupuestoAbril,
|
||||
PresupuestoMayo = cta.PresupuestoMayo,
|
||||
PresupuestoJunio = cta.PresupuestoJunio,
|
||||
PresupuestoJulio = cta.PresupuestoJulio,
|
||||
PresupuestoAgosto = cta.PresupuestoAgosto,
|
||||
PresupuestoSeptiembre = cta.PresupuestoSeptiembre,
|
||||
PresupuestoOctubre = cta.PresupuestoOctubre,
|
||||
PresupuestoNoviembre = cta.PresupuestoNoviembre,
|
||||
PresupuestoDiciembre = cta.PresupuestoDiciembre
|
||||
};
|
||||
bd.cuentas.Add(nc);
|
||||
}
|
||||
}
|
||||
bd.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static ejercicioscontables AbreEjercicio(tscgestionasegasa bd, DateTime fecha)
|
||||
{
|
||||
var ej = new ejercicioscontables
|
||||
{
|
||||
FechaApertura = DateOnly.FromDateTime(DateTime.Now),
|
||||
FechaInicio = new DateOnly(fecha.Year, 1, 1),
|
||||
FechaFin = new DateOnly(fecha.Year, 12, 31),
|
||||
Descripcion = fecha.Year.ToString()
|
||||
};
|
||||
bd.ejercicioscontables.Add(ej);
|
||||
bd.SaveChanges();
|
||||
ej.CopiaCuentas(bd);
|
||||
return ej;
|
||||
}
|
||||
|
||||
public static bool CompruebaEjereciciosAbiertos(tscgestionasegasa bd, List<DateTime> fechas)
|
||||
{
|
||||
var ejeabiertos = bd.ejercicioscontables.Where(x => x.FechaCierre == null).ToList();
|
||||
return fechas.All(f => ejeabiertos.Any(e => e.FechaInicio <= DateOnly.FromDateTime(f) && e.FechaFin >= DateOnly.FromDateTime(f)));
|
||||
}
|
||||
}
|
||||
}
|
||||
331
bdAsegasa/Extensiones/entidades.cs
Normal file
331
bdAsegasa/Extensiones/entidades.cs
Normal file
@@ -0,0 +1,331 @@
|
||||
using bdAsegasa.dbcontext;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class entidades : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected virtual void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
|
||||
public bool UltimoReciboDevueltoFaltaPago(string codigoRamo)
|
||||
{
|
||||
if (this.idEntidad == 0) return false;
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var ramo = bd.ramos.FirstOrDefault(x => x.Codigo == codigoRamo);
|
||||
if (ramo == null) return false;
|
||||
|
||||
var idfp = bd.enumeraciones.FirstOrDefault(x => x.Codigo == "CABA.FP")?.idEnumeracion;
|
||||
if (!idfp.HasValue) return false;
|
||||
|
||||
var rec = bd.entidadespolizas
|
||||
.Where(x => x.idEntidad == this.idEntidad)
|
||||
.Select(x => x.idPolizaNavigation)
|
||||
.Where(x => x.idRamo == ramo.idRamo)
|
||||
.SelectMany(x => x.recibos)
|
||||
.OrderByDescending(x => x.FechaEfecto)
|
||||
.FirstOrDefault();
|
||||
|
||||
return rec?.idCausaBaja == idfp;
|
||||
}
|
||||
}
|
||||
|
||||
public string Sexo => this.idSexoNavigation?.Descripcion ?? "* Desconocido *";
|
||||
|
||||
public direcciones DireccionPrincipal
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idDireccionPrincipal.HasValue && this.idDireccionPrincipal.Value > 0)
|
||||
{
|
||||
return this.direcciones.FirstOrDefault(x => x.idDireccion == this.idDireccionPrincipal.Value);
|
||||
}
|
||||
var correo = this.direcciones.FirstOrDefault(x => x.idTipoNavigation?.Codigo == "TIPDIR.CORREO");
|
||||
return correo ?? this.direcciones.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
private string _codigoPostalTmp;
|
||||
private bool _codigoPostalTmpEsNulo = true;
|
||||
public string CodigoPostalTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_codigoPostalTmpEsNulo)
|
||||
{
|
||||
_codigoPostalTmp = DireccionPrincipal?.CodigoPostal ?? "";
|
||||
_codigoPostalTmpEsNulo = false;
|
||||
}
|
||||
return _codigoPostalTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_codigoPostalTmp = value;
|
||||
_codigoPostalTmpEsNulo = false;
|
||||
if (DireccionPrincipal != null) DireccionPrincipal.CodigoPostal = value;
|
||||
OnPropertyChanged(nameof(CodigoPostalTmp));
|
||||
}
|
||||
}
|
||||
|
||||
private string _domicilioTmp;
|
||||
private bool _domicilioTmpEsNulo = true;
|
||||
public string DomicilioTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_domicilioTmpEsNulo)
|
||||
{
|
||||
_domicilioTmp = DireccionPrincipal?.Direccion ?? "";
|
||||
_domicilioTmpEsNulo = false;
|
||||
}
|
||||
return _domicilioTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_domicilioTmp = value;
|
||||
_domicilioTmpEsNulo = false;
|
||||
if (DireccionPrincipal != null) DireccionPrincipal.Direccion = value;
|
||||
OnPropertyChanged(nameof(DomicilioTmp));
|
||||
}
|
||||
}
|
||||
|
||||
private string _codigoPoblacionTmp;
|
||||
private bool _codigoPoblacionTmpEsNulo = true;
|
||||
public string CodigoPoblacionTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_codigoPoblacionTmpEsNulo)
|
||||
{
|
||||
if (DireccionPrincipal == null || DireccionPrincipal.CodigoMunicipioNavigation == null)
|
||||
{
|
||||
if (DireccionPrincipal != null && DireccionPrincipal.CodigoMunicipioNavigation == null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(DireccionPrincipal.CodigoPostal))
|
||||
{
|
||||
using var bd = bdAsegasa.tscgestionasegasa.NuevoContexto();
|
||||
var pob = bd.codigospostales.FirstOrDefault(x => x.CodigoPostal == DireccionPrincipal.CodigoPostal);
|
||||
if (pob == null)
|
||||
{
|
||||
return "CP.ERRONEO";
|
||||
}
|
||||
else
|
||||
{
|
||||
DireccionPrincipal.CodigoMunicipio = pob.CodigoMunicipio;
|
||||
_codigoPoblacionTmp = pob.CodigoMunicipio;
|
||||
_codigoPoblacionTmpEsNulo = false;
|
||||
return _codigoPoblacionTmp;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_codigoPoblacionTmp = DireccionPrincipal.CodigoMunicipio;
|
||||
_codigoPoblacionTmpEsNulo = false;
|
||||
return DireccionPrincipal.CodigoMunicipio;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return _codigoPoblacionTmp;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
_codigoPoblacionTmp = value;
|
||||
_codigoPoblacionTmpEsNulo = false;
|
||||
if (DireccionPrincipal != null) DireccionPrincipal.CodigoMunicipio = value;
|
||||
OnPropertyChanged(nameof(CodigoPoblacionTmp));
|
||||
|
||||
using var bd = bdAsegasa.tscgestionasegasa.NuevoContexto();
|
||||
var mun = bd.municipios.FirstOrDefault(x => x.CodigoMunicipio == _codigoPoblacionTmp);
|
||||
ProvinciaTmp = mun?.CodigoProvinciaNavigation?.Nombre ?? "";
|
||||
PoblacionTmp = mun?.Nombre ?? "";
|
||||
}
|
||||
}
|
||||
|
||||
private string _poblacionTmp;
|
||||
private bool _poblacionTmpEsNulo = true;
|
||||
public string PoblacionTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_poblacionTmpEsNulo)
|
||||
{
|
||||
using var bd = bdAsegasa.tscgestionasegasa.NuevoContexto();
|
||||
var mun = bd.municipios.FirstOrDefault(x => x.CodigoMunicipio == CodigoPoblacionTmp);
|
||||
_poblacionTmp = mun?.Nombre ?? "";
|
||||
_poblacionTmpEsNulo = false;
|
||||
}
|
||||
return _poblacionTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_poblacionTmp = value;
|
||||
_poblacionTmpEsNulo = false;
|
||||
OnPropertyChanged(nameof(PoblacionTmp));
|
||||
}
|
||||
}
|
||||
|
||||
private string _provinciaTmp;
|
||||
private bool _provinciaTmpEsNulo = true;
|
||||
public string ProvinciaTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_provinciaTmpEsNulo)
|
||||
{
|
||||
using var bd = bdAsegasa.tscgestionasegasa.NuevoContexto();
|
||||
var mun = bd.municipios.FirstOrDefault(x => x.CodigoMunicipio == CodigoPoblacionTmp);
|
||||
_provinciaTmp = mun?.CodigoProvinciaNavigation?.Nombre ?? "";
|
||||
_provinciaTmpEsNulo = false;
|
||||
}
|
||||
return _provinciaTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_provinciaTmp = value;
|
||||
_provinciaTmpEsNulo = false;
|
||||
OnPropertyChanged(nameof(ProvinciaTmp));
|
||||
}
|
||||
}
|
||||
|
||||
public string FechaNacimientoSinHora => this.FechaNacimiento?.ToString("dd/MM/yyyy") ?? "";
|
||||
public string FechaExpCarnetSinHora => this.FechaExpedicionCarnet?.ToString("dd/MM/yyyy") ?? "";
|
||||
|
||||
public static void GuardandoCambios(tscgestionasegasa bd, string aplicacion)
|
||||
{
|
||||
var modifiedEnts = bd.ChangeTracker.Entries<entidades>()
|
||||
.Where(e => e.State == Microsoft.EntityFrameworkCore.EntityState.Modified);
|
||||
|
||||
foreach (var entry in modifiedEnts)
|
||||
{
|
||||
var ent = entry.Entity;
|
||||
if (!string.IsNullOrEmpty(ent.CIF))
|
||||
{
|
||||
ent.CIF = Regex.Replace(ent.CIF, "[^a-zA-Z0-9]", "").ToUpper();
|
||||
}
|
||||
// Legacy logging logic can be implemented here if needed
|
||||
}
|
||||
}
|
||||
|
||||
public virtual List<EntidadRelacionada> RelacionesEntreEntidades
|
||||
{
|
||||
get
|
||||
{
|
||||
var entsh = this.entidadesrelacionadasidEntidadPadreNavigation.Select(x => new EntidadRelacionada {
|
||||
RazonSocial = x.idEntidadHijoNavigation.RazonSocial,
|
||||
TipoRelacion = EntidadRelacionada.TipoRelacionEntidadEnum.ES_HIJA,
|
||||
CIF = x.idEntidadHijoNavigation.CIF,
|
||||
EntRel = x
|
||||
}).ToList();
|
||||
|
||||
var entsp = this.entidadesrelacionadasidEntidadHijoNavigation.Select(x => new EntidadRelacionada {
|
||||
RazonSocial = x.idEntidadPadreNavigation.RazonSocial,
|
||||
TipoRelacion = EntidadRelacionada.TipoRelacionEntidadEnum.ES_PADRE,
|
||||
CIF = x.idEntidadPadreNavigation.CIF,
|
||||
EntRel = x
|
||||
}).ToList();
|
||||
|
||||
return entsh.Union(entsp).OrderBy(x => x.RazonSocial).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public class EntidadRelacionada
|
||||
{
|
||||
public int idEntidad { get; set; }
|
||||
public string CIF { get; set; }
|
||||
public TipoRelacionEntidadEnum TipoRelacion { get; set; }
|
||||
public string DescripcionTipoRelacion => TipoRelacion.ToString().Replace("_", " ");
|
||||
public string RazonSocial { get; set; }
|
||||
public enum TipoRelacionEntidadEnum { ES_HIJA, ES_PADRE }
|
||||
public virtual entidadesrelacionadas EntRel { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
public class ve_entidades
|
||||
{
|
||||
public int idEntidad { get; set; }
|
||||
public string CIF { get; set; }
|
||||
public string RazonSocial { get; set; }
|
||||
public DateOnly? FechaNacimiento { get; set; }
|
||||
public string Direccion { get; set; }
|
||||
public string Poblacion { get; set; }
|
||||
public string Provincia { get; set; }
|
||||
public string Telefono1 { get; set; }
|
||||
public string email { get; set; }
|
||||
public bool EsTaller { get; set; }
|
||||
public bool EsClienteSG { get; set; }
|
||||
public bool EsClienteSA { get; set; }
|
||||
public bool EsContrarioSiniestro { get; set; }
|
||||
|
||||
public string PoblacionYProvincia
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.Provincia == this.Poblacion)
|
||||
{
|
||||
return this.Poblacion;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.Poblacion + " (" + this.Provincia + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ve_entidades_venta_cruzada
|
||||
{
|
||||
public int idEntidad { get; set; }
|
||||
public string CIF { get; set; }
|
||||
public string RazonSocial { get; set; }
|
||||
public string Telefono1 { get; set; }
|
||||
public string Telefono2 { get; set; }
|
||||
public DateOnly? FechaNacimientoTomador { get; set; }
|
||||
public string TelefonoMovilValido { get; set; }
|
||||
public string Email { get; set; }
|
||||
public int NumeroPolizas { get; set; }
|
||||
public int idAgente { get; set; }
|
||||
public string Agente { get; set; }
|
||||
public int? idSubagente { get; set; }
|
||||
public string SubAgente { get; set; }
|
||||
public string TlfAgente { get; set; }
|
||||
public string EmailAgente { get; set; }
|
||||
public string TlfSubAgente { get; set; }
|
||||
public string EmailSubAgente { get; set; }
|
||||
public int NumeroCorreosVentaCruzada { get; set; }
|
||||
public string Compañías { get; set; }
|
||||
|
||||
public string TelefonoSubAgenteAgente
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!string.IsNullOrEmpty(TlfSubAgente))
|
||||
{
|
||||
return TlfSubAgente;
|
||||
}
|
||||
else
|
||||
{
|
||||
return TlfAgente;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
36
bdAsegasa/Extensiones/entidadespolizas.cs
Normal file
36
bdAsegasa/Extensiones/entidadespolizas.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class entidadespolizas
|
||||
{
|
||||
public bool AEliminar_tmp { get; set; }
|
||||
|
||||
public string Domicilio
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idDireccion.HasValue)
|
||||
{
|
||||
if (this.idDireccionNavigation?.CodigoMunicipioNavigation == null || string.IsNullOrEmpty(this.idDireccionNavigation?.Direccion) || string.IsNullOrEmpty(this.idDireccionNavigation?.CodigoPostal))
|
||||
{
|
||||
return "** DOMICILIO INCORRECTO **";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.idDireccionNavigation.CodigoMunicipioNavigation.CodigoProvinciaNavigation?.Nombre == this.idDireccionNavigation.CodigoMunicipioNavigation.Nombre)
|
||||
{
|
||||
return this.idDireccionNavigation.Direccion + " - " + this.idDireccionNavigation.CodigoPostal + " " + this.idDireccionNavigation.CodigoMunicipioNavigation.Nombre;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.idDireccionNavigation.Direccion + " - " + this.idDireccionNavigation.CodigoPostal + " " + this.idDireccionNavigation.CodigoMunicipioNavigation.Nombre + " (" + this.idDireccionNavigation.CodigoMunicipioNavigation.CodigoProvinciaNavigation?.Nombre + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return "** DOMICILIO INCORRECTO **";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
67
bdAsegasa/Extensiones/enumeraciones.cs
Normal file
67
bdAsegasa/Extensiones/enumeraciones.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class enumeraciones
|
||||
{
|
||||
public string CodigoDescripcion
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.Codigo) || !this.Codigo.Contains("."))
|
||||
{
|
||||
return "- " + this.Descripcion;
|
||||
}
|
||||
var parts = this.Codigo.Split('.');
|
||||
if (parts.Length > 1)
|
||||
{
|
||||
return parts[1] + " - " + this.Descripcion;
|
||||
}
|
||||
return this.Codigo + " - " + this.Descripcion;
|
||||
}
|
||||
}
|
||||
|
||||
public int? ValorEntero1
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.ValorNumerico1.HasValue)
|
||||
{
|
||||
return (int)this.ValorNumerico1.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value.HasValue)
|
||||
{
|
||||
this.ValorNumerico1 = (double)value.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ValorNumerico1 = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<enumeraciones> _LConfsi;
|
||||
|
||||
public static List<enumeraciones> LConfsi
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_LConfsi == null)
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
// Assuming NuevoContexto or similar context provider logic is used
|
||||
_LConfsi = bd.enumeraciones.Where(x => x.Codigo != null && x.Codigo.StartsWith("VF.SI-")).OrderByDescending(x => x.Fecha1).ToList();
|
||||
}
|
||||
return _LConfsi;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
64
bdAsegasa/Extensiones/estadossiniestros_eiac.cs
Normal file
64
bdAsegasa/Extensiones/estadossiniestros_eiac.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class estadossiniestros_eiac
|
||||
{
|
||||
public static int ObtieneSituacionSiniestroV6(claves_situacionsiniestro Clave)
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (Clave)
|
||||
{
|
||||
case claves_situacionsiniestro.AP:
|
||||
return (int)ClavesSituacionSiniestroEnum.ABIERTO;
|
||||
case claves_situacionsiniestro.CE:
|
||||
return (int)ClavesSituacionSiniestroEnum.CERRADO;
|
||||
case claves_situacionsiniestro.RA:
|
||||
return (int)ClavesSituacionSiniestroEnum.REABIERTO;
|
||||
case claves_situacionsiniestro.RC:
|
||||
return (int)ClavesSituacionSiniestroEnum.RECHAZADO;
|
||||
default:
|
||||
return (int)ClavesSituacionSiniestroEnum.DESCONOCIDA;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return (int)ClavesSituacionSiniestroEnum.DESCONOCIDA;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ClavesSituacionSiniestroEnum : int
|
||||
{
|
||||
ABIERTO = 1,
|
||||
CERRADO = 2,
|
||||
REABIERTO = 3,
|
||||
RECHAZADO = 4,
|
||||
DESCONOCIDA = 99
|
||||
}
|
||||
|
||||
public enum claves_situacionsiniestro
|
||||
{
|
||||
AP,
|
||||
CE,
|
||||
RA,
|
||||
RC
|
||||
}
|
||||
|
||||
|
||||
public string DescripcionSituacionSiniestro
|
||||
{
|
||||
get
|
||||
{
|
||||
if (SituacionSiniestro.HasValue)
|
||||
{
|
||||
return ((ClavesSituacionSiniestroEnum)SituacionSiniestro.Value).ToString().Replace("_", " ");
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
70
bdAsegasa/Extensiones/expedientessiniestros_eiac.cs
Normal file
70
bdAsegasa/Extensiones/expedientessiniestros_eiac.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class expedientessiniestros_eiac
|
||||
{
|
||||
public static int ObtieneEstadoExpedienteV6(claves_estadoexpediente clave)
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (clave)
|
||||
{
|
||||
case claves_estadoexpediente.DE:
|
||||
return (int)ClavesEstadoExpedienteEnum.DECLARADO;
|
||||
case claves_estadoexpediente.LI:
|
||||
return (int)ClavesEstadoExpedienteEnum.LIQUIDADO;
|
||||
case claves_estadoexpediente.PE:
|
||||
return (int)ClavesEstadoExpedienteEnum.PENDIENTE;
|
||||
case claves_estadoexpediente.RE:
|
||||
return (int)ClavesEstadoExpedienteEnum.REAPERTURA;
|
||||
case claves_estadoexpediente.TE:
|
||||
return (int)ClavesEstadoExpedienteEnum.TERMINADO;
|
||||
default:
|
||||
return (int)ClavesEstadoExpedienteEnum.DESCONOCIDA;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return (int)ClavesEstadoExpedienteEnum.DESCONOCIDA;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ClavesEstadoExpedienteEnum : int
|
||||
{
|
||||
DECLARADO = 1,
|
||||
LIQUIDADO = 2,
|
||||
PENDIENTE = 3,
|
||||
REAPERTURA = 4,
|
||||
TERMINADO = 5,
|
||||
DESCONOCIDA = 99
|
||||
}
|
||||
|
||||
public enum claves_estadoexpediente
|
||||
{
|
||||
|
||||
/// <remarks/>
|
||||
DE,
|
||||
|
||||
/// <remarks/>
|
||||
LI,
|
||||
|
||||
/// <remarks/>
|
||||
PE,
|
||||
|
||||
/// <remarks/>
|
||||
RE,
|
||||
|
||||
/// <remarks/>
|
||||
TE
|
||||
}
|
||||
|
||||
public string DescripcionEstadoExpediente
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((ClavesEstadoExpedienteEnum)EstadoExpediente).ToString().Replace("_", " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
67
bdAsegasa/Extensiones/ficheros.cs
Normal file
67
bdAsegasa/Extensiones/ficheros.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class ficheros
|
||||
{
|
||||
public string idFicheroEnc
|
||||
{
|
||||
get
|
||||
{
|
||||
string idStr = this.idFichero.ToString().PadLeft(8, '0');
|
||||
using (SHA1 sha1 = SHA1.Create())
|
||||
{
|
||||
byte[] hash = sha1.ComputeHash(Encoding.ASCII.GetBytes("ASEGASa" + idStr));
|
||||
string dc = hash[0].ToString("x2");
|
||||
// Using tsUtilidades for encryption
|
||||
return tsUtilidades.crypt.FEncS(idStr + dc, "1973122213","",0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int ObtieneidFichero(string idEncriptado)
|
||||
{
|
||||
try
|
||||
{
|
||||
string idcdc = tsUtilidades.crypt.FEncS(idEncriptado, "1973122213","",0);
|
||||
if (idcdc.Length < 10) return 0;
|
||||
string idr = idcdc.Substring(0, 8);
|
||||
string dc = idcdc.Substring(8, 2);
|
||||
|
||||
using (SHA1 sha1 = SHA1.Create())
|
||||
{
|
||||
byte[] hash = sha1.ComputeHash(Encoding.ASCII.GetBytes("ASEGASa" + idr));
|
||||
if (hash[0].ToString("x2") != dc) return 0;
|
||||
return int.Parse(idr);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class vr_ficheros
|
||||
{
|
||||
public int idFichero { get; set; }
|
||||
public string NombreFichero { get; set; }
|
||||
public DateTime Fecha { get; set; }
|
||||
public string Descripcion { get; set; }
|
||||
|
||||
public static List<vr_ficheros> Obtiene_vr_ficheros(IQueryable<ficheros> iqFicheros)
|
||||
{
|
||||
return iqFicheros.Select(x => new vr_ficheros
|
||||
{
|
||||
idFichero = x.idFichero,
|
||||
NombreFichero = x.NombreFichero,
|
||||
Fecha = (DateTime)x.Fecha,
|
||||
Descripcion = x.Descripcion
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
36
bdAsegasa/Extensiones/ficheroscompanias.cs
Normal file
36
bdAsegasa/Extensiones/ficheroscompanias.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class ficheroscompanias
|
||||
{
|
||||
public enum TipoFicheroCompania : int
|
||||
{
|
||||
POLIZAS_EIAC = 1,
|
||||
RECIBOS_EIAC = 2,
|
||||
MOVIMIENTOS_RECIBOS_EIAC = 3,
|
||||
SINIESTROS_EIAC = 4,
|
||||
MOVIMIENTOS_SINIESTROS_EIAC = 5,
|
||||
LIQUIDACIONES_EIAC = 6, // VB had duplicate 5, fixed to 6 or kept as 5? Original had 5 for both.
|
||||
RECIBOS_PATRIA_HISPANA = 12,
|
||||
RECIBOS_PREVISION_MALLORQUINA = 13,
|
||||
CARTERA_COMPLETA_EIAC = 98,
|
||||
DESCONOCIDO = 99
|
||||
}
|
||||
|
||||
public bool ContieneMovimientosDeRecibos()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Note: Logic for EIAC deserialization requires ProcesosEIAC dlls.
|
||||
// This is a placeholder for the logic.
|
||||
return false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1138
bdAsegasa/Extensiones/gestionasegasaEntities.cs
Normal file
1138
bdAsegasa/Extensiones/gestionasegasaEntities.cs
Normal file
File diff suppressed because it is too large
Load Diff
70
bdAsegasa/Extensiones/gestionesrecibos.cs
Normal file
70
bdAsegasa/Extensiones/gestionesrecibos.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class gestionesrecibos
|
||||
{
|
||||
public string DetalleCorreo
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idCorreoNavigation != null)
|
||||
{
|
||||
var c = this.idCorreoNavigation;
|
||||
if (c.FechaAnulacion.HasValue)
|
||||
return $"Correo a {c.Destinatario} Anulado el {c.FechaAnulacion.Value:dd/MM/yyyy HH:mm}";
|
||||
if (c.FechaEnvio.HasValue)
|
||||
return $"Correo a {c.Destinatario} Enviado el {c.FechaEnvio.Value:dd/MM/yyyy HH:mm}";
|
||||
return $"Correo a {c.Destinatario} pendiente de envio";
|
||||
}
|
||||
return "Sin correo";
|
||||
}
|
||||
}
|
||||
|
||||
public string DetalleMensaje
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idMensajeNavigation != null)
|
||||
{
|
||||
var m = this.idMensajeNavigation;
|
||||
if (m.FechaAnulacion.HasValue)
|
||||
return $"Mensaje a {m.Destinatario} Anulado el {m.FechaAnulacion.Value:dd/MM/yyyy HH:mm}";
|
||||
if (m.FechaEnvio.HasValue)
|
||||
return $"Mensaje a {m.Destinatario} Enviado el {m.FechaEnvio.Value:dd/MM/yyyy HH:mm}";
|
||||
return $"Mensaje a {m.Destinatario} pendiente de envio";
|
||||
}
|
||||
return "Sin Mensaje";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum TipoGestionEnum : int
|
||||
{
|
||||
AVISO_REMESA_O_COBRO_DIRECTO = 1,
|
||||
AVISO_POLIZA_DE_BAJA = 2,
|
||||
AVISO_RECIBO_DEVUELTO_BANCO = 3,
|
||||
AVISO_IMPERATIVO_LEGAL = 4,
|
||||
SOLICITUD_DATOS_DEL_ASEGURADO_AL_AGENTE = 5,
|
||||
COMUNICACIÓN_DEVOLUCIÓN_AL_AGENTE = 6,
|
||||
COMUNICACIÓN_BAJA_AL_AGENTE = 7,
|
||||
CAMBIO_CARTERA_AGENTE = 8,
|
||||
AVISO_DEFENSA_CARTERA = 9,
|
||||
DESCARGA_RECIBO_DE_CIA = 10,
|
||||
OTROS_HP = 100,
|
||||
OTROS = 101,
|
||||
COMUNICACIÓN_EMISION_RECIBO_A_LA_COMPAÑÍA = 200,
|
||||
IMPRESION_RECIBO_CIA = 300,
|
||||
IMPRESION_RECIBO_GENERICO = 301,
|
||||
AVISO_ERRONEO = 1000
|
||||
}
|
||||
|
||||
public enum FormaComunicacionEnum
|
||||
{
|
||||
NINGUNA = 0,
|
||||
POR_SMS = 1,
|
||||
POR_CARTA = 2,
|
||||
SIN_DOMICILIO_NI_TLF_VALIDO = 3,
|
||||
POR_EMAIL = 4
|
||||
}
|
||||
}
|
||||
9
bdAsegasa/Extensiones/gestionessiniestros.cs
Normal file
9
bdAsegasa/Extensiones/gestionessiniestros.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class gestionessiniestros
|
||||
{
|
||||
public bool PendienteRevision => this.FechaRecordatorio.HasValue && this.FechaRecordatorio.Value <= DateOnly.FromDateTime(DateTime.Now);
|
||||
}
|
||||
}
|
||||
71
bdAsegasa/Extensiones/gestionesvarias.cs
Normal file
71
bdAsegasa/Extensiones/gestionesvarias.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using bdAsegasa.dbcontext;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class gestionesvarias
|
||||
{
|
||||
public static gestionesvarias CreaNuevoCambioContraseñaAgente(int idAgente)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var idTg = bd.enumeraciones.First(x => x.Codigo == "TGV.CCAG").idEnumeracion;
|
||||
var ag = bd.agentes.First(x => x.idAgente == idAgente).Codigo;
|
||||
|
||||
var random = new Random();
|
||||
string iAleatorio = random.Next(100000000, 999999999).ToString();
|
||||
|
||||
var ng = new gestionesvarias();
|
||||
ng.idTipo = idTg;
|
||||
ng.idAplicacion = idAgente;
|
||||
ng.FechaCreacion = DateTime.Now;
|
||||
ng.Descripción = ag;
|
||||
ng.Parametros = tsUtilidades.crypt.SHA1ASCII("M3Soft." + iAleatorio);
|
||||
|
||||
bd.gestionesvarias.Add(ng);
|
||||
bd.SaveChanges();
|
||||
return ng;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static gestionesvarias CreaNuevoCambioContraseñaSubAgente(int idSubAgente)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var idTg = bd.enumeraciones.First(x => x.Codigo == "TGV.CCSAG").idEnumeracion;
|
||||
var sag = bd.subagentes.First(x => x.idSubagente == idSubAgente);
|
||||
|
||||
var random = new Random();
|
||||
string iAleatorio = random.Next(100000000, 999999999).ToString();
|
||||
|
||||
var ng = new gestionesvarias();
|
||||
ng.idTipo = idTg;
|
||||
ng.idAplicacion = idSubAgente;
|
||||
ng.FechaCreacion = DateTime.Now;
|
||||
ng.Descripción = $"{sag.idAgenteNavigation?.Codigo}-{sag.Codigo}";
|
||||
ng.Parametros = tsUtilidades.crypt.SHA1("M3Soft." + iAleatorio);
|
||||
|
||||
bd.gestionesvarias.Add(ng);
|
||||
bd.SaveChanges();
|
||||
return ng;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
40
bdAsegasa/Extensiones/historicocomisiones.cs
Normal file
40
bdAsegasa/Extensiones/historicocomisiones.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Linq;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class historicocomisiones
|
||||
{
|
||||
public double TotalComisionAgente
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.comisionAgente ?? 0) + (this.incentivoAgente ?? 0);
|
||||
}
|
||||
}
|
||||
|
||||
public string CodNomAgente
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.idCodigoAgenteNavigation?.Codigo + "-" + this.idCodigoAgenteNavigation?.Nombre;
|
||||
}
|
||||
}
|
||||
|
||||
public string PlanLinea
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.idPolizaAgrarioNavigation?.idPlanLineaNavigation?.planLinea;
|
||||
}
|
||||
}
|
||||
|
||||
public int NumeroPolizas
|
||||
{
|
||||
get
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
return bd.polizasagrario.Count(x => x.poliza == this.idPolizaAgrarioNavigation.poliza);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -28,5 +28,111 @@ namespace bdAsegasa.db
|
||||
return NumeroFactura;
|
||||
}
|
||||
}
|
||||
public const string Prod = "https://www2.agenciatributaria.gob.es/wlpl/TIKE-CONT/ValidarQR";
|
||||
public const string TestValidate = "https://prewww2.aeat.es/wlpl/TIKE-CONT/ValidarQR";
|
||||
|
||||
public string EnlaceQR
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
DateTime fechaCmp = this.Fecha != DateOnly.MinValue ? new DateTime(this.Fecha.Year, this.Fecha.Month, this.Fecha.Day) : DateTime.Now;
|
||||
|
||||
var confsi = enumeraciones.LConfsi?.Where(x => x.Fecha1.HasValue && x.Fecha1.Value <= fechaCmp).OrderByDescending(x => x.Fecha1).FirstOrDefault();
|
||||
|
||||
if (confsi != null)
|
||||
{
|
||||
if (confsi.ValorNumerico4 > 0)
|
||||
{
|
||||
return Prod + "?nif=" + this.idAgenteNavigation?.CIF + "&numserie=" + NumeroFactura + "&fecha=" + this.Fecha.ToString("dd-MM-yyyy") + "&importe=" + Math.Round(TotalFacturaSinIRPF, 2, MidpointRounding.AwayFromZero).ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
else
|
||||
{
|
||||
string nf = NumeroFacturaVF(confsi.ValorAlfabetico4);
|
||||
return TestValidate + "?nif=" + this.idAgenteNavigation?.CIF + "&numserie=" + nf + "&fecha=" + this.Fecha.ToString("dd-MM-yyyy") + "&importe=" + Math.Round(TotalFacturaSinIRPF, 2, MidpointRounding.AwayFromZero).ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string nf = NumeroFacturaVF(null);
|
||||
return TestValidate + "?nif=" + this.idAgenteNavigation?.CIF + "&numserie=" + nf + "&fecha=" + this.Fecha.ToString("dd-MM-yyyy") + "&importe=" + Math.Round(TotalFacturaSinIRPF, 2, MidpointRounding.AwayFromZero).ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool QRVisible
|
||||
{
|
||||
get
|
||||
{
|
||||
DateTime fechaCmp = this.Fecha != DateOnly.MinValue ? new DateTime(this.Fecha.Year, this.Fecha.Month, this.Fecha.Day) : DateTime.Now;
|
||||
var confsi = enumeraciones.LConfsi?.Where(x => x.Fecha1.HasValue && x.Fecha1.Value <= fechaCmp).OrderByDescending(x => x.Fecha1).FirstOrDefault();
|
||||
if (confsi != null)
|
||||
{
|
||||
return confsi.ValorNumerico4 > 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string DescripcionEstadoVerifactu
|
||||
{
|
||||
get
|
||||
{
|
||||
return EstadoVerifactu.ToString().Replace("_", " ");
|
||||
}
|
||||
}
|
||||
|
||||
public EstadoVerifactuEnum EstadoVerifactu
|
||||
{
|
||||
get
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
var rvf = bd.registrosverifactu.Where(x => x.idAplicacion == idLiquidacionAgente).OrderByDescending(x => x.idRegistro).FirstOrDefault();
|
||||
if (rvf != null)
|
||||
{
|
||||
return (EstadoVerifactuEnum)(rvf.Estado);
|
||||
}
|
||||
else
|
||||
{
|
||||
return EstadoVerifactuEnum.SIN_REGISTROS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum EstadoVerifactuEnum
|
||||
{
|
||||
PENDIENTE_RESPUESTA = 0,
|
||||
CORRECTO = 1,
|
||||
ACEPTADO_CON_ERRORES = 2,
|
||||
INCORRECTO = 3,
|
||||
COMPLETADO = 10,
|
||||
SIN_REGISTROS = 100
|
||||
}
|
||||
|
||||
public string ObtieneNumeroFactura()
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
int AnoAct = DateTime.Today.Year;
|
||||
if (this.FechaFactura.HasValue && this.FechaFactura.Value.Year < 2026)
|
||||
{
|
||||
var UltimaLiquidacion = bd.liquidacionesagentes.Where(x => x.FechaFactura.HasValue && x.FechaFactura.Value.Year == AnoAct).OrderByDescending(x => x.NumeroFactura).FirstOrDefault();
|
||||
int UltimaFactura = 1;
|
||||
if (UltimaLiquidacion != null && !string.IsNullOrEmpty(UltimaLiquidacion.NumeroFactura) && UltimaLiquidacion.NumeroFactura.Contains("-"))
|
||||
UltimaFactura = int.Parse(UltimaLiquidacion.NumeroFactura.Split('-')[1]) + 1;
|
||||
return DateTime.Today.Year.ToString() + "-" + UltimaFactura.ToString().PadLeft(5, '0');
|
||||
}
|
||||
else
|
||||
{
|
||||
var UltimaLiquidacion = bd.liquidacionesagentes.Where(x => x.FechaFactura.HasValue && x.FechaFactura.Value.Year == AnoAct && x.idSerieFactura == this.idSerieFactura).OrderByDescending(x => x.NumeroFactura).FirstOrDefault();
|
||||
int UltimaFactura = 1;
|
||||
if (UltimaLiquidacion != null && !string.IsNullOrEmpty(UltimaLiquidacion.NumeroFactura) && UltimaLiquidacion.NumeroFactura.Contains("-"))
|
||||
UltimaFactura = int.Parse(UltimaLiquidacion.NumeroFactura.Split('-')[1].Substring(2)) + 1;
|
||||
var sf = bd.seriesfacturas.First(x => x.idSerieFactura == idSerieFactura).Serie;
|
||||
return sf + "-" + DateTime.Today.Year.ToString().Substring(2) + UltimaFactura.ToString().PadLeft(5, '0');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
16
bdAsegasa/Extensiones/liquidacionescompanias.cs
Normal file
16
bdAsegasa/Extensiones/liquidacionescompanias.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.Linq;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class liquidacionescompanias
|
||||
{
|
||||
public string Compañía
|
||||
{
|
||||
get
|
||||
{
|
||||
var first = this.liquidacionescompaniasrecibos.FirstOrDefault();
|
||||
return first?.idReciboNavigation?.idPolizaNavigation?.idCompaniaNavigation?.Nombre ?? "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
45
bdAsegasa/Extensiones/liquidacionesviajes.cs
Normal file
45
bdAsegasa/Extensiones/liquidacionesviajes.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class liquidacionesviajes
|
||||
{
|
||||
public double Diferencia
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Round((double)(TotalJustificado - Anticipo), 2);
|
||||
}
|
||||
}
|
||||
|
||||
public string ADevolver
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Diferencia < 0)
|
||||
{
|
||||
return Math.Abs(Diferencia).ToString("c2");
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string ARecibir
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Diferencia > 0)
|
||||
{
|
||||
return Diferencia.ToString("c2");
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
56
bdAsegasa/Extensiones/logs.cs
Normal file
56
bdAsegasa/Extensiones/logs.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using bdAsegasa.dbcontext;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class logs
|
||||
{
|
||||
public static int GeneraLog(tscgestionasegasa bd, string Tabla, int id, int? idrelacionado, string Tipo, string LogXML, bool SuperUsuario, string Aplicacion)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (bd == null) bd = tscgestionasegasa.NuevoContexto();
|
||||
|
||||
var nl = new logs();
|
||||
nl.Tabla = Tabla;
|
||||
nl.Aplicacion = Aplicacion;
|
||||
nl.LogXML = LogXML;
|
||||
nl.id = id;
|
||||
nl.idRelacionado = idrelacionado;
|
||||
nl.ip = bd.ip;
|
||||
nl.FechaHora = DateTime.Now;
|
||||
nl.Tipo = Tipo;
|
||||
nl.Usuario = SuperUsuario ? $"{Utilidades.Usuario} (SU)" : Utilidades.Usuario;
|
||||
nl.idTimeStamp = (double)DateTime.Now.Ticks;
|
||||
|
||||
bd.logs.Add(nl);
|
||||
bd.SaveChanges();
|
||||
return nl.idLog;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utilidades.AñadeLog(tsUtilidades.Enumeraciones.TipoLog.Fallo, "En GeneraLog", ex.Message, ex);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public string GeneradoPor
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idRelacionado.HasValue)
|
||||
{
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var lp = bd.logs.FirstOrDefault(x => x.idLog == this.idRelacionado);
|
||||
return lp?.Aplicacion ?? "DESCONOCIDO";
|
||||
}
|
||||
}
|
||||
return this.Aplicacion;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
57
bdAsegasa/Extensiones/modificacionespolizasagrario.cs
Normal file
57
bdAsegasa/Extensiones/modificacionespolizasagrario.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class modificacionespolizasagrario
|
||||
{
|
||||
public double PorIncAge
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.previstasIncentivoAgente.GetValueOrDefault() / this.primaComercialNeta.GetValueOrDefault()) * 100;
|
||||
}
|
||||
}
|
||||
public double PorComAge
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.previstasComisionAgente.GetValueOrDefault() / this.primaComercialNeta.GetValueOrDefault()) * 100;
|
||||
}
|
||||
}
|
||||
public double PorIncAse
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.previstasIncentivoAsegasa.GetValueOrDefault() / this.primaComercialNeta.GetValueOrDefault()) * 100;
|
||||
}
|
||||
}
|
||||
public double PorComAse
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.previstasComisionAsegasa.GetValueOrDefault() / this.primaComercialNeta.GetValueOrDefault()) * 100;
|
||||
}
|
||||
}
|
||||
public double PorNifNue
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.previstasNIFNuevo.GetValueOrDefault() / this.primaComercialNeta.GetValueOrDefault()) * 100;
|
||||
}
|
||||
}
|
||||
public double PorTomPro
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.previstasTomadorPropio.GetValueOrDefault() / this.primaComercialNeta.GetValueOrDefault()) * 100;
|
||||
}
|
||||
}
|
||||
public double PorTotComPre
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.totalPrevistas.GetValueOrDefault() / this.primaComercialNeta.GetValueOrDefault()) * 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
67
bdAsegasa/Extensiones/movimientosbancarios.cs
Normal file
67
bdAsegasa/Extensiones/movimientosbancarios.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class movimientosbancarios
|
||||
{
|
||||
private bool? _Conciliado;
|
||||
|
||||
public bool Conciliado
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Conciliado.HasValue)
|
||||
{
|
||||
return _Conciliado.Value;
|
||||
}
|
||||
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 virtual conciliacionesbancarias ConciliacionActual_TMP { get; set; }
|
||||
|
||||
public string ConciliadoEn
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ConciliacionActual_TMP != null && this.idConciliacion.HasValue && this.idConciliacion != ConciliacionActual_TMP.idconciliacion)
|
||||
{
|
||||
return "Nº Conc.: " + this.idConciliacion + " (" + this.idConciliacionNavigation.Año.ToString() + "-" + this.idConciliacionNavigation.Mes.ToString() + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
82
bdAsegasa/Extensiones/municipios.cs
Normal file
82
bdAsegasa/Extensiones/municipios.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using bdAsegasa.dbcontext;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class municipios
|
||||
{
|
||||
private static List<municipios> _listaPoblaciones;
|
||||
|
||||
public string PoblacionYProvincia
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this.Nombre == this.CodigoProvinciaNavigation?.Nombre)
|
||||
{
|
||||
return this.Nombre;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"{this.Nombre} ({this.CodigoProvinciaNavigation?.Nombre})";
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string ObtienePoblacion(string codigoPoblacion)
|
||||
{
|
||||
EnsureCache();
|
||||
var pob = _listaPoblaciones.FirstOrDefault(x => x.CodigoMunicipio == codigoPoblacion);
|
||||
if (pob != null) return pob.Nombre;
|
||||
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
pob = bd.municipios.Include(x => x.CodigoProvinciaNavigation).FirstOrDefault(x => x.CodigoMunicipio == codigoPoblacion);
|
||||
if (pob != null)
|
||||
{
|
||||
_listaPoblaciones.Add(pob);
|
||||
return pob.Nombre;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static string ObtieneProvincia(string codigoPoblacion)
|
||||
{
|
||||
EnsureCache();
|
||||
var pob = _listaPoblaciones.FirstOrDefault(x => x.CodigoMunicipio == codigoPoblacion);
|
||||
if (pob != null) return pob.CodigoProvinciaNavigation?.Nombre ?? "";
|
||||
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
pob = bd.municipios.Include(x => x.CodigoProvinciaNavigation).FirstOrDefault(x => x.CodigoMunicipio == codigoPoblacion);
|
||||
if (pob != null)
|
||||
{
|
||||
_listaPoblaciones.Add(pob);
|
||||
return pob.CodigoProvinciaNavigation?.Nombre ?? "";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static void EnsureCache()
|
||||
{
|
||||
if (_listaPoblaciones == null)
|
||||
{
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
_listaPoblaciones = bd.municipios.Include(x => x.CodigoProvinciaNavigation).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
25
bdAsegasa/Extensiones/notificaciones.cs
Normal file
25
bdAsegasa/Extensiones/notificaciones.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class notificaciones
|
||||
{
|
||||
public bool Notificado
|
||||
{
|
||||
get => FechaNotificado.HasValue;
|
||||
set => FechaNotificado = value ? DateTime.Now : null;
|
||||
}
|
||||
|
||||
public enum TipoEntidadEnum : int
|
||||
{
|
||||
USUARIO = 1,
|
||||
AGENTE = 2,
|
||||
SUBAGENTE = 3
|
||||
}
|
||||
|
||||
public enum TipoNotificacionEnum : int
|
||||
{
|
||||
AVISO_AGENTE_RECIBOS_BAJA = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
36
bdAsegasa/Extensiones/pagosliquidacionescia.cs
Normal file
36
bdAsegasa/Extensiones/pagosliquidacionescia.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class pagosliquidacionescias
|
||||
{
|
||||
public double ImportePago
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Round((this.ImporteLiquidaciones) + (this.ImporteRegularizacion), 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
|
||||
public double ImporteCobros
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Round(this.liquidacionescompanias.Where(x => x.idTipoLiquidacionNavigation?.Codigo != "TIPLIQ.DESCOBRO").Sum(x => x.Importe), 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
|
||||
public double ImporteDesCobros
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Round(this.liquidacionescompanias.Where(x => x.idTipoLiquidacionNavigation?.Codigo == "TIPLIQ.DESCOBRO").Sum(x => x.Importe), 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
|
||||
public void ActualizaImportePago()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
157
bdAsegasa/Extensiones/pagostelematicos.cs
Normal file
157
bdAsegasa/Extensiones/pagostelematicos.cs
Normal file
@@ -0,0 +1,157 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections.Specialized;
|
||||
using Newtonsoft.Json;
|
||||
using bdAsegasa.dbcontext;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class pagostelematicos
|
||||
{
|
||||
public string CodigoRecibo => this.idReciboNavigation?.CodigoRecibo ?? "";
|
||||
|
||||
public static pagostelematicos GeneraPagoTelematico(tscgestionasegasa bd, OrigenPagoEnum origenPago, string referencia, string emailConfirmacion, string telefono, double importe, string dni = "", int? idRecibo = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (idRecibo.HasValue && !bd.recibos.Any(x => x.idRecibo == idRecibo.Value))
|
||||
throw new Exception("No se encuentra el recibo con id: " + idRecibo.Value);
|
||||
|
||||
var random = new Random();
|
||||
var np = new pagostelematicos();
|
||||
np.DNI = dni?.Trim().ToUpper();
|
||||
np.Referencia = referencia?.Trim().ToUpper();
|
||||
np.EmailConfirmacionPago = emailConfirmacion?.Trim().ToLower();
|
||||
np.Telefono = telefono;
|
||||
np.Importe = Math.Round(importe, 2);
|
||||
np.FechaCreacion = DateTime.Now;
|
||||
np.idRecibo = idRecibo;
|
||||
np.OrigenPago = (int)origenPago;
|
||||
np.CodigoConfirmacionPago = random.Next(100000000, 999999999).ToString();
|
||||
|
||||
bd.pagostelematicos.Add(np);
|
||||
bd.SaveChanges();
|
||||
return np;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum OrigenPagoEnum
|
||||
{
|
||||
PAGO_GENERICO = 0,
|
||||
PAGO_RECIBO = 1
|
||||
}
|
||||
|
||||
public class RespuestaRedsysPOST
|
||||
{
|
||||
public string Ds_SignatureVersion { get; set; }
|
||||
public string Ds_MerchantParameters { get; set; }
|
||||
public string Ds_Signature { get; set; }
|
||||
public ConfirmacionRedsys Confirmacion { get; set; }
|
||||
|
||||
public RespuestaRedsysPOST() { }
|
||||
|
||||
public RespuestaRedsysPOST(NameValueCollection datosPOST)
|
||||
{
|
||||
foreach (string key in datosPOST.AllKeys)
|
||||
{
|
||||
if (key == "Ds_SignatureVersion") this.Ds_SignatureVersion = datosPOST[key];
|
||||
if (key == "Ds_MerchantParameters") this.Ds_MerchantParameters = datosPOST[key];
|
||||
if (key == "Ds_Signature") this.Ds_Signature = datosPOST[key];
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(Ds_MerchantParameters))
|
||||
{
|
||||
byte[] bDatos = Convert.FromBase64String(Ds_MerchantParameters);
|
||||
string sDatos = Encoding.UTF8.GetString(bDatos);
|
||||
this.Confirmacion = JsonConvert.DeserializeObject<ConfirmacionRedsys>(sDatos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ConfirmacionRedsys
|
||||
{
|
||||
public string Ds_Date { get; set; }
|
||||
public string Ds_Hour { get; set; }
|
||||
public string Ds_Amount { get; set; }
|
||||
public string Ds_Currency { get; set; }
|
||||
public string Ds_Order { get; set; }
|
||||
public string Ds_MerchantCode { get; set; }
|
||||
public string Ds_Terminal { get; set; }
|
||||
public string Ds_Response { get; set; }
|
||||
public string Ds_MerchantData { get; set; }
|
||||
public string Ds_SecurePayment { get; set; }
|
||||
public string Ds_TransactionType { get; set; }
|
||||
public string Ds_Card_Country { get; set; }
|
||||
public string Ds_AuthorisationCode { get; set; }
|
||||
public string Ds_ConsumerLanguage { get; set; }
|
||||
public string Ds_Card_Type { get; set; }
|
||||
|
||||
private const string SeparadorFecha = "%2F";
|
||||
private const string SeparadorHora = "%3A";
|
||||
|
||||
public DateTime Ds_Date_ComoDate
|
||||
{
|
||||
get
|
||||
{
|
||||
var parts = Ds_Date.Split(new[] { SeparadorFecha }, StringSplitOptions.None);
|
||||
return new DateTime(int.Parse(parts[2]), int.Parse(parts[1]), int.Parse(parts[0]));
|
||||
}
|
||||
}
|
||||
|
||||
public TimeSpan Ds_Hour_ComoTimeSpan
|
||||
{
|
||||
get
|
||||
{
|
||||
var parts = Ds_Hour.Split(new[] { SeparadorHora }, StringSplitOptions.None);
|
||||
return new TimeSpan(int.Parse(parts[0]), int.Parse(parts[1]), 0);
|
||||
}
|
||||
}
|
||||
|
||||
public double Ds_Amount_ComoDouble => double.Parse(Ds_Amount) / 100.0;
|
||||
|
||||
public bool Ds_Response_ComoBoolean
|
||||
{
|
||||
get
|
||||
{
|
||||
if (uint.TryParse(Ds_Response, out uint code))
|
||||
return code >= 0 && code <= 99;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Ds_SecurePayment_ComoBoolean => Ds_SecurePayment == "1";
|
||||
|
||||
public RedsysTipoTarjeta Ds_Card_Type_ComoEnum
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Ds_Card_Type == "C") return RedsysTipoTarjeta.CREDITO;
|
||||
if (Ds_Card_Type == "D") return RedsysTipoTarjeta.DEBITO;
|
||||
return RedsysTipoTarjeta.NO_PROPORCIONADO;
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime FechaHora
|
||||
{
|
||||
get
|
||||
{
|
||||
var d = Ds_Date_ComoDate;
|
||||
var t = Ds_Hour_ComoTimeSpan;
|
||||
return new DateTime(d.Year, d.Month, d.Day, t.Hours, t.Minutes, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum RedsysTipoTarjeta
|
||||
{
|
||||
NO_PROPORCIONADO = 0,
|
||||
CREDITO = 1,
|
||||
DEBITO = 2
|
||||
}
|
||||
}
|
||||
7
bdAsegasa/Extensiones/planeslineas.cs
Normal file
7
bdAsegasa/Extensiones/planeslineas.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class planeslineas
|
||||
{
|
||||
public string PlanesLineasDescripcion => $"{planLinea}, {descripcion}";
|
||||
}
|
||||
}
|
||||
7
bdAsegasa/Extensiones/plantillas.cs
Normal file
7
bdAsegasa/Extensiones/plantillas.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class plantillas
|
||||
{
|
||||
public byte[]? Plantilla => idFicheroNavigation?.Fichero;
|
||||
}
|
||||
}
|
||||
169
bdAsegasa/Extensiones/polizasagrario.cs
Normal file
169
bdAsegasa/Extensiones/polizasagrario.cs
Normal file
@@ -0,0 +1,169 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using bdAsegasa.dbcontext;
|
||||
using tsUtilidades;
|
||||
using tsEFCore8;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class polizasagrario
|
||||
{
|
||||
public entidades Tomador
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.idTomadorNavigation;
|
||||
}
|
||||
}
|
||||
public entidades Asegurado
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.idAseguradoNavigation;
|
||||
}
|
||||
}
|
||||
public direcciones DireccionAsegurado
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.idDomicilioAseguradoNavigation;
|
||||
}
|
||||
}
|
||||
|
||||
public string CodNomAgente
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.idAgenteNavigation.Codigo + "-" + this.idAgenteNavigation.Nombre;
|
||||
}
|
||||
}
|
||||
public string Fraccio
|
||||
{
|
||||
get
|
||||
{
|
||||
string Retorno = "NO";
|
||||
if (this.fraccionada == true) Retorno = "SI";
|
||||
return Retorno;
|
||||
}
|
||||
}
|
||||
|
||||
public int? idSubAgente_Especial
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idSubagente.HasValue && this.idAgenteNavigation.Codigo == "000047002186")
|
||||
{
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var Codigo = this.idSubagenteNavigation.Codigo.Substring(0, 2) + "00";
|
||||
var subage = bd.subagentes.FirstOrDefault(x => x.idAgente == this.idAgente && x.Codigo == Codigo);
|
||||
if (subage != null)
|
||||
{
|
||||
return subage.idSubagente;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.idSubagente;
|
||||
}
|
||||
}
|
||||
|
||||
public string ProvinciaAsegurado
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idAseguradoNavigation != null && this.idAseguradoNavigation.idDireccionPrincipalNavigation != null && this.idAseguradoNavigation.idDireccionPrincipalNavigation.CodigoPostal != null && this.idAseguradoNavigation.idDireccionPrincipalNavigation.CodigoPostal.Length > 2)
|
||||
{
|
||||
return this.idAseguradoNavigation.idDireccionPrincipalNavigation.CodigoPostal.Substring(0, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ListadoGenericoPA AListadoGenericoPA()
|
||||
{
|
||||
return new ListadoGenericoPA(this);
|
||||
}
|
||||
}
|
||||
|
||||
public class ListadoGenericoPA
|
||||
{
|
||||
public ListadoGenericoPA(polizasagrario p)
|
||||
{
|
||||
NumeroPóliza = p.poliza;
|
||||
|
||||
if (p.fechaPoliza.HasValue)
|
||||
{
|
||||
FechaPóliza = new DateTime(p.fechaPoliza.Value.Year, p.fechaPoliza.Value.Month, p.fechaPoliza.Value.Day);
|
||||
}
|
||||
|
||||
Línea = p.idPlanLineaNavigation?.descripcion;
|
||||
Compañía = p.idCiaNavigation?.Nombre;
|
||||
CIFAsegurado = p.Asegurado?.CIF;
|
||||
Asegurado = p.Asegurado?.RazonSocial;
|
||||
if (!string.IsNullOrEmpty(p.telefono1Asegurado))
|
||||
{
|
||||
Teléfono1 = p.telefono1Asegurado;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p.idAseguradoNavigation != null)
|
||||
{
|
||||
Teléfono1 = p.idAseguradoNavigation.Telefono1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Teléfono1 = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(p.telefono2Asegurado))
|
||||
{
|
||||
Teléfono2 = p.telefono2Asegurado;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p.idAseguradoNavigation != null)
|
||||
{
|
||||
Teléfono2 = p.idAseguradoNavigation.Telefono2;
|
||||
}
|
||||
else
|
||||
{
|
||||
Teléfono2 = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(p.emailAsegurado))
|
||||
{
|
||||
Email = p.emailAsegurado;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p.idAseguradoNavigation != null)
|
||||
{
|
||||
Email = p.idAseguradoNavigation.Email;
|
||||
}
|
||||
else
|
||||
{
|
||||
Email = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string NumeroPóliza { get; set; }
|
||||
public DateTime? FechaPóliza { get; set; }
|
||||
public string Compañía { get; set; }
|
||||
public string Línea { get; set; }
|
||||
public string CIFAsegurado { get; set; }
|
||||
public string Asegurado { get; set; }
|
||||
public string Teléfono1 { get; set; }
|
||||
public string Teléfono2 { get; set; }
|
||||
public string Email { get; set; }
|
||||
}
|
||||
}
|
||||
1425
bdAsegasa/Extensiones/polizassg.cs
Normal file
1425
bdAsegasa/Extensiones/polizassg.cs
Normal file
File diff suppressed because it is too large
Load Diff
16
bdAsegasa/Extensiones/procesos.cs
Normal file
16
bdAsegasa/Extensiones/procesos.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using bdAsegasa.dbcontext;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class procesos
|
||||
{
|
||||
public tsUtilidades.Permisos Permiso
|
||||
{
|
||||
get
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
return Utilidades.ObtienePermisos(bd, this.idPermiso, Utilidades.dsc.idUsuario);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
42
bdAsegasa/Extensiones/ramos.cs
Normal file
42
bdAsegasa/Extensiones/ramos.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class ramos
|
||||
{
|
||||
public static int[] ObtieneIDRamos(tscgestionasegasa bd, string[] CodigosRamos)
|
||||
{
|
||||
return bd.ramos.Where(x => CodigosRamos.Contains(x.Codigo)).Select(x => x.idRamo).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cambia de idRamo todas las pólzias asociadas al ramoAnterior y tras el cambio elimina dicho ramo
|
||||
/// </summary>
|
||||
public static bool EliminarRamo(tscgestionasegasa bd, string ramoAnterior, string ramoNuevo)
|
||||
{
|
||||
try
|
||||
{
|
||||
bd.Database.ExecuteSqlRaw("UPDATE polizassg set idRamo=" + ramoNuevo + " WHERE idRamo=" + ramoAnterior);
|
||||
bd.Database.ExecuteSqlRaw("DELETE FROM ramos where idRamo=" + ramoAnterior);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public string CodigoYDescripcion
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Codigo + " " + this.Descripcion;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2362
bdAsegasa/Extensiones/recibos.cs
Normal file
2362
bdAsegasa/Extensiones/recibos.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -39,9 +39,45 @@ namespace bdAsegasa.db
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public string DescripcionTipoFactura
|
||||
{
|
||||
get
|
||||
{
|
||||
switch ((TipoFacturaEnum)this.TipoFactura)
|
||||
{
|
||||
case TipoFacturaEnum.F1:
|
||||
return "F1 - Factura (art. 6, 7.2 y 7.3 del RD 1619/2012)";
|
||||
case TipoFacturaEnum.F2:
|
||||
return "F2 - Factura Simplificada y Facturas sin identificación del destinatario";
|
||||
case TipoFacturaEnum.F3:
|
||||
return "F3 - Factura emitida en sustitución de facturas simplificadas facturadas y declaradas";
|
||||
case TipoFacturaEnum.R1:
|
||||
return "R1 - Factura Rectificativa (Error fundado en derecho y Art. 80 Uno Dos y Seis LIVA)";
|
||||
case TipoFacturaEnum.R2:
|
||||
return "R2 - Factura Rectificativa (Art. 80.3). Cuando el destinatario de las operaciones sujetas al Impuesto no haya hecho efectivo el pago de las cuotas repercutidas y siempre que, con posterioridad al devengo de la operación, se dicte auto de declaración de concurso.";
|
||||
case TipoFacturaEnum.R3:
|
||||
return "R3 - Factura Rectificativa (Art. 80.4). Cuando los créditos correspondientes a las cuotas repercutidas por las operaciones gravadas sean total o parcialmente incobrables.";
|
||||
case TipoFacturaEnum.R4:
|
||||
return "R4 - Factura Rectificativa (Resto)";
|
||||
case TipoFacturaEnum.R5:
|
||||
return "R5 - Factura Rectificativa en facturas simplificadas. Factura emitida en sustitución de facturas simplificadas facturadas y declaradas";
|
||||
default:
|
||||
return "Tipo de factura desconocido";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum TipoFacturaEnum
|
||||
{
|
||||
F1,
|
||||
F2,
|
||||
F3,
|
||||
R1,
|
||||
R2,
|
||||
R3,
|
||||
R4,
|
||||
R5
|
||||
}
|
||||
|
||||
public enum OperacionEnum
|
||||
{
|
||||
|
||||
15
bdAsegasa/Extensiones/regularizacionespagosagentes.cs
Normal file
15
bdAsegasa/Extensiones/regularizacionespagosagentes.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class regularizacionespagosagentes
|
||||
{
|
||||
public enum TipoRegularizacion
|
||||
{
|
||||
DESCOBRO_RECIBO = 1,
|
||||
DEVOLUCION_PAGO_AL_AGENTE = 2,
|
||||
RECALCULO_COMISION = 3,
|
||||
CAMBIADO_DE_AGENTE = 4
|
||||
}
|
||||
|
||||
public string DescripcionTipo => ((TipoRegularizacion)this.Tipo).ToString().Replace("_", " ");
|
||||
}
|
||||
}
|
||||
44
bdAsegasa/Extensiones/seriesfacturas.cs
Normal file
44
bdAsegasa/Extensiones/seriesfacturas.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class seriesfacturas
|
||||
{
|
||||
private static List<string> _ListadoSeries;
|
||||
|
||||
public static List<string> ListadoSeries
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_ListadoSeries == null)
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
_ListadoSeries = bd.seriesfacturas.Select(x => x.Serie).ToList();
|
||||
}
|
||||
return _ListadoSeries;
|
||||
}
|
||||
}
|
||||
|
||||
public string SerieDescripcion
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Serie + " - " + this.Descripcion;
|
||||
}
|
||||
}
|
||||
|
||||
public string DescripcionClase
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((ClaseFacturaEnum)(this.Clase)).ToString().Replace("_", " ");
|
||||
}
|
||||
}
|
||||
|
||||
public enum ClaseFacturaEnum : int
|
||||
{
|
||||
LIQUIDACIONES_A_AGENTES = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
604
bdAsegasa/Extensiones/siniestros.cs
Normal file
604
bdAsegasa/Extensiones/siniestros.cs
Normal file
@@ -0,0 +1,604 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using bdAsegasa.db;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using tsUtilidades.Extensiones;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class siniestros
|
||||
{
|
||||
public int? idPoliza_Nulable
|
||||
{
|
||||
get
|
||||
{
|
||||
if (idPoliza == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return idPoliza;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value.HasValue)
|
||||
{
|
||||
idPoliza = value.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Contrario
|
||||
private bool _CifContrarioTmpEsNulo = true;
|
||||
private string _CifContrarioTmp;
|
||||
public string CifContrarioTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_CifContrarioTmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadContrarioNavigation == null) return "";
|
||||
_CifContrarioTmp = this.idEntidadContrarioNavigation.CIF;
|
||||
_CifContrarioTmpEsNulo = false;
|
||||
return this.idEntidadContrarioNavigation.CIF;
|
||||
}
|
||||
return _CifContrarioTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_CifContrarioTmp = value;
|
||||
_CifContrarioTmpEsNulo = false;
|
||||
if (this.idEntidadContrarioNavigation != null)
|
||||
{
|
||||
this.idEntidadContrarioNavigation.CIF = string.IsNullOrEmpty(value) ? null : value;
|
||||
}
|
||||
OnPropertyChanged("CifContrarioTmp");
|
||||
OnPropertyChanged("RazonSocialContrarioTmp");
|
||||
OnPropertyChanged("CodigoPostalContrarioTmp");
|
||||
OnPropertyChanged("DomicilioContrarioTmp");
|
||||
OnPropertyChanged("CodigoPoblacionContrarioTmp");
|
||||
OnPropertyChanged("PoblacionContrarioTmp");
|
||||
OnPropertyChanged("ProvinciaContrarioTmp");
|
||||
OnPropertyChanged("TelefonoContrario1Tmp");
|
||||
OnPropertyChanged("TelefonoContrario2Tmp");
|
||||
OnPropertyChanged("EmailContrarioTmp");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _RazonSocialContrarioTmpEsNulo = true;
|
||||
private string _RazonSocialContrarioTmp;
|
||||
public string RazonSocialContrarioTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_RazonSocialContrarioTmpEsNulo)
|
||||
{
|
||||
string rs = "";
|
||||
if (string.IsNullOrEmpty(this.idEntidadContrarioNavigation.RazonSocial))
|
||||
{
|
||||
rs = (this.idEntidadContrarioNavigation.Apellidos + ", " + this.idEntidadContrarioNavigation.Nombre).Trim().Trim(',');
|
||||
}
|
||||
else
|
||||
{
|
||||
rs = this.idEntidadContrarioNavigation.RazonSocial;
|
||||
}
|
||||
_RazonSocialContrarioTmpEsNulo = false;
|
||||
_RazonSocialContrarioTmp = rs;
|
||||
return rs;
|
||||
}
|
||||
return _RazonSocialContrarioTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_RazonSocialContrarioTmp = value;
|
||||
_RazonSocialContrarioTmpEsNulo = false;
|
||||
if (this.idEntidadContrarioNavigation != null)
|
||||
{
|
||||
this.idEntidadContrarioNavigation.RazonSocial = value;
|
||||
if (!string.IsNullOrEmpty(this.idEntidadContrarioNavigation.CIF) && "1234567890X".Contains(this.idEntidadContrarioNavigation.CIF.Substring(1, 1)) && value.Contains(","))
|
||||
{
|
||||
var parts = value.Split(',');
|
||||
this.idEntidadContrarioNavigation.Apellidos = parts[0].Trim();
|
||||
if (parts.Length > 1) this.idEntidadContrarioNavigation.Nombre = parts[1].Trim();
|
||||
}
|
||||
}
|
||||
OnPropertyChanged("RazonSocialContrarioTmp");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _CodigoPostalContrarioTmpEsNulo = true;
|
||||
private string _CodigoPostalContrarioTmp;
|
||||
public string CodigoPostalContrarioTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_CodigoPostalContrarioTmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadContrarioNavigation?.DireccionPrincipal == null) return "";
|
||||
_CodigoPostalContrarioTmp = this.idEntidadContrarioNavigation.DireccionPrincipal.CodigoPostal;
|
||||
_CodigoPostalContrarioTmpEsNulo = false;
|
||||
return _CodigoPostalContrarioTmp;
|
||||
}
|
||||
return _CodigoPostalContrarioTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_CodigoPostalContrarioTmp = value;
|
||||
_CodigoPostalContrarioTmpEsNulo = false;
|
||||
if (this.idEntidadContrarioNavigation?.DireccionPrincipal != null)
|
||||
{
|
||||
this.idEntidadContrarioNavigation.DireccionPrincipal.CodigoPostal = value;
|
||||
}
|
||||
OnPropertyChanged("CodigoPostalContrarioTmp");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _DomicilioContrarioTmpEsNulo = true;
|
||||
private string _DomicilioContrarioTmp;
|
||||
public string DomicilioContrarioTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_DomicilioContrarioTmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadContrarioNavigation?.DireccionPrincipal == null) return "";
|
||||
_DomicilioContrarioTmp = this.idEntidadContrarioNavigation.DireccionPrincipal.Direccion;
|
||||
_DomicilioContrarioTmpEsNulo = false;
|
||||
return _DomicilioContrarioTmp;
|
||||
}
|
||||
return _DomicilioContrarioTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_DomicilioContrarioTmp = value;
|
||||
_DomicilioContrarioTmpEsNulo = false;
|
||||
if (this.idEntidadContrarioNavigation?.DireccionPrincipal != null)
|
||||
{
|
||||
this.idEntidadContrarioNavigation.DireccionPrincipal.Direccion = value;
|
||||
}
|
||||
OnPropertyChanged("DomicilioContrarioTmp");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _CodigoPoblacionContrarioTmpEsNulo = true;
|
||||
private string _CodigoPoblacionContrarioTmp;
|
||||
public string CodigoPoblacionContrarioTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_CodigoPoblacionContrarioTmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadContrarioNavigation?.DireccionPrincipal == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
if (this.idEntidadContrarioNavigation.DireccionPrincipal.CodigoMunicipioNavigation == null && !string.IsNullOrEmpty(this.idEntidadContrarioNavigation.DireccionPrincipal.CodigoPostal))
|
||||
{
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var pob = bd.codigospostales.FirstOrDefault(x => x.CodigoPostal == this.idEntidadContrarioNavigation.DireccionPrincipal.CodigoPostal);
|
||||
if (pob != null)
|
||||
{
|
||||
this.idEntidadContrarioNavigation.DireccionPrincipal.CodigoMunicipio = pob.CodigoMunicipio;
|
||||
_CodigoPoblacionContrarioTmp = pob.CodigoMunicipio;
|
||||
_CodigoPoblacionContrarioTmpEsNulo = false;
|
||||
return _CodigoPoblacionContrarioTmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
_CodigoPoblacionContrarioTmp = this.idEntidadContrarioNavigation.DireccionPrincipal.CodigoMunicipio;
|
||||
_CodigoPoblacionContrarioTmpEsNulo = false;
|
||||
return _CodigoPoblacionContrarioTmp;
|
||||
}
|
||||
return _CodigoPoblacionContrarioTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_CodigoPoblacionContrarioTmp = value;
|
||||
_CodigoPoblacionContrarioTmpEsNulo = false;
|
||||
if (this.idEntidadContrarioNavigation?.DireccionPrincipal != null)
|
||||
{
|
||||
this.idEntidadContrarioNavigation.DireccionPrincipal.CodigoMunicipio = value;
|
||||
}
|
||||
OnPropertyChanged("CodigoPoblacionContrarioTmp");
|
||||
OnPropertyChanged("PoblacionContrarioTmp");
|
||||
OnPropertyChanged("ProvinciaContrarioTmp");
|
||||
}
|
||||
}
|
||||
|
||||
public string PoblacionContrarioTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
return municipios.ObtienePoblacion(CodigoPoblacionContrarioTmp);
|
||||
}
|
||||
}
|
||||
public string ProvinciaContrarioTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
return municipios.ObtieneProvincia(CodigoPoblacionContrarioTmp);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _TelefonoContrario1TmpEsNulo = true;
|
||||
private string _TelefonoContrario1Tmp;
|
||||
public string TelefonoContrario1Tmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_TelefonoContrario1TmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadContrarioNavigation == null) return "";
|
||||
_TelefonoContrario1Tmp = this.idEntidadContrarioNavigation.Telefono1;
|
||||
_TelefonoContrario1TmpEsNulo = false;
|
||||
return _TelefonoContrario1Tmp;
|
||||
}
|
||||
return _TelefonoContrario1Tmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_TelefonoContrario1Tmp = value;
|
||||
_TelefonoContrario1TmpEsNulo = false;
|
||||
if (this.idEntidadContrarioNavigation != null) this.idEntidadContrarioNavigation.Telefono1 = value;
|
||||
OnPropertyChanged("TelefonoContrario1Tmp");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _TelefonoContrario2TmpEsNulo = true;
|
||||
private string _TelefonoContrario2Tmp;
|
||||
public string TelefonoContrario2Tmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_TelefonoContrario2TmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadContrarioNavigation == null) return "";
|
||||
_TelefonoContrario2Tmp = this.idEntidadContrarioNavigation.Telefono2;
|
||||
_TelefonoContrario2TmpEsNulo = false;
|
||||
return _TelefonoContrario2Tmp;
|
||||
}
|
||||
return _TelefonoContrario2Tmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_TelefonoContrario2Tmp = value;
|
||||
_TelefonoContrario2TmpEsNulo = false;
|
||||
if (this.idEntidadContrarioNavigation != null) this.idEntidadContrarioNavigation.Telefono2 = value;
|
||||
OnPropertyChanged("TelefonoContrario2Tmp");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _EmailContrarioTmpEsNulo = true;
|
||||
private string _EmailContrarioTmp;
|
||||
public string EmailContrarioTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_EmailContrarioTmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadContrarioNavigation == null) return "";
|
||||
_EmailContrarioTmp = this.idEntidadContrarioNavigation.Email;
|
||||
_EmailContrarioTmpEsNulo = false;
|
||||
return _EmailContrarioTmp;
|
||||
}
|
||||
return _EmailContrarioTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_EmailContrarioTmp = value;
|
||||
_EmailContrarioTmpEsNulo = false;
|
||||
if (this.idEntidadContrarioNavigation != null) this.idEntidadContrarioNavigation.Email = value;
|
||||
OnPropertyChanged("EmailContrarioTmp");
|
||||
}
|
||||
}
|
||||
|
||||
public void ReiniciaValoresTMPContrario()
|
||||
{
|
||||
_CifContrarioTmpEsNulo = true;
|
||||
_RazonSocialContrarioTmpEsNulo = true;
|
||||
_CodigoPoblacionContrarioTmpEsNulo = true;
|
||||
_CodigoPostalContrarioTmpEsNulo = true;
|
||||
_DomicilioContrarioTmpEsNulo = true;
|
||||
_TelefonoContrario1TmpEsNulo = true;
|
||||
_TelefonoContrario2TmpEsNulo = true;
|
||||
_EmailContrarioTmpEsNulo = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Taller
|
||||
private bool _CifTallerTmpEsNulo = true;
|
||||
private string _CifTallerTmp;
|
||||
public string CifTallerTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_CifTallerTmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadTallerNavigation == null) return "";
|
||||
_CifTallerTmp = this.idEntidadTallerNavigation.CIF;
|
||||
_CifTallerTmpEsNulo = false;
|
||||
return _CifTallerTmp;
|
||||
}
|
||||
return _CifTallerTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_CifTallerTmp = value;
|
||||
_CifTallerTmpEsNulo = false;
|
||||
if (this.idEntidadTallerNavigation != null)
|
||||
{
|
||||
this.idEntidadTallerNavigation.CIF = string.IsNullOrEmpty(value) ? null : value;
|
||||
}
|
||||
OnPropertyChanged("CifTallerTmp");
|
||||
OnPropertyChanged("RazonSocialTallerTmp");
|
||||
OnPropertyChanged("CodigoPostalTallerTmp");
|
||||
OnPropertyChanged("DomicilioTallerTmp");
|
||||
OnPropertyChanged("CodigoPoblacionTallerTmp");
|
||||
OnPropertyChanged("PoblacionTallerTmp");
|
||||
OnPropertyChanged("ProvinciaTallerTmp");
|
||||
OnPropertyChanged("TelefonoTallerTmp");
|
||||
OnPropertyChanged("EmailTallerTmp");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _RazonSocialTallerTmpEsNulo = true;
|
||||
private string _RazonSocialTallerTmp;
|
||||
public string RazonSocialTallerTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_RazonSocialTallerTmpEsNulo)
|
||||
{
|
||||
string rs = "";
|
||||
if (string.IsNullOrEmpty(this.idEntidadTallerNavigation.RazonSocial))
|
||||
{
|
||||
rs = (this.idEntidadTallerNavigation.Apellidos + ", " + this.idEntidadTallerNavigation.Nombre).Trim().Trim(',');
|
||||
}
|
||||
else
|
||||
{
|
||||
rs = this.idEntidadTallerNavigation.RazonSocial;
|
||||
}
|
||||
_RazonSocialTallerTmpEsNulo = false;
|
||||
_RazonSocialTallerTmp = rs;
|
||||
return rs;
|
||||
}
|
||||
return _RazonSocialTallerTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_RazonSocialTallerTmp = value;
|
||||
_RazonSocialTallerTmpEsNulo = false;
|
||||
if (this.idEntidadTallerNavigation != null)
|
||||
{
|
||||
this.idEntidadTallerNavigation.RazonSocial = value;
|
||||
if (!string.IsNullOrEmpty(this.idEntidadTallerNavigation.CIF) && "1234567890X".Contains(this.idEntidadTallerNavigation.CIF.Substring(1, 1)) && value.Contains(","))
|
||||
{
|
||||
var parts = value.Split(',');
|
||||
this.idEntidadTallerNavigation.Apellidos = parts[0].Trim();
|
||||
if (parts.Length > 1) this.idEntidadTallerNavigation.Nombre = parts[1].Trim();
|
||||
}
|
||||
}
|
||||
OnPropertyChanged("RazonSocialTallerTmp");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _CodigoPostalTallerTmpEsNulo = true;
|
||||
private string _CodigoPostalTallerTmp;
|
||||
public string CodigoPostalTallerTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_CodigoPostalTallerTmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadTallerNavigation?.DireccionPrincipal == null) return "";
|
||||
_CodigoPostalTallerTmp = this.idEntidadTallerNavigation.DireccionPrincipal.CodigoPostal;
|
||||
_CodigoPostalTallerTmpEsNulo = false;
|
||||
return _CodigoPostalTallerTmp;
|
||||
}
|
||||
return _CodigoPostalTallerTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_CodigoPostalTallerTmp = value;
|
||||
_CodigoPostalTallerTmpEsNulo = false;
|
||||
if (this.idEntidadTallerNavigation?.DireccionPrincipal != null)
|
||||
{
|
||||
this.idEntidadTallerNavigation.DireccionPrincipal.CodigoPostal = value;
|
||||
}
|
||||
OnPropertyChanged("CodigoPostalTallerTmp");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _DomicilioTallerTmpEsNulo = true;
|
||||
private string _DomicilioTallerTmp;
|
||||
public string DomicilioTallerTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_DomicilioTallerTmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadTallerNavigation?.DireccionPrincipal == null) return "";
|
||||
_DomicilioTallerTmp = this.idEntidadTallerNavigation.DireccionPrincipal.Direccion;
|
||||
_DomicilioTallerTmpEsNulo = false;
|
||||
return _DomicilioTallerTmp;
|
||||
}
|
||||
return _DomicilioTallerTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_DomicilioTallerTmp = value;
|
||||
_DomicilioTallerTmpEsNulo = false;
|
||||
if (this.idEntidadTallerNavigation?.DireccionPrincipal != null)
|
||||
{
|
||||
this.idEntidadTallerNavigation.DireccionPrincipal.Direccion = value;
|
||||
}
|
||||
OnPropertyChanged("DomicilioTallerTmp");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _CodigoPoblacionTallerTmpEsNulo = true;
|
||||
private string _CodigoPoblacionTallerTmp;
|
||||
public string CodigoPoblacionTallerTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_CodigoPoblacionTallerTmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadTallerNavigation?.DireccionPrincipal == null) return "";
|
||||
if (this.idEntidadTallerNavigation.DireccionPrincipal.CodigoMunicipioNavigation == null && !string.IsNullOrEmpty(this.idEntidadTallerNavigation.DireccionPrincipal.CodigoPostal))
|
||||
{
|
||||
using (var bd =tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var pob = bd.codigospostales.FirstOrDefault(x => x.CodigoPostal == this.idEntidadTallerNavigation.DireccionPrincipal.CodigoPostal);
|
||||
if (pob != null)
|
||||
{
|
||||
this.idEntidadTallerNavigation.DireccionPrincipal.CodigoMunicipio = pob.CodigoMunicipio;
|
||||
_CodigoPoblacionTallerTmp = pob.CodigoMunicipio;
|
||||
_CodigoPoblacionTallerTmpEsNulo = false;
|
||||
return _CodigoPoblacionTallerTmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
_CodigoPoblacionTallerTmp = this.idEntidadTallerNavigation.DireccionPrincipal.CodigoMunicipio;
|
||||
_CodigoPoblacionTallerTmpEsNulo = false;
|
||||
return _CodigoPoblacionTallerTmp;
|
||||
}
|
||||
return _CodigoPoblacionTallerTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_CodigoPoblacionTallerTmp = value;
|
||||
_CodigoPoblacionTallerTmpEsNulo = false;
|
||||
if (this.idEntidadTallerNavigation?.DireccionPrincipal != null)
|
||||
{
|
||||
this.idEntidadTallerNavigation.DireccionPrincipal.CodigoMunicipio = value;
|
||||
}
|
||||
OnPropertyChanged("CodigoPoblacionTallerTmp");
|
||||
OnPropertyChanged("PoblacionTallerTmp");
|
||||
OnPropertyChanged("ProvinciaTallerTmp");
|
||||
}
|
||||
}
|
||||
|
||||
public string PoblacionTallerTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
return municipios.ObtienePoblacion(CodigoPoblacionTallerTmp);
|
||||
}
|
||||
}
|
||||
public string ProvinciaTallerTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
return municipios.ObtieneProvincia(CodigoPoblacionTallerTmp);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _TelefonoTallerTmpEsNulo = true;
|
||||
private string _TelefonoTallerTmp;
|
||||
public string TelefonoTallerTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_TelefonoTallerTmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadTallerNavigation == null) return "";
|
||||
_TelefonoTallerTmp = this.idEntidadTallerNavigation.Telefono1;
|
||||
_TelefonoTallerTmpEsNulo = false;
|
||||
return _TelefonoTallerTmp;
|
||||
}
|
||||
return _TelefonoTallerTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_TelefonoTallerTmp = value;
|
||||
_TelefonoTallerTmpEsNulo = false;
|
||||
if (this.idEntidadTallerNavigation != null) this.idEntidadTallerNavigation.Telefono1 = value;
|
||||
OnPropertyChanged("TelefonoTallerTmp");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _EmailTallerTmpEsNulo = true;
|
||||
private string _EmailTallerTmp;
|
||||
public string EmailTallerTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_EmailTallerTmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadTallerNavigation == null) return "";
|
||||
_EmailTallerTmp = this.idEntidadTallerNavigation.Email;
|
||||
_EmailTallerTmpEsNulo = false;
|
||||
return _EmailTallerTmp;
|
||||
}
|
||||
return _EmailTallerTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_EmailTallerTmp = value;
|
||||
_EmailTallerTmpEsNulo = false;
|
||||
if (this.idEntidadTallerNavigation != null) this.idEntidadTallerNavigation.Email = value;
|
||||
OnPropertyChanged("EmailTallerTmp");
|
||||
}
|
||||
}
|
||||
|
||||
public void ReiniciaValoresTMPTaller()
|
||||
{
|
||||
_CifTallerTmpEsNulo = true;
|
||||
_RazonSocialTallerTmpEsNulo = true;
|
||||
_CodigoPoblacionTallerTmpEsNulo = true;
|
||||
_CodigoPostalTallerTmpEsNulo = true;
|
||||
_DomicilioTallerTmpEsNulo = true;
|
||||
_TelefonoTallerTmpEsNulo = true;
|
||||
_EmailTallerTmpEsNulo = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static void GuardandoCambios(tscgestionasegasa bd)
|
||||
{
|
||||
var addedEntries = bd.ChangeTracker.Entries<gestionessiniestros>()
|
||||
.Where(e => e.State == EntityState.Added);
|
||||
AsignaidUsuarioCreadorGestionesSiniestros(bd, addedEntries);
|
||||
|
||||
var modifiedEntries = bd.ChangeTracker.Entries<gestionessiniestros>()
|
||||
.Where(e => e.State == EntityState.Modified);
|
||||
AsignaidUsuarioModificadorGestionesSiniestros(bd, modifiedEntries);
|
||||
}
|
||||
|
||||
private static void AsignaidUsuarioCreadorGestionesSiniestros(tscgestionasegasa bd, IEnumerable<Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<gestionessiniestros>> entries)
|
||||
{
|
||||
if (entries.Any() && bdAsegasa.db.Utilidades.dsc.idUsuario > 0)
|
||||
{
|
||||
var ahora = DateTime.Now;
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
var r = entry.Entity;
|
||||
r.idUsuarioCreador = bdAsegasa.db.Utilidades.dsc.idUsuario;
|
||||
r.idUsuarioModificador = bdAsegasa.db.Utilidades.dsc.idUsuario;
|
||||
r.FechaModificacion = ahora;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void AsignaidUsuarioModificadorGestionesSiniestros(tscgestionasegasa bd, IEnumerable<Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<gestionessiniestros>> entries)
|
||||
{
|
||||
if (entries.Any() && bdAsegasa.db.Utilidades.dsc.idUsuario > 0)
|
||||
{
|
||||
var ahora = DateTime.Now;
|
||||
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
var r = entry.Entity;
|
||||
r.idUsuarioModificador = bdAsegasa.db.Utilidades.dsc.idUsuario;
|
||||
r.FechaModificacion = ahora;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
41
bdAsegasa/Extensiones/siniestros_eiac.cs
Normal file
41
bdAsegasa/Extensiones/siniestros_eiac.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class siniestros_eiac
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
public enum ClavesPosicionSiniestroEnum : int
|
||||
{
|
||||
CULPA = 1,
|
||||
RECLAMACIÓN = 2,
|
||||
INDETERMINADO = 3,
|
||||
NO_APLICA = 4,
|
||||
DESCONOCIDA = 99
|
||||
}
|
||||
|
||||
|
||||
|
||||
public enum SituacionAsegasaENUM : int
|
||||
{
|
||||
NUEVO = 1,
|
||||
MODIFICADO = 2,
|
||||
POLIZA_NO_ENCONTRADA = 10,
|
||||
SINIESTRO_NO_ENCONTRADO = 11,
|
||||
VARIOS_SINIESTROS_POSIBLES = 12,
|
||||
VISUALIZADO = 100,
|
||||
DESCARTADO = 200
|
||||
}
|
||||
|
||||
public string DescripcionPosicionSiniestro => ((ClavesPosicionSiniestroEnum)(this.PosicionSiniestro)).ToString().Replace("_", " ");
|
||||
|
||||
|
||||
public string DescripcionSituacionAsegasa => this.SituacionAsegasa.HasValue
|
||||
? ((SituacionAsegasaENUM)this.SituacionAsegasa.Value).ToString().Replace("_", " ")
|
||||
: "";
|
||||
}
|
||||
}
|
||||
56
bdAsegasa/Extensiones/subagentes.cs
Normal file
56
bdAsegasa/Extensiones/subagentes.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using bdAsegasa.dbcontext;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class subagentes
|
||||
{
|
||||
private static List<subagentes> _ListaSubagentes;
|
||||
|
||||
public bool AMarcarComoBaja { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public List<polizassg> PolizasConDocumentosPendientes
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.polizassg.Where(x => x.documentospolizassg.Any(y => y.Obligatorio && y.FechaComprobacion == null && y.idFichero == null)).ToList();
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public List<polizassg> PolizasConDocumentosPendientes7Dias
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
|
||||
|
||||
DateTime FechaInicio = DateTime.Today.AddDays(-7);
|
||||
return this.polizassg.Where(x => x.FechaAlta >= FechaInicio).ToList().Where(x => x.documentospolizassg.Any(y => y.Obligatorio && y.FechaComprobacion == null && y.idFichero == null)).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<subagentes> ListaSubAgentes()
|
||||
{
|
||||
if (_ListaSubagentes == null)
|
||||
{
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
_ListaSubagentes = bd.subagentes.OrderBy(x => x.Nombre).ToList();
|
||||
}
|
||||
}
|
||||
return _ListaSubagentes;
|
||||
}
|
||||
|
||||
public string CodigoYNombre
|
||||
{
|
||||
get
|
||||
{
|
||||
return Codigo + " - " + Nombre;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
18
bdAsegasa/Extensiones/tiposgestionsiniestros.cs
Normal file
18
bdAsegasa/Extensiones/tiposgestionsiniestros.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class tiposgestionsiniestros
|
||||
{
|
||||
public string DescripcionDetallada
|
||||
{
|
||||
get
|
||||
{
|
||||
string s = $"{this.Descripcion} *{this.Codigo} * ";
|
||||
if (this.idDestinatario.HasValue)
|
||||
{
|
||||
s += $"(DESTINATARIO: {this.idDestinatarioNavigation?.Descripcion})";
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
127
bdAsegasa/Extensiones/ve_recibos.cs
Normal file
127
bdAsegasa/Extensiones/ve_recibos.cs
Normal file
@@ -0,0 +1,127 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using tsUtilidades;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public class ve_recibos
|
||||
{
|
||||
public int idRecibo { get; set; }
|
||||
public int idPoliza { get; set; }
|
||||
public DateOnly? FechaFacturacion { get; set; }
|
||||
public DateOnly? FechaPago { get; set; }
|
||||
public string CodigoRecibo { get; set; }
|
||||
public string NumeroPoliza { get; set; }
|
||||
public string Tomador { get; set; }
|
||||
public string CIFTomador { get; set; }
|
||||
public string Telefono1Tomador { get; set; }
|
||||
public string Telefono2Tomador { get; set; }
|
||||
public string Matricula { get; set; }
|
||||
public DateOnly FechaEfecto { get; set; }
|
||||
public DateOnly? FechaRecepcionCia { get; set; }
|
||||
public DateOnly FechaVencimiento { get; set; }
|
||||
public string Compania { get; set; }
|
||||
public string Agente { get; set; }
|
||||
public string SubAgente { get; set; }
|
||||
public string Ramo { get; set; }
|
||||
public DateOnly? FechaExpedicion { get; set; }
|
||||
|
||||
public string BienesAsegurados { get; set; }
|
||||
public DateOnly? FechaBaja { get; set; }
|
||||
public DateOnly? FechaDevolucionBanco { get; set; }
|
||||
public string CausaBaja { get; set; }
|
||||
public string TipoRecibo { get; set; }
|
||||
public string TipoPago { get; set; }
|
||||
public string Oficina { get; set; }
|
||||
public double? PrimaNeta { get; set; }
|
||||
public double? BonificacionORecargo { get; set; }
|
||||
public double? Consorcio { get; set; }
|
||||
public double? Impuesto { get; set; }
|
||||
public double? RecargoExterno { get; set; }
|
||||
public double? TotalRecibo { get; set; }
|
||||
public double? ComisionReciboPrimaNeta { get; set; }
|
||||
public double? PorcentajeReciboPrimaNeta { get; set; }
|
||||
public double? TotalComision { get; set; }
|
||||
public double? SobreComision { get; set; }
|
||||
public double? PorcentajeComisionAgente { get; set; }
|
||||
public double? ComisionAgente { get; set; }
|
||||
public double? ComisionAsegasaPrimaNeta { get; set; }
|
||||
public double? AsegasaRecargoExterno { get; set; }
|
||||
public double? AsegasaComisionConsorcio { get; set; }
|
||||
public double? AsegasaComisionTotal { get; set; }
|
||||
public double? ComisionPrevista { get; set; }
|
||||
|
||||
public double DiferenciaComision
|
||||
{
|
||||
get
|
||||
{
|
||||
double crpn = ComisionReciboPrimaNeta ?? 0;
|
||||
double cp = ComisionPrevista ?? 0;
|
||||
return Math.Round(crpn - cp, 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
|
||||
public int? idSituacion { get; set; }
|
||||
public DateOnly? FechaLiquidacionAgente { get; set; }
|
||||
public DateOnly? FechaLiquidacionCia { get; set; }
|
||||
public DateOnly? FechaLiquidacionCiaDevuelto { get; set; }
|
||||
|
||||
public static int? idSitr1 = null;
|
||||
public bool BloquearFacturacion
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!idSitr1.HasValue)
|
||||
{
|
||||
using (var bd = bdAsegasa.tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
idSitr1 = bd.enumeraciones.FirstOrDefault(x => x.Codigo == "SITR.1")?.idEnumeracion;
|
||||
}
|
||||
}
|
||||
return idSituacion.HasValue && idSituacion.Value == idSitr1;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!idSitr1.HasValue)
|
||||
{
|
||||
using (var bd = bdAsegasa.tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
idSitr1 = bd.enumeraciones.FirstOrDefault(x => x.Codigo == "SITR.1")?.idEnumeracion;
|
||||
}
|
||||
}
|
||||
if (value)
|
||||
{
|
||||
idSituacion = idSitr1;
|
||||
}
|
||||
else
|
||||
{
|
||||
idSituacion = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string TelefonoMovilValido
|
||||
{
|
||||
get
|
||||
{
|
||||
if (tsUtilidades.Extensiones.StringExtensions.EsNumeroTelefonoMovilEspañolValido(Telefono1Tomador))
|
||||
{
|
||||
return Telefono1Tomador;
|
||||
}
|
||||
else if (tsUtilidades.Extensiones.StringExtensions.EsNumeroTelefonoMovilEspañolValido(Telefono2Tomador))
|
||||
{
|
||||
return Telefono2Tomador;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Observaciones { get; set; }
|
||||
public string ObservacionesPoliza { get; set; }
|
||||
public DateOnly? FechaRemesa { get; set; }
|
||||
}
|
||||
}
|
||||
324
bdAsegasa/Extensiones/vf_cuentas.cs
Normal file
324
bdAsegasa/Extensiones/vf_cuentas.cs
Normal file
@@ -0,0 +1,324 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using tsUtilidades.Extensiones;
|
||||
using System.Linq.Dynamic.Core;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class vf_cuentas
|
||||
{
|
||||
public static List<vf_cuentas> Obtiene_vf_cuentas(gestionasegasaEntities bd, int idEjercicio, int Nivel)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<vf_cuentas> lc;
|
||||
var ctasintermedias = bd.cuentas.Where(x => !x.EsCuentaFinal && x.idEjercicio == idEjercicio && x.NumeroCuenta.Length <= Nivel).ToList();
|
||||
var ctasf = bd.vf_cuentas.Where(x => x.idEjercicio == idEjercicio).ToList();
|
||||
|
||||
if (Nivel == 8)
|
||||
{
|
||||
lc = ctasf;
|
||||
}
|
||||
else
|
||||
{
|
||||
lc = new List<vf_cuentas>();
|
||||
foreach (var cta in ctasintermedias.Where(x => x.Nivel == Nivel))
|
||||
{
|
||||
var sumatorio = ctasf.Where(x => x.NumeroCuenta.StartsWith(cta.NumeroCuenta));
|
||||
var nc = new vf_cuentas();
|
||||
nc.idCuenta = cta.idCuenta;
|
||||
nc.idEjercicio = cta.idEjercicio;
|
||||
nc.Mote = cta.Mote;
|
||||
nc.Denominacion = cta.Denominacion;
|
||||
nc.idEmpresaAmortizacion = cta.idEmpresaAmortizacion;
|
||||
nc.NumeroCuenta = cta.NumeroCuenta;
|
||||
nc.Observaciones = cta.Observaciones;
|
||||
|
||||
nc.PresupuestoEnero = Math.Round(sumatorio.Sum(x => x.PresupuestoEnero), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoFebrero = Math.Round(sumatorio.Sum(x => x.PresupuestoFebrero), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoMarzo = Math.Round(sumatorio.Sum(x => x.PresupuestoMarzo), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoAbril = Math.Round(sumatorio.Sum(x => x.PresupuestoAbril), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoMayo = Math.Round(sumatorio.Sum(x => x.PresupuestoMayo), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoJunio = Math.Round(sumatorio.Sum(x => x.PresupuestoJunio), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoJulio = Math.Round(sumatorio.Sum(x => x.PresupuestoJulio), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoAgosto = Math.Round(sumatorio.Sum(x => x.PresupuestoAgosto), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoSeptiembre = Math.Round(sumatorio.Sum(x => x.PresupuestoSeptiembre), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoOctubre = Math.Round(sumatorio.Sum(x => x.PresupuestoOctubre), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoNoviembre = Math.Round(sumatorio.Sum(x => x.PresupuestoNoviembre), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoDiciembre = Math.Round(sumatorio.Sum(x => x.PresupuestoDiciembre), 2, MidpointRounding.AwayFromZero);
|
||||
|
||||
nc.DebeEnero = Math.Round(sumatorio.Sum(x => x.DebeEnero.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeFebrero = Math.Round(sumatorio.Sum(x => x.DebeFebrero.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeMarzo = Math.Round(sumatorio.Sum(x => x.DebeMarzo.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeAbril = Math.Round(sumatorio.Sum(x => x.DebeAbril.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeMayo = Math.Round(sumatorio.Sum(x => x.DebeMayo.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeJunio = Math.Round(sumatorio.Sum(x => x.DebeJunio.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeJulio = Math.Round(sumatorio.Sum(x => x.DebeJulio.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeAgosto = Math.Round(sumatorio.Sum(x => x.DebeAgosto.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeSeptiembre = Math.Round(sumatorio.Sum(x => x.DebeSeptiembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeOctubre = Math.Round(sumatorio.Sum(x => x.DebeOctubre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeNoviembre = Math.Round(sumatorio.Sum(x => x.DebeNoviembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeDiciembre = Math.Round(sumatorio.Sum(x => x.DebeDiciembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
|
||||
nc.HaberEnero = Math.Round(sumatorio.Sum(x => x.HaberEnero.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberFebrero = Math.Round(sumatorio.Sum(x => x.HaberFebrero.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberMarzo = Math.Round(sumatorio.Sum(x => x.HaberMarzo.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberAbril = Math.Round(sumatorio.Sum(x => x.HaberAbril.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberMayo = Math.Round(sumatorio.Sum(x => x.HaberMayo.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberJunio = Math.Round(sumatorio.Sum(x => x.HaberJunio.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberJulio = Math.Round(sumatorio.Sum(x => x.HaberJulio.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberAgosto = Math.Round(sumatorio.Sum(x => x.HaberAgosto.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberSeptiembre = Math.Round(sumatorio.Sum(x => x.HaberSeptiembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberOctubre = Math.Round(sumatorio.Sum(x => x.HaberOctubre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberNoviembre = Math.Round(sumatorio.Sum(x => x.HaberNoviembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberDiciembre = Math.Round(sumatorio.Sum(x => x.HaberDiciembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
|
||||
nc.TotalDebe = Math.Round(sumatorio.Sum(x => x.TotalDebe), 2, MidpointRounding.AwayFromZero);
|
||||
nc.TotalHaber = Math.Round(sumatorio.Sum(x => x.TotalHaber), 2, MidpointRounding.AwayFromZero);
|
||||
lc.Add(nc);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var cta in lc)
|
||||
{
|
||||
try
|
||||
{
|
||||
var cta1 = ctasintermedias.First(x => x.NumeroCuenta == cta.NumeroCuenta.Substring(0, 1));
|
||||
cta.Grupo1 = cta1.NumeroCuenta + " " + cta1.Denominacion;
|
||||
if (cta.Nivel > 1)
|
||||
{
|
||||
var cta2 = ctasintermedias.First(x => x.NumeroCuenta == cta.NumeroCuenta.Substring(0, 2));
|
||||
cta.Grupo2 = cta2.NumeroCuenta + " " + cta2.Denominacion;
|
||||
if (cta.Nivel > 2)
|
||||
{
|
||||
var cta3 = ctasintermedias.First(x => x.NumeroCuenta == cta.NumeroCuenta.Substring(0, 3));
|
||||
cta.Grupo3 = cta3.NumeroCuenta + " " + cta3.Denominacion;
|
||||
if (cta.Nivel > 3)
|
||||
{
|
||||
var cta4 = ctasintermedias.First(x => x.NumeroCuenta == cta.NumeroCuenta.Substring(0, 4));
|
||||
cta.Grupo4 = cta4.NumeroCuenta + " " + cta4.Denominacion;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Error obteniendo cuentas intermedia de la cuenta " + cta.NumeroCuenta + " " + ex.Message, ex);
|
||||
}
|
||||
}
|
||||
return lc;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<vf_cuentas> Obtiene_vf_cuentas(gestionasegasaEntities bd, int[] Ejercicios, int Nivel, string ExpresionBusqueda)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<vf_cuentas> lc;
|
||||
IQueryable<cuentas> qCtasIntermedias = bd.cuentas.Where(x => !x.EsCuentaFinal && Ejercicios.Contains(x.idEjercicio) && x.NumeroCuenta.Length <= Nivel);
|
||||
IQueryable<vf_cuentas> qcastf;
|
||||
|
||||
if (string.IsNullOrEmpty(ExpresionBusqueda))
|
||||
{
|
||||
qcastf = bd.vf_cuentas.AsQueryable();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Using System.Linq.Dynamic.Core for dynamic filtering
|
||||
qcastf = bd.vf_cuentas.Where(ExpresionBusqueda);
|
||||
if (Nivel < 8)
|
||||
{
|
||||
string expr = $"NumeroCuenta.Length<{Nivel} or ({ExpresionBusqueda})";
|
||||
qCtasIntermedias = qCtasIntermedias.Where(expr);
|
||||
}
|
||||
}
|
||||
|
||||
var ctasintermedias = qCtasIntermedias.ToList();
|
||||
var ctasf = qcastf.Where(x => Ejercicios.Contains(x.idEjercicio)).ToList();
|
||||
|
||||
if (Nivel == 8)
|
||||
{
|
||||
lc = ctasf;
|
||||
}
|
||||
else
|
||||
{
|
||||
lc = new List<vf_cuentas>();
|
||||
foreach (var cta in ctasintermedias.Where(x => x.Nivel == Nivel))
|
||||
{
|
||||
var sumatorio = ctasf.Where(x => x.idEjercicio == cta.idEjercicio && x.NumeroCuenta.StartsWith(cta.NumeroCuenta));
|
||||
var nc = new vf_cuentas();
|
||||
nc.idCuenta = cta.idCuenta;
|
||||
nc.idEjercicio = cta.idEjercicio;
|
||||
nc.Mote = cta.Mote;
|
||||
nc.Denominacion = cta.Denominacion;
|
||||
nc.idEmpresaAmortizacion = cta.idEmpresaAmortizacion;
|
||||
nc.NumeroCuenta = cta.NumeroCuenta;
|
||||
nc.Observaciones = cta.Observaciones;
|
||||
|
||||
nc.PresupuestoEnero = Math.Round(sumatorio.Sum(x => x.PresupuestoEnero), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoFebrero = Math.Round(sumatorio.Sum(x => x.PresupuestoFebrero), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoMarzo = Math.Round(sumatorio.Sum(x => x.PresupuestoMarzo), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoAbril = Math.Round(sumatorio.Sum(x => x.PresupuestoAbril), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoMayo = Math.Round(sumatorio.Sum(x => x.PresupuestoMayo), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoJunio = Math.Round(sumatorio.Sum(x => x.PresupuestoJunio), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoJulio = Math.Round(sumatorio.Sum(x => x.PresupuestoJulio), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoAgosto = Math.Round(sumatorio.Sum(x => x.PresupuestoAgosto), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoSeptiembre = Math.Round(sumatorio.Sum(x => x.PresupuestoSeptiembre), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoOctubre = Math.Round(sumatorio.Sum(x => x.PresupuestoOctubre), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoNoviembre = Math.Round(sumatorio.Sum(x => x.PresupuestoNoviembre), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoDiciembre = Math.Round(sumatorio.Sum(x => x.PresupuestoDiciembre), 2, MidpointRounding.AwayFromZero);
|
||||
|
||||
nc.DebeEnero = Math.Round(sumatorio.Sum(x => x.DebeEnero.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeFebrero = Math.Round(sumatorio.Sum(x => x.DebeFebrero.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeMarzo = Math.Round(sumatorio.Sum(x => x.DebeMarzo.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeAbril = Math.Round(sumatorio.Sum(x => x.DebeAbril.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeMayo = Math.Round(sumatorio.Sum(x => x.DebeMayo.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeJunio = Math.Round(sumatorio.Sum(x => x.DebeJunio.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeJulio = Math.Round(sumatorio.Sum(x => x.DebeJulio.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeAgosto = Math.Round(sumatorio.Sum(x => x.DebeAgosto.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeSeptiembre = Math.Round(sumatorio.Sum(x => x.DebeSeptiembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeOctubre = Math.Round(sumatorio.Sum(x => x.DebeOctubre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeNoviembre = Math.Round(sumatorio.Sum(x => x.DebeNoviembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeDiciembre = Math.Round(sumatorio.Sum(x => x.DebeDiciembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
|
||||
nc.HaberEnero = Math.Round(sumatorio.Sum(x => x.HaberEnero.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberFebrero = Math.Round(sumatorio.Sum(x => x.HaberFebrero.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberMarzo = Math.Round(sumatorio.Sum(x => x.HaberMarzo.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberAbril = Math.Round(sumatorio.Sum(x => x.HaberAbril.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberMayo = Math.Round(sumatorio.Sum(x => x.HaberMayo.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberJunio = Math.Round(sumatorio.Sum(x => x.HaberJunio.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberJulio = Math.Round(sumatorio.Sum(x => x.HaberJulio.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberAgosto = Math.Round(sumatorio.Sum(x => x.HaberAgosto.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberSeptiembre = Math.Round(sumatorio.Sum(x => x.HaberSeptiembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberOctubre = Math.Round(sumatorio.Sum(x => x.HaberOctubre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberNoviembre = Math.Round(sumatorio.Sum(x => x.HaberNoviembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberDiciembre = Math.Round(sumatorio.Sum(x => x.HaberDiciembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
|
||||
nc.TotalDebe = Math.Round(sumatorio.Sum(x => x.TotalDebe), 2, MidpointRounding.AwayFromZero);
|
||||
nc.TotalHaber = Math.Round(sumatorio.Sum(x => x.TotalHaber), 2, MidpointRounding.AwayFromZero);
|
||||
lc.Add(nc);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var cta in lc)
|
||||
{
|
||||
try
|
||||
{
|
||||
var cta1 = ctasintermedias.First(x => x.NumeroCuenta == cta.NumeroCuenta.Substring(0, 1) && x.idEjercicio == cta.idEjercicio);
|
||||
cta.Grupo1 = cta1.NumeroCuenta + " " + cta1.Denominacion;
|
||||
if (cta.Nivel > 1)
|
||||
{
|
||||
var cta2 = ctasintermedias.First(x => x.NumeroCuenta == cta.NumeroCuenta.Substring(0, 2) && x.idEjercicio == cta.idEjercicio);
|
||||
cta.Grupo2 = cta2.NumeroCuenta + " " + cta2.Denominacion;
|
||||
if (cta.Nivel > 2)
|
||||
{
|
||||
var cta3 = ctasintermedias.First(x => x.NumeroCuenta == cta.NumeroCuenta.Substring(0, 3) && x.idEjercicio == cta.idEjercicio);
|
||||
cta.Grupo3 = cta3.NumeroCuenta + " " + cta3.Denominacion;
|
||||
if (cta.Nivel > 3)
|
||||
{
|
||||
var cta4 = ctasintermedias.First(x => x.NumeroCuenta == cta.NumeroCuenta.Substring(0, 4) && x.idEjercicio == cta.idEjercicio);
|
||||
cta.Grupo4 = cta4.NumeroCuenta + " " + cta4.Denominacion;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Error obteniendo cuentas intermedia de la cuenta " + cta.NumeroCuenta + " " + ex.Message, ex);
|
||||
}
|
||||
}
|
||||
return lc;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public string Grupo1 { get; set; }
|
||||
public string Grupo2 { get; set; }
|
||||
public string Grupo3 { get; set; }
|
||||
public string Grupo4 { get; set; }
|
||||
|
||||
public int Nivel => NumeroCuenta.Length;
|
||||
|
||||
#region Saldos
|
||||
public double SaldoEnero => Math.Round(DebeEnero.NothingA0() - HaberEnero.NothingA0(), 2, MidpointRounding.AwayFromZero);
|
||||
public double SaldoFebrero => Math.Round(DebeFebrero.NothingA0() - HaberFebrero.NothingA0(), 2, MidpointRounding.AwayFromZero);
|
||||
public double SaldoMarzo => Math.Round(DebeMarzo.NothingA0() - HaberMarzo.NothingA0(), 2, MidpointRounding.AwayFromZero);
|
||||
public double SaldoAbril => Math.Round(DebeAbril.NothingA0() - HaberAbril.NothingA0(), 2, MidpointRounding.AwayFromZero);
|
||||
public double SaldoMayo => Math.Round(DebeMayo.NothingA0() - HaberMayo.NothingA0(), 2, MidpointRounding.AwayFromZero);
|
||||
public double SaldoJunio => Math.Round(DebeJunio.NothingA0() - HaberJunio.NothingA0(), 2, MidpointRounding.AwayFromZero);
|
||||
public double SaldoJulio => Math.Round(DebeJulio.NothingA0() - HaberJulio.NothingA0(), 2, MidpointRounding.AwayFromZero);
|
||||
public double SaldoAgosto => Math.Round(DebeAgosto.NothingA0() - HaberAgosto.NothingA0(), 2, MidpointRounding.AwayFromZero);
|
||||
public double SaldoSeptiembre => Math.Round(DebeSeptiembre.NothingA0() - HaberSeptiembre.NothingA0(), 2, MidpointRounding.AwayFromZero);
|
||||
public double SaldoOctubre => Math.Round(DebeOctubre.NothingA0() - HaberOctubre.NothingA0(), 2, MidpointRounding.AwayFromZero);
|
||||
public double SaldoNoviembre => Math.Round(DebeNoviembre.NothingA0() - HaberNoviembre.NothingA0(), 2, MidpointRounding.AwayFromZero);
|
||||
public double SaldoDiciembre => Math.Round(DebeDiciembre.NothingA0() - HaberDiciembre.NothingA0(), 2, MidpointRounding.AwayFromZero);
|
||||
public double TotalSaldo => Math.Round(TotalDebe - TotalHaber, 2, MidpointRounding.AwayFromZero);
|
||||
#endregion
|
||||
|
||||
#region Presupuestos
|
||||
public double TotalPresupuestado => Math.Round(PresupuestoEnero + PresupuestoFebrero + PresupuestoMarzo + PresupuestoAbril + PresupuestoMayo + PresupuestoJunio + PresupuestoJulio + PresupuestoAgosto + PresupuestoSeptiembre + PresupuestoOctubre + PresupuestoNoviembre + PresupuestoDiciembre, 2, MidpointRounding.AwayFromZero);
|
||||
public void ActualizaTotalPresupuestado() => OnPropertyChanged("TotalPresupuestado");
|
||||
|
||||
public double DesvioPresupuestoEnero => CalculoDesvio(PresupuestoEnero, SaldoEnero);
|
||||
public double DesvioPresupuestoFebrero => CalculoDesvio(PresupuestoFebrero, SaldoFebrero);
|
||||
public double DesvioPresupuestoMarzo => CalculoDesvio(PresupuestoMarzo, SaldoMarzo);
|
||||
public double DesvioPresupuestoAbril => CalculoDesvio(PresupuestoAbril, SaldoAbril);
|
||||
public double DesvioPresupuestoMayo => CalculoDesvio(PresupuestoMayo, SaldoMayo);
|
||||
public double DesvioPresupuestoJunio => CalculoDesvio(PresupuestoJunio, SaldoJunio);
|
||||
public double DesvioPresupuestoJulio => CalculoDesvio(PresupuestoJulio, SaldoJulio);
|
||||
public double DesvioPresupuestoAgosto => CalculoDesvio(PresupuestoAgosto, SaldoAgosto);
|
||||
public double DesvioPresupuestoSeptiembre => CalculoDesvio(PresupuestoSeptiembre, SaldoSeptiembre);
|
||||
public double DesvioPresupuestoOctubre => CalculoDesvio(PresupuestoOctubre, SaldoOctubre);
|
||||
public double DesvioPresupuestoNoviembre => CalculoDesvio(PresupuestoNoviembre, SaldoNoviembre);
|
||||
public double DesvioPresupuestoDiciembre => CalculoDesvio(PresupuestoDiciembre, SaldoDiciembre);
|
||||
public double DesvioPresupuestoTotal => CalculoDesvio(TotalPresupuestado, TotalSaldo);
|
||||
|
||||
private double CalculoDesvio(double presupuesto, double saldo)
|
||||
{
|
||||
if (string.IsNullOrEmpty(NumeroCuenta)) return 0;
|
||||
char first = NumeroCuenta[0];
|
||||
if (first == '6' || first == '7')
|
||||
{
|
||||
return Math.Round(Math.Abs(presupuesto) - Math.Abs(saldo), 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double PorcentajeDesvioPresupuestoEnero => CalculoPorcentajeDesvio(DesvioPresupuestoEnero, SaldoEnero);
|
||||
public double PorcentajeDesvioPresupuestoFebrero => CalculoPorcentajeDesvio(DesvioPresupuestoFebrero, SaldoFebrero);
|
||||
public double PorcentajeDesvioPresupuestoMarzo => CalculoPorcentajeDesvio(DesvioPresupuestoMarzo, SaldoMarzo);
|
||||
public double PorcentajeDesvioPresupuestoAbril => CalculoPorcentajeDesvio(DesvioPresupuestoAbril, SaldoAbril);
|
||||
public double PorcentajeDesvioPresupuestoMayo => CalculoPorcentajeDesvio(DesvioPresupuestoMayo, SaldoMayo);
|
||||
public double PorcentajeDesvioPresupuestoJunio => CalculoPorcentajeDesvio(DesvioPresupuestoJunio, SaldoJunio);
|
||||
public double PorcentajeDesvioPresupuestoJulio => CalculoPorcentajeDesvio(DesvioPresupuestoJulio, SaldoJulio);
|
||||
public double PorcentajeDesvioPresupuestoAgosto => CalculoPorcentajeDesvio(DesvioPresupuestoAgosto, SaldoAgosto);
|
||||
public double PorcentajeDesvioPresupuestoSeptiembre => CalculoPorcentajeDesvio(DesvioPresupuestoSeptiembre, SaldoSeptiembre);
|
||||
public double PorcentajeDesvioPresupuestoOctubre => CalculoPorcentajeDesvio(DesvioPresupuestoOctubre, SaldoOctubre);
|
||||
public double PorcentajeDesvioPresupuestoNoviembre => CalculoPorcentajeDesvio(DesvioPresupuestoNoviembre, SaldoNoviembre);
|
||||
public double PorcentajeDesvioPresupuestoDiciembre => CalculoPorcentajeDesvio(DesvioPresupuestoDiciembre, SaldoDiciembre);
|
||||
public double PorcentajeDesvioPresupuestoTotal => CalculoPorcentajeDesvio(DesvioPresupuestoTotal, TotalSaldo);
|
||||
|
||||
private double CalculoPorcentajeDesvio(double desvio, double saldo)
|
||||
{
|
||||
if (saldo == 0)
|
||||
{
|
||||
if (desvio < 0) return -100;
|
||||
if (desvio > 0) return 100;
|
||||
return 0;
|
||||
}
|
||||
return Math.Round(desvio * 100 / saldo, 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
41
bdAsegasa/Extensiones/vf_documentospolizassgextendidas.cs
Normal file
41
bdAsegasa/Extensiones/vf_documentospolizassgextendidas.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class vf_documentospolizassgextendidas
|
||||
{
|
||||
public bool FicheroModificado_TMP { get; set; }
|
||||
public byte[] Fichero_TMP { get; set; }
|
||||
|
||||
public bool DocumentoComprobado
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.FechaComprobacion.HasValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
this.FechaComprobacion = DateTime.Now;
|
||||
this.idUsuarioComprueba = Utilidades.idUsuario;
|
||||
this.UsuarioComprueba = Utilidades.NombreUsuario;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.FechaComprobacion = null;
|
||||
this.idUsuarioComprueba = null;
|
||||
this.UsuarioComprueba = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string DescripcionTipo
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((documentospolizassg.TipoDocumentoEnum)(this.Tipo)).ToString().Replace("_", " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
19
bdAsegasa/Extensiones/vf_liquidacionesagentesverifactu.cs
Normal file
19
bdAsegasa/Extensiones/vf_liquidacionesagentesverifactu.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class vf_liquidacionesagentesverifactu
|
||||
{
|
||||
public string DescripcionEstadoVerifactu => EstadoVerifactu.ToString().Replace("_", " ");
|
||||
|
||||
public liquidacionesagentes.EstadoVerifactuEnum EstadoVerifactu
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.Estado.HasValue)
|
||||
{
|
||||
return (liquidacionesagentes.EstadoVerifactuEnum)this.Estado.Value;
|
||||
}
|
||||
return liquidacionesagentes.EstadoVerifactuEnum.SIN_REGISTROS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
15
bdAsegasa/Extensiones/vf_liquidacionesciasextendidas.cs
Normal file
15
bdAsegasa/Extensiones/vf_liquidacionesciasextendidas.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class vf_liquidacionesciasextendidas
|
||||
{
|
||||
public string Compañia
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.NumeroCias == 0) return "";
|
||||
if (this.NumeroCias == 1) return this.Cia;
|
||||
return "Varias";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
32
bdAsegasa/Extensiones/vf_liquidacionesrecibosextendidas.cs
Normal file
32
bdAsegasa/Extensiones/vf_liquidacionesrecibosextendidas.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class vf_liquidacionesrecibosextendidas
|
||||
{
|
||||
public string EsDescobro
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.DescripcionTipoLiquidacion = "DESCOBRO";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public double LiquidoCia
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Round(this.TotalRecibo.Value - this.TotalComision.Value, 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
|
||||
public string LiquidacionTipo
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.idLiquidacionCia.ToString + " " + this.DescripcionTipoLiquidacion;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
106
bdAsegasa/Extensiones/vf_polizasextendidas.cs
Normal file
106
bdAsegasa/Extensiones/vf_polizasextendidas.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class vf_polizasextendidas
|
||||
{
|
||||
public string NumeroSuplemento_String
|
||||
{
|
||||
get
|
||||
{
|
||||
if(this.NumeroSuplemento == 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return NumeroSuplemento.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Situacion_Web
|
||||
{
|
||||
get
|
||||
{
|
||||
return gestionasegasaEntities.ObtieneSituacionWeb(this.idSituacion, this.idTipoPago);
|
||||
}
|
||||
}
|
||||
public string CiaNumeroPoliza
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Compania + "/" + this.NumeroPoliza;
|
||||
}
|
||||
}
|
||||
|
||||
public int? EdadTomador
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.FechaNacimientoTomador.HasValue)
|
||||
{
|
||||
DateOnly hoy = DateOnly.FromDateTime(DateTime.Now);
|
||||
|
||||
return (int)((hoy.Year - this.FechaNacimientoTomador.Value.Year));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public string TelefonoMovilValido
|
||||
{
|
||||
get
|
||||
{
|
||||
if (tsUtilidades.Extensiones.StringExtensions.EsNumeroTelefonoMovilEspañolValido(this.Telefono1Tomador))
|
||||
{
|
||||
return this.Telefono1Tomador;
|
||||
}
|
||||
else if (tsUtilidades.Extensiones.StringExtensions.EsNumeroTelefonoMovilEspañolValido(this.Telefono2Tomador))
|
||||
{
|
||||
return this.Telefono2Tomador;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ListadoReducido AListadoReducido() => new ListadoReducido(this);
|
||||
}
|
||||
|
||||
public class ListadoReducido
|
||||
{
|
||||
public ListadoReducido(vf_polizasextendidas p)
|
||||
{
|
||||
NumeroPropuesta = p.idPoliza;
|
||||
FechaAlta = p.FechaAlta;
|
||||
NumeroPóliza = p.NumeroPoliza;
|
||||
Matrícula = p.Matricula;
|
||||
Compañía = p.Compania;
|
||||
Ramo = p.Ramo;
|
||||
BienesAsegurados = p.BienesAsegurados;
|
||||
TipoPago = p.TipoPago;
|
||||
CIFTomador = p.CIFTomador;
|
||||
Tomador = p.Tomador;
|
||||
Teléfono1 = p.Telefono1Tomador;
|
||||
Teléfono2 = p.Telefono2Tomador;
|
||||
Email = p.EmailTomador;
|
||||
}
|
||||
|
||||
public int NumeroPropuesta { get; set; }
|
||||
public DateTime? FechaAlta { get; set; }
|
||||
public string NumeroPóliza { get; set; }
|
||||
public string Matrícula { get; set; }
|
||||
public string BienesAsegurados { get; set; }
|
||||
public string Compañía { get; set; }
|
||||
public string Ramo { get; set; }
|
||||
public string TipoPago { get; set; }
|
||||
public string CIFTomador { get; set; }
|
||||
public string Tomador { get; set; }
|
||||
public string Teléfono1 { get; set; }
|
||||
public string Teléfono2 { get; set; }
|
||||
public string Email { get; set; }
|
||||
}
|
||||
}
|
||||
22
bdAsegasa/Extensiones/vf_polizassg_estadisticas.cs
Normal file
22
bdAsegasa/Extensiones/vf_polizassg_estadisticas.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public class vf_polizassg_estadisticas_reducido
|
||||
{
|
||||
public int EsContratacion { get; set; }
|
||||
public int EsBaja { get; set; }
|
||||
public DateTime FechaSituacion { get; set; }
|
||||
public string Compania { get; set; }
|
||||
public string FamiliaRamo { get; set; }
|
||||
public string SubAgente { get; set; }
|
||||
|
||||
public int Incremento
|
||||
{
|
||||
get
|
||||
{
|
||||
return EsContratacion - EsBaja;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
190
bdAsegasa/Extensiones/vf_recibosextendidos.cs
Normal file
190
bdAsegasa/Extensiones/vf_recibosextendidos.cs
Normal file
@@ -0,0 +1,190 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using bdAsegasa.dbcontext;
|
||||
using tsUtilidades;
|
||||
using tsUtilidades.Extensiones;
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class vf_recibosextendidos
|
||||
{
|
||||
private static List<enumeraciones> TiposPago;
|
||||
|
||||
public string Situacion_Web => gestionasegasaEntities.ObtieneSituacionWeb(this.idSituacion, this.idTipoPago);
|
||||
|
||||
public string CiaNumeroPoliza => $"{this.Compania}/{this.NumeroPoliza}";
|
||||
public string CompaniaNumeros => $"{this.Compania} (Números de asistencia)";
|
||||
|
||||
public recibos.EstadoRecibo Estado
|
||||
{
|
||||
get
|
||||
{
|
||||
var est = recibos.EstadoRecibo.PENDIENTE;
|
||||
if (this.idRemesa.HasValue) est = recibos.EstadoRecibo.REMESADO;
|
||||
|
||||
if (this.idTipoPago == bdAsegasa.db.gestionasegasaEntities.TipoPagoCia() || this.idTipoPago == bdAsegasa.db.gestionasegasaEntities.TipoPagoFAE()) est = recibos.EstadoRecibo.GESTION_COBRO_CIA;
|
||||
if (this.FechaLiquidacionAgente.HasValue) est = recibos.EstadoRecibo.LIQUIDADO;
|
||||
if (this.FechaBaja.HasValue && this.idCausaBaja != bdAsegasa.db.gestionasegasaEntities.CabaSupl() && this.idCausaBaja != bdAsegasa.db.gestionasegasaEntities.CabaSust()) est = recibos.EstadoRecibo.BAJA;
|
||||
if (this.FechaDevolucionBanco.HasValue) est = recibos.EstadoRecibo.DEVUELTO_BANCO;
|
||||
return est;
|
||||
}
|
||||
}
|
||||
|
||||
public string EstadoRecibo => Estado.ToString().Replace("_", " ");
|
||||
|
||||
public string IBANoTipoPago
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idTipoPago.HasValue)
|
||||
{
|
||||
if (TiposPago == null)
|
||||
{
|
||||
// Asumiendo que bdGestionAsegasa es una clase estática o accesible en el contexto
|
||||
var bdtmp = bdAsegasa.tscgestionasegasa.NuevoContexto();
|
||||
|
||||
TiposPago = bdtmp.enumeraciones
|
||||
.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "TIPP")
|
||||
.ToList();
|
||||
}
|
||||
|
||||
var tp = TiposPago.FirstOrDefault(x => x.idEnumeracion == this.idTipoPago);
|
||||
|
||||
if (tp == null)
|
||||
{
|
||||
return "* DESCONOCIDO *";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tp.Codigo == "TIPP.BA")
|
||||
{
|
||||
if (string.IsNullOrEmpty(IBAN.NothingAVacio()))
|
||||
{
|
||||
return "BANCARIO SIN IBAN ASIGNADO";
|
||||
}
|
||||
else
|
||||
{
|
||||
return IBAN;
|
||||
}
|
||||
}
|
||||
|
||||
return tp.Descripcion;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return "* NO ASIGNADO *";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string TipoPago
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idTipoPago.HasValue)
|
||||
{
|
||||
if (TiposPago == null)
|
||||
{
|
||||
var bdtmp = bdAsegasa.tscgestionasegasa.NuevoContexto();
|
||||
|
||||
TiposPago = bdtmp.enumeraciones
|
||||
.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "TIPP")
|
||||
.ToList();
|
||||
}
|
||||
|
||||
var tp = TiposPago.FirstOrDefault(x => x.idEnumeracion == this.idTipoPago);
|
||||
|
||||
if (tp == null)
|
||||
{
|
||||
return "* DESCONOCIDO *";
|
||||
}
|
||||
else
|
||||
{
|
||||
return tp.Descripcion;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return "* NO ASIGNADO *";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IBANCorrecto => tsUtilidades.Bancos.Genericas.IBANCorrecto(this.IBAN) && this.IBAN != "ES8200000000000000000000";
|
||||
|
||||
public int? idSubAgente_Especial
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idSubagente.HasValue && this.CodigoAgente == "000047002186")
|
||||
{
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var codigoBase = this.CodigoSubAgente.Substring(0, 2) + "00";
|
||||
var subage = bd.subagentes.FirstOrDefault(x => x.idAgente == this.idAgente && x.Codigo == codigoBase);
|
||||
return subage?.idSubagente ?? this.idSubagente;
|
||||
}
|
||||
}
|
||||
return this.idSubagente;
|
||||
}
|
||||
}
|
||||
|
||||
public string NumeroPolizaSuplementoLargo => (this.NumeroSuplemento == 0) ? this.NumeroPoliza : $"{this.NumeroPoliza} ({this.NumeroSuplemento})";
|
||||
public string NumeroPolizaSuplemento => (this.NumeroSuplemento == 0) ? this.NumeroPoliza : $"{this.NumeroPoliza}#{this.NumeroSuplemento}";
|
||||
|
||||
public double LiquidoCia => Math.Round((double)((this.TotalRecibo ?? 0) - (this.TotalComision ?? 0)), 2);
|
||||
public double PrimaNetaBonificada => Math.Round((double)((this.PrimaNeta ?? 0) + (this.BonificacionORecargo ?? 0)), 2);
|
||||
|
||||
public double ImporteALiquidarAgente
|
||||
{
|
||||
get
|
||||
{
|
||||
int factor = EsRetornoComision_TMP ? -1 : 1;
|
||||
return Math.Round(factor * (double)(this.ComisionAgente ?? 0), 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
|
||||
public string TipoLiquidacionAgente => EsRetornoComision_TMP ? "RETORNO COMISION" : "LIQUIDACIÓN";
|
||||
|
||||
public bool EsRetornoComision_TMP { get; set; }
|
||||
public int idRegularizacion_TMP { get; set; }
|
||||
|
||||
private static int? idTippPE;
|
||||
public bool CuentaContableTomadorErronea
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!idTippPE.HasValue)
|
||||
{
|
||||
using var bd = tscgestionasegasa.NuevoContexto();
|
||||
idTippPE = bd.enumeraciones.First(x => x.Codigo == "TIPP.PE").idEnumeracion;
|
||||
}
|
||||
return this.idTipoPago == idTippPE.Value && (this.CuentaContableTomador ?? "").Length != 8;
|
||||
}
|
||||
}
|
||||
|
||||
public string TelefonoMovilValido
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.Telefono1Tomador.EsNumeroTelefonoMovilEspañolValido())
|
||||
{
|
||||
return this.Telefono1Tomador;
|
||||
}
|
||||
else if (this.Telefono2Tomador.EsNumeroTelefonoMovilEspañolValido())
|
||||
{
|
||||
return this.Telefono2Tomador;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string ProvinciaTomador => (this.CodigoPostalTomador?.Length > 2) ? this.CodigoPostalTomador.Substring(0, 2) : "";
|
||||
|
||||
public bool AntiguedadMayor2M => (DateTime.Today - this.FechaEfecto.ToDateTime(TimeOnly.MinValue)).TotalDays > 60;
|
||||
}
|
||||
}
|
||||
88
bdAsegasa/Extensiones/vf_recibosextendidos_lc.cs
Normal file
88
bdAsegasa/Extensiones/vf_recibosextendidos_lc.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using bdAsegasa.dbcontext;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class vf_recibosextendidos_lc
|
||||
{
|
||||
private static List<enumeraciones> _tiposPago;
|
||||
|
||||
public double LiquidoCia => Math.Round((double)((this.TotalRecibo ?? 0) - (this.TotalComision ?? 0)), 2);
|
||||
public string Situacion_Web => gestionasegasaEntities.ObtieneSituacionWeb(this.idSituacion, this.idTipoPago);
|
||||
public string CiaNumeroPoliza => $"{this.Compania}/{this.NumeroPoliza}";
|
||||
|
||||
public string TipoPago
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idTipoPago.HasValue)
|
||||
{
|
||||
if (_tiposPago == null)
|
||||
{
|
||||
var bdtmp = tscgestionasegasa.NuevoContexto();
|
||||
_tiposPago = bdtmp.enumeraciones
|
||||
.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "TIPP")
|
||||
.ToList();
|
||||
}
|
||||
|
||||
var tp = _tiposPago.FirstOrDefault(x => x.idEnumeracion == this.idTipoPago);
|
||||
|
||||
return tp == null ? "* DESCONOCIDO *" : tp.Descripcion;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "* NO ASIGNADO *";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IBANCorrecto => tsUtilidades.Bancos.Genericas.IBANCorrecto(this.IBAN);
|
||||
|
||||
public int? idSubAgente_Especial
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idSubagente.HasValue && this.CodigoAgente == "000047002186")
|
||||
{
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var codigoBase = this.CodigoSubAgente.Substring(0, 2) + "00";
|
||||
var subage = bd.subagentes.FirstOrDefault(x => x.idAgente == this.idAgente && x.Codigo == codigoBase);
|
||||
return subage?.idSubagente ?? this.idSubagente;
|
||||
}
|
||||
}
|
||||
return this.idSubagente;
|
||||
}
|
||||
}
|
||||
|
||||
public string NumeroPolizaSuplementoLargo => (this.NumeroSuplemento == 0) ? this.NumeroPoliza : $"{this.NumeroPoliza} ({this.NumeroSuplemento})";
|
||||
public string NumeroPolizaSuplemento => (this.NumeroSuplemento == 0) ? this.NumeroPoliza : $"{this.NumeroPoliza}#{this.NumeroSuplemento}";
|
||||
|
||||
public string MotivoBajaCia
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!this.idCausaBaja.HasValue) return "";
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
return bd.enumeraciones.FirstOrDefault(x => x.idEnumeracion == this.idCausaBaja)?.ValorAlfabetico2 ?? "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string CodigoDevolucionBanco
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!this.idCausaDevolucion.HasValue) return "";
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var cau = bd.enumeraciones.FirstOrDefault(x => x.idEnumeracion == this.idCausaDevolucion);
|
||||
return cau?.Codigo?.Split('.').ElementAtOrDefault(1) ?? "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
78
bdAsegasa/Extensiones/vf_recibosextendidos_ti.cs
Normal file
78
bdAsegasa/Extensiones/vf_recibosextendidos_ti.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using bdAsegasa.dbcontext;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class vf_recibosextendidos_ti
|
||||
{
|
||||
private static List<enumeraciones> _tiposPago;
|
||||
|
||||
public string Situacion_Web => gestionasegasaEntities.ObtieneSituacionWeb(this.idSituacion, this.idTipoPago);
|
||||
public string CiaNumeroPoliza => $"{this.Compania}/{this.NumeroPoliza}";
|
||||
|
||||
public recibos.EstadoRecibo Estado
|
||||
{
|
||||
get
|
||||
{
|
||||
var est = recibos.EstadoRecibo.PENDIENTE;
|
||||
if (this.idRemesa.HasValue) est = recibos.EstadoRecibo.REMESADO;
|
||||
if (this.idTipoPago == 1 /* TipoPagoCia */ || this.idTipoPago == 2 /* TipoPagoFAE */) est = recibos.EstadoRecibo.GESTION_COBRO_CIA;
|
||||
if (this.FechaLiquidacionAgente.HasValue) est = recibos.EstadoRecibo.LIQUIDADO;
|
||||
if (this.FechaBaja.HasValue && this.idCausaBaja != 10 && this.idCausaBaja != 11) est = recibos.EstadoRecibo.BAJA;
|
||||
if (this.FechaDevolucionBanco.HasValue) est = recibos.EstadoRecibo.DEVUELTO_BANCO;
|
||||
return est;
|
||||
}
|
||||
}
|
||||
|
||||
public string EstadoRecibo => Estado.ToString().Replace("_", " ");
|
||||
|
||||
public string TipoPago
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idTipoPago.HasValue)
|
||||
{
|
||||
if (_tiposPago == null)
|
||||
{
|
||||
var bdtmp = tscgestionasegasa.NuevoContexto();
|
||||
_tiposPago = bdtmp.enumeraciones
|
||||
.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "TIPP")
|
||||
.ToList();
|
||||
}
|
||||
|
||||
var tp = _tiposPago.FirstOrDefault(x => x.idEnumeracion == this.idTipoPago);
|
||||
|
||||
return tp == null ? "* DESCONOCIDO *" : tp.Descripcion;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "* NO ASIGNADO *";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IBANCorrecto => tsUtilidades.Bancos.Genericas.IBANCorrecto(this.IBAN);
|
||||
|
||||
public int? idSubAgente_Especial
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idSubagente.HasValue && this.CodigoAgente == "000047002186")
|
||||
{
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var codigoBase = this.CodigoSubAgente.Substring(0, 2) + "00";
|
||||
var subage = bd.subagentes.FirstOrDefault(x => x.idAgente == this.idAgente && x.Codigo == codigoBase);
|
||||
return subage?.idSubagente ?? this.idSubagente;
|
||||
}
|
||||
}
|
||||
return this.idSubagente;
|
||||
}
|
||||
}
|
||||
|
||||
public string NumeroPolizaSuplementoLargo => (this.NumeroSuplemento == 0) ? this.NumeroPoliza : $"{this.NumeroPoliza} ({this.NumeroSuplemento})";
|
||||
public string NumeroPolizaSuplemento => (this.NumeroSuplemento == 0) ? this.NumeroPoliza : $"{this.NumeroPoliza}#{this.NumeroSuplemento}";
|
||||
}
|
||||
}
|
||||
34
bdAsegasa/Extensiones/vf_siniestros_eiac_extendidos.cs
Normal file
34
bdAsegasa/Extensiones/vf_siniestros_eiac_extendidos.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class vf_siniestros_eiac_extendidos
|
||||
{
|
||||
// Similar mappings to siniestros_eiac for compatibility with view extensions
|
||||
public enum ClavesPosicionSiniestroEnum : int
|
||||
{
|
||||
CULPA = 1,
|
||||
RECLAMACIÓN = 2,
|
||||
INDETERMINADO = 3,
|
||||
NO_APLICA = 4,
|
||||
DESCONOCIDA = 99
|
||||
}
|
||||
|
||||
public string DescripcionPosicionSiniestro => ((ClavesPosicionSiniestroEnum)this.PosicionSiniestro).ToString().Replace("_", " ");
|
||||
|
||||
public enum SituacionAsegasaENUM : int
|
||||
{
|
||||
NUEVO = 1,
|
||||
MODIFICADO = 2,
|
||||
POLIZA_NO_ENCONTRADA = 10,
|
||||
SINIESTRO_NO_ENCONTRADO = 11,
|
||||
VARIOS_SINIESTROS_POSIBLES = 12,
|
||||
VISUALIZADO = 100,
|
||||
DESCARTADO = 200
|
||||
}
|
||||
|
||||
public string DescripcionSituacionAsegasa => this.SituacionAsegasa.HasValue
|
||||
? ((SituacionAsegasaENUM)this.SituacionAsegasa.Value).ToString().Replace("_", " ")
|
||||
: "";
|
||||
}
|
||||
}
|
||||
21
bdAsegasa/Extensiones/vf_siniestrosextendidos.cs
Normal file
21
bdAsegasa/Extensiones/vf_siniestrosextendidos.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class vf_siniestrosextendidos
|
||||
{
|
||||
public long NumeroGestionesNN => this.NumeroGestiones ?? 1;
|
||||
|
||||
public bool Abierto => !this.FechaCierre.HasValue;
|
||||
|
||||
public string AñoMes
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.FechaAccidente.HasValue)
|
||||
{
|
||||
return $"{this.FechaAccidente.Value.Year}-{this.FechaAccidente.Value.Month:D2}";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user