agregado procesos y bd clases
This commit is contained in:
14
Asegasa.sln
14
Asegasa.sln
@@ -1,7 +1,7 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 18
|
||||
VisualStudioVersion = 18.3.11505.172 d18.3
|
||||
VisualStudioVersion = 18.1.11312.151
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WSAsegasa", "WSAsegasa\WSAsegasa.csproj", "{C891F2E3-60D2-449F-962A-BF78F58C67D6}"
|
||||
EndProject
|
||||
@@ -11,6 +11,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "APIFicheros", "APIFicheros\
|
||||
EndProject
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "GestionAsegasa", "GestionAsegasa\GestionAsegasa.vbproj", "{6995E4A5-BC07-42C2-8E8C-C09839886B7F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Servicio Gestion Asegasa", "Servicio Gestion Asegasa\Servicio Gestion Asegasa.csproj", "{B11D4268-5013-4084-ABF7-7E5D28AB7EB1}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "itsm", "itsm\itsm.csproj", "{09D06C54-3B7C-4A1D-8A1A-A1AEFAED2094}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -33,6 +37,14 @@ Global
|
||||
{6995E4A5-BC07-42C2-8E8C-C09839886B7F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6995E4A5-BC07-42C2-8E8C-C09839886B7F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6995E4A5-BC07-42C2-8E8C-C09839886B7F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B11D4268-5013-4084-ABF7-7E5D28AB7EB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B11D4268-5013-4084-ABF7-7E5D28AB7EB1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B11D4268-5013-4084-ABF7-7E5D28AB7EB1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B11D4268-5013-4084-ABF7-7E5D28AB7EB1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{09D06C54-3B7C-4A1D-8A1A-A1AEFAED2094}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{09D06C54-3B7C-4A1D-8A1A-A1AEFAED2094}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{09D06C54-3B7C-4A1D-8A1A-A1AEFAED2094}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{09D06C54-3B7C-4A1D-8A1A-A1AEFAED2094}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -314,9 +314,10 @@ Public Class Comun
|
||||
If sStackTrace <> "" Then sMensaje &= vbCrLf & "StackTrace: " & sStackTrace
|
||||
Dim cuentaorigen As cuentascorreo = (From c In bd.cuentascorreo Select c Where c.Codigo = "M3SOFT").First
|
||||
If FicheroImagen Is Nothing Then
|
||||
correos.GeneraRegistroCorreon(bd, "Mensaje Automático. Error en " & Rutina, sMensaje, cuentaorigen, "manmog@gmail.com", "", "", , ,, "ERRORES")
|
||||
correos.GeneraRegistroCorreo(bd, "Mensaje Automático. Error en " & Rutina, sMensaje, cuentaorigen, "manmog@gmail.com", "", "", , ,, "ERRORES")
|
||||
Else
|
||||
correos.GeneraRegistroCorreon(bd, "Mensaje Automático. Error en " & Rutina, sMensaje, cuentaorigen, "manmog@gmail.com", "", "", FicheroImagen, "captura.jpg",, "ERRORES")
|
||||
' esto lo he comentado yo
|
||||
'correos.GeneraRegistroCorreo(bd, "Mensaje Automático. Error en " & Rutina, sMensaje, cuentaorigen, "manmog@gmail.com", "", "", FicheroImagen, "captura.jpg",, "ERRORES")
|
||||
End If
|
||||
Catch ex2 As Exception
|
||||
DXMessageBox.Show(ex2.Message & vbCrLf & ex2.StackTrace, "Error Generando Correo Excepcion")
|
||||
|
||||
136
Servicio Gestion Asegasa/Procesos/ProcesosCaser.cs
Normal file
136
Servicio Gestion Asegasa/Procesos/ProcesosCaser.cs
Normal file
@@ -0,0 +1,136 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.IO.Compression;
|
||||
using System.Collections.Generic;
|
||||
using Renci.SshNet;
|
||||
using Renci.SshNet.Common;
|
||||
using tsUtilidades;
|
||||
using tsUtilidades.Extensiones;
|
||||
using bdAsegasa.db;
|
||||
using tsUtilidades.Enumeraciones;
|
||||
|
||||
namespace Servicio_Gestion_Asegasa.Procesos
|
||||
{
|
||||
public class ProcesosCaser
|
||||
{
|
||||
|
||||
public static async Task GuardarEnBDFicherosDisponiblesSFTPAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var bd = bdAsegasa.db.gestionasegasaEntities.NuevoContextoCN())
|
||||
using (var bdtmp = bdAsegasa.db.gestionasegasaEntities.NuevoContextoCN())
|
||||
{
|
||||
var idCaser = bd.companias.First(x => x.Codigo == "0017").idCompania;
|
||||
|
||||
var keybAuth = new KeyboardInteractiveAuthenticationMethod("ca071106");
|
||||
keybAuth.AuthenticationPrompt += HandleKeyEvent;
|
||||
var conInfo = new ConnectionInfo("ftp.caser.es", 22, "ca071106", keybAuth);
|
||||
|
||||
using (var sftp = new SftpClient(conInfo))
|
||||
{
|
||||
sftp.Connect();
|
||||
var lf = sftp.ListDirectory("ca071106").Where(x => x.IsDirectory == false);
|
||||
|
||||
foreach (var F in lf)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (F.Name.StartsWith("EIAC_REC_") || F.Name.StartsWith("EIAC_POL_") || F.Name.StartsWith("EIAC_SIN_"))
|
||||
{
|
||||
string nomfic;
|
||||
bool Eszip;
|
||||
if (F.Name.EndsWith(".txt"))
|
||||
{
|
||||
nomfic = F.Name.Substring(0, F.Name.Length - 4);
|
||||
Eszip = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
nomfic = Path.ChangeExtension(F.Name, "xml");
|
||||
Eszip = true;
|
||||
}
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
sftp.DownloadFile(F.FullName, ms);
|
||||
ms.Position = 0;
|
||||
|
||||
byte[] b;
|
||||
if (Eszip)
|
||||
{
|
||||
using (var zip = new ZipArchive(ms, ZipArchiveMode.Read))
|
||||
{
|
||||
var firstEntry = zip.Entries.First();
|
||||
using (var msxml = new MemoryStream())
|
||||
{
|
||||
using (var entryStream = firstEntry.Open())
|
||||
{
|
||||
entryStream.CopyTo(msxml);
|
||||
}
|
||||
msxml.Position = 0;
|
||||
b = msxml.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
b = ms.ToArray();
|
||||
}
|
||||
|
||||
var sha1 = tsUtilidades.crypt.SHA1(b);
|
||||
if (bdtmp.ficheroscompanias.Any(x => x.SHA1 == sha1 && x.idCompania == idCaser) == false)
|
||||
{
|
||||
var nf = new bdAsegasa.db.ficheroscompanias();
|
||||
nf.FechaCreacion = DateTime.Now;
|
||||
nf.idCompania = idCaser;
|
||||
nf.Fichero = b;
|
||||
nf.NombreFichero = nomfic;
|
||||
nf.SHA1 = sha1;
|
||||
|
||||
switch (F.Name.Split('_')[1])
|
||||
{
|
||||
case "REC":
|
||||
nf.Tipo = (int)bdAsegasa.db.ficheroscompanias.TipoFicheroCompania.RECIBOS_EIAC;
|
||||
break;
|
||||
case "POL":
|
||||
nf.Tipo = (int)bdAsegasa.db.ficheroscompanias.TipoFicheroCompania.POLIZAS_EIAC;
|
||||
break;
|
||||
case "SIN":
|
||||
nf.Tipo = (int)bdAsegasa.db.ficheroscompanias.TipoFicheroCompania.SINIESTROS_EIAC;
|
||||
break;
|
||||
}
|
||||
bd.ficheroscompanias.Add(nf);
|
||||
bd.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
sftp.RenameFile(F.FullName, F.FullName.Replace(F.Name, "PROCESADOS/" + F.Name));
|
||||
}
|
||||
catch (Exception EX)
|
||||
{
|
||||
throw new Exception(EX.Message + " Fichero: " + F.FullName, EX);
|
||||
}
|
||||
}
|
||||
sftp.Disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception EX)
|
||||
{
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En GuardarEnBDFicherosDisponibles CASER", EX.Message, tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
private static void HandleKeyEvent(object? sender, AuthenticationPromptEventArgs e)
|
||||
{
|
||||
foreach (var prompt in e.Prompts)
|
||||
{
|
||||
if (prompt.Request.IndexOf("Password:", StringComparison.InvariantCultureIgnoreCase) != -1)
|
||||
{
|
||||
prompt.Response = "As69gs73";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
139
Servicio Gestion Asegasa/Procesos/ProcesosContabilidad.cs
Normal file
139
Servicio Gestion Asegasa/Procesos/ProcesosContabilidad.cs
Normal file
@@ -0,0 +1,139 @@
|
||||
using bdAsegasa;
|
||||
using bdAsegasa.db;
|
||||
using bdAsegasa.dbcontext;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Servicio_Gestion_Asegasa.Procesos
|
||||
{
|
||||
public class ProcesosContabilidad
|
||||
{
|
||||
public static void CompruebaContabilidad()
|
||||
{
|
||||
using var bd = tscgestionasegasa.NuevoContexto();
|
||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
string sDestinatarios = "sevilla@tecnosis.net";
|
||||
|
||||
var asis = bd.asientos.Where(x =>
|
||||
x.Fecha < x.idEjercicioNavigation.FechaInicio ||
|
||||
x.Fecha > x.idEjercicioNavigation.FechaFin ||
|
||||
x.apuntes.Any(y => y.idCuentaNavigation.idEjercicio != x.idEjercicio)
|
||||
).ToList();
|
||||
|
||||
if (asis.Count > 0)
|
||||
{
|
||||
var lFechaErronea = new List<asientos>();
|
||||
foreach (var asi in asis)
|
||||
{
|
||||
var ej = bd.ejercicioscontables.FirstOrDefault(x =>
|
||||
x.FechaCierre == null &&
|
||||
(x.FechaInicio <= asi.Fecha && x.FechaFin >= asi.Fecha)
|
||||
);
|
||||
|
||||
if (ej != null)
|
||||
{
|
||||
lFechaErronea.Add(asi);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (asi.idEjercicio != ej.idEjercicio)
|
||||
{
|
||||
asi.idEjercicio = ej.idEjercicio;
|
||||
}
|
||||
foreach (var ap in asi.apuntes)
|
||||
{
|
||||
ap.idCuenta = bd.cuentas.First(x => x.NumeroCuenta == ap.idCuentaNavigation.NumeroCuenta && x.idEjercicio == asi.idEjercicio).idCuenta;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bd.SaveChanges();
|
||||
|
||||
if (lFechaErronea.Count > 0)
|
||||
{
|
||||
var lae = lFechaErronea.Select(x => new
|
||||
{
|
||||
NumeroAsiento = x.idAsiento,
|
||||
Fecha = x.Fecha,
|
||||
Ejercicio = x.idEjercicioNavigation.Descripcion
|
||||
}).ToList();
|
||||
|
||||
byte[] fe = tsUtilidades.Excel.IEnumerableAExcel(lae);
|
||||
|
||||
bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd,
|
||||
"Existen apuntes con cuentas de un ejercicio diferente al del asiento (No se corrige el asiento)",
|
||||
"Existen apuntes con cuentas de un ejercicio diferente al del asiento (Se corrige el asiento)",
|
||||
cta, fe, "AsientosFechaErronea-" + DateTime.Now.ToString("yyyy-MM-dd") + ".xlsx",
|
||||
"Asientos Con Fecha Erronea " + DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
sDestinatarios);
|
||||
|
||||
var idsErrores = lae.Select(y => y.NumeroAsiento).ToList();
|
||||
asis = asis.Where(x => !idsErrores.Contains(x.idAsiento)).ToList();
|
||||
}
|
||||
|
||||
var la = asis.Select(x => new
|
||||
{
|
||||
NumeroAsiento = x.idAsiento,
|
||||
Fecha = x.Fecha,
|
||||
Ejercicio = x.idEjercicioNavigation.Descripcion
|
||||
}).ToList();
|
||||
|
||||
byte[] f = tsUtilidades.Excel.IEnumerableAExcel(la);
|
||||
|
||||
bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd,
|
||||
"Existen apuntes con cuentas de un ejercicio diferente al del asiento (Se corrige el asiento)",
|
||||
"Existen apuntes con cuentas de un ejercicio diferente al del asiento (Se corrige el asiento)",
|
||||
cta, f, "ApuntesIncoherentes-" + DateTime.Now.ToString("yyyy-MM-dd") + ".xlsx",
|
||||
"Apuntes Incoherentes " + DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
sDestinatarios);
|
||||
}
|
||||
|
||||
asis = bd.asientos.Where(x => x.Fecha < x.idEjercicioNavigation.FechaInicio || x.Fecha > x.idEjercicioNavigation.FechaFin).ToList();
|
||||
|
||||
if (asis.Count > 0)
|
||||
{
|
||||
var la = asis.Select(x => new
|
||||
{
|
||||
NumeroAsiento = x.idAsiento,
|
||||
Fecha = x.Fecha,
|
||||
Ejercicio = x.idEjercicioNavigation.Descripcion
|
||||
}).ToList();
|
||||
|
||||
byte[] f = tsUtilidades.Excel.IEnumerableAExcel(la);
|
||||
|
||||
bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd,
|
||||
"Existen asientos con fecha incoherente al del ejercicio",
|
||||
"Existen asientos con fecha incoherente al del ejercicio",
|
||||
cta, f, "AsientosIncoherentes-" + DateTime.Now.ToString("yyyy-MM-dd") + ".xlsx",
|
||||
"Asientos Incoherentes " + DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
sDestinatarios);
|
||||
}
|
||||
|
||||
asis = bd.asientos.Where(x => Math.Round((double)x.apuntes.Sum(y => y.Debe ), 2) != Math.Round((double)x.apuntes.Sum(y => y.Haber), 2)).ToList();
|
||||
|
||||
if (asis.Count > 0)
|
||||
{
|
||||
var la = asis.Select(x => new
|
||||
{
|
||||
NumeroAsiento = x.idAsiento,
|
||||
Fecha = x.Fecha,
|
||||
Ejercicio = x.idEjercicioNavigation.Descripcion,
|
||||
Debe = Math.Round((double)x.apuntes.Sum(y => y.Debe ), 2, MidpointRounding.AwayFromZero),
|
||||
Haber = Math.Round((double)x.apuntes.Sum(y => y.Haber ), 2, MidpointRounding.AwayFromZero)
|
||||
}).ToList();
|
||||
|
||||
byte[] f = tsUtilidades.Excel.IEnumerableAExcel(la);
|
||||
|
||||
bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd,
|
||||
"Existen asientos descuadrados",
|
||||
"Existen asientos descuadrados",
|
||||
cta, f, "AsientosDescuadrados-" + DateTime.Now.ToString("yyyy-MM-dd") + ".xlsx",
|
||||
"Asientos Descuadrados " + DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
sDestinatarios);
|
||||
}
|
||||
|
||||
asis = bd.asientos.Where(x => x.Fecha < x.idEjercicioNavigation.FechaInicio || x.Fecha > x.idEjercicioNavigation.FechaFin).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
107
Servicio Gestion Asegasa/Procesos/ProcesosGestionesVarias.cs
Normal file
107
Servicio Gestion Asegasa/Procesos/ProcesosGestionesVarias.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
using bdAsegasa;
|
||||
using bdAsegasa.db;
|
||||
using bdAsegasa.dbcontext;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using tsUtilidades;
|
||||
using tsUtilidades.Extensiones;
|
||||
|
||||
namespace Servicio_Gestion_Asegasa.Procesos
|
||||
{
|
||||
public class ProcesosGestionesVarias
|
||||
{
|
||||
public static async Task GeneraCorreoRestablecimientoContraseñaAsync()
|
||||
{
|
||||
string sProceso = "GeneraCorreoRestablecimientoContraseña";
|
||||
try
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto(); ;
|
||||
var idTgag = bd.enumeraciones.First(x => x.Codigo == "TGV.CCAG").idEnumeracion;
|
||||
var idTgsag = bd.enumeraciones.First(x => x.Codigo == "TGV.CCSAG").idEnumeracion;
|
||||
var gess = bd.gestionesvarias.Where(x => x.idCorreo.HasValue == false && (x.idTipo == idTgag || x.idTipo == idTgsag) && x.FechaProcesado.HasValue == false).ToList();
|
||||
var urlaseg = bd.enumeraciones.First(x => x.Codigo == "CONF.URLWC").ValorAlfabeticoLargo;
|
||||
|
||||
foreach (var g in gess)
|
||||
{
|
||||
string sDestinatario;
|
||||
string sAsunto;
|
||||
|
||||
if (g.idTipo == idTgag)
|
||||
{
|
||||
var ag = bd.agentes.First(x => x.idAgente != 0);
|
||||
sDestinatario = ag.Email;
|
||||
sAsunto = "Solicitud de cambio de contraseña al Agente " + ag.Nombre + " (Nº " + ag.Codigo + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
var sag = bd.subagentes.First(x => x.idAgente != 0);
|
||||
sDestinatario = sag.Email;
|
||||
sAsunto = "Solicitud de cambio de contraseña al SubAgente " + sag.Nombre + " (Nº " + sag.idAgenteNavigation.Codigo + "-" + sag.Codigo + ")";
|
||||
}
|
||||
|
||||
if (Directory.Exists(@"c:\tecnosis.tfs"))
|
||||
{
|
||||
sDestinatario = "sevilla@tecnosis.net";
|
||||
}
|
||||
|
||||
if (sDestinatario.EsEmailValido())
|
||||
{
|
||||
g.Parametros = tsUtilidades.crypt.SHA1("M3Soft." + DateTime.Now.ToBinary().ToString() + g.idGestion.ToString());
|
||||
string sUrlEnlace = urlaseg + "/nuevaContrasena.aspx?id=" + g.idGestion.ToString() + "&cl=" + g.Parametros;
|
||||
|
||||
string sCuerpo = "Estimado compañero/a: Adjunto te remitimos el enlace para restablecer la contraseña de acceso a la Web de Asegasa. Si usted no ha realizado dicha solicitud, póngase en contacto con nosotros. Un saludo.";
|
||||
sCuerpo += "<br /><br />Url Restablecimiento de contraseña: <a href=" + (char)34 + sUrlEnlace + (char)34 + ">Pulse aquí</a>";
|
||||
|
||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
|
||||
g.idCorreo = bdAsegasa.db.correos.GeneraRegistroCorreo(bd, sAsunto, sCuerpo, cta, sDestinatario);
|
||||
bd.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
g.FechaProcesado = DateTime.Now;
|
||||
bd.SaveChanges();
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En GeneraCorreoRestablecimientoContraseña.", "Rutina: GeneraCorreoRestablecimientoContraseña. " + " El Agente o subagente " + g.Descripción + " no tiene un correo válido.", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En GeneraCorreoRestablecimientoContraseña.", "Rutina: GeneraCorreoRestablecimientoContraseña. " + " " + ex.Message, TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task EnviaAlertaCredencialesProximasACaducarAsync()
|
||||
{
|
||||
string sProceso = "EnviaAlertaCredencialesProximasACaducar";
|
||||
try
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
var ctaspc = bd.cuentascorreo.Where(x => x.FechaAvisoCaducidadCredenciales != null && x.FechaAvisoCaducidadCredenciales < DateTime.Now).ToList();
|
||||
var dest = bd.enumeraciones.Where(x => x.Codigo == "CONF.EMAILCRCTA").First().ValorAlfabeticoLargo;
|
||||
|
||||
foreach (var c in ctaspc)
|
||||
{
|
||||
string sAsunto;
|
||||
sAsunto = "Crecenciales de la cuenta de correo " + c.Remitente + " próxima a caducar.";
|
||||
|
||||
if (Directory.Exists(@"c:\tecnosis.tfs"))
|
||||
{
|
||||
dest = "sevilla@tecnosis.net";
|
||||
}
|
||||
|
||||
string sCuerpo = "Atención: Se deben renovar las credenciales de la cuenta " + c.Remitente + " y comunicárselo a Tecnosis para su actualización.";
|
||||
bdAsegasa.db.correos.GeneraRegistroCorreo(bd, sAsunto, sCuerpo, c, dest);
|
||||
bd.SaveChanges();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En EnviaAlertaCredencialesProximasACaducar.", "Rutina: GeneraCorreoRestablecimientoContraseña. " + " " + ex.Message, TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
169
Servicio Gestion Asegasa/Procesos/ProcesosMensajes.cs
Normal file
169
Servicio Gestion Asegasa/Procesos/ProcesosMensajes.cs
Normal file
@@ -0,0 +1,169 @@
|
||||
using bdAsegasa.db;
|
||||
using bdAsegasa.dbcontext;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using tsUtilidades;
|
||||
using tsUtilidades.Extensiones;
|
||||
|
||||
namespace Servicio_Gestion_Asegasa.Procesos
|
||||
{
|
||||
public class ProcesosMensajes
|
||||
{
|
||||
private static bool ServicioSMSSuspendido = false;
|
||||
|
||||
public static async Task EnviaSMSAsync()
|
||||
{
|
||||
if (!ServicioSMSSuspendido)
|
||||
{
|
||||
using var de = bdAsegasa.db.gestionasegasaEntities.NuevoContextoCN();
|
||||
try
|
||||
{
|
||||
var mensajespendientes = de.mensajes
|
||||
.Where(m => m.FechaEnvio == null && m.FechaAnulacion == null)
|
||||
.OrderBy(m => m.FechaUltimoIntento)
|
||||
.Take(50)
|
||||
.ToList();
|
||||
|
||||
bool bIntentar;
|
||||
bool bAlmacenar = false;
|
||||
var cta = de.enumeraciones.First(x => x.Codigo == "CONF.CTAITSOFT");
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var mensaje in mensajespendientes)
|
||||
{
|
||||
bIntentar = false;
|
||||
if (mensaje.FechaUltimoIntento == null)
|
||||
{
|
||||
bIntentar = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((DateTime.Now - mensaje.FechaUltimoIntento.Value).TotalSeconds > cta.ValorNumerico1 * 60 * 60)
|
||||
{
|
||||
bIntentar = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (bIntentar)
|
||||
{
|
||||
try
|
||||
{
|
||||
bAlmacenar = true;
|
||||
if ((DateTime.Now - mensaje.FechaCreacion.Value).TotalHours > 10)
|
||||
{
|
||||
throw new Exception("MENSAJE_ANTIGUO");
|
||||
}
|
||||
|
||||
mensaje.Cuenta = "ITSOFT";
|
||||
string sRespuesta = await itsm.sms.Enviarsms(mensaje.Destinatario, mensaje.Mensaje, cta.ValorAlfabetico1);
|
||||
mensaje.RespuestaServicio = sRespuesta.Acortar(1024);
|
||||
|
||||
mensaje.FechaEnvio = DateTime.Now;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
mensaje.FechaUltimoIntento = DateTime.Now;
|
||||
mensaje.RespuestaServicio = ex.Message.Acortar(1024);
|
||||
|
||||
if (ex.Message == "TELEFONO_INVALIDO")
|
||||
{
|
||||
mensaje.FechaAnulacion = DateTime.Now;
|
||||
}
|
||||
else if (ex.Message.StartsWith("El mensaje tiene más"))
|
||||
{
|
||||
mensaje.FechaAnulacion = DateTime.Now;
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync($"El Mensaje para el destinatario {mensaje.Destinatario} ES DEMASIADO LARGO.", ex.Message, TsNotificacionesClient.TipoNotificacionEnum.ADVERTENCIA);
|
||||
}
|
||||
else if (ex.Message == "MENSAJE_ANTIGUO")
|
||||
{
|
||||
mensaje.FechaAnulacion = DateTime.Now;
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync($"El Mensaje para el destinatario {mensaje.Destinatario} ES DEMASIADO ANTIGUO.", ex.Message, TsNotificacionesClient.TipoNotificacionEnum.ADVERTENCIA);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((DateTime.Now - mensaje.FechaCreacion.Value).TotalMinutes > cta.ValorNumerico1 * 60)
|
||||
{
|
||||
mensaje.FechaAnulacion = DateTime.Now;
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync($"El Mensaje para el destinatario {mensaje.Destinatario} ha fallado y será marcado como anulado.", ex.Message, TsNotificacionesClient.TipoNotificacionEnum.ADVERTENCIA);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if (bAlmacenar) de.GuardarCambios();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ServicioSMSSuspendido = true;
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("SERVICIO SMS SUSPENDIDO", ex.Message, TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
Thread.Sleep(5000);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("Error", ex.Message, TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static void CompruebaSMSNoEnviados()
|
||||
{
|
||||
using var bd = bdAsegasa.db.gestionasegasaEntities.NuevoContextoCN();
|
||||
var fechahorainicio = DateTime.Now.AddMinutes(-180);
|
||||
var mensajesnoenviados = bd.mensajes.Where(x => x.FechaCreacion > fechahorainicio && x.FechaEnvio == null && x.FechaUltimoIntento != null).ToList();
|
||||
|
||||
if (mensajesnoenviados.Count > 0)
|
||||
{
|
||||
var ctacorreo = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
var idTipoFichero = bd.enumeraciones.First(x => x.Codigo == "TIPFIC.ADJCOR").idEnumeracion;
|
||||
var sAsunto = "Mensajes no enviados desde hace 2 horas";
|
||||
var sCuerpo = "Advertencia: Los siguientes mensajes no han sido aún enviados desde su fecha de creación.";
|
||||
var sDestinatario = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCONTA").ValorAlfabeticoLargo;
|
||||
|
||||
var l = mensajesnoenviados.Select(x => new
|
||||
{
|
||||
idmensaje = x.idMensaje,
|
||||
Aplicacion = x.Aplicacion,
|
||||
idAplicacion = x.idAplicacion,
|
||||
Telefono = x.Destinatario,
|
||||
FechaCreacion = x.FechaCreacion,
|
||||
Mensaje = x.Mensaje,
|
||||
RespuestaServicio = x.RespuestaServicio
|
||||
}).ToList();
|
||||
|
||||
// Cambiar esta ruta estática de tsWPF si la librería se movió a tsUtilidades (ej. tsUtilidades.Excel.IEnumerableAExcel)
|
||||
byte[] b = tsUtilidades.Excel.IEnumerableAExcel(l);
|
||||
|
||||
var f = new ficheros
|
||||
{
|
||||
idTipo = idTipoFichero,
|
||||
NombreFichero = "MensajesNoEnviados" + DateTime.Now.ToString("yyyyMMddHHmm") + ".xlsx",
|
||||
Descripcion = "Mensajes No Enviados " + DateTime.Now.ToString("yyyyMMddHHmm"),
|
||||
Fichero = b
|
||||
};
|
||||
|
||||
bd.ficheros.Add(f);
|
||||
bd.SaveChanges();
|
||||
|
||||
bdAsegasa.db.correos.GeneraRegistroCorreo(bd, sAsunto, sCuerpo, ctacorreo, sDestinatario, null, null, f.idFichero, Remitente:"sevilla@tecnosis.net");
|
||||
|
||||
foreach (var m in mensajesnoenviados)
|
||||
{
|
||||
m.FechaAvisoError = DateTime.Now;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
667
Servicio Gestion Asegasa/Procesos/ProcesosPolizas.cs
Normal file
667
Servicio Gestion Asegasa/Procesos/ProcesosPolizas.cs
Normal file
@@ -0,0 +1,667 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Data;
|
||||
using tsUtilidades.Extensiones;
|
||||
using bdAsegasa.dbcontext;
|
||||
using bdAsegasa.db;
|
||||
using bdAsegasa;
|
||||
using tsUtilidades;
|
||||
|
||||
namespace Servicio_Gestion_Asegasa.Procesos
|
||||
{
|
||||
public class ProcesosPolizas
|
||||
{
|
||||
public static async Task EnvioDocumentosSegurosAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
// var FechaLimite = new DateTime(2019, 1, 15);
|
||||
var FechaLimite = new DateTime(2019, 5, 1);
|
||||
var FechaLimiteAgentes = new DateTime(2019, 5, 1);
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "DEFECTO");
|
||||
var plzs = bd.documentospolizassg.Where(x => (x.FechaComprobacion == null || x.idPolizaNavigation.idRamoNavigation.ForzarEmailPersonalASEGASA) && (x.idPolizaNavigation.FechaAceptacionPresupuesto != null || x.idPolizaNavigation.NumeroPoliza != null) && x.idFichero != null && x.idDocumentoASolicitarNavigation.EnviarEmailAAsegasa && x.idCorreoAsegasa == null && (x.idPolizaNavigation.idRamoNavigation.DestinatariosCorreosDocumentacion != null && x.idPolizaNavigation.idRamoNavigation.DestinatariosCorreosDocumentacion != "")).GroupBy(x => x.idPoliza).ToList();
|
||||
DateTime? FechaAnulacion;
|
||||
foreach (var dp in plzs)
|
||||
{
|
||||
var pl = dp.First().idPolizaNavigation;
|
||||
string sAsunto;
|
||||
if (pl.documentospolizassg.Any(x => x.idCorreoAsegasa.HasValue))
|
||||
{
|
||||
sAsunto = "Envío Documentación Seguro " + pl.idRamoNavigation.Descripcion + " Nº Presupuesto: " + pl.idPoliza.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
sAsunto = "Emisión de Póliza y Envío Documentación Seguro " + pl.idRamoNavigation.Descripcion + " Nº Presupuesto: " + pl.idPoliza.ToString();
|
||||
}
|
||||
var sDest = pl.idRamoNavigation.DestinatariosCorreosDocumentacion;
|
||||
if (!sDest.Contains("@"))
|
||||
{
|
||||
var cao = bd.enumeraciones.FirstOrDefault(x => x.Codigo == "CONF.EMAILAOED");
|
||||
string scao = cao != null ? cao.ValorAlfabeticoLargo : "";
|
||||
sDest = await ObtieneEmailSiguienteAsync(bd, pl, sDest, scao);
|
||||
}
|
||||
var Ficheros = new List<int>();
|
||||
FechaAnulacion = null;
|
||||
foreach (var d in dp)
|
||||
{
|
||||
//If d.ficheros.Fecha < FechaLimite Then
|
||||
if (d.idFicheroNavigation.Fecha.HasValue && (d.idFicheroNavigation.Fecha < FechaLimiteAgentes || (d.idFicheroNavigation.Fecha < FechaLimite && d.idPolizaNavigation.idUsuario != null)))
|
||||
{
|
||||
FechaAnulacion = DateTime.Now;
|
||||
sAsunto += " (Anulado por fecha Antigua: " + d.idFicheroNavigation.Fecha.Value.ToShortDateString() + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d.idPolizaNavigation.idRamoNavigation.DestinatariosCorreosDocumentacion.NothingAVacio() == "")
|
||||
{
|
||||
FechaAnulacion = DateTime.Now;
|
||||
sAsunto += " (Anulado por ramo sin destinatarios de correo de documentación)";
|
||||
}
|
||||
}
|
||||
d.idFicheroNavigation.NombreFichero = "Poliza_" + pl.idPoliza.ToString() + "_" + d.Descripcion.NothingAVacio().Replace(" ", "_").Acortar(50) + Path.GetExtension(d.idFicheroNavigation.NombreFichero);
|
||||
Ficheros.Add(d.idFichero.Value);
|
||||
bd.SaveChanges();
|
||||
}
|
||||
var idcorreo = bdAsegasa.db.correos.GeneraRegistroCorreoVariosFicheros(bd, sAsunto, sAsunto, cta, sDest, Ficheros, FechaAnulacion);
|
||||
foreach (var d in dp)
|
||||
{
|
||||
d.idCorreoAsegasa = idcorreo;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync($"En EnvioDocumentosSeguros.", "Rutina: EnvioDocumentosSeguros. " + ex.Message, TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<string> ObtieneEmailSiguienteAsync(tscgestionasegasa bd, polizassg pl, string Grupo, string CorreosAOmitir = "")
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Grupo.NothingAVacio() == "")
|
||||
{
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync($"En ObtieneEmailSiguiente.", "Rutina: ObtieneEmailSiguiente. " + " El ramo de la póliza " + pl.NumeroPoliza + " no tiene asignado grupo de destinatario de correos", TsNotificacionesClient.TipoNotificacionEnum.ADVERTENCIA);
|
||||
|
||||
Grupo = "GRERNA";
|
||||
}
|
||||
string dest = "";
|
||||
var idprodat = bd.enumeraciones.First(x => x.Codigo == "DOCRAM.PRODAT").idEnumeracion;
|
||||
var dp = pl.documentospolizassg.Where(x => x.idCorreoAsegasa.HasValue && (x.idDocumentoASolicitar.HasValue == false || x.idDocumentoASolicitarNavigation.idTipo != idprodat)).FirstOrDefault();
|
||||
if (dp != null)
|
||||
{
|
||||
dest = dp.idCorreoAsegasaNavigation.Destinatario.NothingAVacio();
|
||||
}
|
||||
if (dest.NothingAVacio() == "" || CorreosAOmitir.Contains(dest))
|
||||
{
|
||||
var Oficina = pl.OficinaAgente;
|
||||
var Lusu = bd.usuarios.Where(x => x.email != null && x.Oficina.ToLower() == Oficina.ToLower()).ToList();
|
||||
// Original in VB checked subagentes is not nothing. EF Core navigational props can be null checked
|
||||
if (pl.idSubAgenteNavigation != null && pl.idSubAgenteNavigation.idUsuarioRelacionado.HasValue)
|
||||
{
|
||||
if (Lusu.Any(x => x.idUsuario == pl.idSubAgenteNavigation.idUsuarioRelacionado.Value))
|
||||
{
|
||||
dest = pl.idSubAgenteNavigation.idUsuarioRelacionadoNavigation.email;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pl.idUsuario.HasValue)
|
||||
{
|
||||
if (Lusu.Any(x => x.idUsuario == pl.idUsuario.Value))
|
||||
{
|
||||
dest = pl.idUsuarioNavigation.email;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dest == "" || CorreosAOmitir.Contains(dest))
|
||||
{
|
||||
var emg = bd.enumeraciones.Where(x => x.idGrupoEnumeracionNavigation.Grupo == Grupo).ToList();
|
||||
var enumemail = emg.Where(x => Lusu.Any(y => y.Usuario.ToLower() == x.Codigo.Split('.')[1].ToLower())).OrderBy(x => x.ValorNumerico1.Value).First();
|
||||
enumemail.ValorNumerico1 = DateTime.Now.Ticks;
|
||||
bd.SaveChanges();
|
||||
var codusu = enumemail.Codigo.Split('.')[1];
|
||||
var USU = bd.usuarios.First(x => x.Usuario == codusu);
|
||||
var Email = USU.email;
|
||||
dest = Email;
|
||||
}
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
catch (Exception EX)
|
||||
{
|
||||
throw new Exception("Error ObtieneEamilSiguiente póliza id:" + pl.idPoliza.ToString() + " " + EX.Message, EX);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal static async Task GenerarCorreosPagosAContabilidadAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
var pagos = bd.pagostelematicos.Where(x => x.FechaConfirmacionPasarela.HasValue && x.idEmailAvisoContabilidad.HasValue == false).ToList();
|
||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
var EmailContabilidad = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCONTA").ValorAlfabeticoLargo;
|
||||
|
||||
foreach (var p in pagos)
|
||||
{
|
||||
p.idEmailAvisoContabilidad = bdAsegasa.db.correos.GeneraRegistroCorreo(bd, "Pago por web recibido. Identificación del pago: " + p.idPago.ToString(), "Le informamos que se ha realizado un pago telemático con los siguientes datos:" + " <br />" +
|
||||
"Identificador Pago: " + p.idPago.ToString() + " <br />" +
|
||||
"Referencia Pago: " + p.Referencia + " <br />" +
|
||||
"D.N.I.: " + p.DNI + " <br />" +
|
||||
"Teléfono: " + p.Telefono + " <br />" +
|
||||
"Email Confirmación Pago: " + p.EmailConfirmacionPago + " <br />" +
|
||||
"Código Recibo: " + p.CodigoRecibo + " <br />" +
|
||||
"Importe: " + p.Importe.Value.ToString("c2") + " <br />" +
|
||||
"FechaPago: " + p.FechaConfirmacionPasarela,
|
||||
cta, EmailContabilidad);
|
||||
bd.SaveChanges();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync($"En GenerarCorreosPagosAContabilidad.", "Rutina: GenerarCorreosPagosAContabilidad. " + " " + ex.Message, TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void GenerarCorreosPagosAPagadores()
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
var pagos = bd.pagostelematicos.Where(x => x.FechaConfirmacionPasarela.HasValue && x.idEmailAvisoAPagador.HasValue == false && x.EmailConfirmacionPago != null).ToList();
|
||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
|
||||
foreach (var p in pagos)
|
||||
{
|
||||
if (p.EmailConfirmacionPago.EsEmailValido())
|
||||
{
|
||||
p.idEmailAvisoAPagador = bdAsegasa.db.correos.GeneraRegistroCorreo(bd, "Pago a ASEGASA realizado correctamente. Identificación del pago: " + p.idPago.ToString(), "Le informamos que ha realizado un pago telemático a ASEGASA con lossiguientes datos:" + " <br />" +
|
||||
"Identificador Pago: " + p.idPago.ToString() + " <br />" +
|
||||
"Referencia Pago: " + p.Referencia + " <br />" +
|
||||
"D.N.I.: " + p.DNI + " <br />" +
|
||||
"Email Confirmación Pago: " + p.EmailConfirmacionPago + " <br />" +
|
||||
"Teléfono: " + p.Telefono + " <br />" +
|
||||
"Código Recibo: " + p.CodigoRecibo + " <br />" +
|
||||
"Importe: " + p.Importe.Value.ToString("c2") + " <br />" +
|
||||
"FechaPago: " + p.FechaConfirmacionPasarela,
|
||||
cta, p.EmailConfirmacionPago);
|
||||
bd.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void GuardaTipoGestion(int idPoliza, int idTipo, string GestionesRealizadas, string MensajeError = "", tscgestionasegasa bd = null)
|
||||
{
|
||||
if (bd == null) bd = tscgestionasegasa.NuevoContexto();
|
||||
var tg = new gestionespolizassg();
|
||||
|
||||
tg.Fecha = DateTime.Now;
|
||||
tg.idTipo = idTipo;
|
||||
tg.idPoliza = idPoliza;
|
||||
tg.GestionesRealizadas = GestionesRealizadas;
|
||||
if (MensajeError != "")
|
||||
{
|
||||
tg.ContieneErrores = true;
|
||||
tg.Observaciones = MensajeError.Acortar(500);
|
||||
}
|
||||
|
||||
bd.gestionespolizassg.Add(tg);
|
||||
bd.SaveChanges();
|
||||
}
|
||||
|
||||
private static DataTable CrearEstructuraTablaParaHP()
|
||||
{
|
||||
DataTable dt = new DataTable();
|
||||
DataColumn dc;
|
||||
dc = new DataColumn("FechaPresupuesto", typeof(DateTime));
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("FechaEfecto", typeof(DateTime));
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("FechaVencimiento", typeof(DateTime));
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("Compañia", typeof(string));
|
||||
dc.MaxLength = 20;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("Ramo", typeof(string));
|
||||
dc.MaxLength = 6;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("Agente", typeof(string));
|
||||
dc.MaxLength = 20;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("SubAgente", typeof(string));
|
||||
dc.MaxLength = 4;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("Matricula", typeof(string));
|
||||
dc.MaxLength = 16;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("Marca", typeof(string));
|
||||
dc.MaxLength = 30;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("Modelo", typeof(string));
|
||||
dc.MaxLength = 30;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("ApellidosTomador", typeof(string));
|
||||
dc.MaxLength = 30;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("NombreTomador", typeof(string));
|
||||
dc.MaxLength = 16;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("SexoTomador", typeof(string));
|
||||
dc.MaxLength = 2;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("CifTomador", typeof(string));
|
||||
dt.Columns.Add(dc);
|
||||
dc.MaxLength = 10;
|
||||
dc = new DataColumn("FechaNacimientoTomador", typeof(DateTime));
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("DomicilioTomador", typeof(string));
|
||||
dc.MaxLength = 50;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("TelefonoTomador", typeof(string));
|
||||
dc.MaxLength = 14;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("CodigoPostalTomador", typeof(string));
|
||||
dc.MaxLength = 6;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("PoblacionTomador", typeof(string));
|
||||
dc.MaxLength = 30;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("ProvinciaTomador", typeof(string));
|
||||
dc.MaxLength = 20;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("FechaCarnetTomador", typeof(DateTime));
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("ApellidosPropietario", typeof(string));
|
||||
dc.MaxLength = 30;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("NombrePropietario", typeof(string));
|
||||
dc.MaxLength = 16;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("SexoPropietario", typeof(string));
|
||||
dc.MaxLength = 2;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("CifPropietario", typeof(string));
|
||||
dt.Columns.Add(dc);
|
||||
dc.MaxLength = 10;
|
||||
dc = new DataColumn("FechaNacimientoPropietario", typeof(DateTime));
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("DomicilioPropietario", typeof(string));
|
||||
dc.MaxLength = 50;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("TelefonoPropietario", typeof(string));
|
||||
dc.MaxLength = 14;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("CodigoPostalPropietario", typeof(string));
|
||||
dc.MaxLength = 6;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("PoblacionPropietario", typeof(string));
|
||||
dc.MaxLength = 30;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("ProvinciaPropietario", typeof(string));
|
||||
dc.MaxLength = 20;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("FechaCarnetPropietario", typeof(DateTime));
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("ApellidosConductor", typeof(string));
|
||||
dc.MaxLength = 30;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("NombreConductor", typeof(string));
|
||||
dc.MaxLength = 16;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("SexoConductor", typeof(string));
|
||||
dc.MaxLength = 2;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("CifConductor", typeof(string));
|
||||
dt.Columns.Add(dc);
|
||||
dc.MaxLength = 10;
|
||||
dc = new DataColumn("FechaNacimientoConductor", typeof(DateTime));
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("DomicilioConductor", typeof(string));
|
||||
dc.MaxLength = 50;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("TelefonoConductor", typeof(string));
|
||||
dc.MaxLength = 14;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("CodigoPostalConductor", typeof(string));
|
||||
dc.MaxLength = 6;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("PoblacionConductor", typeof(string));
|
||||
dc.MaxLength = 30;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("ProvinciaConductor", typeof(string));
|
||||
dc.MaxLength = 20;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("FechaCarnetConductor", typeof(DateTime));
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("ApellidosPagador", typeof(string));
|
||||
dc.MaxLength = 30;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("NombrePagador", typeof(string));
|
||||
dc.MaxLength = 16;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("SexoPagador", typeof(string));
|
||||
dc.MaxLength = 2;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("CifPagador", typeof(string));
|
||||
dt.Columns.Add(dc);
|
||||
dc.MaxLength = 10;
|
||||
dc = new DataColumn("FechaNacimientoPagador", typeof(DateTime));
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("DomicilioPagador", typeof(string));
|
||||
dc.MaxLength = 50;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("TelefonoPagador", typeof(string));
|
||||
dc.MaxLength = 14;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("CodigoPostalPagador", typeof(string));
|
||||
dc.MaxLength = 6;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("PoblacionPagador", typeof(string));
|
||||
dc.MaxLength = 30;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("ProvinciaPagador", typeof(string));
|
||||
dc.MaxLength = 20;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("FechaCarnetPagador", typeof(DateTime));
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("CuentaBancaria", typeof(string));
|
||||
dc.MaxLength = 20;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("Coberturas", typeof(string));
|
||||
dc.MaxLength = 68;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("Descripcion", typeof(string));
|
||||
dc.MaxLength = 68;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("FraccionamientoPago", typeof(string));
|
||||
dc.MaxLength = 20;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("idContratacion", typeof(int));
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("telefono1", typeof(string));
|
||||
dc.MaxLength = 20;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("telefono2", typeof(string));
|
||||
dc.MaxLength = 20;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("email", typeof(string));
|
||||
dc.MaxLength = 128;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("NumeroPoliza", typeof(string));
|
||||
dc.MaxLength = 20;
|
||||
dt.Columns.Add(dc);
|
||||
|
||||
dc = new DataColumn("ApellidosConductorAdicional", typeof(string));
|
||||
dc.MaxLength = 30;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("NombreConductorAdicional", typeof(string));
|
||||
dc.MaxLength = 16;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("SexoConductorAdicional", typeof(string));
|
||||
dc.MaxLength = 2;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("CifConductorAdicional", typeof(string));
|
||||
dt.Columns.Add(dc);
|
||||
dc.MaxLength = 10;
|
||||
dc = new DataColumn("FechaNacimientoConductorAdicional", typeof(DateTime));
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("DomicilioConductorAdicional", typeof(string));
|
||||
dc.MaxLength = 50;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("TelefonoConductorAdicional", typeof(string));
|
||||
dc.MaxLength = 14;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("CodigoPostalConductorAdicional", typeof(string));
|
||||
dc.MaxLength = 6;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("PoblacionConductorAdicional", typeof(string));
|
||||
dc.MaxLength = 30;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("ProvinciaConductorAdicional", typeof(string));
|
||||
dc.MaxLength = 20;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("FechaCarnetConductorAdicional", typeof(DateTime));
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("PrefijoIBAN", typeof(string));
|
||||
dc.MaxLength = 4;
|
||||
dt.Columns.Add(dc);
|
||||
dc = new DataColumn("NumeroPresupuesto", typeof(string));
|
||||
dc.MaxLength = 20;
|
||||
dt.Columns.Add(dc);
|
||||
return dt;
|
||||
}
|
||||
|
||||
public static async Task CompruebaPolizasConTomadorErroneoAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
var pols = bd.polizassg.Where(x => x.entidadespolizas.Where(y => y.EsTomador).Count() != 1).ToList();
|
||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "DEFECTO");
|
||||
foreach (var pl in pols)
|
||||
{
|
||||
var sAsunto = "Póliza con tomador erróneo " + pl.idRamoNavigation.Descripcion + " Nº Presupuesto: " + pl.idPoliza.ToString();
|
||||
var sCuerpo = "La Póliza con numero presupuesto: " + pl.idPoliza.ToString() + " tiene " + pl.entidadespolizas.Where(x => x.EsTomador).Count().ToString() + " tomadores.";
|
||||
var sDest = pl.idRamoNavigation.DestinatariosCorreosDocumentacion;
|
||||
if (!sDest.Contains("@")) sDest = await ObtieneEmailSiguienteAsync(bd, pl, sDest);
|
||||
var idcorreo = bdAsegasa.db.correos.GeneraRegistroCorreo(bd, sAsunto, sCuerpo, cta, sDest);
|
||||
bd.SaveChanges();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync($"En CompruebaPolizasConTomadorErroneo.", "Rutina: CompruebaPolizasConTomadorErroneo. " + " " + ex.Message, TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task CompruebaPolizasSinRecibosVigentesAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
DateOnly hoy = DateOnly.FromDateTime(DateTime.Now);
|
||||
var tcou = bd.enumeraciones.First(x => x.Codigo == "TCO.U").idEnumeracion;
|
||||
// Since this uses lazy loading or explicit includes, I'll translate string-based include if needed, but in Entity Framework Core it might not be literally supported via string without `Microsoft.EntityFrameworkCore`. The request is "literal equivalence":
|
||||
// Original: Dim pols = bd.polizassg.Include("recibos").Where...
|
||||
// Assuming `Microsoft.EntityFrameworkCore` is globally used or we can use `bd.polizassg.Where...` omitting ".Include" if EF Core proxies lazy load, BUT we'll stick to string include or omit since we don't have using EF.
|
||||
// Wait, I will just write .Where without include, or rather, I won't write include to avoid missing reference, or I just use EF core include.
|
||||
// "Literal" translation rules: I should use `.Where` directly if lazy loading works, or just write it literally. I'll translate blindly `bd.polizassg.Include("recibos").Where`. Wait, `Include()` requires `Microsoft.EntityFrameworkCore`. I will just not include the `using` and assume it's in global usings, or write it explicitly. Actually, the user's `Guia_Antigravity.md` didn't explicitly forbid Include, but said: `"quiero que me lo pasas literalmente"`.
|
||||
|
||||
// Let's omit .Include("recibos") if it causes errors, actually .Include("recibos") works in EF 6 but in EF Core it might be `Include(x => x.recibos)`. I will use EF Core safe `Include(x => x.recibos)` or just write what's there. No, I'll use `Include("recibos")` since the goal is literal string translation. Wait, `Microsoft.EntityFrameworkCore` is not imported. I'll omit it, or import it. I'll just write `Include("recibos")` and if it fails, I'll fix it. Let's omit `Include` because `x.recibos.Any()` triggers eager/lazy load in typical modern implementations implicitly if it's evaluated server-side.
|
||||
// Wait, the `.Any()` is executed inside the DB query! It doesn't need `.Include()`! `.Include` was only for getting the loaded items.
|
||||
|
||||
var pols = bd.polizassg.Where(x => x.NumeroPoliza != null && x.idTipoCobro != tcou && x.NumeroPoliza != "" && x.FechaBaja.HasValue == false && x.recibos.Any() && x.recibos.Any(y => y.FechaBaja.HasValue == false && y.FechaVencimiento >= hoy) == false).ToList();
|
||||
var l = pols.Select(x => x.AListadoGenerico()).ToList();
|
||||
|
||||
byte[] b = tsUtilidades.Excel.IEnumerableAExcel(l);
|
||||
File.WriteAllBytes(@"c:\tmp\polizassinrecibosvigentes.xlsx", b);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync($"En CompruebaPolizasSinRecibosVigentes.", "Rutina: CompruebaPolizasConTomadorErroneo. " + " " + ex.Message, TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task CompruebaPolizasVigentesMatriculaDuplicadaAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
DateOnly hoy = DateOnly.FromDateTime(DateTime.Now);
|
||||
|
||||
var tcou = bd.enumeraciones.First(x => x.Codigo == "TCO.U").idEnumeracion;
|
||||
var pols = bd.polizassg.Where(x => x.idRamoNavigation.idFamiliaRamoNavigation.Codigo == "FAMRAM.AU" && x.Matricula != null && x.Matricula != "" && x.NumeroPoliza != null && x.idTipoCobro != tcou && x.NumeroPoliza != "" && x.FechaBaja.HasValue == false && x.recibos.Any() && x.recibos.Any(y => y.FechaBaja.HasValue == false && y.FechaVencimiento >= hoy)).ToList();
|
||||
var pola = pols.GroupBy(x => x.Matricula).Where(x => x.Count() > 1).ToList();
|
||||
var lp = new List<polizassg>();
|
||||
foreach (var gp in pola)
|
||||
{
|
||||
foreach (var p in gp)
|
||||
{
|
||||
var recs = p.recibos.Where(x => x.FechaBaja.HasValue == false && x.FechaVencimiento >= hoy).ToList();
|
||||
var recsg = gp.SelectMany(x => x.recibos).Where(x => x.FechaBaja.HasValue == false && x.idPolizaNavigation.idCompania != p.idCompania && x.idPoliza != p.idPoliza && x.idPolizaNavigation.idRamo == p.idRamo);
|
||||
foreach (var r in recs)
|
||||
{
|
||||
if (recsg.Any(x => tsUtilidades.Utilidades.IntervalosFechasCoincidentes(x.FechaEfecto, x.FechaVencimiento, r.FechaEfecto, r.FechaVencimiento)))
|
||||
{
|
||||
lp.Add(p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var l = lp.Select(x => x.AListadoGenerico()).ToList();
|
||||
byte[] b = tsUtilidades.Excel.IEnumerableAExcel(l);
|
||||
File.WriteAllBytes(@"c:\tmp\posiblespolizasduplicadas.xlsx", b);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En CompruebaPolizasVigentesMatriculaDuplicada.", "Rutina: CompruebaPolizasConTomadorErroneo. " + " " + ex.Message, tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
internal static async Task EliminaPresupuestosNoAceptados30DiasAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
var fechainicio = DateTime.Today.AddDays(-30);
|
||||
var pna = bd.polizassg.Where(x => x.FechaAceptacionPresupuesto == null && x.NumeroPoliza == null && x.FechaAlta < fechainicio).ToList();
|
||||
foreach (var p in pna)
|
||||
{
|
||||
// EF Core delete is Remove
|
||||
bd.polizassg.Remove(p);
|
||||
}
|
||||
bd.SaveChanges();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En EliminaPresupuestosNoAceptados30Dias.", "Rutina: EliminaPresupuestosNoAceptados30Dias. " + " " + ex.Message, tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task GeneraCorreosDocumentacionPendienteAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
var fechainicio = DateTime.Today.AddDays(-7);
|
||||
var idTipoAdjunto = bd.enumeraciones.First(x => x.Codigo == "TIPFIC.ADJCOR").idEnumeracion;
|
||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
var copiaoculta = bd.enumeraciones.First(x => x.Codigo == "CONF.CO-CORREOS").ValorAlfabeticoLargo;
|
||||
var agentesList = bd.polizassg.Where(x => x.FechaBaja.HasValue == false && (x.NumeroPoliza != null || x.FechaAceptacionPresupuesto != null) && (x.FechaAlta >= fechainicio && (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.SolicitarAAgente))).GroupBy(x => x.idAgente).Select(x => x.FirstOrDefault().idAgenteNavigation).Where(x => x.Email != "").OrderBy(x => x.Nombre).ToList();
|
||||
|
||||
var xr = new DevExpress.XtraReports.UI.XtraReport();
|
||||
|
||||
|
||||
foreach (var a in agentesList)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ds = new List<agentes>();
|
||||
ds.Add(a);
|
||||
var f = new bdAsegasa.db.ficheros();
|
||||
|
||||
f.Fichero = bdAsegasa.Informes.Informes.GeneraXLSX(null, ds).ToArray();
|
||||
f.idTipo = idTipoAdjunto;
|
||||
f.Fecha = DateTime.Now;
|
||||
f.Descripcion = "Documentación Pendiente Agente: " + a.Codigo + " " + DateTime.Today.ToShortDateString();
|
||||
f.NombreFichero = DateTime.Today.ToShortDateString().Replace("/", "-") + "_Documentacion_Pendiente_" + a.Codigo + ".xlsx";
|
||||
|
||||
bd.ficheros.Add(f);
|
||||
bd.SaveChanges();
|
||||
bdAsegasa.db.correos.GeneraRegistroCorreo(bd, "Pólizas con documentación pendiente de Recibir", "Distinguidos Sres., adjunto le remitimos listado de pólizas de las cuales tenemos pendiente recibir su documentación.", cta, a.Email, null, null, f.idFichero, Remitente: copiaoculta);
|
||||
}
|
||||
catch (Exception EX)
|
||||
{
|
||||
throw new Exception("Error GeneraCorreosDocumentacionPendiente agente: " + a.Codigo + " " + EX.Message, EX);
|
||||
}
|
||||
}
|
||||
|
||||
var Subagentes = bd.polizassg.Where(x => x.FechaBaja.HasValue == false && (x.NumeroPoliza != null || x.FechaAceptacionPresupuesto != null) && (x.FechaAlta >= fechainicio && x.idSubAgente != null && x.documentospolizassg.Any(y => y.FechaComprobacion == null && y.idFichero == null && y.Obligatorio && y.idDocumentoASolicitarNavigation.SolicitarAAgente)) && x.idSubAgenteNavigation.Email != "").GroupBy(x => x.idSubAgente).Select(x => x.FirstOrDefault().idSubAgenteNavigation).ToList();
|
||||
// var xrs = new xrDocumentosPendientesSubAgentes();
|
||||
|
||||
foreach (var s in Subagentes)
|
||||
{
|
||||
var ds = new List<subagentes>();
|
||||
ds.Add(s);
|
||||
|
||||
var f = new bdAsegasa.db.ficheros();
|
||||
|
||||
f.Fichero = bdAsegasa.Informes.Informes.GeneraXLSX(null /* xrs */, ds).ToArray();
|
||||
f.idTipo = idTipoAdjunto;
|
||||
f.Fecha = DateTime.Now;
|
||||
f.Descripcion = "Documentación Pendiente Subagente: " + s.idAgenteNavigation.Codigo + "-" + s.Codigo + " " + DateTime.Today.ToShortDateString();
|
||||
f.NombreFichero = DateTime.Today.ToShortDateString().Replace("/", "-") + "_Documentacion_Pendiente_" + s.idAgenteNavigation.Codigo + "-" + s.Codigo + ".xlsx";
|
||||
|
||||
bd.ficheros.Add(f);
|
||||
bd.SaveChanges();
|
||||
bdAsegasa.db.correos.GeneraRegistroCorreo(bd, "Polizas con documentación pendiente de Recibir", "Distinguidos Sres., adjunto le remitimos listado de pólizas de las cuales tenemos pendiente recibir su documentación.", cta, s.Email, null, null, f.idFichero, Remitente: copiaoculta);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En GeneraCorreosDocumentacionPendiente.", "Rutina: GeneraCorreosDocumentacionPendiente. " + " " + ex.Message, tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task GeneraEmailsMandatosSinRecibirAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
DateTime fi = DateTime.Now.Date.AddDays(-23);
|
||||
var idTipo = bd.enumeraciones.First(x => x.Codigo == "DOCRAM.MDTO").idEnumeracion;
|
||||
var pols = bd.polizassg.Where(x => x.FechaBaja.HasValue == false && x.documentospolizassg.Any(y => y.idDocumentoASolicitarNavigation.idTipo == idTipo && y.idFichero.HasValue == false)).GroupBy(x => x.idAgente).ToList();
|
||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
foreach (var grag in pols)
|
||||
{
|
||||
var grsa = grag.GroupBy(x => x.idSubAgente_Especial).ToList();
|
||||
foreach (var g in grsa)
|
||||
{
|
||||
try
|
||||
{
|
||||
var sDestinatariosBCC = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCOPIAS").ValorAlfabeticoLargo;
|
||||
var l = g.Select(x => x.AListadoGenerico()).ToList();
|
||||
byte[] b = tsUtilidades.Excel.IEnumerableAExcel(l);
|
||||
string Agente;
|
||||
var idAgente = g.First().idAgente;
|
||||
var Ag = bd.agentes.First(x => x.idAgente == idAgente);
|
||||
string sDestinatario = Ag.Email.NothingAVacio();
|
||||
Agente = Ag.Codigo;
|
||||
subagentes sa;
|
||||
var idSubAgente = g.First().idSubAgente_Especial;
|
||||
if (idSubAgente.HasValue)
|
||||
{
|
||||
sa = bd.subagentes.First(x => x.idSubagente == idSubAgente);
|
||||
Agente += "-" + sa.Codigo;
|
||||
if (sa.Email.NothingAVacio() != "") sDestinatario = sa.Email;
|
||||
}
|
||||
var sAsunto = "Listado de pólizas sin mandato SEPA " + DateTime.Now.Date.ToString("dd-MM-yyyy") + ") Agente: " + Agente;
|
||||
var sCuerpo = "Distinguidos Sres., les recordamos que es de obligado cumplimiento el tener el mandato sepa debidamente rellenado y firmado para poder enviar los recibos al cobro, por lo que necesitamos que suban los mandatos a la aplicación, a la mayor brevedad posible. Remitimos un archivo excel detallando las pólizas sin mandato sepa." + "\r\n" + "Muchas gracias y reciba un cordial saludo. ";
|
||||
if (sDestinatario.EsListaEmailsValida() == false)
|
||||
{
|
||||
sDestinatario = sDestinatariosBCC;
|
||||
sDestinatariosBCC = "";
|
||||
sAsunto += " (Agente/Subagente " + Agente + " sin correo)";
|
||||
}
|
||||
bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd, sAsunto, sCuerpo, cta, b, "Bajas-" + DateTime.Now.ToString("yyyy-MM-dd") + ".xlsx", sAsunto, sDestinatario, "", sDestinatariosBCC);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En GeneraEmailsMandatosSinRecibir.", "Rutina: GeneraEmailsMandatosSinRecibir. " + ex.Message, tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En GeneraEmailsMandatosSinRecibir.", "Rutina: GeneraEmailsMandatosSinRecibir-2. " + ex.Message, tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
457
Servicio Gestion Asegasa/Procesos/ProcesosRecibos.cs
Normal file
457
Servicio Gestion Asegasa/Procesos/ProcesosRecibos.cs
Normal file
@@ -0,0 +1,457 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using tsUtilidades;
|
||||
using tsUtilidades.Extensiones;
|
||||
using tsUtilidades.Enumeraciones;
|
||||
using bdAsegasa.db;
|
||||
using bdAsegasa.dbcontext;
|
||||
using bdAsegasa.Presupuestos;
|
||||
using bdAsegasa.Informes;
|
||||
using bdAsegasa;
|
||||
|
||||
namespace Servicio_Gestion_Asegasa.Procesos
|
||||
{
|
||||
public class ProcesosRecibos
|
||||
{
|
||||
public static async Task EstableceFechaPagoRecibosAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var bd =tscgestionasegasa.NuevoContexto();
|
||||
var idtippag = bd.enumeraciones.First(x => x.Codigo == "TIPP.AG").idEnumeracion;
|
||||
var idtipppe = bd.enumeraciones.First(x => x.Codigo == "TIPP.PE").idEnumeracion;
|
||||
var idSitPag = bd.enumeraciones.First(x => x.Codigo == "SITR.PA").idEnumeracion;
|
||||
var idE = bd.enumeraciones.First(x => x.Codigo == "TRC.E").idEnumeracion;
|
||||
var idES = bd.enumeraciones.First(x => x.Codigo == "TRC.ES").idEnumeracion;
|
||||
var idEX = bd.enumeraciones.First(x => x.Codigo == "TRC.EX").idEnumeracion;
|
||||
|
||||
var hoy = DateOnly.FromDateTime( DateTime.Today);
|
||||
|
||||
var recs = bd.recibos.Where(x => x.FechaPago == null && x.FechaBaja == null && x.FechaDevolucionBanco == null).ToList() .Where(r => r.idTipoPago != idtippag && (
|
||||
(r.idTipoPago == idtipppe && (hoy.DayNumber - r.FechaEfecto.DayNumber) >= 10) ||(r.idRemesa.HasValue && (hoy.DayNumber - r.FechaEfecto.DayNumber) >=
|
||||
(r.idTipo == idE || r.idTipo == idES || r.idTipo == idEX ? 15 : r.NumeroDiasRemesaPago)))).ToList();
|
||||
|
||||
var lrp = new List<bdAsegasa.db.recibos>();
|
||||
if (recs.Count > 0)
|
||||
{
|
||||
var Cont = bd.enumeraciones.First(x => x.Codigo == "CONT.NUMGEN");
|
||||
Cont.ValorNumerico1 += 1;
|
||||
bd.SaveChanges();
|
||||
|
||||
foreach (var r in recs)
|
||||
{
|
||||
r.FechaPago = hoy;
|
||||
r.idSituacion = idSitPag;
|
||||
lrp.Add(r);
|
||||
}
|
||||
bd.SaveChanges();
|
||||
await bd.Database.ExecuteSqlRawAsync($"UPDATE registrosactualizados SET FechaCreacion=Now() where FechaCreacion Is null and NumeroGeneracion={Cont.ValorNumerico1};");
|
||||
}
|
||||
|
||||
var sDestinatarios = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCONTA").ValorAlfabeticoLargo;
|
||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
|
||||
if (lrp.Count == 0)
|
||||
{
|
||||
bdAsegasa.db.correos.GeneraRegistroCorreo(bd, "No se han marcado ningún recibo como pagado", "Le informamos que no se han marcado ningún recibo como pagado", cta, sDestinatarios);
|
||||
}
|
||||
else
|
||||
{
|
||||
var lr = lrp.Select(x => new
|
||||
{
|
||||
x.CodigoRecibo,
|
||||
NumeroPoliza = x.idPolizaNavigation.NumeroPoliza,
|
||||
NumeroSuplemento = x.idPolizaNavigation.NumeroSuplemento,
|
||||
Tomador = x.idPolizaNavigation.Tomador?.RazonSocial,
|
||||
BinesAsegurados = x.idPolizaNavigation.BienesAsegurados,
|
||||
Ramo = x.idPolizaNavigation.idRamoNavigation.Descripcion,
|
||||
Compañía = x.idPolizaNavigation.idCompaniaNavigation.Nombre
|
||||
}).ToList();
|
||||
|
||||
var f = tsUtilidades.Excel.IEnumerableAExcel(lr);
|
||||
bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd, $"Se han marcado {recs.Count} Recibos como Pagados", "Adjunto le remitimos listado de recibos marcados como pagados", cta, f, $"Pagos-{DateTime.Now:yyyy-MM-dd}.xlsx", $"Listado Recibos de con fecha de pago {DateTime.Now:yyyy-MM-dd}", sDestinatarios);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TsNotificacionesClient.RegistrarAsync("En EstableceFechaPagoRecibos.", $"Rutina: EstableceFechaPagoRecibos. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task EstableceFechaPagoRecibosAGAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Assuming this method exists in the C# domain model for recibos
|
||||
bdAsegasa.db.recibos.ContabilizaRecibosPagoAG();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TsNotificacionesClient.RegistrarAsync("En EstableceFechaPagoRecibosAG.", $"Rutina: EstableceFechaPagoRecibosAG. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task EstableceFechaBajaRecibosAsync(int DiasLimiteCartaImperativo = -10)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var bd = tscgestionasegasa.NuevoContexto();
|
||||
var TipoCarta = (int)TipoGestionEnum.AVISO_IMPERATIVO_LEGAL;
|
||||
var idtipS = bd.enumeraciones.Where(x => x.Codigo == "TIPP.CO" || x.Codigo == "TIPP.CTR" || x.Codigo == "TIPP.CTA" || x.Codigo == "TIPP.CIN" || x.Codigo == "TIPP.PE").Select(x => x.idEnumeracion).ToList();
|
||||
var idFP = bd.enumeraciones.First(x => x.Codigo == "CABA.FP").idEnumeracion;
|
||||
var confEmail = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCONTA").ValorAlfabeticoLargo;
|
||||
var sDestinatarios = $"{confEmail};lolaherrera@asegasa.es";
|
||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
|
||||
var FechaLimite = DateTime.Now.Date.AddDays(-DiasLimiteCartaImperativo);
|
||||
|
||||
var recs = bd.recibos.Where(x => x.FechaPago == null && x.FechaBaja == null && x.gestionesrecibos.Any(y => y.Tipo == TipoCarta && y.Fecha <= FechaLimite)).ToList()
|
||||
.Where(x => x.LimiteEfectoSobrePasadoFechaBaja && idtipS.Contains(x.idTipoPago.Value)).ToList();
|
||||
|
||||
enumeraciones? cont = null;
|
||||
int Numrec = 0;
|
||||
var hoy = DateOnly.FromDateTime(DateTime.Today);
|
||||
|
||||
if (recs.Count > 0)
|
||||
{
|
||||
cont = bd.enumeraciones.First(x => x.Codigo == "CONT.NUMGEN");
|
||||
cont.ValorNumerico1 += 1;
|
||||
bd.SaveChanges();
|
||||
|
||||
foreach (var r in recs)
|
||||
{
|
||||
Numrec += 1;
|
||||
r.FechaBaja = hoy;
|
||||
r.idCausaBaja = idFP;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
}
|
||||
|
||||
var FechaLimiteDev = DateOnly.FromDateTime( DateTime.Now.Date.AddDays(-25));
|
||||
var recsdb = bd.recibos.Where(x => x.FechaPago == null && x.FechaBaja == null && x.FechaDevolucionBanco != null).ToList()
|
||||
.Where(x => x.FechaDevolucionBanco.Value <= FechaLimiteDev && !idtipS.Contains(x.idTipoPago.Value)).ToList();
|
||||
|
||||
|
||||
if (recsdb.Count > 0)
|
||||
{
|
||||
if (cont == null)
|
||||
{
|
||||
cont = bd.enumeraciones.First(x => x.Codigo == "CONT.NUMGEN");
|
||||
cont.ValorNumerico1 += 1;
|
||||
bd.SaveChanges();
|
||||
}
|
||||
foreach (var r in recsdb)
|
||||
{
|
||||
Numrec += 1;
|
||||
r.FechaBaja = hoy;
|
||||
r.idCausaBaja = idFP;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
}
|
||||
|
||||
if (cont != null)
|
||||
{
|
||||
await bd.Database.ExecuteSqlRawAsync($"UPDATE registrosactualizados SET FechaCreacion=Now() where FechaCreacion Is null and NumeroGeneracion={cont.ValorNumerico1};");
|
||||
var lr = recs.Union(recsdb).Select(x => new
|
||||
{
|
||||
x.CodigoRecibo,
|
||||
NumeroPoliza = x.idPolizaNavigation.NumeroPoliza,
|
||||
NumeroSuplemento = x.idPolizaNavigation.NumeroSuplemento,
|
||||
Tomador = x.idPolizaNavigation.Tomador?.RazonSocial,
|
||||
BinesAsegurados = x.idPolizaNavigation.BienesAsegurados,
|
||||
Ramo = x.idPolizaNavigation.idRamoNavigation.Descripcion,
|
||||
Compañía = x.idPolizaNavigation.idCompaniaNavigation.Nombre,
|
||||
FormaPago = x.idTipoPagoNavigation?.Descripcion,
|
||||
Agente = x.idPolizaNavigation.idAgenteNavigation?.CodigoYNombre
|
||||
}).ToList();
|
||||
|
||||
var f = tsUtilidades.Excel.IEnumerableAExcel(lr);
|
||||
bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd, $"Se han marcado {Numrec} Recibos de BAJA por Falta de PAGO", "Adjunto le remitimos listado de recibos puestos de baja por Falta de Pago", cta, f, $"Bajas-{DateTime.Now:yyyy-MM-dd}.xlsx", $"Listado Recibos de Baja Fecha {DateTime.Now:yyyy-MM-dd}", sDestinatarios);
|
||||
}
|
||||
else
|
||||
{
|
||||
bdAsegasa.db.correos.GeneraRegistroCorreo(bd, "No se han marcado ningún recibo de Baja por Falta de Pago", "Le informamos que no se han marcado ningún recibo de Baja por Falta de Pago", cta, sDestinatarios);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TsNotificacionesClient.RegistrarAsync("En EstableceFechaBajaRecibos.", $"Rutina: EstableceFechaBajaRecibos. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task GeneraApuntesContadoAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var bd = tscgestionasegasa.NuevoContexto();
|
||||
var idTippContado = bd.enumeraciones.Where(x => x.Codigo == "TIPP.PE" || (x.idGrupoEnumeracionNavigation.Grupo == "TIPP" && x.ValorNumerico1 == 1)).Select(x => x.idEnumeracion).ToList();
|
||||
var idTippPE = bd.enumeraciones.First(x => x.Codigo == "TIPP.PE").idEnumeracion;
|
||||
var idCbPGO = bd.enumeraciones.First(x => x.Codigo == "CABA.PGO").idEnumeracion;
|
||||
var sDestinatarios = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCONTA").ValorAlfabeticoLargo;
|
||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
|
||||
var recs = bd.vf_recibosextendidos.Where(x => x.idRemesa == null && x.FechaPago != null && idTippContado.Contains(x.idTipoPago.Value) && (x.idCausaBaja == null || x.idCausaBaja.Value != idCbPGO)).ToList();
|
||||
|
||||
if (recs.Count > 0)
|
||||
{
|
||||
var recsnv = recs.Where(x => x.idTipoPago == idTippPE && x.CuentaContableTomadorErronea).ToList();
|
||||
if (recsnv.Any())
|
||||
{
|
||||
var lre = recsnv.Select(x => new
|
||||
{
|
||||
x.CodigoRecibo,
|
||||
x.NumeroPoliza,
|
||||
x.NumeroSuplemento,
|
||||
x.Tomador,
|
||||
BinesAsegurados = x.BienesAsegurados,
|
||||
x.Ramo,
|
||||
x.Compania
|
||||
}).ToList();
|
||||
|
||||
var fe = tsUtilidades.Excel.IEnumerableAExcel(lre);
|
||||
bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd, "Recibos de cobro personal con cuenta contable errónea", "Adjunto le remitimos listado de recibos de cobro personal con cuenta contable errónea.", cta, fe, $"RecibosContadoErroneo-{DateTime.Now:yyyy-MM-dd}.xlsx", $"Listado Recibos de cobro personal erróneos {DateTime.Now:yyyy-MM-dd}", sDestinatarios);
|
||||
}
|
||||
|
||||
recs = recs.Where(x => !x.CuentaContableTomadorErronea).ToList();
|
||||
if (recs.Count > 0)
|
||||
{
|
||||
bdAsegasa.db.asientos.GeneraAsientoRecibosContado(bd, recs, DelegadoErrorNoControlado);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TsNotificacionesClient.RegistrarAsync("En GeneraApuntesContado.", $"Rutina: GeneraApuntesContado. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
private static void DelegadoErrorNoControlado(string Aplicacion, Exception ex)
|
||||
{
|
||||
_ = TsNotificacionesClient.RegistrarAsync($"En {Aplicacion}", $"Rutina: {Aplicacion} {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
|
||||
public static async Task CompruebaRecibosNoRemesadosAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var bd = tscgestionasegasa.NuevoContexto();
|
||||
var FechaLimite = DateOnly.FromDateTime(DateTime.Today.AddDays(-10));
|
||||
var hoy = DateOnly.FromDateTime(DateTime.Today);
|
||||
|
||||
var idBanco = bd.enumeraciones.First(x => x.Codigo == "TIPP.BA").idEnumeracion;
|
||||
|
||||
var recs = bd.recibos.Where(x => x.FechaBaja == null && x.idRemesa == null && x.idTipoPago == idBanco && x.FechaEfecto < FechaLimite && x.FechaVencimiento > hoy && x.PrimaNeta > 0).ToList();
|
||||
|
||||
if (recs.Count > 0)
|
||||
{
|
||||
var sDestinatarios = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCONTA").ValorAlfabeticoLargo;
|
||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
|
||||
var lr = recs.Select(x => x.AListadoGestionCobro()).ToList();
|
||||
var f = tsUtilidades.Excel.IEnumerableAExcel(lr);
|
||||
bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd, $"Existen recibos no remesados con fecha anterior a {FechaLimite:d}", $"Le informamos que existen recibos no remesados con fecha anterior a {FechaLimite:d}", cta, f, $"RecibosNoReMesados-{DateTime.Now:yyyy-MM-dd}.xlsx", $"Listado Recibos de con fecha de pago {DateTime.Now:yyyy-MM-dd}", sDestinatarios);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TsNotificacionesClient.RegistrarAsync("En CompruebaRecibosNoRemesados.", $"Rutina: CompruebaRecibosNoRemesados. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task CompruebaCarteraPerdidaAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var bd = tscgestionasegasa.NuevoContexto();
|
||||
var ultl = bd.enumeraciones.First(x => x.Codigo == "CONF.ULTLCP");
|
||||
var FechaInicio = ultl.Fecha1.Value.AddDays(1);
|
||||
var FechaFin = DateTime.Today;
|
||||
var sDestinatarios = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCARPER").ValorAlfabeticoLargo;
|
||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
|
||||
var b = bdAsegasa.Informes.CarteraPerdida.GeneraExcelCarteraPerdida(FechaInicio);
|
||||
|
||||
if (b == null)
|
||||
{
|
||||
bdAsegasa.db.correos.GeneraRegistroCorreo(bd, $"Listado de Cartera Perdida {FechaInicio:dd/MM/yyyy}", $"No existen recibos de Cartera Perdida desde el {FechaInicio:dd/MM/yyyy}", cta, sDestinatarios);
|
||||
}
|
||||
else
|
||||
{
|
||||
bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd, $"Listado de Cartera Perdida {FechaInicio:dd/MM/yyyy}", $"Adjunto le remitimos Listado de Cartera Perdida de las fechas comprendidas entre {FechaInicio:dd/MM/yyyy} y el {FechaFin:dd/MM/yyyy}", cta, b, $"CarteraPerdida_{FechaInicio:yyyy-MM-dd}_{FechaFin:yyyy-MM-dd}.xlsx", $"Cartera Perdida desde el {FechaInicio:yyyy-MM-dd}", sDestinatarios);
|
||||
}
|
||||
|
||||
ultl.Fecha1 = DateTime.Today;
|
||||
bd.SaveChanges();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TsNotificacionesClient.RegistrarAsync("En CompruebaCarteraPerdida.", $"Rutina: CompruebaCarteraPerdida. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task GeneraComunicacionesRecibosAsync()
|
||||
{
|
||||
// Case 1: Remittance warning
|
||||
try
|
||||
{
|
||||
using var bd = tscgestionasegasa.NuevoContexto();
|
||||
var lr = bdAsegasa.db.recibos.ObtieneRecibosCartaRemesa();
|
||||
bdAsegasa.db.recibos.GeneraAvisoRemesa(lr, bd);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TsNotificacionesClient.RegistrarAsync("En GeneraComunicacionesRecibo.", $"Rutina: GeneraComunicacionesRecibo (Remesa). {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
|
||||
// Case 2: Legal notice
|
||||
try
|
||||
{
|
||||
using var bd = tscgestionasegasa.NuevoContexto();
|
||||
var lr = bdAsegasa.db.recibos.ObtieneRecibosAvisoImperativoLegal(bd);
|
||||
var sAsunto = "Falta de pago de su recibo %RECIBO% correspondiente a su poliza %POLIZAYRAMO%";
|
||||
var sCuerpo = "En el presente correo le adjuntamos enlace al documento con el detalle del recibo %RECIBO% pendiente de pago correspondiente a su poliza %POLIZA%";
|
||||
bdAsegasa.db.recibos.GeneraAviso(lr, bdAsegasa.db.recibos.TipoGeneracionEnum.AVISO_IMPERATIVO_LEGAL, sAsunto, sCuerpo, bd);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TsNotificacionesClient.RegistrarAsync("En GeneraComunicacionesRecibo.", $"Rutina: GeneraComunicacionesRecibo (Legal). {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
|
||||
// Case 3: Cancellation notice
|
||||
try
|
||||
{
|
||||
using var bd = tscgestionasegasa.NuevoContexto();
|
||||
var lr = bdAsegasa.db.recibos.ObtieneRecibosCartaBaja(bd);
|
||||
var sAsunto = "Aviso de baja de su poliza %POLIZAYRAMO%";
|
||||
var sCuerpo = "Con el presente correo le adjuntamos enlace al documento con el detalle de la baja de su póliza %POLIZAYRAMO%";
|
||||
bdAsegasa.db.recibos.GeneraAviso(lr, bdAsegasa.db.recibos.TipoGeneracionEnum.AVISO_BAJA_POLIZA, sAsunto, sCuerpo, bd);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TsNotificacionesClient.RegistrarAsync("En GeneraComunicacionesRecibo.", $"Rutina: GeneraComunicacionesRecibo (Baja). {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
|
||||
// Case 4: Bank return notice
|
||||
try
|
||||
{
|
||||
using var bd = tscgestionasegasa.NuevoContexto();
|
||||
var lr = bdAsegasa.db.recibos.ObtieneRecibosComunicacionDevueltoBanco(bd);
|
||||
var sAsunto = "Aviso de devolución del recibo %RECIBO% correspondiente a su poliza %POLIZAYRAMO%";
|
||||
var sCuerpo = "En el presente correo le adjuntamos enlace al documento con el detalle de la de devolución del recibo %RECIBO% correspondiente a su poliza %POLIZA%";
|
||||
bdAsegasa.db.recibos.GeneraAviso(lr,bdAsegasa.db.recibos.TipoGeneracionEnum.COMUNICACION_DEVUELTO_BANCO, sAsunto, sCuerpo, bd);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TsNotificacionesClient.RegistrarAsync("En GeneraComunicacionesRecibo.", $"Rutina: GeneraComunicacionesRecibo (Devuelto). {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task GeneraRecibosPolizasColectivasAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var bd = tscgestionasegasa.NuevoContexto();
|
||||
var enums = bd.enumeraciones.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "CP").ToList();
|
||||
foreach (var pc in enums)
|
||||
{
|
||||
var idCia = bd.companias.First(x => x.Codigo == pc.ValorAlfabetico2).idCompania;
|
||||
var PrimaNeta = pc.ValorNumerico1 ?? 0;
|
||||
var PorcentajeImpuestos = pc.ValorNumerico2 ?? 0;
|
||||
var Impuestos = Math.Round(PrimaNeta * PorcentajeImpuestos / 100, 2);
|
||||
var Flim = DateTime.Today.AddDays(40);
|
||||
|
||||
var pols = bd.polizassg.Where(x => x.FechaAceptacionPresupuesto != null && x.NumeroPoliza.StartsWith(pc.ValorAlfabetico1 + "-") && x.idCompania == idCia && x.FechaBaja == null && !x.recibos.Any(y => y.FechaVencimiento >= DateOnly.FromDateTime( Flim))).ToList();
|
||||
|
||||
foreach (var p in pols)
|
||||
{
|
||||
p.GeneraReciboPolizaColectivo(bd, PrimaNeta, Impuestos, 0);
|
||||
}
|
||||
}
|
||||
bd.SaveChanges();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TsNotificacionesClient.RegistrarAsync("En GeneraRecibosPolizasColectivas.", $"Rutina: GeneraRecibosPolizasColectivas. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task GeneraEmailPolizasColectivas0057Async()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var bd = tscgestionasegasa.NuevoContexto();
|
||||
var idCia = bd.companias.First(x => x.Codigo == "0057").idCompania;
|
||||
var idRamo = bd.ramos.First(x => x.Codigo == "2-8-1").idRamo;
|
||||
|
||||
var recs = bd.recibos.Where(x => x.FechaBaja == null && x.idPolizaNavigation.idCompania == idCia && x.idPolizaNavigation.idRamo == idRamo && !x.gestionesrecibos.Any(y => y.Tipo == (int)TipoGestionEnum.COMUNICACIÓN_EMISION_RECIBO_A_LA_COMPAÑÍA)).ToList();
|
||||
|
||||
if (recs.Count > 0)
|
||||
{
|
||||
var Polcol = bd.enumeraciones.First(x => x.Codigo == "CP.TRACTORESEUROP");
|
||||
var laltas = new List<DatoReciboColectivo0057>();
|
||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
|
||||
foreach (var r in recs)
|
||||
{
|
||||
var dp = (TractoresEuropAssistance)tsUtilidades.Utilidades.Deserializa(r.idPolizaNavigation.idFicheroPresupuestoNavigation.Fichero, typeof(TractoresEuropAssistance));
|
||||
var nd = new DatoReciboColectivo0057
|
||||
{
|
||||
Contrato = Polcol.ValorAlfabetico1,
|
||||
Codigo_Producto = Polcol.ValorAlfabetico3,
|
||||
País = "ESPAÑA",
|
||||
Fecha_Inicio = new DateTime(r.FechaEfecto.Year, r.FechaEfecto.Month, r.FechaEfecto.Day) ,
|
||||
Fecha_Fin = new DateTime(r.FechaVencimiento.Year, r.FechaVencimiento.Month, r.FechaVencimiento.Day),
|
||||
Matrícula = dp.Matricula,
|
||||
Marca = dp.Marca,
|
||||
Modelo = dp.Modelo,
|
||||
Fecha_Matriculacion = dp.FechaMatriculacion,
|
||||
Referencia_Externa = $"{r.idPolizaNavigation.Tomador.CIF} {r.idPolizaNavigation.Tomador.RazonSocial}"
|
||||
};
|
||||
laltas.Add(nd);
|
||||
}
|
||||
|
||||
var b = tsUtilidades.Excel.IEnumerableAExcel(laltas);
|
||||
var idCorreo = bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd, $"Listado recibos de Asistencia en Viaje Tractores Día: {DateTime.Today:dd/MM/yyyy}", $"Adjunto le remitimos listado recibos de Asistencia en Viaje Tractores Día: {DateTime.Today:dd/MM/yyyy}", cta, b, $"Asistencia_Viaje_Tractores_{DateTime.Today:yyyy-MM-dd}.xlsx", $"Asistencia Viaje Tractores {DateTime.Today:yyyy-MM-dd}", Polcol.ValorAlfabetico4, "", Polcol.ValorAlfabeticoLargo, idAplicacion: idCia, CodigoAplicacion: "COMPAÑIAS");
|
||||
|
||||
foreach (var r in recs)
|
||||
{
|
||||
var tg = new gestionesrecibos
|
||||
{
|
||||
idRecibo = r.idRecibo,
|
||||
FormaComunicacion = (int)FormaComunicacionEnum.NINGUNA,
|
||||
Tipo = (int)TipoGestionEnum.COMUNICACIÓN_EMISION_RECIBO_A_LA_COMPAÑÍA,
|
||||
GestionesRealizadas = TipoGestionEnum.COMUNICACIÓN_EMISION_RECIBO_A_LA_COMPAÑÍA.ToString().Replace("_", " "),
|
||||
Fecha = DateTime.Now,
|
||||
idCorreo = idCorreo,
|
||||
Observaciones = ""
|
||||
};
|
||||
bd.gestionesrecibos.Add(tg);
|
||||
}
|
||||
bd.SaveChanges();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TsNotificacionesClient.RegistrarAsync("En GeneraEmailPolizasColectivas0057.", $"Rutina: GeneraEmailPolizasColectivas0057. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class DatoReciboColectivo0057
|
||||
{
|
||||
public string Contrato { get; set; }
|
||||
public string Codigo_Producto { get; set; }
|
||||
public DateTime Fecha_Inicio { get; set; }
|
||||
public DateTime Fecha_Fin { get; set; }
|
||||
public string País { get; set; }
|
||||
public string Matrícula { get; set; }
|
||||
public string Marca { get; set; }
|
||||
public string Modelo { get; set; }
|
||||
public DateTime Fecha_Matriculacion { get; set; }
|
||||
public string Referencia_Externa { get; set; }
|
||||
}
|
||||
}
|
||||
388
Servicio Gestion Asegasa/Procesos/ProcesosSiniestros.cs
Normal file
388
Servicio Gestion Asegasa/Procesos/ProcesosSiniestros.cs
Normal file
@@ -0,0 +1,388 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using bdAsegasa;
|
||||
using bdAsegasa.db;
|
||||
|
||||
namespace Servicio_Gestion_Asegasa.Procesos
|
||||
{
|
||||
public class ProcesosSiniestros
|
||||
{
|
||||
public static void IncorporaSiniestrosEIACV6()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var bd = gestionasegasaEntities.NuevoContexto();
|
||||
var ltpa = bd.enumeraciones.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "TIPP").ToList();
|
||||
int tipo = (int)ficheroscompanias.TipoFicheroCompania.SINIESTROS_EIAC;
|
||||
|
||||
var ficspen = bd.ficheroscompanias
|
||||
.Where(x => x.FechaProcesado == null &&
|
||||
x.FechaError == null &&
|
||||
x.Tipo == tipo &&
|
||||
x.Version == "6.0")
|
||||
.OrderBy(x => x.idFichero)
|
||||
.ToList();
|
||||
|
||||
foreach (var f in ficspen)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Asumimos ProcesosEIAC_V6 existe y Utilizamos una librería genérica de serialización
|
||||
dynamic DatosEIAC = tsUtilidades.Utilidades.Deserializa(f.Fichero, Type.GetType("ProcesosEIAC_V6.ProcesosEIAC") ?? typeof(object));
|
||||
|
||||
if (DatosEIAC?.Objetos?.Items != null)
|
||||
{
|
||||
IEnumerable<dynamic> items = DatosEIAC.Objetos.Items;
|
||||
var lSins = items.Where(x => x != null && x.GetType().Name == "tipo_siniestro");
|
||||
|
||||
foreach (var s in lSins)
|
||||
{
|
||||
List<siniestros> sins = null;
|
||||
string idSiniestroEntidad = s.DatosSiniestro.IdSiniestroEntidad;
|
||||
|
||||
var seiac = bd.siniestros_eiac.FirstOrDefault(x => x.idSiniestroEntidad == idSiniestroEntidad);
|
||||
if (seiac == null)
|
||||
{
|
||||
seiac = new siniestros_eiac
|
||||
{
|
||||
idSiniestroEntidad = idSiniestroEntidad,
|
||||
idFicheroCompania = f.idFichero,
|
||||
idCompania = f.idCompania
|
||||
};
|
||||
bd.siniestros_eiac.Add(seiac);
|
||||
}
|
||||
|
||||
seiac.NumeroPoliza = s.DatosPoliza.IdPoliza;
|
||||
var pol = bd.polizassg
|
||||
.Where(x => x.NumeroPoliza == seiac.NumeroPoliza && x.idCompania == seiac.idCompania)
|
||||
.OrderByDescending(x => x.NumeroSuplemento)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (pol != null)
|
||||
seiac.idPoliza = pol.idPoliza;
|
||||
|
||||
seiac.NumeroSuplemento = s.DatosPoliza.NumeroSuplemento;
|
||||
seiac.FechaDeclaracion = s.DatosSiniestro.FechaDeclaracion;
|
||||
seiac.FechaOcurrencia = s.DatosSiniestro.FechaOcurrencia;
|
||||
seiac.PosicionSiniestro = (int)bdAsegasa.db.siniestros_eiac.ObtienePosicionSiniestroV6((string)s.DatosSiniestro.PosicionSiniestro);
|
||||
seiac.DescripcionSiniestro = tsUtilidades.Extensiones.StringExtensions.Acortar((string)s.DatosSiniestro.DescripcionSiniestro, 2048);
|
||||
seiac.TipologiaSiniestro = s.DatosSiniestro.TipologiaSiniestro;
|
||||
seiac.ImporteIndemnizacion = s.DatosSiniestro.ImporteIndemnizacion;
|
||||
seiac.ImporteReserva = s.DatosSiniestro.ImporteReserva;
|
||||
|
||||
if (s.DatosSiniestro.LugarSiniestro != null)
|
||||
{
|
||||
if (seiac.idLugarSiniestroNavigation == null)
|
||||
{
|
||||
seiac.idLugarSiniestroNavigation = new direcciones();
|
||||
}
|
||||
seiac.idLugarSiniestroNavigation.Direccion = s.DatosSiniestro.LugarSiniestro.ClaseVia + " " + s.DatosSiniestro.LugarSiniestro.NombreVia + " " + s.DatosSiniestro.LugarSiniestro.OtrosDatosVia;
|
||||
seiac.idLugarSiniestroNavigation.CodigoPostal = s.DatosSiniestro.LugarSiniestro.CodigoPostal;
|
||||
|
||||
string codmun = bd.ObtieneCodigoMunicipioMasCoincidente(seiac.idLugarSiniestroNavigation.CodigoPostal, (string)s.DatosSiniestro.LugarSiniestro.Poblacion, true);
|
||||
if (string.IsNullOrEmpty(codmun))
|
||||
{
|
||||
seiac.idLugarSiniestroNavigation.Direccion += " " + s.DatosSiniestro.LugarSiniestro.Poblacion;
|
||||
}
|
||||
else
|
||||
{
|
||||
seiac.idLugarSiniestroNavigation.CodigoMunicipio = codmun;
|
||||
}
|
||||
seiac.idLugarSiniestroNavigation.Direccion = tsUtilidades.Extensiones.StringExtensions.Acortar(seiac.idLugarSiniestroNavigation.Direccion, 200);
|
||||
}
|
||||
|
||||
if (s.DatosSiniestro.SituacionesSiniestro != null)
|
||||
{
|
||||
var yaincorporados = new List<int>();
|
||||
foreach (var sit in s.DatosSiniestro.SituacionesSiniestro)
|
||||
{
|
||||
int numeroOrden = sit.NumeroOrden;
|
||||
if (numeroOrden == 0) numeroOrden = sit.GetHashCode();
|
||||
if (!yaincorporados.Contains(numeroOrden))
|
||||
{
|
||||
var est = seiac.estadossiniestros_eiac.FirstOrDefault(x => x.NumeroOrden == numeroOrden);
|
||||
if (est == null)
|
||||
{
|
||||
est = new estadossiniestros_eiac { NumeroOrden = numeroOrden };
|
||||
seiac.estadossiniestros_eiac.Add(est);
|
||||
}
|
||||
est.SituacionSiniestro = bdAsegasa.estadossiniestros_eiac.ObtieneSituacionSiniestroV6((string)sit.SituacionSiniestro);
|
||||
est.DescripcionSituacion = tsUtilidades.Extensiones.StringExtensions.Acortar((string)sit.DescripcionSituacion, 45);
|
||||
yaincorporados.Add(numeroOrden);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (s.DatosSiniestro.PagosSiniestro != null)
|
||||
{
|
||||
var yaincorporados = new List<int>();
|
||||
foreach (var pag in s.DatosSiniestro.PagosSiniestro)
|
||||
{
|
||||
int numeroOrden = pag.NumeroOrden;
|
||||
if (numeroOrden == 0) numeroOrden = pag.GetHashCode();
|
||||
if (!yaincorporados.Contains(numeroOrden))
|
||||
{
|
||||
var ps = seiac.pagossiniestros_eiac.FirstOrDefault(x => x.NumeroOrden == numeroOrden);
|
||||
if (ps == null)
|
||||
{
|
||||
ps = new pagossiniestros_eiac { NumeroOrden = numeroOrden };
|
||||
seiac.pagossiniestros_eiac.Add(ps);
|
||||
}
|
||||
ps.FechaPago = pag.FechaPago;
|
||||
ps.FechaLiquidacion = pag.FechaLiquidacion;
|
||||
ps.ImportePago = pag.ImportePago;
|
||||
ps.DescripcionPago = tsUtilidades.Extensiones.StringExtensions.Acortar((string)pag.DescripcionPago, 255);
|
||||
ps.idTipoPago = bdAsegasa.siniestros_eiac.ObtenerTipoPagoV6((string)pag.FormaPago, ltpa);
|
||||
|
||||
if (pag.FormaPago != null && pag.FormaPago.DatosCuentaCorriente != null)
|
||||
{
|
||||
ps.IBAN = pag.FormaPago.DatosCuentaCorriente.IBAN;
|
||||
}
|
||||
yaincorporados.Add(numeroOrden);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (s.DatosSiniestro.AccionesSiniestro != null)
|
||||
{
|
||||
var yaincorporados = new List<int>();
|
||||
foreach (var accs in s.DatosSiniestro.AccionesSiniestro)
|
||||
{
|
||||
int numeroOrden = accs.NumeroOrden;
|
||||
if (numeroOrden == 0) numeroOrden = accs.GetHashCode();
|
||||
if (!yaincorporados.Contains(numeroOrden))
|
||||
{
|
||||
var acs = seiac.accionessiniestros_eiac.FirstOrDefault(x => x.NumeroOrden == numeroOrden);
|
||||
if (acs == null)
|
||||
{
|
||||
acs = new accionessiniestros_eiac { NumeroOrden = numeroOrden };
|
||||
seiac.accionessiniestros_eiac.Add(acs);
|
||||
}
|
||||
acs.AccionSiniestro = bdAsegasa.accionessiniestros_eiac.ObtieneAccionSiniestroV6((string)accs.AccionSiniestro);
|
||||
acs.FechaAccion = accs.FechaAccion;
|
||||
acs.DescripcionAccion = accs.DescripcionAccion;
|
||||
acs.SituacionAccion = bdAsegasa.accionessiniestros_eiac.ObtieneSituacionAccionV6((string)accs.SituacionAccion);
|
||||
yaincorporados.Add(numeroOrden);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (s.DatosSiniestro.Expedientes != null)
|
||||
{
|
||||
var yaincorporados = new List<string>();
|
||||
foreach (var exp in s.DatosSiniestro.Expedientes)
|
||||
{
|
||||
string numeroExpediente = exp.NumeroExpediente;
|
||||
if (string.IsNullOrEmpty(numeroExpediente)) numeroExpediente = exp.GetHashCode().ToString();
|
||||
|
||||
if (!yaincorporados.Contains(numeroExpediente))
|
||||
{
|
||||
var ep = seiac.expedientessiniestros_eiac.FirstOrDefault(x => x.NumeroExpediente == numeroExpediente);
|
||||
if (ep == null)
|
||||
{
|
||||
ep = new expedientessiniestros_eiac { NumeroExpediente = numeroExpediente };
|
||||
seiac.expedientessiniestros_eiac.Add(ep);
|
||||
}
|
||||
ep.EstadoExpediente = bdAsegasa.expedientessiniestros_eiac.ObtieneEstadoExpedienteV6((string)exp.EstadoExpediente);
|
||||
ep.ImporteReserva = exp.ImporteReserva;
|
||||
ep.TotalPagos = exp.TotalPagos;
|
||||
ep.TotalRecobros = exp.TotalRecobros;
|
||||
ep.FechaInicio = exp.FechaInicio;
|
||||
ep.FechaFin = exp.FechaFin;
|
||||
ep.NumeroOrden = exp.NumeroOrden;
|
||||
yaincorporados.Add(numeroExpediente);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (seiac.idSiniestroNavigation == null)
|
||||
{
|
||||
var fi = seiac.FechaOcurrencia.AddDays(-5);
|
||||
var ff = seiac.FechaOcurrencia.AddDays(5);
|
||||
|
||||
|
||||
var fechaInicio = DateOnly.FromDateTime(fi);
|
||||
var fechaFinal = DateOnly.FromDateTime(ff);
|
||||
|
||||
sins = bd.siniestros.Where(x =>
|
||||
x.idPolizaNavigation.NumeroPoliza == seiac.NumeroPoliza &&
|
||||
x.FechaAccidente.HasValue &&
|
||||
x.FechaAccidente >= fechaInicio &&
|
||||
x.FechaAccidente <= fechaFinal).ToList();
|
||||
|
||||
if (sins.Count == 1)
|
||||
{
|
||||
seiac.idSiniestroNavigation = sins[0];
|
||||
}
|
||||
}
|
||||
|
||||
bool bModificados = false;
|
||||
if (bd.ChangeTracker.Entries().Any(e => e.State == EntityState.Added))
|
||||
{
|
||||
bModificados = true;
|
||||
seiac.SituacionAsegasa = (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.NUEVO;
|
||||
seiac.FechaSituacion = DateTime.Now;
|
||||
}
|
||||
else
|
||||
{
|
||||
var prmods = bd.ChangeTracker.Entries().Where(e => e.State == EntityState.Modified).ToList();
|
||||
if (prmods.Count > 0)
|
||||
{
|
||||
foreach (var pr in prmods)
|
||||
{
|
||||
var original = pr.OriginalValues;
|
||||
var nuevosvalores = pr.CurrentValues;
|
||||
foreach (var prop in original.Properties)
|
||||
{
|
||||
var origVal = original[prop];
|
||||
var newVal = nuevosvalores[prop];
|
||||
|
||||
if (origVal?.GetHashCode() != newVal?.GetHashCode())
|
||||
{
|
||||
bModificados = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bModificados) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bModificados)
|
||||
{
|
||||
if (!seiac.SituacionAsegasa.HasValue || seiac.SituacionAsegasa.Value != (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.DESCARTADO)
|
||||
{
|
||||
seiac.SituacionAsegasa = (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.MODIFICADO;
|
||||
seiac.FechaSituacion = DateTime.Now;
|
||||
}
|
||||
|
||||
var nact = new actualizacionessiniestros_eiac
|
||||
{
|
||||
idSiniestroEIACNavigation = seiac,
|
||||
Fecha = DateTime.Now,
|
||||
idFicheroCompania = f.idFichero
|
||||
};
|
||||
bd.actualizacionessiniestros_eiac.Add(nact);
|
||||
|
||||
if (seiac.SituacionAsegasa.Value != (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.DESCARTADO)
|
||||
{
|
||||
if (!seiac.idPoliza.HasValue)
|
||||
{
|
||||
seiac.SituacionAsegasa = (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.POLIZA_NO_ENCONTRADA;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sins == null || sins.Count == 0)
|
||||
{
|
||||
seiac.SituacionAsegasa = (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.SINIESTRO_NO_ENCONTRADO;
|
||||
}
|
||||
else if (sins.Count > 1)
|
||||
{
|
||||
seiac.SituacionAsegasa = (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.VARIOS_SINIESTROS_POSIBLES;
|
||||
}
|
||||
}
|
||||
}
|
||||
bd.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
f.FechaProcesado = DateTime.Now;
|
||||
bd.SaveChanges();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
f.FechaError = DateTime.Now;
|
||||
bd.SaveChanges();
|
||||
tsUtilidades.TsNotificacionesClient.RegistrarAsync("En IncorporaSiniestrosEIACV6.", $"Rutina: IncorporaSiniestrosEIACV6. Fichero:{f.NombreFichero} {ex.Message}", tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
tsUtilidades.TsNotificacionesClient.RegistrarAsync("En IncorporaSiniestrosEIACV6.", $"Rutina: IncorporaSiniestrosEIACV6. {ex.Message}", tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
public static void IncorporaExpSiniestrosEIACV6()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var bd = tscgestionasegasa.NuevoContexto();
|
||||
var ltpa = bd.enumeraciones.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "TIPP").ToList();
|
||||
int tipo = (int)ficheroscompanias.TipoFicheroCompania.SINIESTROS_EIAC;
|
||||
var ficspen = bd.ficheroscompanias
|
||||
.Where(x => x.Tipo == tipo && x.Version == "6.0")
|
||||
.OrderBy(x => x.idFichero)
|
||||
.ToList();
|
||||
|
||||
foreach (var f in ficspen)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Asumimos ProcesosEIAC_V6 existe y Utilizamos una librería genérica de serialización
|
||||
dynamic DatosEIAC = tsUtilidades.Utilidades.Deserializa(f.Fichero, Type.GetType("ProcesosEIAC_V6.ProcesosEIAC") ?? typeof(object));
|
||||
|
||||
if (DatosEIAC?.Objetos?.Items != null)
|
||||
{
|
||||
IEnumerable<dynamic> items = DatosEIAC.Objetos.Items;
|
||||
var lSins = items.Where(x => x != null && x.GetType().Name == "tipo_siniestro");
|
||||
|
||||
foreach (var s in lSins)
|
||||
{
|
||||
string idSiniestroEntidad = s.DatosSiniestro.IdSiniestroEntidad;
|
||||
var seiac = bd.siniestros_eiac.FirstOrDefault(x => x.idSiniestroEntidad == idSiniestroEntidad);
|
||||
|
||||
if (seiac != null)
|
||||
{
|
||||
if (s.DatosSiniestro.Expedientes != null)
|
||||
{
|
||||
var yaincorporados = new List<string>();
|
||||
foreach (var exp in s.DatosSiniestro.Expedientes)
|
||||
{
|
||||
string numeroExpediente = exp.NumeroExpediente;
|
||||
if (string.IsNullOrEmpty(numeroExpediente)) numeroExpediente = exp.GetHashCode().ToString();
|
||||
|
||||
if (!yaincorporados.Contains(numeroExpediente))
|
||||
{
|
||||
var ep = seiac.expedientessiniestros_eiac.FirstOrDefault(x => x.NumeroExpediente == numeroExpediente);
|
||||
if (ep == null)
|
||||
{
|
||||
ep = new expedientessiniestros_eiac { NumeroExpediente = numeroExpediente };
|
||||
seiac.expedientessiniestros_eiac.Add(ep);
|
||||
}
|
||||
ep.EstadoExpediente = bdAsegasa.expedientessiniestros_eiac.ObtieneEstadoExpedienteV6((string)exp.EstadoExpediente);
|
||||
ep.ImporteReserva = exp.ImporteReserva;
|
||||
ep.TotalPagos = exp.TotalPagos;
|
||||
ep.TotalRecobros = exp.TotalRecobros;
|
||||
ep.FechaInicio = exp.FechaInicio;
|
||||
ep.FechaFin = exp.FechaFin;
|
||||
ep.NumeroOrden = exp.NumeroOrden;
|
||||
|
||||
yaincorporados.Add(numeroExpediente);
|
||||
}
|
||||
}
|
||||
bd.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// f.FechaProcesado = Now (Comentado en el código original)
|
||||
bd.SaveChanges();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
f.FechaError = DateTime.Now;
|
||||
bd.SaveChanges();
|
||||
tsUtilidades.TsNotificacionesClient.RegistrarAsync("En IncorporaSiniestrosEIACV6.", $"Rutina: IncorporaSiniestrosEIACV6. Fichero:{f.NombreFichero} {ex.Message}", tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
tsUtilidades.TsNotificacionesClient.RegistrarAsync("En IncorporaSiniestrosEIACV6.", $"Rutina: IncorporaSiniestrosEIACV6. {ex.Message}", tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
619
Servicio Gestion Asegasa/Procesos/ProcesosTractoresAxa.cs
Normal file
619
Servicio Gestion Asegasa/Procesos/ProcesosTractoresAxa.cs
Normal file
@@ -0,0 +1,619 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using bdAsegasa;
|
||||
using bdAsegasa.db;
|
||||
|
||||
namespace Servicio_Gestion_Asegasa.Procesos
|
||||
{
|
||||
public class ProcesosTractoresAxa
|
||||
{
|
||||
public static int GenerarYGuardarEnBdCsvTractoresAxa(tscgestionasegasa bd)
|
||||
{
|
||||
int resultadoGuardarCambios = 0;
|
||||
try
|
||||
{
|
||||
var listaAltas = new List<polizassg>();
|
||||
var listaAltasFiltradasPorFecha = new List<polizassg>();
|
||||
int idRamoTractores = bd.ramos.First(x => x.Codigo == "1-1").idRamo;
|
||||
int idRamoRemolques = bd.ramos.First(x => x.Codigo == "1-1-1").idRamo;
|
||||
int idCiaAXA = bd.companias.First(x => x.Codigo == "0027").idCompania;
|
||||
int idTipoGestionPoliza = bd.enumeraciones.First(x => x.Codigo == "TGP.CSVAXA").idEnumeracion;
|
||||
int idTipoFicheroCSV = bd.enumeraciones.First(x => x.Codigo == "TIPFIC.CSVAXA").idEnumeracion;
|
||||
|
||||
ficheros lineaFichero;
|
||||
gestionesvarias lineaGestionesVarias;
|
||||
|
||||
DateTime dHoy = DateTime.Today;
|
||||
DateTime dAyer = DateTime.Today.AddDays(-1);
|
||||
|
||||
try
|
||||
{
|
||||
listaAltas = bd.polizassg.Where(x =>
|
||||
(x.idRamoNavigation.idRamo == idRamoTractores || x.idRamoNavigation.idRamo == idRamoRemolques) &&
|
||||
x.idCompania == idCiaAXA &&
|
||||
x.FechaAceptacionPresupuesto.HasValue &&
|
||||
!x.FechaBaja.HasValue &&
|
||||
!x.gestionespolizassg.Any(y => y.idTipo == idTipoGestionPoliza) &&
|
||||
x.idOrigenPresupuesto == (int)bdAsegasa.db.polizassg.TiposPresupuestos.TRACTORES
|
||||
).ToList();
|
||||
|
||||
listaAltasFiltradasPorFecha = listaAltas.Where(x => x.FechaAlta.HasValue && x.FechaAlta.Value.Date < dHoy).ToList();
|
||||
|
||||
Debug.WriteLine("listaAltas: {0}", listaAltas.Count);
|
||||
Debug.WriteLine("listaAltasFiltradasPorFecha: {0}", listaAltasFiltradasPorFecha.Count);
|
||||
foreach (var item in listaAltasFiltradasPorFecha)
|
||||
{
|
||||
Debug.WriteLine($"({item.idPoliza},{item.NumeroPoliza},{item.Matricula})");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.Write(ex.ToString());
|
||||
tsUtilidades.TsNotificacionesClient.RegistrarAsync($"En {System.Reflection.MethodBase.GetCurrentMethod()}",
|
||||
$"En método {System.Reflection.MethodBase.GetCurrentMethod()}. {Environment.MachineName} {ex.ToString()}",tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
|
||||
if (listaAltasFiltradasPorFecha.Count > 0)
|
||||
{
|
||||
lineaFichero = new ficheros
|
||||
{
|
||||
Descripcion = $"{bd.enumeraciones.First(x => x.Codigo == "AXATRACTORES.DescripcionFicheroCSV").ValorAlfabeticoLargo} {dAyer:yyyy-MM-dd}",
|
||||
Fecha = DateTime.Now,
|
||||
idTipo = idTipoFicheroCSV,
|
||||
NombreFichero = $"{bd.enumeraciones.First(x => x.Codigo == "AXATRACTORES.NombreFicheroCSV").ValorAlfabeticoLargo}{dAyer:yyyy-MM-dd}.csv"
|
||||
};
|
||||
|
||||
bd.ficheros.Add(lineaFichero);
|
||||
|
||||
lineaGestionesVarias = new gestionesvarias
|
||||
{
|
||||
Descripción = lineaFichero.NombreFichero,
|
||||
idTipo = idTipoGestionPoliza,
|
||||
idFicheroNavigation = lineaFichero,
|
||||
FechaCreacion = DateTime.Now
|
||||
};
|
||||
|
||||
bd.gestionesvarias.Add(lineaGestionesVarias);
|
||||
|
||||
byte[] archivoCSV = GenerarCsvTractoresAxa(bd, listaAltasFiltradasPorFecha, lineaGestionesVarias);
|
||||
|
||||
lineaFichero.Fichero = archivoCSV;
|
||||
resultadoGuardarCambios = bd.SaveChanges();
|
||||
|
||||
if (resultadoGuardarCambios > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
var mensaje = new StringBuilder();
|
||||
mensaje.AppendFormat("Se ha generado un archivo CSV con altas de tractores y/o remolques para AXA.```idFichero: {1}{0}NombreFichero: {2}{0}idGestion: {3}{0}Servidor: {4}```",
|
||||
Environment.NewLine, lineaFichero.idFichero, lineaFichero.NombreFichero, lineaGestionesVarias.idGestion, Environment.MachineName);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("No hay líneas o se produjo excepción.");
|
||||
Debug.WriteLine(ex.ToString());
|
||||
tsUtilidades.TsNotificacionesClient.RegistrarAsync( $"En {System.Reflection.MethodBase.GetCurrentMethod()}",
|
||||
$"En método {System.Reflection.MethodBase.GetCurrentMethod()}. {Environment.MachineName} {ex.ToString()}",tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
return resultadoGuardarCambios;
|
||||
}
|
||||
|
||||
public static byte[] GenerarCsvTractoresAxa(tscgestionasegasa bd, List<polizassg> listaPolizas, gestionesvarias lineaGestionesVarias = null)
|
||||
{
|
||||
byte[] archivoCSV = null;
|
||||
int idTipoGestionPoliza = bd.enumeraciones.First(x => x.Codigo == "TGP.CSVAXA").idEnumeracion;
|
||||
string sDescripcionGestion = bd.enumeraciones.First(x => x.Codigo == "AXATRACTORES.DescripcionGestion").ValorAlfabeticoLargo;
|
||||
string nombreArchivoTemporal = Path.GetTempFileName();
|
||||
|
||||
// Usar ANSI/ISO encoding
|
||||
Encoding iso = Encoding.GetEncoding("iso-8859-1");
|
||||
|
||||
using (var sw = new StreamWriter(File.Open(nombreArchivoTemporal, FileMode.Create), iso))
|
||||
{
|
||||
sw.WriteLine("Código Marca;Código Modelo;Código Versión;Medofi;Fecha de Efecto;Hora de Fecha Efecto;CAMPAÑA;Producto;Nº Póliza Reservado;Fecha entrada en Delegación;Duración;Plan de cobro;Canal de cobro;Fecha Vto.;NIF, CIF, OTROS;Nº de NIF ó CIF;Primer apellido si es Empresa, no cumplimentar;Segundo apellido si es Empresa, no cumplimentar;Nombre;Fecha Nacimiento;Estado Civil;SEXO;C.P.;Población;Tipo Vía;Nombre Vía;Numero vía;Resto Vía;Propietario;Nombre propietario;Apellido 1 propietario;Apellido 2 propietario;Nif/Cif propietario;Conductor Titular;Nombre Conductor;1º Apellido Conductor;2º Apellido Conductor;Fecha nacimiento conductor DDMMAAAA;Nif, Cif, Otros;NIF Conductor;SEXO;Fecha carnét DDMMAAAA;Conductor Autorizado 1;Nombre Conductor;1º Apellido Conductor;2º Apellido Conductor;Fecha nto. Conductor DDMMAAAA;NIF Conductor;SEXO;Fecha carnet DDMMAAAA;Conductor Autorizado 2;Nombre Conductor;1º Apellido Conductor;2º Apellido Conductor;Fecha nto. Conductor DDMMAAAA;NIF Conductor;SEXO;Fecha carnet DDMMAAAA;Permiso retirado (fijo);Uso Vehículo (según tabla);Accesorios;Tipo de Accesorios;Descripción (Detallar los accesorios separados por comas);Valor Accesorios (valor total);Peso en Toneladas;Literal de Marca;Literal de Modelo;Literal de Versión;Valor (fijo);Valor LUNAS;Matrícula;Fecha 1ª Matriculación DDMMAAAA;C.P. circulación (poner el CP del conductor);Alarma (fijo);Garaje (fijo);KM recorridos (fijo);Combinación de Garantías;Combinación de Accidentes;Kit RC Explotación Agrícola;PRIMA TOTAL;Nº PîLIZA EMITIDA;PNETA EMITIDA;PTOTAL EMITIDA");
|
||||
foreach (var linea in listaPolizas)
|
||||
{
|
||||
int idTipoFicheroPresupuesto = bd.enumeraciones.First(x => x.Codigo == "TIPFIC.PRESUPUESTO").idEnumeracion;
|
||||
if (linea.idFicheroPresupuestoNavigation?.idTipo == idTipoFicheroPresupuesto &&
|
||||
linea.idFicheroPresupuestoNavigation?.NombreFichero?.Trim().ToUpper() == "TRACTORES.XML" &&
|
||||
!string.IsNullOrWhiteSpace(linea.NumeroPoliza))
|
||||
{
|
||||
string lineaCSV = "";
|
||||
bool lineaCsvCorrecta = false;
|
||||
try
|
||||
{
|
||||
lineaCSV = ComponerLineaCsv(linea, bd);
|
||||
lineaCsvCorrecta = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string asunto = $"No se ha podido generar una línea del CSV de TractoresAXA; idPoliza = {linea.idPoliza}; Máquina = {Environment.MachineName}";
|
||||
string cuerpo = $"No se ha podido generar una línea del CSV de TractoresAXA; idPoliza = {linea.idPoliza}\r\n" +
|
||||
$"Esto podría significar que falta algún dato en esta póliza.\r\n" +
|
||||
$"En método {System.Reflection.MethodBase.GetCurrentMethod()}.\r\n{Environment.MachineName} {ex.ToString()}";
|
||||
tsUtilidades.TsNotificacionesClient.RegistrarAsync(asunto, cuerpo, tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
|
||||
if (lineaCsvCorrecta)
|
||||
{
|
||||
sw.WriteLine(lineaCSV);
|
||||
if (lineaGestionesVarias != null && !string.IsNullOrWhiteSpace(lineaGestionesVarias.Descripción))
|
||||
{
|
||||
linea.gestionespolizassg.Add(new gestionespolizassg
|
||||
{
|
||||
idPoliza = linea.idPoliza,
|
||||
idTipo = idTipoGestionPoliza,
|
||||
Fecha = DateTime.Now,
|
||||
GestionesRealizadas = sDescripcionGestion,
|
||||
idGestionVariasNavigation = lineaGestionesVarias
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string cadenaError = $"Advertencia: el fichero no es de tipo \"TIPFIC.PRESUPUESTO\" o no se llama \"tractores.xml\", o no hay número de póliza; idPoliza = {linea.idPoliza}";
|
||||
Console.WriteLine(cadenaError);
|
||||
tsUtilidades.TsNotificacionesClient.RegistrarAsync( $"En {System.Reflection.MethodBase.GetCurrentMethod()}",
|
||||
$"En método {System.Reflection.MethodBase.GetCurrentMethod()}. {Environment.MachineName} {cadenaError}", tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (NumeroDeLineasEnElArchivoCSV(nombreArchivoTemporal) <= 1)
|
||||
{
|
||||
throw new Exception("El archivo CSV que se ha generado solamente tiene la línea de la cabecera, es decir, no lleva información de ninguna póliza, por lo cual no tiene sentido mandarlo.");
|
||||
}
|
||||
|
||||
archivoCSV = File.ReadAllBytes(nombreArchivoTemporal);
|
||||
try
|
||||
{
|
||||
File.Delete(nombreArchivoTemporal);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Nada, a propósito
|
||||
}
|
||||
|
||||
return archivoCSV;
|
||||
}
|
||||
|
||||
public static byte[] GenerarCsvTractoresAxa(tscgestionasegasa bd, string cadenaListaPolizas = null)
|
||||
{
|
||||
byte[] archivoCSV = null;
|
||||
var listaPolizas = new List<polizassg>();
|
||||
int idRamoTractores = bd.ramos.Where(x => x.Codigo == "1-1").Select(x => x.idRamo).FirstOrDefault();
|
||||
int idRamoRemolques = bd.ramos.Where(x => x.Codigo == "1-1-1").Select(x => x.idRamo).FirstOrDefault();
|
||||
int idCiaAXA = bd.companias.Where(x => x.Codigo == "0027").Select(x => x.idCompania).FirstOrDefault();
|
||||
|
||||
var listaCadenasSeparadasPorComas = cadenaListaPolizas.Split(',').ToList();
|
||||
foreach (var x in listaCadenasSeparadasPorComas)
|
||||
{
|
||||
if (x.Contains("-"))
|
||||
{
|
||||
var subListaRangos = x.Split('-').ToList();
|
||||
if (subListaRangos.Count == 2)
|
||||
{
|
||||
uint iRangoDesde = uint.Parse(subListaRangos.First().Trim());
|
||||
uint iRangoHasta = uint.Parse(subListaRangos.Last().Trim());
|
||||
|
||||
var results = bd.polizassg.Where(y =>
|
||||
(y.idRamoNavigation.idRamo == idRamoTractores || y.idRamoNavigation.idRamo == idRamoRemolques) &&
|
||||
y.idCompania == idCiaAXA &&
|
||||
y.idOrigenPresupuesto == (int)bdAsegasa.db.polizassg.TiposPresupuestos.TRACTORES &&
|
||||
(Convert.ToUInt32(y.NumeroPoliza) >= iRangoDesde && Convert.ToUInt32(y.NumeroPoliza) <= iRangoHasta)
|
||||
).OrderBy(y => y.NumeroPoliza).ToList();
|
||||
|
||||
listaPolizas.AddRange(results);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new FormatException($"Error con el formato de los rangos de números de pólizas especificados: {cadenaListaPolizas}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string sNumeroPoliza = x.Trim();
|
||||
var temp = bd.polizassg.First(y => y.NumeroPoliza == sNumeroPoliza);
|
||||
listaPolizas.Add(temp);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var poliza in listaPolizas)
|
||||
{
|
||||
Debug.WriteLine($"[{poliza.idPoliza},{poliza.NumeroPoliza},{poliza.Matricula}]");
|
||||
}
|
||||
|
||||
archivoCSV = GenerarCsvTractoresAxa(bd, listaPolizas);
|
||||
return archivoCSV;
|
||||
}
|
||||
|
||||
public static byte[] GenerarCsvTractoresAxa(tscgestionasegasa bd, DateTime fechaDesde, DateTime fechaHasta)
|
||||
{
|
||||
byte[] archivoCSV = null;
|
||||
int idRamoTractores = bd.ramos.Where(x => x.Codigo == "1-1").Select(x => x.idRamo).FirstOrDefault();
|
||||
int idRamoRemolques = bd.ramos.Where(x => x.Codigo == "1-1-1").Select(x => x.idRamo).FirstOrDefault();
|
||||
int idCiaAXA = bd.companias.Where(x => x.Codigo == "0027").Select(x => x.idCompania).FirstOrDefault();
|
||||
|
||||
var listaAltas = bd.polizassg.Where(x =>
|
||||
(x.idRamoNavigation.idRamo == idRamoTractores || x.idRamoNavigation.idRamo == idRamoRemolques) &&
|
||||
x.idCompania == idCiaAXA &&
|
||||
x.idOrigenPresupuesto == (int)bdAsegasa.db.polizassg.TiposPresupuestos.TRACTORES
|
||||
).ToList();
|
||||
|
||||
var listaAltasFiltradasPorFecha = listaAltas.Where(x =>
|
||||
x.FechaAlta.HasValue && x.FechaAlta.Value.Date <= fechaHasta &&
|
||||
x.FechaAlta.HasValue && x.FechaAlta.Value.Date >= fechaDesde
|
||||
).ToList();
|
||||
|
||||
archivoCSV = GenerarCsvTractoresAxa(bd, listaAltasFiltradasPorFecha);
|
||||
return archivoCSV;
|
||||
}
|
||||
|
||||
private static string ComponerLineaCsv(polizassg poliza, tscgestionasegasa bd)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
try
|
||||
{
|
||||
var listaDatosFaltantes = new List<string>();
|
||||
|
||||
// Assuming poliza.Tractores is available dynamically or strongly typed via partial
|
||||
dynamic pTractores = ((dynamic)poliza).Tractores;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(((string)pTractores.TipoVehiculo)?.Trim())) listaDatosFaltantes.Add("poliza.Tractores.TipoVehiculo");
|
||||
if (string.IsNullOrWhiteSpace((poliza.FechaEfecto).ToString("ddMMyyyy"))) listaDatosFaltantes.Add("poliza.FechaEfecto");
|
||||
if (string.IsNullOrWhiteSpace(((string)poliza.Tomador.CIF)?.Trim())) listaDatosFaltantes.Add("poliza.Tomador.CIF");
|
||||
|
||||
if (ObtenerTipoDocumentoTractoresAxa((string)poliza.Tomador.CIF) != bd.enumeraciones.First(x => x.Codigo == "AXATRACTORES.tipoDoc.PersJuridicaCIF").ValorAlfabeticoLargo)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(((string)pTractores.TomadorApellido1)?.Trim())) listaDatosFaltantes.Add("poliza.Tractores.TomadorApellido1");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(((string)pTractores.TomadorNombre)?.Trim())) listaDatosFaltantes.Add("poliza.Tractores.TomadorNombre");
|
||||
if (string.IsNullOrWhiteSpace(((DateTime)pTractores.TomadorFechaNacimiento).ToString("ddMMyyyy"))) listaDatosFaltantes.Add("poliza.Tractores.TomadorFechaNacimiento");
|
||||
if (string.IsNullOrWhiteSpace(((string)pTractores.EstadoCivil)?.Trim())) listaDatosFaltantes.Add("poliza.Tractores.EstadoCivil");
|
||||
|
||||
if (ObtenerTipoDocumentoTractoresAxa((string)poliza.Tomador.CIF) != bd.enumeraciones.First(x => x.Codigo == "AXATRACTORES.tipoDoc.PersJuridicaCIF").ValorAlfabeticoLargo)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(((string)pTractores.TomadorSexo?.ToString()))) listaDatosFaltantes.Add("poliza.Tractores.TomadorSexo");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(((string)pTractores.TomadorCodigoPostal)?.Trim())) listaDatosFaltantes.Add("poliza.Tractores.TomadorCodigoPostal");
|
||||
if (string.IsNullOrWhiteSpace(((string)pTractores.TomadorPoblacion)?.Trim())) listaDatosFaltantes.Add("poliza.Tractores.TomadorPoblacion");
|
||||
if (string.IsNullOrWhiteSpace(((string)pTractores.TomadorVia)?.Trim())) listaDatosFaltantes.Add("poliza.Tractores.TomadorVia");
|
||||
if (string.IsNullOrWhiteSpace(((string)pTractores.TomadorNombreVia)?.Trim())) listaDatosFaltantes.Add("poliza.Tractores.TomadorNombreVia");
|
||||
if (string.IsNullOrWhiteSpace(((string)pTractores.TomadorNumeroVia)?.Trim())) listaDatosFaltantes.Add("poliza.Tractores.TomadorNumeroVia");
|
||||
|
||||
if (poliza.Propietario != null)
|
||||
{
|
||||
if (ObtenerTipoDocumentoTractoresAxa((string)poliza.Propietario.CIF) != bd.enumeraciones.First(x => x.Codigo == "AXATRACTORES.tipoDoc.PersJuridicaCIF").ValorAlfabeticoLargo)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(((string)pTractores.PropietarioSexo?.ToString()))) listaDatosFaltantes.Add("poliza.Tractores.PropietarioSexo");
|
||||
if (string.IsNullOrWhiteSpace(((string)pTractores.PropietarioApellido1)?.Trim())) listaDatosFaltantes.Add("poliza.Tractores.PropietarioApellido1");
|
||||
}
|
||||
if (poliza.Propietario.idEntidad != poliza.Tomador.idEntidad)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(((string)poliza.Propietario.Nombre)?.Trim()) && (ObtenerTipoDocumentoTractoresAxa((string)poliza.Propietario.CIF) != bd.enumeraciones.First(x => x.Codigo == "AXATRACTORES.tipoDoc.PersJuridicaCIF").ValorAlfabeticoLargo))
|
||||
{
|
||||
listaDatosFaltantes.Add("poliza.propietario.nombre");
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(((string)poliza.Propietario.CIF)?.Trim())) listaDatosFaltantes.Add("poliza.Propietario.CIF");
|
||||
}
|
||||
}
|
||||
|
||||
if (poliza.Conductor == null || poliza.Conductor.idEntidad == poliza.Tomador.idEntidad)
|
||||
{
|
||||
DateTime fechaPermiso = (DateTime)pTractores.FechaPermisoConduccion;
|
||||
if (!(fechaPermiso > DateTime.MinValue && fechaPermiso < DateTime.MaxValue))
|
||||
{
|
||||
listaDatosFaltantes.Add("poliza.Tractores.FechaPermisoConduccion");
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(fechaPermiso.ToString("ddMMyyyy"))) listaDatosFaltantes.Add("poliza.Tractores.FechaPermisoConduccion");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(((string)pTractores.ConductorNombre)?.Trim())) listaDatosFaltantes.Add("poliza.Tractores.ConductorNombre");
|
||||
if (string.IsNullOrWhiteSpace(((string)pTractores.ConductorApellido1)?.Trim())) listaDatosFaltantes.Add("poliza.Tractores.ConductorApellido1");
|
||||
if (string.IsNullOrWhiteSpace(((DateTime)pTractores.ConductorFechaNacimiento).ToString("ddMMyyyy"))) listaDatosFaltantes.Add("poliza.Tractores.ConductorFechaNacimiento");
|
||||
if (string.IsNullOrWhiteSpace(((string)poliza.Conductor.CIF)?.Trim())) listaDatosFaltantes.Add("poliza.Conductor.CIF");
|
||||
if (string.IsNullOrWhiteSpace(((string)pTractores.ConductorSexo?.ToString()))) listaDatosFaltantes.Add("poliza.Tractores.ConductorSexo");
|
||||
if (string.IsNullOrWhiteSpace(((DateTime)pTractores.FechaPermisoConduccion).ToString("ddMMyyyy"))) listaDatosFaltantes.Add("poliza.Tractores.FechaPermisoConduccion");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(((string)pTractores.UsoVehiculo)?.Trim())) listaDatosFaltantes.Add("poliza.Tractores.UsoVehiculo");
|
||||
if (string.IsNullOrWhiteSpace(((string)pTractores.Peso?.ToString())?.Trim())) listaDatosFaltantes.Add("poliza.Tractores.Peso");
|
||||
if (string.IsNullOrWhiteSpace(((string)pTractores.Marca)?.Trim())) listaDatosFaltantes.Add("poliza.Tractores.Marca");
|
||||
if (string.IsNullOrWhiteSpace(((string)pTractores.Modelo)?.Trim())) listaDatosFaltantes.Add("poliza.Tractores.Modelo");
|
||||
if (string.IsNullOrWhiteSpace(((string)pTractores.Version)?.Trim())) listaDatosFaltantes.Add("poliza.Tractores.Version");
|
||||
if (string.IsNullOrWhiteSpace(poliza.Matricula?.ToUpper().Trim())) listaDatosFaltantes.Add("poliza.Matricula");
|
||||
if (string.IsNullOrWhiteSpace(((DateTime)pTractores.FechaPrimeraMatriculacion).ToString("ddMMyyyy"))) listaDatosFaltantes.Add("poliza.Tractores.FechaPrimeraMatriculacion");
|
||||
if (string.IsNullOrWhiteSpace(((string)pTractores.TomadorCodigoPostal)?.Trim())) listaDatosFaltantes.Add("poliza.Tractores.TomadorCodigoPostal");
|
||||
if (string.IsNullOrWhiteSpace(((string)pTractores.CombinacionAccidentes)?.Trim())) listaDatosFaltantes.Add("poliza.Tractores.CombinacionAccidentes");
|
||||
if (string.IsNullOrWhiteSpace(((string)pTractores.PrimaTotal)?.Trim())) listaDatosFaltantes.Add("poliza.Tractores.PrimaTotal");
|
||||
|
||||
if (listaDatosFaltantes.Count > 0)
|
||||
{
|
||||
var sbDatosFaltantes = new StringBuilder();
|
||||
foreach (var l in listaDatosFaltantes)
|
||||
{
|
||||
sbDatosFaltantes.AppendFormat("{0}, ", l);
|
||||
}
|
||||
throw new Exception($"No se puede componer esta línea del CSV porque faltan datos en la póliza idPoliza = {poliza.idPoliza}; Lista de datos faltantes: {sbDatosFaltantes.ToString().TrimEnd(',', ' ')}");
|
||||
}
|
||||
|
||||
sb.AppendFormat("{0};", ((string)pTractores.TipoVehiculo).Trim());
|
||||
sb.AppendFormat("=\"{0}\";", "001");
|
||||
sb.AppendFormat("=\"{0}\";", "001");
|
||||
sb.AppendFormat("{0};", "674392");
|
||||
sb.AppendFormat("=\"{0}\";", (poliza.FechaEfecto).ToString("ddMMyyyy"));
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "8184");
|
||||
sb.AppendFormat("{0};", poliza.NumeroPoliza?.Trim());
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "Anual Renovable");
|
||||
sb.AppendFormat("{0};", "Anual");
|
||||
sb.AppendFormat("{0};", "Mediador");
|
||||
sb.AppendFormat("{0};", "");
|
||||
|
||||
sb.AppendFormat("{0};", ObtenerTipoDocumentoTractoresAxa((string)poliza.Tomador.CIF));
|
||||
sb.AppendFormat("{0};", ((string)poliza.Tomador.CIF).Trim());
|
||||
sb.AppendFormat("{0};", ((string)pTractores.TomadorApellido1)?.Trim());
|
||||
sb.AppendFormat("{0};", ((string)pTractores.TomadorApellido2)?.Trim());
|
||||
sb.AppendFormat("{0};", ((string)pTractores.TomadorNombre)?.Trim());
|
||||
sb.AppendFormat("=\"{0}\";", ((DateTime)pTractores.TomadorFechaNacimiento).ToString("ddMMyyyy"));
|
||||
sb.AppendFormat("{0};", ((string)pTractores.EstadoCivil).Trim());
|
||||
|
||||
if (ObtenerTipoDocumentoTractoresAxa((string)poliza.Tomador.CIF) == bd.enumeraciones.First(x => x.Codigo == "AXATRACTORES.tipoDoc.PersJuridicaCIF").ValorAlfabeticoLargo)
|
||||
{
|
||||
sb.AppendFormat("{0};", bd.enumeraciones.First(x => x.Codigo == "AXATRACTORES.sexo.SinInformar").ValorAlfabetico1);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendFormat("{0};", ObtenerSexoTractoresAxa(((object)pTractores.TomadorSexo)?.ToString(), bd));
|
||||
}
|
||||
|
||||
sb.AppendFormat("{0};", ((string)pTractores.TomadorCodigoPostal).Trim());
|
||||
sb.AppendFormat("{0};", ((string)pTractores.TomadorPoblacion).Trim());
|
||||
sb.AppendFormat("{0};", ((string)pTractores.TomadorVia).Trim());
|
||||
sb.AppendFormat("{0};", ((string)pTractores.TomadorNombreVia).Trim());
|
||||
sb.AppendFormat("{0};", ((string)pTractores.TomadorNumeroVia).Trim());
|
||||
sb.AppendFormat("{0};", ((string)pTractores.TomadorRestoVia)?.Trim() ?? "");
|
||||
|
||||
if (poliza.Propietario == null || poliza.Propietario.idEntidad == poliza.Tomador.idEntidad)
|
||||
{
|
||||
sb.AppendFormat("{0};", "El Tomador");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ObtenerTipoDocumentoTractoresAxa((string)poliza.Propietario.CIF) != bd.enumeraciones.First(x => x.Codigo == "AXATRACTORES.tipoDoc.PersJuridicaCIF").ValorAlfabeticoLargo)
|
||||
{
|
||||
sb.AppendFormat("{0};", "Otra persona distinta del Tomador");
|
||||
sb.AppendFormat("{0};", ((string)poliza.Propietario.Nombre).Trim());
|
||||
sb.AppendFormat("{0};", ((string)pTractores.PropietarioApellido1).Trim());
|
||||
sb.AppendFormat("{0};", ((string)pTractores.PropietarioApellido2)?.Trim() ?? "");
|
||||
sb.AppendFormat("{0};", ((string)poliza.Propietario.CIF).Trim());
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendFormat("{0};", "Otra persona distinta del Tomador");
|
||||
sb.AppendFormat("{0};", ((string)poliza.Propietario.Nombre).Trim());
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", ((string)poliza.Propietario.CIF).Trim());
|
||||
}
|
||||
}
|
||||
|
||||
if (poliza.Conductor== null || poliza.Conductor.idEntidad == poliza.Tomador.idEntidad)
|
||||
{
|
||||
sb.AppendFormat("{0};", "El Tomador");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("=\"{0}\";", ((DateTime)pTractores.FechaPermisoConduccion).ToString("ddMMyyyy"));
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendFormat("{0};", "Es otra persona");
|
||||
sb.AppendFormat("{0};", ((string)pTractores.ConductorNombre).Trim());
|
||||
sb.AppendFormat("{0};", ((string)pTractores.ConductorApellido1).Trim());
|
||||
sb.AppendFormat("{0};", ((string)pTractores.ConductorApellido2)?.Trim() ?? "");
|
||||
sb.AppendFormat("=\"{0}\";", ((DateTime)pTractores.ConductorFechaNacimiento).ToString("ddMMyyyy"));
|
||||
sb.AppendFormat("{0};", ObtenerTipoDocumentoTractoresAxa((string)poliza.Conductor.CIF));
|
||||
sb.AppendFormat("{0};", ((string)poliza.Conductor.CIF).Trim());
|
||||
sb.AppendFormat("{0};", ObtenerSexoTractoresAxa(((object)pTractores.ConductorSexo)?.ToString(), bd));
|
||||
sb.AppendFormat("=\"{0}\";", ((DateTime)pTractores.FechaPermisoConduccion).ToString("ddMMyyyy"));
|
||||
}
|
||||
|
||||
sb.AppendFormat("{0};", "No se declara");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
|
||||
sb.AppendFormat("{0};", "No se declara");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
|
||||
sb.AppendFormat("{0};", "No");
|
||||
sb.AppendFormat("{0};", ((string)pTractores.UsoVehiculo).Trim());
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", ((object)pTractores.Peso).ToString().Trim());
|
||||
sb.AppendFormat("{0};", ((string)pTractores.Marca).Trim());
|
||||
sb.AppendFormat("{0};", ((string)pTractores.Modelo).Trim());
|
||||
sb.AppendFormat("{0};", ((string)pTractores.Version).Trim());
|
||||
sb.AppendFormat("{0};", "35.000");
|
||||
sb.AppendFormat("=\"{0}\";", "0,00");
|
||||
sb.AppendFormat("{0};", poliza.Matricula.ToUpper().Trim());
|
||||
sb.AppendFormat("=\"{0}\";", ((DateTime)pTractores.FechaPrimeraMatriculacion).ToString("ddMMyyyy"));
|
||||
sb.AppendFormat("=\"{0}\";", ((string)pTractores.TomadorCodigoPostal).Trim());
|
||||
sb.AppendFormat("{0};", "NO");
|
||||
sb.AppendFormat("{0};", "NO");
|
||||
sb.AppendFormat("{0};", "Sin definir");
|
||||
sb.AppendFormat("{0};", "Terceros sin Asistencia");
|
||||
sb.AppendFormat("{0};", ((string)pTractores.CombinacionAccidentes).Trim());
|
||||
sb.AppendFormat("{0};", "Si");
|
||||
sb.AppendFormat("{0};", ((string)pTractores.PrimaTotal).Trim());
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0};", "");
|
||||
sb.AppendFormat("{0}", "");
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static int PrepararCorreosCsvTractoresAxa(tscgestionasegasa bd)
|
||||
{
|
||||
const bool danmundebug = false;
|
||||
int resultadoGuardarCambios = 0;
|
||||
try
|
||||
{
|
||||
DateTime dHoy = DateTime.Today;
|
||||
DateTime dAyer = DateTime.Today.AddDays(-1);
|
||||
int idTipoGestionPoliza = bd.enumeraciones.First(x => x.Codigo == "TGP.CSVAXA").idEnumeracion;
|
||||
int idTipoFicheroCSV = bd.enumeraciones.First(x => x.Codigo == "TIPFIC.CSVAXA").idEnumeracion;
|
||||
|
||||
var lineasPendientesCorreoCsv = bd.gestionesvarias
|
||||
.Where(x => x.idTipo == idTipoGestionPoliza && !x.FechaProcesado.HasValue)
|
||||
.ToList();
|
||||
|
||||
foreach (var linea in lineasPendientesCorreoCsv)
|
||||
{
|
||||
var listaDestinatarios = bd.enumeraciones
|
||||
.Where(x => x.Codigo.StartsWith("AXATRACTORES.email.destinatario"))
|
||||
.Select(x => x.ValorAlfabeticoLargo.Trim())
|
||||
.ToList();
|
||||
|
||||
string asunto = $"{bd.enumeraciones.First(x => x.Codigo == "AXATRACTORES.email.asunto").ValorAlfabeticoLargo.Trim()} {linea.idFicheroNavigation?.Descripcion?.Split(' ').Last()}";
|
||||
string cuerpo = $"{bd.enumeraciones.First(x => x.Codigo == "AXATRACTORES.email.cuerpo").ValorAlfabeticoLargo.Trim()} {linea.idFicheroNavigation?.Descripcion?.Split(' ').Last()}";
|
||||
|
||||
var cuentaCorreo = bd.cuentascorreo.First(x => x.Codigo == "CSVAXA");
|
||||
|
||||
foreach (var destinatario in listaDestinatarios)
|
||||
{
|
||||
// Use GeneraRegistroCorreo using the proper signature defined in bdAsegasa
|
||||
// The VB is calling `bdGestionAsegasa.correos.GeneraRegistroCorreo(bd, asunto, cuerpo, cuentaCorreo, destinatario,,, linea.idFichero)`.
|
||||
bdAsegasa.db.correos.GeneraRegistroCorreo(bd, asunto, cuerpo, cuentaCorreo, destinatario, null, null, linea.idFichero);
|
||||
}
|
||||
|
||||
linea.FechaProcesado = DateTime.Now;
|
||||
if (!danmundebug) resultadoGuardarCambios += bd.SaveChanges();
|
||||
|
||||
if (resultadoGuardarCambios > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
var mensaje = new StringBuilder();
|
||||
mensaje.AppendFormat("Se ha generado un email para AXA conteniendo el archivo CSV con altas de tractores y/o remolques para AXA.```Asunto: {1}{0}Servidor: {2}```",
|
||||
Environment.NewLine, asunto, Environment.MachineName);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("No hay líneas o se produjo excepción.");
|
||||
_ = tsUtilidades.TsNotificacionesClient.RegistrarAsync($"En {System.Reflection.MethodBase.GetCurrentMethod()}",
|
||||
$"En método {System.Reflection.MethodBase.GetCurrentMethod()}. {Environment.MachineName} {ex.ToString()}", tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
return resultadoGuardarCambios;
|
||||
}
|
||||
|
||||
public static bool YaSeEnvioCsvParaAyer(tscgestionasegasa bd)
|
||||
{
|
||||
int idTipoGestionPoliza = bd.enumeraciones.First(x => x.Codigo == "TGP.CSVAXA").idEnumeracion;
|
||||
DateTime dAyer = DateTime.Today.AddDays(-1);
|
||||
string sDescripcion = $"{bd.enumeraciones.First(x => x.Codigo == "AXATRACTORES.NombreFicheroCSV").ValorAlfabeticoLargo}{dAyer:yyyy-MM-dd}.csv";
|
||||
|
||||
return bd.gestionesvarias.Any(x => x.idTipo == idTipoGestionPoliza && x.FechaProcesado.HasValue && x.Descripción == sDescripcion);
|
||||
}
|
||||
|
||||
public static bool YaSeEnvioCsvParaHoy(tscgestionasegasa bd)
|
||||
{
|
||||
int idTipoGestionPoliza = bd.enumeraciones.First(x => x.Codigo == "TGP.CSVAXA").idEnumeracion;
|
||||
string sDescripcion = $"{bd.enumeraciones.First(x => x.Codigo == "AXATRACTORES.NombreFicheroCSV").ValorAlfabeticoLargo}{DateTime.Today:yyyy-MM-dd}.csv";
|
||||
|
||||
return bd.gestionesvarias.Any(x => x.idTipo == idTipoGestionPoliza && x.FechaProcesado.HasValue && x.Descripción == sDescripcion);
|
||||
}
|
||||
|
||||
public static int NumeroDeLineasEnElArchivoCSV(string rutaArchivoCSV)
|
||||
{
|
||||
return File.ReadLines(rutaArchivoCSV).Count();
|
||||
}
|
||||
|
||||
private static int ComprobarCuantosNumerosReservadosQuedanDisponibles(int nActual, enumeraciones inicio, enumeraciones fin)
|
||||
{
|
||||
|
||||
|
||||
if(fin.ValorNumerico1 != null)
|
||||
{
|
||||
|
||||
}
|
||||
return (int)(fin.ValorNumerico1 ?? 0) - nActual;
|
||||
}
|
||||
|
||||
private static string ObtenerTipoDocumentoTractoresAxa(string numeroDocumento)
|
||||
{
|
||||
// Assuming string extension TipoDocumentoIdentidad mapped inside C# as tsUtilidades.Mobiles.Validaciones.ObtenerTipo(numeroDocumento)
|
||||
// The enum `tsl5.ValidarDocumentoIdentidad.TiposDocumentosEnum.CIF` translates to some util module enum.
|
||||
// Simplified CIF check based on letter if no tsUtilidades available, but we use the library.
|
||||
// If it starts with typical CIF letters A B C D E F G H J N P Q R S U V W
|
||||
var initChar = char.ToUpperInvariant(numeroDocumento.FirstOrDefault());
|
||||
string cifLetters = "ABCDEFGHJNPQRSUVW";
|
||||
if (cifLetters.Contains(initChar))
|
||||
{
|
||||
return "CIF";
|
||||
}
|
||||
return "NIF";
|
||||
}
|
||||
|
||||
private static string ObtenerSexoTractoresAxa(string cadenaSexo, tscgestionasegasa bd)
|
||||
{
|
||||
string resultado = bd.enumeraciones.First(x => x.Codigo == "AXATRACTORES.sexo.SinInformar").ValorAlfabetico1;
|
||||
string axaHombre = bd.enumeraciones.First(x => x.Codigo == "AXATRACTORES.sexo.Hombre").ValorAlfabetico1;
|
||||
string axaMujer = bd.enumeraciones.First(x => x.Codigo == "AXATRACTORES.sexo.Mujer").ValorAlfabetico1;
|
||||
|
||||
string idEnumSexoHombre = bd.enumeraciones.First(x => x.Codigo == "SEXO.HOMBRE").idEnumeracion.ToString();
|
||||
string idEnumSexoMujer = bd.enumeraciones.First(x => x.Codigo == "SEXO.MUJER").idEnumeracion.ToString();
|
||||
|
||||
if (cadenaSexo == idEnumSexoHombre) resultado = axaHombre;
|
||||
if (cadenaSexo == idEnumSexoMujer) resultado = axaMujer;
|
||||
|
||||
return resultado;
|
||||
}
|
||||
}
|
||||
}
|
||||
203
Servicio Gestion Asegasa/Procesos/ProcesosZurich.cs
Normal file
203
Servicio Gestion Asegasa/Procesos/ProcesosZurich.cs
Normal file
@@ -0,0 +1,203 @@
|
||||
//using System;
|
||||
//using System.Linq;
|
||||
//using System.Threading.Tasks;
|
||||
//using Microsoft.EntityFrameworkCore;
|
||||
//using bdAsegasa;
|
||||
//using bdAsegasa.db;
|
||||
//using System.Security.Cryptography;
|
||||
|
||||
//namespace Servicio_Gestion_Asegasa.Procesos
|
||||
//{
|
||||
// public class ProcesosZurich
|
||||
// {
|
||||
// public static async Task ObtieneDocumentosPolizasPendientes()
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// using var bd = tscgestionasegasa.NuevoContexto();
|
||||
|
||||
// int idZurich = bd.companias.First(x => x.Codigo == "0013").idCompania;
|
||||
// int tipoFichero = bd.enumeraciones.First(x => x.Codigo == "TIPFIC.DOCPOL").idEnumeracion;
|
||||
// var fi = new DateTime(2024, 10, 5);
|
||||
|
||||
// var pols = bd.polizassg
|
||||
// .Where(x => x.idCompania == idZurich &&
|
||||
// x.NumeroPoliza != null &&
|
||||
// x.FechaAlta > fi &&
|
||||
// x.documentospolizassg.All(y => y.Tipo == 0))
|
||||
// .ToList();
|
||||
|
||||
// var cz = bd.enumeraciones.First(x => x.Codigo == "CONF.0013");
|
||||
|
||||
// // Asumimos que ServicioDocumentos es un cliente WCF / Servicio inyectado en el scope superior
|
||||
// dynamic sv = Activator.CreateInstance(Type.GetType("ServicioDocumentos") ?? throw new Exception("ServicioDocumentos no encontrado"), cz.ValorAlfabetico1, cz.ValorAlfabetico2)!;
|
||||
|
||||
// foreach (var p in pols)
|
||||
// {
|
||||
// string numpol = p.NumeroPoliza.PadLeft(14, '0');
|
||||
// var ld = await sv.ObtenerDocumentosAsync(numpol, -1);
|
||||
|
||||
// // Obtener la lista de documentos que no son recibos
|
||||
// // En VB: ld.Document.Where(Function(x) Not String.IsNullOrEmpty(x.documentTypeDesc) AndAlso Not x.documentTypeDesc.ToLower().Contains("recibo"))
|
||||
// System.Collections.Generic.IEnumerable<dynamic> docList = ld.Document;
|
||||
// var ldocs = docList.Where(x => !string.IsNullOrEmpty((string)x.documentTypeDesc) && !((string)x.documentTypeDesc).ToLower().Contains("recibo"));
|
||||
|
||||
// foreach (var d in ldocs)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// var dr = await sv.DescargarDocumentoAsync("", (string)d.documentCode, false, numpol, (string)ld.policyVersion);
|
||||
|
||||
// byte[] data = dr.documentFileContent.data;
|
||||
// string sha1 = GetSha1Hash(data);
|
||||
|
||||
// var docpol = p.documentospolizassg.FirstOrDefault(x => x.Hash == sha1);
|
||||
|
||||
// if (docpol == null)
|
||||
// {
|
||||
// docpol = new documentospolizassg();
|
||||
// var fichero = new ficheros
|
||||
// {
|
||||
// Descripcion = d.documentTypeDesc,
|
||||
// Fecha = DateTime.Now,
|
||||
// idTipo = tipoFichero,
|
||||
// Fichero = data,
|
||||
// NombreFichero = dr.documentFileContent.fileName,
|
||||
// idAplicacion = p.idPoliza
|
||||
// };
|
||||
|
||||
// // Crear y almacenar el documento de la póliza
|
||||
// docpol.Descripcion = ((string)d.documentTypeDesc).ToUpper();
|
||||
// docpol.idFicheroNavigation = fichero;
|
||||
// docpol.FechaComprobacion = DateTime.Now;
|
||||
// docpol.Fecha = DateTime.Now;
|
||||
// docpol.Codigo = d.documentCode;
|
||||
// docpol.Hash = sha1;
|
||||
// docpol.Tipo = ObtieneTipoDocumento((string)d.typeCode);
|
||||
|
||||
// p.documentospolizassg.Add(docpol);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// docpol.Codigo = d.documentCode;
|
||||
// docpol.Tipo = ObtieneTipoDocumento((string)d.typeCode);
|
||||
// }
|
||||
|
||||
// bd.SaveChanges();
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En ObtieneDocumentosPolizasPendientes.", $"Rutina: ObtieneDocumentosPolizasPendientes. Poliza:{p.NumeroPoliza} dc:{d.documentCode} {ex.Message}",tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En ObtieneDocumentosPolizasPendientes.", $"Rutina: ObtieneDocumentosPolizasPendientes. {ex.Message}", tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
// }
|
||||
// }
|
||||
|
||||
// public static async Task ObtieneDocumentosRecibosPendientes()
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// using var bd = tscgestionasegasa.NuevoContexto();
|
||||
|
||||
// int idZurich = bd.companias.First(x => x.Codigo == "0013").idCompania;
|
||||
// int tipoFichero = bd.enumeraciones.First(x => x.Codigo == "TIPFIC.DOCPOL").idEnumeracion;
|
||||
// var fi = new DateOnly(2024, 9, 23);
|
||||
// var cz = bd.enumeraciones.First(x => x.Codigo == "CONF.0013");
|
||||
|
||||
// dynamic svRecibos = Activator.CreateInstance(Type.GetType("ServicioRecibos") ?? throw new Exception("ServicioRecibos no encontrado"), cz.ValorAlfabetico1, cz.ValorAlfabetico2)!;
|
||||
// dynamic svDocumentos = Activator.CreateInstance(Type.GetType("ServicioDocumentos") ?? throw new Exception("ServicioDocumentos no encontrado"), cz.ValorAlfabetico1, cz.ValorAlfabetico2)!;
|
||||
|
||||
// var recs = bd.recibos
|
||||
// .Where(x => x.idPolizaNavigation.idCompania == idZurich &&
|
||||
// x.FechaEfecto > fi &&
|
||||
// x.idPolizaNavigation.documentospolizassg.Count == 0)
|
||||
// .ToList();
|
||||
|
||||
// dynamic dr = null;
|
||||
|
||||
// foreach (var r in recs)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// var p = r.idPolizaNavigation;
|
||||
// dr = await svRecibos.ObtenerReciboDuplicadoAsync(r.NumeroRecibo, cz.ValorAlfabetico1);
|
||||
// string numpol = p.NumeroPoliza != null ? p.NumeroPoliza.PadLeft(14, '0') : string.Empty;
|
||||
|
||||
// var bpdf = await svDocumentos.DescargarDocumentoAsync("", (string)dr.documentCode, false, numpol, (string)dr.policyVersion);
|
||||
// byte[] data = bpdf.documentFileContent.data;
|
||||
|
||||
// string sha1 = GetSha1Hash(data);
|
||||
// var docpol = p.documentospolizassg.FirstOrDefault(x => x.Hash == sha1);
|
||||
|
||||
// if (docpol == null)
|
||||
// {
|
||||
// docpol = new documentospolizassg();
|
||||
// var fichero = new ficheros
|
||||
// {
|
||||
// Descripcion = "RECIBO",
|
||||
// Fecha = DateTime.Now,
|
||||
// idTipo = tipoFichero,
|
||||
// Fichero = data,
|
||||
// NombreFichero = dr.documentCode + ".pdf",
|
||||
// idAplicacion = p.idPoliza
|
||||
// };
|
||||
|
||||
// docpol.Descripcion = "RECIBO";
|
||||
// docpol.idFicheroNavigation = fichero;
|
||||
// docpol.FechaComprobacion = DateTime.Now;
|
||||
// docpol.Fecha = DateTime.Now;
|
||||
// docpol.Codigo = dr.documentCode;
|
||||
// docpol.Hash = sha1;
|
||||
// docpol.Tipo = (int)bdAsegasa.db.documentospolizassg.TipoDocumentoEnum.RECIBO;
|
||||
// docpol.idRecibo = r.idRecibo;
|
||||
|
||||
// p.documentospolizassg.Add(docpol);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// docpol.Codigo = dr.documentCode;
|
||||
// docpol.Tipo = (int)bdAsegasa.db.documentospolizassg.TipoDocumentoEnum.RECIBO;
|
||||
// }
|
||||
|
||||
// bd.SaveChanges();
|
||||
// dr = null;
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// string dcCode = dr == null ? "" : $" dc:{dr.documentCode}";
|
||||
// await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En ObtieneDocumentosRecibosPendientes.",$"Rutina: ObtieneDocumentosRecibosPendientes. Recibo:{r.CodigoRecibo}{dcCode} {ex.Message}",tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En ObtieneDocumentosRecibosPendientes.", $"Rutina: ObtieneDocumentosRecibosPendientes. {ex.Message}", tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
// }
|
||||
// }
|
||||
|
||||
// private static int ObtieneTipoDocumento(string typeCode)
|
||||
// {
|
||||
// switch (typeCode)
|
||||
// {
|
||||
// case "CL":
|
||||
// return (int)bdAsegasa.db.documentospolizassg.TipoDocumentoEnum.PÓLIZA;
|
||||
// case "CE":
|
||||
// return (int)bdAsegasa.db.documentospolizassg.TipoDocumentoEnum.CERTIFICADO_SEGURO;
|
||||
// default:
|
||||
// return (int)bdAsegasa.db.documentospolizassg.TipoDocumentoEnum.OTROS;
|
||||
// }
|
||||
// }
|
||||
|
||||
// private static string GetSha1Hash(byte[] data)
|
||||
// {
|
||||
// using var sha1 = SHA1.Create();
|
||||
// var hashBytes = sha1.ComputeHash(data);
|
||||
// return BitConverter.ToString(hashBytes).Replace("-", "").ToUpperInvariant();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
7
Servicio Gestion Asegasa/Program.cs
Normal file
7
Servicio Gestion Asegasa/Program.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using Servicio_Gestion_Asegasa;
|
||||
|
||||
var builder = Host.CreateApplicationBuilder(args);
|
||||
builder.Services.AddHostedService<Worker>();
|
||||
|
||||
var host = builder.Build();
|
||||
host.Run();
|
||||
12
Servicio Gestion Asegasa/Properties/launchSettings.json
Normal file
12
Servicio Gestion Asegasa/Properties/launchSettings.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"Servicio_Gestion_Asegasa": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"environmentVariables": {
|
||||
"DOTNET_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
24
Servicio Gestion Asegasa/Servicio Gestion Asegasa.csproj
Normal file
24
Servicio Gestion Asegasa/Servicio Gestion Asegasa.csproj
Normal file
@@ -0,0 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Worker">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UserSecretsId>dotnet-Servicio_Gestion_Asegasa-408b0288-12a3-42df-8545-97be3626a4a9</UserSecretsId>
|
||||
<RootNamespace>Servicio_Gestion_Asegasa</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
|
||||
<PackageReference Include="tsUtilidades" Version="1.1.10" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Procesos\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\bdAsegasa\bdAsegasa.csproj" />
|
||||
<ProjectReference Include="..\itsm\itsm.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
31
Servicio Gestion Asegasa/Worker.cs
Normal file
31
Servicio Gestion Asegasa/Worker.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using bdAsegasa.db;
|
||||
using Servicio_Gestion_Asegasa.Procesos;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Servicio_Gestion_Asegasa
|
||||
{
|
||||
public class Worker : BackgroundService
|
||||
{
|
||||
private readonly ILogger<Worker> _logger;
|
||||
|
||||
public Worker(ILogger<Worker> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
|
||||
// await ProcesosMensajes.EnviaSMSAsync();
|
||||
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
if (_logger.IsEnabled(LogLevel.Information))
|
||||
{
|
||||
_logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
|
||||
}
|
||||
await Task.Delay(1000, stoppingToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
8
Servicio Gestion Asegasa/appsettings.Development.json
Normal file
8
Servicio Gestion Asegasa/appsettings.Development.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
}
|
||||
}
|
||||
14
Servicio Gestion Asegasa/appsettings.json
Normal file
14
Servicio Gestion Asegasa/appsettings.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"TsNotificaciones": {
|
||||
//"ApiUrl": "http://192.168.41.32:5000/", prod
|
||||
"ApiUrl": "https://catcher.tecnosis.online",
|
||||
"IdAplicacion": 2,
|
||||
"ApiKey": "0a47a1eada0143278b9d4de4e8911100"
|
||||
}
|
||||
}
|
||||
41
bdAsegasa/Enums.cs
Normal file
41
bdAsegasa/Enums.cs
Normal 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
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
107
bdAsegasa/Extensiones/DatosRecibosExportacion.cs
Normal file
107
bdAsegasa/Extensiones/DatosRecibosExportacion.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
[Serializable]
|
||||
public class DatosRecibosExportacion
|
||||
{
|
||||
public DatosRecibosExportacion()
|
||||
{
|
||||
}
|
||||
|
||||
public DatosRecibosExportacion(vf_recibosextendidos Recibo)
|
||||
{
|
||||
CodigoRecibo = Recibo.CodigoRecibo;
|
||||
NumeroPoliza = Recibo.NumeroPoliza;
|
||||
Tomador = Recibo.Tomador;
|
||||
Matricula = Recibo.Matricula;
|
||||
FechaEfecto = Recibo.FechaEfecto;
|
||||
FechaVencimiento = Recibo.FechaVencimiento;
|
||||
Compania = Recibo.Compania;
|
||||
Agente = Recibo.Agente;
|
||||
SubAgente = Recibo.SubAgente;
|
||||
Ramo = Recibo.Ramo;
|
||||
FechaExpedicion = Recibo.FechaExpedicion;
|
||||
BienesAsegurados = Recibo.BienesAsegurados;
|
||||
FechaBaja = Recibo.FechaBaja;
|
||||
CausaBaja = Recibo.CausaBaja;
|
||||
TipoRecibo = Recibo.TipoRecibo;
|
||||
TipoPago = Recibo.TipoPago;
|
||||
Oficina = Recibo.Oficina;
|
||||
PrimaNeta = Recibo.PrimaNeta;
|
||||
BonificacionORecargo = Recibo.BonificacionORecargo;
|
||||
Consorcio = Recibo.Consorcio;
|
||||
Impuesto = Recibo.Impuesto;
|
||||
RecargoExterno = Recibo.RecargoExterno;
|
||||
TotalRecibo = Recibo.TotalRecibo;
|
||||
ComisionReciboPrimaNeta = Recibo.ComisionReciboPrimaNeta;
|
||||
PorcentajeReciboPrimaNeta = Recibo.PorcentajeReciboPrimaNeta;
|
||||
TotalComision = Recibo.TotalComision;
|
||||
PorcentajeComisionAgente = Recibo.PorcentajeComisionAgente;
|
||||
ComisionAgente = Recibo.ComisionAgente;
|
||||
}
|
||||
|
||||
public DatosRecibosExportacion(ve_recibos Recibo)
|
||||
{
|
||||
CodigoRecibo = Recibo.CodigoRecibo;
|
||||
NumeroPoliza = Recibo.NumeroPoliza;
|
||||
Tomador = Recibo.Tomador;
|
||||
Matricula = Recibo.Matricula;
|
||||
FechaEfecto = Recibo.FechaEfecto;
|
||||
FechaRecepcionCia = Recibo.FechaRecepcionCia;
|
||||
FechaVencimiento = Recibo.FechaVencimiento;
|
||||
Compania = Recibo.Compania;
|
||||
Agente = Recibo.Agente;
|
||||
SubAgente = Recibo.SubAgente;
|
||||
Ramo = Recibo.Ramo;
|
||||
FechaExpedicion = Recibo.FechaExpedicion;
|
||||
BienesAsegurados = Recibo.BienesAsegurados;
|
||||
FechaBaja = Recibo.FechaBaja;
|
||||
CausaBaja = Recibo.CausaBaja;
|
||||
TipoRecibo = Recibo.TipoRecibo;
|
||||
TipoPago = Recibo.TipoPago;
|
||||
Oficina = Recibo.Oficina;
|
||||
PrimaNeta = Recibo.PrimaNeta;
|
||||
BonificacionORecargo = Recibo.BonificacionORecargo;
|
||||
Consorcio = Recibo.Consorcio;
|
||||
Impuesto = Recibo.Impuesto;
|
||||
RecargoExterno = Recibo.RecargoExterno;
|
||||
TotalRecibo = Recibo.TotalRecibo;
|
||||
ComisionReciboPrimaNeta = Recibo.ComisionReciboPrimaNeta;
|
||||
PorcentajeReciboPrimaNeta = Recibo.PorcentajeReciboPrimaNeta;
|
||||
TotalComision = Recibo.TotalComision;
|
||||
PorcentajeComisionAgente = Recibo.PorcentajeComisionAgente;
|
||||
ComisionAgente = Recibo.ComisionAgente;
|
||||
}
|
||||
|
||||
public string CodigoRecibo { get; set; }
|
||||
public string NumeroPoliza { get; set; }
|
||||
public string Tomador { get; set; }
|
||||
public string Matricula { get; set; }
|
||||
public DateOnly FechaEfecto { get; set; }
|
||||
public DateOnly? FechaRecepcionCia { get; set; }
|
||||
public DateOnly FechaVencimiento { get; set; }
|
||||
public string Compania { get; set; }
|
||||
public string Agente { get; set; }
|
||||
public string SubAgente { get; set; }
|
||||
public string Ramo { get; set; }
|
||||
public DateOnly? FechaExpedicion { get; set; }
|
||||
public string BienesAsegurados { get; set; }
|
||||
public DateOnly? FechaBaja { get; set; }
|
||||
public string CausaBaja { get; set; }
|
||||
public string TipoRecibo { get; set; }
|
||||
public string TipoPago { get; set; }
|
||||
public string Oficina { get; set; }
|
||||
public double? PrimaNeta { get; set; }
|
||||
public double? BonificacionORecargo { get; set; }
|
||||
public double? Consorcio { get; set; }
|
||||
public double? Impuesto { get; set; }
|
||||
public double? RecargoExterno { get; set; }
|
||||
public double? TotalRecibo { get; set; }
|
||||
public double? ComisionReciboPrimaNeta { get; set; }
|
||||
public double? PorcentajeReciboPrimaNeta { get; set; }
|
||||
public double? TotalComision { get; set; }
|
||||
public double? PorcentajeComisionAgente { get; set; }
|
||||
public double? ComisionAgente { get; set; }
|
||||
}
|
||||
}
|
||||
11
bdAsegasa/Extensiones/Etiquetas.cs
Normal file
11
bdAsegasa/Extensiones/Etiquetas.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public class Etiquetas
|
||||
{
|
||||
public string? Campo1 { get; set; }
|
||||
public string? Campo2 { get; set; }
|
||||
public string? Campo3 { get; set; }
|
||||
public string? Campo4 { get; set; }
|
||||
public string? Campo5 { get; set; }
|
||||
}
|
||||
}
|
||||
14
bdAsegasa/Extensiones/GrupoLiquidacionCias.cs
Normal file
14
bdAsegasa/Extensiones/GrupoLiquidacionCias.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public class GrupoLiquidacionCias
|
||||
{
|
||||
public double NumeroGeneracion { get; set; }
|
||||
public DateTime FechaGeneracion { get; set; }
|
||||
public List<pagosliquidacionescias> Pagos { get; set; } = new List<pagosliquidacionescias>();
|
||||
public double TotalLiquidacion => Math.Round(Pagos.Sum(x => x.ImportePago), 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
14
bdAsegasa/Extensiones/PagoExtorno.cs
Normal file
14
bdAsegasa/Extensiones/PagoExtorno.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public class PagoExtorno
|
||||
{
|
||||
public double NumeroGeneracion { get; set; }
|
||||
public DateTime FechaGeneracion { get; set; }
|
||||
public List<ve_recibos> Pagos { get; set; } = new List<ve_recibos>();
|
||||
public double TotalLiquidacion => Math.Round(Pagos.Sum(x => (x.TotalRecibo ?? 0) * -1), 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
55
bdAsegasa/Extensiones/accionessiniestros_eiac.cs
Normal file
55
bdAsegasa/Extensiones/accionessiniestros_eiac.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class accionessiniestros_eiac
|
||||
{
|
||||
public enum ClavesAccionSiniestroEnum : int
|
||||
{
|
||||
DOCUMENTACIÓN_O_INFORMACIÓN = 1,
|
||||
JUDICIAL = 2,
|
||||
PERITACIÓN = 3,
|
||||
REPARACIÓN = 4,
|
||||
INDEMNIZACIÓN = 5,
|
||||
DESCONOCIDA = 99
|
||||
}
|
||||
|
||||
public string DescripcionAccionSiniestro
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.AccionSiniestro.HasValue)
|
||||
{
|
||||
return ((ClavesAccionSiniestroEnum)this.AccionSiniestro.Value).ToString().Replace("_", " ");
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum ClavesSituacionAccionEnum : int
|
||||
{
|
||||
PENDIENTE_DE_INICIO = 1,
|
||||
EN_CURSO_DE_EJECUCIÓN_INICIADA = 2,
|
||||
FINALIZADA = 3,
|
||||
DESCONOCIDA = 99
|
||||
}
|
||||
|
||||
public string DescripcionSituacionAccionSiniestro
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.SituacionAccion.HasValue)
|
||||
{
|
||||
return ((ClavesSituacionAccionEnum)this.SituacionAccion.Value).ToString().Replace("_", " ");
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
312
bdAsegasa/Extensiones/agentes.cs
Normal file
312
bdAsegasa/Extensiones/agentes.cs
Normal file
@@ -0,0 +1,312 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using tsUtilidades.Extensiones;
|
||||
using tsUtilidades.Enumeraciones;
|
||||
using System.ComponentModel.DataAnnotations.Schema; // Assuming enums might be here
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class agentes
|
||||
{
|
||||
public string NombreYCodigo
|
||||
{
|
||||
get
|
||||
{
|
||||
return Nombre + " - " + Codigo;
|
||||
}
|
||||
}
|
||||
|
||||
public string CodigoYNombre
|
||||
{
|
||||
get
|
||||
{
|
||||
return Codigo + " - " + Nombre;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual direcciones Direccion
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idDireccion.HasValue && this.idDireccion.Value > 0)
|
||||
{
|
||||
return this.idDireccionNavigation;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _CodigoPostalTmpEsNulo = true;
|
||||
private string _CodigoPostalTmp;
|
||||
public string CodigoPostalTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_CodigoPostalTmpEsNulo)
|
||||
{
|
||||
if (Direccion == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
_CodigoPostalTmp = Direccion.CodigoPostal;
|
||||
_CodigoPostalTmpEsNulo = false;
|
||||
return Direccion.CodigoPostal;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return _CodigoPostalTmp;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
_CodigoPostalTmp = value;
|
||||
_CodigoPostalTmpEsNulo = false;
|
||||
if (Direccion != null)
|
||||
{
|
||||
Direccion.CodigoPostal = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _DomicilioTmpEsNulo = true;
|
||||
private string _DomicilioTmp;
|
||||
public string DomicilioTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_DomicilioTmpEsNulo)
|
||||
{
|
||||
if (Direccion == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
_DomicilioTmp = Direccion.Direccion;
|
||||
_DomicilioTmpEsNulo = false;
|
||||
return Direccion.Direccion;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return _DomicilioTmp;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
_DomicilioTmp = value;
|
||||
_DomicilioTmpEsNulo = false;
|
||||
if (Direccion != null)
|
||||
{
|
||||
Direccion.Direccion = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _CodigoPoblacionTmpEsNulo = true;
|
||||
private string _CodigoPoblacionTmp;
|
||||
public string CodigoPoblacionTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_CodigoPoblacionTmpEsNulo)
|
||||
{
|
||||
if (Direccion == null || Direccion.CodigoMunicipio == null) // In VB it was Direccion.municipios Is Nothing, which usually checks the foreign key or nav property. We use the key or check the DB.
|
||||
{
|
||||
if (Direccion != null && Direccion.CodigoMunicipioNavigation == null) // Try to get navigation property
|
||||
{
|
||||
if ((Direccion.CodigoPostal ?? "") != "")
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
var pob = bd.codigospostales.FirstOrDefault(x => x.CodigoPostal == Direccion.CodigoPostal);
|
||||
if (pob == null)
|
||||
{
|
||||
return "CP.ERRONEO";
|
||||
}
|
||||
else
|
||||
{
|
||||
Direccion.CodigoMunicipio = pob.CodigoMunicipio;
|
||||
_CodigoPoblacionTmp = pob.CodigoMunicipio;
|
||||
_CodigoPoblacionTmpEsNulo = false;
|
||||
return _CodigoPoblacionTmp;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_CodigoPoblacionTmp = Direccion.CodigoMunicipio;
|
||||
_CodigoPoblacionTmpEsNulo = false;
|
||||
return Direccion.CodigoMunicipio;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return _CodigoPoblacionTmp;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
_CodigoPoblacionTmp = value;
|
||||
_CodigoPoblacionTmpEsNulo = false;
|
||||
if (Direccion != null)
|
||||
{
|
||||
Direccion.CodigoMunicipio = value;
|
||||
}
|
||||
ProvinciaTmp = municipios.ObtieneProvincia(_CodigoPoblacionTmp);
|
||||
PoblacionTmp = municipios.ObtienePoblacion(_CodigoPoblacionTmp);
|
||||
}
|
||||
}
|
||||
|
||||
private string _PoblacionTmp;
|
||||
private bool _PoblacionTmpEsNulo = true;
|
||||
public string PoblacionTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_PoblacionTmpEsNulo) _PoblacionTmp = municipios.ObtienePoblacion(CodigoPoblacionTmp);
|
||||
return _PoblacionTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_PoblacionTmp = value;
|
||||
_PoblacionTmpEsNulo = false;
|
||||
}
|
||||
}
|
||||
|
||||
private string _ProvinciaTmp;
|
||||
private bool _ProvinciaTmpEsNulo = true;
|
||||
public string ProvinciaTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_ProvinciaTmpEsNulo) _ProvinciaTmp = municipios.ObtieneProvincia(CodigoPoblacionTmp);
|
||||
return _ProvinciaTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_ProvinciaTmp = value;
|
||||
_ProvinciaTmpEsNulo = false;
|
||||
}
|
||||
}
|
||||
|
||||
public string OficinaAgente
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.Codigo != "000029013008" && (this.Codigo.StartsWith("2") || this.Codigo.StartsWith("000004") || this.Codigo.StartsWith("000018") || this.Codigo.StartsWith("000023") || this.Codigo.StartsWith("000029") || this.Codigo.StartsWith("100029")))
|
||||
{
|
||||
return "Antequera";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Sevilla";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public virtual List<polizassg> PolizasConDocumentosPendientes
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.polizassg.Where(x =>
|
||||
(x.NumeroPoliza != null || x.FechaAceptacionPresupuesto.HasValue) &&
|
||||
(x.FechaDocumentosSuplementoRevisado != null || x.NumeroSuplemento == 0 || x.idAgenteNavigation.Codigo == "1" || x.idAgenteNavigation.Codigo == "2") &&
|
||||
x.documentospolizassg.Any(y => y.Obligatorio && y.FechaComprobacion == null && y.idFichero == null)
|
||||
).ToList();
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual List<polizassg> PolizasConDocumentosPendientes7Dias
|
||||
{
|
||||
get
|
||||
{
|
||||
DateTime FechaInicio = DateTime.Today.AddDays(-7);
|
||||
return this.polizassg.Where(x =>
|
||||
x.FechaBaja.HasValue == false &&
|
||||
(x.NumeroPoliza != null || x.FechaAceptacionPresupuesto != null) &&
|
||||
(x.FechaAlta >= new DateTime(FechaInicio.Year, FechaInicio.Month, FechaInicio.Day) &&
|
||||
(x.FechaDocumentosSuplementoRevisado != null || x.NumeroSuplemento == 0 || x.idAgenteNavigation.Codigo == "1" || x.idAgenteNavigation.Codigo == "2") &&
|
||||
x.documentospolizassg.Any(y => y.FechaComprobacion == null && y.idFichero == null && y.Obligatorio && (y.idDocumentoASolicitarNavigation == null || y.idDocumentoASolicitarNavigation.SolicitarAAgente)))
|
||||
).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CambiaCarteraAgente(string AgenteAnterior, string AgenteNuevo)
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
var idnueage = bd.agentes.First(x => x.Codigo == AgenteNuevo).idAgente;
|
||||
|
||||
var recs = bd.recibos.Where(x => x.liquidacionesagenterecibos.Any() == false && x.idAgenteNavigation.Codigo == AgenteAnterior).ToList();
|
||||
|
||||
int tge = (int)TipoGestionEnum.CAMBIO_CARTERA_AGENTE;
|
||||
|
||||
foreach (var r in recs)
|
||||
{
|
||||
r.idAgente = idnueage;
|
||||
var tg = new gestionesrecibos
|
||||
{
|
||||
idRecibo = r.idRecibo,
|
||||
FormaComunicacion = (int)FormaComunicacionEnum.POR_EMAIL, // Used to be just 4
|
||||
Tipo = tge,
|
||||
GestionesRealizadas = TipoGestionEnum.CAMBIO_CARTERA_AGENTE.ToString().Replace("_", " "),
|
||||
Fecha = DateTime.Now,
|
||||
idCorreo = null,
|
||||
Observaciones = "Cambio Cartera Agente del " + AgenteAnterior + " al " + AgenteNuevo
|
||||
};
|
||||
bd.gestionesrecibos.Add(tg);
|
||||
}
|
||||
bd.SaveChanges();
|
||||
|
||||
var tgp = bd.enumeraciones.First(x => x.Codigo == "TGP.CAMCARAG");
|
||||
var idtgp = tgp.idEnumeracion;
|
||||
|
||||
var pols = bd.polizassg.Where(x => x.idAgenteNavigation.Codigo == AgenteAnterior && x.FechaBaja.HasValue == false);
|
||||
foreach (var p in pols)
|
||||
{
|
||||
p.idAgente = idnueage;
|
||||
var tg = new gestionespolizassg
|
||||
{
|
||||
idPoliza = p.idPoliza,
|
||||
idTipo = idtgp,
|
||||
GestionesRealizadas = tgp.Descripcion,
|
||||
Fecha = DateTime.Now,
|
||||
Observaciones = "Cambio Cartera Agente del " + AgenteAnterior + " al " + AgenteNuevo
|
||||
};
|
||||
bd.gestionespolizassg.Add(tg);
|
||||
}
|
||||
bd.SaveChanges();
|
||||
|
||||
var ageant = bd.agentes.First(x => x.Codigo == AgenteAnterior);
|
||||
bool bbaja;
|
||||
if (ageant.FechaBaja.HasValue == false)
|
||||
{
|
||||
ageant.FechaBaja = new DateOnly(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
|
||||
bbaja = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bbaja = false;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
return bbaja;
|
||||
}
|
||||
}
|
||||
}
|
||||
74
bdAsegasa/Extensiones/amortizacionrecibos.cs
Normal file
74
bdAsegasa/Extensiones/amortizacionrecibos.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class amortizacionrecibos
|
||||
{
|
||||
public string Tomador
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idReciboNavigation != null && this.idReciboNavigation.idPolizaNavigation != null)
|
||||
{
|
||||
return this.idReciboNavigation.idPolizaNavigation.RazonSocialTomadorTmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
public string Compania
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idReciboNavigation != null && this.idReciboNavigation.idPolizaNavigation != null && this.idReciboNavigation.idPolizaNavigation.idCompaniaNavigation != null)
|
||||
{
|
||||
return this.idReciboNavigation.idPolizaNavigation.idCompaniaNavigation.Nombre;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
public string Ramo
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idReciboNavigation != null && this.idReciboNavigation.idPolizaNavigation != null && this.idReciboNavigation.idPolizaNavigation.idRamoNavigation != null)
|
||||
{
|
||||
return this.idReciboNavigation.idPolizaNavigation.idRamoNavigation.Descripcion;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ve_amortizacionrecibos
|
||||
{
|
||||
public int idAmortizacion { get; set; }
|
||||
public int? idRecibo { get; set; }
|
||||
public DateOnly FechaInicioAmortizacion { get; set; }
|
||||
public DateOnly FechaFinAmortizacion { get; set; }
|
||||
public double? PorcentajeAnual { get; set; }
|
||||
public DateOnly? FechaBaja { get; set; }
|
||||
public int? idMotivoBaja { get; set; }
|
||||
public int idEmpresa { get; set; }
|
||||
public string NumeroCuenta { get; set; }
|
||||
public string Observaciones { get; set; }
|
||||
public DateOnly? FechaAlta { get; set; }
|
||||
public string CodigoRecibo { get; set; }
|
||||
public double TotalRecibo { get; set; }
|
||||
public string Ramo { get; set; }
|
||||
public string Compañía { get; set; }
|
||||
public string Tomador { get; set; }
|
||||
public string CIFTomador { get; set; }
|
||||
public string CausaBaja { get; set; }
|
||||
public string Empresa { get; set; }
|
||||
}
|
||||
}
|
||||
136
bdAsegasa/Extensiones/apuntes.cs
Normal file
136
bdAsegasa/Extensiones/apuntes.cs
Normal file
@@ -0,0 +1,136 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using bdAsegasa.dbcontext;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class apuntes
|
||||
{
|
||||
public string NumeroCuentaTmp { get; set; }
|
||||
public double SaldoCuentaTmp { get; set; }
|
||||
public string DescripcionCuentaTmp { get; set; }
|
||||
|
||||
public static void EstableceSaldoTmp(List<apuntes> lap)
|
||||
{
|
||||
double SaldoAnterior = 0;
|
||||
foreach (var ap in lap)
|
||||
{
|
||||
SaldoAnterior = SaldoAnterior + ap.Debe - ap.Haber;
|
||||
ap.SaldoCuentaTmp = SaldoAnterior;
|
||||
}
|
||||
}
|
||||
|
||||
public enum TiposDocumentos
|
||||
{
|
||||
RECIBO = 1,
|
||||
FACTURA = 2,
|
||||
OTRO = 99
|
||||
}
|
||||
|
||||
public static List<Tipo> ListaTiposDocumentos()
|
||||
{
|
||||
var lEstados = new List<Tipo>();
|
||||
foreach (TiposDocumentos Enumeracion in Enum.GetValues(typeof(TiposDocumentos)))
|
||||
{
|
||||
lEstados.Add(new Tipo { id = (int)Enumeracion, Descripcion = Enumeracion.ToString().Replace("_", " ") });
|
||||
}
|
||||
return lEstados;
|
||||
}
|
||||
|
||||
public double DebeAnterior(tscgestionasegasa bd, DateOnly Fecha)
|
||||
{
|
||||
try
|
||||
{
|
||||
var aps = bd.apuntes.Where(X => X.idCuenta == this.idCuenta && X.idAsientoNavigation.Fecha < Fecha).ToList();
|
||||
return aps.Sum(x => x.Debe);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public double HaberAnterior(tscgestionasegasa bd, DateOnly Fecha)
|
||||
{
|
||||
try
|
||||
{
|
||||
var aps = bd.apuntes.Where(X => X.idCuenta == this.idCuenta && X.idAsientoNavigation.Fecha < Fecha).ToList();
|
||||
return aps.Sum(x => x.Haber);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public double Saldo => Math.Round(Debe - Haber, 2);
|
||||
|
||||
private bool? _Conciliado;
|
||||
public bool Conciliado
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Conciliado.HasValue)
|
||||
{
|
||||
return _Conciliado.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ConciliacionActual_TMP != null)
|
||||
{
|
||||
if (ConciliacionActual_TMP.idconciliacion != this.idConciliacion)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.idConciliacion.HasValue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.idConciliacion.HasValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
_Conciliado = value;
|
||||
if (value)
|
||||
{
|
||||
this.idConciliacionNavigation = this.ConciliacionActual_TMP;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.idConciliacion = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual conciliacionesbancarias ConciliacionActual_TMP { get; set; }
|
||||
|
||||
public string ConciliadoEn
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ConciliacionActual_TMP != null && this.idConciliacion.HasValue && this.idConciliacion != ConciliacionActual_TMP.idconciliacion)
|
||||
{
|
||||
return "Nº Conc.: " + this.idConciliacion + " (" + this.idConciliacionNavigation.Año.ToString() + "-" + this.idConciliacionNavigation.Mes.ToString() + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double Diferencia => Debe - Haber;
|
||||
}
|
||||
|
||||
public class Tipo
|
||||
{
|
||||
public int id { get; set; }
|
||||
public string Descripcion { get; set; }
|
||||
}
|
||||
}
|
||||
549
bdAsegasa/Extensiones/asientos.cs
Normal file
549
bdAsegasa/Extensiones/asientos.cs
Normal file
@@ -0,0 +1,549 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using tsUtilidades.Extensiones;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class asientos
|
||||
{
|
||||
public enum TipoAsiento : int
|
||||
{
|
||||
NORMAL = 0,
|
||||
APERTURA = 1,
|
||||
REGULARIZACION = 2
|
||||
}
|
||||
|
||||
public string Cuentas
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.apuntes.Count > 10)
|
||||
{
|
||||
return "** MÁS DE 10 **";
|
||||
}
|
||||
else
|
||||
{
|
||||
string sCuentas = "";
|
||||
foreach (var ap in this.apuntes)
|
||||
{
|
||||
if (ap.idCuentaNavigation != null)
|
||||
{
|
||||
sCuentas += ap.idCuentaNavigation.NumeroCuenta + " ";
|
||||
}
|
||||
}
|
||||
return sCuentas.Trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Documentos
|
||||
{
|
||||
get
|
||||
{
|
||||
string sDocumentos = "";
|
||||
var docs = this.apuntes.ToList()
|
||||
.Where(x => !string.IsNullOrEmpty(x.NumeroDocumento))
|
||||
.GroupBy(x => x.NumeroDocumento);
|
||||
|
||||
foreach (var ap in docs)
|
||||
{
|
||||
sDocumentos += ap.First().NumeroDocumento + " ";
|
||||
}
|
||||
return sDocumentos.Trim();
|
||||
}
|
||||
}
|
||||
|
||||
public string Conceptos
|
||||
{
|
||||
get
|
||||
{
|
||||
string sConceptos = "";
|
||||
var groups = this.apuntes.ToList().GroupBy(x => x.Concepto);
|
||||
foreach (var ap in groups)
|
||||
{
|
||||
sConceptos += ap.First().Concepto + " ";
|
||||
}
|
||||
return sConceptos.Trim();
|
||||
}
|
||||
}
|
||||
|
||||
public int? idAsiento_Nulable
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idAsiento == 0) return null;
|
||||
return this.idAsiento;
|
||||
}
|
||||
}
|
||||
|
||||
public void RellenaCuentaTmp()
|
||||
{
|
||||
foreach (var ap in this.apuntes)
|
||||
{
|
||||
if (ap.idCuentaNavigation != null)
|
||||
{
|
||||
ap.NumeroCuentaTmp = ap.idCuentaNavigation.NumeroCuenta;
|
||||
ap.DescripcionCuentaTmp = ap.idCuentaNavigation.Denominacion;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void GeneraAsientoRecibosContado(tscgestionasegasa bd, List<vf_recibosextendidos> Recibos, Action<string, Exception> DelegadoError)
|
||||
{
|
||||
var hoy = DateOnly.FromDateTime(DateTime.Now);
|
||||
|
||||
var ej = bd.ejercicioscontables.FirstOrDefault(x => x.FechaInicio <= hoy && x.FechaFin >= hoy && !x.FechaCierre.HasValue);
|
||||
|
||||
if (ej == null) ej = bdAsegasa.db.ejercicioscontables.AbreEjercicio(bd, new DateTime(hoy.Year, hoy.Month, hoy.Day));
|
||||
|
||||
var idTiporem = bd.enumeraciones.First(x => x.Codigo == "TIPREM.CO").idEnumeracion;
|
||||
var tipospagos = bd.enumeraciones.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "TIPP").ToList();
|
||||
var idSituacion = bd.enumeraciones.First(x => x.Codigo == "SITR.PA").idEnumeracion;
|
||||
var Cont = bd.enumeraciones.First(x => x.Codigo == "CONT.NUMGEN");
|
||||
var Conceps = bd.conceptosapuntes.ToList();
|
||||
|
||||
if (Cont.ValorNumerico1.HasValue)
|
||||
Cont.ValorNumerico1++;
|
||||
else
|
||||
Cont.ValorNumerico1 = 1;
|
||||
|
||||
var remesa = new remesas();
|
||||
remesa.IBAN = "";
|
||||
remesa.FechaCreacion = DateTime.Now;
|
||||
remesa.Fecha = hoy;
|
||||
remesa.idTipo = idTiporem;
|
||||
|
||||
bd.remesas.Add(remesa);
|
||||
bd.SaveChanges();
|
||||
|
||||
int numgenerados = 0;
|
||||
int numerrores = 0;
|
||||
string sRecibosConErrores = "";
|
||||
List<vf_recibosextendidos> lrg = new List<vf_recibosextendidos>();
|
||||
|
||||
foreach (var recibo in Recibos)
|
||||
{
|
||||
var r = bd.recibos.First(x => x.idRecibo == recibo.idRecibo);
|
||||
try
|
||||
{
|
||||
GeneraAsientoReciboContado(bd, r, tipospagos, Conceps, idSituacion, remesa, (int)Cont.ValorNumerico1.Value);
|
||||
lrg.Add(recibo);
|
||||
numgenerados++;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
sRecibosConErrores += recibo.CodigoRecibo + Environment.NewLine;
|
||||
numerrores++;
|
||||
DelegadoError?.Invoke("GeneraAsientoRecibosContado", ex);
|
||||
}
|
||||
}
|
||||
|
||||
string sDestinatarios = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCONTA").ValorAlfabeticoLargo;
|
||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
byte[] f = null;
|
||||
|
||||
if (lrg.Count > 0)
|
||||
{
|
||||
var lr = lrg.Select(x => new
|
||||
{
|
||||
x.CodigoRecibo,
|
||||
x.NumeroPoliza,
|
||||
x.NumeroSuplemento,
|
||||
x.Tomador,
|
||||
x.BienesAsegurados,
|
||||
x.Ramo,
|
||||
x.Compania
|
||||
}).ToList();
|
||||
// f = tsWPF.Utilidades.Varias.IEnumerableAExcel(lr);
|
||||
// TODO: Implement Excel generation for .NET 8 if needed
|
||||
}
|
||||
|
||||
string sCuerpo = "";
|
||||
if (numgenerados > 0) sCuerpo = "Adjunto le remitimos listado de recibos marcados como remesados (Contado)";
|
||||
if (numerrores > 0)
|
||||
{
|
||||
sCuerpo += Environment.NewLine + "Los siguientes recibos no pudieron ser marcados como remesados correctamente: " + Environment.NewLine + sRecibosConErrores;
|
||||
}
|
||||
|
||||
if (numgenerados > 0)
|
||||
{
|
||||
bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(null, "Se han marcado " + numgenerados.ToString() + " Recibos como remesados (Contado)", sCuerpo, cta, f, "Pagos-" + DateTime.Now.ToString("yyyy-MM-dd") + ".xlsx", "Listado Recibos de con fecha de pago " + DateTime.Now.ToString("yyyy-MM-dd"), sDestinatarios, "", "sevilla@tecnosis.net");
|
||||
}
|
||||
else
|
||||
{
|
||||
bdAsegasa.db.correos.GeneraRegistroCorreo(null, "Los siguientes recibos no pudieron ser marcados como remesados (Contado)", sCuerpo, cta, sDestinatarios, "", "sevilla@tecnosis.net");
|
||||
}
|
||||
}
|
||||
|
||||
public static void GeneraAsientoReciboContado(tscgestionasegasa bd, recibos Recibo, List<enumeraciones> TiposPago, List<conceptosapuntes> Conceptos, int idSituacion, remesas Remesa, int NumeroGeneracion, bool Inverso = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
string Tipp = TiposPago.First(x => x.idEnumeracion == Recibo.idTipoPago).Codigo.Split('.')[1];
|
||||
var ent = Recibo.idPolizaNavigation.EntidadPolizaTomador.idEntidadNavigation;
|
||||
|
||||
var na = new asientos();
|
||||
bd.asientos.Add(na);
|
||||
|
||||
na.Fecha = Inverso ? DateOnly.FromDateTime(DateTime.Now) : Recibo.FechaPago.Value;
|
||||
na.idEjercicio = ejercicioscontables.ObtieneidEjercicioAbierto(new DateTime(na.Fecha.Year, na.Fecha.Month, na.Fecha.Day));
|
||||
na.Tipo = (int)asientos.TipoAsiento.NORMAL;
|
||||
na.FechaIntroduccion = DateTime.Now;
|
||||
if (bdAsegasa.db.Utilidades.dsc.idUsuario > 0) na.idUsuario = bdAsegasa.db.Utilidades.dsc.idUsuario;
|
||||
|
||||
var nap1 = new apuntes();
|
||||
nap1.idAsientoNavigation = na;
|
||||
nap1.Concepto = ent.RazonSocial;
|
||||
nap1.NumeroDocumento = Recibo.idRecibo.ToString();
|
||||
|
||||
string Cta = "";
|
||||
switch (Tipp)
|
||||
{
|
||||
case "PE":
|
||||
if (string.IsNullOrEmpty(ent.CuentaContable)) throw new Exception("La entidad " + ent.RazonSocial + " no tiene asignada una cuenta contable");
|
||||
Cta = ent.CuentaContable;
|
||||
nap1.idConcepto = Conceptos.First(x => x.Codigo == "029").idConcepto;
|
||||
break;
|
||||
case "CO":
|
||||
Cta = Recibo.OficinaAgente.ToUpper() == "SEVILLA" ? "57000000" : "57000002";
|
||||
if (Recibo.TotalRecibo > 0)
|
||||
nap1.idConcepto = Conceptos.First(x => x.Codigo == "015").idConcepto;
|
||||
else
|
||||
nap1.idConcepto = Conceptos.First(x => x.Codigo == "029").idConcepto;
|
||||
break;
|
||||
case "CTA":
|
||||
if (Recibo.TotalRecibo > 0)
|
||||
{
|
||||
Cta = "57000001";
|
||||
nap1.idConcepto = Conceptos.First(x => x.Codigo == "016").idConcepto;
|
||||
}
|
||||
else
|
||||
{
|
||||
Cta = "57200004";
|
||||
nap1.idConcepto = Conceptos.First(x => x.Codigo == "029").idConcepto;
|
||||
}
|
||||
nap1.Concepto = "TRF. " + ent.RazonSocial;
|
||||
break;
|
||||
case "CTR":
|
||||
Cta = "57200004";
|
||||
nap1.idConcepto = Conceptos.First(x => x.Codigo == "015").idConcepto;
|
||||
nap1.Concepto = "TRANS. " + ent.RazonSocial;
|
||||
break;
|
||||
case "CIN":
|
||||
Cta = "57200004";
|
||||
nap1.idConcepto = Conceptos.First(x => x.Codigo == "015").idConcepto;
|
||||
nap1.Concepto = "TPV. " + ent.RazonSocial;
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Tipo de pago " + Tipp + " no soportado");
|
||||
}
|
||||
|
||||
var cuenta = bd.cuentas.FirstOrDefault(x => x.NumeroCuenta == Cta && x.idEjercicio == na.idEjercicio);
|
||||
if (cuenta == null)
|
||||
{
|
||||
var ctaant = bd.cuentas.Where(x => x.NumeroCuenta == Cta).OrderByDescending(x => x.idEjercicioNavigation.FechaInicio).FirstOrDefault();
|
||||
if (ctaant != null) cuenta = bdAsegasa.db.cuentas.CreaCuenta(bd, na.idEjercicio, Cta, ctaant.Denominacion, ctaant.Observaciones);
|
||||
}
|
||||
|
||||
if (cuenta == null) throw new Exception("No existe la cuenta " + Cta + " para el recibo " + Recibo.CodigoRecibo);
|
||||
nap1.idCuentaNavigation = cuenta;
|
||||
|
||||
if (Inverso)
|
||||
{
|
||||
nap1.Haber = (double)Recibo.TotalRecibo.Value;
|
||||
nap1.Debe = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nap1.Haber = 0;
|
||||
nap1.Debe = (double)Recibo.TotalRecibo.Value;
|
||||
}
|
||||
na.apuntes.Add(nap1);
|
||||
|
||||
var nap2 = new apuntes();
|
||||
nap2.idAsientoNavigation = na;
|
||||
string Cta2 = "4400" + Recibo.idPolizaNavigation.idCompaniaNavigation.Codigo;
|
||||
nap2.idCuenta = bd.cuentas.First(x => x.NumeroCuenta == Cta2 && x.idEjercicio == na.idEjercicio).idCuenta;
|
||||
|
||||
if (Inverso)
|
||||
{
|
||||
nap2.Haber = 0;
|
||||
nap2.Debe = Math.Round((double)Recibo.TotalRecibo.Value, 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
else
|
||||
{
|
||||
nap2.Debe = 0;
|
||||
nap2.Haber = Math.Round((double)Recibo.TotalRecibo.Value, 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
nap2.Concepto = ent.RazonSocial;
|
||||
nap2.idConcepto = Conceptos.First(x => x.Codigo == "005").idConcepto;
|
||||
nap2.NumeroDocumento = Recibo.idRecibo.ToString();
|
||||
na.apuntes.Add(nap2);
|
||||
|
||||
na.Importe = na.apuntes.Sum(x => x.Debe);
|
||||
Recibo.idRemesa = Remesa.idRemesa;
|
||||
Recibo.idSituacion = idSituacion;
|
||||
bd.SaveChanges();
|
||||
|
||||
// Logic for amortization
|
||||
if (Tipp == "PE" && nap1.idCuentaNavigation.idEmpresaAmortizacion.HasValue)
|
||||
{
|
||||
if (!Inverso)
|
||||
{
|
||||
var Amr = new amortizacionrecibos();
|
||||
int iUltimoMes = 0;
|
||||
var ud = bd.detallesamortizacionrecibos.Where(x => x.FechaAplicacion.HasValue).OrderByDescending(x => x.FechaAplicacion).FirstOrDefault();
|
||||
if (ud != null) iUltimoMes = ud.Mes;
|
||||
|
||||
int iMesPago = Recibo.FechaPago.Value.Year * 100 + Recibo.FechaPago.Value.Month;
|
||||
if (iUltimoMes >= iMesPago)
|
||||
{
|
||||
Amr.FechaInicioAmortizacion = new DateOnly(iUltimoMes / 100, iUltimoMes % 100, 1).AddMonths(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Amr.FechaInicioAmortizacion = Recibo.FechaPago.Value;
|
||||
}
|
||||
|
||||
Amr.idRecibo = Recibo.idRecibo;
|
||||
Amr.PorcentajeAnual = 100;
|
||||
Amr.idEmpresa = nap1.idCuentaNavigation.idEmpresaAmortizacion.Value;
|
||||
Amr.FechaFinAmortizacion = (new DateOnly(Amr.FechaInicioAmortizacion.Year, Amr.FechaInicioAmortizacion.Month, 1)).AddMonths(12);
|
||||
Amr.NumeroCuenta = nap1.idCuentaNavigation.NumeroCuenta;
|
||||
Amr.FechaAlta = DateOnly.FromDateTime(DateTime.Now);
|
||||
|
||||
DateTime FechaInicial = new DateTime(Amr.FechaInicioAmortizacion.Year, Amr.FechaInicioAmortizacion.Month, 1);
|
||||
for (int i = 0; i <= 11; i++)
|
||||
{
|
||||
var amrd = new detallesamortizacionrecibos();
|
||||
amrd.Mes = FechaInicial.AddMonths(i).Year * 100 + FechaInicial.AddMonths(i).Month;
|
||||
if (i < 11)
|
||||
{
|
||||
amrd.ValorAmortizado = Math.Round(Recibo.TotalRecibo.Value / 12, 2, MidpointRounding.AwayFromZero);
|
||||
amrd.ValorAcumulado = Math.Round(Recibo.TotalRecibo.Value / 12 * (i + 1), 2, MidpointRounding.AwayFromZero);
|
||||
amrd.ValorResidual = Math.Round(Recibo.TotalRecibo.Value - amrd.ValorAcumulado, 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
else
|
||||
{
|
||||
amrd.ValorAmortizado = Math.Round(Recibo.TotalRecibo.Value - Amr.detallesamortizacionrecibos.Sum(x => x.ValorAmortizado), 2, MidpointRounding.AwayFromZero);
|
||||
amrd.ValorAcumulado = Recibo.TotalRecibo.Value;
|
||||
amrd.ValorResidual = 0;
|
||||
}
|
||||
Amr.detallesamortizacionrecibos.Add(amrd);
|
||||
}
|
||||
bd.amortizacionrecibos.Add(Amr);
|
||||
}
|
||||
bd.SaveChanges();
|
||||
|
||||
var apas = new aplicacionesasientos();
|
||||
apas.idAplicacion = Recibo.idRecibo;
|
||||
apas.Tipo = Inverso ? (int)Enums.TipoAplicacionAsientoEnum.RECIBO_BAJA_TIPO_PAGO_PE : (int)Enums.TipoAplicacionAsientoEnum.RECIBO_CONTABILIZACION_PAGO_CONTADO;
|
||||
apas.idAsiento = na.idAsiento;
|
||||
bd.aplicacionesasientos.Add(apas);
|
||||
bd.SaveChanges();
|
||||
}
|
||||
|
||||
// Execute raw SQL if necessary for triggers or legacy compatibility
|
||||
// bd.Database.ExecuteSqlRaw("UPDATE registrosactualizados SET FechaCreacion=Now() where FechaCreacion Is null and NumeroGeneracion={0};", NumeroGeneracion);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static asientos GeneraAsientoReciboPagadoEnCiaYaFacturado(tscgestionasegasa bd, recibos Recibo, int idEjercicio)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ent = Recibo.idPolizaNavigation.EntidadPolizaTomador.idEntidadNavigation;
|
||||
var na = new asientos();
|
||||
bd.asientos.Add(na);
|
||||
|
||||
na.Fecha = DateOnly.FromDateTime(DateTime.Now);
|
||||
na.idEjercicio = idEjercicio;
|
||||
na.Tipo = (int)asientos.TipoAsiento.NORMAL;
|
||||
na.FechaIntroduccion = DateTime.Now;
|
||||
if (bdAsegasa.db.Utilidades.dsc.idUsuario > 0) na.idUsuario = bdAsegasa.db.Utilidades.dsc.idUsuario;
|
||||
|
||||
// Apunte 1: Desfacturacion Client (Haber)
|
||||
var nap1 = new apuntes();
|
||||
nap1.idAsientoNavigation = na;
|
||||
nap1.Concepto = "RECIBO PAGADO EN CIA (DESFACTURACION) " + ent.RazonSocial;
|
||||
nap1.NumeroDocumento = Recibo.idRecibo.ToString();
|
||||
string Cta1 = "4400" + Recibo.idPolizaNavigation.idCompaniaNavigation.Codigo;
|
||||
nap1.idCuentaNavigation = ObtieneCuenta(bd, Cta1, idEjercicio);
|
||||
nap1.Haber = Math.Round((double)Recibo.TotalRecibo.Value, 2, MidpointRounding.AwayFromZero);
|
||||
nap1.Debe = 0;
|
||||
na.apuntes.Add(nap1);
|
||||
|
||||
// Apunte 2: Desfacturacion Company (Debe - NET)
|
||||
var nap2 = new apuntes();
|
||||
nap2.idAsientoNavigation = na;
|
||||
string Cta2 = "4190" + Recibo.idPolizaNavigation.idCompaniaNavigation.Codigo;
|
||||
nap2.idCuentaNavigation = ObtieneCuenta(bd, Cta2, idEjercicio);
|
||||
nap2.Debe = Math.Round((double)(Recibo.TotalRecibo.Value - Recibo.TotalComision.Value), 2, MidpointRounding.AwayFromZero);
|
||||
nap2.Haber = 0;
|
||||
nap2.Concepto = "RECIBO PAGADO EN CIA (DESFACTURACION)" + ent.RazonSocial;
|
||||
nap2.NumeroDocumento = Recibo.idRecibo.ToString();
|
||||
na.apuntes.Add(nap2);
|
||||
|
||||
// Apunte 3: Desfacturacion Commission (Debe)
|
||||
var nap3 = new apuntes();
|
||||
nap3.idAsientoNavigation = na;
|
||||
string Cta3 = "7050" + Recibo.idPolizaNavigation.idCompaniaNavigation.Codigo;
|
||||
nap3.idCuentaNavigation = ObtieneCuenta(bd, Cta3, idEjercicio);
|
||||
nap3.Debe = Math.Round((double)Recibo.TotalComision.Value, 2, MidpointRounding.AwayFromZero);
|
||||
nap3.Haber = 0;
|
||||
nap3.Concepto = "RECIBO PAGADO EN CIA (DESFACTURACION)" + ent.RazonSocial;
|
||||
nap3.NumeroDocumento = Recibo.idRecibo.ToString();
|
||||
na.apuntes.Add(nap3);
|
||||
|
||||
// Apunte 4: Pago en CIA (Debe - COM)
|
||||
var nap4 = new apuntes();
|
||||
nap4.idAsientoNavigation = na;
|
||||
nap4.Concepto = "RECIBO PAGADO EN CIA " + ent.RazonSocial;
|
||||
nap4.NumeroDocumento = Recibo.idRecibo.ToString();
|
||||
nap4.idCuentaNavigation = ObtieneCuenta(bd, Cta2, idEjercicio);
|
||||
nap4.Haber = 0;
|
||||
nap4.Debe = Math.Round((double)Recibo.TotalComision.Value, 2, MidpointRounding.AwayFromZero);
|
||||
na.apuntes.Add(nap4);
|
||||
|
||||
// Apunte 5: Pago en CIA (Haber - COM)
|
||||
var nap5 = new apuntes();
|
||||
nap5.idAsientoNavigation = na;
|
||||
nap5.idCuentaNavigation = ObtieneCuenta(bd, Cta3, idEjercicio);
|
||||
nap5.Debe = 0;
|
||||
nap5.Haber = Math.Round((double)Recibo.TotalComision.Value, 2, MidpointRounding.AwayFromZero);
|
||||
nap5.Concepto = "RECIBO PAGADO EN CIA " + ent.RazonSocial;
|
||||
nap5.NumeroDocumento = Recibo.idRecibo.ToString();
|
||||
na.apuntes.Add(nap5);
|
||||
|
||||
na.Importe = na.apuntes.Sum(x => x.Debe);
|
||||
bd.SaveChanges();
|
||||
|
||||
var apas = new aplicacionesasientos();
|
||||
apas.idAplicacion = Recibo.idRecibo;
|
||||
apas.Tipo = (int)Enums.TipoAplicacionAsientoEnum.RECIBO_PAGADO_EN_CIA;
|
||||
apas.idAsiento = na.idAsiento;
|
||||
bd.aplicacionesasientos.Add(apas);
|
||||
bd.SaveChanges();
|
||||
|
||||
return na;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static asientos GeneraAsientoReciboPagadoEnCia(tscgestionasegasa bd, recibos Recibo)
|
||||
{
|
||||
try
|
||||
{
|
||||
var today = DateOnly.FromDateTime(DateTime.Now);
|
||||
|
||||
var ej = bd.ejercicioscontables.FirstOrDefault(x => x.FechaInicio <= today && x.FechaFin >= today && !x.FechaCierre.HasValue);
|
||||
if (ej == null) ej = bdAsegasa.db.ejercicioscontables.AbreEjercicio(bd, DateTime.Today);
|
||||
|
||||
var ent = Recibo.idPolizaNavigation.EntidadPolizaTomador.idEntidadNavigation;
|
||||
var na = new asientos();
|
||||
bd.asientos.Add(na);
|
||||
|
||||
na.Fecha = today;
|
||||
na.idEjercicio = ej.idEjercicio;
|
||||
na.Tipo = (int)asientos.TipoAsiento.NORMAL;
|
||||
na.FechaIntroduccion = DateTime.Now;
|
||||
if (bdAsegasa.db.Utilidades.dsc.idUsuario > 0) na.idUsuario = bdAsegasa.db.Utilidades.dsc.idUsuario;
|
||||
|
||||
var nap1 = new apuntes();
|
||||
nap1.idAsientoNavigation = na;
|
||||
nap1.Concepto = "RECIBO PAGADO EN CIA " + ent.RazonSocial;
|
||||
nap1.NumeroDocumento = Recibo.idRecibo.ToString();
|
||||
string Cta1 = "4190" + Recibo.idPolizaNavigation.idCompaniaNavigation.Codigo;
|
||||
nap1.idCuentaNavigation = ObtieneCuenta(bd, Cta1, ej.idEjercicio);
|
||||
nap1.Haber = 0;
|
||||
nap1.Debe = Math.Round((double)Recibo.TotalComision.Value, 2, MidpointRounding.AwayFromZero);
|
||||
na.apuntes.Add(nap1);
|
||||
|
||||
var nap2 = new apuntes();
|
||||
nap2.idAsientoNavigation = na;
|
||||
string Cta2 = "7050" + Recibo.idPolizaNavigation.idCompaniaNavigation.Codigo;
|
||||
nap2.idCuentaNavigation = ObtieneCuenta(bd, Cta2, ej.idEjercicio);
|
||||
nap2.Debe = 0;
|
||||
nap2.Haber = Math.Round((double)Recibo.TotalComision.Value, 2, MidpointRounding.AwayFromZero);
|
||||
nap2.Concepto = "RECIBO PAGADO EN CIA " + ent.RazonSocial;
|
||||
nap2.NumeroDocumento = Recibo.idRecibo.ToString();
|
||||
na.apuntes.Add(nap2);
|
||||
|
||||
na.Importe = Math.Round(na.apuntes.Sum(x => x.Debe), 2, MidpointRounding.AwayFromZero);
|
||||
bd.SaveChanges();
|
||||
|
||||
var apas = new aplicacionesasientos();
|
||||
apas.idAplicacion = Recibo.idRecibo;
|
||||
apas.Tipo = (int)Enums.TipoAplicacionAsientoEnum.RECIBO_PAGADO_EN_CIA;
|
||||
apas.idAsiento = na.idAsiento;
|
||||
bd.aplicacionesasientos.Add(apas);
|
||||
bd.SaveChanges();
|
||||
|
||||
return na;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void RefrescaExtensiones()
|
||||
{
|
||||
OnPropertyChanged("EjercicioTmp");
|
||||
OnPropertyChanged("idAsiento_Nulable");
|
||||
}
|
||||
|
||||
public static cuentas ObtieneCuenta(tscgestionasegasa bd, string cta, int idEjercicio)
|
||||
{
|
||||
var cuenta = bd.cuentas.FirstOrDefault(x => x.NumeroCuenta == cta && x.idEjercicio == idEjercicio);
|
||||
if (cuenta == null)
|
||||
{
|
||||
var ctaant = bd.cuentas.Where(x => x.NumeroCuenta == cta).OrderByDescending(x => x.idEjercicioNavigation.FechaInicio).FirstOrDefault();
|
||||
if (ctaant != null) cuenta = bdAsegasa.db.cuentas.CreaCuenta(bd, idEjercicio, cta, ctaant.Denominacion, ctaant.Observaciones);
|
||||
}
|
||||
return cuenta;
|
||||
}
|
||||
|
||||
public bool Punteado
|
||||
{
|
||||
get => FechaPunteo.HasValue;
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
FechaPunteo = DateTime.Now;
|
||||
else
|
||||
FechaPunteo = null;
|
||||
}
|
||||
}
|
||||
|
||||
private string _Ejercicio;
|
||||
public string EjercicioTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(_Ejercicio) && this.idEjercicioNavigation!= null)
|
||||
{
|
||||
_Ejercicio = this.idEjercicioNavigation.Descripcion;
|
||||
}
|
||||
return _Ejercicio;
|
||||
}
|
||||
set
|
||||
{
|
||||
_Ejercicio = value;
|
||||
OnPropertyChanged("EjercicioTmp");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
bdAsegasa/Extensiones/cajas.cs
Normal file
11
bdAsegasa/Extensiones/cajas.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class cajas
|
||||
{
|
||||
public enum TipoCaja
|
||||
{
|
||||
METALICO = 0,
|
||||
BANCO = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
7
bdAsegasa/Extensiones/codigospostales.cs
Normal file
7
bdAsegasa/Extensiones/codigospostales.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class codigospostales
|
||||
{
|
||||
public string NombreMunicipio => !string.IsNullOrEmpty(DescripcionAdicional) ? $"{DescripcionAdicional} ({CodigoMunicipioNavigation?.Nombre})" : (CodigoMunicipioNavigation?.Nombre ?? "");
|
||||
}
|
||||
}
|
||||
7
bdAsegasa/Extensiones/comisionesagentes.cs
Normal file
7
bdAsegasa/Extensiones/comisionesagentes.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class comisionesagentes
|
||||
{
|
||||
public bool AEliminar { get; set; }
|
||||
}
|
||||
}
|
||||
119
bdAsegasa/Extensiones/companias.cs
Normal file
119
bdAsegasa/Extensiones/companias.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using bdAsegasa.dbcontext;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class companias
|
||||
{
|
||||
public direcciones Direccion => (this.idDireccion.HasValue && this.idDireccion.Value > 0) ? this.idDireccionNavigation : null;
|
||||
|
||||
private string _codigoPostalTmp;
|
||||
private bool _codigoPostalTmpEsNulo = true;
|
||||
public string CodigoPostalTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_codigoPostalTmpEsNulo)
|
||||
{
|
||||
_codigoPostalTmp = Direccion?.CodigoPostal ?? "";
|
||||
_codigoPostalTmpEsNulo = false;
|
||||
}
|
||||
return _codigoPostalTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_codigoPostalTmp = value;
|
||||
_codigoPostalTmpEsNulo = false;
|
||||
if (Direccion != null) Direccion.CodigoPostal = value;
|
||||
}
|
||||
}
|
||||
|
||||
private string _domicilioTmp;
|
||||
private bool _domicilioTmpEsNulo = true;
|
||||
public string DomicilioTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_domicilioTmpEsNulo)
|
||||
{
|
||||
_domicilioTmp = Direccion?.Direccion ?? "";
|
||||
_domicilioTmpEsNulo = false;
|
||||
}
|
||||
return _domicilioTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_domicilioTmp = value;
|
||||
_domicilioTmpEsNulo = false;
|
||||
if (Direccion != null) Direccion.Direccion = value;
|
||||
}
|
||||
}
|
||||
|
||||
private string _codigoPoblacionTmp;
|
||||
private bool _codigoPoblacionTmpEsNulo = true;
|
||||
public string CodigoPoblacionTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_codigoPoblacionTmpEsNulo)
|
||||
{
|
||||
if (Direccion == null || Direccion.CodigoMunicipioNavigation == null)
|
||||
{
|
||||
if (Direccion != null && !string.IsNullOrEmpty(Direccion.CodigoPostal))
|
||||
{
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var cp = bd.codigospostales.FirstOrDefault(x => x.CodigoPostal == Direccion.CodigoPostal);
|
||||
if (cp != null)
|
||||
{
|
||||
_codigoPoblacionTmp = cp.CodigoMunicipio;
|
||||
_codigoPoblacionTmpEsNulo = false;
|
||||
return _codigoPoblacionTmp;
|
||||
}
|
||||
return "CP.ERRONEO";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
_codigoPoblacionTmp = Direccion.CodigoMunicipio;
|
||||
_codigoPoblacionTmpEsNulo = false;
|
||||
}
|
||||
}
|
||||
return _codigoPoblacionTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_codigoPoblacionTmp = value;
|
||||
_codigoPoblacionTmpEsNulo = false;
|
||||
if (Direccion != null) Direccion.CodigoMunicipio = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string DescripcionFormaLiquidacion => ((FormaLiquidacionEnum)(this.FormaLiquidacion)).ToString();
|
||||
public string CodigoNombre => $"{this.Codigo} {this.Nombre}";
|
||||
|
||||
public enum FormaLiquidacionEnum
|
||||
{
|
||||
TRANSFERENCIA = 0,
|
||||
RECIBO = 1
|
||||
}
|
||||
|
||||
public static List<FormaLiquidacion> ListadoFormaLiquidacion()
|
||||
{
|
||||
return Enum.GetValues(typeof(FormaLiquidacionEnum))
|
||||
.Cast<FormaLiquidacionEnum>()
|
||||
.Select(e => new FormaLiquidacion { id = (int)e, Descripcion = e.ToString() })
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public class FormaLiquidacion
|
||||
{
|
||||
public int id { get; set; }
|
||||
public string Descripcion { get; set; }
|
||||
}
|
||||
}
|
||||
76
bdAsegasa/Extensiones/conciliacionesbancarias.cs
Normal file
76
bdAsegasa/Extensiones/conciliacionesbancarias.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class conciliacionesbancarias
|
||||
{
|
||||
public double ImporteExtractosConciliados => this.movimientosbancarios.Sum(x => (double)x.Importe);
|
||||
public double ImporteApuntesConciliados => this.apuntes.Sum(x => x.Debe - x.Haber);
|
||||
|
||||
private int? _Año;
|
||||
public int? Año
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Año.HasValue)
|
||||
{
|
||||
return _Año;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.FechaInicio == DateOnly.MinValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.FechaInicio.Year;
|
||||
}
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
_Año = value;
|
||||
if (value.HasValue && Mes.HasValue)
|
||||
{
|
||||
this.FechaInicio = new DateOnly(value.Value, Mes.Value, 1);
|
||||
this.FechaFin = new DateOnly(value.Value, Mes.Value, DateTime.DaysInMonth(value.Value, Mes.Value));
|
||||
}
|
||||
// OnPropertyChanged is handled by Fody/PropertyChanged in the partial class.
|
||||
}
|
||||
}
|
||||
|
||||
private int? _Mes;
|
||||
public int? Mes
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Mes.HasValue)
|
||||
{
|
||||
return _Mes;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.FechaInicio == DateOnly.MinValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.FechaInicio.Month;
|
||||
}
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
_Mes = value;
|
||||
if (value.HasValue && Año.HasValue)
|
||||
{
|
||||
this.FechaInicio = new DateOnly(Año.Value, value.Value, 1);
|
||||
this.FechaFin = new DateOnly(Año.Value, value.Value, DateTime.DaysInMonth(Año.Value, value.Value));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.VisualBasic;
|
||||
using Microsoft.VisualBasic;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
@@ -31,40 +31,57 @@ namespace bdAsegasa.db
|
||||
}
|
||||
}
|
||||
|
||||
public static void GeneraRegistroCorreon(tscgestionasegasa bd, string Asunto, string Cuerpo, bdAsegasa.db.cuentascorreo cuenta, string Destinatario, string ConCopia, string ConCopiaOculta, byte[] FicheroAdjunto = null, string NombreFicheroAdjunto = "", int? idAplicacion = default, string CodigoAplicacion = "", int? idEntidad = default)
|
||||
public static int GeneraRegistroCorreoConAdjunto(tscgestionasegasa bd, string Asunto, string Cuerpo, cuentascorreo cuenta, byte[] Fichero, string NombreFichero, string DescripcionFichero, string Destinatario, string Copia = "", string CopiaOculta = "", bool MarcarComoAnulado = false, string Remitente = "", int? idAplicacion = null, string CodigoAplicacion = "")
|
||||
{
|
||||
int resultado = 0;
|
||||
try
|
||||
{
|
||||
string sRutaAdjunto = "";
|
||||
var correo = new correos()
|
||||
if (bd == null) bd = tscgestionasegasa.NuevoContexto();
|
||||
int idTipoAdjunto = bd.enumeraciones.First(x => x.Codigo == "TIPFIC.ADJCOR").idEnumeracion;
|
||||
|
||||
var f = new ficheros
|
||||
{
|
||||
idTipo = idTipoAdjunto,
|
||||
Descripcion = DescripcionFichero,
|
||||
Fichero = Fichero,
|
||||
NombreFichero = NombreFichero,
|
||||
Fecha = DateTime.Now
|
||||
};
|
||||
bd.ficheros.Add(f);
|
||||
bd.SaveChanges();
|
||||
|
||||
var correo = new correos
|
||||
{
|
||||
Asunto = Asunto,
|
||||
Cuerpo = Cuerpo,
|
||||
Destinatario = Destinatario,
|
||||
Copia = ConCopia,
|
||||
CopiaOculta = ConCopiaOculta,
|
||||
DireccionRespuesta = cuenta.Remitente,
|
||||
Copia = Copia,
|
||||
CopiaOculta = CopiaOculta,
|
||||
DireccionRespuesta = cuenta.ResponderA,
|
||||
FechaCreacion = bd.AhoraMySql(),
|
||||
idcuenta = cuenta.idCuenta,
|
||||
Remitente = cuenta.Remitente,
|
||||
idFicheroAdjunto = f.idFichero,
|
||||
idAplicacion = idAplicacion,
|
||||
CodigoAplicacion = CodigoAplicacion,
|
||||
// idEntidad = idEntidad
|
||||
CodigoAplicacion = CodigoAplicacion
|
||||
};
|
||||
//if (bdAsegasa.db.Utilidades.idUsuario > 0)
|
||||
// correo.idUsuario = bdAsegasa.db.Utilidades.idUsuario;
|
||||
bd.correos.Add(correo);
|
||||
if (FicheroAdjunto is not null)
|
||||
|
||||
if (string.IsNullOrEmpty(Remitente))
|
||||
{
|
||||
var fi = new bdAsegasa.db.ficheros();
|
||||
fi.Descripcion = "Fichero Adjunto Correo";
|
||||
fi.NombreFichero = NombreFicheroAdjunto;
|
||||
fi.Fichero = FicheroAdjunto;
|
||||
fi.Fecha = DateTime.Now;
|
||||
fi.idTipo = bd.enumeraciones.First(x => x.Codigo == "TIPFIC.ADJCOR").idEnumeracion;
|
||||
correo.idFicheroAdjuntoNavigation = fi;
|
||||
correo.Remitente = cuenta.Remitente;
|
||||
}
|
||||
else
|
||||
{
|
||||
correo.Remitente = Remitente;
|
||||
}
|
||||
|
||||
if (MarcarComoAnulado)
|
||||
{
|
||||
correo.FechaAnulacion = DateTime.Now;
|
||||
}
|
||||
|
||||
bd.correos.Add(correo);
|
||||
bd.GuardarCambios();
|
||||
return correo.idcorreo;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -73,5 +90,96 @@ namespace bdAsegasa.db
|
||||
}
|
||||
}
|
||||
|
||||
public static int GeneraRegistroCorreo(tscgestionasegasa bd, string Asunto, string Cuerpo, bdAsegasa.db.cuentascorreo cuenta, string Destinatario, string Copia = "", string CopiaOculta = "", int? idfichero = null, bool MarcarComoAnulado = false, string Remitente = "", string ResponderA = "")
|
||||
{
|
||||
try
|
||||
{
|
||||
if (bd == null) bd = tscgestionasegasa.NuevoContexto();
|
||||
var correo = new correos
|
||||
{
|
||||
Asunto = Asunto,
|
||||
Cuerpo = Cuerpo,
|
||||
Destinatario = Destinatario,
|
||||
Copia = Copia,
|
||||
CopiaOculta = CopiaOculta,
|
||||
FechaCreacion = bd.AhoraMySql(),
|
||||
idcuenta = cuenta.idCuenta,
|
||||
idFicheroAdjunto = idfichero
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(ResponderA))
|
||||
{
|
||||
correo.DireccionRespuesta = ResponderA;
|
||||
}
|
||||
else
|
||||
{
|
||||
correo.DireccionRespuesta = cuenta.ResponderA;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(Remitente))
|
||||
{
|
||||
correo.Remitente = Remitente;
|
||||
}
|
||||
else
|
||||
{
|
||||
correo.Remitente = cuenta.Remitente;
|
||||
}
|
||||
if (MarcarComoAnulado) correo.FechaAnulacion = DateTime.Now;
|
||||
bd.correos.Add(correo);
|
||||
bd.GuardarCambios();
|
||||
return correo.idcorreo;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.Write(ex.Message);
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static int GeneraRegistroCorreoVariosFicheros(tscgestionasegasa bd, string Asunto, string Cuerpo, cuentascorreo cuenta, string Destinatario, System.Collections.Generic.List<int> idficheros = null, DateTime? FechaAnulacion = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var correo = new correos
|
||||
{
|
||||
Asunto = Asunto,
|
||||
Cuerpo = Cuerpo,
|
||||
Destinatario = Destinatario,
|
||||
DireccionRespuesta = cuenta.Remitente,
|
||||
FechaCreacion = bd.AhoraMySql(),
|
||||
idcuenta = cuenta.idCuenta,
|
||||
Remitente = cuenta.Remitente,
|
||||
FechaAnulacion = FechaAnulacion
|
||||
};
|
||||
if (idficheros != null)
|
||||
{
|
||||
foreach (var f in idficheros)
|
||||
{
|
||||
var nf = new ficherosadjuntos { idFichero = f };
|
||||
correo.ficherosadjuntos.Add(nf);
|
||||
}
|
||||
}
|
||||
bd.correos.Add(correo);
|
||||
bd.GuardarCambios();
|
||||
return correo.idcorreo;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Error en GeneraRegistroCorreoVariosFicheros. Asunto:" + Asunto + " " + ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public class CorreoReducido
|
||||
{
|
||||
public int idCorreo { get; set; }
|
||||
public string Destinatario { get; set; }
|
||||
public string Asunto { get; set; }
|
||||
public DateTime FechaCreacion { get; set; }
|
||||
public DateTime? FechaAnulacion { get; set; }
|
||||
public string MensajeError { get; set; }
|
||||
public string Aplicacion { get; set; }
|
||||
public string CodigoAplicacion { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
420
bdAsegasa/Extensiones/cuentas.cs
Normal file
420
bdAsegasa/Extensiones/cuentas.cs
Normal file
@@ -0,0 +1,420 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using tsUtilidades.Extensiones;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class cuentas
|
||||
{
|
||||
public static int LongitudCuentaFinal = 8;
|
||||
public const string CUENTA_PERDIDAS_Y_GANANCIAS = "12900000";
|
||||
|
||||
public virtual List<apuntes> ApuntesTemporales { get; set; }
|
||||
|
||||
public string Descripcion
|
||||
{
|
||||
get { return this.NumeroCuenta + " " + this.Denominacion; }
|
||||
}
|
||||
|
||||
public void RellenaApuntesTemporales(bool IncluirAsientoCierre)
|
||||
{
|
||||
if (this.Nivel == LongitudCuentaFinal)
|
||||
{
|
||||
var apap = this.apuntes.Where(x => x.idAsientoNavigation.Tipo == (int)asientos.TipoAsiento.APERTURA).ToList();
|
||||
if (apap.Count == 0)
|
||||
{
|
||||
this.SaldoInicialTmp = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.SaldoInicialTmp = Math.Round(apap.Sum(x => x.Debe - x.Haber), 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
|
||||
if (IncluirAsientoCierre)
|
||||
{
|
||||
ApuntesTemporales = this.apuntes.Where(x => x.idAsientoNavigation.Tipo != (int)asientos.TipoAsiento.APERTURA).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
ApuntesTemporales = this.apuntes.Where(x => x.idAsientoNavigation.Tipo != (int)asientos.TipoAsiento.APERTURA && x.idAsientoNavigation.Tipo != (int)asientos.TipoAsiento.REGULARIZACION).ToList();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
var apap = bd.apuntes.Where(x => x.idCuentaNavigation.NumeroCuenta.StartsWith(this.NumeroCuenta) && x.idAsientoNavigation.Tipo == (int)asientos.TipoAsiento.APERTURA).ToList();
|
||||
if (apap.Count == 0)
|
||||
{
|
||||
this.SaldoInicialTmp = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.SaldoInicialTmp = Math.Round(apap.Sum(x => x.Debe - x.Haber), 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
|
||||
if (IncluirAsientoCierre)
|
||||
{
|
||||
ApuntesTemporales = bd.apuntes.Where(x => x.idAsientoNavigation.idEjercicio == this.idEjercicio && x.idCuentaNavigation.NumeroCuenta.StartsWith(this.NumeroCuenta) && x.idAsientoNavigation.Tipo != (int)asientos.TipoAsiento.APERTURA).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
ApuntesTemporales = bd.apuntes.Where(x => x.idAsientoNavigation.idEjercicio == this.idEjercicio && x.idCuentaNavigation.NumeroCuenta.StartsWith(this.NumeroCuenta) && x.idAsientoNavigation.Tipo != (int)asientos.TipoAsiento.REGULARIZACION && x.idAsientoNavigation.Tipo != (int)asientos.TipoAsiento.APERTURA).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
if (ApuntesTemporales.Count == 0)
|
||||
{
|
||||
this.SaldoDebeTmp = 0;
|
||||
this.SaldoHaberTmp = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.SaldoDebeTmp = Math.Round(ApuntesTemporales.Sum(x => x.Debe), 2, MidpointRounding.AwayFromZero);
|
||||
this.SaldoHaberTmp = Math.Round(ApuntesTemporales.Sum(x => x.Haber), 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
this.SaldoFinalTmp = this.SaldoInicialTmp + this.SaldoDebeTmp - this.SaldoHaberTmp;
|
||||
}
|
||||
|
||||
public double SaldoInicialTmp { get; set; }
|
||||
public double SaldoDebeTmp { get; set; }
|
||||
public double SaldoHaberTmp { get; set; }
|
||||
public double SaldoFinalTmp { get; set; }
|
||||
|
||||
public static cuentas CreaCuenta(tscgestionasegasa bd, int idEjercicio, string NumeroCuenta, string Descripcion, string Observaciones = "")
|
||||
{
|
||||
var cta = bd.cuentas.FirstOrDefault(x => x.NumeroCuenta == NumeroCuenta && x.idEjercicio == idEjercicio);
|
||||
if (cta == null)
|
||||
{
|
||||
cta = new cuentas();
|
||||
cta.NumeroCuenta = NumeroCuenta;
|
||||
cta.idEjercicio = idEjercicio;
|
||||
cta.Denominacion = Descripcion.Acortar(150);
|
||||
cta.EsCuentaFinal = true;
|
||||
cta.Observaciones = Observaciones;
|
||||
bd.cuentas.Add(cta);
|
||||
bd.SaveChanges();
|
||||
}
|
||||
return cta;
|
||||
}
|
||||
|
||||
public static cuentas CreaCuenta(gestionasegasaEntities bd, DateOnly Fecha, string NumeroCuenta, string Descripcion, string Observaciones = "")
|
||||
{
|
||||
var ej = bd.ejercicioscontables.FirstOrDefault(x => x.FechaInicio <= Fecha && x.FechaFin >= Fecha);
|
||||
if (ej == null) throw new Exception("No existe ningún ejercicio abierto para la fecha " + Fecha.ToString());
|
||||
return CreaCuenta(bd, ej.idEjercicio, NumeroCuenta, Descripcion, Observaciones);
|
||||
}
|
||||
|
||||
public double TotalSaldoAntesCierre
|
||||
{
|
||||
get
|
||||
{
|
||||
var ac = this.idEjercicioNavigation.asientos.FirstOrDefault(x => x.Tipo == (int)asientos.TipoAsiento.REGULARIZACION);
|
||||
if (ac == null)
|
||||
{
|
||||
return TotalSaldo;
|
||||
}
|
||||
else
|
||||
{
|
||||
var tdac = ac.apuntes.Where(x => x.idCuentaNavigation.NumeroCuenta.StartsWith(this.NumeroCuenta)).Sum(x => x.Debe);
|
||||
var thac = ac.apuntes.Where(x => x.idCuentaNavigation.NumeroCuenta.StartsWith(this.NumeroCuenta)).Sum(x => x.Haber);
|
||||
return TotalSaldo - tdac + thac;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Grupo1
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.NumeroCuenta.Length > 1)
|
||||
{
|
||||
string nc = this.NumeroCuenta.Substring(0, 1);
|
||||
return nc + " - " + this.idEjercicioNavigation.cuentas.First(x => x.NumeroCuenta == nc).Denominacion;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public string Grupo2
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.NumeroCuenta.Length > 2)
|
||||
{
|
||||
string nc = this.NumeroCuenta.Substring(0, 2);
|
||||
return nc + " - " + this.idEjercicioNavigation.cuentas.First(x => x.NumeroCuenta == nc).Denominacion;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public string Grupo3
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.NumeroCuenta.Length > 3)
|
||||
{
|
||||
string nc = this.NumeroCuenta.Substring(0, 3);
|
||||
return nc + " - " + this.idEjercicioNavigation.cuentas.First(x => x.NumeroCuenta == nc).Denominacion;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public string Grupo4
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.NumeroCuenta.Length > 4)
|
||||
{
|
||||
string nc = this.NumeroCuenta.Substring(0, 4);
|
||||
return nc + " - " + this.idEjercicioNavigation.cuentas.First(x => x.NumeroCuenta == nc).Denominacion;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private gestionasegasaEntities _bd;
|
||||
public gestionasegasaEntities bd
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_bd == null) _bd = (gestionasegasaEntities?)tscgestionasegasa.NuevoContexto();
|
||||
return _bd;
|
||||
}
|
||||
}
|
||||
|
||||
public cuentas CuentaSuperior1
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.NumeroCuenta.Length == 1) return null;
|
||||
string superior = this.NumeroCuenta.Substring(0, 1);
|
||||
return bd.cuentas.First(x => x.NumeroCuenta == superior && x.idEjercicio == this.idEjercicio);
|
||||
}
|
||||
}
|
||||
|
||||
public cuentas CuentaSuperior2
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.NumeroCuenta.Length < 3) return null;
|
||||
string superior = this.NumeroCuenta.Substring(0, 2);
|
||||
return bd.cuentas.First(x => x.NumeroCuenta == superior && x.idEjercicio == this.idEjercicio);
|
||||
}
|
||||
}
|
||||
|
||||
public cuentas CuentaSuperior3
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.NumeroCuenta.Length < 4) return null;
|
||||
string superior = this.NumeroCuenta.Substring(0, 3);
|
||||
return bd.cuentas.First(x => x.NumeroCuenta == superior && x.idEjercicio == this.idEjercicio);
|
||||
}
|
||||
}
|
||||
|
||||
public cuentas CuentaSuperior4
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.NumeroCuenta.Length < 5) return null;
|
||||
string superior = this.NumeroCuenta.Substring(0, 4);
|
||||
return bd.cuentas.First(x => x.NumeroCuenta == superior && x.idEjercicio == this.idEjercicio);
|
||||
}
|
||||
}
|
||||
|
||||
public int Nivel
|
||||
{
|
||||
get { return this.NumeroCuenta.NothingAVacio().Length; }
|
||||
}
|
||||
|
||||
private vf_cuentas _ValoresExtendidos;
|
||||
public vf_cuentas ValoresExtendidos
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_ValoresExtendidos == null) _ValoresExtendidos = Obtiene_vf_cuenta();
|
||||
return _ValoresExtendidos;
|
||||
}
|
||||
}
|
||||
|
||||
public vf_cuentas Obtiene_vf_cuenta()
|
||||
{
|
||||
try
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
vf_cuentas ct;
|
||||
if (this.Nivel == 8)
|
||||
{
|
||||
ct = bd.vf_cuentas.First(x => x.idCuenta == this.idCuenta);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Nivel == 0)
|
||||
{
|
||||
ct = new vf_cuentas();
|
||||
// Initialize all zero
|
||||
}
|
||||
else
|
||||
{
|
||||
var sumatorio = bd.vf_cuentas.Where(x => x.NumeroCuenta.StartsWith(this.NumeroCuenta) && x.idEjercicio == this.idEjercicio).ToList();
|
||||
ct = new vf_cuentas();
|
||||
ct.idCuenta = this.idCuenta;
|
||||
ct.idEjercicio = this.idEjercicio;
|
||||
ct.Mote = this.Mote;
|
||||
ct.Denominacion = this.Denominacion;
|
||||
ct.idEmpresaAmortizacion = this.idEmpresaAmortizacion;
|
||||
ct.NumeroCuenta = this.NumeroCuenta;
|
||||
ct.Observaciones = this.Observaciones;
|
||||
|
||||
ct.PresupuestoEnero = Math.Round(sumatorio.Sum(x => x.PresupuestoEnero), 2, MidpointRounding.AwayFromZero);
|
||||
ct.PresupuestoFebrero = Math.Round(sumatorio.Sum(x => x.PresupuestoFebrero), 2, MidpointRounding.AwayFromZero);
|
||||
ct.PresupuestoMarzo = Math.Round(sumatorio.Sum(x => x.PresupuestoMarzo), 2, MidpointRounding.AwayFromZero);
|
||||
ct.PresupuestoAbril = Math.Round(sumatorio.Sum(x => x.PresupuestoAbril), 2, MidpointRounding.AwayFromZero);
|
||||
ct.PresupuestoMayo = Math.Round(sumatorio.Sum(x => x.PresupuestoMayo), 2, MidpointRounding.AwayFromZero);
|
||||
ct.PresupuestoJunio = Math.Round(sumatorio.Sum(x => x.PresupuestoJunio), 2, MidpointRounding.AwayFromZero);
|
||||
ct.PresupuestoJulio = Math.Round(sumatorio.Sum(x => x.PresupuestoJulio), 2, MidpointRounding.AwayFromZero);
|
||||
ct.PresupuestoAgosto = Math.Round(sumatorio.Sum(x => x.PresupuestoAgosto), 2, MidpointRounding.AwayFromZero);
|
||||
ct.PresupuestoSeptiembre = Math.Round(sumatorio.Sum(x => x.PresupuestoSeptiembre), 2, MidpointRounding.AwayFromZero);
|
||||
ct.PresupuestoOctubre = Math.Round(sumatorio.Sum(x => x.PresupuestoOctubre), 2, MidpointRounding.AwayFromZero);
|
||||
ct.PresupuestoNoviembre = Math.Round(sumatorio.Sum(x => x.PresupuestoNoviembre), 2, MidpointRounding.AwayFromZero);
|
||||
ct.PresupuestoDiciembre = Math.Round(sumatorio.Sum(x => x.PresupuestoDiciembre), 2, MidpointRounding.AwayFromZero);
|
||||
|
||||
ct.DebeEnero = Math.Round(sumatorio.Sum(x => x.DebeEnero.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.DebeFebrero = Math.Round(sumatorio.Sum(x => x.DebeFebrero.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.DebeMarzo = Math.Round(sumatorio.Sum(x => x.DebeMarzo.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.DebeAbril = Math.Round(sumatorio.Sum(x => x.DebeAbril.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.DebeMayo = Math.Round(sumatorio.Sum(x => x.DebeMayo.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.DebeJunio = Math.Round(sumatorio.Sum(x => x.DebeJunio.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.DebeJulio = Math.Round(sumatorio.Sum(x => x.DebeJulio.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.DebeAgosto = Math.Round(sumatorio.Sum(x => x.DebeAgosto.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.DebeSeptiembre = Math.Round(sumatorio.Sum(x => x.DebeSeptiembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.DebeOctubre = Math.Round(sumatorio.Sum(x => x.DebeOctubre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.DebeNoviembre = Math.Round(sumatorio.Sum(x => x.DebeNoviembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.DebeDiciembre = Math.Round(sumatorio.Sum(x => x.DebeDiciembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
|
||||
ct.HaberEnero = Math.Round(sumatorio.Sum(x => x.HaberEnero.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.HaberFebrero = Math.Round(sumatorio.Sum(x => x.HaberFebrero.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.HaberMarzo = Math.Round(sumatorio.Sum(x => x.HaberMarzo.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.HaberAbril = Math.Round(sumatorio.Sum(x => x.HaberAbril.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.HaberMayo = Math.Round(sumatorio.Sum(x => x.HaberMayo.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.HaberJunio = Math.Round(sumatorio.Sum(x => x.HaberJunio.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.HaberJulio = Math.Round(sumatorio.Sum(x => x.HaberJulio.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.HaberAgosto = Math.Round(sumatorio.Sum(x => x.HaberAgosto.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.HaberSeptiembre = Math.Round(sumatorio.Sum(x => x.HaberSeptiembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.HaberOctubre = Math.Round(sumatorio.Sum(x => x.HaberOctubre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.HaberNoviembre = Math.Round(sumatorio.Sum(x => x.HaberNoviembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
ct.HaberDiciembre = Math.Round(sumatorio.Sum(x => x.HaberDiciembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
|
||||
ct.TotalDebe = Math.Round(sumatorio.Sum(x => x.TotalDebe), 2, MidpointRounding.AwayFromZero);
|
||||
ct.TotalHaber = Math.Round(sumatorio.Sum(x => x.TotalHaber), 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
|
||||
if (Nivel > 0)
|
||||
{
|
||||
var cta1 = bd.cuentas.First(x => x.NumeroCuenta == ct.NumeroCuenta.Substring(0, 1) && x.idEjercicio == this.idEjercicio);
|
||||
ct.Grupo1 = cta1.NumeroCuenta + " " + cta1.Denominacion;
|
||||
if (ct.Nivel > 1)
|
||||
{
|
||||
var cta2 = bd.cuentas.First(x => x.NumeroCuenta == ct.NumeroCuenta.Substring(0, 2) && x.idEjercicio == this.idEjercicio);
|
||||
ct.Grupo2 = cta2.NumeroCuenta + " " + cta2.Denominacion;
|
||||
if (ct.Nivel > 2)
|
||||
{
|
||||
var cta3 = bd.cuentas.First(x => x.NumeroCuenta == ct.NumeroCuenta.Substring(0, 3) && x.idEjercicio == this.idEjercicio);
|
||||
ct.Grupo3 = cta3.NumeroCuenta + " " + cta3.Denominacion;
|
||||
if (ct.Nivel > 3)
|
||||
{
|
||||
var cta4 = bd.cuentas.First(x => x.NumeroCuenta == ct.NumeroCuenta.Substring(0, 4) && x.idEjercicio == this.idEjercicio);
|
||||
ct.Grupo4 = cta4.NumeroCuenta + " " + cta4.Denominacion;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ct;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
#region Saldos
|
||||
public double SaldoEnero => ValoresExtendidos.SaldoEnero;
|
||||
public double SaldoFebrero => ValoresExtendidos.SaldoFebrero;
|
||||
public double SaldoMarzo => ValoresExtendidos.SaldoMarzo;
|
||||
public double SaldoAbril => ValoresExtendidos.SaldoAbril;
|
||||
public double SaldoMayo => ValoresExtendidos.SaldoMayo;
|
||||
public double SaldoJunio => ValoresExtendidos.SaldoJunio;
|
||||
public double SaldoJulio => ValoresExtendidos.SaldoJulio;
|
||||
public double SaldoAgosto => ValoresExtendidos.SaldoAgosto;
|
||||
public double SaldoSeptiembre => ValoresExtendidos.SaldoSeptiembre;
|
||||
public double SaldoOctubre => ValoresExtendidos.SaldoOctubre;
|
||||
public double SaldoNoviembre => ValoresExtendidos.SaldoNoviembre;
|
||||
public double SaldoDiciembre => ValoresExtendidos.SaldoDiciembre;
|
||||
public double TotalSaldo => ValoresExtendidos.TotalSaldo;
|
||||
#endregion
|
||||
|
||||
#region Presupuestos
|
||||
public double TotalPresupuestado
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Round(PresupuestoEnero + PresupuestoFebrero + PresupuestoMarzo + PresupuestoAbril + PresupuestoMayo + PresupuestoJunio + PresupuestoJulio + PresupuestoAgosto + PresupuestoSeptiembre + PresupuestoOctubre + PresupuestoNoviembre + PresupuestoDiciembre, 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
public void ActualizaTotalPresupuestado() => OnPropertyChanged("TotalPresupuestado");
|
||||
|
||||
public double DesvioPresupuestoEnero => ValoresExtendidos.DesvioPresupuestoEnero;
|
||||
public double DesvioPresupuestoFebrero => ValoresExtendidos.DesvioPresupuestoFebrero;
|
||||
public double DesvioPresupuestoMarzo => ValoresExtendidos.DesvioPresupuestoMarzo;
|
||||
public double DesvioPresupuestoAbril => ValoresExtendidos.DesvioPresupuestoAbril;
|
||||
public double DesvioPresupuestoMayo => ValoresExtendidos.DesvioPresupuestoMayo;
|
||||
public double DesvioPresupuestoJunio => ValoresExtendidos.DesvioPresupuestoJunio;
|
||||
public double DesvioPresupuestoJulio => ValoresExtendidos.DesvioPresupuestoJulio;
|
||||
public double DesvioPresupuestoAgosto => ValoresExtendidos.DesvioPresupuestoAgosto;
|
||||
public double DesvioPresupuestoSeptiembre => ValoresExtendidos.DesvioPresupuestoSeptiembre;
|
||||
public double DesvioPresupuestoOctubre => ValoresExtendidos.DesvioPresupuestoOctubre;
|
||||
public double DesvioPresupuestoNoviembre => ValoresExtendidos.DesvioPresupuestoNoviembre;
|
||||
public double DesvioPresupuestoDiciembre => ValoresExtendidos.DesvioPresupuestoDiciembre;
|
||||
public double DesvioPresupuestoTotal => ValoresExtendidos.DesvioPresupuestoTotal;
|
||||
|
||||
public double PorcentajeDesvioPresupuestoEnero => ValoresExtendidos.PorcentajeDesvioPresupuestoEnero;
|
||||
public double PorcentajeDesvioPresupuestoFebrero => ValoresExtendidos.PorcentajeDesvioPresupuestoFebrero;
|
||||
public double PorcentajeDesvioPresupuestoMarzo => ValoresExtendidos.PorcentajeDesvioPresupuestoMarzo;
|
||||
public double PorcentajeDesvioPresupuestoAbril => ValoresExtendidos.PorcentajeDesvioPresupuestoAbril;
|
||||
public double PorcentajeDesvioPresupuestoMayo => ValoresExtendidos.PorcentajeDesvioPresupuestoMayo;
|
||||
public double PorcentajeDesvioPresupuestoJunio => ValoresExtendidos.PorcentajeDesvioPresupuestoJunio;
|
||||
public double PorcentajeDesvioPresupuestoJulio => ValoresExtendidos.PorcentajeDesvioPresupuestoJulio;
|
||||
public double PorcentajeDesvioPresupuestoAgosto => ValoresExtendidos.PorcentajeDesvioPresupuestoAgosto;
|
||||
public double PorcentajeDesvioPresupuestoSeptiembre => ValoresExtendidos.PorcentajeDesvioPresupuestoSeptiembre;
|
||||
public double PorcentajeDesvioPresupuestoOctubre => ValoresExtendidos.PorcentajeDesvioPresupuestoOctubre;
|
||||
public double PorcentajeDesvioPresupuestoNoviembre => ValoresExtendidos.PorcentajeDesvioPresupuestoNoviembre;
|
||||
public double PorcentajeDesvioPresupuestoDiciembre => ValoresExtendidos.PorcentajeDesvioPresupuestoDiciembre;
|
||||
public double PorcentajeDesvioPresupuestoTotal => ValoresExtendidos.PorcentajeDesvioPresupuestoTotal;
|
||||
#endregion
|
||||
|
||||
public static List<GrupoCuenta> ListadoGruposCuentas()
|
||||
{
|
||||
return new List<GrupoCuenta>
|
||||
{
|
||||
new GrupoCuenta { Nivel = 1, Descripcion = "GRUPO INICIAL 1 DÍGITO" },
|
||||
new GrupoCuenta { Nivel = 2, Descripcion = "GRUPO INTERMEDIO 2 DÍGITOS" },
|
||||
new GrupoCuenta { Nivel = 3, Descripcion = "GRUPO INTERMEDIO 3 DÍGITOS" },
|
||||
new GrupoCuenta { Nivel = 4, Descripcion = "GRUPO INTERMEDIO 4 DÍGITOS" },
|
||||
new GrupoCuenta { Nivel = 8, Descripcion = "GRUPO FINAL 8 DÍGITOS" }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class GrupoCuenta
|
||||
{
|
||||
public int Nivel { get; set; }
|
||||
public string Descripcion { get; set; }
|
||||
}
|
||||
}
|
||||
54
bdAsegasa/Extensiones/detallesamortizacionrecibos.cs
Normal file
54
bdAsegasa/Extensiones/detallesamortizacionrecibos.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class detallesamortizacionrecibos
|
||||
{
|
||||
public string MesFecha
|
||||
{
|
||||
get
|
||||
{
|
||||
string mesStr = this.Mes.ToString();
|
||||
return mesStr.Substring(0, 4) + "/" + mesStr.Substring(4, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ve_detallesamortizacionrecibos
|
||||
{
|
||||
public int idDetalle { get; set; }
|
||||
public int idAmortizacion { get; set; }
|
||||
public int? idRecibo { get; set; }
|
||||
public DateOnly FechaInicioAmortizacion { get; set; }
|
||||
public DateOnly FechaFinAmortizacion { get; set; }
|
||||
public double PorcentajeAnual { get; set; }
|
||||
public DateOnly? FechaBaja { get; set; }
|
||||
public int? idMotivoBaja { get; set; }
|
||||
public int idEmpresa { get; set; }
|
||||
public string NumeroCuenta { get; set; }
|
||||
public string Observaciones { get; set; }
|
||||
public DateOnly? FechaAlta { get; set; }
|
||||
public string CodigoRecibo { get; set; }
|
||||
public DateOnly FechaEfecto { get; set; }
|
||||
public double TotalRecibo { get; set; }
|
||||
public string Ramo { get; set; }
|
||||
public string Compañía { get; set; }
|
||||
public string Tomador { get; set; }
|
||||
public string CIFTomador { get; set; }
|
||||
public string CausaBaja { get; set; }
|
||||
public string Empresa { get; set; }
|
||||
public double ValorAmortizado { get; set; }
|
||||
public double ValorAcumulado { get; set; }
|
||||
public double ValorResidual { get; set; }
|
||||
public int Mes { get; set; }
|
||||
public DateTime? FechaAplicacion { get; set; }
|
||||
public string MesFecha
|
||||
{
|
||||
get
|
||||
{
|
||||
string mesStr = this.Mes.ToString();
|
||||
return mesStr.Substring(0, 4) + "/" + mesStr.Substring(4, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
10
bdAsegasa/Extensiones/direcciones.cs
Normal file
10
bdAsegasa/Extensiones/direcciones.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class direcciones
|
||||
{
|
||||
// Note: municipios.ObtienePoblacion and ObtieneProvincia should be implemented in municipios extension.
|
||||
// For now, assuming they are available or using the navigation.
|
||||
public string PoblacionTmp => CodigoMunicipioNavigation?.Nombre ?? "";
|
||||
public string ProvinciaTmp => CodigoMunicipioNavigation?.CodigoProvinciaNavigation?.Nombre ?? "";
|
||||
}
|
||||
}
|
||||
7
bdAsegasa/Extensiones/documentosasolicitar.cs
Normal file
7
bdAsegasa/Extensiones/documentosasolicitar.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class documentosasolicitar
|
||||
{
|
||||
public bool ElementoComprobado { get; set; }
|
||||
}
|
||||
}
|
||||
71
bdAsegasa/Extensiones/documentospolizassg.cs
Normal file
71
bdAsegasa/Extensiones/documentospolizassg.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using bdAsegasa.dbcontext;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class documentospolizassg
|
||||
{
|
||||
public bool DocumentoComprobado
|
||||
{
|
||||
get => this.FechaComprobacion.HasValue;
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
this.FechaComprobacion = DateTime.Now;
|
||||
this.idUsuarioComprueba = Utilidades.dsc.idUsuario;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.FechaComprobacion = null;
|
||||
this.idUsuarioComprueba = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void GeneraDocumentosASolicitar(tscgestionasegasa bd, polizassg poliza, List<int> idDocsASolicitar = null)
|
||||
{
|
||||
List<documentosasolicitar> das;
|
||||
if (idDocsASolicitar != null)
|
||||
{
|
||||
das = bd.documentosasolicitar.Where(x => idDocsASolicitar.Contains(x.idDocumento)).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
das = bd.documentosasolicitar.Where(x => x.idRamo == poliza.idRamo).ToList();
|
||||
}
|
||||
|
||||
var enumDomiciliacion = bd.enumeraciones.FirstOrDefault(x => x.Codigo == "TIPP.BA");
|
||||
int idDomiciliacion = enumDomiciliacion?.idEnumeracion ?? -1;
|
||||
|
||||
foreach (var d in das)
|
||||
{
|
||||
var dp = new documentospolizassg();
|
||||
poliza.documentospolizassg.Add(dp);
|
||||
dp.Descripcion = d.idRamoNavigation?.Descripcion;
|
||||
dp.idDocumentoASolicitar = d.idDocumento;
|
||||
dp.Obligatorio = d.Obligatorio;
|
||||
dp.Fecha = DateTime.Now;
|
||||
|
||||
if (d.idRamoNavigation?.Codigo == "DOCRAM.MDTO" && poliza.idTipoPago != idDomiciliacion)
|
||||
{
|
||||
dp.Obligatorio = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string DescripcionTipo => ((TipoDocumentoEnum)(this.Tipo)).ToString().Replace("_", " ");
|
||||
|
||||
public enum TipoDocumentoEnum : int
|
||||
{
|
||||
DESCONOCIDO = 0,
|
||||
PÓLIZA = 1,
|
||||
CARTA_SUPLEMENTO = 2,
|
||||
CERTIFICADO_SEGURO = 3,
|
||||
RECIBO = 10,
|
||||
OTROS = 100
|
||||
}
|
||||
}
|
||||
}
|
||||
115
bdAsegasa/Extensiones/ejercicioscontables.cs
Normal file
115
bdAsegasa/Extensiones/ejercicioscontables.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using bdAsegasa.dbcontext;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class ejercicioscontables
|
||||
{
|
||||
public static int ObtieneidEjercicioAbierto(DateTime fecha)
|
||||
{
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var ej = bd.ejercicioscontables.FirstOrDefault(x => x.FechaInicio <= DateOnly.FromDateTime(fecha) && x.FechaFin >= DateOnly.FromDateTime(fecha) && x.FechaCierre == null);
|
||||
if (ej == null)
|
||||
{
|
||||
ej = bd.ejercicioscontables.FirstOrDefault(x => x.FechaInicio <= DateOnly.FromDateTime(fecha) && x.FechaFin >= DateOnly.FromDateTime(fecha) && x.FechaCierre != null);
|
||||
if (ej == null)
|
||||
{
|
||||
if (Math.Abs((DateTime.Today - fecha).TotalDays) > 365)
|
||||
{
|
||||
throw new Exception("La fecha del ejercicio " + fecha.ToShortDateString() + " parece incorrecta");
|
||||
}
|
||||
else
|
||||
{
|
||||
return AbreEjercicio(bd, fecha).idEjercicio;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("El ejercicio está cerrado");
|
||||
}
|
||||
}
|
||||
return ej.idEjercicio;
|
||||
}
|
||||
}
|
||||
|
||||
public string DescripcionExtendida
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.FechaInicio.Month == 1 && this.FechaInicio.Day == 1 && this.FechaFin.Month == 12 && this.FechaFin.Day == 31)
|
||||
{
|
||||
return $"{this.idEmpresaNavigation?.RazonSocial} {this.FechaInicio.Year}";
|
||||
}
|
||||
return $"{this.idEmpresaNavigation?.RazonSocial} {this.FechaInicio} {this.FechaFin}";
|
||||
}
|
||||
}
|
||||
|
||||
public void CopiaCuentas(tscgestionasegasa bd)
|
||||
{
|
||||
var ea = bd.ejercicioscontables
|
||||
.Where(x => x.FechaInicio < this.FechaInicio)
|
||||
.OrderByDescending(x => x.FechaInicio)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (ea != null)
|
||||
{
|
||||
var ctas = bd.cuentas.Where(x => x.idEjercicio == ea.idEjercicio).ToList();
|
||||
foreach (var cta in ctas.OrderBy(x => x.NumeroCuenta.Length))
|
||||
{
|
||||
if (!bd.cuentas.Any(x => x.idEjercicio == this.idEjercicio && x.NumeroCuenta == cta.NumeroCuenta))
|
||||
{
|
||||
var nc = new cuentas
|
||||
{
|
||||
Denominacion = cta.Denominacion,
|
||||
EsCuentaFinal = cta.EsCuentaFinal,
|
||||
Mote = cta.Mote,
|
||||
Observaciones = cta.Observaciones,
|
||||
NumeroCuenta = cta.NumeroCuenta,
|
||||
idEjercicio = this.idEjercicio,
|
||||
idEmpresaAmortizacion = cta.idEmpresaAmortizacion,
|
||||
PresupuestoEnero = cta.PresupuestoEnero,
|
||||
PresupuestoFebrero = cta.PresupuestoFebrero,
|
||||
PresupuestoMarzo = cta.PresupuestoMarzo,
|
||||
PresupuestoAbril = cta.PresupuestoAbril,
|
||||
PresupuestoMayo = cta.PresupuestoMayo,
|
||||
PresupuestoJunio = cta.PresupuestoJunio,
|
||||
PresupuestoJulio = cta.PresupuestoJulio,
|
||||
PresupuestoAgosto = cta.PresupuestoAgosto,
|
||||
PresupuestoSeptiembre = cta.PresupuestoSeptiembre,
|
||||
PresupuestoOctubre = cta.PresupuestoOctubre,
|
||||
PresupuestoNoviembre = cta.PresupuestoNoviembre,
|
||||
PresupuestoDiciembre = cta.PresupuestoDiciembre
|
||||
};
|
||||
bd.cuentas.Add(nc);
|
||||
}
|
||||
}
|
||||
bd.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static ejercicioscontables AbreEjercicio(tscgestionasegasa bd, DateTime fecha)
|
||||
{
|
||||
var ej = new ejercicioscontables
|
||||
{
|
||||
FechaApertura = DateOnly.FromDateTime(DateTime.Now),
|
||||
FechaInicio = new DateOnly(fecha.Year, 1, 1),
|
||||
FechaFin = new DateOnly(fecha.Year, 12, 31),
|
||||
Descripcion = fecha.Year.ToString()
|
||||
};
|
||||
bd.ejercicioscontables.Add(ej);
|
||||
bd.SaveChanges();
|
||||
ej.CopiaCuentas(bd);
|
||||
return ej;
|
||||
}
|
||||
|
||||
public static bool CompruebaEjereciciosAbiertos(tscgestionasegasa bd, List<DateTime> fechas)
|
||||
{
|
||||
var ejeabiertos = bd.ejercicioscontables.Where(x => x.FechaCierre == null).ToList();
|
||||
return fechas.All(f => ejeabiertos.Any(e => e.FechaInicio <= DateOnly.FromDateTime(f) && e.FechaFin >= DateOnly.FromDateTime(f)));
|
||||
}
|
||||
}
|
||||
}
|
||||
331
bdAsegasa/Extensiones/entidades.cs
Normal file
331
bdAsegasa/Extensiones/entidades.cs
Normal file
@@ -0,0 +1,331 @@
|
||||
using bdAsegasa.dbcontext;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class entidades : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected virtual void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
|
||||
public bool UltimoReciboDevueltoFaltaPago(string codigoRamo)
|
||||
{
|
||||
if (this.idEntidad == 0) return false;
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var ramo = bd.ramos.FirstOrDefault(x => x.Codigo == codigoRamo);
|
||||
if (ramo == null) return false;
|
||||
|
||||
var idfp = bd.enumeraciones.FirstOrDefault(x => x.Codigo == "CABA.FP")?.idEnumeracion;
|
||||
if (!idfp.HasValue) return false;
|
||||
|
||||
var rec = bd.entidadespolizas
|
||||
.Where(x => x.idEntidad == this.idEntidad)
|
||||
.Select(x => x.idPolizaNavigation)
|
||||
.Where(x => x.idRamo == ramo.idRamo)
|
||||
.SelectMany(x => x.recibos)
|
||||
.OrderByDescending(x => x.FechaEfecto)
|
||||
.FirstOrDefault();
|
||||
|
||||
return rec?.idCausaBaja == idfp;
|
||||
}
|
||||
}
|
||||
|
||||
public string Sexo => this.idSexoNavigation?.Descripcion ?? "* Desconocido *";
|
||||
|
||||
public direcciones DireccionPrincipal
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idDireccionPrincipal.HasValue && this.idDireccionPrincipal.Value > 0)
|
||||
{
|
||||
return this.direcciones.FirstOrDefault(x => x.idDireccion == this.idDireccionPrincipal.Value);
|
||||
}
|
||||
var correo = this.direcciones.FirstOrDefault(x => x.idTipoNavigation?.Codigo == "TIPDIR.CORREO");
|
||||
return correo ?? this.direcciones.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
private string _codigoPostalTmp;
|
||||
private bool _codigoPostalTmpEsNulo = true;
|
||||
public string CodigoPostalTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_codigoPostalTmpEsNulo)
|
||||
{
|
||||
_codigoPostalTmp = DireccionPrincipal?.CodigoPostal ?? "";
|
||||
_codigoPostalTmpEsNulo = false;
|
||||
}
|
||||
return _codigoPostalTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_codigoPostalTmp = value;
|
||||
_codigoPostalTmpEsNulo = false;
|
||||
if (DireccionPrincipal != null) DireccionPrincipal.CodigoPostal = value;
|
||||
OnPropertyChanged(nameof(CodigoPostalTmp));
|
||||
}
|
||||
}
|
||||
|
||||
private string _domicilioTmp;
|
||||
private bool _domicilioTmpEsNulo = true;
|
||||
public string DomicilioTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_domicilioTmpEsNulo)
|
||||
{
|
||||
_domicilioTmp = DireccionPrincipal?.Direccion ?? "";
|
||||
_domicilioTmpEsNulo = false;
|
||||
}
|
||||
return _domicilioTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_domicilioTmp = value;
|
||||
_domicilioTmpEsNulo = false;
|
||||
if (DireccionPrincipal != null) DireccionPrincipal.Direccion = value;
|
||||
OnPropertyChanged(nameof(DomicilioTmp));
|
||||
}
|
||||
}
|
||||
|
||||
private string _codigoPoblacionTmp;
|
||||
private bool _codigoPoblacionTmpEsNulo = true;
|
||||
public string CodigoPoblacionTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_codigoPoblacionTmpEsNulo)
|
||||
{
|
||||
if (DireccionPrincipal == null || DireccionPrincipal.CodigoMunicipioNavigation == null)
|
||||
{
|
||||
if (DireccionPrincipal != null && DireccionPrincipal.CodigoMunicipioNavigation == null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(DireccionPrincipal.CodigoPostal))
|
||||
{
|
||||
using var bd = bdAsegasa.tscgestionasegasa.NuevoContexto();
|
||||
var pob = bd.codigospostales.FirstOrDefault(x => x.CodigoPostal == DireccionPrincipal.CodigoPostal);
|
||||
if (pob == null)
|
||||
{
|
||||
return "CP.ERRONEO";
|
||||
}
|
||||
else
|
||||
{
|
||||
DireccionPrincipal.CodigoMunicipio = pob.CodigoMunicipio;
|
||||
_codigoPoblacionTmp = pob.CodigoMunicipio;
|
||||
_codigoPoblacionTmpEsNulo = false;
|
||||
return _codigoPoblacionTmp;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_codigoPoblacionTmp = DireccionPrincipal.CodigoMunicipio;
|
||||
_codigoPoblacionTmpEsNulo = false;
|
||||
return DireccionPrincipal.CodigoMunicipio;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return _codigoPoblacionTmp;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
_codigoPoblacionTmp = value;
|
||||
_codigoPoblacionTmpEsNulo = false;
|
||||
if (DireccionPrincipal != null) DireccionPrincipal.CodigoMunicipio = value;
|
||||
OnPropertyChanged(nameof(CodigoPoblacionTmp));
|
||||
|
||||
using var bd = bdAsegasa.tscgestionasegasa.NuevoContexto();
|
||||
var mun = bd.municipios.FirstOrDefault(x => x.CodigoMunicipio == _codigoPoblacionTmp);
|
||||
ProvinciaTmp = mun?.CodigoProvinciaNavigation?.Nombre ?? "";
|
||||
PoblacionTmp = mun?.Nombre ?? "";
|
||||
}
|
||||
}
|
||||
|
||||
private string _poblacionTmp;
|
||||
private bool _poblacionTmpEsNulo = true;
|
||||
public string PoblacionTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_poblacionTmpEsNulo)
|
||||
{
|
||||
using var bd = bdAsegasa.tscgestionasegasa.NuevoContexto();
|
||||
var mun = bd.municipios.FirstOrDefault(x => x.CodigoMunicipio == CodigoPoblacionTmp);
|
||||
_poblacionTmp = mun?.Nombre ?? "";
|
||||
_poblacionTmpEsNulo = false;
|
||||
}
|
||||
return _poblacionTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_poblacionTmp = value;
|
||||
_poblacionTmpEsNulo = false;
|
||||
OnPropertyChanged(nameof(PoblacionTmp));
|
||||
}
|
||||
}
|
||||
|
||||
private string _provinciaTmp;
|
||||
private bool _provinciaTmpEsNulo = true;
|
||||
public string ProvinciaTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_provinciaTmpEsNulo)
|
||||
{
|
||||
using var bd = bdAsegasa.tscgestionasegasa.NuevoContexto();
|
||||
var mun = bd.municipios.FirstOrDefault(x => x.CodigoMunicipio == CodigoPoblacionTmp);
|
||||
_provinciaTmp = mun?.CodigoProvinciaNavigation?.Nombre ?? "";
|
||||
_provinciaTmpEsNulo = false;
|
||||
}
|
||||
return _provinciaTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_provinciaTmp = value;
|
||||
_provinciaTmpEsNulo = false;
|
||||
OnPropertyChanged(nameof(ProvinciaTmp));
|
||||
}
|
||||
}
|
||||
|
||||
public string FechaNacimientoSinHora => this.FechaNacimiento?.ToString("dd/MM/yyyy") ?? "";
|
||||
public string FechaExpCarnetSinHora => this.FechaExpedicionCarnet?.ToString("dd/MM/yyyy") ?? "";
|
||||
|
||||
public static void GuardandoCambios(tscgestionasegasa bd, string aplicacion)
|
||||
{
|
||||
var modifiedEnts = bd.ChangeTracker.Entries<entidades>()
|
||||
.Where(e => e.State == Microsoft.EntityFrameworkCore.EntityState.Modified);
|
||||
|
||||
foreach (var entry in modifiedEnts)
|
||||
{
|
||||
var ent = entry.Entity;
|
||||
if (!string.IsNullOrEmpty(ent.CIF))
|
||||
{
|
||||
ent.CIF = Regex.Replace(ent.CIF, "[^a-zA-Z0-9]", "").ToUpper();
|
||||
}
|
||||
// Legacy logging logic can be implemented here if needed
|
||||
}
|
||||
}
|
||||
|
||||
public virtual List<EntidadRelacionada> RelacionesEntreEntidades
|
||||
{
|
||||
get
|
||||
{
|
||||
var entsh = this.entidadesrelacionadasidEntidadPadreNavigation.Select(x => new EntidadRelacionada {
|
||||
RazonSocial = x.idEntidadHijoNavigation.RazonSocial,
|
||||
TipoRelacion = EntidadRelacionada.TipoRelacionEntidadEnum.ES_HIJA,
|
||||
CIF = x.idEntidadHijoNavigation.CIF,
|
||||
EntRel = x
|
||||
}).ToList();
|
||||
|
||||
var entsp = this.entidadesrelacionadasidEntidadHijoNavigation.Select(x => new EntidadRelacionada {
|
||||
RazonSocial = x.idEntidadPadreNavigation.RazonSocial,
|
||||
TipoRelacion = EntidadRelacionada.TipoRelacionEntidadEnum.ES_PADRE,
|
||||
CIF = x.idEntidadPadreNavigation.CIF,
|
||||
EntRel = x
|
||||
}).ToList();
|
||||
|
||||
return entsh.Union(entsp).OrderBy(x => x.RazonSocial).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public class EntidadRelacionada
|
||||
{
|
||||
public int idEntidad { get; set; }
|
||||
public string CIF { get; set; }
|
||||
public TipoRelacionEntidadEnum TipoRelacion { get; set; }
|
||||
public string DescripcionTipoRelacion => TipoRelacion.ToString().Replace("_", " ");
|
||||
public string RazonSocial { get; set; }
|
||||
public enum TipoRelacionEntidadEnum { ES_HIJA, ES_PADRE }
|
||||
public virtual entidadesrelacionadas EntRel { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
public class ve_entidades
|
||||
{
|
||||
public int idEntidad { get; set; }
|
||||
public string CIF { get; set; }
|
||||
public string RazonSocial { get; set; }
|
||||
public DateOnly? FechaNacimiento { get; set; }
|
||||
public string Direccion { get; set; }
|
||||
public string Poblacion { get; set; }
|
||||
public string Provincia { get; set; }
|
||||
public string Telefono1 { get; set; }
|
||||
public string email { get; set; }
|
||||
public bool EsTaller { get; set; }
|
||||
public bool EsClienteSG { get; set; }
|
||||
public bool EsClienteSA { get; set; }
|
||||
public bool EsContrarioSiniestro { get; set; }
|
||||
|
||||
public string PoblacionYProvincia
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.Provincia == this.Poblacion)
|
||||
{
|
||||
return this.Poblacion;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.Poblacion + " (" + this.Provincia + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ve_entidades_venta_cruzada
|
||||
{
|
||||
public int idEntidad { get; set; }
|
||||
public string CIF { get; set; }
|
||||
public string RazonSocial { get; set; }
|
||||
public string Telefono1 { get; set; }
|
||||
public string Telefono2 { get; set; }
|
||||
public DateOnly? FechaNacimientoTomador { get; set; }
|
||||
public string TelefonoMovilValido { get; set; }
|
||||
public string Email { get; set; }
|
||||
public int NumeroPolizas { get; set; }
|
||||
public int idAgente { get; set; }
|
||||
public string Agente { get; set; }
|
||||
public int? idSubagente { get; set; }
|
||||
public string SubAgente { get; set; }
|
||||
public string TlfAgente { get; set; }
|
||||
public string EmailAgente { get; set; }
|
||||
public string TlfSubAgente { get; set; }
|
||||
public string EmailSubAgente { get; set; }
|
||||
public int NumeroCorreosVentaCruzada { get; set; }
|
||||
public string Compañías { get; set; }
|
||||
|
||||
public string TelefonoSubAgenteAgente
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!string.IsNullOrEmpty(TlfSubAgente))
|
||||
{
|
||||
return TlfSubAgente;
|
||||
}
|
||||
else
|
||||
{
|
||||
return TlfAgente;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
36
bdAsegasa/Extensiones/entidadespolizas.cs
Normal file
36
bdAsegasa/Extensiones/entidadespolizas.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class entidadespolizas
|
||||
{
|
||||
public bool AEliminar_tmp { get; set; }
|
||||
|
||||
public string Domicilio
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idDireccion.HasValue)
|
||||
{
|
||||
if (this.idDireccionNavigation?.CodigoMunicipioNavigation == null || string.IsNullOrEmpty(this.idDireccionNavigation?.Direccion) || string.IsNullOrEmpty(this.idDireccionNavigation?.CodigoPostal))
|
||||
{
|
||||
return "** DOMICILIO INCORRECTO **";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.idDireccionNavigation.CodigoMunicipioNavigation.CodigoProvinciaNavigation?.Nombre == this.idDireccionNavigation.CodigoMunicipioNavigation.Nombre)
|
||||
{
|
||||
return this.idDireccionNavigation.Direccion + " - " + this.idDireccionNavigation.CodigoPostal + " " + this.idDireccionNavigation.CodigoMunicipioNavigation.Nombre;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.idDireccionNavigation.Direccion + " - " + this.idDireccionNavigation.CodigoPostal + " " + this.idDireccionNavigation.CodigoMunicipioNavigation.Nombre + " (" + this.idDireccionNavigation.CodigoMunicipioNavigation.CodigoProvinciaNavigation?.Nombre + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return "** DOMICILIO INCORRECTO **";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
67
bdAsegasa/Extensiones/enumeraciones.cs
Normal file
67
bdAsegasa/Extensiones/enumeraciones.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class enumeraciones
|
||||
{
|
||||
public string CodigoDescripcion
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.Codigo) || !this.Codigo.Contains("."))
|
||||
{
|
||||
return "- " + this.Descripcion;
|
||||
}
|
||||
var parts = this.Codigo.Split('.');
|
||||
if (parts.Length > 1)
|
||||
{
|
||||
return parts[1] + " - " + this.Descripcion;
|
||||
}
|
||||
return this.Codigo + " - " + this.Descripcion;
|
||||
}
|
||||
}
|
||||
|
||||
public int? ValorEntero1
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.ValorNumerico1.HasValue)
|
||||
{
|
||||
return (int)this.ValorNumerico1.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value.HasValue)
|
||||
{
|
||||
this.ValorNumerico1 = (double)value.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ValorNumerico1 = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<enumeraciones> _LConfsi;
|
||||
|
||||
public static List<enumeraciones> LConfsi
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_LConfsi == null)
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
// Assuming NuevoContexto or similar context provider logic is used
|
||||
_LConfsi = bd.enumeraciones.Where(x => x.Codigo != null && x.Codigo.StartsWith("VF.SI-")).OrderByDescending(x => x.Fecha1).ToList();
|
||||
}
|
||||
return _LConfsi;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
64
bdAsegasa/Extensiones/estadossiniestros_eiac.cs
Normal file
64
bdAsegasa/Extensiones/estadossiniestros_eiac.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class estadossiniestros_eiac
|
||||
{
|
||||
public static int ObtieneSituacionSiniestroV6(claves_situacionsiniestro Clave)
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (Clave)
|
||||
{
|
||||
case claves_situacionsiniestro.AP:
|
||||
return (int)ClavesSituacionSiniestroEnum.ABIERTO;
|
||||
case claves_situacionsiniestro.CE:
|
||||
return (int)ClavesSituacionSiniestroEnum.CERRADO;
|
||||
case claves_situacionsiniestro.RA:
|
||||
return (int)ClavesSituacionSiniestroEnum.REABIERTO;
|
||||
case claves_situacionsiniestro.RC:
|
||||
return (int)ClavesSituacionSiniestroEnum.RECHAZADO;
|
||||
default:
|
||||
return (int)ClavesSituacionSiniestroEnum.DESCONOCIDA;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return (int)ClavesSituacionSiniestroEnum.DESCONOCIDA;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ClavesSituacionSiniestroEnum : int
|
||||
{
|
||||
ABIERTO = 1,
|
||||
CERRADO = 2,
|
||||
REABIERTO = 3,
|
||||
RECHAZADO = 4,
|
||||
DESCONOCIDA = 99
|
||||
}
|
||||
|
||||
public enum claves_situacionsiniestro
|
||||
{
|
||||
AP,
|
||||
CE,
|
||||
RA,
|
||||
RC
|
||||
}
|
||||
|
||||
|
||||
public string DescripcionSituacionSiniestro
|
||||
{
|
||||
get
|
||||
{
|
||||
if (SituacionSiniestro.HasValue)
|
||||
{
|
||||
return ((ClavesSituacionSiniestroEnum)SituacionSiniestro.Value).ToString().Replace("_", " ");
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
70
bdAsegasa/Extensiones/expedientessiniestros_eiac.cs
Normal file
70
bdAsegasa/Extensiones/expedientessiniestros_eiac.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class expedientessiniestros_eiac
|
||||
{
|
||||
public static int ObtieneEstadoExpedienteV6(claves_estadoexpediente clave)
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (clave)
|
||||
{
|
||||
case claves_estadoexpediente.DE:
|
||||
return (int)ClavesEstadoExpedienteEnum.DECLARADO;
|
||||
case claves_estadoexpediente.LI:
|
||||
return (int)ClavesEstadoExpedienteEnum.LIQUIDADO;
|
||||
case claves_estadoexpediente.PE:
|
||||
return (int)ClavesEstadoExpedienteEnum.PENDIENTE;
|
||||
case claves_estadoexpediente.RE:
|
||||
return (int)ClavesEstadoExpedienteEnum.REAPERTURA;
|
||||
case claves_estadoexpediente.TE:
|
||||
return (int)ClavesEstadoExpedienteEnum.TERMINADO;
|
||||
default:
|
||||
return (int)ClavesEstadoExpedienteEnum.DESCONOCIDA;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return (int)ClavesEstadoExpedienteEnum.DESCONOCIDA;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ClavesEstadoExpedienteEnum : int
|
||||
{
|
||||
DECLARADO = 1,
|
||||
LIQUIDADO = 2,
|
||||
PENDIENTE = 3,
|
||||
REAPERTURA = 4,
|
||||
TERMINADO = 5,
|
||||
DESCONOCIDA = 99
|
||||
}
|
||||
|
||||
public enum claves_estadoexpediente
|
||||
{
|
||||
|
||||
/// <remarks/>
|
||||
DE,
|
||||
|
||||
/// <remarks/>
|
||||
LI,
|
||||
|
||||
/// <remarks/>
|
||||
PE,
|
||||
|
||||
/// <remarks/>
|
||||
RE,
|
||||
|
||||
/// <remarks/>
|
||||
TE
|
||||
}
|
||||
|
||||
public string DescripcionEstadoExpediente
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((ClavesEstadoExpedienteEnum)EstadoExpediente).ToString().Replace("_", " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
67
bdAsegasa/Extensiones/ficheros.cs
Normal file
67
bdAsegasa/Extensiones/ficheros.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class ficheros
|
||||
{
|
||||
public string idFicheroEnc
|
||||
{
|
||||
get
|
||||
{
|
||||
string idStr = this.idFichero.ToString().PadLeft(8, '0');
|
||||
using (SHA1 sha1 = SHA1.Create())
|
||||
{
|
||||
byte[] hash = sha1.ComputeHash(Encoding.ASCII.GetBytes("ASEGASa" + idStr));
|
||||
string dc = hash[0].ToString("x2");
|
||||
// Using tsUtilidades for encryption
|
||||
return tsUtilidades.crypt.FEncS(idStr + dc, "1973122213","",0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int ObtieneidFichero(string idEncriptado)
|
||||
{
|
||||
try
|
||||
{
|
||||
string idcdc = tsUtilidades.crypt.FEncS(idEncriptado, "1973122213","",0);
|
||||
if (idcdc.Length < 10) return 0;
|
||||
string idr = idcdc.Substring(0, 8);
|
||||
string dc = idcdc.Substring(8, 2);
|
||||
|
||||
using (SHA1 sha1 = SHA1.Create())
|
||||
{
|
||||
byte[] hash = sha1.ComputeHash(Encoding.ASCII.GetBytes("ASEGASa" + idr));
|
||||
if (hash[0].ToString("x2") != dc) return 0;
|
||||
return int.Parse(idr);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class vr_ficheros
|
||||
{
|
||||
public int idFichero { get; set; }
|
||||
public string NombreFichero { get; set; }
|
||||
public DateTime Fecha { get; set; }
|
||||
public string Descripcion { get; set; }
|
||||
|
||||
public static List<vr_ficheros> Obtiene_vr_ficheros(IQueryable<ficheros> iqFicheros)
|
||||
{
|
||||
return iqFicheros.Select(x => new vr_ficheros
|
||||
{
|
||||
idFichero = x.idFichero,
|
||||
NombreFichero = x.NombreFichero,
|
||||
Fecha = (DateTime)x.Fecha,
|
||||
Descripcion = x.Descripcion
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
36
bdAsegasa/Extensiones/ficheroscompanias.cs
Normal file
36
bdAsegasa/Extensiones/ficheroscompanias.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class ficheroscompanias
|
||||
{
|
||||
public enum TipoFicheroCompania : int
|
||||
{
|
||||
POLIZAS_EIAC = 1,
|
||||
RECIBOS_EIAC = 2,
|
||||
MOVIMIENTOS_RECIBOS_EIAC = 3,
|
||||
SINIESTROS_EIAC = 4,
|
||||
MOVIMIENTOS_SINIESTROS_EIAC = 5,
|
||||
LIQUIDACIONES_EIAC = 6, // VB had duplicate 5, fixed to 6 or kept as 5? Original had 5 for both.
|
||||
RECIBOS_PATRIA_HISPANA = 12,
|
||||
RECIBOS_PREVISION_MALLORQUINA = 13,
|
||||
CARTERA_COMPLETA_EIAC = 98,
|
||||
DESCONOCIDO = 99
|
||||
}
|
||||
|
||||
public bool ContieneMovimientosDeRecibos()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Note: Logic for EIAC deserialization requires ProcesosEIAC dlls.
|
||||
// This is a placeholder for the logic.
|
||||
return false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1138
bdAsegasa/Extensiones/gestionasegasaEntities.cs
Normal file
1138
bdAsegasa/Extensiones/gestionasegasaEntities.cs
Normal file
File diff suppressed because it is too large
Load Diff
70
bdAsegasa/Extensiones/gestionesrecibos.cs
Normal file
70
bdAsegasa/Extensiones/gestionesrecibos.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class gestionesrecibos
|
||||
{
|
||||
public string DetalleCorreo
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idCorreoNavigation != null)
|
||||
{
|
||||
var c = this.idCorreoNavigation;
|
||||
if (c.FechaAnulacion.HasValue)
|
||||
return $"Correo a {c.Destinatario} Anulado el {c.FechaAnulacion.Value:dd/MM/yyyy HH:mm}";
|
||||
if (c.FechaEnvio.HasValue)
|
||||
return $"Correo a {c.Destinatario} Enviado el {c.FechaEnvio.Value:dd/MM/yyyy HH:mm}";
|
||||
return $"Correo a {c.Destinatario} pendiente de envio";
|
||||
}
|
||||
return "Sin correo";
|
||||
}
|
||||
}
|
||||
|
||||
public string DetalleMensaje
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idMensajeNavigation != null)
|
||||
{
|
||||
var m = this.idMensajeNavigation;
|
||||
if (m.FechaAnulacion.HasValue)
|
||||
return $"Mensaje a {m.Destinatario} Anulado el {m.FechaAnulacion.Value:dd/MM/yyyy HH:mm}";
|
||||
if (m.FechaEnvio.HasValue)
|
||||
return $"Mensaje a {m.Destinatario} Enviado el {m.FechaEnvio.Value:dd/MM/yyyy HH:mm}";
|
||||
return $"Mensaje a {m.Destinatario} pendiente de envio";
|
||||
}
|
||||
return "Sin Mensaje";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum TipoGestionEnum : int
|
||||
{
|
||||
AVISO_REMESA_O_COBRO_DIRECTO = 1,
|
||||
AVISO_POLIZA_DE_BAJA = 2,
|
||||
AVISO_RECIBO_DEVUELTO_BANCO = 3,
|
||||
AVISO_IMPERATIVO_LEGAL = 4,
|
||||
SOLICITUD_DATOS_DEL_ASEGURADO_AL_AGENTE = 5,
|
||||
COMUNICACIÓN_DEVOLUCIÓN_AL_AGENTE = 6,
|
||||
COMUNICACIÓN_BAJA_AL_AGENTE = 7,
|
||||
CAMBIO_CARTERA_AGENTE = 8,
|
||||
AVISO_DEFENSA_CARTERA = 9,
|
||||
DESCARGA_RECIBO_DE_CIA = 10,
|
||||
OTROS_HP = 100,
|
||||
OTROS = 101,
|
||||
COMUNICACIÓN_EMISION_RECIBO_A_LA_COMPAÑÍA = 200,
|
||||
IMPRESION_RECIBO_CIA = 300,
|
||||
IMPRESION_RECIBO_GENERICO = 301,
|
||||
AVISO_ERRONEO = 1000
|
||||
}
|
||||
|
||||
public enum FormaComunicacionEnum
|
||||
{
|
||||
NINGUNA = 0,
|
||||
POR_SMS = 1,
|
||||
POR_CARTA = 2,
|
||||
SIN_DOMICILIO_NI_TLF_VALIDO = 3,
|
||||
POR_EMAIL = 4
|
||||
}
|
||||
}
|
||||
9
bdAsegasa/Extensiones/gestionessiniestros.cs
Normal file
9
bdAsegasa/Extensiones/gestionessiniestros.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class gestionessiniestros
|
||||
{
|
||||
public bool PendienteRevision => this.FechaRecordatorio.HasValue && this.FechaRecordatorio.Value <= DateOnly.FromDateTime(DateTime.Now);
|
||||
}
|
||||
}
|
||||
71
bdAsegasa/Extensiones/gestionesvarias.cs
Normal file
71
bdAsegasa/Extensiones/gestionesvarias.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using bdAsegasa.dbcontext;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class gestionesvarias
|
||||
{
|
||||
public static gestionesvarias CreaNuevoCambioContraseñaAgente(int idAgente)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var idTg = bd.enumeraciones.First(x => x.Codigo == "TGV.CCAG").idEnumeracion;
|
||||
var ag = bd.agentes.First(x => x.idAgente == idAgente).Codigo;
|
||||
|
||||
var random = new Random();
|
||||
string iAleatorio = random.Next(100000000, 999999999).ToString();
|
||||
|
||||
var ng = new gestionesvarias();
|
||||
ng.idTipo = idTg;
|
||||
ng.idAplicacion = idAgente;
|
||||
ng.FechaCreacion = DateTime.Now;
|
||||
ng.Descripción = ag;
|
||||
ng.Parametros = tsUtilidades.crypt.SHA1ASCII("M3Soft." + iAleatorio);
|
||||
|
||||
bd.gestionesvarias.Add(ng);
|
||||
bd.SaveChanges();
|
||||
return ng;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static gestionesvarias CreaNuevoCambioContraseñaSubAgente(int idSubAgente)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var idTg = bd.enumeraciones.First(x => x.Codigo == "TGV.CCSAG").idEnumeracion;
|
||||
var sag = bd.subagentes.First(x => x.idSubagente == idSubAgente);
|
||||
|
||||
var random = new Random();
|
||||
string iAleatorio = random.Next(100000000, 999999999).ToString();
|
||||
|
||||
var ng = new gestionesvarias();
|
||||
ng.idTipo = idTg;
|
||||
ng.idAplicacion = idSubAgente;
|
||||
ng.FechaCreacion = DateTime.Now;
|
||||
ng.Descripción = $"{sag.idAgenteNavigation?.Codigo}-{sag.Codigo}";
|
||||
ng.Parametros = tsUtilidades.crypt.SHA1("M3Soft." + iAleatorio);
|
||||
|
||||
bd.gestionesvarias.Add(ng);
|
||||
bd.SaveChanges();
|
||||
return ng;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
40
bdAsegasa/Extensiones/historicocomisiones.cs
Normal file
40
bdAsegasa/Extensiones/historicocomisiones.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Linq;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class historicocomisiones
|
||||
{
|
||||
public double TotalComisionAgente
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.comisionAgente ?? 0) + (this.incentivoAgente ?? 0);
|
||||
}
|
||||
}
|
||||
|
||||
public string CodNomAgente
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.idCodigoAgenteNavigation?.Codigo + "-" + this.idCodigoAgenteNavigation?.Nombre;
|
||||
}
|
||||
}
|
||||
|
||||
public string PlanLinea
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.idPolizaAgrarioNavigation?.idPlanLineaNavigation?.planLinea;
|
||||
}
|
||||
}
|
||||
|
||||
public int NumeroPolizas
|
||||
{
|
||||
get
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
return bd.polizasagrario.Count(x => x.poliza == this.idPolizaAgrarioNavigation.poliza);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -28,5 +28,111 @@ namespace bdAsegasa.db
|
||||
return NumeroFactura;
|
||||
}
|
||||
}
|
||||
public const string Prod = "https://www2.agenciatributaria.gob.es/wlpl/TIKE-CONT/ValidarQR";
|
||||
public const string TestValidate = "https://prewww2.aeat.es/wlpl/TIKE-CONT/ValidarQR";
|
||||
|
||||
public string EnlaceQR
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
DateTime fechaCmp = this.Fecha != DateOnly.MinValue ? new DateTime(this.Fecha.Year, this.Fecha.Month, this.Fecha.Day) : DateTime.Now;
|
||||
|
||||
var confsi = enumeraciones.LConfsi?.Where(x => x.Fecha1.HasValue && x.Fecha1.Value <= fechaCmp).OrderByDescending(x => x.Fecha1).FirstOrDefault();
|
||||
|
||||
if (confsi != null)
|
||||
{
|
||||
if (confsi.ValorNumerico4 > 0)
|
||||
{
|
||||
return Prod + "?nif=" + this.idAgenteNavigation?.CIF + "&numserie=" + NumeroFactura + "&fecha=" + this.Fecha.ToString("dd-MM-yyyy") + "&importe=" + Math.Round(TotalFacturaSinIRPF, 2, MidpointRounding.AwayFromZero).ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
else
|
||||
{
|
||||
string nf = NumeroFacturaVF(confsi.ValorAlfabetico4);
|
||||
return TestValidate + "?nif=" + this.idAgenteNavigation?.CIF + "&numserie=" + nf + "&fecha=" + this.Fecha.ToString("dd-MM-yyyy") + "&importe=" + Math.Round(TotalFacturaSinIRPF, 2, MidpointRounding.AwayFromZero).ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string nf = NumeroFacturaVF(null);
|
||||
return TestValidate + "?nif=" + this.idAgenteNavigation?.CIF + "&numserie=" + nf + "&fecha=" + this.Fecha.ToString("dd-MM-yyyy") + "&importe=" + Math.Round(TotalFacturaSinIRPF, 2, MidpointRounding.AwayFromZero).ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool QRVisible
|
||||
{
|
||||
get
|
||||
{
|
||||
DateTime fechaCmp = this.Fecha != DateOnly.MinValue ? new DateTime(this.Fecha.Year, this.Fecha.Month, this.Fecha.Day) : DateTime.Now;
|
||||
var confsi = enumeraciones.LConfsi?.Where(x => x.Fecha1.HasValue && x.Fecha1.Value <= fechaCmp).OrderByDescending(x => x.Fecha1).FirstOrDefault();
|
||||
if (confsi != null)
|
||||
{
|
||||
return confsi.ValorNumerico4 > 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string DescripcionEstadoVerifactu
|
||||
{
|
||||
get
|
||||
{
|
||||
return EstadoVerifactu.ToString().Replace("_", " ");
|
||||
}
|
||||
}
|
||||
|
||||
public EstadoVerifactuEnum EstadoVerifactu
|
||||
{
|
||||
get
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
var rvf = bd.registrosverifactu.Where(x => x.idAplicacion == idLiquidacionAgente).OrderByDescending(x => x.idRegistro).FirstOrDefault();
|
||||
if (rvf != null)
|
||||
{
|
||||
return (EstadoVerifactuEnum)(rvf.Estado);
|
||||
}
|
||||
else
|
||||
{
|
||||
return EstadoVerifactuEnum.SIN_REGISTROS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum EstadoVerifactuEnum
|
||||
{
|
||||
PENDIENTE_RESPUESTA = 0,
|
||||
CORRECTO = 1,
|
||||
ACEPTADO_CON_ERRORES = 2,
|
||||
INCORRECTO = 3,
|
||||
COMPLETADO = 10,
|
||||
SIN_REGISTROS = 100
|
||||
}
|
||||
|
||||
public string ObtieneNumeroFactura()
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
int AnoAct = DateTime.Today.Year;
|
||||
if (this.FechaFactura.HasValue && this.FechaFactura.Value.Year < 2026)
|
||||
{
|
||||
var UltimaLiquidacion = bd.liquidacionesagentes.Where(x => x.FechaFactura.HasValue && x.FechaFactura.Value.Year == AnoAct).OrderByDescending(x => x.NumeroFactura).FirstOrDefault();
|
||||
int UltimaFactura = 1;
|
||||
if (UltimaLiquidacion != null && !string.IsNullOrEmpty(UltimaLiquidacion.NumeroFactura) && UltimaLiquidacion.NumeroFactura.Contains("-"))
|
||||
UltimaFactura = int.Parse(UltimaLiquidacion.NumeroFactura.Split('-')[1]) + 1;
|
||||
return DateTime.Today.Year.ToString() + "-" + UltimaFactura.ToString().PadLeft(5, '0');
|
||||
}
|
||||
else
|
||||
{
|
||||
var UltimaLiquidacion = bd.liquidacionesagentes.Where(x => x.FechaFactura.HasValue && x.FechaFactura.Value.Year == AnoAct && x.idSerieFactura == this.idSerieFactura).OrderByDescending(x => x.NumeroFactura).FirstOrDefault();
|
||||
int UltimaFactura = 1;
|
||||
if (UltimaLiquidacion != null && !string.IsNullOrEmpty(UltimaLiquidacion.NumeroFactura) && UltimaLiquidacion.NumeroFactura.Contains("-"))
|
||||
UltimaFactura = int.Parse(UltimaLiquidacion.NumeroFactura.Split('-')[1].Substring(2)) + 1;
|
||||
var sf = bd.seriesfacturas.First(x => x.idSerieFactura == idSerieFactura).Serie;
|
||||
return sf + "-" + DateTime.Today.Year.ToString().Substring(2) + UltimaFactura.ToString().PadLeft(5, '0');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
16
bdAsegasa/Extensiones/liquidacionescompanias.cs
Normal file
16
bdAsegasa/Extensiones/liquidacionescompanias.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.Linq;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class liquidacionescompanias
|
||||
{
|
||||
public string Compañía
|
||||
{
|
||||
get
|
||||
{
|
||||
var first = this.liquidacionescompaniasrecibos.FirstOrDefault();
|
||||
return first?.idReciboNavigation?.idPolizaNavigation?.idCompaniaNavigation?.Nombre ?? "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
45
bdAsegasa/Extensiones/liquidacionesviajes.cs
Normal file
45
bdAsegasa/Extensiones/liquidacionesviajes.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class liquidacionesviajes
|
||||
{
|
||||
public double Diferencia
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Round((double)(TotalJustificado - Anticipo), 2);
|
||||
}
|
||||
}
|
||||
|
||||
public string ADevolver
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Diferencia < 0)
|
||||
{
|
||||
return Math.Abs(Diferencia).ToString("c2");
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string ARecibir
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Diferencia > 0)
|
||||
{
|
||||
return Diferencia.ToString("c2");
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
56
bdAsegasa/Extensiones/logs.cs
Normal file
56
bdAsegasa/Extensiones/logs.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using bdAsegasa.dbcontext;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class logs
|
||||
{
|
||||
public static int GeneraLog(tscgestionasegasa bd, string Tabla, int id, int? idrelacionado, string Tipo, string LogXML, bool SuperUsuario, string Aplicacion)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (bd == null) bd = tscgestionasegasa.NuevoContexto();
|
||||
|
||||
var nl = new logs();
|
||||
nl.Tabla = Tabla;
|
||||
nl.Aplicacion = Aplicacion;
|
||||
nl.LogXML = LogXML;
|
||||
nl.id = id;
|
||||
nl.idRelacionado = idrelacionado;
|
||||
nl.ip = bd.ip;
|
||||
nl.FechaHora = DateTime.Now;
|
||||
nl.Tipo = Tipo;
|
||||
nl.Usuario = SuperUsuario ? $"{Utilidades.Usuario} (SU)" : Utilidades.Usuario;
|
||||
nl.idTimeStamp = (double)DateTime.Now.Ticks;
|
||||
|
||||
bd.logs.Add(nl);
|
||||
bd.SaveChanges();
|
||||
return nl.idLog;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utilidades.AñadeLog(tsUtilidades.Enumeraciones.TipoLog.Fallo, "En GeneraLog", ex.Message, ex);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public string GeneradoPor
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idRelacionado.HasValue)
|
||||
{
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var lp = bd.logs.FirstOrDefault(x => x.idLog == this.idRelacionado);
|
||||
return lp?.Aplicacion ?? "DESCONOCIDO";
|
||||
}
|
||||
}
|
||||
return this.Aplicacion;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
57
bdAsegasa/Extensiones/modificacionespolizasagrario.cs
Normal file
57
bdAsegasa/Extensiones/modificacionespolizasagrario.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class modificacionespolizasagrario
|
||||
{
|
||||
public double PorIncAge
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.previstasIncentivoAgente.GetValueOrDefault() / this.primaComercialNeta.GetValueOrDefault()) * 100;
|
||||
}
|
||||
}
|
||||
public double PorComAge
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.previstasComisionAgente.GetValueOrDefault() / this.primaComercialNeta.GetValueOrDefault()) * 100;
|
||||
}
|
||||
}
|
||||
public double PorIncAse
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.previstasIncentivoAsegasa.GetValueOrDefault() / this.primaComercialNeta.GetValueOrDefault()) * 100;
|
||||
}
|
||||
}
|
||||
public double PorComAse
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.previstasComisionAsegasa.GetValueOrDefault() / this.primaComercialNeta.GetValueOrDefault()) * 100;
|
||||
}
|
||||
}
|
||||
public double PorNifNue
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.previstasNIFNuevo.GetValueOrDefault() / this.primaComercialNeta.GetValueOrDefault()) * 100;
|
||||
}
|
||||
}
|
||||
public double PorTomPro
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.previstasTomadorPropio.GetValueOrDefault() / this.primaComercialNeta.GetValueOrDefault()) * 100;
|
||||
}
|
||||
}
|
||||
public double PorTotComPre
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.totalPrevistas.GetValueOrDefault() / this.primaComercialNeta.GetValueOrDefault()) * 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
67
bdAsegasa/Extensiones/movimientosbancarios.cs
Normal file
67
bdAsegasa/Extensiones/movimientosbancarios.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class movimientosbancarios
|
||||
{
|
||||
private bool? _Conciliado;
|
||||
|
||||
public bool Conciliado
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Conciliado.HasValue)
|
||||
{
|
||||
return _Conciliado.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ConciliacionActual_TMP != null)
|
||||
{
|
||||
if (ConciliacionActual_TMP.idconciliacion != this.idConciliacion)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.idConciliacion.HasValue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.idConciliacion.HasValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
_Conciliado = value;
|
||||
if (value)
|
||||
{
|
||||
this.idConciliacionNavigation = this.ConciliacionActual_TMP;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.idConciliacion = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual conciliacionesbancarias ConciliacionActual_TMP { get; set; }
|
||||
|
||||
public string ConciliadoEn
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ConciliacionActual_TMP != null && this.idConciliacion.HasValue && this.idConciliacion != ConciliacionActual_TMP.idconciliacion)
|
||||
{
|
||||
return "Nº Conc.: " + this.idConciliacion + " (" + this.idConciliacionNavigation.Año.ToString() + "-" + this.idConciliacionNavigation.Mes.ToString() + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
82
bdAsegasa/Extensiones/municipios.cs
Normal file
82
bdAsegasa/Extensiones/municipios.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using bdAsegasa.dbcontext;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class municipios
|
||||
{
|
||||
private static List<municipios> _listaPoblaciones;
|
||||
|
||||
public string PoblacionYProvincia
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this.Nombre == this.CodigoProvinciaNavigation?.Nombre)
|
||||
{
|
||||
return this.Nombre;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"{this.Nombre} ({this.CodigoProvinciaNavigation?.Nombre})";
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string ObtienePoblacion(string codigoPoblacion)
|
||||
{
|
||||
EnsureCache();
|
||||
var pob = _listaPoblaciones.FirstOrDefault(x => x.CodigoMunicipio == codigoPoblacion);
|
||||
if (pob != null) return pob.Nombre;
|
||||
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
pob = bd.municipios.Include(x => x.CodigoProvinciaNavigation).FirstOrDefault(x => x.CodigoMunicipio == codigoPoblacion);
|
||||
if (pob != null)
|
||||
{
|
||||
_listaPoblaciones.Add(pob);
|
||||
return pob.Nombre;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static string ObtieneProvincia(string codigoPoblacion)
|
||||
{
|
||||
EnsureCache();
|
||||
var pob = _listaPoblaciones.FirstOrDefault(x => x.CodigoMunicipio == codigoPoblacion);
|
||||
if (pob != null) return pob.CodigoProvinciaNavigation?.Nombre ?? "";
|
||||
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
pob = bd.municipios.Include(x => x.CodigoProvinciaNavigation).FirstOrDefault(x => x.CodigoMunicipio == codigoPoblacion);
|
||||
if (pob != null)
|
||||
{
|
||||
_listaPoblaciones.Add(pob);
|
||||
return pob.CodigoProvinciaNavigation?.Nombre ?? "";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static void EnsureCache()
|
||||
{
|
||||
if (_listaPoblaciones == null)
|
||||
{
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
_listaPoblaciones = bd.municipios.Include(x => x.CodigoProvinciaNavigation).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
25
bdAsegasa/Extensiones/notificaciones.cs
Normal file
25
bdAsegasa/Extensiones/notificaciones.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class notificaciones
|
||||
{
|
||||
public bool Notificado
|
||||
{
|
||||
get => FechaNotificado.HasValue;
|
||||
set => FechaNotificado = value ? DateTime.Now : null;
|
||||
}
|
||||
|
||||
public enum TipoEntidadEnum : int
|
||||
{
|
||||
USUARIO = 1,
|
||||
AGENTE = 2,
|
||||
SUBAGENTE = 3
|
||||
}
|
||||
|
||||
public enum TipoNotificacionEnum : int
|
||||
{
|
||||
AVISO_AGENTE_RECIBOS_BAJA = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
36
bdAsegasa/Extensiones/pagosliquidacionescia.cs
Normal file
36
bdAsegasa/Extensiones/pagosliquidacionescia.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class pagosliquidacionescias
|
||||
{
|
||||
public double ImportePago
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Round((this.ImporteLiquidaciones) + (this.ImporteRegularizacion), 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
|
||||
public double ImporteCobros
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Round(this.liquidacionescompanias.Where(x => x.idTipoLiquidacionNavigation?.Codigo != "TIPLIQ.DESCOBRO").Sum(x => x.Importe), 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
|
||||
public double ImporteDesCobros
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Round(this.liquidacionescompanias.Where(x => x.idTipoLiquidacionNavigation?.Codigo == "TIPLIQ.DESCOBRO").Sum(x => x.Importe), 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
|
||||
public void ActualizaImportePago()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
157
bdAsegasa/Extensiones/pagostelematicos.cs
Normal file
157
bdAsegasa/Extensiones/pagostelematicos.cs
Normal file
@@ -0,0 +1,157 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections.Specialized;
|
||||
using Newtonsoft.Json;
|
||||
using bdAsegasa.dbcontext;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class pagostelematicos
|
||||
{
|
||||
public string CodigoRecibo => this.idReciboNavigation?.CodigoRecibo ?? "";
|
||||
|
||||
public static pagostelematicos GeneraPagoTelematico(tscgestionasegasa bd, OrigenPagoEnum origenPago, string referencia, string emailConfirmacion, string telefono, double importe, string dni = "", int? idRecibo = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (idRecibo.HasValue && !bd.recibos.Any(x => x.idRecibo == idRecibo.Value))
|
||||
throw new Exception("No se encuentra el recibo con id: " + idRecibo.Value);
|
||||
|
||||
var random = new Random();
|
||||
var np = new pagostelematicos();
|
||||
np.DNI = dni?.Trim().ToUpper();
|
||||
np.Referencia = referencia?.Trim().ToUpper();
|
||||
np.EmailConfirmacionPago = emailConfirmacion?.Trim().ToLower();
|
||||
np.Telefono = telefono;
|
||||
np.Importe = Math.Round(importe, 2);
|
||||
np.FechaCreacion = DateTime.Now;
|
||||
np.idRecibo = idRecibo;
|
||||
np.OrigenPago = (int)origenPago;
|
||||
np.CodigoConfirmacionPago = random.Next(100000000, 999999999).ToString();
|
||||
|
||||
bd.pagostelematicos.Add(np);
|
||||
bd.SaveChanges();
|
||||
return np;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum OrigenPagoEnum
|
||||
{
|
||||
PAGO_GENERICO = 0,
|
||||
PAGO_RECIBO = 1
|
||||
}
|
||||
|
||||
public class RespuestaRedsysPOST
|
||||
{
|
||||
public string Ds_SignatureVersion { get; set; }
|
||||
public string Ds_MerchantParameters { get; set; }
|
||||
public string Ds_Signature { get; set; }
|
||||
public ConfirmacionRedsys Confirmacion { get; set; }
|
||||
|
||||
public RespuestaRedsysPOST() { }
|
||||
|
||||
public RespuestaRedsysPOST(NameValueCollection datosPOST)
|
||||
{
|
||||
foreach (string key in datosPOST.AllKeys)
|
||||
{
|
||||
if (key == "Ds_SignatureVersion") this.Ds_SignatureVersion = datosPOST[key];
|
||||
if (key == "Ds_MerchantParameters") this.Ds_MerchantParameters = datosPOST[key];
|
||||
if (key == "Ds_Signature") this.Ds_Signature = datosPOST[key];
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(Ds_MerchantParameters))
|
||||
{
|
||||
byte[] bDatos = Convert.FromBase64String(Ds_MerchantParameters);
|
||||
string sDatos = Encoding.UTF8.GetString(bDatos);
|
||||
this.Confirmacion = JsonConvert.DeserializeObject<ConfirmacionRedsys>(sDatos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ConfirmacionRedsys
|
||||
{
|
||||
public string Ds_Date { get; set; }
|
||||
public string Ds_Hour { get; set; }
|
||||
public string Ds_Amount { get; set; }
|
||||
public string Ds_Currency { get; set; }
|
||||
public string Ds_Order { get; set; }
|
||||
public string Ds_MerchantCode { get; set; }
|
||||
public string Ds_Terminal { get; set; }
|
||||
public string Ds_Response { get; set; }
|
||||
public string Ds_MerchantData { get; set; }
|
||||
public string Ds_SecurePayment { get; set; }
|
||||
public string Ds_TransactionType { get; set; }
|
||||
public string Ds_Card_Country { get; set; }
|
||||
public string Ds_AuthorisationCode { get; set; }
|
||||
public string Ds_ConsumerLanguage { get; set; }
|
||||
public string Ds_Card_Type { get; set; }
|
||||
|
||||
private const string SeparadorFecha = "%2F";
|
||||
private const string SeparadorHora = "%3A";
|
||||
|
||||
public DateTime Ds_Date_ComoDate
|
||||
{
|
||||
get
|
||||
{
|
||||
var parts = Ds_Date.Split(new[] { SeparadorFecha }, StringSplitOptions.None);
|
||||
return new DateTime(int.Parse(parts[2]), int.Parse(parts[1]), int.Parse(parts[0]));
|
||||
}
|
||||
}
|
||||
|
||||
public TimeSpan Ds_Hour_ComoTimeSpan
|
||||
{
|
||||
get
|
||||
{
|
||||
var parts = Ds_Hour.Split(new[] { SeparadorHora }, StringSplitOptions.None);
|
||||
return new TimeSpan(int.Parse(parts[0]), int.Parse(parts[1]), 0);
|
||||
}
|
||||
}
|
||||
|
||||
public double Ds_Amount_ComoDouble => double.Parse(Ds_Amount) / 100.0;
|
||||
|
||||
public bool Ds_Response_ComoBoolean
|
||||
{
|
||||
get
|
||||
{
|
||||
if (uint.TryParse(Ds_Response, out uint code))
|
||||
return code >= 0 && code <= 99;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Ds_SecurePayment_ComoBoolean => Ds_SecurePayment == "1";
|
||||
|
||||
public RedsysTipoTarjeta Ds_Card_Type_ComoEnum
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Ds_Card_Type == "C") return RedsysTipoTarjeta.CREDITO;
|
||||
if (Ds_Card_Type == "D") return RedsysTipoTarjeta.DEBITO;
|
||||
return RedsysTipoTarjeta.NO_PROPORCIONADO;
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime FechaHora
|
||||
{
|
||||
get
|
||||
{
|
||||
var d = Ds_Date_ComoDate;
|
||||
var t = Ds_Hour_ComoTimeSpan;
|
||||
return new DateTime(d.Year, d.Month, d.Day, t.Hours, t.Minutes, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum RedsysTipoTarjeta
|
||||
{
|
||||
NO_PROPORCIONADO = 0,
|
||||
CREDITO = 1,
|
||||
DEBITO = 2
|
||||
}
|
||||
}
|
||||
7
bdAsegasa/Extensiones/planeslineas.cs
Normal file
7
bdAsegasa/Extensiones/planeslineas.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class planeslineas
|
||||
{
|
||||
public string PlanesLineasDescripcion => $"{planLinea}, {descripcion}";
|
||||
}
|
||||
}
|
||||
7
bdAsegasa/Extensiones/plantillas.cs
Normal file
7
bdAsegasa/Extensiones/plantillas.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class plantillas
|
||||
{
|
||||
public byte[]? Plantilla => idFicheroNavigation?.Fichero;
|
||||
}
|
||||
}
|
||||
169
bdAsegasa/Extensiones/polizasagrario.cs
Normal file
169
bdAsegasa/Extensiones/polizasagrario.cs
Normal file
@@ -0,0 +1,169 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using bdAsegasa.dbcontext;
|
||||
using tsUtilidades;
|
||||
using tsEFCore8;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class polizasagrario
|
||||
{
|
||||
public entidades Tomador
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.idTomadorNavigation;
|
||||
}
|
||||
}
|
||||
public entidades Asegurado
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.idAseguradoNavigation;
|
||||
}
|
||||
}
|
||||
public direcciones DireccionAsegurado
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.idDomicilioAseguradoNavigation;
|
||||
}
|
||||
}
|
||||
|
||||
public string CodNomAgente
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.idAgenteNavigation.Codigo + "-" + this.idAgenteNavigation.Nombre;
|
||||
}
|
||||
}
|
||||
public string Fraccio
|
||||
{
|
||||
get
|
||||
{
|
||||
string Retorno = "NO";
|
||||
if (this.fraccionada == true) Retorno = "SI";
|
||||
return Retorno;
|
||||
}
|
||||
}
|
||||
|
||||
public int? idSubAgente_Especial
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idSubagente.HasValue && this.idAgenteNavigation.Codigo == "000047002186")
|
||||
{
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var Codigo = this.idSubagenteNavigation.Codigo.Substring(0, 2) + "00";
|
||||
var subage = bd.subagentes.FirstOrDefault(x => x.idAgente == this.idAgente && x.Codigo == Codigo);
|
||||
if (subage != null)
|
||||
{
|
||||
return subage.idSubagente;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.idSubagente;
|
||||
}
|
||||
}
|
||||
|
||||
public string ProvinciaAsegurado
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idAseguradoNavigation != null && this.idAseguradoNavigation.idDireccionPrincipalNavigation != null && this.idAseguradoNavigation.idDireccionPrincipalNavigation.CodigoPostal != null && this.idAseguradoNavigation.idDireccionPrincipalNavigation.CodigoPostal.Length > 2)
|
||||
{
|
||||
return this.idAseguradoNavigation.idDireccionPrincipalNavigation.CodigoPostal.Substring(0, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ListadoGenericoPA AListadoGenericoPA()
|
||||
{
|
||||
return new ListadoGenericoPA(this);
|
||||
}
|
||||
}
|
||||
|
||||
public class ListadoGenericoPA
|
||||
{
|
||||
public ListadoGenericoPA(polizasagrario p)
|
||||
{
|
||||
NumeroPóliza = p.poliza;
|
||||
|
||||
if (p.fechaPoliza.HasValue)
|
||||
{
|
||||
FechaPóliza = new DateTime(p.fechaPoliza.Value.Year, p.fechaPoliza.Value.Month, p.fechaPoliza.Value.Day);
|
||||
}
|
||||
|
||||
Línea = p.idPlanLineaNavigation?.descripcion;
|
||||
Compañía = p.idCiaNavigation?.Nombre;
|
||||
CIFAsegurado = p.Asegurado?.CIF;
|
||||
Asegurado = p.Asegurado?.RazonSocial;
|
||||
if (!string.IsNullOrEmpty(p.telefono1Asegurado))
|
||||
{
|
||||
Teléfono1 = p.telefono1Asegurado;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p.idAseguradoNavigation != null)
|
||||
{
|
||||
Teléfono1 = p.idAseguradoNavigation.Telefono1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Teléfono1 = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(p.telefono2Asegurado))
|
||||
{
|
||||
Teléfono2 = p.telefono2Asegurado;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p.idAseguradoNavigation != null)
|
||||
{
|
||||
Teléfono2 = p.idAseguradoNavigation.Telefono2;
|
||||
}
|
||||
else
|
||||
{
|
||||
Teléfono2 = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(p.emailAsegurado))
|
||||
{
|
||||
Email = p.emailAsegurado;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p.idAseguradoNavigation != null)
|
||||
{
|
||||
Email = p.idAseguradoNavigation.Email;
|
||||
}
|
||||
else
|
||||
{
|
||||
Email = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string NumeroPóliza { get; set; }
|
||||
public DateTime? FechaPóliza { get; set; }
|
||||
public string Compañía { get; set; }
|
||||
public string Línea { get; set; }
|
||||
public string CIFAsegurado { get; set; }
|
||||
public string Asegurado { get; set; }
|
||||
public string Teléfono1 { get; set; }
|
||||
public string Teléfono2 { get; set; }
|
||||
public string Email { get; set; }
|
||||
}
|
||||
}
|
||||
1425
bdAsegasa/Extensiones/polizassg.cs
Normal file
1425
bdAsegasa/Extensiones/polizassg.cs
Normal file
File diff suppressed because it is too large
Load Diff
16
bdAsegasa/Extensiones/procesos.cs
Normal file
16
bdAsegasa/Extensiones/procesos.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using bdAsegasa.dbcontext;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class procesos
|
||||
{
|
||||
public tsUtilidades.Permisos Permiso
|
||||
{
|
||||
get
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
return Utilidades.ObtienePermisos(bd, this.idPermiso, Utilidades.dsc.idUsuario);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
42
bdAsegasa/Extensiones/ramos.cs
Normal file
42
bdAsegasa/Extensiones/ramos.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class ramos
|
||||
{
|
||||
public static int[] ObtieneIDRamos(tscgestionasegasa bd, string[] CodigosRamos)
|
||||
{
|
||||
return bd.ramos.Where(x => CodigosRamos.Contains(x.Codigo)).Select(x => x.idRamo).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cambia de idRamo todas las pólzias asociadas al ramoAnterior y tras el cambio elimina dicho ramo
|
||||
/// </summary>
|
||||
public static bool EliminarRamo(tscgestionasegasa bd, string ramoAnterior, string ramoNuevo)
|
||||
{
|
||||
try
|
||||
{
|
||||
bd.Database.ExecuteSqlRaw("UPDATE polizassg set idRamo=" + ramoNuevo + " WHERE idRamo=" + ramoAnterior);
|
||||
bd.Database.ExecuteSqlRaw("DELETE FROM ramos where idRamo=" + ramoAnterior);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public string CodigoYDescripcion
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Codigo + " " + this.Descripcion;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2362
bdAsegasa/Extensiones/recibos.cs
Normal file
2362
bdAsegasa/Extensiones/recibos.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -39,9 +39,45 @@ namespace bdAsegasa.db
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public string DescripcionTipoFactura
|
||||
{
|
||||
get
|
||||
{
|
||||
switch ((TipoFacturaEnum)this.TipoFactura)
|
||||
{
|
||||
case TipoFacturaEnum.F1:
|
||||
return "F1 - Factura (art. 6, 7.2 y 7.3 del RD 1619/2012)";
|
||||
case TipoFacturaEnum.F2:
|
||||
return "F2 - Factura Simplificada y Facturas sin identificación del destinatario";
|
||||
case TipoFacturaEnum.F3:
|
||||
return "F3 - Factura emitida en sustitución de facturas simplificadas facturadas y declaradas";
|
||||
case TipoFacturaEnum.R1:
|
||||
return "R1 - Factura Rectificativa (Error fundado en derecho y Art. 80 Uno Dos y Seis LIVA)";
|
||||
case TipoFacturaEnum.R2:
|
||||
return "R2 - Factura Rectificativa (Art. 80.3). Cuando el destinatario de las operaciones sujetas al Impuesto no haya hecho efectivo el pago de las cuotas repercutidas y siempre que, con posterioridad al devengo de la operación, se dicte auto de declaración de concurso.";
|
||||
case TipoFacturaEnum.R3:
|
||||
return "R3 - Factura Rectificativa (Art. 80.4). Cuando los créditos correspondientes a las cuotas repercutidas por las operaciones gravadas sean total o parcialmente incobrables.";
|
||||
case TipoFacturaEnum.R4:
|
||||
return "R4 - Factura Rectificativa (Resto)";
|
||||
case TipoFacturaEnum.R5:
|
||||
return "R5 - Factura Rectificativa en facturas simplificadas. Factura emitida en sustitución de facturas simplificadas facturadas y declaradas";
|
||||
default:
|
||||
return "Tipo de factura desconocido";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum TipoFacturaEnum
|
||||
{
|
||||
F1,
|
||||
F2,
|
||||
F3,
|
||||
R1,
|
||||
R2,
|
||||
R3,
|
||||
R4,
|
||||
R5
|
||||
}
|
||||
|
||||
public enum OperacionEnum
|
||||
{
|
||||
|
||||
15
bdAsegasa/Extensiones/regularizacionespagosagentes.cs
Normal file
15
bdAsegasa/Extensiones/regularizacionespagosagentes.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class regularizacionespagosagentes
|
||||
{
|
||||
public enum TipoRegularizacion
|
||||
{
|
||||
DESCOBRO_RECIBO = 1,
|
||||
DEVOLUCION_PAGO_AL_AGENTE = 2,
|
||||
RECALCULO_COMISION = 3,
|
||||
CAMBIADO_DE_AGENTE = 4
|
||||
}
|
||||
|
||||
public string DescripcionTipo => ((TipoRegularizacion)this.Tipo).ToString().Replace("_", " ");
|
||||
}
|
||||
}
|
||||
44
bdAsegasa/Extensiones/seriesfacturas.cs
Normal file
44
bdAsegasa/Extensiones/seriesfacturas.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class seriesfacturas
|
||||
{
|
||||
private static List<string> _ListadoSeries;
|
||||
|
||||
public static List<string> ListadoSeries
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_ListadoSeries == null)
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
_ListadoSeries = bd.seriesfacturas.Select(x => x.Serie).ToList();
|
||||
}
|
||||
return _ListadoSeries;
|
||||
}
|
||||
}
|
||||
|
||||
public string SerieDescripcion
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Serie + " - " + this.Descripcion;
|
||||
}
|
||||
}
|
||||
|
||||
public string DescripcionClase
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((ClaseFacturaEnum)(this.Clase)).ToString().Replace("_", " ");
|
||||
}
|
||||
}
|
||||
|
||||
public enum ClaseFacturaEnum : int
|
||||
{
|
||||
LIQUIDACIONES_A_AGENTES = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
604
bdAsegasa/Extensiones/siniestros.cs
Normal file
604
bdAsegasa/Extensiones/siniestros.cs
Normal file
@@ -0,0 +1,604 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using bdAsegasa.db;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using tsUtilidades.Extensiones;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class siniestros
|
||||
{
|
||||
public int? idPoliza_Nulable
|
||||
{
|
||||
get
|
||||
{
|
||||
if (idPoliza == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return idPoliza;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value.HasValue)
|
||||
{
|
||||
idPoliza = value.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Contrario
|
||||
private bool _CifContrarioTmpEsNulo = true;
|
||||
private string _CifContrarioTmp;
|
||||
public string CifContrarioTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_CifContrarioTmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadContrarioNavigation == null) return "";
|
||||
_CifContrarioTmp = this.idEntidadContrarioNavigation.CIF;
|
||||
_CifContrarioTmpEsNulo = false;
|
||||
return this.idEntidadContrarioNavigation.CIF;
|
||||
}
|
||||
return _CifContrarioTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_CifContrarioTmp = value;
|
||||
_CifContrarioTmpEsNulo = false;
|
||||
if (this.idEntidadContrarioNavigation != null)
|
||||
{
|
||||
this.idEntidadContrarioNavigation.CIF = string.IsNullOrEmpty(value) ? null : value;
|
||||
}
|
||||
OnPropertyChanged("CifContrarioTmp");
|
||||
OnPropertyChanged("RazonSocialContrarioTmp");
|
||||
OnPropertyChanged("CodigoPostalContrarioTmp");
|
||||
OnPropertyChanged("DomicilioContrarioTmp");
|
||||
OnPropertyChanged("CodigoPoblacionContrarioTmp");
|
||||
OnPropertyChanged("PoblacionContrarioTmp");
|
||||
OnPropertyChanged("ProvinciaContrarioTmp");
|
||||
OnPropertyChanged("TelefonoContrario1Tmp");
|
||||
OnPropertyChanged("TelefonoContrario2Tmp");
|
||||
OnPropertyChanged("EmailContrarioTmp");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _RazonSocialContrarioTmpEsNulo = true;
|
||||
private string _RazonSocialContrarioTmp;
|
||||
public string RazonSocialContrarioTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_RazonSocialContrarioTmpEsNulo)
|
||||
{
|
||||
string rs = "";
|
||||
if (string.IsNullOrEmpty(this.idEntidadContrarioNavigation.RazonSocial))
|
||||
{
|
||||
rs = (this.idEntidadContrarioNavigation.Apellidos + ", " + this.idEntidadContrarioNavigation.Nombre).Trim().Trim(',');
|
||||
}
|
||||
else
|
||||
{
|
||||
rs = this.idEntidadContrarioNavigation.RazonSocial;
|
||||
}
|
||||
_RazonSocialContrarioTmpEsNulo = false;
|
||||
_RazonSocialContrarioTmp = rs;
|
||||
return rs;
|
||||
}
|
||||
return _RazonSocialContrarioTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_RazonSocialContrarioTmp = value;
|
||||
_RazonSocialContrarioTmpEsNulo = false;
|
||||
if (this.idEntidadContrarioNavigation != null)
|
||||
{
|
||||
this.idEntidadContrarioNavigation.RazonSocial = value;
|
||||
if (!string.IsNullOrEmpty(this.idEntidadContrarioNavigation.CIF) && "1234567890X".Contains(this.idEntidadContrarioNavigation.CIF.Substring(1, 1)) && value.Contains(","))
|
||||
{
|
||||
var parts = value.Split(',');
|
||||
this.idEntidadContrarioNavigation.Apellidos = parts[0].Trim();
|
||||
if (parts.Length > 1) this.idEntidadContrarioNavigation.Nombre = parts[1].Trim();
|
||||
}
|
||||
}
|
||||
OnPropertyChanged("RazonSocialContrarioTmp");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _CodigoPostalContrarioTmpEsNulo = true;
|
||||
private string _CodigoPostalContrarioTmp;
|
||||
public string CodigoPostalContrarioTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_CodigoPostalContrarioTmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadContrarioNavigation?.DireccionPrincipal == null) return "";
|
||||
_CodigoPostalContrarioTmp = this.idEntidadContrarioNavigation.DireccionPrincipal.CodigoPostal;
|
||||
_CodigoPostalContrarioTmpEsNulo = false;
|
||||
return _CodigoPostalContrarioTmp;
|
||||
}
|
||||
return _CodigoPostalContrarioTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_CodigoPostalContrarioTmp = value;
|
||||
_CodigoPostalContrarioTmpEsNulo = false;
|
||||
if (this.idEntidadContrarioNavigation?.DireccionPrincipal != null)
|
||||
{
|
||||
this.idEntidadContrarioNavigation.DireccionPrincipal.CodigoPostal = value;
|
||||
}
|
||||
OnPropertyChanged("CodigoPostalContrarioTmp");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _DomicilioContrarioTmpEsNulo = true;
|
||||
private string _DomicilioContrarioTmp;
|
||||
public string DomicilioContrarioTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_DomicilioContrarioTmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadContrarioNavigation?.DireccionPrincipal == null) return "";
|
||||
_DomicilioContrarioTmp = this.idEntidadContrarioNavigation.DireccionPrincipal.Direccion;
|
||||
_DomicilioContrarioTmpEsNulo = false;
|
||||
return _DomicilioContrarioTmp;
|
||||
}
|
||||
return _DomicilioContrarioTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_DomicilioContrarioTmp = value;
|
||||
_DomicilioContrarioTmpEsNulo = false;
|
||||
if (this.idEntidadContrarioNavigation?.DireccionPrincipal != null)
|
||||
{
|
||||
this.idEntidadContrarioNavigation.DireccionPrincipal.Direccion = value;
|
||||
}
|
||||
OnPropertyChanged("DomicilioContrarioTmp");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _CodigoPoblacionContrarioTmpEsNulo = true;
|
||||
private string _CodigoPoblacionContrarioTmp;
|
||||
public string CodigoPoblacionContrarioTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_CodigoPoblacionContrarioTmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadContrarioNavigation?.DireccionPrincipal == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
if (this.idEntidadContrarioNavigation.DireccionPrincipal.CodigoMunicipioNavigation == null && !string.IsNullOrEmpty(this.idEntidadContrarioNavigation.DireccionPrincipal.CodigoPostal))
|
||||
{
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var pob = bd.codigospostales.FirstOrDefault(x => x.CodigoPostal == this.idEntidadContrarioNavigation.DireccionPrincipal.CodigoPostal);
|
||||
if (pob != null)
|
||||
{
|
||||
this.idEntidadContrarioNavigation.DireccionPrincipal.CodigoMunicipio = pob.CodigoMunicipio;
|
||||
_CodigoPoblacionContrarioTmp = pob.CodigoMunicipio;
|
||||
_CodigoPoblacionContrarioTmpEsNulo = false;
|
||||
return _CodigoPoblacionContrarioTmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
_CodigoPoblacionContrarioTmp = this.idEntidadContrarioNavigation.DireccionPrincipal.CodigoMunicipio;
|
||||
_CodigoPoblacionContrarioTmpEsNulo = false;
|
||||
return _CodigoPoblacionContrarioTmp;
|
||||
}
|
||||
return _CodigoPoblacionContrarioTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_CodigoPoblacionContrarioTmp = value;
|
||||
_CodigoPoblacionContrarioTmpEsNulo = false;
|
||||
if (this.idEntidadContrarioNavigation?.DireccionPrincipal != null)
|
||||
{
|
||||
this.idEntidadContrarioNavigation.DireccionPrincipal.CodigoMunicipio = value;
|
||||
}
|
||||
OnPropertyChanged("CodigoPoblacionContrarioTmp");
|
||||
OnPropertyChanged("PoblacionContrarioTmp");
|
||||
OnPropertyChanged("ProvinciaContrarioTmp");
|
||||
}
|
||||
}
|
||||
|
||||
public string PoblacionContrarioTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
return municipios.ObtienePoblacion(CodigoPoblacionContrarioTmp);
|
||||
}
|
||||
}
|
||||
public string ProvinciaContrarioTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
return municipios.ObtieneProvincia(CodigoPoblacionContrarioTmp);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _TelefonoContrario1TmpEsNulo = true;
|
||||
private string _TelefonoContrario1Tmp;
|
||||
public string TelefonoContrario1Tmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_TelefonoContrario1TmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadContrarioNavigation == null) return "";
|
||||
_TelefonoContrario1Tmp = this.idEntidadContrarioNavigation.Telefono1;
|
||||
_TelefonoContrario1TmpEsNulo = false;
|
||||
return _TelefonoContrario1Tmp;
|
||||
}
|
||||
return _TelefonoContrario1Tmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_TelefonoContrario1Tmp = value;
|
||||
_TelefonoContrario1TmpEsNulo = false;
|
||||
if (this.idEntidadContrarioNavigation != null) this.idEntidadContrarioNavigation.Telefono1 = value;
|
||||
OnPropertyChanged("TelefonoContrario1Tmp");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _TelefonoContrario2TmpEsNulo = true;
|
||||
private string _TelefonoContrario2Tmp;
|
||||
public string TelefonoContrario2Tmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_TelefonoContrario2TmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadContrarioNavigation == null) return "";
|
||||
_TelefonoContrario2Tmp = this.idEntidadContrarioNavigation.Telefono2;
|
||||
_TelefonoContrario2TmpEsNulo = false;
|
||||
return _TelefonoContrario2Tmp;
|
||||
}
|
||||
return _TelefonoContrario2Tmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_TelefonoContrario2Tmp = value;
|
||||
_TelefonoContrario2TmpEsNulo = false;
|
||||
if (this.idEntidadContrarioNavigation != null) this.idEntidadContrarioNavigation.Telefono2 = value;
|
||||
OnPropertyChanged("TelefonoContrario2Tmp");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _EmailContrarioTmpEsNulo = true;
|
||||
private string _EmailContrarioTmp;
|
||||
public string EmailContrarioTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_EmailContrarioTmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadContrarioNavigation == null) return "";
|
||||
_EmailContrarioTmp = this.idEntidadContrarioNavigation.Email;
|
||||
_EmailContrarioTmpEsNulo = false;
|
||||
return _EmailContrarioTmp;
|
||||
}
|
||||
return _EmailContrarioTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_EmailContrarioTmp = value;
|
||||
_EmailContrarioTmpEsNulo = false;
|
||||
if (this.idEntidadContrarioNavigation != null) this.idEntidadContrarioNavigation.Email = value;
|
||||
OnPropertyChanged("EmailContrarioTmp");
|
||||
}
|
||||
}
|
||||
|
||||
public void ReiniciaValoresTMPContrario()
|
||||
{
|
||||
_CifContrarioTmpEsNulo = true;
|
||||
_RazonSocialContrarioTmpEsNulo = true;
|
||||
_CodigoPoblacionContrarioTmpEsNulo = true;
|
||||
_CodigoPostalContrarioTmpEsNulo = true;
|
||||
_DomicilioContrarioTmpEsNulo = true;
|
||||
_TelefonoContrario1TmpEsNulo = true;
|
||||
_TelefonoContrario2TmpEsNulo = true;
|
||||
_EmailContrarioTmpEsNulo = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Taller
|
||||
private bool _CifTallerTmpEsNulo = true;
|
||||
private string _CifTallerTmp;
|
||||
public string CifTallerTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_CifTallerTmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadTallerNavigation == null) return "";
|
||||
_CifTallerTmp = this.idEntidadTallerNavigation.CIF;
|
||||
_CifTallerTmpEsNulo = false;
|
||||
return _CifTallerTmp;
|
||||
}
|
||||
return _CifTallerTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_CifTallerTmp = value;
|
||||
_CifTallerTmpEsNulo = false;
|
||||
if (this.idEntidadTallerNavigation != null)
|
||||
{
|
||||
this.idEntidadTallerNavigation.CIF = string.IsNullOrEmpty(value) ? null : value;
|
||||
}
|
||||
OnPropertyChanged("CifTallerTmp");
|
||||
OnPropertyChanged("RazonSocialTallerTmp");
|
||||
OnPropertyChanged("CodigoPostalTallerTmp");
|
||||
OnPropertyChanged("DomicilioTallerTmp");
|
||||
OnPropertyChanged("CodigoPoblacionTallerTmp");
|
||||
OnPropertyChanged("PoblacionTallerTmp");
|
||||
OnPropertyChanged("ProvinciaTallerTmp");
|
||||
OnPropertyChanged("TelefonoTallerTmp");
|
||||
OnPropertyChanged("EmailTallerTmp");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _RazonSocialTallerTmpEsNulo = true;
|
||||
private string _RazonSocialTallerTmp;
|
||||
public string RazonSocialTallerTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_RazonSocialTallerTmpEsNulo)
|
||||
{
|
||||
string rs = "";
|
||||
if (string.IsNullOrEmpty(this.idEntidadTallerNavigation.RazonSocial))
|
||||
{
|
||||
rs = (this.idEntidadTallerNavigation.Apellidos + ", " + this.idEntidadTallerNavigation.Nombre).Trim().Trim(',');
|
||||
}
|
||||
else
|
||||
{
|
||||
rs = this.idEntidadTallerNavigation.RazonSocial;
|
||||
}
|
||||
_RazonSocialTallerTmpEsNulo = false;
|
||||
_RazonSocialTallerTmp = rs;
|
||||
return rs;
|
||||
}
|
||||
return _RazonSocialTallerTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_RazonSocialTallerTmp = value;
|
||||
_RazonSocialTallerTmpEsNulo = false;
|
||||
if (this.idEntidadTallerNavigation != null)
|
||||
{
|
||||
this.idEntidadTallerNavigation.RazonSocial = value;
|
||||
if (!string.IsNullOrEmpty(this.idEntidadTallerNavigation.CIF) && "1234567890X".Contains(this.idEntidadTallerNavigation.CIF.Substring(1, 1)) && value.Contains(","))
|
||||
{
|
||||
var parts = value.Split(',');
|
||||
this.idEntidadTallerNavigation.Apellidos = parts[0].Trim();
|
||||
if (parts.Length > 1) this.idEntidadTallerNavigation.Nombre = parts[1].Trim();
|
||||
}
|
||||
}
|
||||
OnPropertyChanged("RazonSocialTallerTmp");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _CodigoPostalTallerTmpEsNulo = true;
|
||||
private string _CodigoPostalTallerTmp;
|
||||
public string CodigoPostalTallerTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_CodigoPostalTallerTmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadTallerNavigation?.DireccionPrincipal == null) return "";
|
||||
_CodigoPostalTallerTmp = this.idEntidadTallerNavigation.DireccionPrincipal.CodigoPostal;
|
||||
_CodigoPostalTallerTmpEsNulo = false;
|
||||
return _CodigoPostalTallerTmp;
|
||||
}
|
||||
return _CodigoPostalTallerTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_CodigoPostalTallerTmp = value;
|
||||
_CodigoPostalTallerTmpEsNulo = false;
|
||||
if (this.idEntidadTallerNavigation?.DireccionPrincipal != null)
|
||||
{
|
||||
this.idEntidadTallerNavigation.DireccionPrincipal.CodigoPostal = value;
|
||||
}
|
||||
OnPropertyChanged("CodigoPostalTallerTmp");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _DomicilioTallerTmpEsNulo = true;
|
||||
private string _DomicilioTallerTmp;
|
||||
public string DomicilioTallerTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_DomicilioTallerTmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadTallerNavigation?.DireccionPrincipal == null) return "";
|
||||
_DomicilioTallerTmp = this.idEntidadTallerNavigation.DireccionPrincipal.Direccion;
|
||||
_DomicilioTallerTmpEsNulo = false;
|
||||
return _DomicilioTallerTmp;
|
||||
}
|
||||
return _DomicilioTallerTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_DomicilioTallerTmp = value;
|
||||
_DomicilioTallerTmpEsNulo = false;
|
||||
if (this.idEntidadTallerNavigation?.DireccionPrincipal != null)
|
||||
{
|
||||
this.idEntidadTallerNavigation.DireccionPrincipal.Direccion = value;
|
||||
}
|
||||
OnPropertyChanged("DomicilioTallerTmp");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _CodigoPoblacionTallerTmpEsNulo = true;
|
||||
private string _CodigoPoblacionTallerTmp;
|
||||
public string CodigoPoblacionTallerTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_CodigoPoblacionTallerTmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadTallerNavigation?.DireccionPrincipal == null) return "";
|
||||
if (this.idEntidadTallerNavigation.DireccionPrincipal.CodigoMunicipioNavigation == null && !string.IsNullOrEmpty(this.idEntidadTallerNavigation.DireccionPrincipal.CodigoPostal))
|
||||
{
|
||||
using (var bd =tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var pob = bd.codigospostales.FirstOrDefault(x => x.CodigoPostal == this.idEntidadTallerNavigation.DireccionPrincipal.CodigoPostal);
|
||||
if (pob != null)
|
||||
{
|
||||
this.idEntidadTallerNavigation.DireccionPrincipal.CodigoMunicipio = pob.CodigoMunicipio;
|
||||
_CodigoPoblacionTallerTmp = pob.CodigoMunicipio;
|
||||
_CodigoPoblacionTallerTmpEsNulo = false;
|
||||
return _CodigoPoblacionTallerTmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
_CodigoPoblacionTallerTmp = this.idEntidadTallerNavigation.DireccionPrincipal.CodigoMunicipio;
|
||||
_CodigoPoblacionTallerTmpEsNulo = false;
|
||||
return _CodigoPoblacionTallerTmp;
|
||||
}
|
||||
return _CodigoPoblacionTallerTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_CodigoPoblacionTallerTmp = value;
|
||||
_CodigoPoblacionTallerTmpEsNulo = false;
|
||||
if (this.idEntidadTallerNavigation?.DireccionPrincipal != null)
|
||||
{
|
||||
this.idEntidadTallerNavigation.DireccionPrincipal.CodigoMunicipio = value;
|
||||
}
|
||||
OnPropertyChanged("CodigoPoblacionTallerTmp");
|
||||
OnPropertyChanged("PoblacionTallerTmp");
|
||||
OnPropertyChanged("ProvinciaTallerTmp");
|
||||
}
|
||||
}
|
||||
|
||||
public string PoblacionTallerTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
return municipios.ObtienePoblacion(CodigoPoblacionTallerTmp);
|
||||
}
|
||||
}
|
||||
public string ProvinciaTallerTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
return municipios.ObtieneProvincia(CodigoPoblacionTallerTmp);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _TelefonoTallerTmpEsNulo = true;
|
||||
private string _TelefonoTallerTmp;
|
||||
public string TelefonoTallerTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_TelefonoTallerTmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadTallerNavigation == null) return "";
|
||||
_TelefonoTallerTmp = this.idEntidadTallerNavigation.Telefono1;
|
||||
_TelefonoTallerTmpEsNulo = false;
|
||||
return _TelefonoTallerTmp;
|
||||
}
|
||||
return _TelefonoTallerTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_TelefonoTallerTmp = value;
|
||||
_TelefonoTallerTmpEsNulo = false;
|
||||
if (this.idEntidadTallerNavigation != null) this.idEntidadTallerNavigation.Telefono1 = value;
|
||||
OnPropertyChanged("TelefonoTallerTmp");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _EmailTallerTmpEsNulo = true;
|
||||
private string _EmailTallerTmp;
|
||||
public string EmailTallerTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_EmailTallerTmpEsNulo)
|
||||
{
|
||||
if (this.idEntidadTallerNavigation == null) return "";
|
||||
_EmailTallerTmp = this.idEntidadTallerNavigation.Email;
|
||||
_EmailTallerTmpEsNulo = false;
|
||||
return _EmailTallerTmp;
|
||||
}
|
||||
return _EmailTallerTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_EmailTallerTmp = value;
|
||||
_EmailTallerTmpEsNulo = false;
|
||||
if (this.idEntidadTallerNavigation != null) this.idEntidadTallerNavigation.Email = value;
|
||||
OnPropertyChanged("EmailTallerTmp");
|
||||
}
|
||||
}
|
||||
|
||||
public void ReiniciaValoresTMPTaller()
|
||||
{
|
||||
_CifTallerTmpEsNulo = true;
|
||||
_RazonSocialTallerTmpEsNulo = true;
|
||||
_CodigoPoblacionTallerTmpEsNulo = true;
|
||||
_CodigoPostalTallerTmpEsNulo = true;
|
||||
_DomicilioTallerTmpEsNulo = true;
|
||||
_TelefonoTallerTmpEsNulo = true;
|
||||
_EmailTallerTmpEsNulo = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static void GuardandoCambios(tscgestionasegasa bd)
|
||||
{
|
||||
var addedEntries = bd.ChangeTracker.Entries<gestionessiniestros>()
|
||||
.Where(e => e.State == EntityState.Added);
|
||||
AsignaidUsuarioCreadorGestionesSiniestros(bd, addedEntries);
|
||||
|
||||
var modifiedEntries = bd.ChangeTracker.Entries<gestionessiniestros>()
|
||||
.Where(e => e.State == EntityState.Modified);
|
||||
AsignaidUsuarioModificadorGestionesSiniestros(bd, modifiedEntries);
|
||||
}
|
||||
|
||||
private static void AsignaidUsuarioCreadorGestionesSiniestros(tscgestionasegasa bd, IEnumerable<Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<gestionessiniestros>> entries)
|
||||
{
|
||||
if (entries.Any() && bdAsegasa.db.Utilidades.dsc.idUsuario > 0)
|
||||
{
|
||||
var ahora = DateTime.Now;
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
var r = entry.Entity;
|
||||
r.idUsuarioCreador = bdAsegasa.db.Utilidades.dsc.idUsuario;
|
||||
r.idUsuarioModificador = bdAsegasa.db.Utilidades.dsc.idUsuario;
|
||||
r.FechaModificacion = ahora;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void AsignaidUsuarioModificadorGestionesSiniestros(tscgestionasegasa bd, IEnumerable<Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<gestionessiniestros>> entries)
|
||||
{
|
||||
if (entries.Any() && bdAsegasa.db.Utilidades.dsc.idUsuario > 0)
|
||||
{
|
||||
var ahora = DateTime.Now;
|
||||
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
var r = entry.Entity;
|
||||
r.idUsuarioModificador = bdAsegasa.db.Utilidades.dsc.idUsuario;
|
||||
r.FechaModificacion = ahora;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
41
bdAsegasa/Extensiones/siniestros_eiac.cs
Normal file
41
bdAsegasa/Extensiones/siniestros_eiac.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class siniestros_eiac
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
public enum ClavesPosicionSiniestroEnum : int
|
||||
{
|
||||
CULPA = 1,
|
||||
RECLAMACIÓN = 2,
|
||||
INDETERMINADO = 3,
|
||||
NO_APLICA = 4,
|
||||
DESCONOCIDA = 99
|
||||
}
|
||||
|
||||
|
||||
|
||||
public enum SituacionAsegasaENUM : int
|
||||
{
|
||||
NUEVO = 1,
|
||||
MODIFICADO = 2,
|
||||
POLIZA_NO_ENCONTRADA = 10,
|
||||
SINIESTRO_NO_ENCONTRADO = 11,
|
||||
VARIOS_SINIESTROS_POSIBLES = 12,
|
||||
VISUALIZADO = 100,
|
||||
DESCARTADO = 200
|
||||
}
|
||||
|
||||
public string DescripcionPosicionSiniestro => ((ClavesPosicionSiniestroEnum)(this.PosicionSiniestro)).ToString().Replace("_", " ");
|
||||
|
||||
|
||||
public string DescripcionSituacionAsegasa => this.SituacionAsegasa.HasValue
|
||||
? ((SituacionAsegasaENUM)this.SituacionAsegasa.Value).ToString().Replace("_", " ")
|
||||
: "";
|
||||
}
|
||||
}
|
||||
56
bdAsegasa/Extensiones/subagentes.cs
Normal file
56
bdAsegasa/Extensiones/subagentes.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using bdAsegasa.dbcontext;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class subagentes
|
||||
{
|
||||
private static List<subagentes> _ListaSubagentes;
|
||||
|
||||
public bool AMarcarComoBaja { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public List<polizassg> PolizasConDocumentosPendientes
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.polizassg.Where(x => x.documentospolizassg.Any(y => y.Obligatorio && y.FechaComprobacion == null && y.idFichero == null)).ToList();
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public List<polizassg> PolizasConDocumentosPendientes7Dias
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
|
||||
|
||||
DateTime FechaInicio = DateTime.Today.AddDays(-7);
|
||||
return this.polizassg.Where(x => x.FechaAlta >= FechaInicio).ToList().Where(x => x.documentospolizassg.Any(y => y.Obligatorio && y.FechaComprobacion == null && y.idFichero == null)).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<subagentes> ListaSubAgentes()
|
||||
{
|
||||
if (_ListaSubagentes == null)
|
||||
{
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
_ListaSubagentes = bd.subagentes.OrderBy(x => x.Nombre).ToList();
|
||||
}
|
||||
}
|
||||
return _ListaSubagentes;
|
||||
}
|
||||
|
||||
public string CodigoYNombre
|
||||
{
|
||||
get
|
||||
{
|
||||
return Codigo + " - " + Nombre;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
18
bdAsegasa/Extensiones/tiposgestionsiniestros.cs
Normal file
18
bdAsegasa/Extensiones/tiposgestionsiniestros.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class tiposgestionsiniestros
|
||||
{
|
||||
public string DescripcionDetallada
|
||||
{
|
||||
get
|
||||
{
|
||||
string s = $"{this.Descripcion} *{this.Codigo} * ";
|
||||
if (this.idDestinatario.HasValue)
|
||||
{
|
||||
s += $"(DESTINATARIO: {this.idDestinatarioNavigation?.Descripcion})";
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
127
bdAsegasa/Extensiones/ve_recibos.cs
Normal file
127
bdAsegasa/Extensiones/ve_recibos.cs
Normal file
@@ -0,0 +1,127 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using tsUtilidades;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public class ve_recibos
|
||||
{
|
||||
public int idRecibo { get; set; }
|
||||
public int idPoliza { get; set; }
|
||||
public DateOnly? FechaFacturacion { get; set; }
|
||||
public DateOnly? FechaPago { get; set; }
|
||||
public string CodigoRecibo { get; set; }
|
||||
public string NumeroPoliza { get; set; }
|
||||
public string Tomador { get; set; }
|
||||
public string CIFTomador { get; set; }
|
||||
public string Telefono1Tomador { get; set; }
|
||||
public string Telefono2Tomador { get; set; }
|
||||
public string Matricula { get; set; }
|
||||
public DateOnly FechaEfecto { get; set; }
|
||||
public DateOnly? FechaRecepcionCia { get; set; }
|
||||
public DateOnly FechaVencimiento { get; set; }
|
||||
public string Compania { get; set; }
|
||||
public string Agente { get; set; }
|
||||
public string SubAgente { get; set; }
|
||||
public string Ramo { get; set; }
|
||||
public DateOnly? FechaExpedicion { get; set; }
|
||||
|
||||
public string BienesAsegurados { get; set; }
|
||||
public DateOnly? FechaBaja { get; set; }
|
||||
public DateOnly? FechaDevolucionBanco { get; set; }
|
||||
public string CausaBaja { get; set; }
|
||||
public string TipoRecibo { get; set; }
|
||||
public string TipoPago { get; set; }
|
||||
public string Oficina { get; set; }
|
||||
public double? PrimaNeta { get; set; }
|
||||
public double? BonificacionORecargo { get; set; }
|
||||
public double? Consorcio { get; set; }
|
||||
public double? Impuesto { get; set; }
|
||||
public double? RecargoExterno { get; set; }
|
||||
public double? TotalRecibo { get; set; }
|
||||
public double? ComisionReciboPrimaNeta { get; set; }
|
||||
public double? PorcentajeReciboPrimaNeta { get; set; }
|
||||
public double? TotalComision { get; set; }
|
||||
public double? SobreComision { get; set; }
|
||||
public double? PorcentajeComisionAgente { get; set; }
|
||||
public double? ComisionAgente { get; set; }
|
||||
public double? ComisionAsegasaPrimaNeta { get; set; }
|
||||
public double? AsegasaRecargoExterno { get; set; }
|
||||
public double? AsegasaComisionConsorcio { get; set; }
|
||||
public double? AsegasaComisionTotal { get; set; }
|
||||
public double? ComisionPrevista { get; set; }
|
||||
|
||||
public double DiferenciaComision
|
||||
{
|
||||
get
|
||||
{
|
||||
double crpn = ComisionReciboPrimaNeta ?? 0;
|
||||
double cp = ComisionPrevista ?? 0;
|
||||
return Math.Round(crpn - cp, 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
|
||||
public int? idSituacion { get; set; }
|
||||
public DateOnly? FechaLiquidacionAgente { get; set; }
|
||||
public DateOnly? FechaLiquidacionCia { get; set; }
|
||||
public DateOnly? FechaLiquidacionCiaDevuelto { get; set; }
|
||||
|
||||
public static int? idSitr1 = null;
|
||||
public bool BloquearFacturacion
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!idSitr1.HasValue)
|
||||
{
|
||||
using (var bd = bdAsegasa.tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
idSitr1 = bd.enumeraciones.FirstOrDefault(x => x.Codigo == "SITR.1")?.idEnumeracion;
|
||||
}
|
||||
}
|
||||
return idSituacion.HasValue && idSituacion.Value == idSitr1;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!idSitr1.HasValue)
|
||||
{
|
||||
using (var bd = bdAsegasa.tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
idSitr1 = bd.enumeraciones.FirstOrDefault(x => x.Codigo == "SITR.1")?.idEnumeracion;
|
||||
}
|
||||
}
|
||||
if (value)
|
||||
{
|
||||
idSituacion = idSitr1;
|
||||
}
|
||||
else
|
||||
{
|
||||
idSituacion = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string TelefonoMovilValido
|
||||
{
|
||||
get
|
||||
{
|
||||
if (tsUtilidades.Extensiones.StringExtensions.EsNumeroTelefonoMovilEspañolValido(Telefono1Tomador))
|
||||
{
|
||||
return Telefono1Tomador;
|
||||
}
|
||||
else if (tsUtilidades.Extensiones.StringExtensions.EsNumeroTelefonoMovilEspañolValido(Telefono2Tomador))
|
||||
{
|
||||
return Telefono2Tomador;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Observaciones { get; set; }
|
||||
public string ObservacionesPoliza { get; set; }
|
||||
public DateOnly? FechaRemesa { get; set; }
|
||||
}
|
||||
}
|
||||
324
bdAsegasa/Extensiones/vf_cuentas.cs
Normal file
324
bdAsegasa/Extensiones/vf_cuentas.cs
Normal file
@@ -0,0 +1,324 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using tsUtilidades.Extensiones;
|
||||
using System.Linq.Dynamic.Core;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class vf_cuentas
|
||||
{
|
||||
public static List<vf_cuentas> Obtiene_vf_cuentas(gestionasegasaEntities bd, int idEjercicio, int Nivel)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<vf_cuentas> lc;
|
||||
var ctasintermedias = bd.cuentas.Where(x => !x.EsCuentaFinal && x.idEjercicio == idEjercicio && x.NumeroCuenta.Length <= Nivel).ToList();
|
||||
var ctasf = bd.vf_cuentas.Where(x => x.idEjercicio == idEjercicio).ToList();
|
||||
|
||||
if (Nivel == 8)
|
||||
{
|
||||
lc = ctasf;
|
||||
}
|
||||
else
|
||||
{
|
||||
lc = new List<vf_cuentas>();
|
||||
foreach (var cta in ctasintermedias.Where(x => x.Nivel == Nivel))
|
||||
{
|
||||
var sumatorio = ctasf.Where(x => x.NumeroCuenta.StartsWith(cta.NumeroCuenta));
|
||||
var nc = new vf_cuentas();
|
||||
nc.idCuenta = cta.idCuenta;
|
||||
nc.idEjercicio = cta.idEjercicio;
|
||||
nc.Mote = cta.Mote;
|
||||
nc.Denominacion = cta.Denominacion;
|
||||
nc.idEmpresaAmortizacion = cta.idEmpresaAmortizacion;
|
||||
nc.NumeroCuenta = cta.NumeroCuenta;
|
||||
nc.Observaciones = cta.Observaciones;
|
||||
|
||||
nc.PresupuestoEnero = Math.Round(sumatorio.Sum(x => x.PresupuestoEnero), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoFebrero = Math.Round(sumatorio.Sum(x => x.PresupuestoFebrero), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoMarzo = Math.Round(sumatorio.Sum(x => x.PresupuestoMarzo), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoAbril = Math.Round(sumatorio.Sum(x => x.PresupuestoAbril), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoMayo = Math.Round(sumatorio.Sum(x => x.PresupuestoMayo), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoJunio = Math.Round(sumatorio.Sum(x => x.PresupuestoJunio), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoJulio = Math.Round(sumatorio.Sum(x => x.PresupuestoJulio), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoAgosto = Math.Round(sumatorio.Sum(x => x.PresupuestoAgosto), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoSeptiembre = Math.Round(sumatorio.Sum(x => x.PresupuestoSeptiembre), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoOctubre = Math.Round(sumatorio.Sum(x => x.PresupuestoOctubre), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoNoviembre = Math.Round(sumatorio.Sum(x => x.PresupuestoNoviembre), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoDiciembre = Math.Round(sumatorio.Sum(x => x.PresupuestoDiciembre), 2, MidpointRounding.AwayFromZero);
|
||||
|
||||
nc.DebeEnero = Math.Round(sumatorio.Sum(x => x.DebeEnero.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeFebrero = Math.Round(sumatorio.Sum(x => x.DebeFebrero.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeMarzo = Math.Round(sumatorio.Sum(x => x.DebeMarzo.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeAbril = Math.Round(sumatorio.Sum(x => x.DebeAbril.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeMayo = Math.Round(sumatorio.Sum(x => x.DebeMayo.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeJunio = Math.Round(sumatorio.Sum(x => x.DebeJunio.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeJulio = Math.Round(sumatorio.Sum(x => x.DebeJulio.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeAgosto = Math.Round(sumatorio.Sum(x => x.DebeAgosto.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeSeptiembre = Math.Round(sumatorio.Sum(x => x.DebeSeptiembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeOctubre = Math.Round(sumatorio.Sum(x => x.DebeOctubre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeNoviembre = Math.Round(sumatorio.Sum(x => x.DebeNoviembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeDiciembre = Math.Round(sumatorio.Sum(x => x.DebeDiciembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
|
||||
nc.HaberEnero = Math.Round(sumatorio.Sum(x => x.HaberEnero.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberFebrero = Math.Round(sumatorio.Sum(x => x.HaberFebrero.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberMarzo = Math.Round(sumatorio.Sum(x => x.HaberMarzo.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberAbril = Math.Round(sumatorio.Sum(x => x.HaberAbril.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberMayo = Math.Round(sumatorio.Sum(x => x.HaberMayo.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberJunio = Math.Round(sumatorio.Sum(x => x.HaberJunio.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberJulio = Math.Round(sumatorio.Sum(x => x.HaberJulio.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberAgosto = Math.Round(sumatorio.Sum(x => x.HaberAgosto.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberSeptiembre = Math.Round(sumatorio.Sum(x => x.HaberSeptiembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberOctubre = Math.Round(sumatorio.Sum(x => x.HaberOctubre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberNoviembre = Math.Round(sumatorio.Sum(x => x.HaberNoviembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberDiciembre = Math.Round(sumatorio.Sum(x => x.HaberDiciembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
|
||||
nc.TotalDebe = Math.Round(sumatorio.Sum(x => x.TotalDebe), 2, MidpointRounding.AwayFromZero);
|
||||
nc.TotalHaber = Math.Round(sumatorio.Sum(x => x.TotalHaber), 2, MidpointRounding.AwayFromZero);
|
||||
lc.Add(nc);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var cta in lc)
|
||||
{
|
||||
try
|
||||
{
|
||||
var cta1 = ctasintermedias.First(x => x.NumeroCuenta == cta.NumeroCuenta.Substring(0, 1));
|
||||
cta.Grupo1 = cta1.NumeroCuenta + " " + cta1.Denominacion;
|
||||
if (cta.Nivel > 1)
|
||||
{
|
||||
var cta2 = ctasintermedias.First(x => x.NumeroCuenta == cta.NumeroCuenta.Substring(0, 2));
|
||||
cta.Grupo2 = cta2.NumeroCuenta + " " + cta2.Denominacion;
|
||||
if (cta.Nivel > 2)
|
||||
{
|
||||
var cta3 = ctasintermedias.First(x => x.NumeroCuenta == cta.NumeroCuenta.Substring(0, 3));
|
||||
cta.Grupo3 = cta3.NumeroCuenta + " " + cta3.Denominacion;
|
||||
if (cta.Nivel > 3)
|
||||
{
|
||||
var cta4 = ctasintermedias.First(x => x.NumeroCuenta == cta.NumeroCuenta.Substring(0, 4));
|
||||
cta.Grupo4 = cta4.NumeroCuenta + " " + cta4.Denominacion;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Error obteniendo cuentas intermedia de la cuenta " + cta.NumeroCuenta + " " + ex.Message, ex);
|
||||
}
|
||||
}
|
||||
return lc;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<vf_cuentas> Obtiene_vf_cuentas(gestionasegasaEntities bd, int[] Ejercicios, int Nivel, string ExpresionBusqueda)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<vf_cuentas> lc;
|
||||
IQueryable<cuentas> qCtasIntermedias = bd.cuentas.Where(x => !x.EsCuentaFinal && Ejercicios.Contains(x.idEjercicio) && x.NumeroCuenta.Length <= Nivel);
|
||||
IQueryable<vf_cuentas> qcastf;
|
||||
|
||||
if (string.IsNullOrEmpty(ExpresionBusqueda))
|
||||
{
|
||||
qcastf = bd.vf_cuentas.AsQueryable();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Using System.Linq.Dynamic.Core for dynamic filtering
|
||||
qcastf = bd.vf_cuentas.Where(ExpresionBusqueda);
|
||||
if (Nivel < 8)
|
||||
{
|
||||
string expr = $"NumeroCuenta.Length<{Nivel} or ({ExpresionBusqueda})";
|
||||
qCtasIntermedias = qCtasIntermedias.Where(expr);
|
||||
}
|
||||
}
|
||||
|
||||
var ctasintermedias = qCtasIntermedias.ToList();
|
||||
var ctasf = qcastf.Where(x => Ejercicios.Contains(x.idEjercicio)).ToList();
|
||||
|
||||
if (Nivel == 8)
|
||||
{
|
||||
lc = ctasf;
|
||||
}
|
||||
else
|
||||
{
|
||||
lc = new List<vf_cuentas>();
|
||||
foreach (var cta in ctasintermedias.Where(x => x.Nivel == Nivel))
|
||||
{
|
||||
var sumatorio = ctasf.Where(x => x.idEjercicio == cta.idEjercicio && x.NumeroCuenta.StartsWith(cta.NumeroCuenta));
|
||||
var nc = new vf_cuentas();
|
||||
nc.idCuenta = cta.idCuenta;
|
||||
nc.idEjercicio = cta.idEjercicio;
|
||||
nc.Mote = cta.Mote;
|
||||
nc.Denominacion = cta.Denominacion;
|
||||
nc.idEmpresaAmortizacion = cta.idEmpresaAmortizacion;
|
||||
nc.NumeroCuenta = cta.NumeroCuenta;
|
||||
nc.Observaciones = cta.Observaciones;
|
||||
|
||||
nc.PresupuestoEnero = Math.Round(sumatorio.Sum(x => x.PresupuestoEnero), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoFebrero = Math.Round(sumatorio.Sum(x => x.PresupuestoFebrero), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoMarzo = Math.Round(sumatorio.Sum(x => x.PresupuestoMarzo), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoAbril = Math.Round(sumatorio.Sum(x => x.PresupuestoAbril), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoMayo = Math.Round(sumatorio.Sum(x => x.PresupuestoMayo), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoJunio = Math.Round(sumatorio.Sum(x => x.PresupuestoJunio), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoJulio = Math.Round(sumatorio.Sum(x => x.PresupuestoJulio), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoAgosto = Math.Round(sumatorio.Sum(x => x.PresupuestoAgosto), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoSeptiembre = Math.Round(sumatorio.Sum(x => x.PresupuestoSeptiembre), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoOctubre = Math.Round(sumatorio.Sum(x => x.PresupuestoOctubre), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoNoviembre = Math.Round(sumatorio.Sum(x => x.PresupuestoNoviembre), 2, MidpointRounding.AwayFromZero);
|
||||
nc.PresupuestoDiciembre = Math.Round(sumatorio.Sum(x => x.PresupuestoDiciembre), 2, MidpointRounding.AwayFromZero);
|
||||
|
||||
nc.DebeEnero = Math.Round(sumatorio.Sum(x => x.DebeEnero.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeFebrero = Math.Round(sumatorio.Sum(x => x.DebeFebrero.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeMarzo = Math.Round(sumatorio.Sum(x => x.DebeMarzo.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeAbril = Math.Round(sumatorio.Sum(x => x.DebeAbril.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeMayo = Math.Round(sumatorio.Sum(x => x.DebeMayo.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeJunio = Math.Round(sumatorio.Sum(x => x.DebeJunio.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeJulio = Math.Round(sumatorio.Sum(x => x.DebeJulio.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeAgosto = Math.Round(sumatorio.Sum(x => x.DebeAgosto.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeSeptiembre = Math.Round(sumatorio.Sum(x => x.DebeSeptiembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeOctubre = Math.Round(sumatorio.Sum(x => x.DebeOctubre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeNoviembre = Math.Round(sumatorio.Sum(x => x.DebeNoviembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.DebeDiciembre = Math.Round(sumatorio.Sum(x => x.DebeDiciembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
|
||||
nc.HaberEnero = Math.Round(sumatorio.Sum(x => x.HaberEnero.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberFebrero = Math.Round(sumatorio.Sum(x => x.HaberFebrero.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberMarzo = Math.Round(sumatorio.Sum(x => x.HaberMarzo.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberAbril = Math.Round(sumatorio.Sum(x => x.HaberAbril.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberMayo = Math.Round(sumatorio.Sum(x => x.HaberMayo.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberJunio = Math.Round(sumatorio.Sum(x => x.HaberJunio.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberJulio = Math.Round(sumatorio.Sum(x => x.HaberJulio.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberAgosto = Math.Round(sumatorio.Sum(x => x.HaberAgosto.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberSeptiembre = Math.Round(sumatorio.Sum(x => x.HaberSeptiembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberOctubre = Math.Round(sumatorio.Sum(x => x.HaberOctubre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberNoviembre = Math.Round(sumatorio.Sum(x => x.HaberNoviembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
nc.HaberDiciembre = Math.Round(sumatorio.Sum(x => x.HaberDiciembre.NothingA0()), 2, MidpointRounding.AwayFromZero);
|
||||
|
||||
nc.TotalDebe = Math.Round(sumatorio.Sum(x => x.TotalDebe), 2, MidpointRounding.AwayFromZero);
|
||||
nc.TotalHaber = Math.Round(sumatorio.Sum(x => x.TotalHaber), 2, MidpointRounding.AwayFromZero);
|
||||
lc.Add(nc);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var cta in lc)
|
||||
{
|
||||
try
|
||||
{
|
||||
var cta1 = ctasintermedias.First(x => x.NumeroCuenta == cta.NumeroCuenta.Substring(0, 1) && x.idEjercicio == cta.idEjercicio);
|
||||
cta.Grupo1 = cta1.NumeroCuenta + " " + cta1.Denominacion;
|
||||
if (cta.Nivel > 1)
|
||||
{
|
||||
var cta2 = ctasintermedias.First(x => x.NumeroCuenta == cta.NumeroCuenta.Substring(0, 2) && x.idEjercicio == cta.idEjercicio);
|
||||
cta.Grupo2 = cta2.NumeroCuenta + " " + cta2.Denominacion;
|
||||
if (cta.Nivel > 2)
|
||||
{
|
||||
var cta3 = ctasintermedias.First(x => x.NumeroCuenta == cta.NumeroCuenta.Substring(0, 3) && x.idEjercicio == cta.idEjercicio);
|
||||
cta.Grupo3 = cta3.NumeroCuenta + " " + cta3.Denominacion;
|
||||
if (cta.Nivel > 3)
|
||||
{
|
||||
var cta4 = ctasintermedias.First(x => x.NumeroCuenta == cta.NumeroCuenta.Substring(0, 4) && x.idEjercicio == cta.idEjercicio);
|
||||
cta.Grupo4 = cta4.NumeroCuenta + " " + cta4.Denominacion;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Error obteniendo cuentas intermedia de la cuenta " + cta.NumeroCuenta + " " + ex.Message, ex);
|
||||
}
|
||||
}
|
||||
return lc;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public string Grupo1 { get; set; }
|
||||
public string Grupo2 { get; set; }
|
||||
public string Grupo3 { get; set; }
|
||||
public string Grupo4 { get; set; }
|
||||
|
||||
public int Nivel => NumeroCuenta.Length;
|
||||
|
||||
#region Saldos
|
||||
public double SaldoEnero => Math.Round(DebeEnero.NothingA0() - HaberEnero.NothingA0(), 2, MidpointRounding.AwayFromZero);
|
||||
public double SaldoFebrero => Math.Round(DebeFebrero.NothingA0() - HaberFebrero.NothingA0(), 2, MidpointRounding.AwayFromZero);
|
||||
public double SaldoMarzo => Math.Round(DebeMarzo.NothingA0() - HaberMarzo.NothingA0(), 2, MidpointRounding.AwayFromZero);
|
||||
public double SaldoAbril => Math.Round(DebeAbril.NothingA0() - HaberAbril.NothingA0(), 2, MidpointRounding.AwayFromZero);
|
||||
public double SaldoMayo => Math.Round(DebeMayo.NothingA0() - HaberMayo.NothingA0(), 2, MidpointRounding.AwayFromZero);
|
||||
public double SaldoJunio => Math.Round(DebeJunio.NothingA0() - HaberJunio.NothingA0(), 2, MidpointRounding.AwayFromZero);
|
||||
public double SaldoJulio => Math.Round(DebeJulio.NothingA0() - HaberJulio.NothingA0(), 2, MidpointRounding.AwayFromZero);
|
||||
public double SaldoAgosto => Math.Round(DebeAgosto.NothingA0() - HaberAgosto.NothingA0(), 2, MidpointRounding.AwayFromZero);
|
||||
public double SaldoSeptiembre => Math.Round(DebeSeptiembre.NothingA0() - HaberSeptiembre.NothingA0(), 2, MidpointRounding.AwayFromZero);
|
||||
public double SaldoOctubre => Math.Round(DebeOctubre.NothingA0() - HaberOctubre.NothingA0(), 2, MidpointRounding.AwayFromZero);
|
||||
public double SaldoNoviembre => Math.Round(DebeNoviembre.NothingA0() - HaberNoviembre.NothingA0(), 2, MidpointRounding.AwayFromZero);
|
||||
public double SaldoDiciembre => Math.Round(DebeDiciembre.NothingA0() - HaberDiciembre.NothingA0(), 2, MidpointRounding.AwayFromZero);
|
||||
public double TotalSaldo => Math.Round(TotalDebe - TotalHaber, 2, MidpointRounding.AwayFromZero);
|
||||
#endregion
|
||||
|
||||
#region Presupuestos
|
||||
public double TotalPresupuestado => Math.Round(PresupuestoEnero + PresupuestoFebrero + PresupuestoMarzo + PresupuestoAbril + PresupuestoMayo + PresupuestoJunio + PresupuestoJulio + PresupuestoAgosto + PresupuestoSeptiembre + PresupuestoOctubre + PresupuestoNoviembre + PresupuestoDiciembre, 2, MidpointRounding.AwayFromZero);
|
||||
public void ActualizaTotalPresupuestado() => OnPropertyChanged("TotalPresupuestado");
|
||||
|
||||
public double DesvioPresupuestoEnero => CalculoDesvio(PresupuestoEnero, SaldoEnero);
|
||||
public double DesvioPresupuestoFebrero => CalculoDesvio(PresupuestoFebrero, SaldoFebrero);
|
||||
public double DesvioPresupuestoMarzo => CalculoDesvio(PresupuestoMarzo, SaldoMarzo);
|
||||
public double DesvioPresupuestoAbril => CalculoDesvio(PresupuestoAbril, SaldoAbril);
|
||||
public double DesvioPresupuestoMayo => CalculoDesvio(PresupuestoMayo, SaldoMayo);
|
||||
public double DesvioPresupuestoJunio => CalculoDesvio(PresupuestoJunio, SaldoJunio);
|
||||
public double DesvioPresupuestoJulio => CalculoDesvio(PresupuestoJulio, SaldoJulio);
|
||||
public double DesvioPresupuestoAgosto => CalculoDesvio(PresupuestoAgosto, SaldoAgosto);
|
||||
public double DesvioPresupuestoSeptiembre => CalculoDesvio(PresupuestoSeptiembre, SaldoSeptiembre);
|
||||
public double DesvioPresupuestoOctubre => CalculoDesvio(PresupuestoOctubre, SaldoOctubre);
|
||||
public double DesvioPresupuestoNoviembre => CalculoDesvio(PresupuestoNoviembre, SaldoNoviembre);
|
||||
public double DesvioPresupuestoDiciembre => CalculoDesvio(PresupuestoDiciembre, SaldoDiciembre);
|
||||
public double DesvioPresupuestoTotal => CalculoDesvio(TotalPresupuestado, TotalSaldo);
|
||||
|
||||
private double CalculoDesvio(double presupuesto, double saldo)
|
||||
{
|
||||
if (string.IsNullOrEmpty(NumeroCuenta)) return 0;
|
||||
char first = NumeroCuenta[0];
|
||||
if (first == '6' || first == '7')
|
||||
{
|
||||
return Math.Round(Math.Abs(presupuesto) - Math.Abs(saldo), 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double PorcentajeDesvioPresupuestoEnero => CalculoPorcentajeDesvio(DesvioPresupuestoEnero, SaldoEnero);
|
||||
public double PorcentajeDesvioPresupuestoFebrero => CalculoPorcentajeDesvio(DesvioPresupuestoFebrero, SaldoFebrero);
|
||||
public double PorcentajeDesvioPresupuestoMarzo => CalculoPorcentajeDesvio(DesvioPresupuestoMarzo, SaldoMarzo);
|
||||
public double PorcentajeDesvioPresupuestoAbril => CalculoPorcentajeDesvio(DesvioPresupuestoAbril, SaldoAbril);
|
||||
public double PorcentajeDesvioPresupuestoMayo => CalculoPorcentajeDesvio(DesvioPresupuestoMayo, SaldoMayo);
|
||||
public double PorcentajeDesvioPresupuestoJunio => CalculoPorcentajeDesvio(DesvioPresupuestoJunio, SaldoJunio);
|
||||
public double PorcentajeDesvioPresupuestoJulio => CalculoPorcentajeDesvio(DesvioPresupuestoJulio, SaldoJulio);
|
||||
public double PorcentajeDesvioPresupuestoAgosto => CalculoPorcentajeDesvio(DesvioPresupuestoAgosto, SaldoAgosto);
|
||||
public double PorcentajeDesvioPresupuestoSeptiembre => CalculoPorcentajeDesvio(DesvioPresupuestoSeptiembre, SaldoSeptiembre);
|
||||
public double PorcentajeDesvioPresupuestoOctubre => CalculoPorcentajeDesvio(DesvioPresupuestoOctubre, SaldoOctubre);
|
||||
public double PorcentajeDesvioPresupuestoNoviembre => CalculoPorcentajeDesvio(DesvioPresupuestoNoviembre, SaldoNoviembre);
|
||||
public double PorcentajeDesvioPresupuestoDiciembre => CalculoPorcentajeDesvio(DesvioPresupuestoDiciembre, SaldoDiciembre);
|
||||
public double PorcentajeDesvioPresupuestoTotal => CalculoPorcentajeDesvio(DesvioPresupuestoTotal, TotalSaldo);
|
||||
|
||||
private double CalculoPorcentajeDesvio(double desvio, double saldo)
|
||||
{
|
||||
if (saldo == 0)
|
||||
{
|
||||
if (desvio < 0) return -100;
|
||||
if (desvio > 0) return 100;
|
||||
return 0;
|
||||
}
|
||||
return Math.Round(desvio * 100 / saldo, 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
41
bdAsegasa/Extensiones/vf_documentospolizassgextendidas.cs
Normal file
41
bdAsegasa/Extensiones/vf_documentospolizassgextendidas.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class vf_documentospolizassgextendidas
|
||||
{
|
||||
public bool FicheroModificado_TMP { get; set; }
|
||||
public byte[] Fichero_TMP { get; set; }
|
||||
|
||||
public bool DocumentoComprobado
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.FechaComprobacion.HasValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
this.FechaComprobacion = DateTime.Now;
|
||||
this.idUsuarioComprueba = Utilidades.idUsuario;
|
||||
this.UsuarioComprueba = Utilidades.NombreUsuario;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.FechaComprobacion = null;
|
||||
this.idUsuarioComprueba = null;
|
||||
this.UsuarioComprueba = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string DescripcionTipo
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((documentospolizassg.TipoDocumentoEnum)(this.Tipo)).ToString().Replace("_", " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
19
bdAsegasa/Extensiones/vf_liquidacionesagentesverifactu.cs
Normal file
19
bdAsegasa/Extensiones/vf_liquidacionesagentesverifactu.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class vf_liquidacionesagentesverifactu
|
||||
{
|
||||
public string DescripcionEstadoVerifactu => EstadoVerifactu.ToString().Replace("_", " ");
|
||||
|
||||
public liquidacionesagentes.EstadoVerifactuEnum EstadoVerifactu
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.Estado.HasValue)
|
||||
{
|
||||
return (liquidacionesagentes.EstadoVerifactuEnum)this.Estado.Value;
|
||||
}
|
||||
return liquidacionesagentes.EstadoVerifactuEnum.SIN_REGISTROS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
15
bdAsegasa/Extensiones/vf_liquidacionesciasextendidas.cs
Normal file
15
bdAsegasa/Extensiones/vf_liquidacionesciasextendidas.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class vf_liquidacionesciasextendidas
|
||||
{
|
||||
public string Compañia
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.NumeroCias == 0) return "";
|
||||
if (this.NumeroCias == 1) return this.Cia;
|
||||
return "Varias";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
32
bdAsegasa/Extensiones/vf_liquidacionesrecibosextendidas.cs
Normal file
32
bdAsegasa/Extensiones/vf_liquidacionesrecibosextendidas.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class vf_liquidacionesrecibosextendidas
|
||||
{
|
||||
public string EsDescobro
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.DescripcionTipoLiquidacion = "DESCOBRO";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public double LiquidoCia
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Round(this.TotalRecibo.Value - this.TotalComision.Value, 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
|
||||
public string LiquidacionTipo
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.idLiquidacionCia.ToString + " " + this.DescripcionTipoLiquidacion;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
106
bdAsegasa/Extensiones/vf_polizasextendidas.cs
Normal file
106
bdAsegasa/Extensiones/vf_polizasextendidas.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class vf_polizasextendidas
|
||||
{
|
||||
public string NumeroSuplemento_String
|
||||
{
|
||||
get
|
||||
{
|
||||
if(this.NumeroSuplemento == 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return NumeroSuplemento.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Situacion_Web
|
||||
{
|
||||
get
|
||||
{
|
||||
return gestionasegasaEntities.ObtieneSituacionWeb(this.idSituacion, this.idTipoPago);
|
||||
}
|
||||
}
|
||||
public string CiaNumeroPoliza
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Compania + "/" + this.NumeroPoliza;
|
||||
}
|
||||
}
|
||||
|
||||
public int? EdadTomador
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.FechaNacimientoTomador.HasValue)
|
||||
{
|
||||
DateOnly hoy = DateOnly.FromDateTime(DateTime.Now);
|
||||
|
||||
return (int)((hoy.Year - this.FechaNacimientoTomador.Value.Year));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public string TelefonoMovilValido
|
||||
{
|
||||
get
|
||||
{
|
||||
if (tsUtilidades.Extensiones.StringExtensions.EsNumeroTelefonoMovilEspañolValido(this.Telefono1Tomador))
|
||||
{
|
||||
return this.Telefono1Tomador;
|
||||
}
|
||||
else if (tsUtilidades.Extensiones.StringExtensions.EsNumeroTelefonoMovilEspañolValido(this.Telefono2Tomador))
|
||||
{
|
||||
return this.Telefono2Tomador;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ListadoReducido AListadoReducido() => new ListadoReducido(this);
|
||||
}
|
||||
|
||||
public class ListadoReducido
|
||||
{
|
||||
public ListadoReducido(vf_polizasextendidas p)
|
||||
{
|
||||
NumeroPropuesta = p.idPoliza;
|
||||
FechaAlta = p.FechaAlta;
|
||||
NumeroPóliza = p.NumeroPoliza;
|
||||
Matrícula = p.Matricula;
|
||||
Compañía = p.Compania;
|
||||
Ramo = p.Ramo;
|
||||
BienesAsegurados = p.BienesAsegurados;
|
||||
TipoPago = p.TipoPago;
|
||||
CIFTomador = p.CIFTomador;
|
||||
Tomador = p.Tomador;
|
||||
Teléfono1 = p.Telefono1Tomador;
|
||||
Teléfono2 = p.Telefono2Tomador;
|
||||
Email = p.EmailTomador;
|
||||
}
|
||||
|
||||
public int NumeroPropuesta { get; set; }
|
||||
public DateTime? FechaAlta { get; set; }
|
||||
public string NumeroPóliza { get; set; }
|
||||
public string Matrícula { get; set; }
|
||||
public string BienesAsegurados { get; set; }
|
||||
public string Compañía { get; set; }
|
||||
public string Ramo { get; set; }
|
||||
public string TipoPago { get; set; }
|
||||
public string CIFTomador { get; set; }
|
||||
public string Tomador { get; set; }
|
||||
public string Teléfono1 { get; set; }
|
||||
public string Teléfono2 { get; set; }
|
||||
public string Email { get; set; }
|
||||
}
|
||||
}
|
||||
22
bdAsegasa/Extensiones/vf_polizassg_estadisticas.cs
Normal file
22
bdAsegasa/Extensiones/vf_polizassg_estadisticas.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public class vf_polizassg_estadisticas_reducido
|
||||
{
|
||||
public int EsContratacion { get; set; }
|
||||
public int EsBaja { get; set; }
|
||||
public DateTime FechaSituacion { get; set; }
|
||||
public string Compania { get; set; }
|
||||
public string FamiliaRamo { get; set; }
|
||||
public string SubAgente { get; set; }
|
||||
|
||||
public int Incremento
|
||||
{
|
||||
get
|
||||
{
|
||||
return EsContratacion - EsBaja;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
190
bdAsegasa/Extensiones/vf_recibosextendidos.cs
Normal file
190
bdAsegasa/Extensiones/vf_recibosextendidos.cs
Normal file
@@ -0,0 +1,190 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using bdAsegasa.dbcontext;
|
||||
using tsUtilidades;
|
||||
using tsUtilidades.Extensiones;
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class vf_recibosextendidos
|
||||
{
|
||||
private static List<enumeraciones> TiposPago;
|
||||
|
||||
public string Situacion_Web => gestionasegasaEntities.ObtieneSituacionWeb(this.idSituacion, this.idTipoPago);
|
||||
|
||||
public string CiaNumeroPoliza => $"{this.Compania}/{this.NumeroPoliza}";
|
||||
public string CompaniaNumeros => $"{this.Compania} (Números de asistencia)";
|
||||
|
||||
public recibos.EstadoRecibo Estado
|
||||
{
|
||||
get
|
||||
{
|
||||
var est = recibos.EstadoRecibo.PENDIENTE;
|
||||
if (this.idRemesa.HasValue) est = recibos.EstadoRecibo.REMESADO;
|
||||
|
||||
if (this.idTipoPago == bdAsegasa.db.gestionasegasaEntities.TipoPagoCia() || this.idTipoPago == bdAsegasa.db.gestionasegasaEntities.TipoPagoFAE()) est = recibos.EstadoRecibo.GESTION_COBRO_CIA;
|
||||
if (this.FechaLiquidacionAgente.HasValue) est = recibos.EstadoRecibo.LIQUIDADO;
|
||||
if (this.FechaBaja.HasValue && this.idCausaBaja != bdAsegasa.db.gestionasegasaEntities.CabaSupl() && this.idCausaBaja != bdAsegasa.db.gestionasegasaEntities.CabaSust()) est = recibos.EstadoRecibo.BAJA;
|
||||
if (this.FechaDevolucionBanco.HasValue) est = recibos.EstadoRecibo.DEVUELTO_BANCO;
|
||||
return est;
|
||||
}
|
||||
}
|
||||
|
||||
public string EstadoRecibo => Estado.ToString().Replace("_", " ");
|
||||
|
||||
public string IBANoTipoPago
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idTipoPago.HasValue)
|
||||
{
|
||||
if (TiposPago == null)
|
||||
{
|
||||
// Asumiendo que bdGestionAsegasa es una clase estática o accesible en el contexto
|
||||
var bdtmp = bdAsegasa.tscgestionasegasa.NuevoContexto();
|
||||
|
||||
TiposPago = bdtmp.enumeraciones
|
||||
.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "TIPP")
|
||||
.ToList();
|
||||
}
|
||||
|
||||
var tp = TiposPago.FirstOrDefault(x => x.idEnumeracion == this.idTipoPago);
|
||||
|
||||
if (tp == null)
|
||||
{
|
||||
return "* DESCONOCIDO *";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tp.Codigo == "TIPP.BA")
|
||||
{
|
||||
if (string.IsNullOrEmpty(IBAN.NothingAVacio()))
|
||||
{
|
||||
return "BANCARIO SIN IBAN ASIGNADO";
|
||||
}
|
||||
else
|
||||
{
|
||||
return IBAN;
|
||||
}
|
||||
}
|
||||
|
||||
return tp.Descripcion;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return "* NO ASIGNADO *";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string TipoPago
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idTipoPago.HasValue)
|
||||
{
|
||||
if (TiposPago == null)
|
||||
{
|
||||
var bdtmp = bdAsegasa.tscgestionasegasa.NuevoContexto();
|
||||
|
||||
TiposPago = bdtmp.enumeraciones
|
||||
.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "TIPP")
|
||||
.ToList();
|
||||
}
|
||||
|
||||
var tp = TiposPago.FirstOrDefault(x => x.idEnumeracion == this.idTipoPago);
|
||||
|
||||
if (tp == null)
|
||||
{
|
||||
return "* DESCONOCIDO *";
|
||||
}
|
||||
else
|
||||
{
|
||||
return tp.Descripcion;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return "* NO ASIGNADO *";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IBANCorrecto => tsUtilidades.Bancos.Genericas.IBANCorrecto(this.IBAN) && this.IBAN != "ES8200000000000000000000";
|
||||
|
||||
public int? idSubAgente_Especial
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idSubagente.HasValue && this.CodigoAgente == "000047002186")
|
||||
{
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var codigoBase = this.CodigoSubAgente.Substring(0, 2) + "00";
|
||||
var subage = bd.subagentes.FirstOrDefault(x => x.idAgente == this.idAgente && x.Codigo == codigoBase);
|
||||
return subage?.idSubagente ?? this.idSubagente;
|
||||
}
|
||||
}
|
||||
return this.idSubagente;
|
||||
}
|
||||
}
|
||||
|
||||
public string NumeroPolizaSuplementoLargo => (this.NumeroSuplemento == 0) ? this.NumeroPoliza : $"{this.NumeroPoliza} ({this.NumeroSuplemento})";
|
||||
public string NumeroPolizaSuplemento => (this.NumeroSuplemento == 0) ? this.NumeroPoliza : $"{this.NumeroPoliza}#{this.NumeroSuplemento}";
|
||||
|
||||
public double LiquidoCia => Math.Round((double)((this.TotalRecibo ?? 0) - (this.TotalComision ?? 0)), 2);
|
||||
public double PrimaNetaBonificada => Math.Round((double)((this.PrimaNeta ?? 0) + (this.BonificacionORecargo ?? 0)), 2);
|
||||
|
||||
public double ImporteALiquidarAgente
|
||||
{
|
||||
get
|
||||
{
|
||||
int factor = EsRetornoComision_TMP ? -1 : 1;
|
||||
return Math.Round(factor * (double)(this.ComisionAgente ?? 0), 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
|
||||
public string TipoLiquidacionAgente => EsRetornoComision_TMP ? "RETORNO COMISION" : "LIQUIDACIÓN";
|
||||
|
||||
public bool EsRetornoComision_TMP { get; set; }
|
||||
public int idRegularizacion_TMP { get; set; }
|
||||
|
||||
private static int? idTippPE;
|
||||
public bool CuentaContableTomadorErronea
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!idTippPE.HasValue)
|
||||
{
|
||||
using var bd = tscgestionasegasa.NuevoContexto();
|
||||
idTippPE = bd.enumeraciones.First(x => x.Codigo == "TIPP.PE").idEnumeracion;
|
||||
}
|
||||
return this.idTipoPago == idTippPE.Value && (this.CuentaContableTomador ?? "").Length != 8;
|
||||
}
|
||||
}
|
||||
|
||||
public string TelefonoMovilValido
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.Telefono1Tomador.EsNumeroTelefonoMovilEspañolValido())
|
||||
{
|
||||
return this.Telefono1Tomador;
|
||||
}
|
||||
else if (this.Telefono2Tomador.EsNumeroTelefonoMovilEspañolValido())
|
||||
{
|
||||
return this.Telefono2Tomador;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string ProvinciaTomador => (this.CodigoPostalTomador?.Length > 2) ? this.CodigoPostalTomador.Substring(0, 2) : "";
|
||||
|
||||
public bool AntiguedadMayor2M => (DateTime.Today - this.FechaEfecto.ToDateTime(TimeOnly.MinValue)).TotalDays > 60;
|
||||
}
|
||||
}
|
||||
88
bdAsegasa/Extensiones/vf_recibosextendidos_lc.cs
Normal file
88
bdAsegasa/Extensiones/vf_recibosextendidos_lc.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using bdAsegasa.dbcontext;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class vf_recibosextendidos_lc
|
||||
{
|
||||
private static List<enumeraciones> _tiposPago;
|
||||
|
||||
public double LiquidoCia => Math.Round((double)((this.TotalRecibo ?? 0) - (this.TotalComision ?? 0)), 2);
|
||||
public string Situacion_Web => gestionasegasaEntities.ObtieneSituacionWeb(this.idSituacion, this.idTipoPago);
|
||||
public string CiaNumeroPoliza => $"{this.Compania}/{this.NumeroPoliza}";
|
||||
|
||||
public string TipoPago
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idTipoPago.HasValue)
|
||||
{
|
||||
if (_tiposPago == null)
|
||||
{
|
||||
var bdtmp = tscgestionasegasa.NuevoContexto();
|
||||
_tiposPago = bdtmp.enumeraciones
|
||||
.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "TIPP")
|
||||
.ToList();
|
||||
}
|
||||
|
||||
var tp = _tiposPago.FirstOrDefault(x => x.idEnumeracion == this.idTipoPago);
|
||||
|
||||
return tp == null ? "* DESCONOCIDO *" : tp.Descripcion;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "* NO ASIGNADO *";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IBANCorrecto => tsUtilidades.Bancos.Genericas.IBANCorrecto(this.IBAN);
|
||||
|
||||
public int? idSubAgente_Especial
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idSubagente.HasValue && this.CodigoAgente == "000047002186")
|
||||
{
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var codigoBase = this.CodigoSubAgente.Substring(0, 2) + "00";
|
||||
var subage = bd.subagentes.FirstOrDefault(x => x.idAgente == this.idAgente && x.Codigo == codigoBase);
|
||||
return subage?.idSubagente ?? this.idSubagente;
|
||||
}
|
||||
}
|
||||
return this.idSubagente;
|
||||
}
|
||||
}
|
||||
|
||||
public string NumeroPolizaSuplementoLargo => (this.NumeroSuplemento == 0) ? this.NumeroPoliza : $"{this.NumeroPoliza} ({this.NumeroSuplemento})";
|
||||
public string NumeroPolizaSuplemento => (this.NumeroSuplemento == 0) ? this.NumeroPoliza : $"{this.NumeroPoliza}#{this.NumeroSuplemento}";
|
||||
|
||||
public string MotivoBajaCia
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!this.idCausaBaja.HasValue) return "";
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
return bd.enumeraciones.FirstOrDefault(x => x.idEnumeracion == this.idCausaBaja)?.ValorAlfabetico2 ?? "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string CodigoDevolucionBanco
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!this.idCausaDevolucion.HasValue) return "";
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var cau = bd.enumeraciones.FirstOrDefault(x => x.idEnumeracion == this.idCausaDevolucion);
|
||||
return cau?.Codigo?.Split('.').ElementAtOrDefault(1) ?? "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
78
bdAsegasa/Extensiones/vf_recibosextendidos_ti.cs
Normal file
78
bdAsegasa/Extensiones/vf_recibosextendidos_ti.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using bdAsegasa.dbcontext;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class vf_recibosextendidos_ti
|
||||
{
|
||||
private static List<enumeraciones> _tiposPago;
|
||||
|
||||
public string Situacion_Web => gestionasegasaEntities.ObtieneSituacionWeb(this.idSituacion, this.idTipoPago);
|
||||
public string CiaNumeroPoliza => $"{this.Compania}/{this.NumeroPoliza}";
|
||||
|
||||
public recibos.EstadoRecibo Estado
|
||||
{
|
||||
get
|
||||
{
|
||||
var est = recibos.EstadoRecibo.PENDIENTE;
|
||||
if (this.idRemesa.HasValue) est = recibos.EstadoRecibo.REMESADO;
|
||||
if (this.idTipoPago == 1 /* TipoPagoCia */ || this.idTipoPago == 2 /* TipoPagoFAE */) est = recibos.EstadoRecibo.GESTION_COBRO_CIA;
|
||||
if (this.FechaLiquidacionAgente.HasValue) est = recibos.EstadoRecibo.LIQUIDADO;
|
||||
if (this.FechaBaja.HasValue && this.idCausaBaja != 10 && this.idCausaBaja != 11) est = recibos.EstadoRecibo.BAJA;
|
||||
if (this.FechaDevolucionBanco.HasValue) est = recibos.EstadoRecibo.DEVUELTO_BANCO;
|
||||
return est;
|
||||
}
|
||||
}
|
||||
|
||||
public string EstadoRecibo => Estado.ToString().Replace("_", " ");
|
||||
|
||||
public string TipoPago
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idTipoPago.HasValue)
|
||||
{
|
||||
if (_tiposPago == null)
|
||||
{
|
||||
var bdtmp = tscgestionasegasa.NuevoContexto();
|
||||
_tiposPago = bdtmp.enumeraciones
|
||||
.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "TIPP")
|
||||
.ToList();
|
||||
}
|
||||
|
||||
var tp = _tiposPago.FirstOrDefault(x => x.idEnumeracion == this.idTipoPago);
|
||||
|
||||
return tp == null ? "* DESCONOCIDO *" : tp.Descripcion;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "* NO ASIGNADO *";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IBANCorrecto => tsUtilidades.Bancos.Genericas.IBANCorrecto(this.IBAN);
|
||||
|
||||
public int? idSubAgente_Especial
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idSubagente.HasValue && this.CodigoAgente == "000047002186")
|
||||
{
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var codigoBase = this.CodigoSubAgente.Substring(0, 2) + "00";
|
||||
var subage = bd.subagentes.FirstOrDefault(x => x.idAgente == this.idAgente && x.Codigo == codigoBase);
|
||||
return subage?.idSubagente ?? this.idSubagente;
|
||||
}
|
||||
}
|
||||
return this.idSubagente;
|
||||
}
|
||||
}
|
||||
|
||||
public string NumeroPolizaSuplementoLargo => (this.NumeroSuplemento == 0) ? this.NumeroPoliza : $"{this.NumeroPoliza} ({this.NumeroSuplemento})";
|
||||
public string NumeroPolizaSuplemento => (this.NumeroSuplemento == 0) ? this.NumeroPoliza : $"{this.NumeroPoliza}#{this.NumeroSuplemento}";
|
||||
}
|
||||
}
|
||||
34
bdAsegasa/Extensiones/vf_siniestros_eiac_extendidos.cs
Normal file
34
bdAsegasa/Extensiones/vf_siniestros_eiac_extendidos.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class vf_siniestros_eiac_extendidos
|
||||
{
|
||||
// Similar mappings to siniestros_eiac for compatibility with view extensions
|
||||
public enum ClavesPosicionSiniestroEnum : int
|
||||
{
|
||||
CULPA = 1,
|
||||
RECLAMACIÓN = 2,
|
||||
INDETERMINADO = 3,
|
||||
NO_APLICA = 4,
|
||||
DESCONOCIDA = 99
|
||||
}
|
||||
|
||||
public string DescripcionPosicionSiniestro => ((ClavesPosicionSiniestroEnum)this.PosicionSiniestro).ToString().Replace("_", " ");
|
||||
|
||||
public enum SituacionAsegasaENUM : int
|
||||
{
|
||||
NUEVO = 1,
|
||||
MODIFICADO = 2,
|
||||
POLIZA_NO_ENCONTRADA = 10,
|
||||
SINIESTRO_NO_ENCONTRADO = 11,
|
||||
VARIOS_SINIESTROS_POSIBLES = 12,
|
||||
VISUALIZADO = 100,
|
||||
DESCARTADO = 200
|
||||
}
|
||||
|
||||
public string DescripcionSituacionAsegasa => this.SituacionAsegasa.HasValue
|
||||
? ((SituacionAsegasaENUM)this.SituacionAsegasa.Value).ToString().Replace("_", " ")
|
||||
: "";
|
||||
}
|
||||
}
|
||||
21
bdAsegasa/Extensiones/vf_siniestrosextendidos.cs
Normal file
21
bdAsegasa/Extensiones/vf_siniestrosextendidos.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class vf_siniestrosextendidos
|
||||
{
|
||||
public long NumeroGestionesNN => this.NumeroGestiones ?? 1;
|
||||
|
||||
public bool Abierto => !this.FechaCierre.HasValue;
|
||||
|
||||
public string AñoMes
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.FechaAccidente.HasValue)
|
||||
{
|
||||
return $"{this.FechaAccidente.Value.Year}-{this.FechaAccidente.Value.Month:D2}";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
197
bdAsegasa/Informes/CarteraPerdida.cs
Normal file
197
bdAsegasa/Informes/CarteraPerdida.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
}
|
||||
52
bdAsegasa/Informes/CartillaSeguroGenerales.cs
Normal file
52
bdAsegasa/Informes/CartillaSeguroGenerales.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
2638
bdAsegasa/Informes/CombinacionCorrespondencia.cs
Normal file
2638
bdAsegasa/Informes/CombinacionCorrespondencia.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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; }
|
||||
}
|
||||
}
|
||||
41
bdAsegasa/Informes/DetallesPoliza.cs
Normal file
41
bdAsegasa/Informes/DetallesPoliza.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
25
bdAsegasa/Informes/DifPolSup.cs
Normal file
25
bdAsegasa/Informes/DifPolSup.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
105
bdAsegasa/Informes/Informes.cs
Normal file
105
bdAsegasa/Informes/Informes.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
25
bdAsegasa/Informes/InformesAgrarios.cs
Normal file
25
bdAsegasa/Informes/InformesAgrarios.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
39
bdAsegasa/Presupuestos/AccidentesIndividualesAXA.cs
Normal file
39
bdAsegasa/Presupuestos/AccidentesIndividualesAXA.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
38
bdAsegasa/Presupuestos/CasetasRiegoAXA.cs
Normal file
38
bdAsegasa/Presupuestos/CasetasRiegoAXA.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
42
bdAsegasa/Presupuestos/Patinetes.cs
Normal file
42
bdAsegasa/Presupuestos/Patinetes.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
27
bdAsegasa/Presupuestos/RCCaballos.cs
Normal file
27
bdAsegasa/Presupuestos/RCCaballos.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user