Cambios mensajes
This commit is contained in:
@@ -1,457 +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;
|
||||
//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;
|
||||
//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 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 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();
|
||||
// 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};");
|
||||
}
|
||||
// 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");
|
||||
// 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();
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
// 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 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");
|
||||
// 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 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();
|
||||
// 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);
|
||||
// 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();
|
||||
// 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();
|
||||
}
|
||||
// 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();
|
||||
// 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 (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();
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
// 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");
|
||||
// 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();
|
||||
// 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();
|
||||
// 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);
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
// 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);
|
||||
// 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 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();
|
||||
// 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");
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
// 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");
|
||||
// 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);
|
||||
// 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);
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
// 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 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 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);
|
||||
}
|
||||
}
|
||||
// // 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);
|
||||
// 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();
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
// 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;
|
||||
// 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();
|
||||
// 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");
|
||||
// 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);
|
||||
}
|
||||
// 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");
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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; }
|
||||
}
|
||||
}
|
||||
// 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; }
|
||||
// }
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user