1426 lines
47 KiB
C#
1426 lines
47 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using bdAsegasa.dbcontext;
|
|
using bdAsegasa.Presupuestos;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace bdAsegasa.db
|
|
{
|
|
public partial class polizassg
|
|
{
|
|
#region CamposTemporales
|
|
public string FechasInexistentes { get; set; }
|
|
#endregion
|
|
|
|
#region Listados
|
|
public static List<polizassg> ListadoPolizasCIAsFechasInexistentes(tscgestionasegasa bd)
|
|
{
|
|
var consultaIdsPolizasCobroCiaNoBaja = bd.polizassg
|
|
.Where(x => x.idTipoPago == 279 && x.FechaBaja != null)
|
|
.Select(x => x.idPoliza)
|
|
.ToList();
|
|
|
|
var consultaIdsRecibosQueSeAnalizaran = bd.recibos
|
|
.OrderBy(y => y.FechaVencimiento)
|
|
.Where(x => consultaIdsPolizasCobroCiaNoBaja.Contains(x.idPoliza))
|
|
.Select(x => new { x.idRecibo, x.idPoliza })
|
|
.ToList();
|
|
|
|
List<polizassg> lp = new List<polizassg>();
|
|
|
|
foreach (var idP in consultaIdsPolizasCobroCiaNoBaja)
|
|
{
|
|
var consultaIdsRecibos = consultaIdsRecibosQueSeAnalizaran
|
|
.Where(x => x.idPoliza == idP)
|
|
.Select(x => x.idRecibo)
|
|
.ToList();
|
|
|
|
if (consultaIdsRecibos.Count > 1)
|
|
{
|
|
var consultaRecibos = bd.recibos
|
|
.Where(x => consultaIdsRecibos.Contains(x.idRecibo))
|
|
.OrderBy(x => x.FechaVencimiento)
|
|
.ToList();
|
|
|
|
DateOnly fechaVencimientoA = default;
|
|
DateOnly fechaEfectoB = default;
|
|
bool rupturaContinuidad = false;
|
|
StringBuilder sbFechas = new StringBuilder();
|
|
|
|
bool primero = true;
|
|
foreach (var recibo in consultaRecibos)
|
|
{
|
|
if (primero)
|
|
{
|
|
fechaVencimientoA = recibo.FechaVencimiento;
|
|
primero = false;
|
|
}
|
|
else
|
|
{
|
|
fechaEfectoB = recibo.FechaEfecto;
|
|
|
|
if (fechaVencimientoA.AddDays(1) < fechaEfectoB)
|
|
{
|
|
rupturaContinuidad = true;
|
|
sbFechas.AppendFormat("{0}—{1}, ", fechaVencimientoA.ToString("yyyy-MM-dd"), fechaEfectoB.ToString("yyyy-MM-dd"));
|
|
}
|
|
|
|
fechaVencimientoA = recibo.FechaVencimiento;
|
|
}
|
|
}
|
|
|
|
if (rupturaContinuidad)
|
|
{
|
|
var poliza = bd.polizassg.FirstOrDefault(x => x.idPoliza == idP);
|
|
if (poliza != null)
|
|
{
|
|
string sFechasInexistentes = sbFechas.ToString();
|
|
if (sFechasInexistentes.Length > 2)
|
|
sFechasInexistentes = sFechasInexistentes.Substring(0, sFechasInexistentes.Length - 2);
|
|
|
|
poliza.FechasInexistentes = sFechasInexistentes;
|
|
lp.Add(poliza);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return lp;
|
|
}
|
|
#endregion
|
|
|
|
public int? idSubAgente_Especial
|
|
{
|
|
get
|
|
{
|
|
if (this.idSubAgente.HasValue && this.idAgenteNavigation?.Codigo == "000047002186")
|
|
{
|
|
var bd = tscgestionasegasa.NuevoContexto();
|
|
string codigoM = (this.idSubAgenteNavigation?.Codigo ?? "").Length >= 2
|
|
? (this.idSubAgenteNavigation.Codigo.Substring(0, 2) + "00")
|
|
: "00";
|
|
|
|
var subage = bd.subagentes.FirstOrDefault(x => x.idAgente == this.idAgente && x.Codigo == codigoM);
|
|
return subage?.idSubagente ?? idSubAgente;
|
|
}
|
|
else
|
|
{
|
|
return idSubAgente;
|
|
}
|
|
}
|
|
}
|
|
|
|
public string AvisosEntidades
|
|
{
|
|
get
|
|
{
|
|
try
|
|
{
|
|
var la = this.entidadespolizas
|
|
.Where(x => !string.IsNullOrEmpty(x.idEntidadNavigation?.Avisos))
|
|
.Select(x => x.idEntidadNavigation.Avisos)
|
|
.ToList();
|
|
|
|
if (!string.IsNullOrEmpty(CifTomadorTmp))
|
|
{
|
|
var bd = tscgestionasegasa.NuevoContexto();
|
|
var ent = bd.entidades.FirstOrDefault(x => x.CIF == CifTomadorTmp);
|
|
if (ent != null && !string.IsNullOrEmpty(ent.Avisos))
|
|
{
|
|
if (!la.Contains(ent.Avisos)) la.Add(ent.Avisos);
|
|
}
|
|
}
|
|
|
|
return la.Count == 0 ? "" : string.Join(" ", la);
|
|
}
|
|
catch
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
|
|
public string OficinaAgente
|
|
{
|
|
get
|
|
{
|
|
if (this.idAgenteNavigation != null && !string.IsNullOrEmpty(this.idAgenteNavigation.OficinaAgente))
|
|
{
|
|
return this.idAgenteNavigation.OficinaAgente;
|
|
}
|
|
else
|
|
{
|
|
return "Sevilla";
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool _idPoliza_EsNula;
|
|
public int? idPoliza_Nulable
|
|
{
|
|
get
|
|
{
|
|
if (this.idPoliza == 0 || _idPoliza_EsNula)
|
|
{
|
|
return null;
|
|
}
|
|
else
|
|
{
|
|
return (int?)this.idPoliza;
|
|
}
|
|
}
|
|
set
|
|
{
|
|
_idPoliza_EsNula = value == null;
|
|
}
|
|
}
|
|
|
|
public int? idCompania_Nulable
|
|
{
|
|
get
|
|
{
|
|
if (this.idCompania == 0) return null;
|
|
return (int?)this.idCompania;
|
|
}
|
|
set
|
|
{
|
|
if (value.HasValue) this.idCompania = value.Value;
|
|
}
|
|
}
|
|
|
|
public int? idAgente_Nulable
|
|
{
|
|
get
|
|
{
|
|
if (this.idAgente == 0) return null;
|
|
return (int?)this.idAgente;
|
|
}
|
|
set
|
|
{
|
|
if (value.HasValue) this.idAgente = value.Value;
|
|
}
|
|
}
|
|
|
|
public int? idRamo_Nulable
|
|
{
|
|
get
|
|
{
|
|
if (this.idRamo == 0) return null;
|
|
return (int?)this.idRamo;
|
|
}
|
|
set
|
|
{
|
|
if (value.HasValue) this.idRamo = value.Value;
|
|
}
|
|
}
|
|
|
|
public string AgenteSubagente
|
|
{
|
|
get
|
|
{
|
|
if (this.idAgenteNavigation == null) return "";
|
|
if (this.idSubAgenteNavigation != null)
|
|
{
|
|
return this.idAgenteNavigation.Nombre + " / " + this.idSubAgenteNavigation.Nombre;
|
|
}
|
|
return this.idAgenteNavigation.Nombre;
|
|
}
|
|
}
|
|
|
|
public string NombreSubAgente
|
|
{
|
|
get
|
|
{
|
|
if (this.idSubAgenteNavigation != null)
|
|
{
|
|
return this.idSubAgenteNavigation.Nombre;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
|
|
public entidadespolizas EntidadPolizaTomador
|
|
{
|
|
get
|
|
{
|
|
return this.entidadespolizas.FirstOrDefault(x => x.EsTomador);
|
|
}
|
|
}
|
|
public entidadespolizas EntidadPolizaPropietario
|
|
{
|
|
get
|
|
{
|
|
return this.entidadespolizas.FirstOrDefault(x => x.EsPropietario);
|
|
}
|
|
}
|
|
public entidadespolizas EntidadPolizaConductor
|
|
{
|
|
get
|
|
{
|
|
return this.entidadespolizas.FirstOrDefault(x => x.EsConductorHabitual);
|
|
}
|
|
}
|
|
public entidadespolizas EntidadPolizaPagador
|
|
{
|
|
get
|
|
{
|
|
return this.entidadespolizas.FirstOrDefault(x => x.EsPagador);
|
|
}
|
|
}
|
|
public entidadespolizas EntidadPolizaConductorOcasional
|
|
{
|
|
get
|
|
{
|
|
return this.entidadespolizas.FirstOrDefault(x => x.EsConductorOcasional);
|
|
}
|
|
}
|
|
|
|
public string CausaBaja
|
|
{
|
|
get
|
|
{
|
|
if (this.idCausaBajaNavigation != null)
|
|
{
|
|
return this.idCausaBajaNavigation.Descripcion;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
public string NumeroSuplemento_String
|
|
{
|
|
get
|
|
{
|
|
if (this.NumeroSuplemento == 0) return "";
|
|
return this.NumeroSuplemento.ToString();
|
|
}
|
|
}
|
|
public string NumeroPolizaSuplementoLargo
|
|
{
|
|
get
|
|
{
|
|
if (this.NumeroSuplemento == 0)
|
|
{
|
|
return this.NumeroPoliza;
|
|
}
|
|
else
|
|
{
|
|
return this.NumeroPoliza + " (" + this.NumeroSuplemento + ")";
|
|
}
|
|
}
|
|
}
|
|
public string NumeroPolizaSuplemento
|
|
{
|
|
get
|
|
{
|
|
if (this.NumeroSuplemento == 0)
|
|
{
|
|
return this.NumeroPoliza;
|
|
}
|
|
else
|
|
{
|
|
return this.NumeroPoliza + "#" + this.NumeroSuplemento;
|
|
}
|
|
}
|
|
}
|
|
public string CiaNumeroPolizaSuplemento
|
|
{
|
|
get
|
|
{
|
|
if (this.NumeroSuplemento == 0)
|
|
{
|
|
return this.idCompaniaNavigation.Codigo + "-" + this.NumeroPoliza;
|
|
}
|
|
else
|
|
{
|
|
return this.idCompaniaNavigation.Codigo + "-" + this.NumeroPoliza + "#" + this.NumeroSuplemento;
|
|
}
|
|
}
|
|
}
|
|
|
|
public recibos UltimoRecibo
|
|
{
|
|
get
|
|
{
|
|
var bd = tscgestionasegasa.NuevoContexto();
|
|
return bd.recibos
|
|
.Where(x => x.idPoliza == this.idPoliza)
|
|
.OrderByDescending(x => x.FechaEfecto)
|
|
.FirstOrDefault();
|
|
}
|
|
}
|
|
|
|
public bool TieneSuplementoPosterior
|
|
{
|
|
get
|
|
{
|
|
var bd = tscgestionasegasa.NuevoContexto();
|
|
return bd.polizassg.Any(x => x.NumeroPoliza == this.NumeroPoliza
|
|
&& x.idCompania == this.idCompania
|
|
&& x.NumeroSuplemento > this.NumeroSuplemento);
|
|
}
|
|
}
|
|
|
|
#region Presupuestos (XML Serialization)
|
|
private object _presupuestoCache;
|
|
private int? _idFicheroCache;
|
|
|
|
private T GetPresupuesto<T>(TiposPresupuestos tipo) where T : class
|
|
{
|
|
if (_idFicheroCache == this.idFicheroPresupuesto && _presupuestoCache is T)
|
|
return (T)_presupuestoCache;
|
|
|
|
if (this.idOrigenPresupuesto == (int)tipo && this.idFicheroPresupuesto.HasValue && this.idFicheroPresupuestoNavigation?.Fichero != null)
|
|
{
|
|
try
|
|
{
|
|
var xml = Encoding.Unicode.GetString(this.idFicheroPresupuestoNavigation.Fichero);
|
|
var serializer = new System.Xml.Serialization.XmlSerializer(typeof(T));
|
|
using (var reader = new System.IO.StringReader(xml))
|
|
{
|
|
_presupuestoCache = serializer.Deserialize(reader);
|
|
_idFicheroCache = this.idFicheroPresupuesto;
|
|
return (T)_presupuestoCache;
|
|
}
|
|
}
|
|
catch { return null; }
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private void SetPresupuesto<T>(tscgestionasegasa bd, T value, string fileName, string description) where T : class
|
|
{
|
|
var serializer = new System.Xml.Serialization.XmlSerializer(typeof(T));
|
|
string xml;
|
|
using (var writer = new System.IO.StringWriter())
|
|
{
|
|
serializer.Serialize(writer, value);
|
|
xml = writer.ToString();
|
|
}
|
|
var bytes = Encoding.Unicode.GetBytes(xml);
|
|
|
|
if (!this.idFicheroPresupuesto.HasValue)
|
|
{
|
|
var fi = new ficheros
|
|
{
|
|
idTipo = bd.enumeraciones.First(x => x.Codigo == "TIPFIC.PRESUPUESTO").idEnumeracion,
|
|
NombreFichero = fileName,
|
|
Fichero = bytes,
|
|
Descripcion = description
|
|
};
|
|
this.idFicheroPresupuestoNavigation = fi;
|
|
}
|
|
else
|
|
{
|
|
if (this.idFicheroPresupuestoNavigation != null)
|
|
{
|
|
this.idFicheroPresupuestoNavigation.Fichero = bytes;
|
|
}
|
|
}
|
|
_presupuestoCache = value;
|
|
_idFicheroCache = this.idFicheroPresupuesto;
|
|
}
|
|
|
|
private RCSociosCaser _RCSociosCaser;
|
|
|
|
public virtual RCSociosCaser RcSociosCaser
|
|
{
|
|
get
|
|
{
|
|
if (_RCSociosCaser == null)
|
|
{
|
|
if (this.idOrigenPresupuesto == (int)TiposPresupuestos.RCSOCIOSCASER && this.idFicheroPresupuesto.HasValue)
|
|
{
|
|
_RCSociosCaser = (RCSociosCaser)tsUtilidades.Utilidades.Deserializa(this.idFicheroPresupuestoNavigation.Fichero, typeof(RCSociosCaser));
|
|
}
|
|
}
|
|
return _RCSociosCaser;
|
|
}
|
|
set
|
|
{
|
|
_RCSociosCaser = value;
|
|
}
|
|
}
|
|
|
|
public void GuardaRcSociosCaser(tscgestionasegasa bd, object rcsc)
|
|
{
|
|
SetPresupuesto(bd, rcsc, "rcsocioscaser.xml", "Documento XML de Presupuesto");
|
|
}
|
|
|
|
public virtual RCMaquinariaAgricola RCMaquinariaAgricola
|
|
{
|
|
get { return GetPresupuesto<RCMaquinariaAgricola>(TiposPresupuestos.RCMAQUINARIAAGRICOLA); }
|
|
set { _presupuestoCache = value; }
|
|
}
|
|
public void GuardaRcMaquinariaAgricola(tscgestionasegasa bd, object rcsc)
|
|
{
|
|
SetPresupuesto(bd, rcsc, "rcmaquinariaagricola.xml", "Documento XML de Presupuesto");
|
|
}
|
|
|
|
public virtual TarificadorMaquinariaPlusUltra TarificadorMaquinariaPlusUltra
|
|
{
|
|
get { return GetPresupuesto<TarificadorMaquinariaPlusUltra>(TiposPresupuestos.MAQUINARIAPLUSULTRA); }
|
|
set { _presupuestoCache = value; }
|
|
}
|
|
public void GuardaTarificadorMaquinariaPlusUltra(tscgestionasegasa bd, object rcsc)
|
|
{
|
|
SetPresupuesto(bd, rcsc, "TarificadorMaquinariaPlusUltra.xml", "Documento XML de Presupuesto");
|
|
}
|
|
|
|
public virtual TarificadorGenerico TarificadorGenerico
|
|
{
|
|
get { return GetPresupuesto<TarificadorGenerico>(TiposPresupuestos.TARIFICADORGENERICO); }
|
|
set { _presupuestoCache = value; }
|
|
}
|
|
public void GuardaTarificadorGenerico(tscgestionasegasa bd, object rcsc)
|
|
{
|
|
SetPresupuesto(bd, rcsc, "TarificadorGenerico.xml", "Documento XML de Presupuesto");
|
|
}
|
|
|
|
public virtual Tractores Tractores
|
|
{
|
|
get { return GetPresupuesto<Tractores>(TiposPresupuestos.TRACTORES); }
|
|
set { _presupuestoCache = value; }
|
|
}
|
|
public void GuardaTractores(tscgestionasegasa bd, object tractor)
|
|
{
|
|
SetPresupuesto(bd, tractor, "tractores.xml", "Documento XML de Presupuesto");
|
|
}
|
|
|
|
public virtual RCSociosZurich RCSociosZurich
|
|
{
|
|
get { return GetPresupuesto<RCSociosZurich>(TiposPresupuestos.RCSOCIOSZURICH); }
|
|
set { _presupuestoCache = value; }
|
|
}
|
|
public void GuardaRCSociosZurich(tscgestionasegasa bd, object rcp)
|
|
{
|
|
SetPresupuesto(bd, rcp, "RCSociosZurich.xml", "Documento XML de Presupuesto");
|
|
}
|
|
|
|
public virtual RCCotosCazaCaser RCCotosCazaCaser
|
|
{
|
|
get { return GetPresupuesto<RCCotosCazaCaser>(TiposPresupuestos.RCCOTOSCAZACASER); }
|
|
set { _presupuestoCache = value; }
|
|
}
|
|
public void GuardaRCCotosCazaCaser(tscgestionasegasa bd, object rcsc)
|
|
{
|
|
SetPresupuesto(bd, rcsc, "rccotoscazacaser.xml", "Documento XML de Presupuesto");
|
|
}
|
|
|
|
public virtual TarificadorMaquinaria TarificadorMaquinaria
|
|
{
|
|
get { return GetPresupuesto<TarificadorMaquinaria>(TiposPresupuestos.TARIFICADORMAQUINARIA); }
|
|
set { _presupuestoCache = value; }
|
|
}
|
|
public void GuardaTarificadorMaquinaria(tscgestionasegasa bd, object rcsc)
|
|
{
|
|
SetPresupuesto(bd, rcsc, "tarificadormaquinaria.xml", "Documento XML de Presupuesto");
|
|
}
|
|
|
|
public virtual RCPerros RCPerros
|
|
{
|
|
get { return GetPresupuesto<RCPerros>(TiposPresupuestos.RCPERROS); }
|
|
set { _presupuestoCache = value; }
|
|
}
|
|
public void GuardaRCPerros(tscgestionasegasa bd, object rcp)
|
|
{
|
|
SetPresupuesto(bd, rcp, "rcperros.xml", "Documento XML de Presupuesto");
|
|
}
|
|
|
|
public virtual RCCaballos RCCaballos
|
|
{
|
|
get { return GetPresupuesto<RCCaballos>(TiposPresupuestos.RCCABALLOS); }
|
|
set { _presupuestoCache = value; }
|
|
}
|
|
public void GuardaRCCaballos(tscgestionasegasa bd, object rcp)
|
|
{
|
|
SetPresupuesto(bd, rcp, "rccaballos.xml", "Documento XML de Presupuesto");
|
|
}
|
|
|
|
public virtual TransportexAXA TransportesAXA
|
|
{
|
|
get { return GetPresupuesto<TransportexAXA>(TiposPresupuestos.TRANSPORTESAXA); }
|
|
set { _presupuestoCache = value; }
|
|
}
|
|
public void GuardaTransportesAXA(tscgestionasegasa bd, object rcp)
|
|
{
|
|
SetPresupuesto(bd, rcp, "transportesAXA.xml", "Documento XML de Presupuesto");
|
|
}
|
|
|
|
public virtual AccidentesIndividualesAXA AccidentesIndividualesAXA
|
|
{
|
|
get { return GetPresupuesto<AccidentesIndividualesAXA>(TiposPresupuestos.ACCIDENTESINDIVIDUALESAXA); }
|
|
set { _presupuestoCache = value; }
|
|
}
|
|
public void GuardaAccidentesIndividualesAXA(tscgestionasegasa bd, object rcp)
|
|
{
|
|
SetPresupuesto(bd, rcp, "accidentesIndividualesAXA.xml", "Documento XML de Presupuesto");
|
|
}
|
|
|
|
public virtual SaludMapfre SaludMapfre
|
|
{
|
|
get { return GetPresupuesto<SaludMapfre>(TiposPresupuestos.SALUDMAPFRE); }
|
|
set { _presupuestoCache = value; }
|
|
}
|
|
public void GuardaSaludMapfre(tscgestionasegasa bd, object rcp)
|
|
{
|
|
SetPresupuesto(bd, rcp, "SaludMapfre.xml", "Documento XML de Presupuesto");
|
|
}
|
|
|
|
public virtual CasetasRiegoAXA CasetasRiegoAXA
|
|
{
|
|
get { return GetPresupuesto<CasetasRiegoAXA>(TiposPresupuestos.CASETASRIEGOAXA); }
|
|
set { _presupuestoCache = value; }
|
|
}
|
|
public void GuardaCasetasRiegoAxa(tscgestionasegasa bd, object rcp)
|
|
{
|
|
SetPresupuesto(bd, rcp, "CasetasRiegoAxa.xml", "Documento XML de Presupuesto");
|
|
}
|
|
|
|
public virtual TractoresEuropAssistance TractoresEuropAssistance
|
|
{
|
|
get { return GetPresupuesto<TractoresEuropAssistance>(TiposPresupuestos.TRACTORESEUROPASSISTANCE); }
|
|
set { _presupuestoCache = value; }
|
|
}
|
|
public void GuardaTractoresEuropAssistance(tscgestionasegasa bd, object rcp)
|
|
{
|
|
SetPresupuesto(bd, rcp, "TractoresEuropAssistance.xml", "Documento XML de Presupuesto");
|
|
}
|
|
|
|
[NotMapped]
|
|
public object DatosCodeoscopic
|
|
{
|
|
get { return GetPresupuesto<object>(TiposPresupuestos.AVANT2); }
|
|
set { _presupuestoCache = value; }
|
|
}
|
|
|
|
public virtual Patinetes Patinetes
|
|
{
|
|
get { return GetPresupuesto<Patinetes>(TiposPresupuestos.PATINETES); }
|
|
set { _presupuestoCache = value; }
|
|
}
|
|
public void GuardaPatinetes(tscgestionasegasa bd, object rcp)
|
|
{
|
|
SetPresupuesto(bd, rcp, "patinetes.xml", "Documento XML de Presupuesto");
|
|
}
|
|
|
|
public enum TiposPresupuestos
|
|
{
|
|
RCSOCIOSCASER = 1,
|
|
TRACTORES = 2,
|
|
RCCOTOSCAZACASER = 3,
|
|
TARIFICADORMAQUINARIA = 4,
|
|
AVANT2 = 5,
|
|
RCMAQUINARIAAGRICOLA = 6,
|
|
RCPERROS = 7,
|
|
PATINETES = 8,
|
|
RCCABALLOS = 9,
|
|
TRANSPORTESAXA = 10,
|
|
ACCIDENTESINDIVIDUALESAXA = 11,
|
|
SALUDMAPFRE = 12,
|
|
CASETASRIEGOAXA = 13,
|
|
RCSOCIOSZURICH = 14,
|
|
MAQUINARIAPLUSULTRA = 15,
|
|
TARIFICADORGENERICO = 16,
|
|
TRACTORESEUROPASSISTANCE = 17,
|
|
IMPORTACION_CSV_ALLIANZ_202111 = 100,
|
|
FICHERO_EIAC = 101
|
|
}
|
|
#endregion
|
|
|
|
#region Entidades (Tomador, Propietario, etc.)
|
|
[NotMapped]
|
|
public virtual entidades Tomador
|
|
{
|
|
get
|
|
{
|
|
if (EntidadPolizaTomador != null)
|
|
{
|
|
return EntidadPolizaTomador.idEntidadNavigation;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
set
|
|
{
|
|
var ep = EntidadPolizaTomador;
|
|
if (ep == null)
|
|
{
|
|
this.entidadespolizas.Add(new entidadespolizas { EsTomador = true, idEntidadNavigation = value });
|
|
}
|
|
else
|
|
{
|
|
ep.idEntidadNavigation = value;
|
|
}
|
|
}
|
|
}
|
|
public virtual direcciones DireccionTomador
|
|
{
|
|
get
|
|
{
|
|
if (EntidadPolizaTomador != null)
|
|
{
|
|
return EntidadPolizaTomador.idDireccionNavigation;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
public string Telefono1Tomador
|
|
{
|
|
get
|
|
{
|
|
if (EntidadPolizaTomador != null)
|
|
{
|
|
return EntidadPolizaTomador.Telefono1;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
set
|
|
{
|
|
if (EntidadPolizaTomador != null) EntidadPolizaTomador.Telefono1 = value;
|
|
}
|
|
}
|
|
public string Telefono2Tomador
|
|
{
|
|
get
|
|
{
|
|
if (EntidadPolizaTomador != null)
|
|
{
|
|
return EntidadPolizaTomador.Telefono2;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
set
|
|
{
|
|
if (EntidadPolizaTomador != null) EntidadPolizaTomador.Telefono2 = value;
|
|
}
|
|
}
|
|
public string EmailTomador
|
|
{
|
|
get
|
|
{
|
|
if (EntidadPolizaTomador != null)
|
|
{
|
|
return EntidadPolizaTomador.Email;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual entidades Propietario
|
|
{
|
|
get
|
|
{
|
|
if (EntidadPolizaPropietario != null)
|
|
{
|
|
return EntidadPolizaPropietario.idEntidadNavigation;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
public virtual direcciones DireccionPropietario
|
|
{
|
|
get
|
|
{
|
|
if (EntidadPolizaPropietario != null)
|
|
{
|
|
return EntidadPolizaPropietario.idDireccionNavigation;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
public string Telefono1Propietario
|
|
{
|
|
get
|
|
{
|
|
if (EntidadPolizaPropietario != null)
|
|
{
|
|
return EntidadPolizaPropietario.Telefono1;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
public string Telefono2Propietario
|
|
{
|
|
get
|
|
{
|
|
if (EntidadPolizaPropietario != null)
|
|
{
|
|
return EntidadPolizaPropietario.Telefono2;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
public string EmailPropietario
|
|
{
|
|
get
|
|
{
|
|
if (EntidadPolizaPropietario != null)
|
|
{
|
|
return EntidadPolizaPropietario.Email;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual entidades Conductor
|
|
{
|
|
get
|
|
{
|
|
if (EntidadPolizaConductor != null)
|
|
{
|
|
return EntidadPolizaConductor.idEntidadNavigation;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
public virtual direcciones DireccionConductor
|
|
{
|
|
get
|
|
{
|
|
if (EntidadPolizaConductor != null)
|
|
{
|
|
return EntidadPolizaConductor.idDireccionNavigation;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
public string Telefono1Conductor
|
|
{
|
|
get
|
|
{
|
|
if (EntidadPolizaConductor != null)
|
|
{
|
|
return EntidadPolizaConductor.Telefono1;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
public string Telefono2Conductor
|
|
{
|
|
get
|
|
{
|
|
if (EntidadPolizaConductor != null)
|
|
{
|
|
return EntidadPolizaConductor.Telefono2;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
public string EmailConductor
|
|
{
|
|
get
|
|
{
|
|
if (EntidadPolizaConductor != null)
|
|
{
|
|
return EntidadPolizaConductor.Email;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual entidades Asegurado1
|
|
{
|
|
get
|
|
{
|
|
var ep = this.entidadespolizas.FirstOrDefault(x => x.Observaciones == "Asegurado1");
|
|
if (ep != null)
|
|
{
|
|
return ep.idEntidadNavigation;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
public virtual entidades Asegurado2
|
|
{
|
|
get
|
|
{
|
|
var ep = this.entidadespolizas.FirstOrDefault(x => x.Observaciones == "Asegurado2");
|
|
if (ep != null)
|
|
{
|
|
return ep.idEntidadNavigation;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
public virtual entidades Asegurado3
|
|
{
|
|
get
|
|
{
|
|
var ep = this.entidadespolizas.FirstOrDefault(x => x.Observaciones == "Asegurado3");
|
|
if (ep != null)
|
|
{
|
|
return ep.idEntidadNavigation;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
public virtual entidades Asegurado4
|
|
{
|
|
get
|
|
{
|
|
var ep = this.entidadespolizas.FirstOrDefault(x => x.Observaciones == "Asegurado4");
|
|
if (ep != null)
|
|
{
|
|
return ep.idEntidadNavigation;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
public virtual entidades Pagador
|
|
{
|
|
get
|
|
{
|
|
if (EntidadPolizaPagador != null)
|
|
{
|
|
return EntidadPolizaPagador.idEntidadNavigation;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
public virtual direcciones DireccionPagador
|
|
{
|
|
get
|
|
{
|
|
if (EntidadPolizaPagador != null)
|
|
{
|
|
return EntidadPolizaPagador.idDireccionNavigation;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
public string Telefono1Pagador
|
|
{
|
|
get
|
|
{
|
|
if (EntidadPolizaPagador != null)
|
|
{
|
|
return EntidadPolizaPagador.Telefono1;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
public string Telefono2Pagador
|
|
{
|
|
get
|
|
{
|
|
if (EntidadPolizaPagador != null)
|
|
{
|
|
return EntidadPolizaPagador.Telefono2;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
public string EmailPagador
|
|
{
|
|
get
|
|
{
|
|
if (EntidadPolizaPagador != null)
|
|
{
|
|
return EntidadPolizaPagador.Email;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual entidades ConductorOcasional
|
|
{
|
|
get
|
|
{
|
|
if (EntidadPolizaConductorOcasional != null)
|
|
{
|
|
return EntidadPolizaConductorOcasional.idEntidadNavigation;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
public virtual direcciones DireccionConductorOcasional
|
|
{
|
|
get
|
|
{
|
|
if (EntidadPolizaConductorOcasional != null)
|
|
{
|
|
return EntidadPolizaConductorOcasional.idDireccionNavigation;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
public string Telefono1ConductorOcasional
|
|
{
|
|
get
|
|
{
|
|
if (EntidadPolizaConductorOcasional != null)
|
|
{
|
|
return EntidadPolizaConductorOcasional.Telefono1;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
public string Telefono2ConductorOcasional
|
|
{
|
|
get
|
|
{
|
|
if (EntidadPolizaConductorOcasional != null)
|
|
{
|
|
return EntidadPolizaConductorOcasional.Telefono2;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
public string EmailConductorOcasional
|
|
{
|
|
get
|
|
{
|
|
if (EntidadPolizaConductorOcasional != null)
|
|
{
|
|
return EntidadPolizaConductorOcasional.Email;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Tomador_Tmp (WPF Bindings)
|
|
public string CifTomadorTmp { get; set; }
|
|
public string RazonSocialTomadorTmp { get; set; }
|
|
public string CodigoPostalTomadorTmp { get; set; }
|
|
public string DomicilioTomadorTmp { get; set; }
|
|
public string CodigoPoblacionTomadorTmp { get; set; }
|
|
public string PoblacionTomadorTmp { get; set; }
|
|
public string ProvinciaTomadorTmp { get; set; }
|
|
public string TelefonoTomador1Tmp { get; set; }
|
|
public string TelefonoTomador2Tmp { get; set; }
|
|
public string EmailTomadorTmp { get; set; }
|
|
public bool? TomadorEsConductorHabitualTmp { get; set; }
|
|
public bool? TomadorEsPagadorTmp { get; set; }
|
|
public bool? TomadorEsConductorOcasionalTmp { get; set; }
|
|
public bool? TomadorEsPropietarioTmp { get; set; }
|
|
public int? idSexoTomadorTmp { get; set; }
|
|
public DateTime? FechaNacimientoTomadorTmp { get; set; }
|
|
public DateTime? FechaCarnetTomadorTmp { get; set; }
|
|
|
|
public void RellenaDatosTmpTomador(entidades entidad)
|
|
{
|
|
if (entidad == null) return;
|
|
CifTomadorTmp = entidad.CIF;
|
|
RazonSocialTomadorTmp = entidad.RazonSocial;
|
|
var dir = entidad.idDireccionPrincipalNavigation; // Assuming primary address
|
|
if (dir != null)
|
|
{
|
|
CodigoPostalTomadorTmp = dir.CodigoPostal;
|
|
DomicilioTomadorTmp = dir.Direccion;
|
|
CodigoPoblacionTomadorTmp = dir.CodigoMunicipio;
|
|
if (dir.CodigoMunicipioNavigation != null)
|
|
{
|
|
PoblacionTomadorTmp = dir.CodigoMunicipioNavigation.Nombre;
|
|
ProvinciaTomadorTmp = dir.CodigoMunicipioNavigation.CodigoProvinciaNavigation?.Nombre;
|
|
}
|
|
}
|
|
TelefonoTomador1Tmp = entidad.Telefono1;
|
|
TelefonoTomador2Tmp = entidad.Telefono2;
|
|
EmailTomadorTmp = entidad.Email;
|
|
idSexoTomadorTmp = entidad.idSexo;
|
|
FechaNacimientoTomadorTmp = entidad.FechaNacimiento?.ToDateTime(TimeOnly.MinValue);
|
|
FechaCarnetTomadorTmp = entidad.FechaExpedicionCarnet?.ToDateTime(TimeOnly.MinValue);
|
|
}
|
|
|
|
public void RellenaDatosTmpTomador(entidadespolizas ep)
|
|
{
|
|
if (ep?.idEntidadNavigation == null) return;
|
|
var entidad = ep.idEntidadNavigation;
|
|
CifTomadorTmp = entidad.CIF;
|
|
RazonSocialTomadorTmp = entidad.RazonSocial;
|
|
var dir = ep.idDireccionNavigation ?? entidad.idDireccionPrincipalNavigation;
|
|
if (dir != null)
|
|
{
|
|
CodigoPostalTomadorTmp = dir.CodigoPostal;
|
|
DomicilioTomadorTmp = dir.Direccion;
|
|
CodigoPoblacionTomadorTmp = dir.CodigoMunicipio;
|
|
if (dir.CodigoMunicipioNavigation != null)
|
|
{
|
|
PoblacionTomadorTmp = dir.CodigoMunicipioNavigation.Nombre;
|
|
ProvinciaTomadorTmp = dir.CodigoMunicipioNavigation.CodigoProvinciaNavigation?.Nombre;
|
|
}
|
|
}
|
|
TelefonoTomador1Tmp = ep.Telefono1;
|
|
TelefonoTomador2Tmp = ep.Telefono2;
|
|
EmailTomadorTmp = ep.Email;
|
|
|
|
TomadorEsConductorHabitualTmp = ep.EsConductorHabitual;
|
|
TomadorEsPagadorTmp = ep.EsPagador;
|
|
TomadorEsConductorOcasionalTmp = ep.EsConductorOcasional;
|
|
TomadorEsPropietarioTmp = ep.EsPropietario;
|
|
|
|
idSexoTomadorTmp = entidad.idSexo;
|
|
FechaNacimientoTomadorTmp = entidad.FechaNacimiento?.ToDateTime(TimeOnly.MinValue);
|
|
FechaCarnetTomadorTmp = entidad.FechaExpedicionCarnet?.ToDateTime(TimeOnly.MinValue);
|
|
}
|
|
|
|
public void VaciaDatosTmpTomador()
|
|
{
|
|
CifTomadorTmp = ""; RazonSocialTomadorTmp = ""; CodigoPostalTomadorTmp = ""; DomicilioTomadorTmp = "";
|
|
CodigoPoblacionTomadorTmp = ""; PoblacionTomadorTmp = ""; ProvinciaTomadorTmp = "";
|
|
TelefonoTomador1Tmp = ""; TelefonoTomador2Tmp = ""; EmailTomadorTmp = "";
|
|
TomadorEsConductorHabitualTmp = false; TomadorEsPagadorTmp = false;
|
|
TomadorEsConductorOcasionalTmp = false; TomadorEsPropietarioTmp = false;
|
|
idSexoTomadorTmp = null; FechaNacimientoTomadorTmp = null; FechaCarnetTomadorTmp = null;
|
|
}
|
|
#endregion
|
|
|
|
#region Helpers & Formatting
|
|
public string TipoCobro
|
|
{
|
|
get
|
|
{
|
|
if (this.idTipoCobroNavigation != null)
|
|
{
|
|
return this.idTipoCobroNavigation.Descripcion;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
public string TipoPago
|
|
{
|
|
get
|
|
{
|
|
if (this.idTipoPagoNavigation != null)
|
|
{
|
|
return this.idTipoPagoNavigation.Descripcion;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual ficheros FicheroFSS
|
|
{
|
|
get
|
|
{
|
|
return this.documentospolizassg
|
|
.Where(x => x.idDocumentoASolicitarNavigation?.idTipoNavigation?.Codigo == "DOCRAM.FSS" && x.idFichero.HasValue)
|
|
.OrderByDescending(x => x.idDocumento)
|
|
.FirstOrDefault()?.idFicheroNavigation;
|
|
}
|
|
}
|
|
|
|
[NotMapped]
|
|
public virtual List<documentospolizassg> DocumentosPendientesRecibir
|
|
{
|
|
get
|
|
{
|
|
return this.documentospolizassg
|
|
.Where(x => x.FechaComprobacion == null && x.Obligatorio && x.idFichero == null)
|
|
.ToList();
|
|
}
|
|
}
|
|
|
|
public static string TransformaNumeroPolizaAFormatoAsegasa(string NumeroPolizaAvant, string CodigoCompañia, string CodigoRamo)
|
|
{
|
|
string NumeroPoliza = NumeroPolizaAvant;
|
|
switch (CodigoCompañia)
|
|
{
|
|
case "0013":
|
|
case "2913":
|
|
if (NumeroPolizaAvant.Length > 11) NumeroPoliza = NumeroPoliza.Substring(NumeroPoliza.Length - 11, 11);
|
|
if (NumeroPolizaAvant.Length < 11) NumeroPoliza = NumeroPoliza.PadLeft(11, '0');
|
|
break;
|
|
case "0008":
|
|
if (NumeroPoliza.Contains("-")) NumeroPoliza = NumeroPoliza.Replace("-", "");
|
|
break;
|
|
case "0021":
|
|
if ((CodigoRamo == "1" || CodigoRamo == "1-2") && NumeroPoliza.Length > 0 && NumeroPoliza[0] != '0')
|
|
NumeroPoliza = "0" + NumeroPoliza;
|
|
break;
|
|
}
|
|
return NumeroPoliza;
|
|
}
|
|
#endregion
|
|
|
|
#region GeneracionFicheros (PDF)
|
|
public byte[] GeneraFicheroMandatoSEPA(tscgestionasegasa bd)
|
|
{
|
|
string codigoTemplate = "SEPA." + this.idCompaniaNavigation?.Codigo;
|
|
var plantilla = bd.plantillas.FirstOrDefault(x => x.Codigo == codigoTemplate)
|
|
?? bd.plantillas.First(x => x.Codigo == "SEPA.ASEGASA");
|
|
|
|
var lp = new List<polizassg> { this };
|
|
// Placeholder: CombinacionCorrespondencia logic needs to be ported or referenced
|
|
return null;
|
|
}
|
|
#endregion
|
|
|
|
#region Persistence Hooks
|
|
public static void GuardandoCambios(tscgestionasegasa bd, string Aplicacion)
|
|
{
|
|
var entries = bd.ChangeTracker.Entries()
|
|
.Where(e => e.State == EntityState.Added || e.State == EntityState.Modified);
|
|
|
|
foreach (var entry in entries)
|
|
{
|
|
if (entry.Entity is polizassg p)
|
|
{
|
|
if (!string.IsNullOrEmpty(p.Matricula))
|
|
p.Matricula = Regex.Replace(p.Matricula, "[^a-zA-Z0-9]", "").ToUpper();
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Conversiones
|
|
public ListadoPropuestasRealizadas AListadoPropuestas()
|
|
{
|
|
return new ListadoPropuestasRealizadas(this);
|
|
}
|
|
public ListadoGenerico AListadoGenerico()
|
|
{
|
|
return new ListadoGenerico(this);
|
|
}
|
|
#endregion
|
|
|
|
#region Recibos
|
|
public void GeneraReciboPolizaColectivo(tscgestionasegasa bd, string PolizaColectivo)
|
|
{
|
|
var today = DateOnly.FromDateTime(DateTime.Today);
|
|
if (!this.recibos.Any(x => x.FechaVencimiento >= today))
|
|
{
|
|
if (!this.FechaAceptacionPresupuesto.HasValue) throw new Exception("La póliza no está aceptada");
|
|
|
|
var pc = bd.enumeraciones.First(x => x.Codigo == PolizaColectivo);
|
|
double primaNeta = pc.ValorNumerico1 ?? 0;
|
|
double porcentajeImpuestos = pc.ValorNumerico2 ?? 0;
|
|
double impuestos = Math.Round(primaNeta * porcentajeImpuestos / 100, 2);
|
|
|
|
GeneraReciboPolizaColectivo(bd, primaNeta, impuestos, 0);
|
|
}
|
|
}
|
|
|
|
public void GeneraReciboPolizaColectivo(tscgestionasegasa bd, double primaNeta, double impuestos, double consorcio)
|
|
{
|
|
var nr = new recibos();
|
|
var ur = this.recibos.OrderByDescending(x => x.FechaVencimiento).FirstOrDefault();
|
|
|
|
int sr = 1;
|
|
if (ur != null)
|
|
{
|
|
var parts = ur.NumeroRecibo.Split('-');
|
|
if (parts.Length >= 3) int.TryParse(parts[2], out sr);
|
|
sr++;
|
|
}
|
|
|
|
nr.NumeroRecibo = $"{this.NumeroPoliza}-{sr}";
|
|
nr.CodigoRecibo = $"{this.idCompaniaNavigation?.Codigo}/{nr.NumeroRecibo}";
|
|
nr.PrimaNeta = primaNeta;
|
|
nr.BonificacionORecargo = 0;
|
|
nr.Consorcio = consorcio;
|
|
nr.Impuesto = impuestos;
|
|
nr.RecargoExterno = 0;
|
|
nr.TotalRecibo = 0;
|
|
nr.ComisionReciboPrimaNeta = 0;
|
|
nr.PorcentajeReciboPrimaNeta = 0;
|
|
nr.TotalComision = 0;
|
|
nr.PorcentajeComisionAgente = 0;
|
|
nr.ComisionAgente = 0;
|
|
nr.ComisionAsegasaPrimaNeta = 0;
|
|
nr.AsegasaRecargoExterno = 0;
|
|
nr.AsegasaComisionConsorcio = 0;
|
|
nr.AsegasaComisionTotal = 0;
|
|
|
|
nr.FechaEfecto = ur == null ? this.FechaEfecto : ur.FechaVencimiento.AddDays(1);
|
|
nr.FechaVencimiento = nr.FechaEfecto.AddYears(1).AddDays(-1);
|
|
nr.FechaExpedicion = DateOnly.FromDateTime(DateTime.Today);
|
|
nr.FechaRecepcionCia = DateOnly.FromDateTime(DateTime.Today);
|
|
|
|
nr.idDuracion = bd.enumeraciones.First(x => x.Codigo == "DUR.A").idEnumeracion;
|
|
nr.idPoliza = this.idPoliza;
|
|
nr.idAgente = this.idAgente;
|
|
nr.idSubagente = this.idSubAgente;
|
|
nr.IBAN = this.IBAN;
|
|
nr.idTipoPago = this.idTipoPago;
|
|
nr.idTipo = ur == null
|
|
? bd.enumeraciones.First(x => x.Codigo == "TRC.E").idEnumeracion
|
|
: bd.enumeraciones.First(x => x.Codigo == "TRC.C").idEnumeracion;
|
|
|
|
this.recibos.Add(nr);
|
|
if (!this.FechaReciboCompania.HasValue) this.FechaReciboCompania = DateOnly.FromDateTime(DateTime.Now);
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
#region Export DTOs
|
|
public class ListadoPropuestasRealizadas
|
|
{
|
|
public ListadoPropuestasRealizadas(polizassg p)
|
|
{
|
|
NumeroPropuesta = p.idPoliza;
|
|
FechaPropuesta = p.FechaAlta ?? default;
|
|
NumeroPolizaSuplemento = p.NumeroPolizaSuplementoLargo;
|
|
FechaPoliza = p.FechaReciboCompania?.ToDateTime(TimeOnly.MinValue);
|
|
Compañia = p.idCompaniaNavigation?.Nombre ?? "";
|
|
Tomador = p.Tomador?.RazonSocial ?? "* DESCONOCIDO *";
|
|
Telefono = p.Tomador?.Telefono1 ?? "";
|
|
Estado = p.FechaReciboCompania.HasValue ? "EMITIDA" : "PENDIENTE EMITIR CIA.";
|
|
}
|
|
|
|
public int NumeroPropuesta { get; set; }
|
|
public DateTime FechaPropuesta { get; set; }
|
|
public string NumeroPolizaSuplemento { get; set; }
|
|
public DateTime? FechaPoliza { get; set; }
|
|
public string Compañia { get; set; }
|
|
public string Ramo { get; set; }
|
|
public string Tomador { get; set; }
|
|
public string Telefono { get; set; }
|
|
public string Estado { get; set; }
|
|
}
|
|
|
|
public class ListadoGenerico
|
|
{
|
|
public ListadoGenerico(polizassg p)
|
|
{
|
|
NumeroPropuesta = p.idPoliza;
|
|
FechaAlta = p.FechaAlta;
|
|
NumeroPoliza = p.NumeroPoliza;
|
|
Matricula = p.Matricula;
|
|
Compañia = p.idCompaniaNavigation?.Nombre ?? "";
|
|
Ramo = p.idRamoNavigation?.CodigoYDescripcion;
|
|
BienesAsegurados = p.BienesAsegurados;
|
|
TipoCobro = p.TipoCobro;
|
|
TipoPago = p.TipoPago;
|
|
|
|
if (p.EntidadPolizaTomador != null)
|
|
{
|
|
CIFTomador = p.EntidadPolizaTomador.idEntidadNavigation?.CIF;
|
|
Tomador = p.EntidadPolizaTomador.idEntidadNavigation?.RazonSocial;
|
|
Telefono1 = p.EntidadPolizaTomador.Telefono1;
|
|
Telefono2 = p.EntidadPolizaTomador.Telefono2;
|
|
Email = p.EntidadPolizaTomador.Email;
|
|
}
|
|
|
|
var r = p.recibos.Where(x => x.FechaBaja == null).OrderByDescending(x => x.FechaEfecto).FirstOrDefault();
|
|
if (r != null)
|
|
{
|
|
UltimoRecibo = r.CodigoRecibo;
|
|
FechaEfectoUltimoRecibo = r.FechaEfecto.ToDateTime(TimeOnly.MinValue);
|
|
FechaVencimientoUltimoRecibo = r.FechaVencimiento.ToDateTime(TimeOnly.MinValue);
|
|
}
|
|
}
|
|
|
|
public int NumeroPropuesta { get; set; }
|
|
public DateTime? FechaAlta { get; set; }
|
|
public string NumeroPoliza { get; set; }
|
|
public string Matricula { get; set; }
|
|
public string BienesAsegurados { get; set; }
|
|
public string Compañia { get; set; }
|
|
public string Ramo { get; set; }
|
|
public string TipoCobro { get; set; }
|
|
public string TipoPago { get; set; }
|
|
public string CIFTomador { get; set; }
|
|
public string Tomador { get; set; }
|
|
public string Telefono1 { get; set; }
|
|
public string Telefono2 { get; set; }
|
|
public string Email { get; set; }
|
|
public string UltimoRecibo { get; set; }
|
|
public DateTime? FechaEfectoUltimoRecibo { get; set; }
|
|
public DateTime? FechaVencimientoUltimoRecibo { get; set; }
|
|
}
|
|
#endregion
|
|
}
|