agregado procesos y bd clases

This commit is contained in:
2026-04-28 11:52:16 +02:00
parent 59a774c397
commit cd2e8b8530
251 changed files with 56881 additions and 49 deletions

41
bdAsegasa/Enums.cs Normal file
View File

@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bdAsegasa
{
public class Enums
{
public enum TipoImpresionAlbaranEntregaEnum
{
IMPRIMIR_CONTRATO = 0,
IMPRIMIR_ALBARAN_NO_VALORADO = 1,
IMPRIMIR_ALBARAN_VALORADO = 2
}
public enum TarifasEnum
{
A,
B,
C,
D
}
public enum TipoCajaEnum
{
CONTADO = 0,
TPV = 1,
BANCO = 2
}
public enum TipoAplicacionAsientoEnum
{
RECIBO_CONTABILIZACION_PAGO_CONTADO = 20,
RECIBO_BAJA_TIPO_PAGO_PE = 21,
RECIBO_PAGADO_EN_CIA = 22
}
}
}

View 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; }
}
}

View 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; }
}
}

View 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);
}
}

View 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);
}
}

View 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 "";
}
}
}
}
}

View 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;
}
}
}

View 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; }
}
}

View 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; }
}
}

View 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");
}
}
}
}

View File

@@ -0,0 +1,11 @@
namespace bdAsegasa.db
{
public partial class cajas
{
public enum TipoCaja
{
METALICO = 0,
BANCO = 1
}
}
}

View File

@@ -0,0 +1,7 @@
namespace bdAsegasa.db
{
public partial class codigospostales
{
public string NombreMunicipio => !string.IsNullOrEmpty(DescripcionAdicional) ? $"{DescripcionAdicional} ({CodigoMunicipioNavigation?.Nombre})" : (CodigoMunicipioNavigation?.Nombre ?? "");
}
}

View File

@@ -0,0 +1,7 @@
namespace bdAsegasa.db
{
public partial class comisionesagentes
{
public bool AEliminar { get; set; }
}
}

View 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; }
}
}

View 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));
}
}
}
}
}

View File

@@ -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; }
}
}
}

View 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; }
}
}

View 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);
}
}
}
}

View 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 ?? "";
}
}

View File

@@ -0,0 +1,7 @@
namespace bdAsegasa.db
{
public partial class documentosasolicitar
{
public bool ElementoComprobado { get; set; }
}
}

View 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
}
}
}

View 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)));
}
}
}

View 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;
}
}
}
}
}

View 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 **";
}
}
}
}
}

View 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;
}
}
}
}

View 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 "";
}
}
}
}
}

View 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("_", " ");
}
}
}
}

View 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();
}
}
}

View 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;
}
}
}
}

File diff suppressed because it is too large Load Diff

View 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
}
}

View 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);
}
}

View 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);
}
}
}
}

View 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);
}
}
}
}

View File

@@ -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');
}
}
}
}

View 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 ?? "";
}
}
}
}

View 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 "";
}
}
}
}
}

View 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;
}
}
}
}

View 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;
}
}
}
}

View 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 "";
}
}
}
}
}

View 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();
}
}
}
}
}

View 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
}
}
}

View 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()
{
}
}
}

View 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
}
}

View File

@@ -0,0 +1,7 @@
namespace bdAsegasa.db
{
public partial class planeslineas
{
public string PlanesLineasDescripcion => $"{planLinea}, {descripcion}";
}
}

View File

@@ -0,0 +1,7 @@
namespace bdAsegasa.db
{
public partial class plantillas
{
public byte[]? Plantilla => idFicheroNavigation?.Fichero;
}
}

View 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; }
}
}

File diff suppressed because it is too large Load Diff

View 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);
}
}
}
}

View 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;
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -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
{

View 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("_", " ");
}
}

View 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
}
}
}

View 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;
}
}
}
}
}

View 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("_", " ")
: "";
}
}

View 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;
}
}
}
}

View 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;
}
}
}
}

View 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; }
}
}

View 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
}
}

View 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("_", " ");
}
}
}
}

View 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;
}
}
}
}

View 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";
}
}
}
}

View 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;
}
}
}
}

View 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; }
}
}

View 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;
}
}
}
}

View 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;
}
}

View 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) ?? "";
}
}
}
}
}

View 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}";
}
}

View 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("_", " ")
: "";
}
}

View 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 "";
}
}
}
}

View File

