| | | 1 | | using FAU.Entidades; |
| | | 2 | | |
| | | 3 | | namespace FAU.Logica.DTOs; |
| | | 4 | | |
| | | 5 | | public sealed class InsumosPeriodo |
| | | 6 | | { |
| | 58 | 7 | | public long PeriodoId { get; init; } |
| | 871 | 8 | | public ParametroPeriodo ParametroPeriodo { get; init; } = null!; |
| | 1725 | 9 | | public IReadOnlyDictionary<long, IReadOnlyDictionary<int, RemuneracionGrado>> RemuneracionesPorGrado { get; init; } |
| | 188 | 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, retención, comedor) |
| | 108 | 39 | | public IReadOnlyDictionary<long, IReadOnlyList<DescuentoPersonalPeriodo>> DescuentosPersonalesPorPersona { get; init |
| | | 40 | | |
| | | 41 | | public RemuneracionGrado? ObtenerRemuneracion(long gradoId, int codigoItem) |
| | | 42 | | { |
| | 1580 | 43 | | if (RemuneracionesPorGrado.TryGetValue(gradoId, out var items) && items.TryGetValue(codigoItem, out var remunera |
| | | 44 | | { |
| | 171 | 45 | | return remuneracion; |
| | | 46 | | } |
| | | 47 | | |
| | 1409 | 48 | | return null; |
| | | 49 | | } |
| | | 50 | | |
| | | 51 | | /// <summary> |
| | | 52 | | /// Retorna la tasa mínima registrada para un ítem entre todos los grados. |
| | | 53 | | /// Usado para obtener la tasa de subalterno del progresivo (044.001 = $114.01/año) |
| | | 54 | | /// cuando hay que calcular el tramo de tropa previo al ascenso a oficial. |
| | | 55 | | /// La tasa mínima corresponde siempre a los grados de tropa/subalterno. |
| | | 56 | | /// </summary> |
| | | 57 | | public decimal ObtenerTasaMinimaProgresivo(int codigoItem) |
| | | 58 | | { |
| | 0 | 59 | | var minRate = 0m; |
| | 0 | 60 | | foreach (var gradoItems in RemuneracionesPorGrado.Values) |
| | | 61 | | { |
| | 0 | 62 | | if (gradoItems.TryGetValue(codigoItem, out var rem) && rem.Monto > 0) |
| | | 63 | | { |
| | 0 | 64 | | if (minRate == 0m || rem.Monto < minRate) |
| | 0 | 65 | | minRate = rem.Monto; |
| | | 66 | | } |
| | | 67 | | } |
| | 0 | 68 | | return minRate; |
| | | 69 | | } |
| | | 70 | | |
| | | 71 | | public TablaPermanencia? ObtenerPermanencia(long escalafonId, long gradoId, int mesesServicio, bool riesgoVuelo) |
| | | 72 | | { |
| | 44 | 73 | | if (PermanenciasPorEscalafon.TryGetValue(escalafonId, out var filas)) |
| | | 74 | | { |
| | | 75 | | // Lógica legacy (SUM33106.PRG / CALC_HAB.PRG): |
| | | 76 | | // Recorre los tramos mientras tiempo_pm (MesesHasta) <= meses del funcionario |
| | | 77 | | // y conserva el último que cumplió la condición (monto creciente por antigüedad). |
| | 3 | 78 | | return filas |
| | 3 | 79 | | .Where(p => p.GradoId == gradoId) |
| | 3 | 80 | | .Where(p => p.AplicaRiesgoVuelo == riesgoVuelo) |
| | 3 | 81 | | .Where(p => p.MesesHasta <= mesesServicio) |
| | 3 | 82 | | .OrderByDescending(p => p.MesesHasta) |
| | 3 | 83 | | .FirstOrDefault(); |
| | | 84 | | } |
| | | 85 | | |
| | 41 | 86 | | return null; |
| | | 87 | | } |
| | | 88 | | |
| | | 89 | | /// <summary> |
| | | 90 | | /// Retorna el tramo de Sanidad Militar cuyo rango [Desde, Hasta] contiene la base imponible. |
| | | 91 | | /// Hasta == null representa el último tramo (sin tope superior). |
| | | 92 | | /// </summary> |
| | | 93 | | public TramoSanidadMilitar? ObtenerTramoSanidad(decimal baseImponible) |
| | | 94 | | { |
| | 50 | 95 | | return TramosSanidad.FirstOrDefault(t => |
| | 64 | 96 | | baseImponible >= t.Desde && (t.Hasta is null || baseImponible <= t.Hasta)); |
| | | 97 | | } |
| | | 98 | | |
| | | 99 | | public IReadOnlyList<BeneficioSocial> ObtenerBeneficios(long personaId) |
| | | 100 | | { |
| | 44 | 101 | | return BeneficiosPorPersona.TryGetValue(personaId, out var beneficios) |
| | 44 | 102 | | ? beneficios |
| | 44 | 103 | | : Array.Empty<BeneficioSocial>(); |
| | | 104 | | } |
| | | 105 | | |
| | | 106 | | public IReadOnlyList<ItemLoteCompensacion> ObtenerCompensaciones(long personaId) |
| | | 107 | | { |
| | 43 | 108 | | return CompensacionesPorPersona.TryGetValue(personaId, out var items) |
| | 43 | 109 | | ? items |
| | 43 | 110 | | : Array.Empty<ItemLoteCompensacion>(); |
| | | 111 | | } |
| | | 112 | | |
| | | 113 | | public NovedadPeriodo? ObtenerNovedad(long personaId) |
| | | 114 | | { |
| | 1 | 115 | | return NovedadesPorPersona.TryGetValue(personaId, out var novedades) |
| | 1 | 116 | | ? novedades.FirstOrDefault() |
| | 1 | 117 | | : null; |
| | | 118 | | } |
| | | 119 | | |
| | | 120 | | /// <summary> |
| | | 121 | | /// Retorna la novedad de tipo 'dias_eximidos' para el prorrateo salarial. |
| | | 122 | | /// 'subsidio_enfermedad' no reduce el sueldo base — tiene su propio cálculo (pendiente). |
| | | 123 | | /// </summary> |
| | | 124 | | public NovedadPeriodo? ObtenerNovedadEximidos(long personaId) |
| | | 125 | | { |
| | 18 | 126 | | if (!NovedadesPorPersona.TryGetValue(personaId, out var novedades)) |
| | 15 | 127 | | return null; |
| | 6 | 128 | | return novedades.FirstOrDefault(n => n.Tipo == "dias_eximidos"); |
| | | 129 | | } |
| | | 130 | | |
| | | 131 | | public IReadOnlyList<NovedadPeriodo> ObtenerNovedades(long personaId) |
| | | 132 | | { |
| | 42 | 133 | | return NovedadesPorPersona.TryGetValue(personaId, out var novedades) |
| | 42 | 134 | | ? novedades |
| | 42 | 135 | | : Array.Empty<NovedadPeriodo>(); |
| | | 136 | | } |
| | | 137 | | |
| | | 138 | | public CompensacionDiferenciaAscenso? ObtenerDiferenciaAscenso(long personaId) |
| | | 139 | | { |
| | 42 | 140 | | return CompensacionesDiferenciaAscensoPorPersona.TryGetValue(personaId, out var diff) |
| | 42 | 141 | | ? diff |
| | 42 | 142 | | : null; |
| | | 143 | | } |
| | | 144 | | |
| | | 145 | | public IReadOnlyList<DescuentoPersonalPeriodo> ObtenerDescuentosPersonales(long personaId) |
| | | 146 | | { |
| | 0 | 147 | | return DescuentosPersonalesPorPersona.TryGetValue(personaId, out var descuentos) |
| | 0 | 148 | | ? descuentos |
| | 0 | 149 | | : Array.Empty<DescuentoPersonalPeriodo>(); |
| | | 150 | | } |
| | | 151 | | } |