| | | 1 | | using FAU.Entidades; |
| | | 2 | | |
| | | 3 | | namespace FAU.Logica.DTOs; |
| | | 4 | | |
| | | 5 | | public sealed class InsumosPeriodo |
| | | 6 | | { |
| | 58 | 7 | | public long PeriodoId { get; init; } |
| | 883 | 8 | | public ParametroPeriodo ParametroPeriodo { get; init; } = null!; |
| | 1725 | 9 | | public IReadOnlyDictionary<long, IReadOnlyDictionary<int, RemuneracionGrado>> RemuneracionesPorGrado { get; init; } |
| | 194 | 10 | | public IReadOnlyDictionary<long, IReadOnlyList<TablaPermanencia>> PermanenciasPorEscalafon { get; init; } = new Dict |
| | 200 | 11 | | public IReadOnlyList<FranjaIrpf> FranjasIrpf { get; init; } = Array.Empty<FranjaIrpf>(); |
| | | 12 | | // Tramos de Sanidad Militar (Art. 94 Ley 18.834), ordenados por Desde ASC |
| | 166 | 13 | | public IReadOnlyList<TramoSanidadMilitar> TramosSanidad { get; init; } = Array.Empty<TramoSanidadMilitar>(); |
| | 511 | 14 | | public IReadOnlyList<CatalogoItem> CatalogoItems { get; init; } = Array.Empty<CatalogoItem>(); |
| | 152 | 15 | | public IReadOnlyDictionary<long, IReadOnlyList<BeneficioSocial>> BeneficiosPorPersona { get; init; } = new Dictionar |
| | 151 | 16 | | public IReadOnlyDictionary<long, IReadOnlyList<ItemLoteCompensacion>> CompensacionesPorPersona { get; init; } = new |
| | 169 | 17 | | public IReadOnlyDictionary<long, IReadOnlyList<NovedadPeriodo>> NovedadesPorPersona { get; init; } = new Dictionary< |
| | | 18 | | // beneficioId → hijos registrados (para ASIGNACION_FAMILIAR) |
| | 151 | 19 | | public IReadOnlyDictionary<long, IReadOnlyList<BeneficioSocialBeneficiario>> BeneficiariosPorBeneficio { get; init; |
| | | 20 | | |
| | | 21 | | // Instructivos DFC — tipoFranja → registro vigente |
| | 151 | 22 | | public IReadOnlyDictionary<string, InstructivoAsigFamiliar> InstructivoAsigFamiliar { get; init; } = new Dictionary< |
| | | 23 | | // Instructivos DFC — numCategoria → registro vigente |
| | 151 | 24 | | public IReadOnlyDictionary<int, InstructivoPsf> InstructivoPsf { get; init; } = new Dictionary<int, InstructivoPsf>( |
| | | 25 | | // Tabla hogar constituido — tramos ordenados (hasta_haberes ASC, NULL al final) |
| | 151 | 26 | | public IReadOnlyList<TablaHogarConstituido> TablaPorHogar { get; init; } = Array.Empty<TablaHogarConstituido>(); |
| | | 27 | | |
| | | 28 | | // Aguinaldos (SAC) del año por persona — usado por AguinaldoCalculator (SIT14/15/18/20) |
| | 116 | 29 | | public IReadOnlyDictionary<long, IReadOnlyList<Aguinaldo>> AguinaldosPorPersona { get; init; } = new Dictionary<long |
| | | 30 | | |
| | | 31 | | // Diferencias de haberes por ascenso (OG 042.615) — cargado desde compensaciones_diferencia_ascenso |
| | 150 | 32 | | public IReadOnlyDictionary<long, CompensacionDiferenciaAscenso> CompensacionesDiferenciaAscensoPorPersona { get; ini |
| | | 33 | | |
| | | 34 | | // Orden de cada grado (para determinar porcentaje DI: clases 35% vs alistados 30%) |
| | | 35 | | // Cargado desde la tabla grados; key = grado_id, value = grado.orden |
| | 173 | 36 | | public IReadOnlyDictionary<long, short> OrdenPorGrado { get; init; } = new Dictionary<long, short>(); |
| | | 37 | | |
| | | 38 | | // Descuentos personales aprobados por persona (COFAnS, retenciones y otros). |
| | 108 | 39 | | public IReadOnlyDictionary<long, IReadOnlyList<DescuentoPersonalPeriodo>> DescuentosPersonalesPorPersona { get; init |
| | | 40 | | |
| | 77 | 41 | | public IReadOnlyDictionary<long, IReadOnlyList<FictoPersona>> FictosPorPersona { get; init; } = |
| | 92 | 42 | | new Dictionary<long, IReadOnlyList<FictoPersona>>(); |
| | | 43 | | |
| | | 44 | | public RemuneracionGrado? ObtenerRemuneracion(long gradoId, int codigoItem) |
| | | 45 | | { |
| | 1580 | 46 | | if (RemuneracionesPorGrado.TryGetValue(gradoId, out var items) && items.TryGetValue(codigoItem, out var remunera |
| | | 47 | | { |
| | 171 | 48 | | return remuneracion; |
| | | 49 | | } |
| | | 50 | | |
| | 1409 | 51 | | return null; |
| | | 52 | | } |
| | | 53 | | |
| | | 54 | | /// <summary> |
| | | 55 | | /// Retorna la tasa mínima registrada para un ítem entre todos los grados. |
| | | 56 | | /// Usado para obtener la tasa de subalterno del progresivo (044.001 = $114.01/año) |
| | | 57 | | /// cuando hay que calcular el tramo de tropa previo al ascenso a oficial. |
| | | 58 | | /// La tasa mínima corresponde siempre a los grados de tropa/subalterno. |
| | | 59 | | /// </summary> |
| | | 60 | | public decimal ObtenerTasaMinimaProgresivo(int codigoItem) |
| | | 61 | | { |
| | 0 | 62 | | var minRate = 0m; |
| | 0 | 63 | | foreach (var gradoItems in RemuneracionesPorGrado.Values) |
| | | 64 | | { |
| | 0 | 65 | | if (gradoItems.TryGetValue(codigoItem, out var rem) && rem.Monto > 0) |
| | | 66 | | { |
| | 0 | 67 | | if (minRate == 0m || rem.Monto < minRate) |
| | 0 | 68 | | minRate = rem.Monto; |
| | | 69 | | } |
| | | 70 | | } |
| | 0 | 71 | | return minRate; |
| | | 72 | | } |
| | | 73 | | |
| | | 74 | | public TablaPermanencia? ObtenerPermanencia(long escalafonId, long gradoId, int mesesServicio, bool riesgoVuelo) |
| | | 75 | | { |
| | 50 | 76 | | if (PermanenciasPorEscalafon.TryGetValue(escalafonId, out var filas)) |
| | | 77 | | { |
| | | 78 | | // Lógica legacy (SUM33106.PRG / CALC_HAB.PRG): |
| | | 79 | | // Recorre los tramos mientras tiempo_pm (MesesHasta) <= meses del funcionario |
| | | 80 | | // y conserva el último que cumplió la condición (monto creciente por antigüedad). |
| | 3 | 81 | | return filas |
| | 3 | 82 | | .Where(p => p.GradoId == gradoId) |
| | 3 | 83 | | .Where(p => p.AplicaRiesgoVuelo == riesgoVuelo) |
| | 3 | 84 | | .Where(p => p.MesesHasta <= mesesServicio) |
| | 3 | 85 | | .OrderByDescending(p => p.MesesHasta) |
| | 3 | 86 | | .FirstOrDefault(); |
| | | 87 | | } |
| | | 88 | | |
| | 47 | 89 | | return null; |
| | | 90 | | } |
| | | 91 | | |
| | | 92 | | /// <summary> |
| | | 93 | | /// Retorna el tramo de Sanidad Militar cuyo rango [Desde, Hasta] contiene la base imponible. |
| | | 94 | | /// Hasta == null representa el último tramo (sin tope superior). |
| | | 95 | | /// </summary> |
| | | 96 | | public TramoSanidadMilitar? ObtenerTramoSanidad(decimal baseImponible) |
| | | 97 | | { |
| | 50 | 98 | | return TramosSanidad.FirstOrDefault(t => |
| | 64 | 99 | | baseImponible >= t.Desde && (t.Hasta is null || baseImponible <= t.Hasta)); |
| | | 100 | | } |
| | | 101 | | |
| | | 102 | | public IReadOnlyList<BeneficioSocial> ObtenerBeneficios(long personaId) |
| | | 103 | | { |
| | 44 | 104 | | return BeneficiosPorPersona.TryGetValue(personaId, out var beneficios) |
| | 44 | 105 | | ? beneficios |
| | 44 | 106 | | : Array.Empty<BeneficioSocial>(); |
| | | 107 | | } |
| | | 108 | | |
| | | 109 | | public IReadOnlyList<ItemLoteCompensacion> ObtenerCompensaciones(long personaId) |
| | | 110 | | { |
| | 43 | 111 | | return CompensacionesPorPersona.TryGetValue(personaId, out var items) |
| | 43 | 112 | | ? items |
| | 43 | 113 | | : Array.Empty<ItemLoteCompensacion>(); |
| | | 114 | | } |
| | | 115 | | |
| | | 116 | | public NovedadPeriodo? ObtenerNovedad(long personaId) |
| | | 117 | | { |
| | 1 | 118 | | return NovedadesPorPersona.TryGetValue(personaId, out var novedades) |
| | 1 | 119 | | ? novedades.FirstOrDefault() |
| | 1 | 120 | | : null; |
| | | 121 | | } |
| | | 122 | | |
| | | 123 | | /// <summary> |
| | | 124 | | /// Retorna la novedad de tipo 'dias_eximidos' para el prorrateo salarial. |
| | | 125 | | /// 'subsidio_enfermedad' no reduce el sueldo base — tiene su propio cálculo (pendiente). |
| | | 126 | | /// </summary> |
| | | 127 | | public NovedadPeriodo? ObtenerNovedadEximidos(long personaId) |
| | | 128 | | { |
| | 18 | 129 | | if (!NovedadesPorPersona.TryGetValue(personaId, out var novedades)) |
| | 15 | 130 | | return null; |
| | 6 | 131 | | return novedades.FirstOrDefault(n => n.Tipo == "dias_eximidos"); |
| | | 132 | | } |
| | | 133 | | |
| | | 134 | | public IReadOnlyList<NovedadPeriodo> ObtenerNovedades(long personaId) |
| | | 135 | | { |
| | 42 | 136 | | return NovedadesPorPersona.TryGetValue(personaId, out var novedades) |
| | 42 | 137 | | ? novedades |
| | 42 | 138 | | : Array.Empty<NovedadPeriodo>(); |
| | | 139 | | } |
| | | 140 | | |
| | | 141 | | public CompensacionDiferenciaAscenso? ObtenerDiferenciaAscenso(long personaId) |
| | | 142 | | { |
| | 42 | 143 | | return CompensacionesDiferenciaAscensoPorPersona.TryGetValue(personaId, out var diff) |
| | 42 | 144 | | ? diff |
| | 42 | 145 | | : null; |
| | | 146 | | } |
| | | 147 | | |
| | | 148 | | public IReadOnlyList<DescuentoPersonalPeriodo> ObtenerDescuentosPersonales(long personaId) |
| | | 149 | | { |
| | 0 | 150 | | return DescuentosPersonalesPorPersona.TryGetValue(personaId, out var descuentos) |
| | 0 | 151 | | ? descuentos |
| | 0 | 152 | | : Array.Empty<DescuentoPersonalPeriodo>(); |
| | | 153 | | } |
| | | 154 | | |
| | | 155 | | public IReadOnlyList<FictoPersona> ObtenerFictos(long personaId) |
| | | 156 | | { |
| | 44 | 157 | | return FictosPorPersona.TryGetValue(personaId, out var fictos) |
| | 44 | 158 | | ? fictos |
| | 44 | 159 | | : Array.Empty<FictoPersona>(); |
| | | 160 | | } |
| | | 161 | | } |