@@ -0,0 +1,197 @@
using bdAsegasa.dbcontext;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
namespace bdAsegasa.Informes
{
public class CarteraPerdida
{
public static byte[] GeneraExcelCarteraPerdidaEF(DateOnly fi, DateOnly ff)
{
try
{
var bd = tscgestionasegasa.NuevoContexto();
var fai = fi.AddYears(-1);
var faf = ff.AddYears(-1);
var idLiquidacion = bd.enumeraciones.First(x => x.Codigo == "TIPLIQ.LIQUIDACION").idEnumeracion;
var idLiquidacioncia = bd.enumeraciones.First(x => x.Codigo == "TIPLIQ.PGDO.CIA").idEnumeracion;
var iddevuelto = bd.enumeraciones.First(x => x.Codigo == "TIPLIQ.DEVUELTO").idEnumeracion;
var idDescobro = bd.enumeraciones.First(x => x.Codigo == "TIPLIQ.DESCOBRO").idEnumeracion;
var idCabaPGO = bd.enumeraciones.First(x => x.Codigo == "CABA.PGO").idEnumeracion;
var idCabaFP = bd.enumeraciones.First(x => x.Codigo == "CABA.FP").idEnumeracion;
var idTrex = bd.enumeraciones.First(x => x.Codigo == "TRC.EX").idEnumeracion;
var idTrcx = bd.enumeraciones.First(x => x.Codigo == "TRC.CX").idEnumeracion;
var idDuru = bd.enumeraciones.First(x => x.Codigo == "DUR.U").idEnumeracion;
var lr = new List<ReciboCarteraPerdida>();
var ps = bd.polizassg.Select(x => new { idpoliza = x.idPoliza, idDuracion = x.idDuracion, idCausaBaja = x.idCausaBaja, FechaBaja = x.FechaBaja, NumeroPoliza = x.NumeroPoliza, idCompania = x.idCompania, NumeroSuplemento = x.NumeroSuplemento, FechaVencimiento = x.FechaVencimiento }).ToList();
var POLS = ps.Where(p => p.NumeroPoliza != null)
.GroupBy(p => new { p.NumeroPoliza, p.idCompania })
.Select(g => g.OrderByDescending(Y => Y.NumeroSuplemento).FirstOrDefault())
.Where(X => X.FechaBaja.HasValue == false || (X.idCausaBaja.HasValue && X.idCausaBaja == idCabaFP))
.ToList();
var recsex = bd.vf_recibosextendidos.Where(x => x.FechaEfecto >= fai && x.FechaEfecto <= faf && x.idTipo != idTrex && x.idTipo != idTrcx && x.idDuracion != idDuru)
.Select(x => new { idRecibo = x.idRecibo, Tomador = x.Tomador }).ToList();
var recsant = bd.recibos.Where(x => x.FechaEfecto >= fai && x.FechaEfecto <= faf && x.idTipo != idTrex && x.idTipo != idTrcx && x.idPolizaNavigation.idDuracion != idDuru &&
(x.liquidacionescompaniasrecibos.Any(y => y.idLiquidacionCiaNavigation.idTipoLiquidacion == idLiquidacion || y.idLiquidacionCiaNavigation.idTipoLiquidacion == idLiquidacioncia) ||
(x.liquidacionescompaniasrecibos.Any(y => y.idLiquidacionCiaNavigation.idTipoLiquidacion == iddevuelto && x.idCausaBaja == idCabaPGO))))
.Select(x => new ReciboCarteraPerdida
{
NumeroPoliza = x.idPolizaNavigation.NumeroPoliza,
idRecibo = x.idRecibo.ToString(),
idCompañia = x.idPolizaNavigation.idCompania,
Compañía = x.idPolizaNavigation.idCompaniaNavigation.Nombre,
Ramo = x.idPolizaNavigation.idRamoNavigation.Descripcion,
FechaEfecto = new DateTime(x.FechaEfecto.Year, x.FechaEfecto.Month, x.FechaEfecto.Day),
Observaciones = x.idPolizaNavigation.Observaciones
}).ToList();
var recs = bd.recibos.Where(x => x.FechaEfecto >= fi && x.FechaEfecto <= ff && x.TotalRecibo > 0 && x.idPolizaNavigation.idDuracion != idDuru)
.Select(x => new ReciboCarteraPerdida
{
NumeroPoliza = x.idPolizaNavigation.NumeroPoliza,
idRecibo = x.idRecibo.ToString(),
idCompañia = x.idPolizaNavigation.idCompania,
Compañía = x.idPolizaNavigation.idCompaniaNavigation.Nombre,
Ramo = x.idPolizaNavigation.idRamoNavigation.Descripcion,
FechaEfecto = new DateTime(x.FechaEfecto.Year, x.FechaEfecto.Month, x.FechaEfecto.Day),
Observaciones = x.idPolizaNavigation.Observaciones
}).ToList();
var flim = DateOnly.FromDateTime(DateTime.Now).AddYears(-1);
foreach (var r in recsant)
{
if (lr.Any(X => X.NumeroPoliza == r.NumeroPoliza && X.idCompañia == r.idCompañia) == false &&
recs.Any(x => x.NumeroPoliza == r.NumeroPoliza && x.idCompañia == r.idCompañia) == false &&
POLS.Any(x => x.NumeroPoliza == r.NumeroPoliza && x.idCompania == r.idCompañia && !(x.idDuracion == idDuru && x.FechaVencimiento < flim)))
{
r.Tomador = recsex.First(x => x.idRecibo.ToString() == r.idRecibo).Tomador;
lr.Add(r);
}
}
if (lr.Count > 0)
{
var lrd = lr.OrderBy(x => x.Compañía).ThenBy(x => x.Ramo).Select(x => new { x.NumeroPoliza, x.Compañía, x.Ramo, x.Tomador, FechaEfectoUltimoRecibo = x.FechaEfecto, x.Observaciones }).ToList();
byte[] b = tsUtilidades.Excel.IEnumerableAExcel(lrd);
return b;
}
else
{
return null;
}
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
}
public static byte[] GeneraExcelCarteraPerdida(DateTime fi)
{
try
{
var bd = tscgestionasegasa.NuevoContexto();
var idLiquidacion = bd.enumeraciones.First(x => x.Codigo == "TIPLIQ.LIQUIDACION").idEnumeracion;
var idLiquidacioncia = bd.enumeraciones.First(x => x.Codigo == "TIPLIQ.PGDO.CIA").idEnumeracion;
var fiDate = DateOnly.FromDateTime(fi);
var iddevuelto = bd.enumeraciones.First(x => x.Codigo == "TIPLIQ.DEVUELTO").idEnumeracion;
var idDescobro = bd.enumeraciones.First(x => x.Codigo == "TIPLIQ.DESCOBRO").idEnumeracion;
var idTrex = bd.enumeraciones.First(x => x.Codigo == "TRC.EX").idEnumeracion;
var idTrcx = bd.enumeraciones.First(x => x.Codigo == "TRC.CX").idEnumeracion;
var idDuru = bd.enumeraciones.First(x => x.Codigo == "DUR.U").idEnumeracion;
var lr = new List<ReciboCarteraPerdida>();
var ps = bd.polizassg.Select(x => new { idpoliza = x.idPoliza, idDuracion = x.idDuracion, idCausaBaja = x.idCausaBaja, FechaBaja = x.FechaBaja, NumeroPoliza = x.NumeroPoliza, idCompania = x.idCompania, NumeroSuplemento = x.NumeroSuplemento, FechaVencimiento = x.FechaVencimiento }).ToList();
var POLS = ps.Where(p => p.NumeroPoliza != null)
.GroupBy(p => new { p.NumeroPoliza, p.idCompania })
.Select(g => g.OrderByDescending(Y => Y.NumeroSuplemento).FirstOrDefault())
.Where(X => X.FechaBaja.HasValue == false).ToList();
var recsex = bd.vf_recibosextendidos.Where(x => x.FechaEfecto >= fiDate && x.idTipo != idTrex && x.idTipo != idTrcx && x.idDuracion != idDuru)
.Select(x => new { idRecibo = x.idRecibo, Tomador = x.Tomador, NumeroPoliza = x.NumeroPoliza, idCompania = x.idCompania, FechaVencimiento = x.FechaVencimiento }).ToList();
var recsant = bd.recibos.Where(x => x.FechaEfecto >= fiDate && x.FechaVencimiento <= DateOnly.FromDateTime(DateTime.Today) && x.idTipo != idTrex && x.idTipo != idTrcx && x.idPolizaNavigation.idDuracion != idDuru)
.Select(x => new ReciboCarteraPerdida
{
NumeroPoliza = x.idPolizaNavigation.NumeroPoliza,
idRecibo = x.idRecibo.ToString(),
idCompañia = x.idPolizaNavigation.idCompania,
Compañía = x.idPolizaNavigation.idCompaniaNavigation.Nombre,
Ramo = x.idPolizaNavigation.idRamoNavigation.Descripcion,
FechaEfecto = new DateTime(x.FechaEfecto.Year, x.FechaEfecto.Month, x.FechaEfecto.Day),
FechaVencimiento = new DateTime(x.FechaVencimiento.Year, x.FechaVencimiento.Month, x.FechaVencimiento.Day),
Observaciones = x.idPolizaNavigation.Observaciones
}).ToList();
DateOnly DentroUnMes = DateOnly.FromDateTime( fi.AddMonths(13));
var recs = bd.recibos.Where(x => x.FechaVencimiento >= DentroUnMes && x.TotalRecibo > 0 && x.idPolizaNavigation.idDuracion != idDuru)
.Select(x => new ReciboCarteraPerdida
{
NumeroPoliza = x.idPolizaNavigation.NumeroPoliza,
idRecibo = x.idRecibo.ToString(),
idCompañia = x.idPolizaNavigation.idCompania,
Compañía = x.idPolizaNavigation.idCompaniaNavigation.Nombre,
Ramo = x.idPolizaNavigation.idRamoNavigation.Descripcion,
FechaEfecto = new DateTime(x.FechaEfecto.Year, x.FechaEfecto.Month, x.FechaEfecto.Day),
Observaciones = x.idPolizaNavigation.Observaciones
}).ToList();
var flimduru = fi.AddYears(-1);
foreach (var r in recsant)
{
if (lr.Any(X => X.NumeroPoliza == r.NumeroPoliza && X.idCompañia == r.idCompañia) == false &&
recs.Any(x => x.NumeroPoliza == r.NumeroPoliza && x.idCompañia == r.idCompañia) == false &&
POLS.Any(x => x.NumeroPoliza == r.NumeroPoliza && x.idCompania == r.idCompañia && !(x.idDuracion == idDuru && x.FechaVencimiento < DateOnly.FromDateTime(flimduru))))
{
if (recsex.Any(x => x.NumeroPoliza == r.NumeroPoliza && x.idCompania == r.idCompañia && x.idRecibo.ToString() != r.idRecibo && x.FechaVencimiento > DateOnly.FromDateTime(r.FechaVencimiento.Value)) == false)
{
r.Tomador = recsex.First(x => x.idRecibo.ToString() == r.idRecibo).Tomador;
lr.Add(r);
}
}
}
if (lr.Count > 0)
{
var lrd = lr.OrderBy(x => x.Compañía).ThenBy(x => x.Ramo).Select(x => new { x.NumeroPoliza, x.Compañía, x.Ramo, x.Tomador, FechaEfectoUltimoRecibo = x.FechaEfecto, x.Observaciones }).ToList();
byte[] b = tsUtilidades.Excel.IEnumerableAExcel(lrd);
return b;
}
else
{
return null;
}
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
}
private class ReciboCarteraPerdida
{
public string idRecibo { get; set; }
public string NumeroPoliza { get; set; }
public int? idCompañia { get; set; }
public string Compañía { get; set; }
public string Ramo { get; set; }
public string Tomador { get; set; }
public DateTime? FechaEfecto { get; set; }
public DateTime? FechaVencimiento { get; set; }
public string Observaciones { get; set; }
}
}
}

View File

@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
namespace bdAsegasa.Informes
{
public class CartillaSeguroGenerales
{
public string Rso { get; set; }
public string Cif { get; set; }
public List<PolizaGeneral> PolizasEntidad { get; set; }
public int NumDePolizas { get; set; }
public double TotalPagados { get; set; }
public double TotalAnulados { get; set; }
public double TotalCia { get; set; }
public double TotalPendiente { get; set; }
public string Cia { get; set; }
}
public class SiniestroGeneral
{
public int IdSiniestro { get; set; }
public string RefCompania { get; set; }
public string DescripcionSiniestro { get; set; }
public string DanoCliente { get; set; }
public string DanoContrario { get; set; }
public string Culpabilidad { get; set; }
public string FechaSiniestro { get; set; }
}
public class PolizaGeneral
{
public string NumeroPoliza { get; set; }
public string Ramo { get; set; }
public string Compañia { get; set; }
public List<ReciboPoliza> RecibosPolizas { get; set; }
public List<SiniestroGeneral> SiniestrosEntidad { get; set; }
}
public class ReciboPoliza
{
public DateTime FechaEfecto { get; set; }
public DateTime? FechaVencimiento { get; set; }
public double Importe { get; set; }
public string Matricula { get; set; }
public string Duracion { get; set; }
public string TipoPago { get; set; }
public string FechaPago { get; set; }
public string CausaBaja { get; set; }
public string FechaBaja { get; set; }
public string BienesAsegurados { get; set; }
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,12 @@
namespace bdAsegasa.Informes
{
public class CombinacionCorrespondenciaPagosTelematicos
{
public string NumeroOperacion { get; set; }
public string FechaOperacion { get; set; }
public string Importe { get; set; }
public string Referencia { get; set; }
public string RazonSocial { get; set; }
public string DNI { get; set; }
}
}

View File

@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using bdAsegasa.db;
namespace bdAsegasa.Informes
{
public class DetallesPoliza
{
public string NumeroPropuesta { get; set; }
public string Compania { get; set; }
public string NumeroPoliza { get; set; }
public string NumeroSuplemento { get; set; }
public string FechaEnvioCompania { get; set; }
public string FechaRecibidoCompania { get; set; }
public string Duracion { get; set; }
public string FechaEfecto { get; set; }
public string FechaVencimiento { get; set; }
public string FechaBaja { get; set; }
public string CausaBaja { get; set; }
public string Ramo { get; set; }
public string Agente { get; set; }
public string SubAgente { get; set; }
public string BienesAsegurados { get; set; }
public string Matricula { get; set; }
public string Coberturas { get; set; }
public string Garantias { get; set; }
public string DescripcionSumplemento { get; set; }
public string FechaAceptacionPropuesta { get; set; }
public string SuplementoRechazdoPorCompania { get; set; }
public string Observaciones { get; set; }
public string Usuario { get; set; }
public string FechaAlta { get; set; }
public string TipoPago { get; set; }
public string IBAN { get; set; }
public string FechaMandato { get; set; }
public string TipoCobro { get; set; }
public string Directorio { get; set; }
public List<entidades> Tomador { get; set; }
public List<entidades> OtroAsegurado { get; set; }
}
}

View File

@@ -0,0 +1,25 @@
using System.Collections.Generic;
namespace bdAsegasa.Informes
{
public class DifPolSup
{
public string Compania { get; set; }
public string TomadorActual { get; set; }
public string NumPoliza { get; set; }
public string NumPropuesta { get; set; }
public string Ramo { get; set; }
public string Matricula { get; set; }
public string NumSuplemento { get; set; }
public List<Modificacion> ModEnPoliza { get; set; }
public List<Modificacion> ModEnAsegurados { get; set; }
public string Aclaracion1 { get; set; }
public string Aclaracion2 { get; set; }
}
public class Modificacion
{
public string Concepto { get; set; }
public string ValorNuevo { get; set; }
}
}

View File

@@ -0,0 +1,105 @@
using bdAsegasa.db;
using bdAsegasa.dbcontext;
using DevExpress.XtraReports.UI;
using Microsoft.EntityFrameworkCore;
using System;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using tsEFCore8;
using tsUtilidades;
using static Google.Protobuf.WellKnownTypes.FieldMask;
namespace bdAsegasa.Informes
{
public class Informes
{
public static void ImprimeInforme(XtraReport xr, object Datos, bool ImpresoraPredeterminada)
{
foreach (DevExpress.XtraReports.Parameters.Parameter pr in xr.Parameters)
{
pr.Visible = false;
}
xr.DataSource = Datos;
xr.CreateDocument(true);
if (ImpresoraPredeterminada)
{
xr.Print();
}
else
{
xr.Print();
}
}
public static MemoryStream GeneraXLSX(XtraReport xr, object Datos)
{
MemoryStream ms = new MemoryStream();
foreach (DevExpress.XtraReports.Parameters.Parameter pr in xr.Parameters)
{
pr.Visible = false;
}
xr.DataSource = Datos;
xr.CreateDocument(true);
xr.ExportToXlsx(ms);
return ms;
}
public static MemoryStream GeneraPDF(bdAsegasa.tscgestionasegasa bd, int idPlantilla, object Datasource)
{
try
{
if (idPlantilla == 0)
throw new Exception("Seleccione primero la plantilla a imprimir");
XtraReport xr = new XtraReport();
var plantillas = bd.plantillas.ToList();
var pl = plantillas.Where(x => x.idPlantilla == idPlantilla).First();
string s = Encoding.UTF8.GetString(pl.idFicheroNavigation.Fichero);
using (MemoryStream tempMs = new MemoryStream())
{
using (StreamWriter sw = new StreamWriter(tempMs, Encoding.UTF8, 1024, true))
{
sw.Write(s);
sw.Flush();
tempMs.Position = 0;
xr = XtraReport.FromStream(tempMs, true);
}
}
try
{
var pr = xr.Parameters.Cast<DevExpress.XtraReports.Parameters.Parameter>().FirstOrDefault(p => p.Name == "Fecha");
if (pr != null)
{
pr.Value = DateTime.Now;
pr.Visible = false;
}
}
catch
{
// Ignorar si el par<61>metro no existe
}
xr.DataSource = Datasource;
xr.CreateDocument(true);
MemoryStream ms = new MemoryStream();
xr.ExportToPdf(ms);
ms.Position = 0; // Importante para que quien reciba el stream pueda leerlo desde el inicio
return ms;
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
}
}
}

View File

@@ -0,0 +1,25 @@
using System.Collections.Generic;
namespace bdAsegasa.Informes
{
public class InformesAgrarios
{
public List<LinInformesAgrarios> DatosLineas { get; set; }
}
public class LinInformesAgrarios
{
public string CodLinea { get; set; }
public string GruLinea { get; set; }
public string DesLinea { get; set; }
public string Compania { get; set; }
public int NumPolizas { get; set; }
public double PrimaNetaCalculo { get; set; }
public double ComAsegasa { get; set; }
public double ComAgentes { get; set; }
public double ComAsegasaPrev { get; set; }
public double ComAgentesPrev { get; set; }
public double TotComCob { get; set; }
public double TotComPrev { get; set; }
}
}

View File

@@ -0,0 +1,39 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace bdAsegasa.Presupuestos
{
[Serializable]
[NotMapped]
public class AccidentesIndividualesAXA
{
public string TomadorCIF { get; set; }
public string TomadorNombre { get; set; }
public string TomadorApellidos { get; set; }
public string TomadorTelefono { get; set; }
public string TomadorEmail { get; set; }
public string TomadorDomicilio { get; set; }
public string TomadorCodigoPostal { get; set; }
public string TomadorPoblacion { get; set; }
public string TomadorProvincia { get; set; }
public string TomadorCodigoMunicipio { get; set; }
public string PropietarioCIF { get; set; }
public string PropietarioNombre { get; set; }
public string PropietarioApellidos { get; set; }
public string PropietarioTelefono { get; set; }
public string PropietarioEmail { get; set; }
public string PropietarioDomicilio { get; set; }
public string PropietarioCodigoPostal { get; set; }
public string PropietarioPoblacion { get; set; }
public string PropietarioProvincia { get; set; }
public string PropietarioCodigoMunicipio { get; set; }
public string Observaciones { get; set; }
public string CapitalElegido { get; set; }
public string IBAN { get; set; }
public DateTime FechaEfecto { get; set; }
public DateTime FechaVencimiento { get; set; }
}
}

View File

@@ -0,0 +1,38 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace bdAsegasa.Presupuestos
{
[Serializable]
[NotMapped]
public class CasetasRiegoAXA
{
public string TomadorCIF { get; set; }
public string TomadorNombre { get; set; }
public string TomadorApellidos { get; set; }
public string TomadorTelefono { get; set; }
public string TomadorEmail { get; set; }
public string TomadorDomicilio { get; set; }
public string TomadorCodigoPostal { get; set; }
public string TomadorPoblacion { get; set; }
public string TomadorProvincia { get; set; }
public string TomadorCodigoMunicipio { get; set; }
public string CasetaUbicacion { get; set; }
public string CasetaLocalidad { get; set; }
public string CasetaCodigoPostal { get; set; }
public string CasetaProvincia { get; set; }
public string EdificiosDescripcion { get; set; }
public string EdificiosCapital { get; set; }
public string MobiliarioDescripcion { get; set; }
public string MobiliarioCapital { get; set; }
public string ExistenciasDescripcion { get; set; }
public string ExistenciasCapital { get; set; }
public string CapitalElegido { get; set; }
public string IBAN { get; set; }
public DateTime FechaEfecto { get; set; }
public DateTime FechaVencimiento { get; set; }
}
}

View File

@@ -0,0 +1,42 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace bdAsegasa.Presupuestos
{
[Serializable]
[NotMapped]
public class Patinetes
{
public string TomadorCIF { get; set; }
public string TomadorNombre { get; set; }
public string TomadorApellidos { get; set; }
public string TomadorTelefono { get; set; }
public string TomadorCorreo { get; set; }
public string TomadorDomicilio { get; set; }
public string TomadorCodigoPostal { get; set; }
public string TomadorPoblacion { get; set; }
public string TomadorProvincia { get; set; }
public string TomadorCodigoMunicipio { get; set; }
public string PropietarioCIF { get; set; }
public string PropietarioNombre { get; set; }
public string PropietarioApellidos { get; set; }
public string PropietarioTelefono { get; set; }
public string PropietarioCorreo { get; set; }
public string PropietarioDomicilio { get; set; }
public string PropietarioCodigoPostal { get; set; }
public string PropietarioPoblacion { get; set; }
public string PropietarioProvincia { get; set; }
public string PropietarioCodigoMunicipio { get; set; }
public string Producto { get; set; }
public string Identificador { get; set; }
public DateTime FechaCompra { get; set; }
public double PrimaAnualizada { get; set; }
public string Observaciones { get; set; }
public string IBAN { get; set; }
public DateTime FechaEfecto { get; set; }
public DateTime FechaVencimiento { get; set; }
}
}

View File

@@ -0,0 +1,27 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace bdAsegasa.Presupuestos
{
[Serializable]
[NotMapped]
public class RCCaballos
{
public string TomadorCIF { get; set; }
public string TomadorNombre { get; set; }
public string TomadorApellidos { get; set; }
public string TomadorTelefono { get; set; }
public string TomadorEmail { get; set; }
public string TomadorDomicilio { get; set; }
public string TomadorCodigoPostal { get; set; }
public string TomadorPoblacion { get; set; }
public string TomadorProvincia { get; set; }
public string TomadorCodigoMunicipio { get; set; }
public string DocumentacionEquina { get; set; }
public string Observaciones { get; set; }
public string IBAN { get; set; }
public DateTime FechaEfecto { get; set; }
public DateTime FechaVencimiento { get; set; }
}
}

View File

@@ -0,0 +1,53 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace bdAsegasa.Presupuestos
{
[Serializable]
[NotMapped]
public class RCCotosCazaCaser
{
public double NumeroHectareas { get; set; }
public double OpcionA { get; set; }
public double OpcionB { get; set; }
public double OpcionC { get; set; }
public string OpcionElegida { get; set; }
public string TotalOpcionElegida { get; set; }
public string LimitePorSiniestro { get; set; }
public string TomadorCIF { get; set; }
public string TomadorNombre { get; set; }
public string TomadorApellidos { get; set; }
public string TomadorTelefono { get; set; }
public string TomadorDomicilio { get; set; }
public string TomadorCodigoPostal { get; set; }
public string TomadorPoblacion { get; set; }
public string TomadorProvincia { get; set; }
public string TomadorCodigoMunicipio { get; set; }
public string PropietarioCIF { get; set; }
public string PropietarioNombre { get; set; }
public string PropietarioApellidos { get; set; }
public string PropietarioTelefono { get; set; }
public string PropietarioDomicilio { get; set; }
public string PropietarioCodigoPostal { get; set; }
public string PropietarioPoblacion { get; set; }
public string PropietarioProvincia { get; set; }
public string PropietarioCodigoMunicipio { get; set; }
public string RiesgoCodigoMunicipio { get; set; }
public string RiesgoSituacion { get; set; }
public string RiesgoCodigoPostal { get; set; }
public string RiesgoPoblacion { get; set; }
public string RiesgoProvincia { get; set; }
public string RiesgoActividad { get; set; }
public string RiesgoEpigrafe { get; set; }
public string RiesgoDescripcion { get; set; }
public string AclaracionesDeLaActividad { get; set; }
public string Observaciones { get; set; }
public DateTime FechaEfecto { get; set; }
public DateTime FechaVencimiento { get; set; }
public string IBAN { get; set; }
}
}

View File

@@ -0,0 +1,28 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace bdAsegasa.Presupuestos
{
[Serializable]
[NotMapped]
public class RCMaquinariaAgricola
{
public string AseguradoCIF { get; set; }
public string AseguradoNombre { get; set; }
public string AseguradoApellidos { get; set; }
public string AseguradoDireccion { get; set; }
public string AseguradoCodigoPostal { get; set; }
public string CodigoMunicipio { get; set; }
public string AseguradoPoblacion { get; set; }
public string AseguradoTelefono1 { get; set; }
public string AseguradoTelefono2 { get; set; }
public string AseguradoCorreo { get; set; }
public DateTime FechaEfecto { get; set; }
public string FechaVencimiento { get; set; }
public string IBAN { get; set; }
public string Matricula { get; set; }
public string Cobertura { get; set; }
public string Elegida { get; set; }
public string PrimaTotal { get; set; }
}
}

View File

@@ -0,0 +1,62 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace bdAsegasa.Presupuestos
{
[Serializable]
[NotMapped]
public class RCPerros
{
public string TomadorCIF { get; set; }
public string TomadorNombre { get; set; }
public string TomadorApellidos { get; set; }
public string TomadorTelefono { get; set; }
public string TomadorEmail { get; set; }
public string TomadorDomicilio { get; set; }
public string TomadorCodigoPostal { get; set; }
public string TomadorPoblacion { get; set; }
public string TomadorProvincia { get; set; }
public string TomadorCodigoMunicipio { get; set; }
public string PropietarioCIF { get; set; }
public string PropietarioNombre { get; set; }
public string PropietarioApellidos { get; set; }
public string PropietarioTelefono { get; set; }
public string PropietarioEmail { get; set; }
public string PropietarioDomicilio { get; set; }
public string PropietarioCodigoPostal { get; set; }
public string PropietarioPoblacion { get; set; }
public string PropietarioProvincia { get; set; }
public string PropietarioCodigoMunicipio { get; set; }
public string CoberturaElegida { get; set; }
public string PrecioCobertura { get; set; }
public int NumeroPerrosPeligrosos { get; set; }
public int NumeroPerrosNoPeligrosos { get; set; }
public double PrimaPerrosPeligrosos { get; set; }
public double PrimaPerrosNoPeligrosos { get; set; }
public double PrecioPerrosPeligrosos { get; set; }
public double PrecioPerrosNoPeligrosos { get; set; }
public string PrimeroRaza { get; set; }
public string PrimeroMicrochip { get; set; }
public string PrimeroNombre { get; set; }
public DateTime PrimeroFechaNacimiento { get; set; }
public string SegundoRaza { get; set; }
public string SegundoMicrochip { get; set; }
public string SegundoNombre { get; set; }
public DateTime SegundoFechaNacimiento { get; set; }
public string TerceroRaza { get; set; }
public string TerceroMicrochip { get; set; }
public string TerceroNombre { get; set; }
public DateTime TerceroFechaNacimiento { get; set; }
public string Observaciones { get; set; }
public string IBAN { get; set; }
public DateTime FechaEfecto { get; set; }
public DateTime FechaVencimiento { get; set; }
public string TipoPerro { get; set; }
}
}

View File

@@ -0,0 +1,150 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace bdAsegasa.Presupuestos
{
[Serializable]
[NotMapped]
public class RCSociosCaser
{
public string Nombre { get; set; }
public string Situacion { get; set; }
public string TMunicipal { get; set; }
public string FProvincia { get; set; }
public string Descripcion { get; set; }
public double Equino { get; set; }
public double VacunoManso { get; set; }
public double Porcino { get; set; }
public double OvinoCaprino { get; set; }
public double Aviar { get; set; }
public double Cunicula { get; set; }
public double TotalGanado { get; set; }
public double VacunoBravo { get; set; }
public double MenorSinJabalies { get; set; }
public double MenorConJabalies { get; set; }
public double MayorSinMalla { get; set; }
public double MayorConMalla { get; set; }
public double HasLabor { get; set; }
public double HasDehesa { get; set; }
public double TotalSuperficie { get; set; }
public int OpcionElegida { get; set; }
public string Total { get; set; }
public string IBAN { get; set; }
public double DañosMateriales1 { get; set; }
public double DañosMateriales2 { get; set; }
public double DañosMateriales3 { get; set; }
public double DañosMateriales4 { get; set; }
public double DañosMateriales5 { get; set; }
public double DañosMateriales6 { get; set; }
public double Sublimite1 { get; set; }
public double Sublimite2 { get; set; }
public double Sublimite3 { get; set; }
public double Sublimite4 { get; set; }
public double Sublimite5 { get; set; }
public double Sublimite6 { get; set; }
public double Patronal1 { get; set; }
public double Patronal2 { get; set; }
public double Patronal3 { get; set; }
public double Patronal4 { get; set; }
public double Patronal5 { get; set; }
public double Patronal6 { get; set; }
public double PNetaLabor1 { get; set; }
public double PNetaLabor2 { get; set; }
public double PNetaLabor3 { get; set; }
public double PNetaLabor4 { get; set; }
public double PNetaLabor5 { get; set; }
public double PNetaLabor6 { get; set; }
public double PNetaGanado1 { get; set; }
public double PNetaGanado2 { get; set; }
public double PNetaGanado3 { get; set; }
public double PNetaGanado4 { get; set; }
public double PNetaGanado5 { get; set; }
public double PNetaGanado6 { get; set; }
public double PNetaGanaderia1 { get; set; }
public double PNetaGanaderia2 { get; set; }
public double PNetaGanaderia3 { get; set; }
public double PNetaGanaderia4 { get; set; }
public double PNetaGanaderia5 { get; set; }
public double PNetaGanaderia6 { get; set; }
public double PSubtotal1 { get; set; }
public double PSubtotal2 { get; set; }
public double PSubtotal3 { get; set; }
public double PSubtotal4 { get; set; }
public double PSubtotal5 { get; set; }
public double PSubtotal6 { get; set; }
public double MenorSinJabalies1 { get; set; }
public double MenorSinJabalies2 { get; set; }
public double MenorSinJabalies3 { get; set; }
public double MenorSinJabalies4 { get; set; }
public double MenorSinJabalies5 { get; set; }
public double MenorSinJabalies6 { get; set; }
public double MenorConJabalies1 { get; set; }
public double MenorConJabalies2 { get; set; }
public double MenorConJabalies3 { get; set; }
public double MenorConJabalies4 { get; set; }
public double MenorConJabalies5 { get; set; }
public double MenorConJabalies6 { get; set; }
public double MayorSinMalla1 { get; set; }
public double MayorSinMalla2 { get; set; }
public double MayorSinMalla3 { get; set; }
public double MayorSinMalla4 { get; set; }
public double MayorSinMalla5 { get; set; }
public double MayorSinMalla6 { get; set; }
public double MayorConMalla1 { get; set; }
public double MayorConMalla2 { get; set; }
public double MayorConMalla3 { get; set; }
public double MayorConMalla4 { get; set; }
public double MayorConMalla5 { get; set; }
public double MayorConMalla6 { get; set; }
public double CotosSubtotal1 { get; set; }
public double CotosSubtotal2 { get; set; }
public double CotosSubtotal3 { get; set; }
public double CotosSubtotal4 { get; set; }
public double CotosSubtotal5 { get; set; }
public double CotosSubtotal6 { get; set; }
public double PNeta1 { get; set; }
public double PNeta2 { get; set; }
public double PNeta3 { get; set; }
public double PNeta4 { get; set; }
public double PNeta5 { get; set; }
public double PNeta6 { get; set; }
public double Impuestos1 { get; set; }
public double Impuestos2 { get; set; }
public double Impuestos3 { get; set; }
public double Impuestos4 { get; set; }
public double Impuestos5 { get; set; }
public double Impuestos6 { get; set; }
public double PTotal1 { get; set; }
public double PTotal2 { get; set; }
public double PTotal3 { get; set; }
public double PTotal4 { get; set; }
public double PTotal5 { get; set; }
public double PTotal6 { get; set; }
public string AseguradoCIF { get; set; }
public string AseguradoNombre { get; set; }
public string AseguradoApellidos { get; set; }
public string AseguradoDireccion { get; set; }
public string AseguradoCodigoPostal { get; set; }
public string CodigoMunicipio { get; set; }
public string AseguradoPoblacion { get; set; }
public string AseguradoTelefono1 { get; set; }
public string AseguradoTelefono2 { get; set; }
public string AseguradoCorreo { get; set; }
}
}

View File

@@ -0,0 +1,71 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace bdAsegasa.Presupuestos
{
[Serializable]
[NotMapped]
public class RCSociosZurich
{
public string TomadorCIF { get; set; }
public string TomadorNombre { get; set; }
public string TomadorApellidos { get; set; }
public string TomadorTelefono { get; set; }
public string TomadorTelefono2 { get; set; }
public string TomadorEmail { get; set; }
public string TomadorDomicilio { get; set; }
public string TomadorCodigoPostal { get; set; }
public string TomadorPoblacion { get; set; }
public string TomadorProvincia { get; set; }
public string TomadorCodigoMunicipio { get; set; }
public string PropietarioCIF { get; set; }
public string PropietarioNombre { get; set; }
public string PropietarioApellidos { get; set; }
public string PropietarioTelefono { get; set; }
public string PropietarioTelefono2 { get; set; }
public string PropietarioEmail { get; set; }
public string PropietarioDomicilio { get; set; }
public string PropietarioCodigoPostal { get; set; }
public string PropietarioPoblacion { get; set; }
public string PropietarioProvincia { get; set; }
public string PropietarioCodigoMunicipio { get; set; }
public double Dehesa { get; set; }
public double SuperficieCosechable { get; set; }
public double CotoDeCaza { get; set; }
public double VidaPrivada { get; set; }
public int CabezasVacuno { get; set; }
public int CabezasOvino { get; set; }
public int CabezasPorcino { get; set; }
public int CabezasEquino { get; set; }
public int CabezasGanadoBravo { get; set; }
public string NumeroRega { get; set; }
public string CodigoGanadero { get; set; }
public string Observaciones { get; set; }
public string SumaContratar { get; set; }
public string IBAN { get; set; }
public DateTime FechaEfecto { get; set; }
public DateTime FechaVencimiento { get; set; }
public string FormaPago { get; set; }
public string TipoRC { get; set; }
public double OpcionA { get; set; }
public double OpcionB { get; set; }
public double OpcionC { get; set; }
public double PrimaNetaA { get; set; }
public double PrimaNetaB { get; set; }
public double PrimaNetaC { get; set; }
public double ImpuestosA { get; set; }
public double ImpuestosB { get; set; }
public string ImpuestosC { get; set; }
public double PrimaTotalA { get; set; }
public double PrimaTotalB { get; set; }
public double PrimaTotalC { get; set; }
}
}

View File

@@ -0,0 +1,129 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace bdAsegasa.Presupuestos
{
[Serializable]
[NotMapped]
public class SaludMapfre
{
public string TomadorCIF { get; set; }
public string TomadorNombre { get; set; }
public string TomadorApellidos { get; set; }
public string TomadorTelefono { get; set; }
public string TomadorEmail { get; set; }
public string TomadorDomicilio { get; set; }
public string TomadorCodigoPostal { get; set; }
public string TomadorPoblacion { get; set; }
public string TomadorProvincia { get; set; }
public string TomadorCodigoMunicipio { get; set; }
public DateTime TomadorFechaNacimiento { get; set; }
public string TomadorSexo { get; set; }
public string TomadorEstadoCivil { get; set; }
public string Asegurado1CIF { get; set; }
public string Asegurado1Nombre { get; set; }
public string Asegurado1Apellidos { get; set; }
public string Asegurado1Domicilio { get; set; }
public string Asegurado1CodigoPostal { get; set; }
public string Asegurado1Poblacion { get; set; }
public string Asegurado1Provincia { get; set; }
public string Asegurado1CodigoMunicipio { get; set; }
public string Asegurado1Telefono { get; set; }
public string Asegurado1Email { get; set; }
public DateTime Asegurado1FechaNacimiento { get; set; }
public string Asegurado1Sexo { get; set; }
public int Asegurado1Peso { get; set; }
public int Asegurado1Estatura { get; set; }
public string Asegurado1Profesion { get; set; }
public string Asegurado1Parentesco { get; set; }
public string Asegurado2CIF { get; set; }
public string Asegurado2Nombre { get; set; }
public string Asegurado2Apellidos { get; set; }
public string Asegurado2Domicilio { get; set; }
public string Asegurado2CodigoPostal { get; set; }
public string Asegurado2Poblacion { get; set; }
public string Asegurado2Provincia { get; set; }
public string Asegurado2CodigoMunicipio { get; set; }
public string Asegurado2Telefono { get; set; }
public string Asegurado2Email { get; set; }
public DateTime Asegurado2FechaNacimiento { get; set; }
public string Asegurado2Sexo { get; set; }
public int Asegurado2Peso { get; set; }
public int Asegurado2Estatura { get; set; }
public string Asegurado2Profesion { get; set; }
public string Asegurado2Parentesco { get; set; }
public string Asegurado3CIF { get; set; }
public string Asegurado3Nombre { get; set; }
public string Asegurado3Apellidos { get; set; }
public string Asegurado3Domicilio { get; set; }
public string Asegurado3CodigoPostal { get; set; }
public string Asegurado3Poblacion { get; set; }
public string Asegurado3Provincia { get; set; }
public string Asegurado3CodigoMunicipio { get; set; }
public string Asegurado3Telefono { get; set; }
public string Asegurado3Email { get; set; }
public DateTime Asegurado3FechaNacimiento { get; set; }
public string Asegurado3Sexo { get; set; }
public int Asegurado3Peso { get; set; }
public int Asegurado3Estatura { get; set; }
public string Asegurado3Profesion { get; set; }
public string Asegurado3Parentesco { get; set; }
public string Asegurado4CIF { get; set; }
public string Asegurado4Nombre { get; set; }
public string Asegurado4Apellidos { get; set; }
public string Asegurado4Domicilio { get; set; }
public string Asegurado4CodigoPostal { get; set; }
public string Asegurado4Poblacion { get; set; }
public string Asegurado4Provincia { get; set; }
public string Asegurado4CodigoMunicipio { get; set; }
public string Asegurado4Telefono { get; set; }
public string Asegurado4Email { get; set; }
public DateTime Asegurado4FechaNacimiento { get; set; }
public string Asegurado4Sexo { get; set; }
public int Asegurado4Peso { get; set; }
public string Asegurado4Estatura { get; set; }
public string Asegurado4Profesion { get; set; }
public string Asegurado4Parentesco { get; set; }
public bool Pregunta1Asegurado1 { get; set; }
public bool Pregunta1Asegurado2 { get; set; }
public bool Pregunta1Asegurado3 { get; set; }
public bool Pregunta1Asegurado4 { get; set; }
public bool Pregunta2Asegurado1 { get; set; }
public bool Pregunta2Asegurado2 { get; set; }
public bool Pregunta2Asegurado3 { get; set; }
public bool Pregunta2Asegurado4 { get; set; }
public bool Pregunta3Asegurado1 { get; set; }
public bool Pregunta3Asegurado2 { get; set; }
public bool Pregunta3Asegurado3 { get; set; }
public bool Pregunta3Asegurado4 { get; set; }
public bool Pregunta4Asegurado1 { get; set; }
public bool Pregunta4Asegurado2 { get; set; }
public bool Pregunta4Asegurado3 { get; set; }
public bool Pregunta4Asegurado4 { get; set; }
public bool Pregunta5Asegurado1 { get; set; }
public bool Pregunta5Asegurado2 { get; set; }
public bool Pregunta5Asegurado3 { get; set; }
public bool Pregunta5Asegurado4 { get; set; }
public string Observaciones { get; set; }
public bool AsistenciaSanitaria { get; set; }
public bool GarantiaBucodental { get; set; }
public bool ReembolsoGastosCompletos { get; set; }
public bool ReembolsoGastosHospitalarios { get; set; }
public bool ReembolsoGranCobertura { get; set; }
public string FormaPago { get; set; }
public string IBAN { get; set; }
public DateTime FechaEfecto { get; set; }
public DateTime FechaVencimiento { get; set; }
}
}

View File

@@ -0,0 +1,28 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace bdAsegasa.Presupuestos
{
[Serializable]
[NotMapped]
public class TarificadorGenerico
{
public string TomadorCIF { get; set; }
public string TomadorNombre { get; set; }
public string TomadorApellidos { get; set; }
public string TomadorTelefono { get; set; }
public string TomadorTelefono2 { get; set; }
public string TomadorEmail { get; set; }
public string TomadorDomicilio { get; set; }
public string TomadorCodigoPostal { get; set; }
public string TomadorPoblacion { get; set; }
public string TomadorProvincia { get; set; }
public string TomadorCodigoMunicipio { get; set; }
public string FormaPago { get; set; }
public string IBAN { get; set; }
public string Total { get; set; }
public DateTime FechaEfecto { get; set; }
public DateTime FechaVencimiento { get; set; }
}
}

View File

@@ -0,0 +1,64 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace bdAsegasa.Presupuestos
{
[Serializable]
[NotMapped]
public class TarificadorMaquinaria
{
public string TomadorCIF { get; set; }
public string TomadorNombre { get; set; }
public string TomadorApellidos { get; set; }
public string TomadorTelefono { get; set; }
public string TomadorEmail { get; set; }
public string TomadorDomicilio { get; set; }
public string TomadorCodigoPostal { get; set; }
public string TomadorPoblacion { get; set; }
public string TomadorProvincia { get; set; }
public string TomadorCodigoMunicipio { get; set; }
public string PropietarioCIF { get; set; }
public string PropietarioNombre { get; set; }
public string PropietarioApellidos { get; set; }
public string PropietarioTelefono { get; set; }
public string PropietarioEmail { get; set; }
public string PropietarioDomicilio { get; set; }
public string PropietarioCodigoPostal { get; set; }
public string PropietarioPoblacion { get; set; }
public string PropietarioProvincia { get; set; }
public string PropietarioCodigoMunicipio { get; set; }
public string Matricula { get; set; }
public string UsoAlQueSeDestina { get; set; }
public int AntiguedadMaquinaria { get; set; }
public int NumeroMaquinasAseguradas { get; set; }
public int Cosechadoras { get; set; }
public int CosechadorasRotura { get; set; }
public int TractoresAgricolas { get; set; }
public int Empacadoras { get; set; }
public int Vendimiadoras { get; set; }
public int NoAutoPropulsados { get; set; }
public int VibradoresOlivos { get; set; }
public double CosechadorasCalculado { get; set; }
public double CosechadorasRoturaCalculado { get; set; }
public double TractoresAgricolasCalculado { get; set; }
public double EmpacadorasCalculado { get; set; }
public double VendimiadorasCalculado { get; set; }
public double NoAutoPropulsadosCalculado { get; set; }
public double VibradoresOlivosCalculado { get; set; }
public double PrimaNetaMinima { get; set; }
public double PrimaNeta { get; set; }
public double Impuestos { get; set; }
public double PrimaTotal { get; set; }
public string Condicionantes { get; set; }
public string Observaciones { get; set; }
public string DaniosLuna { get; set; }
public string IBAN { get; set; }
public DateTime FechaEfecto { get; set; }
public DateTime FechaVencimiento { get; set; }
}
}

View File

@@ -0,0 +1,47 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace bdAsegasa.Presupuestos
{
[Serializable]
[NotMapped]
public class TarificadorMaquinariaPlusUltra
{
public string TomadorCIF { get; set; }
public string TomadorNombre { get; set; }
public string TomadorApellidos { get; set; }
public string TomadorTelefono { get; set; }
public string TomadorTelefono2 { get; set; }
public string TomadorEmail { get; set; }
public string TomadorDomicilio { get; set; }
public string TomadorCodigoPostal { get; set; }
public string TomadorPoblacion { get; set; }
public string TomadorProvincia { get; set; }
public string TomadorCodigoMunicipio { get; set; }
public string TipoMaquinaria { get; set; }
public string UsoAlQueSeDestina { get; set; }
public double ValorMaquinaria { get; set; }
public double ValorAccesorios { get; set; }
public string ExistenciasProductoRecolectado { get; set; }
public string Marca { get; set; }
public string Modelo { get; set; }
public DateTime FechaMatriculacion { get; set; }
public string Antiguedad { get; set; }
public string Estado { get; set; }
public string GarantiaIncendio { get; set; }
public string GarantiaResponsabilidadCivil { get; set; }
public string RiesgosExtensivos { get; set; }
public string Paralizacion { get; set; }
public string RoboExpoliacion { get; set; }
public string Lunas { get; set; }
public string FormaPago { get; set; }
public string IBAN { get; set; }
public string Total { get; set; }
public DateTime FechaEfecto { get; set; }
public DateTime FechaVencimiento { get; set; }
}
}

View File

@@ -0,0 +1,61 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace bdAsegasa.Presupuestos
{
[Serializable]
[NotMapped]
public class Tractores
{
public double Peso { get; set; }
public string Marca { get; set; }
public string Modelo { get; set; }
public string Version { get; set; }
public DateTime FechaPrimeraMatriculacion { get; set; }
public string TipoVehiculo { get; set; }
public string Matricula { get; set; }
public string TomadorCodigoMunicipio { get; set; }
public string TomadorDocumento { get; set; }
public string TomadorTipoDocumento { get; set; }
public string TomadorNombre { get; set; }
public string TomadorApellido1 { get; set; }
public string TomadorApellido2 { get; set; }
public DateTime TomadorFechaNacimiento { get; set; }
public string EstadoCivil { get; set; }
public int TomadorSexo { get; set; }
public string TomadorVia { get; set; }
public string TomadorNombreVia { get; set; }
public string TomadorNumeroVia { get; set; }
public string TomadorRestoVia { get; set; }
public string TomadorCodigoPostal { get; set; }
public string TomadorPoblacion { get; set; }
public string Telefono1 { get; set; }
public string Telefono2 { get; set; }
public string CorreoElectronico { get; set; }
public string TipoPropietario { get; set; }
public string PropietarioDocumento { get; set; }
public string PropietarioNombre { get; set; }
public string PropietarioApellido1 { get; set; }
public string PropietarioApellido2 { get; set; }
public DateTime PropietarioFechaNacimiento { get; set; }
public int PropietarioSexo { get; set; }
public string TipoConductor { get; set; }
public DateTime FechaPermisoConduccion { get; set; }
public string ConductorIdEntidad { get; set; }
public string ConductorDocumento { get; set; }
public string ConductorNombre { get; set; }
public string ConductorApellido1 { get; set; }
public string ConductorApellido2 { get; set; }
public int ConductorSexo { get; set; }
public DateTime ConductorFechaNacimiento { get; set; }
public string FechaEfecto { get; set; }
public string IBAN { get; set; }
public string CombinacionAccidentes { get; set; }
public string UsoVehiculo { get; set; }
public string PrimaTotal { get; set; }
}
}

View File

@@ -0,0 +1,37 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace bdAsegasa.Presupuestos
{
[Serializable]
[NotMapped]
public class TractoresEuropAssistance
{
public string Matricula { get; set; }
public string Marca { get; set; }
public string Modelo { get; set; }
public string Version { get; set; }
public DateTime FechaMatriculacion { get; set; }
public string CIF { get; set; }
public string RazonSocial { get; set; }
public DateTime FechaNacimiento { get; set; }
public string EstadoCivil { get; set; }
public string Sexo { get; set; }
public string Telefono1 { get; set; }
public string Telefono2 { get; set; }
public string Email { get; set; }
public string FechaEfecto { get; set; }
public string FechaVencimiento { get; set; }
public string Direccion { get; set; }
public string CodigoPostal { get; set; }
public string CodigoPoblacion { get; set; }
public string Poblacion { get; set; }
public string CodigoProvincia { get; set; }
public string Provincia { get; set; }
public string IBAN { get; set; }
}
}

View File

@@ -0,0 +1,30 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace bdAsegasa.Presupuestos
{
[Serializable]
[NotMapped]
public class TransportexAXA
{
public string TomadorCIF { get; set; }
public string TomadorNombre { get; set; }
public string TomadorApellidos { get; set; }
public string TomadorTelefono { get; set; }
public string TomadorEmail { get; set; }
public string TomadorDomicilio { get; set; }
public string TomadorCodigoPostal { get; set; }
public string TomadorPoblacion { get; set; }
public string TomadorProvincia { get; set; }
public string TomadorCodigoMunicipio { get; set; }
public string MatriculaRemolque { get; set; }
public string CalidadTomador { get; set; }
public string MedioTransporte { get; set; }
public string CapitalElegido { get; set; }
public string IBAN { get; set; }
public DateTime FechaEfecto { get; set; }
public DateTime FechaVencimiento { get; set; }
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
@@ -20,7 +20,31 @@ namespace bdAsegasa.db
public static EventLog el;
public static string DirectorioLogs;
private static object oBloqueoLog = new object();
public static void AñadeLog(tsUtilidades.Enumeraciones.TipoLog Tipo, string Asunto, string Mensaje, Exception e = null)
public static bool CorreoLogsHabilitado = true;
public static bool tsNotificacionesHabilitado = true;
public static DateOnly FechaActualDateOnly()
{
DateOnly hoy = new DateOnly(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
return hoy;
}
public static async Task EnviaAlertaExcepcion(string Titulo, string Mensaje, byte[] FicheroImagen = null)
{
try
{
await tsUtilidades.TsNotificacionesClient.RegistrarAsync(Titulo, Mensaje, tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
}
catch (Exception Exc)
{
throw new Exception(Exc.Message, Exc);
}
}
public static async void AñadeLog(tsUtilidades.Enumeraciones.TipoLog Tipo, string Asunto, string Mensaje, Exception e = null)
{
// ----------------------------------------------------------------------------------------------------
// Descripción Sub: Gestión de logs de la aplicación
@@ -31,9 +55,6 @@ namespace bdAsegasa.db
// Modificaciones:
// ===============
lock (oBloqueoLog)
{
string sFicheroLog = DirectorioLogs + "Log-" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + ".txt";
try
@@ -64,18 +85,55 @@ namespace bdAsegasa.db
if (Tipo == tsUtilidades.Enumeraciones.TipoLog.Fallo)
{
sFicheroLog = DirectorioLogs + "Errores-" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString().PadLeft(2, '0') + ".txt";
Asunto = "Error Servicio Tecnosis. " + ". Version:" + VersionPrograma + ". " + Asunto;
Mensaje = "Error Servicio Tecnosis. " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + " Enviado desde " + Environment.MachineName + ". Version:" + VersionPrograma + ". Mensaje: " + Mensaje;
Mensaje = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + " Error enviado desde " + Environment.MachineName + " VERSION: " + VersionPrograma + ". " + Mensaje;
}
else
{
Asunto = "Advertencia Servicio Tecnosis. " + ". Version:" + VersionPrograma + ". " + Asunto;
Mensaje = "Advertencia Servicio Tecnosis. " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + " Enviado desde " + Environment.MachineName + ". Version:" + VersionPrograma + ". " + Mensaje;
Mensaje = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + " Advertencia enviado desde " + Environment.MachineName + " VERSION: " + VersionPrograma + ". " + Mensaje;
}
string sDireccionesEnvio = "sevilla@tecnosis.net";
string sServidorSMTP = "mail.tecnosis.net";
string sRemitente = "logs@tecnosis.es";
tsUtilidades.Correo.Funciones.EnviaCorreo(sServidorSMTP, sRemitente, sDireccionesEnvio, Asunto, Mensaje, null, "", "", sRemitente, "jtvdzklmujkechje", 587, true); //Cambiar contraseña de logs -> LoGs20i9.
if (Environment.MachineName.ToUpper().Trim() == "INTI" || Environment.MachineName.ToUpper().Trim() == "CERBERO")
{
sDireccionesEnvio = "danmun@tecnosis.net";
Asunto = "[`" + Environment.MachineName.Trim() + "`] " + Asunto;
}
bool FuerzaCorreo = false;
if (tsNotificacionesHabilitado)
{
try
{
await EnviaAlertaExcepcion(Asunto, Mensaje);
}
catch (Exception ex1)
{
FuerzaCorreo = true;
string sStackTrace2 = "Tipo excepción Alerta: " + ex1.ToString() + "\r\n";
var exError2 = ex1;
do
{
sStackTrace2 += exError2.StackTrace + "\r\n";
exError2 = exError2.InnerException;
}
while (exError2 != null);
if (!string.IsNullOrEmpty(sStackTrace2))
Mensaje += "\r\nStackTrace: " + sStackTrace2;
}
}
else
{
FuerzaCorreo = true;
}
if (CorreoLogsHabilitado || FuerzaCorreo)
{
// Mantenemos los parámetros editados originariamente por #davrod (jtvdzklmujkechje y puerto 587)
tsUtilidades.Correo.Funciones.EnviaCorreo(sServidorSMTP, sRemitente, sDireccionesEnvio, Asunto, Mensaje, null, "", "", sRemitente, "jtvdzklmujkechje", 587, true);
}
break;
}
}
@@ -89,7 +147,6 @@ namespace bdAsegasa.db
Anadelogtxt(Mensaje + " ---" + ex.Message + " --- " + ex.StackTrace, sFicheroLog);
}
}
}
public static void Anadelogtxt(string Mensaje, string FicheroLog)
{
System.IO.StreamWriter sw = null;
@@ -138,6 +195,529 @@ namespace bdAsegasa.db
}
}
public static string NombreUsuario { get; set; }
public static tsUtilidades.Datos.DatosSesionCliente dsc = new tsUtilidades.Datos.DatosSesionCliente();
public static bool? EsRemoto = null;
private static string FicheroLog = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\Asegasa\GestionAsegasaLog.txt";
internal static int? idTippPE { get; set; }
internal static int? idTippBA { get; set; }
internal static int? idtrCx { get; set; }
internal static int? idtrEx { get; set; }
public static int? idSitr1 { get; set; }
private static void ActualizaConexion(tscgestionasegasa deGestionAsegasa)
{
try
{
int idMYSQL = Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.ExecuteSqlRaw(deGestionAsegasa.Database, "select connection_id() as id");
conexiones cn;
if (deGestionAsegasa.conexiones.Any(x => x.idMysql == idMYSQL))
{
cn = deGestionAsegasa.conexiones.First(x => x.idMysql == idMYSQL);
}
else
{
cn = new conexiones();
cn.idMysql = idMYSQL;
deGestionAsegasa.conexiones.Add(cn);
}
cn.ip = "unknown"; // Not selecting host here to simplify EF Core migration
if (deGestionAsegasa.usuarios.Any(x => x.Usuario == Usuario))
{
if (cn.Usuario != Usuario)
{
cn.Usuario = Usuario;
cn.FechaHora = AhoraMysql(deGestionAsegasa);
deGestionAsegasa.SaveChanges();
}
}
else
{
cn.Usuario = Usuario + " * NO ENCONTRADO *";
cn.FechaHora = AhoraMysql(deGestionAsegasa);
deGestionAsegasa.SaveChanges();
}
}
catch (Exception ex)
{
Debug.Write(ex.Message);
}
}
public static DateTime AhoraMysql(tscgestionasegasa deGestionAsegasa)
{
try
{
return DateTime.Now;
}
catch (Exception)
{
return DateTime.Now;
}
}
public static void AñadeLogNombre(string nombreLog, tsUtilidades.Enumeraciones.TipoLog Tipo, string Asunto, string Mensaje, bool forzarEnviarCorreoE = false, string forzarDestinatario = "", bool forzarEnviarSlack = false, Exception excepcion = null)
{
string sFicheroLog = DirectorioLogs + "Log-" + nombreLog + "-" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + ".txt";
try
{
bool enviarCorreoE = false;
StringBuilder sbAsunto = new StringBuilder();
string sSeguimientoDePila = "";
sbAsunto.AppendFormat("[`{0}`] ", System.Diagnostics.Process.GetCurrentProcess().ProcessName);
sbAsunto.Append(Asunto);
if (excepcion != null)
{
if (el != null) el.WriteEntry(excepcion.Message + "\r\n" + excepcion.StackTrace, EventLogEntryType.Error);
}
Mensaje = sbAsunto.ToString() + "\r\n" + Mensaje + "\r\n";
if (Tipo == tsUtilidades.Enumeraciones.TipoLog.Fallo || Tipo == tsUtilidades.Enumeraciones.TipoLog.Advertencia) enviarCorreoE = true;
if (forzarEnviarCorreoE || excepcion != null) enviarCorreoE = true;
if (enviarCorreoE)
{
string sDireccionesEnvio = "sevilla@tecnosis.net";
string sServidorSMTP = "correo.tecnosis.net";
string sRemitente = "logs@tecnosis.es";
if (!string.IsNullOrWhiteSpace(forzarDestinatario)) sDireccionesEnvio = forzarDestinatario;
if (Environment.MachineName.ToUpper().Trim() == "INTI" || Environment.MachineName.ToUpper().Trim() == "CERBERO") sDireccionesEnvio = "danmun@tecnosis.net";
tsUtilidades.Correo.Funciones.EnviaCorreo(sServidorSMTP, sRemitente, sDireccionesEnvio, sbAsunto.ToString().Replace("`", ""), Mensaje.Replace("`", ""),null,null, "","", "logs@tecnosis.es","LoGs20i9.",25,false,false,"");
}
if (forzarEnviarSlack || Tipo == tsUtilidades.Enumeraciones.TipoLog.Fallo || Tipo == tsUtilidades.Enumeraciones.TipoLog.Advertencia || excepcion != null)
{
string destinoSlack = forzarEnviarSlack ? "Avant2" : "asegasa";
tsUtilidades.Utilidades.EnviarNotificacionSlack(Asunto, destinoSlack, System.Reflection.MethodBase.GetCurrentMethod().ToString());
}
Anadelogtxt(Mensaje, sFicheroLog);
}
catch (Exception ex)
{
Anadelogtxt(ex.Message, DirectorioLogs + "Errores-" + nombreLog + ".txt");
}
}
public static void AñadeLogNombreConFicheroTexto(string nombreLog, tsUtilidades.Enumeraciones.TipoLog Tipo, string descripcion, string nombreDelFichero, string textoDelFichero, bool forzarEnviarCorreoE = false, string forzarDestinatario = "", bool forzarEnviarSlack = false, Exception excepcion = null)
{
// Placeholder logic linking AñadeLogNombre
AñadeLogNombre(nombreLog, Tipo, descripcion, textoDelFichero, forzarEnviarCorreoE, forzarDestinatario, forzarEnviarSlack, excepcion);
}
public static async void GeneraRegistroCorreoExcepcion(Exception ex, string Rutina, bool MostrarMensajeError = false, byte[] FicheroImagen = null, string CabeceraAsunto = "")
{
bool FuerzaCorreo = false;
try
{
var bd = tscgestionasegasa.NuevoContexto();
string sMensaje = (CabeceraAsunto != "" ? CabeceraAsunto + " \r\n" : "") + "Usuario: " + Usuario + " Versión: " + VersionPrograma + "\r\n";
string sStackTrace = "Tipo excepción: " + ex.ToString() + "\r\n";
Exception exError = ex;
do
{
sStackTrace += exError.StackTrace + "\r\n";
exError = exError.InnerException;
} while (exError != null);
if (!string.IsNullOrEmpty(sStackTrace)) sMensaje += "\r\nStackTrace: " + sStackTrace;
string Titulo = "Mensaje Automático. Error en " + Rutina;
if (tsNotificacionesHabilitado)
{
try
{
await EnviaAlertaExcepcion(Titulo, sMensaje, FicheroImagen);
}
catch (Exception ex1)
{
FuerzaCorreo = true;
string sStackTrace2 = "Tipo excepción Alerta: " + ex1.ToString() + "\r\n";
var exError2 = ex1;
do
{
sStackTrace2 += exError2.StackTrace + "\r\n";
exError2 = exError2.InnerException;
} while (exError2 != null);
if (!string.IsNullOrEmpty(sStackTrace2)) sMensaje += "\r\nStackTrace: " + sStackTrace2;
}
}
else
{
FuerzaCorreo = true;
}
if (CorreoLogsHabilitado || FuerzaCorreo)
{
var cuentaorigen = bd.cuentascorreo.First(c => c.Codigo == "TECNOSIS");
GeneraRegistroCorreo(bd, Titulo, sMensaje, cuentaorigen, "sevilla@tecnosis.net", FicheroImagen, null, "ERROR");
}
}
catch (Exception ex2)
{
Anadelogtxt(ex2.Message, FicheroLog);
throw new Exception (ex2.Message + "\r\n" + ex2.StackTrace + "Error Generando Correo Excepcion");
}
}
public static void GeneraRegistroCorreoExcepcion(tscgestionasegasa bd, Exception ex, string sAsunto, string sCuerpo, bool MostrarMensajeError = false, byte[] FicheroImagen = null)
{
try
{
string sMensaje = sCuerpo + "\r\n\r\nUsuario: " + Usuario + "\r\n\r\n";
string sStackTrace = "Excepción: " + ex.ToString() + "\r\n";
Exception exError = ex;
do
{
sStackTrace += exError.StackTrace + "\r\n\r\n";
exError = exError.InnerException;
} while (exError != null);
if (!string.IsNullOrEmpty(sStackTrace)) sMensaje += "\r\nStackTrace: " + sStackTrace;
var cuentaorigen = bd.cuentascorreo.First(c => c.Codigo == "TECNOSIS");
GeneraRegistroCorreo(bd, sAsunto, sMensaje, cuentaorigen, "sevilla@tecnosis.net", FicheroImagen, null, "ERROR");
}
catch (Exception ex2)
{
Anadelogtxt(ex2.Message, FicheroLog);
throw new Exception(ex2.Message + "\r\n" + ex2.StackTrace + "Error Generando Correo Excepcion");
}
}
public static void GeneraRegistroCorreo(tscgestionasegasa bd, string Asunto, string Cuerpo)
{
try
{
var cuentaorigen = bd.cuentascorreo.First(c => c.Codigo == "TECNOSIS");
var correo = new bdAsegasa.db.correos
{
Asunto = Asunto,
Cuerpo = Cuerpo,
Destinatario = "sevilla@tecnosis.net",
DireccionRespuesta = cuentaorigen.Remitente,
FechaCreacion = AhoraMysql(bd),
idcuenta = cuentaorigen.idCuenta,
Remitente = cuentaorigen.Remitente
};
if (Environment.MachineName.ToUpper() == "INTI" || Environment.MachineName.ToUpper().Trim() == "CERBERO") correo.Destinatario = "danmun@tecnosis.net";
bd.correos.Add(correo);
bd.SaveChanges();
}
catch (Exception ex)
{
Debug.Write(ex.Message);
throw;
}
}
public static void GeneraRegistroCorreo(tscgestionasegasa bd, string Asunto, string Cuerpo, cuentascorreo cuenta, string Destinatario, byte[] CapturaPantallaError = null, int? idAplicacion = null, string CodigoAplicacion = "")
{
try
{
var correo = new bdAsegasa.db.correos
{
Asunto = Asunto,
Cuerpo = Cuerpo,
Destinatario = Destinatario,
DireccionRespuesta = cuenta.Remitente,
FechaCreacion = AhoraMysql(bd),
idcuenta = cuenta.idCuenta,
Remitente = cuenta.Remitente,
idAplicacion = idAplicacion,
CodigoAplicacion = CodigoAplicacion
};
if (CapturaPantallaError != null)
{
var idtipocapturaerror = bd.enumeraciones.First(x => x.Codigo == "TIPFIC.CAPERROR").idEnumeracion;
var f = new bdAsegasa.db.ficheros();
f.NombreFichero = "CapturaPantallaError_" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".jpg";
f.Fichero = CapturaPantallaError;
f.idTipo = idtipocapturaerror;
bd.ficheros.Add(f);
// Mapped dynamically if possible (usually a list or direct relation)
if (correo.ficherosadjuntos == null) correo.ficherosadjuntos = new List<ficherosadjuntos>();
correo.ficherosadjuntos.Add(new ficherosadjuntos { idFicheroNavigation = f });
}
if (Environment.MachineName.ToUpper() == "INTI" || Environment.MachineName.ToUpper().Trim() == "CERBERO") Destinatario = "danmun@tecnosis.net";
bd.correos.Add(correo);
bd.SaveChanges();
}
catch (Exception ex)
{
Debug.Write(ex.Message);
throw;
}
}
public static void GenerarRegistroCorreoAvant2Agente3(tscgestionasegasa bd, ref polizassg linea, string sQuotationID, string usuarioAvant2 = "")
{
try
{
var lineasEnumeraciones = bd.enumeraciones.Where(x => x.idGrupoEnumeracion == 62).ToList();
string sDireccionRespuesta = lineasEnumeraciones.FirstOrDefault(x => x.Codigo == "AVANT2.EMAIL.IP.RESPUESTA")?.ValorAlfabetico1;
var sDireccionesDestino = new List<string>();
foreach (var le in lineasEnumeraciones)
{
if (le.Codigo != null && le.Codigo.StartsWith("AVANT2.EMAIL.IP.DESTINO")) sDireccionesDestino.Add(le.ValorAlfabetico1);
}
StringBuilder sbAsuntoEmail = new StringBuilder();
StringBuilder sbCuerpoEmail = new StringBuilder();
sbAsuntoEmail.Append("Avant2: se procederá a la incorporación de una póliza al agente 3");
sbCuerpoEmail.AppendLine("Avant2: se procederá a la incorporación de una póliza al agente 3.<br/>");
sbCuerpoEmail.AppendLine("No es posible transferir la póliza a su usuario original porque no se encuentra la información del usuario que la emitió desde Avant2.<br/>");
sbCuerpoEmail.AppendLine("Hay que revisar que el usuario de Avant2 que realizó la emisión de esta póliza esté correctamente identificado en la aplicación Gestión Asegasa.<br/>");
sbCuerpoEmail.AppendLine("Datos de la póliza importada al agente 3:<br/>");
sbCuerpoEmail.AppendLine(string.Format("quotationID: {0} <br/>", sQuotationID));
try { sbCuerpoEmail.AppendLine(string.Format("Nº de póliza: {0} <br/>", linea.NumeroPoliza)); } catch { }
try { sbCuerpoEmail.AppendLine(string.Format("Compañía: {0} <br/>", linea.idCompaniaNavigation?.Nombre)); } catch { }
try { sbCuerpoEmail.AppendLine(string.Format("Ramo: {0} <br/>", linea.idRamoNavigation?.Descripcion)); } catch { }
try { sbCuerpoEmail.AppendLine(string.Format("CIF del tomador: {0} <br/>", linea.Tomador?.CIF)); } catch { }
try { sbCuerpoEmail.AppendLine(string.Format("Nombre del tomador: {0} <br/>", (linea.Tomador?.Nombre + " " + linea.Tomador?.Apellidos).Trim())); } catch { }
try { sbCuerpoEmail.AppendLine(string.Format("Fecha de efecto: {0} <br/>", linea.FechaEfecto)); } catch { }
try { if (!string.IsNullOrWhiteSpace(usuarioAvant2)) sbCuerpoEmail.AppendLine(string.Format("Identificador del usuario de Avant 2 que realizó el alta: {0} <br/>", usuarioAvant2.Trim())); } catch { }
sbCuerpoEmail.AppendLine("<br/>Fin del correo electrónico.");
var cuentaorigen = bd.cuentascorreo.First(c => c.Codigo == "TECNOSIS");
foreach (var destinatario in sDireccionesDestino)
{
GeneraRegistroCorreo(bd, sbAsuntoEmail.ToString(), sbCuerpoEmail.ToString(), cuentaorigen, destinatario);
}
}
catch (Exception ex2)
{
Anadelogtxt(ex2.Message, FicheroLog);
}
}
public static void GenerarRegistroCorreoAvant2IncorporacionParcial(tscgestionasegasa bd, ref polizassg linea, string sQuotationID)
{
try
{
var lineasEnumeraciones = bd.enumeraciones.Where(x => x.idGrupoEnumeracion == 62).ToList();
string sDireccionRespuesta = lineasEnumeraciones.FirstOrDefault(x => x.Codigo == "AVANT2.EMAIL.IP.RESPUESTA")?.ValorAlfabetico1;
var sDireccionesDestino = new List<string>();
foreach (var le in lineasEnumeraciones)
{
if (le.Codigo != null && le.Codigo.StartsWith("AVANT2.EMAIL.IP.DESTINO")) sDireccionesDestino.Add(le.ValorAlfabetico1);
}
StringBuilder sbAsuntoEmail = new StringBuilder();
StringBuilder sbCuerpoEmail = new StringBuilder();
sbAsuntoEmail.AppendFormat("Avant2: incorporación parcial de poliza nº {0}, {1}", linea.NumeroPoliza, linea.idRamoNavigation?.Descripcion);
sbCuerpoEmail.AppendLine("Avant2, incorporación parcial de póliza.\r\n");
sbCuerpoEmail.AppendLine("Esto es una incorporación parcial. Avant2 de Codeoscopic no proporciona varios datos de la póliza.\r\n");
sbCuerpoEmail.AppendLine(string.Format("quotationID: {0}", sQuotationID));
try { sbCuerpoEmail.AppendLine(string.Format("Numero de póliza: {0}", linea.NumeroPoliza)); } catch { }
try { sbCuerpoEmail.AppendLine(string.Format("Compañía: {0}", linea.idCompaniaNavigation?.Nombre)); } catch { }
try { sbCuerpoEmail.AppendLine(string.Format("Ramo: {0}", linea.idRamoNavigation?.Descripcion)); } catch { }
try { sbCuerpoEmail.AppendLine(string.Format("CIF del tomador: {0}", linea.Tomador?.CIF)); } catch { }
try { sbCuerpoEmail.AppendLine(string.Format("Nombre del tomador: {0}", (linea.Tomador?.Nombre + " " + linea.Tomador?.Apellidos).Trim())); } catch { }
try { sbCuerpoEmail.AppendLine(string.Format("Fecha de efecto: {0}", linea.FechaEfecto)); } catch { }
sbCuerpoEmail.AppendLine("\r\nFin del correo electronico.");
var cuentaorigen = bd.cuentascorreo.First(c => c.Codigo == "TECNOSIS");
foreach (var destinatario in sDireccionesDestino)
{
GeneraRegistroCorreo(bd, sbAsuntoEmail.ToString(), sbCuerpoEmail.ToString(), cuentaorigen, destinatario);
}
}
catch (Exception ex2)
{
Anadelogtxt(ex2.Message, FicheroLog);
}
}
public static tsUtilidades.Permisos ObtienePermisos(tscgestionasegasa bd, int? idPermiso, int idUsuario)
{
var per = new tsUtilidades.Permisos();
var usuario = bd.usuarios.First(u => u.idUsuario == idUsuario);
var grupoUsuario = bd.gruposusuarios.FirstOrDefault(g => g.idGrupo == usuario.idGrupo);
if (grupoUsuario != null && grupoUsuario.Descripcion == "TECNOSIS")
{
per.Consultar = true; per.Eliminar = true; per.Nuevos = true; per.Otros = true; per.Modificar = true; per.Impresion = true; per.Exportar = true;
}
else
{
if (idPermiso == null)
{
per.Consultar = false; per.Eliminar = false; per.Nuevos = false; per.Otros = false; per.Modificar = false; per.Impresion = false; per.Exportar = false;
}
else
{
var au = bd.autorizacionesusuarios.Where(a => a.idPermiso == idPermiso && a.idUsuario == idUsuario).ToList();
if (au.Count == 0)
{
var ag = bd.autorizacionesgrupos.Where(g => g.idPermiso == idPermiso && g.idGrupo == usuario.idGrupo).ToList();
if (ag.Count == 0)
{
per.Consultar = false; per.Eliminar = false; per.Nuevos = false; per.Otros = false; per.Modificar = false; per.Impresion = false; per.Exportar = false;
}
else
{
per.Consultar = ag.First().PermitirConsultas;
per.Eliminar = ag.First().PermitirEliminaciones;
per.Nuevos = ag.First().PermitirNuevos;
per.Otros = ag.First().OtrosPermisos;
per.Modificar = ag.First().PermitirModificaciones;
per.Impresion = ag.First().PermitirImpresiones;
per.Exportar = ag.First().PermitirExportar;
}
}
else
{
per.Consultar = au.First().PermitirConsultas;
per.Eliminar = au.First().PermitirEliminaciones;
per.Nuevos = au.First().PermitirNuevos;
per.Otros = au.First().OtrosPermisos;
per.Modificar = au.First().PermitirModificaciones;
per.Impresion = au.First().PermitirImpresiones;
per.Exportar = au.First().PermitirExportar;
}
}
}
return per;
}
public static tsUtilidades.Permisos ObtienePermisos(tscgestionasegasa bd, string Codigo, int idUsuario)
{
try
{
var per = new tsUtilidades.Permisos();
var usuario = bd.usuarios.First(u => u.idUsuario == idUsuario);
var grupoUsuario = bd.gruposusuarios.FirstOrDefault(g => g.idGrupo == usuario.idGrupo);
if (grupoUsuario != null && grupoUsuario.Descripcion == "TECNOSIS")
{
per.Consultar = true; per.Eliminar = true; per.Nuevos = true; per.Otros = true; per.Modificar = true; per.Impresion = true; per.Exportar = true;
}
else
{
var au = bd.autorizacionesusuarios.Where(a => a.idPermisoNavigation.CodigoPermiso == Codigo && a.idUsuario == idUsuario).ToList();
if (au.Count == 0)
{
var ag = bd.autorizacionesgrupos.Where(g => g.idPermisoNavigation.CodigoPermiso == Codigo && g.idGrupo == usuario.idGrupo).ToList();
if (ag.Count == 0)
{
per.Consultar = false; per.Eliminar = false; per.Nuevos = false; per.Otros = false; per.Modificar = false; per.Impresion = false; per.Exportar = false;
}
else
{
per.Consultar = ag.First().PermitirConsultas;
per.Eliminar = ag.First().PermitirEliminaciones;
per.Nuevos = ag.First().PermitirNuevos;
per.Otros = ag.First().OtrosPermisos;
per.Modificar = ag.First().PermitirModificaciones;
per.Impresion = ag.First().PermitirImpresiones;
per.Exportar = ag.First().PermitirExportar;
}
}
else
{
per.Consultar = au.First().PermitirConsultas;
per.Eliminar = au.First().PermitirEliminaciones;
per.Nuevos = au.First().PermitirNuevos;
per.Otros = au.First().OtrosPermisos;
per.Modificar = au.First().PermitirModificaciones;
per.Impresion = au.First().PermitirImpresiones;
per.Exportar = au.First().PermitirExportar;
}
}
return per;
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
}
public static string ObtenerNumeroDePolizaDisponibleTractoresAXA(tscgestionasegasa bd, uint n = 0)
{
try
{
string resultado = "";
enumeraciones inicio;
enumeraciones fin;
uint actual = 0;
bool bEncontrado = false;
var enumNumeracion = bd.enumeraciones.Where(x => x.Codigo != null && x.Codigo.StartsWith("AXATRACTORES.numeracion.") && x.ValorAlfabetico1.ToUpper().Trim() == "DISPONIBLE").OrderBy(x => x.Codigo).ToList();
int idRamoTractores = 0;
int idRamoRemolques = 0;
int.TryParse(bd.ramos.Where(x => x.Codigo == "1-1").Select(x => x.idRamo).FirstOrDefault().ToString(), out idRamoTractores);
int.TryParse(bd.ramos.Where(x => x.Codigo == "1-1-1").Select(x => x.idRamo).FirstOrDefault().ToString(), out idRamoRemolques);
inicio = enumNumeracion.FirstOrDefault(x => x.Codigo != null && x.Codigo.EndsWith(".inicio"));
fin = enumNumeracion.FirstOrDefault(x => x.Codigo != null && x.Codigo.EndsWith(".fin"));
try
{
if (n == 0)
{
string strActual = bd.polizassg.Where(x => x.NumeroPoliza.CompareTo(inicio.ValorNumerico1.ToString()) >= 0 && x.NumeroPoliza.CompareTo(fin.ValorNumerico1.ToString()) <= 0 && (x.idRamo == idRamoTractores || x.idRamo == idRamoRemolques)).OrderByDescending(x => x.NumeroPoliza).Select(x => x.NumeroPoliza).Take(10).FirstOrDefault();
if (strActual != null)
{
uint.TryParse(strActual, out actual);
}
}
else
{
actual = n;
}
}
catch (Exception) { }
if (actual == 0)
{
resultado = inicio?.ValorNumerico1?.ToString();
bEncontrado = true;
}
else
{
if (actual < inicio?.ValorNumerico1)
{
resultado = inicio?.ValorNumerico1?.ToString();
bEncontrado = true;
}
else if (actual == fin?.ValorNumerico1)
{
inicio.ValorAlfabetico1 = "Usado";
fin.ValorAlfabetico1 = "Usado";
bd.SaveChanges();
resultado = ObtenerNumeroDePolizaDisponibleTractoresAXA(bd);
}
else if (actual > fin?.ValorNumerico1)
{
resultado = "-1";
bEncontrado = true;
string asunto = "TractoresAXA: Se han acabado los nºs de pólizas reservados para el servicio de TractoresAXA.";
string cuerpo = asunto + "\r\n Hay que avisar a ASEGASA para que gestionen con AXA la asignación de un nuevo rango de nºs de pólizas para este servicio.\r\nEn método `" + System.Reflection.MethodBase.GetCurrentMethod().ToString() + "`. \r\n" + Environment.MachineName;
AñadeLog(tsUtilidades.Enumeraciones.TipoLog.Fallo, asunto, cuerpo);
tsUtilidades.Utilidades.EnviarNotificacionSlack(asunto, "asegasa", System.Reflection.MethodBase.GetCurrentMethod().ToString());
}
else
{
resultado = (actual + 1).ToString();
bEncontrado = true;
}
}
return resultado;
}
catch(Exception)
{
return "-1";
}
}
}
}

View File

@@ -0,0 +1,8 @@
{
"TsNotificaciones": {
//"ApiUrl": "http://192.168.41.32:5000/", prod
"ApiUrl": "https://catcher.tecnosis.online",
"IdAplicacion": 2,
"ApiKey": "0a47a1eada0143278b9d4de4e8911100"
}
}

View File

@@ -1,22 +1,38 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<TargetFrameworks>net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DevExpress.AspNetCore.Common" Version="23.2.3" />
<PackageReference Include="DevExpress.AspNetCore.Dashboard" Version="23.2.3" />
<PackageReference Include="DevExpress.AspNetCore.RichEdit" Version="23.2.3" />
<PackageReference Include="DevExpress.Charts" Version="23.2.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.DynamicLinq" Version="8.7.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.24" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.14" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.3" />
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
<PackageReference Include="tsEFCore8" Version="1.0.1" />
<PackageReference Include="tsUtilidades" Version="1.1.1" />
<PackageReference Include="tsEFCore8" Version="1.0.5" />
<PackageReference Include="tsUtilidades" Version="1.1.10" />
</ItemGroup>
<ItemGroup>
<Folder Include="db\" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-windows7.0'">
<PackageReference Include="tsWPFCore">
<Version>1.3.10</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Reference Include="DevExpress.Xpf.Core.v23.2">
<HintPath>..\..\..\..\Program Files\DevExpress 23.2\Components\Offline Packages\devexpress.wpf.core\23.2.3\lib\net6.0-windows\DevExpress.Xpf.Core.v23.2.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using PropertyChanged;
namespace bdAsegasa.db;
[AddINotifyPropertyChangedInterface]
public partial class agrupacionrecibossepa
{
public int idagrupacionrecibossepa { get; set; }
public DateTime? Fecha { get; set; }
public int? idUsuario { get; set; }
public double? Total { get; set; }
public virtual ICollection<detallesagrupacionrecibossepa> detallesagrupacionrecibossepa { get; set; } = new List<detallesagrupacionrecibossepa>();
public virtual usuarios? idUsuarioNavigation { get; set; }
}

View File

@@ -15,7 +15,7 @@ public partial class amortizacionrecibos
public DateOnly FechaFinAmortizacion { get; set; }
public double? PorcentajeAnual { get; set; }
public double PorcentajeAnual { get; set; }
public DateOnly? FechaBaja { get; set; }

Some files were not shown because too many files have changed in this diff Show More