- 2026-05-12 1.2.0.0 Correccion tsUtilidades
- 2026-05-12 1.1.0.0 Se añade rutina diaria FinalizaPolizasPagoUnicoVencidas
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
using bdAsegasa;
|
||||
using bdAsegasa.db;
|
||||
using bdAsegasa.dbcontext;
|
||||
using DevExpress.DataProcessing.InMemoryDataProcessor;
|
||||
using DevExpress.XtraCharts.Native;
|
||||
using DocumentFormat.OpenXml.Bibliography;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Servicio_Gestion_Asegasa.Clases;
|
||||
using System;
|
||||
@@ -16,58 +19,58 @@ namespace Servicio_Gestion_Asegasa.Procesos
|
||||
public class ProcesosPolizas
|
||||
{
|
||||
|
||||
public static async Task ComprobarPolizasPagoUnico()
|
||||
public static async Task FinalizaPolizasPagoUnicoVencidas()
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
|
||||
try
|
||||
{
|
||||
DateOnly hoy = DateOnly.FromDateTime(DateTime.Now);
|
||||
int idTcpu = bd.enumeraciones.First(x => x.Codigo == "DUR.U").idEnumeracion;
|
||||
int idcaba = bd.enumeraciones.First(x => x.Codigo == "CABA.VENCI").idEnumeracion;
|
||||
|
||||
|
||||
var lr = bd.vf_recibosextendidos.Where(x => x.idDuracion == idTcpu && x.FechaVencimiento < hoy && x.FechaBajaPoliza==null && x.NumeroPoliza!=null).Select(x => new PolizaPagoUnicoExcel{
|
||||
idPoliza = x.idPoliza,
|
||||
|
||||
var lr = bd.recibos.Include(x => x.idPolizaNavigation).ThenInclude(x => x.entidadespolizas).ThenInclude(x => x.idEntidadNavigation).Include(x => x.idPolizaNavigation)
|
||||
.ThenInclude(x => x.idCompaniaNavigation).Include(x => x.idAgenteNavigation).Where(x => x.idPolizaNavigation.idTipoCobro == 272 && x.FechaVencimiento < hoy).Select(x => new PolizaPagoUnicoExcel{
|
||||
NumeroPoliza = x.idPolizaNavigation.NumeroPoliza ?? "",
|
||||
NumeroPoliza = x.NumeroPoliza ,
|
||||
|
||||
RazonSocial = x.idPolizaNavigation.Tomador.RazonSocial ?? "",
|
||||
Tomador = x.Tomador,
|
||||
|
||||
FechaEfecto = x.FechaEfecto,
|
||||
|
||||
FechaVencimiento = x.FechaVencimiento,
|
||||
|
||||
Descripcion = x.idPolizaNavigation.idRamoNavigation.Descripcion ?? "",
|
||||
Ramo = x.Ramo,
|
||||
|
||||
NombreAgente = x.idPolizaNavigation.idAgenteNavigation.Nombre ?? "",
|
||||
NombreAgente = x.Agente ?? "",
|
||||
|
||||
CiaNumeroPolizaSuplemento = x.idPolizaNavigation.CiaNumeroPolizaSuplemento
|
||||
Compañia = x.Compania
|
||||
}).ToList();
|
||||
|
||||
if (lr.Count > 0)
|
||||
{
|
||||
string Destinatarios = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCONTA").ValorAlfabeticoLargo;
|
||||
byte[] excelPolizas = tsUtilidades.Excel.IEnumerableAExcel(lr);
|
||||
string sql = @"UPDATE polizassg p INNER JOIN recibos r ON r.idPoliza = p.idPoliza SET p.FechaBaja = p.FechaVencimiento, p.idCausaBaja = " + idcaba.ToString() + " WHERE p.idDuracion = " + idTcpu.ToString() + " AND r.FechaVencimiento < '" + hoy.ToString("yyyyMMdd") +@"' AND p.FechaBaja IS NULL;";
|
||||
var na = await bd.Database.ExecuteSqlRawAsync(sql);
|
||||
//await bd.polizassg.Where(x => lPol.Contains(x.idPoliza)).ExecuteUpdateAsync(setters => setters
|
||||
// .SetProperty(x => x.FechaBaja, x.FechaVencimiento)
|
||||
// .SetProperty(x => x.idCausaBaja, idcaba));
|
||||
|
||||
byte[] excelPolizas = tsUtilidades.Excel.IEnumerableAExcel(lr);
|
||||
|
||||
|
||||
//await bd.polizassg.Where(x => x.idTipoCobro == 272 && x.recibos.Any(r => r.FechaVencimiento < hoy)).ExecuteUpdateAsync(setters => setters
|
||||
// .SetProperty(x => x.FechaBaja, hoy)
|
||||
// .SetProperty(x => x.idCausaBaja, 784));
|
||||
|
||||
string sDireccionesEnvio = "sevilla@tecnosis.net";
|
||||
string sServidorSMTP = "mail.tecnosis.net";
|
||||
string sRemitente = "logs@tecnosis.es";
|
||||
string Asunto = "Ficheros vencidos";
|
||||
string Cuerpo = "Excel de ficheros cobro único vencidos.";
|
||||
|
||||
List<tsUtilidades.Correo.FicheroAdjunto> listadoFicheros = new List<tsUtilidades.Correo.FicheroAdjunto>();
|
||||
listadoFicheros.Add(new tsUtilidades.Correo.FicheroAdjunto
|
||||
{
|
||||
NombreFichero = "FicherosVencidos.xlsx",
|
||||
Fichero = excelPolizas
|
||||
});
|
||||
|
||||
tsUtilidades.Correo.Funciones.EnviaCorreoVariosAdjuntos(sServidorSMTP, sRemitente, sDireccionesEnvio, Asunto, Cuerpo, listadoFicheros);
|
||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "TECNOSIS");
|
||||
correos.GeneraRegistroCorreoConAdjunto(bd,
|
||||
"Listado de pólizas de Duración Pago Único Vencidas.",
|
||||
"Se ha procedido dar de baja por vencimiento a las pólizas del fichero adjunto de tipo de duración a único.",
|
||||
cta,
|
||||
excelPolizas, "PolizasPagoUnicoVencidas-" + hoy.ToString("yyyy-MM-dd") + ".xlsx",
|
||||
"Pólizas pago único vencidas",
|
||||
Destinatarios);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
||||
catch (Exception ex) {
|
||||
await Logs.AñadeLogAsync(tsUtilidades.Enumeraciones.TipoLog.Fallo, ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user